Interface CustomXmlDataStorage

All Known Implementing Classes:
CustomXmlDataStorageImpl

public interface CustomXmlDataStorage
Interface to provide access to the data stored in a CustomXmlDataStoragePart. This approach gives the user flexibility as to whether they use eg JAXB or DOM or dom4j to represent and manipulate their data.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String cachedXPathGetString​(java.lang.String xpath, java.lang.String prefixMappings)
    (Unless you are using Saxon as your XPath implementation (XPathFactoryUtil.setxPathFactory)) this uses org.apache.xpath.CachedXPathAPI for better performance, since Apache's old XPathAPI class, have the drawback of instantiating a new XPathContext (and thus building a new DTMManager, and new DTMs) each time it was called.
    void discardCacheXPathObject()
    Use this to null out the org.apache.xpath.CachedXPathAPI object, which you should do if you've changed your source document, or want to reclaim memory.
    CustomXmlDataStorage factory()
    Create this object.
    org.w3c.dom.Document getDocument()
    Write the contents of this object to the org.w3c.dom.Document
    java.lang.String getXML()
    Get the XML as a String.
    void setDocument​(java.io.InputStream is)
    Set the contents of this object from the input stream
    void setDocument​(org.w3c.dom.Document doc)  
    boolean setNodeValueAtXPath​(java.lang.String xpath, java.lang.String value, java.lang.String prefixMappings)  
    void writeDocument​(java.io.OutputStream os)
    Write the contents of this object to the output stream
    java.util.List<org.w3c.dom.Node> xpathGetNodes​(java.lang.String xpathString, java.lang.String prefixMappings)  
    java.lang.String xpathGetString​(java.lang.String xpath, java.lang.String prefixMappings)
    Get the data pointed to by the xpath.
  • Method Details

    • factory

      Create this object.
      Returns:
    • xpathGetString

      java.lang.String xpathGetString​(java.lang.String xpath, java.lang.String prefixMappings) throws Docx4JException
      Get the data pointed to by the xpath. (return what if it points at a non-existent??)
      Parameters:
      xpath -
      Returns:
      Throws:
      Docx4JException
    • cachedXPathGetString

      java.lang.String cachedXPathGetString​(java.lang.String xpath, java.lang.String prefixMappings) throws Docx4JException
      (Unless you are using Saxon as your XPath implementation (XPathFactoryUtil.setxPathFactory)) this uses org.apache.xpath.CachedXPathAPI for better performance, since Apache's old XPathAPI class, have the drawback of instantiating a new XPathContext (and thus building a new DTMManager, and new DTMs) each time it was called. XPathAPIObject instead retains its context as long as the object persists, reusing the DTMs. If you are using Saxon, then the cache won't be used.
      Parameters:
      xpath -
      prefixMappings -
      Returns:
      Throws:
      Docx4JException
      Since:
      3.3.1
      See Also:
      discardCacheXPathObject()
    • discardCacheXPathObject

      void discardCacheXPathObject()
      Use this to null out the org.apache.xpath.CachedXPathAPI object, which you should do if you've changed your source document, or want to reclaim memory.
      Since:
      3.3.1
    • xpathGetNodes

      java.util.List<org.w3c.dom.Node> xpathGetNodes​(java.lang.String xpathString, java.lang.String prefixMappings)
    • setNodeValueAtXPath

      boolean setNodeValueAtXPath​(java.lang.String xpath, java.lang.String value, java.lang.String prefixMappings) throws Docx4JException
      Throws:
      Docx4JException
    • setDocument

      void setDocument​(java.io.InputStream is) throws Docx4JException
      Set the contents of this object from the input stream
      Parameters:
      is -
      Throws:
      Docx4JException
    • setDocument

      void setDocument​(org.w3c.dom.Document doc) throws Docx4JException
      Throws:
      Docx4JException
    • writeDocument

      void writeDocument​(java.io.OutputStream os) throws Docx4JException
      Write the contents of this object to the output stream
      Parameters:
      os -
      Throws:
      Docx4JException
    • getDocument

      org.w3c.dom.Document getDocument() throws Docx4JException
      Write the contents of this object to the org.w3c.dom.Document
      Parameters:
      os -
      Throws:
      Docx4JException
    • getXML

      java.lang.String getXML() throws Docx4JException
      Get the XML as a String.
      Throws:
      Docx4JException
      Since:
      3.0.1