abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r470973 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/filter/ core/src/main/java/org/apache/abdera/parser/ core/src/main/java/org/apache/abdera/util/ core/src/main/java/org/apache/abdera/util/filter/ examples/src/m...
Date Fri, 03 Nov 2006 20:16:10 GMT
Author: jmsnell
Date: Fri Nov  3 12:16:09 2006
New Revision: 470973

URL: http://svn.apache.org/viewvc?view=rev&rev=470973
Log:
Pull out TextFilter. This is something we can add back in fairly easily later if it becomes
useful.

Removed:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/filter/TextFilter.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/filter/NonOpTextFilter.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/TextFilterExample.java
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java?view=diff&rev=470973&r1=470972&r2=470973
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
Fri Nov  3 12:16:09 2006
@@ -19,8 +19,6 @@
 
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.filter.ParseFilter;
-import org.apache.abdera.filter.TextFilter;
-
 
 /**
  * Parser options are used to modify the behavior of the parser. 
@@ -64,18 +62,6 @@
    * will only pay attention to elements whose QName's appear in the filter list.
    */
   void setParseFilter(ParseFilter parseFilter);
-  
-  /**
-   * Returns the TextFilter.  The text filter provides filtering for all
-   * character strings encountered during the parse process.
-   */
-  TextFilter getTextFilter();
-
-  /**
-   * Sets the TextFilter.  The text filter provides filtering for all
-   * character strings encountered during the parse process.
-   */
-  void setTextFilter(TextFilter textFilter);
   
   /**
    * Returns true if the parser should attempt to automatically detect the 

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java?view=diff&rev=470973&r1=470972&r2=470973
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
Fri Nov  3 12:16:09 2006
@@ -19,7 +19,6 @@
 
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.filter.ParseFilter;
-import org.apache.abdera.filter.TextFilter;
 import org.apache.abdera.parser.ParserOptions;
 
 /**
@@ -31,7 +30,6 @@
   protected Factory factory = null;
   protected String charset = null;
   protected ParseFilter parseFilter = null;
-  protected TextFilter textFilter = null;
   protected boolean detect = false;
 
   protected abstract void initFactory();
@@ -47,9 +45,6 @@
     if (parseFilter != null)
       copy.parseFilter = (ParseFilter) parseFilter.clone();
     
-    if (textFilter != null)
-      copy.textFilter = (TextFilter) textFilter.clone();
-    
     return copy;
   }
 
@@ -76,14 +71,6 @@
   }
   public void setParseFilter(ParseFilter parseFilter) {
     this.parseFilter = parseFilter;
-  }
-  
-  public TextFilter getTextFilter() {
-    return textFilter;
-  }
-  
-  public void setTextFilter(TextFilter textFilter) {
-    this.textFilter = textFilter;
   }
   
   public boolean getAutodetectCharset() {

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?view=diff&rev=470973&r1=470972&r2=470973
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Fri Nov  3 12:16:09 2006
@@ -23,7 +23,6 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.abdera.filter.ParseFilter;
-import org.apache.abdera.filter.TextFilter;
 import org.apache.abdera.model.Content;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
@@ -139,35 +138,16 @@
   
   private OMNode applyTextFilter(int type) {
     if (parserOptions != null) { 
-      TextFilter filter = parserOptions.getTextFilter();
       ParseFilter parseFilter = parserOptions.getParseFilter();
       if (parseFilter != null) {
-        if (parser.isWhiteSpace() && parseFilter.getIgnoreWhitespace()) return createOMText("",type);
-      }
-      if (filter != null) {
-        String value = parser.getText();
-        if (!lastNode.isComplete())
-          value = filter.applyFilter(
-            parser.getTextCharacters(), 
-            parser.getTextStart(), 
-            parser.getTextLength(), 
-            (Element)lastNode);
-        return createOMText(value, type);
+        if (parser.isWhiteSpace() && 
+            parseFilter.getIgnoreWhitespace()) 
+              return createOMText("",type);
       }
     }
     return createOMText(type);
   }
   
-  private String applyAttributeTextFilter(String value, QName attribute, Element parent)
{
-    if (parserOptions != null) { 
-      TextFilter filter = parserOptions.getTextFilter();
-      if (filter != null) {
-        return filter.applyFilter(value, parent, attribute);
-      }
-    }
-    return value;
-  }
-  
   private int getNextElementToParse() 
     throws XMLStreamException{
       int token = parser.next();
@@ -310,9 +290,7 @@
                 namespace = node.declareNamespace(uri, prefix);
             }
         }
-        String value = applyAttributeTextFilter(
-          parser.getAttributeValue(i), 
-          attr, (Element)node);
+        String value = parser.getAttributeValue(i);
         node.addAttribute(parser.getAttributeLocalName(i),
                 value, namespace);
       }

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java?view=diff&rev=470973&r1=470972&r2=470973
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
Fri Nov  3 12:16:09 2006
@@ -35,9 +35,7 @@
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.filter.ListParseFilter;
-import org.apache.abdera.filter.TextFilter;
 import org.apache.abdera.model.AtomDate;
-import org.apache.abdera.model.Base;
 import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Content;
@@ -64,7 +62,6 @@
 import org.apache.abdera.util.URIHelper;
 import org.apache.abdera.util.Version;
 import org.apache.abdera.util.filter.BlackListParseFilter;
-import org.apache.abdera.util.filter.NonOpTextFilter;
 import org.apache.abdera.util.filter.WhiteListParseFilter;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
@@ -238,50 +235,6 @@
     assertEquals(entry.getSummary(), "Some text.");
     assertEquals(entry.getSummaryType(), Text.Type.TEXT);
 
-  }
-  
-  public void testTextFilter() throws Exception {
-    
-    TextFilter filter = new NonOpTextFilter() {
-      @Override
-      public String applyFilter(char[] c, int start, int len, Element parent) {
-        QName qname = parent.getQName();
-        Base elparent = parent.getParentElement();
-        String text = new String(c,start,len);
-        if (Constants.NAME.equals(qname)) {
-          text = "Jane Doe";
-        } else if (Constants.TITLE.equals(qname) && elparent instanceof Entry) {
-          text = text.replaceAll("Amok", "Crazy");
-        }
-        return text;
-      }
-    };
-    
-    ParserOptions options = getParser().getDefaultParserOptions();
-    options.setTextFilter(filter);
-    
-    URL url = FOMTest.class.getResource("/simple.xml");
-    InputStream in = url.openStream();
-    Document<Feed> doc = getParser().parse(in, url.toString(), options);
-    Feed feed = doc.getRoot();
-    
-    assertEquals(feed.getTitle(),"Example Feed");
-    assertEquals(feed.getTitleType(), Text.Type.TEXT);
-    assertEquals(feed.getAlternateLink().getResolvedHref().toString(), "http://example.org/");
-    assertNotNull(feed.getUpdated());
-    assertEquals(feed.getAuthor().getName(), "Jane Doe");
-    assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
-    
-    Entry entry = feed.getEntries().get(0);
-
-    assertEquals(entry.getTitle(),"Atom-Powered Robots Run Crazy");
-    assertEquals(entry.getTitleType(), Text.Type.TEXT);
-    assertEquals(entry.getAlternateLink().getResolvedHref().toString(), "http://example.org/2003/12/13/atom03");
-    assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
-    assertNotNull(entry.getUpdated());
-    assertEquals(entry.getSummary(), "Some text.");
-    assertEquals(entry.getSummaryType(), Text.Type.TEXT);
-    
   }
   
   public void testXPath() throws Exception {



Mime
View raw message