Class XMPScanner
- java.lang.Object
-
- com.twelvemonkeys.imageio.metadata.xmp.XMPScanner
-
public final class XMPScanner extends java.lang.Object
XMPScanner- Version:
- $Id: XMPScanner.java,v 1.0 Nov 11, 2009 4:49:00 PM haraldk Exp$
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
XMP_PACKET_BEGIN
<?xpacket begin=
private static byte[]
XMP_PACKET_END
<?xpacket end=
-
Constructor Summary
Constructors Constructor Description XMPScanner()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] pArgs)
private static long
scanForSequence(javax.imageio.stream.ImageInputStream pStream, byte[] pSequence)
Scans for a given ASCII sequence.static java.io.Reader
scanForXMPPacket(java.lang.Object pInput)
Scans the given input for an XML metadata packet.
-
-
-
Field Detail
-
XMP_PACKET_BEGIN
private static final byte[] XMP_PACKET_BEGIN
<?xpacket begin=
- 8-bit (UTF-8): 0x3C 0x3F 0x78 0x70 0x61 0x63 0x6B 0x65 0x74 0x20 0x62 0x65 0x67 0x69 0x6E 0x3D
- 16-bit encoding (UCS-2, UTF-16): (either big- or little-endian order) 0x3C 0x00 0x3F 0x00 0x78 0x00 0x70 0x00 0x61 0x00 0x63 0x00 0x6B 0x00 0x65 0x00 0x74 0x00 0x20 0x00 0x62 0x00 0x65 0x00 0x67 0x00 0x69 0x00 0x6E 0x00 0x3D [0x00]
- 32-bit encoding (UCS-4): As 16 bit UCS2, with three 0x00 instead of one.
-
XMP_PACKET_END
private static final byte[] XMP_PACKET_END
<?xpacket end=
-
-
Method Detail
-
scanForXMPPacket
public static java.io.Reader scanForXMPPacket(java.lang.Object pInput) throws java.io.IOException
Scans the given input for an XML metadata packet. The scanning process involves reading every byte in the file, while searching for an XMP packet. This process is very inefficient, compared to reading a known file format.NOTE: The XMP Specification says this method of reading an XMP packet should be considered a last resort.
This is because files may contain multiple XMP packets, some which may be related to embedded resources, some which may be obsolete (or even incomplete).- Parameters:
pInput
- the input to scan. The input may be anImageInputStream
or any object that can be passed toImageIO.createImageInputStream(Object)
. Typically this may be aFile
,InputStream
orRandomAccessFile
.- Returns:
- a character Reader
- Throws:
java.nio.charset.UnsupportedCharsetException
- if the encoding specified within the BOM is not supported by the JRE.java.io.IOException
- if an I/O exception occurs reading frompInput
.- See Also:
ImageIO.createImageInputStream(Object)
-
scanForSequence
private static long scanForSequence(javax.imageio.stream.ImageInputStream pStream, byte[] pSequence) throws java.io.IOException
Scans for a given ASCII sequence.- Parameters:
pStream
- the stream to scanpSequence
- the byte sequence to search for- Returns:
- the start position of the given sequence.
- Throws:
java.io.IOException
- if an I/O exception occurs during scanning
-
main
public static void main(java.lang.String[] pArgs) throws java.io.IOException
- Throws:
java.io.IOException
-
-