Commit 34934dc29701640ec00bb4c5cbe654b8d975118a

Authored by Bartłomiej Nitoń
1 parent aca83149

Add "text" charfilter configuration type.

@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <modelVersion>4.0.0</modelVersion> 24 <modelVersion>4.0.0</modelVersion>
25 <groupId>org.textexploration.mtas</groupId> 25 <groupId>org.textexploration.mtas</groupId>
26 <artifactId>mtas</artifactId> 26 <artifactId>mtas</artifactId>
27 - <version>7.4.0.1-SNAPSHOT</version> 27 + <version>7.5.0.0-IPI-SNAPSHOT</version>
28 <packaging>jar</packaging> 28 <packaging>jar</packaging>
29 <licenses> 29 <licenses>
30 <license> 30 <license>
src/main/java/mtas/analysis/util/MtasCharFilterFactory.java
@@ -39,6 +39,9 @@ public class MtasCharFilterFactory extends CharFilterFactory @@ -39,6 +39,9 @@ public class MtasCharFilterFactory extends CharFilterFactory
39 39
40 /** The Constant VALUE_TYPE_FILE. */ 40 /** The Constant VALUE_TYPE_FILE. */
41 public static final String VALUE_TYPE_FILE = "file"; 41 public static final String VALUE_TYPE_FILE = "file";
  42 +
  43 + /** The Constant VALUE_TYPE_TEXT. */
  44 + public static final String VALUE_TYPE_TEXT = "text";
42 45
43 /** The config argument. */ 46 /** The config argument. */
44 String configArgument; 47 String configArgument;
@@ -249,6 +252,14 @@ public class MtasCharFilterFactory extends CharFilterFactory @@ -249,6 +252,14 @@ public class MtasCharFilterFactory extends CharFilterFactory
249 } catch (MtasParserException e) { 252 } catch (MtasParserException e) {
250 throw new IOException(e); 253 throw new IOException(e);
251 } 254 }
  255 + } else if (config.attributes
  256 + .get(MtasConfiguration.CHARFILTER_CONFIGURATION_TYPE)
  257 + .equals(VALUE_TYPE_TEXT)) {
  258 + try {
  259 + return fetchData.getText();
  260 + } catch (MtasParserException e) {
  261 + throw new IOException(e);
  262 + }
252 } else { 263 } else {
253 return fetchData.getDefault(); 264 return fetchData.getDefault();
254 } 265 }
src/main/java/mtas/analysis/util/MtasFetchData.java
@@ -143,6 +143,22 @@ public class MtasFetchData { @@ -143,6 +143,22 @@ public class MtasFetchData {
143 throw new MtasParserException("no valid file: " + file); 143 throw new MtasParserException("no valid file: " + file);
144 } 144 }
145 } 145 }
  146 +
  147 + /**
  148 + * Gets the text.
  149 + *
  150 + * @return the text
  151 + * @throws MtasParserException the mtas parser exception
  152 + */
  153 + public Reader getText()
  154 + throws MtasParserException {
  155 + String text = getString();
  156 + if ((text != null) && !text.equals("")) {
  157 + return new StringReader(text);
  158 + } else {
  159 + throw new MtasParserException("no valid text: " + text);
  160 + }
  161 + }
146 162
147 /** 163 /**
148 * Gets the default. 164 * Gets the default.