Package org.apache.jackrabbit.oak.benchmark

Examples of org.apache.jackrabbit.oak.benchmark.ReadManyTest$Content


      final CDATA cdata) throws XMLStreamException {
    final List<CDATA> list = Collections.singletonList(cdata);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        printCDATA(out, fstack, new CDATA(walker.text()));
      } else if (c.getCType() == CType.CDATA) {
        printCDATA(out, fstack, (CDATA)c);
      }
    }
    out.flush();
  }
View Full Code Here


      final Text text) throws XMLStreamException {
    final List<Text> list = Collections.singletonList(text);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        printText(out, fstack, new Text(walker.text()));
      } else if (c.getCType() == CType.Text) {
        printText(out, fstack, (Text)c);
      }
    }
    out.flush();
  }
View Full Code Here

    }
    Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      while (walker.hasNext()) {
       
        final Content c = walker.next();
        // we do not ignore Text-like things in the Document.
        // the walker creates the indenting for us.
        if (c == null) {
          // but, what we do is ensure it is all whitespace, and not CDATA
          final String padding = walker.text();
          if (padding != null && Verifier.isAllXMLWhitespace(padding) &&
              !walker.isCDATA()) {
            // we do not use the escaping or text* method because this
            // content is outside of the root element, and thus is not
            // strict text.
            out.writeCharacters(padding);
          }
        } else {
          switch (c.getCType()) {
            case Comment :
              printComment(out, fstack, (Comment)c);
              break;
            case DocType :
              printDocType(out, fstack, (DocType)c);
View Full Code Here

  protected void printContent(final XMLStreamWriter out,
      final FormatStack fstack, final NamespaceStack nstack,
      final Walker walker) throws XMLStreamException {

    while (walker.hasNext()) {
      final Content content = walker.next();
     
      if (content == null) {
        if (walker.isCDATA()) {
          printCDATA(out, fstack, new CDATA(walker.text()));
        } else {
          printText(out, fstack, new Text(walker.text()));
        }
      } else {
        switch (content.getCType()) {
          case CDATA:
            printCDATA(out, fstack, (CDATA) content);
            break;
          case Comment:
            printComment(out, fstack, (Comment) content);
            break;
          case Element:
            printElement(out, fstack, nstack, (Element) content);
            break;
          case EntityRef:
            printEntityRef(out, fstack, (EntityRef) content);
            break;
          case ProcessingInstruction:
            printProcessingInstruction(out, fstack,
                (ProcessingInstruction) content);
            break;
          case Text:
            printText(out, fstack, (Text) content);
            break;
          case DocType:
            printDocType(out, fstack, (DocType) content);
            break;
          default:
            throw new IllegalStateException(
                "Unexpected Content " + content.getCType());
   
        }
      }
    }
View Full Code Here

      assertNotNull(ap);
      assertNotNull(bp);
      assertEquals(ap.getClass(), bp.getClass());
      assertTrue(ap != bp);
      if (ap instanceof Content) {
        final Content a = (Content)ap;
        final Content b = (Content)bp;
        if (a.getParent() != null) {
          assertTrue(a.getParent() != b.getParent());
        }
       
        switch (a.getCType()) {
          case Text:
            assertEquals(a.getValue(), b.getValue());
            break;
          case CDATA:
            assertEquals(a.getValue(), b.getValue());
            break;
          case Comment:
            assertEquals(((Comment)a).getText(), ((Comment)b).getText());
            break;
          case DocType:
            DocType da = (DocType)a;
            DocType db = (DocType)b;
            assertEquals(da.getElementName(), db.getElementName());
            assertEquals(da.getPublicID(), db.getPublicID());
            assertEquals(da.getSystemID(), db.getSystemID());
            assertEquals(da.getInternalSubset(), db.getInternalSubset());
            break;
          case Element:
            Element ea = (Element)a;
            Element eb = (Element)b;
            assertEquals(ea.getName(), eb.getName());
            compare(ea.getAttributes(), eb.getAttributes());
            assertEquals(ea.getNamespacesInScope(), eb.getNamespacesInScope());
              final int sz = ea.getContentSize();
              assertTrue(sz == eb.getContentSize());
              for (int i = 0; i < sz; i++) {
                compare(ea.getContent(i), eb.getContent(i));
              }
            break;
          case EntityRef:
            assertEquals(((EntityRef)a).getName(), ((EntityRef)b).getName());
            break;
          case ProcessingInstruction:
            ProcessingInstruction pa = (ProcessingInstruction)a;
            ProcessingInstruction pb = (ProcessingInstruction)b;
            assertEquals(pa.getTarget(), pb.getTarget());
            assertEquals(pa.getData(), pb.getData());
            break;
        }
      } else if (ap instanceof Attribute) {
        compare ((Attribute)ap, (Attribute)bp);
      } else if (ap instanceof Document) {
        Document a = (Document)ap;
        Document b = (Document)bp;
        assertEquals(a.getBaseURI(), b.getBaseURI());
        final int sz = a.getContentSize();
        assertTrue(sz == b.getContentSize());
        for (int i = 0; i < sz; i++) {
          compare(a.getContent(i), b.getContent(i));
        }
      }
    }
View Full Code Here

          Element emt = processElementFragment(factory, stream);
          stream.next();
          return emt;

        case DTD:
          Content dt = DTDParser.parse(stream.getText(), factory);
          stream.next();
          return dt;

        case CDATA:
          Content cd = factory.cdata(stream.getText());
          stream.next();
          return cd;

        case SPACE:
        case CHARACTERS:
          Content txt = factory.text(stream.getText());
          stream.next();
          return txt;

        case COMMENT:
          Content comment = factory.comment(stream.getText());
          stream.next();
          return comment;

        case ENTITY_REFERENCE:
          Content er = factory.entityRef(stream.getLocalName());
          stream.next();
          return er;

        case PROCESSING_INSTRUCTION:
          Content pi = factory.processingInstruction(
              stream.getPITarget(), stream.getPIData());
          stream.next();
          return pi;

        default:
View Full Code Here

    public static String textValueOf(Element htmlElement) {
        List<Content> htmlContent = htmlElement.getContent();
        if(htmlContent.isEmpty()) {
            return null;
        }
        Content content = htmlContent.get(0);
        if(!(content instanceof Text)) {
            return null;
        }
        Text htmlText = (Text) content;
        return normalized(htmlText.getValue());
View Full Code Here

            //
            //  In many cases these are the same.  [linktext|linkref].
            //
            if( VariableManager.isVariableLink( linktext ) )
            {
                Content el = new VariableContent(linktext);

                addElement( el );
            }
            else if( isExternalLink( linkref ) )
            {
View Full Code Here

            int idxOfFirstContent = 0;
            int count = 0;

            for( Iterator i = kids.iterator(); i.hasNext(); count++ )
            {
                Content c = (Content) i.next();
                if( c instanceof Element )
                {
                    String name = ((Element)c).getName();
                    if( isBlockLevel(name) ) break;
                }

                if( !(c instanceof ProcessingInstruction) )
                {
                    ls.add( c );
                    if( idxOfFirstContent == 0 ) idxOfFirstContent = count;
                }
            }

            //
            //  If there were any elements, then add a new <p> (unless it would
            //  be an empty one)
            //
            if( ls.size() > 0 )
            {
                Element newel = new Element("p");

                for( Iterator i = ls.iterator(); i.hasNext(); )
                {
                    Content c = (Content) i.next();

                    c.detach();
                    newel.addContent(c);
                }

                //
                // Make sure there are no empty <p/> tags added.
View Full Code Here

    public static String textValueOf(Element htmlElement) {
        List<Content> htmlContent = htmlElement.getContent();
        if(htmlContent.isEmpty()) {
            return null;
        }
        Content content = htmlContent.get(0);
        if(!(content instanceof Text)) {
            return null;
        }
        Text htmlText = (Text) content;
        return normalized(htmlText.getValue());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.benchmark.ReadManyTest$Content

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.