예제 #1
0
 public OMProcessingInstruction createOMProcessingInstruction(
     OMContainer parent, String piTarget, String piData) {
   ProcessingInstructionImpl pi =
       new ProcessingInstructionImpl(getDocumentFromParent(parent), piTarget, piData, this);
   parent.addChild(pi);
   return pi;
 }
예제 #2
0
 /**
  * This method will check whether the text can be optimizable using IS_BINARY flag. If that is set
  * then we try to get the data handler.
  *
  * @param omContainer
  * @param textType
  * @return omNode
  */
 private OMNode createOMText(OMContainer omContainer, int textType) {
   if (dataHandlerReader != null && dataHandlerReader.isBinary()) {
     Object dataHandlerObject;
     if (dataHandlerReader.isDeferred()) {
       dataHandlerObject = dataHandlerReader.getDataHandlerProvider();
     } else {
       try {
         dataHandlerObject = dataHandlerReader.getDataHandler();
       } catch (XMLStreamException ex) {
         throw new OMException(ex);
       }
     }
     OMText text = omfactory.createOMText(dataHandlerObject, dataHandlerReader.isOptimized());
     String contentID = dataHandlerReader.getContentID();
     if (contentID != null) {
       text.setContentID(contentID);
     }
     omContainer.addChild(text);
     return text;
   } else {
     // Some parsers (like Woodstox) parse text nodes lazily and may throw a
     // RuntimeException in getText()
     String text;
     try {
       text = parser.getText();
     } catch (RuntimeException ex) {
       parserException = ex;
       throw ex;
     }
     return omfactory.createOMText(omContainer, text, textType);
   }
 }
예제 #3
0
 /**
  * Creates an OMDOM Text node, adds it to the give parent element and returns it.
  *
  * @see org.apache.axiom.om.OMFactory#createOMText(OMContainer, String, String, boolean)
  */
 public OMText createOMText(OMContainer parent, String s, String mimeType, boolean optimize) {
   TextImpl text =
       new TextImpl(
           (DocumentImpl) ((ElementImpl) parent).getOwnerDocument(), s, mimeType, optimize, this);
   parent.addChild(text);
   return text;
 }
예제 #4
0
 /**
  * Creates a new OMDOM Text node with the given value and appends it to the given parent element.
  *
  * @see org.apache.axiom.om.OMFactory#createOMText( org.apache.axiom.om.OMElement,String)
  */
 public OMText createOMText(OMContainer parent, String text) {
   if (parent instanceof DocumentImpl) {
     throw new OMHierarchyException("DOM doesn't support text nodes as children of a document");
   }
   TextImpl txt =
       new TextImpl((DocumentImpl) ((ElementImpl) parent).getOwnerDocument(), text, this);
   parent.addChild(txt);
   return txt;
 }
예제 #5
0
 public OMComment createOMComment(OMContainer parent, String content) {
   CommentImpl comment = new CommentImpl(getDocumentFromParent(parent), content, this);
   parent.addChild(comment);
   return comment;
 }
예제 #6
0
 public OMText createOMText(String contentID, OMContainer parent, OMXMLParserWrapper builder) {
   TextImpl text = new TextImpl(contentID, parent, builder, this);
   parent.addChild(text);
   return text;
 }
예제 #7
0
 /** Removes the contents (i.e. children) of the container. */
 public static void removeContents(OMContainer container) {
   for (Iterator<?> iterator = container.getChildren(); iterator.hasNext(); ) {
     iterator.next();
     iterator.remove();
   }
 }