Class XMPMetaFactory


  • public final class XMPMetaFactory
    extends java.lang.Object
    Creates XMPMeta-instances from an InputStream
    Since:
    30.01.2006
    • Method Detail

      • getSchemaRegistry

        public static XMPSchemaRegistry getSchemaRegistry()
        Returns:
        Returns the singleton instance of the XMPSchemaRegistry.
      • create

        public static XMPMeta create()
        Returns:
        Returns an empty XMPMeta-object.
      • parse

        public static XMPMeta parse​(java.io.InputStream in,
                                    long timeOut)
                             throws XMPException
        Parsing with default options.
        Parameters:
        in - an InputStream
        timeOut - Time in milliseconds for which the delay in InputStream is considered. If timeOut is 0, the InputStream is considered to have no delay.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML, if the parsing fails, if timeOut is negative or the InputStream is not available for timeOut milliseconds.
        See Also:
        parse(InputStream, ParseOptions, long)
      • parse

        public static XMPMeta parse​(java.io.InputStream in,
                                    ParseOptions options,
                                    long timeOut)
                             throws XMPException
        These functions support parsing serialized RDF into an XMP object, and serailizing an XMP object into RDF. The input for parsing may be any valid Unicode encoding. ISO Latin-1 is also recognized, but its use is strongly discouraged. Serialization is always as UTF-8.

        parseFromBuffer() parses RDF from an InputStream. The encoding is recognized automatically.

        Parameters:
        in - an InputStream
        options - Options controlling the parsing.
        The available options are:
        • XMP_REQUIRE_XMPMETA - The <x:xmpmeta> XML element is required around <rdf:RDF>.
        • XMP_STRICT_ALIASING - Do not reconcile alias differences, throw an exception.
        Note:The XMP_STRICT_ALIASING option is not yet implemented.
        timeOut - Time in milliseconds for which the delay in InputStream is considered. If timeOut is 0, the InputStream is considered to have no delay.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML, if the parsing fails, if timeOut is negative or the InputStream is not available for timeOut milliseconds.
      • parse

        public static XMPMeta parse​(java.io.InputStream in,
                                    ParseOptions options)
                             throws XMPException
        These functions support parsing serialized RDF into an XMP object, and serailizing an XMP object into RDF. The input for parsing may be any valid Unicode encoding. ISO Latin-1 is also recognized, but its use is strongly discouraged. Serialization is always as UTF-8.

        parseFromBuffer() parses RDF from an InputStream. The encoding is recognized automatically. By default timeOut is 0. The InputStream is considered to have no delay.

        Parameters:
        in - an InputStream
        options - Options controlling the parsing.
        The available options are:
        • XMP_REQUIRE_XMPMETA - The <x:xmpmeta> XML element is required around <rdf:RDF>.
        • XMP_STRICT_ALIASING - Do not reconcile alias differences, throw an exception.
        Note:The XMP_STRICT_ALIASING option is not yet implemented.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML or if the parsing fails.
      • parseFromString

        public static XMPMeta parseFromString​(java.lang.String packet)
                                       throws XMPException
        Parsing with default options.
        Parameters:
        packet - a String contain an XMP-file.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML or if the parsing fails.
        See Also:
        parse(InputStream)
      • parseFromString

        public static XMPMeta parseFromString​(java.lang.String packet,
                                              ParseOptions options)
                                       throws XMPException
        Creates an XMPMeta-object from a string.
        Parameters:
        packet - a String contain an XMP-file.
        options - Options controlling the parsing.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML or if the parsing fails.
        See Also:
        parseFromString(String, ParseOptions)
      • parseFromBuffer

        public static XMPMeta parseFromBuffer​(byte[] buffer)
                                       throws XMPException
        Parsing with default options.
        Parameters:
        buffer - a String contain an XMP-file.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML or if the parsing fails.
        See Also:
        parseFromBuffer(byte[], ParseOptions)
      • parseFromBuffer

        public static XMPMeta parseFromBuffer​(byte[] buffer,
                                              ParseOptions options)
                                       throws XMPException
        Creates an XMPMeta-object from a byte-buffer.
        Parameters:
        buffer - a String contain an XMP-file.
        options - Options controlling the parsing.
        Returns:
        Returns the XMPMeta-object created from the input.
        Throws:
        XMPException - If the file is not well-formed XML or if the parsing fails.
        See Also:
        parse(InputStream, ParseOptions)
      • serialize

        public static void serialize​(XMPMeta xmp,
                                     java.io.OutputStream out)
                              throws XMPException
        Serializes an XMPMeta-object as RDF into an OutputStream with default options.
        Parameters:
        xmp - a metadata object
        out - an OutputStream to write the serialized RDF to.
        Throws:
        XMPException - on serializsation errors.
      • serialize

        public static void serialize​(XMPMeta xmp,
                                     java.io.OutputStream out,
                                     SerializeOptions options)
                              throws XMPException
        Serializes an XMPMeta-object as RDF into an OutputStream.
        Parameters:
        xmp - a metadata object
        options - Options to control the serialization (see SerializeOptions).
        out - an OutputStream to write the serialized RDF to.
        Throws:
        XMPException - on serializsation errors.
      • serializeToBuffer

        public static byte[] serializeToBuffer​(XMPMeta xmp,
                                               SerializeOptions options)
                                        throws XMPException
        Serializes an XMPMeta-object as RDF into a byte buffer.
        Parameters:
        xmp - a metadata object
        options - Options to control the serialization (see SerializeOptions).
        Returns:
        Returns a byte buffer containing the serialized RDF.
        Throws:
        XMPException - on serializsation errors.
      • serializeToString

        public static java.lang.String serializeToString​(XMPMeta xmp,
                                                         SerializeOptions options)
                                                  throws XMPException
        Serializes an XMPMeta-object as RDF into a string. Note: Encoding is ignored when serializing to a string.
        Parameters:
        xmp - a metadata object
        options - Options to control the serialization (see SerializeOptions).
        Returns:
        Returns a string containing the serialized RDF.
        Throws:
        XMPException - on serializsation errors.
      • reset

        public static void reset()
        Resets the schema registry to its original state (creates a new one). Be careful this might break all existing XMPMeta-objects and should be used only for testing purpurses.
      • getVersionInfo

        public static XMPVersionInfo getVersionInfo()
        Obtain version information. The XMPVersionInfo singleton is created the first time its requested.
        Returns:
        Returns the version information.