Class XMPPacketParser


  • public final class XMPPacketParser
    extends java.lang.Object
    This class is a parser for XMP packets. By default, it tries to locate the first XMP packet it finds and parses it.

    Important: Before you use this class to look for an XMP packet in some random file, please read the chapter on "Scanning Files for XMP Packets" in the XMP specification!

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XMPPacketParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Metadata parse​(java.io.InputStream in)
      Locates an XMP packet in a stream, parses it and returns the XMP metadata.
      private static boolean skipAfter​(java.io.InputStream in, byte[] match)  
      private static boolean skipAfter​(java.io.InputStream in, byte[] match, java.io.OutputStream out)  
      • Methods inherited from class java.lang.Object

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

      • PACKET_HEADER

        private static final byte[] PACKET_HEADER
      • PACKET_HEADER_END

        private static final byte[] PACKET_HEADER_END
      • PACKET_TRAILER

        private static final byte[] PACKET_TRAILER
    • Constructor Detail

      • XMPPacketParser

        private XMPPacketParser()
    • Method Detail

      • parse

        public static Metadata parse​(java.io.InputStream in)
                              throws java.io.IOException,
                                     javax.xml.transform.TransformerException
        Locates an XMP packet in a stream, parses it and returns the XMP metadata. If no XMP packet is found until the stream ends, null is returned. Note: This method only finds the first XMP packet in a stream. And it cannot determine whether it has found the right XMP packet if there are multiple packets.
        Parameters:
        in - the InputStream to search
        Returns:
        the parsed XMP metadata or null if no XMP packet is found
        Throws:
        java.io.IOException - if an I/O error occurs
        javax.xml.transform.TransformerException - if an error occurs while parsing the XMP packet
      • skipAfter

        private static boolean skipAfter​(java.io.InputStream in,
                                         byte[] match)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • skipAfter

        private static boolean skipAfter​(java.io.InputStream in,
                                         byte[] match,
                                         java.io.OutputStream out)
                                  throws java.io.IOException
        Throws:
        java.io.IOException