Revision 5b2db12a
Added by Andreas Müller about 3 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/StripTagsConverter.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
18 | 18 |
|
19 | 19 |
public class StripTagsConverter implements CustomConverter { |
20 | 20 |
|
21 |
public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) { |
|
21 |
@Override |
|
22 |
public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) { |
|
22 | 23 |
if (source == null) { |
23 | 24 |
return null; |
24 | 25 |
} |
25 |
if (source instanceof String) {
|
|
26 |
if (source instanceof String) { |
|
26 | 27 |
Reader reader = new RemoveHTMLReader(new StringReader((String)source)); |
27 | 28 |
StringBuilder stringBuilder = new StringBuilder(); |
28 | 29 |
int charValue; |
... | ... | |
30 | 31 |
while ((charValue = reader.read()) != -1) { |
31 | 32 |
stringBuilder.append((char)charValue); |
32 | 33 |
} |
34 |
reader.close(); |
|
33 | 35 |
} catch (IOException e) {return e.toString();} |
34 | 36 |
return stringBuilder.toString(); |
35 | 37 |
} else { |
... | ... | |
37 | 39 |
+ destination + " and " + source); |
38 | 40 |
} |
39 | 41 |
} |
40 |
|
|
41 |
} |
|
42 |
} |
Also available in: Unified diff
cleanup