Revision 53171
Added by Claudio Atzori over 5 years ago
FieldValueImpl.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.pace.model; |
2 | 2 |
|
3 |
import java.net.MalformedURLException; |
|
4 |
import java.net.URL; |
|
3 | 5 |
import java.util.Iterator; |
4 | 6 |
import java.util.List; |
5 | 7 |
|
6 | 8 |
import eu.dnetlib.pace.config.Type; |
7 | 9 |
import org.apache.commons.collections.iterators.SingletonIterator; |
10 |
import org.apache.commons.lang.StringUtils; |
|
8 | 11 |
|
9 | 12 |
/** |
10 | 13 |
* The Class FieldValueImpl. |
... | ... | |
50 | 53 |
case List: |
51 | 54 |
List<?> list = (List<?>) value; |
52 | 55 |
return list.isEmpty() || ((FieldValueImpl) list.get(0)).isEmpty(); |
56 |
case URL: |
|
57 |
String str = value.toString(); |
|
58 |
return StringUtils.isNotBlank(str) && isValidURL(str); |
|
53 | 59 |
default: |
54 | 60 |
return true; |
55 | 61 |
} |
56 | 62 |
} |
57 | 63 |
|
64 |
private boolean isValidURL(final String s) { |
|
65 |
try { |
|
66 |
new URL(value.toString()); |
|
67 |
return true; |
|
68 |
} catch (MalformedURLException e) { |
|
69 |
return true; |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
58 | 73 |
/* |
59 | 74 |
* (non-Javadoc) |
60 | 75 |
* |
Also available in: Unified diff
introduced url type and UrlMatcher