Package com.itextpdf.xmp.impl
Class XMPUtilsImpl
java.lang.Object
com.itextpdf.xmp.impl.XMPUtilsImpl
- All Implemented Interfaces:
XMPConst
- Since:
- 11.08.2006
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
U+002C, ASCII comma
U+FF0C, full width comma
U+FF64, half width ideographic comma
U+FE50, small comma
U+FE51, small ideographic comma
U+3001, ideographic comma
U+060C, Arabic comma
U+055D, Armenian commaprivate static final String
U+0000..U+001F ASCII controls
U+2028, line separator.
U+2029, paragraph separator.private static final String
U+0022 ASCII quote
The square brackets are not interpreted as quotes anymore (bug #2674672) (ASCII '[' (0x5B) and ']' (0x5D) are used as quotes in Chinese and Korean.)
U+00AB and U+00BB, guillemet quotes
U+3008..U+300F, various quotes.
U+301D..U+301F, double prime quotes.
U+2015, dash quote.
U+2018..U+201F, various quotes.
U+2039 and U+203A, guillemet quotes.private static final String
U+003B, ASCII semicolon
U+FF1B, full width semicolon
U+FE54, small semicolon
U+061B, Arabic semicolon
U+037E, Greek "semicolon" (really a question mark)private static final String
U+0022 ASCII space
U+3000, ideographic space
U+303F, ideographic half fill space
U+2000..U+200B, en quad through zero width spaceprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final int
Fields inherited from interface com.itextpdf.xmp.XMPConst
ARRAY_ITEM_NAME, ARRAY_LAST_ITEM, FALSESTR, NS_ADOBESTOCKPHOTO, NS_ASF, NS_BWF, NS_CAMERARAW, NS_CREATOR_ATOM, NS_DC, NS_DC_DEPRECATED, NS_DICOM, NS_DM, NS_EXIF, NS_EXIF_AUX, NS_EXIFX, NS_IPTCCORE, NS_IPTCEXT, NS_IX, NS_JP2K, NS_JPEG, NS_PDF, NS_PDFA_EXTENSION, NS_PDFA_FIELD, NS_PDFA_ID, NS_PDFA_PROPERTY, NS_PDFA_SCHEMA, NS_PDFA_TYPE, NS_PDFUA_ID, NS_PDFX, NS_PDFX_ID, NS_PHOTOSHOP, NS_PLUS, NS_PNG, NS_PSALBUM, NS_RDF, NS_RIFFINFO, NS_SCRIPT, NS_SWF, NS_TIFF, NS_TRANSIENT, NS_TXMP, NS_WAV, NS_X, NS_XML, NS_XMP, NS_XMP_BJ, NS_XMP_MM, NS_XMP_NOTE, NS_XMP_RIGHTS, RDF_TYPE, TAG_XAPMETA, TAG_XMPMETA, TRUESTR, TYPE_DIMENSIONS, TYPE_FONT, TYPE_GRAPHICS, TYPE_IDENTIFIERQUAL, TYPE_IMAGE, TYPE_MANIFESTITEM, TYPE_PAGEDFILE, TYPE_RESOURCEEVENT, TYPE_RESOURCEREF, TYPE_ST_JOB, TYPE_ST_VERSION, TYPE_TEXT, X_DEFAULT, XML_LANG, XMP_PI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendProperties
(XMPMeta source, XMPMeta destination, boolean doAllProperties, boolean replaceOldValues, boolean deleteEmptyValues) private static void
appendSubtree
(XMPMetaImpl destXMP, XMPNode sourceNode, XMPNode destParent, boolean replaceOldValues, boolean deleteEmptyValues) private static String
applyQuotes
(String item, char openQuote, char closeQuote, boolean allowCommas) Add quotes to the item.static String
catenateArrayItems
(XMPMeta xmp, String schemaNS, String arrayName, String separator, String quotes, boolean allowCommas) private static char
checkQuotes
(String quotes, char openQuote) Make sure the open and close quotes are a legitimate pair and return the correct closing quote or an exception.private static void
checkSeparator
(String separator) Make sure the separator is OK.private static int
classifyCharacter
(char ch) Classifies the character into normal chars, spaces, semicola, quotes, control chars.private static char
getClosingQuote
(char openQuote) private static boolean
isClosingingQuote
(char ch, char openQuote, char closeQuote) private static boolean
isSurroundingQuote
(char ch, char openQuote, char closeQuote) private static boolean
itemValuesMatch
(XMPNode leftNode, XMPNode rightNode) Compares two nodes including its children and qualifier.static void
removeProperties
(XMPMeta xmp, String schemaNS, String propName, boolean doAllProperties, boolean includeAliases) private static boolean
removeSchemaChildren
(XMPNode schemaNode, boolean doAllProperties) Remove all schema children according to the flagdoAllProperties
.static void
separateArrayItems
(XMPMeta xmp, String schemaNS, String arrayName, String catedStr, PropertyOptions arrayOptions, boolean preserveCommas) private static XMPNode
separateFindCreateArray
(String schemaNS, String arrayName, PropertyOptions arrayOptions, XMPMetaImpl xmp) Utility to find or create the array used byseparateArrayItems()
.
-
Field Details
-
UCK_NORMAL
private static final int UCK_NORMAL- See Also:
-
UCK_SPACE
private static final int UCK_SPACE- See Also:
-
UCK_COMMA
private static final int UCK_COMMA- See Also:
-
UCK_SEMICOLON
private static final int UCK_SEMICOLON- See Also:
-
UCK_QUOTE
private static final int UCK_QUOTE- See Also:
-
UCK_CONTROL
private static final int UCK_CONTROL- See Also:
-
SPACES
U+0022 ASCII space
U+3000, ideographic space
U+303F, ideographic half fill space
U+2000..U+200B, en quad through zero width space- See Also:
-
COMMAS
U+002C, ASCII comma
U+FF0C, full width comma
U+FF64, half width ideographic comma
U+FE50, small comma
U+FE51, small ideographic comma
U+3001, ideographic comma
U+060C, Arabic comma
U+055D, Armenian comma- See Also:
-
SEMICOLA
U+003B, ASCII semicolon
U+FF1B, full width semicolon
U+FE54, small semicolon
U+061B, Arabic semicolon
U+037E, Greek "semicolon" (really a question mark)- See Also:
-
QUOTES
U+0022 ASCII quote
The square brackets are not interpreted as quotes anymore (bug #2674672) (ASCII '[' (0x5B) and ']' (0x5D) are used as quotes in Chinese and Korean.)
U+00AB and U+00BB, guillemet quotes
U+3008..U+300F, various quotes.
U+301D..U+301F, double prime quotes.
U+2015, dash quote.
U+2018..U+201F, various quotes.
U+2039 and U+203A, guillemet quotes.- See Also:
-
CONTROLS
U+0000..U+001F ASCII controls
U+2028, line separator.
U+2029, paragraph separator.- See Also:
-
-
Constructor Details
-
XMPUtilsImpl
private XMPUtilsImpl()Private constructor, as
-
-
Method Details
-
catenateArrayItems
public static String catenateArrayItems(XMPMeta xmp, String schemaNS, String arrayName, String separator, String quotes, boolean allowCommas) throws XMPException - Parameters:
xmp
- The XMP object containing the array to be catenated.schemaNS
- The schema namespace URI for the array. Must not be null or the empty string.arrayName
- The name of the array. May be a general path expression, must not be null or the empty string. Each item in the array must be a simple string value.separator
- The string to be used to separate the items in the catenated string. Defaults to "; ", ASCII semicolon and space (U+003B, U+0020).quotes
- The characters to be used as quotes around array items that contain a separator. Defaults to '"'allowCommas
- Option flag to control the catenation.- Returns:
- Returns the string containing the catenated array items.
- Throws:
XMPException
- Forwards the Exceptions from the metadata processing- See Also:
-
separateArrayItems
public static void separateArrayItems(XMPMeta xmp, String schemaNS, String arrayName, String catedStr, PropertyOptions arrayOptions, boolean preserveCommas) throws XMPException - Parameters:
xmp
- The XMP object containing the array to be updated.schemaNS
- The schema namespace URI for the array. Must not be null or the empty string.arrayName
- The name of the array. May be a general path expression, must not be null or the empty string. Each item in the array must be a simple string value.catedStr
- The string to be separated into the array items.arrayOptions
- Option flags to control the separation.preserveCommas
- Flag if commas shall be preserved- Throws:
XMPException
- Forwards the Exceptions from the metadata processing
-
separateFindCreateArray
private static XMPNode separateFindCreateArray(String schemaNS, String arrayName, PropertyOptions arrayOptions, XMPMetaImpl xmp) throws XMPException Utility to find or create the array used byseparateArrayItems()
.- Parameters:
schemaNS
- a the namespace fo the arrayarrayName
- the name of the arrayarrayOptions
- the options for the array if newly createdxmp
- the xmp object- Returns:
- Returns the array node.
- Throws:
XMPException
- Forwards exceptions
-
removeProperties
public static void removeProperties(XMPMeta xmp, String schemaNS, String propName, boolean doAllProperties, boolean includeAliases) throws XMPException - Parameters:
xmp
- The XMP object containing the properties to be removed.schemaNS
- Optional schema namespace URI for the properties to be removed.propName
- Optional path expression for the property to be removed.doAllProperties
- Option flag to control the deletion: do internal properties in addition to external properties.includeAliases
- Option flag to control the deletion: Include aliases in the "named schema" case above.- Throws:
XMPException
- If metadata processing fails- See Also:
-
appendProperties
public static void appendProperties(XMPMeta source, XMPMeta destination, boolean doAllProperties, boolean replaceOldValues, boolean deleteEmptyValues) throws XMPException - Parameters:
source
- The source XMP object.destination
- The destination XMP object.doAllProperties
- Do internal properties in addition to external properties.replaceOldValues
- Replace the values of existing properties.deleteEmptyValues
- Delete destination values if source property is empty.- Throws:
XMPException
- Forwards the Exceptions from the metadata processing- See Also:
-
removeSchemaChildren
Remove all schema children according to the flagdoAllProperties
. Empty schemas are automatically remove byXMPNode
- Parameters:
schemaNode
- a schema nodedoAllProperties
- flag if all properties or only externals shall be removed.- Returns:
- Returns true if the schema is empty after the operation.
-
appendSubtree
private static void appendSubtree(XMPMetaImpl destXMP, XMPNode sourceNode, XMPNode destParent, boolean replaceOldValues, boolean deleteEmptyValues) throws XMPException - Parameters:
destXMP
- The destination XMP object.sourceNode
- the source nodedestParent
- the parent of the destination nodereplaceOldValues
- Replace the values of existing properties.deleteEmptyValues
- flag if properties with empty values should be deleted in the destination object.- Throws:
XMPException
- See Also:
-
itemValuesMatch
Compares two nodes including its children and qualifier.- Parameters:
leftNode
- anXMPNode
rightNode
- anXMPNode
- Returns:
- Returns true if the nodes are equal, false otherwise.
- Throws:
XMPException
- Forwards exceptions to the calling method.
-
checkSeparator
Make sure the separator is OK. It must be one semicolon surrounded by zero or more spaces. Any of the recognized semicolons or spaces are allowed.- Parameters:
separator
-- Throws:
XMPException
-
checkQuotes
Make sure the open and close quotes are a legitimate pair and return the correct closing quote or an exception.- Parameters:
quotes
- opened and closing quote in a stringopenQuote
- the open quote- Returns:
- Returns a corresponding closing quote.
- Throws:
XMPException
-
classifyCharacter
private static int classifyCharacter(char ch) Classifies the character into normal chars, spaces, semicola, quotes, control chars.- Parameters:
ch
- a char- Returns:
- Return the character kind.
-
getClosingQuote
private static char getClosingQuote(char openQuote) - Parameters:
openQuote
- the open quote char- Returns:
- Returns the matching closing quote for an open quote.
-
applyQuotes
private static String applyQuotes(String item, char openQuote, char closeQuote, boolean allowCommas) Add quotes to the item.- Parameters:
item
- the array itemopenQuote
- the open quote charactercloseQuote
- the closing quote characterallowCommas
- flag if commas are allowed- Returns:
- Returns the value in quotes.
-
isSurroundingQuote
private static boolean isSurroundingQuote(char ch, char openQuote, char closeQuote) - Parameters:
ch
- a characteropenQuote
- the opening quote charcloseQuote
- the closing quote char- Returns:
- Return it the character is a surrounding quote.
-
isClosingingQuote
private static boolean isClosingingQuote(char ch, char openQuote, char closeQuote) - Parameters:
ch
- a characteropenQuote
- the opening quote charcloseQuote
- the closing quote char- Returns:
- Returns true if the character is a closing quote.
-