Class CmsXmlPageFactory


  • public final class CmsXmlPageFactory
    extends java.lang.Object
    Provides factory methods to unmarshal (read) an XML page object.

    Since:
    6.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.dom4j.Document createDocument​(java.util.Locale locale)
      Creates a valid XML page document, containing one empty element in the given locale.
      static java.lang.String createDocument​(java.util.Locale locale, java.lang.String encoding)
      Creates a valid XML page String representation, containing one empty element in the given locale.
      static CmsXmlPage unmarshal​(byte[] xmlData, java.lang.String encoding, org.xml.sax.EntityResolver resolver)
      Factory method to unmarshal (read) a XML page instance from a byte array that contains XML data.
      static CmsXmlPage unmarshal​(java.lang.String xmlData, java.lang.String encoding, org.xml.sax.EntityResolver resolver)
      Factory method to unmarshal (read) a XML page instance from a String that contains XML data.
      static I_CmsXmlDocument unmarshal​(CmsObject cms, java.lang.String filename, javax.servlet.ServletRequest req)
      Factory method to unmarshal (read) a XML document instance from a filename in the VFS, using the request attributes as cache.
      static CmsXmlPage unmarshal​(CmsObject cms, CmsFile file)
      Factory method to unmarshal (read) a XML page instance from a OpenCms VFS file that contains XML data.
      static CmsXmlPage unmarshal​(CmsObject cms, CmsFile file, boolean keepEncoding)
      Factory method to unmarshal (read) a XML page instance from a OpenCms VFS file that contains XML data, using wither the encoding set in the XML file header, or the encoding set in the VFS file property.
      static CmsXmlPage unmarshal​(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req)
      Factory method to unmarshal (read) a XML page instance from a resource, using the request attributes as cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createDocument

        public static org.dom4j.Document createDocument​(java.util.Locale locale)
        Creates a valid XML page document, containing one empty element in the given locale.

        Parameters:
        locale - the locale to create the XML page for
        Returns:
        a valid XML page document
      • createDocument

        public static java.lang.String createDocument​(java.util.Locale locale,
                                                      java.lang.String encoding)
        Creates a valid XML page String representation, containing one empty element in the given locale.

        Parameters:
        locale - the locale to create the XML page for
        encoding - the encoding to use when creating the String from the XML
        Returns:
        a valid XML page document as a String
      • unmarshal

        public static CmsXmlPage unmarshal​(byte[] xmlData,
                                           java.lang.String encoding,
                                           org.xml.sax.EntityResolver resolver)
                                    throws CmsXmlException
        Factory method to unmarshal (read) a XML page instance from a byte array that contains XML data.

        When unmarshalling, the encoding is read directly from the XML header. The given encoding is used only when marshalling the XML again later.

        Parameters:
        xmlData - the XML data in a byte array
        encoding - the encoding to use when marshalling the XML page later
        resolver - the XML entity resolver to use
        Returns:
        a XML page instance unmarshalled from the byte array
        Throws:
        CmsXmlException - if something goes wrong
      • unmarshal

        public static CmsXmlPage unmarshal​(CmsObject cms,
                                           CmsFile file)
                                    throws CmsXmlException
        Factory method to unmarshal (read) a XML page instance from a OpenCms VFS file that contains XML data.

        Parameters:
        cms - the current cms object
        file - the file with the XML data to unmarshal
        Returns:
        a XML page instance unmarshalled from the provided file
        Throws:
        CmsXmlException - if something goes wrong
      • unmarshal

        public static CmsXmlPage unmarshal​(CmsObject cms,
                                           CmsFile file,
                                           boolean keepEncoding)
                                    throws CmsXmlException
        Factory method to unmarshal (read) a XML page instance from a OpenCms VFS file that contains XML data, using wither the encoding set in the XML file header, or the encoding set in the VFS file property.

        If you are not sure about the implications of the encoding issues, use unmarshal(CmsObject, CmsFile) instead.

        Parameters:
        cms - the current OpenCms user context
        file - the file with the XML data to unmarshal
        keepEncoding - if true, the encoding spefified in the XML header is used, otherwise the encoding from the VFS file property is used
        Returns:
        a XML page instance unmarshalled from the provided file
        Throws:
        CmsXmlException - if something goes wrong
      • unmarshal

        public static CmsXmlPage unmarshal​(CmsObject cms,
                                           CmsResource resource,
                                           javax.servlet.ServletRequest req)
                                    throws CmsException
        Factory method to unmarshal (read) a XML page instance from a resource, using the request attributes as cache.

        Parameters:
        cms - the current OpenCms user context
        resource - the resource to unmarshal
        req - the current request
        Returns:
        the unmarshaled XML page, or null if the given resource was not of type CmsResourceTypeXmlPage
        Throws:
        CmsException - in something goes wrong
      • unmarshal

        public static I_CmsXmlDocument unmarshal​(CmsObject cms,
                                                 java.lang.String filename,
                                                 javax.servlet.ServletRequest req)
                                          throws CmsException
        Factory method to unmarshal (read) a XML document instance from a filename in the VFS, using the request attributes as cache.

        Parameters:
        cms - the current OpenCms user context
        filename - the filename of the resource to unmarshal
        req - the current request
        Returns:
        the unmarshaled XML document, or null if the given resource was not of type I_CmsXmlDocument
        Throws:
        CmsException - in something goes wrong
      • unmarshal

        public static CmsXmlPage unmarshal​(java.lang.String xmlData,
                                           java.lang.String encoding,
                                           org.xml.sax.EntityResolver resolver)
                                    throws CmsXmlException
        Factory method to unmarshal (read) a XML page instance from a String that contains XML data.

        When unmarshalling, the encoding is read directly from the XML header. The given encoding is used only when marshalling the XML again later.

        Parameters:
        xmlData - the XML data in a String
        encoding - the encoding to use when marshalling the XML page later
        resolver - the XML entity resolver to use
        Returns:
        a XML page instance unmarshalled from the String
        Throws:
        CmsXmlException - if something goes wrong