Class XMPScanner
java.lang.Object
com.twelvemonkeys.imageio.metadata.xmp.XMPScanner
XMPScanner
- Version:
- $Id: XMPScanner.java,v 1.0 Nov 11, 2009 4:49:00 PM haraldk Exp$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
<?xpacket begin=
private static final byte[]
<?xpacket end=
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
private static long
scanForSequence
(ImageInputStream pStream, byte[] pSequence) Scans for a given ASCII sequence.static Reader
scanForXMPPacket
(Object pInput) Scans the given input for an XML metadata packet.
-
Field Details
-
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=
-
-
Constructor Details
-
XMPScanner
public XMPScanner()
-
-
Method Details
-
scanForXMPPacket
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:
UnsupportedCharsetException
- if the encoding specified within the BOM is not supported by the JRE.IOException
- if an I/O exception occurs reading frompInput
.- See Also:
-
scanForSequence
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:
IOException
- if an I/O exception occurs during scanning
-
main
- Throws:
IOException
-