Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf39dabf

Browse files
committed
fix#19, only support String type bean
1 parent8ff438d commitf39dabf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

‎src/main/java/im/nll/data/extractor/Extractors.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ public <T> List<T> asBeanList(EntityListExtractor<T> entityListExtractor) {
443443
//------------ internal --------------//
444444

445445
private <T>TextractBean(Stringhtml,Class<T>clazz) {
446+
// only support String type
447+
if (clazz.equals(String.class)) {
448+
return (T)newString(html);
449+
}
446450
Tentity =Reflect.on(clazz).create().get();
447451
for (Map.Entry<String,List<Extractor>>one :extractorsMap.entrySet()) {
448452
Stringname =one.getKey();

‎src/test/java/im/nll/data/extractor/ExtractorsTest.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
importim.nll.data.extractor.rule.ExtractRule;
88
importorg.junit.Assert;
99
importorg.junit.Before;
10-
importorg.junit.Ignore;
1110
importorg.junit.Test;
1211

1312
importjava.io.IOException;
@@ -242,9 +241,8 @@ public void testExtractByMapToBeanList() throws Exception {
242241
}
243242

244243
@Test
245-
@Ignore
246244
publicvoidtestToBeanListString()throwsException {
247-
//TODO bean class can't be primitive class
245+
//NOTE only support String type
248246
List<String>languages =Extractors.on(listHtml2).split(selector("a.h4.attr(href)"))
249247
.asBeanList(String.class);
250248
Assert.assertNotNull(languages);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp