Package org.apache.abdera.filter

Examples of org.apache.abdera.filter.ParseFilter


    private void mapAttributes() {
        attributeCount = 0;
        int orgAttCount = super.getAttributeCount();
        if (orgAttCount > 0) {
            QName elementQName = super.getName();
            ParseFilter filter = parserOptions.getParseFilter();
            for (int i=0; i<orgAttCount; i++) {
                if (filter.acceptable(elementQName, super.getAttributeName(i))) {
                    if (attributeCount == attributeMap.length) {
                        int[] newAttributeMap = new int[attributeMap.length*2];
                        System.arraycopy(attributeMap, 0, newAttributeMap, 0, attributeMap.length);
                        attributeMap = newAttributeMap;
                    }
View Full Code Here


                        // document with the DTD. Since very few folks actually use DTD's in feeds
                        // right now (and we should likely be encouraging folks not to do so), this
                        // shouldn't be that big of a problem
                        continue;
                    case START_ELEMENT:
                        ParseFilter filter = parserOptions.getParseFilter();
                        if (filter != null && !filter.acceptable(super.getName())) {
                            depthInSkipElement = 1;
                            continue;
                        }
                        translateQName();
                        if (attributeMap != null) {
View Full Code Here

   
    @Test
    public void testIgnoreComments() {
        Parser parser = abdera.getParser();
        ParserOptions options = parser.getDefaultParserOptions();
        ParseFilter filter = new SimpleParseFilter();
        filter.setIgnoreComments(true);
        options.setParseFilter(filter);
        Document<Feed> doc = parser.parse(ParserOptionsTest.class.getResourceAsStream(
                "/parseroptionstest.xml"), options);
        assertTrue(abdera.getXPath().selectNodes("//comment()", doc).isEmpty());
    }
View Full Code Here

   
    @Test
    public void testIgnoreProcessingInstructions() {
        Parser parser = abdera.getParser();
        ParserOptions options = parser.getDefaultParserOptions();
        ParseFilter filter = new SimpleParseFilter();
        filter.setIgnoreProcessingInstructions(true);
        options.setParseFilter(filter);
        Document<Feed> doc = parser.parse(ParserOptionsTest.class.getResourceAsStream(
                "/parseroptionstest.xml"), options);
        assertTrue(abdera.getXPath().selectNodes("//processing-instruction()", doc).isEmpty());
    }
View Full Code Here

   
    @Test
    public void testIgnoreWhitespace() {
        Parser parser = abdera.getParser();
        ParserOptions options = parser.getDefaultParserOptions();
        ParseFilter filter = new SimpleParseFilter();
        filter.setIgnoreWhitespace(true);
        options.setParseFilter(filter);
        Document<Feed> doc = parser.parse(ParserOptionsTest.class.getResourceAsStream(
                "/parseroptionstest.xml"), options);
        assertEquals("", doc.getRoot().getEntries().get(0).getSummary());
    }
View Full Code Here

      document.setCharsetEncoding(enc != null ? enc : "utf-8");
      document.setXMLVersion(
        parser.getVersion() != null ?
          parser.getVersion() : "1.0");
      if (parserOptions != null) {
        ParseFilter parseFilter = parserOptions.getParseFilter();
        if (parseFilter != null) {
          ignoreWhitespace = parseFilter.getIgnoreWhitespace();
          ignoreComments = parseFilter.getIgnoreComments();
          ignorePI = parseFilter.getIgnoreProcessingInstructions();
        }
      }
  }
View Full Code Here

    return ctype;
  }
 
  private boolean isAcceptableToParse(QName qname, boolean attribute) {
    if (parserOptions == null) return true;
    ParseFilter filter = parserOptions.getParseFilter();
    return (filter != null) ?
      (!attribute) ?
         filter.acceptable(qname) :
         filter.acceptable(parser.getName(), qname):
      true;
  }
View Full Code Here

      true;
  }
 
  private OMNode applyTextFilter(int type) {
    if (parserOptions != null) {
      ParseFilter parseFilter = parserOptions.getParseFilter();
      if (parseFilter != null) {
        if (parser.isWhiteSpace() &&
            parseFilter.getIgnoreWhitespace())
              return createOMText("",type);
      }
    }
    return createOMText(type);
  }
View Full Code Here

      document.setCharsetEncoding(enc != null ? enc : "utf-8");
      document.setXMLVersion(
        parser.getVersion() != null ?
          parser.getVersion() : "1.0");
      if (parserOptions != null) {
        ParseFilter parseFilter = parserOptions.getParseFilter();
        if (parseFilter != null) {
          ignoreWhitespace = parseFilter.getIgnoreWhitespace();
          ignoreComments = parseFilter.getIgnoreComments();
          ignorePI = parseFilter.getIgnoreProcessingInstructions();
        }
      }
  }
View Full Code Here

    return ctype;
  }
 
  private boolean isAcceptableToParse(QName qname, boolean attribute) {
    if (parserOptions == null) return true;
    ParseFilter filter = parserOptions.getParseFilter();
    return (filter != null) ?
      (!attribute) ?
         filter.acceptable(qname) :
         filter.acceptable(parser.getName(), qname):
      true;
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.filter.ParseFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.