本文整理了Java中com.adobe.xmp.XMPException
类的一些代码示例,展示了XMPException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMPException
类的具体详情如下:
包路径:com.adobe.xmp.XMPException
类名称:XMPException
[英]This exception wraps all errors that occur in the XMP Toolkit.
[中]此异常封装了XMP工具包中发生的所有错误。
代码示例来源:origin: drewnoakes/metadata-extractor
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final String xmpString, @NotNull Metadata metadata, @Nullable Directory parentDirectory)
{
XmpDirectory directory = new XmpDirectory();
if (parentDirectory != null)
directory.setParent(parentDirectory);
try {
XMPMeta xmpMeta = XMPMetaFactory.parseFromString(xmpString);
directory.setXMPMeta(xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
if (!directory.isEmpty())
metadata.addDirectory(directory);
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* 7.2.20 parseTypeOtherPropertyElt
* start-element ( URI == propertyElementURIs, attributes == set ( idAttr?, parseOther ) )
* propertyEltList
* end-element()
*
* @throws XMPException thown on parsing errors
*/
private static void rdf_ParseTypeOtherPropertyElement() throws XMPException
{
throw new XMPException("ParseTypeOther property element not allowed", BADXMP);
}
代码示例来源:origin: drewnoakes/metadata-extractor
/**
* Serializes the XmpDirectory component of <code>Metadata</code> into an <code>OutputStream</code>
* @param os Destination for the xmp data
* @param data populated metadata
* @return serialize success
*/
public static boolean write(OutputStream os, Metadata data)
{
XmpDirectory dir = data.getFirstDirectoryOfType(XmpDirectory.class);
if (dir == null)
return false;
XMPMeta meta = dir.getXMPMeta();
try
{
SerializeOptions so = new SerializeOptions().setOmitPacketWrapper(true);
XMPMetaFactory.serialize(meta, os, so);
}
catch (XMPException e)
{
e.printStackTrace();
return false;
}
return true;
}
}
代码示例来源:origin: veraPDF/veraPDF-library
if (e.getErrorCode() == XMPError.BADXML ||
e.getErrorCode() == XMPError.BADSTREAM)
throw new XMPException("Unsupported Encoding",
XMPError.INTERNALFAILURE, e);
代码示例来源:origin: veraPDF/veraPDF-library
/**
* Parses XML from a {@link String},
* fixing the illegal control character optionally.
*
* @param input a <code>String</code> containing the XMP packet
* @param options the parsing options
* @return Returns an XML DOM-Document.
* @throws XMPException Thrown when the parsing fails.
*/
private static Document parseXmlFromString(String input, ParseOptions options)
throws XMPException
{
InputSource source = new InputSource(new StringReader(input));
try
{
return parseInputSource(source);
}
catch (XMPException e)
{
if (e.getErrorCode() == XMPError.BADXML && options.getFixControlChars())
{
source = new InputSource(new FixASCIIControlsReader(new StringReader(input)));
return parseInputSource(source);
}
else
{
throw e;
}
}
}
代码示例来源:origin: drewnoakes/metadata-extractor
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final byte[] xmpBytes, int offset, int length, @NotNull Metadata metadata, @Nullable Directory parentDirectory)
{
XmpDirectory directory = new XmpDirectory();
if (parentDirectory != null)
directory.setParent(parentDirectory);
try {
XMPMeta xmpMeta;
// If all xmpBytes are requested, no need to make a new ByteBuffer
if (offset == 0 && length == xmpBytes.length) {
xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
} else {
ByteBuffer buffer = new ByteBuffer(xmpBytes, offset, length);
xmpMeta = XMPMetaFactory.parse(buffer.getByteStream());
}
directory.setXMPMeta(xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
if (!directory.isEmpty())
metadata.addDirectory(directory);
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* 7.2.17 parseTypeLiteralPropertyElt
* start-element ( URI == propertyElementURIs,
* attributes == set ( idAttr?, parseLiteral ) )
* literal
* end-element()
*
* @throws XMPException thown on parsing errors
*/
private static void rdf_ParseTypeLiteralPropertyElement() throws XMPException
{
throw new XMPException("ParseTypeLiteral property element not allowed", BADXMP);
}
代码示例来源:origin: drewnoakes/metadata-extractor
e.printStackTrace();
代码示例来源:origin: org.verapdf/pdfbox-metadata-fixer
private static MetadataImpl parseMetadata(PDMetadata meta) {
try {
VeraPDFMeta xmp = VeraPDFMeta.parse(meta.getStream().getUnfilteredStream());
if (xmp != null) {
return new MetadataImpl(xmp, meta.getStream());
}
} catch (IOException e) {
LOGGER.debug("Problems with document parsing or structure. " + e.getMessage(), e);
} catch (XMPException e) {
LOGGER.debug("Problems with XMP parsing. " + e.getMessage(), e);
}
return null;
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* 7.2.19 parseTypeCollectionPropertyElt
* start-element ( URI == propertyElementURIs,
* attributes == set ( idAttr?, parseCollection ) )
* nodeElementList
* end-element()
*
* @throws XMPException thown on parsing errors
*/
private static void rdf_ParseTypeCollectionPropertyElement() throws XMPException
{
throw new XMPException("ParseTypeCollection property element not allowed", BADXMP);
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
/**
* Serializes the XmpDirectory component of <code>Metadata</code> into an <code>OutputStream</code>
* @param os Destination for the xmp data
* @param data populated metadata
* @return serialize success
*/
public static boolean write(OutputStream os, Metadata data)
{
XmpDirectory dir = data.getFirstDirectoryOfType(XmpDirectory.class);
if (dir == null)
return false;
XMPMeta meta = dir.getXMPMeta();
try
{
SerializeOptions so = new SerializeOptions().setOmitPacketWrapper(true);
XMPMetaFactory.serialize(meta, os, so);
}
catch (XMPException e)
{
e.printStackTrace();
return false;
}
return true;
}
}
代码示例来源:origin: org.verapdf/metadata-fixer
private static MetadataImpl parseMetadata(PDMetadata meta, PDDocument document) {
try {
VeraPDFMeta xmp = VeraPDFMeta.parse(meta.getStream());
if (xmp != null) {
return new MetadataImpl(xmp, meta.getObject(),
document.getDocument(), false);
}
} catch (XMPException e) {
LOGGER.log(Level.FINE, "Problems with XMP parsing. " + e.getMessage(), e);
}
return null;
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* Asserts that the xmp object is of this implemention
* ({@link XMPMetaImpl}).
* @param xmp the XMP object
* @throws XMPException A wrong implentaion is used.
*/
public static void assertImplementation(XMPMeta xmp) throws XMPException
{
if (xmp == null)
{
throw new XMPException("Parameter must not be null",
XMPError.BADPARAM);
}
else if (!(xmp instanceof XMPMetaImpl))
{
throw new XMPException("The XMPMeta-object is not compatible with this implementation",
XMPError.BADPARAM);
}
}
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
e.printStackTrace();
代码示例来源:origin: org.verapdf/validation-model
/**
* Matches properties of document information dictionary and xmp metadata.
*
* @param document which will be tested
* @return true if fields of xmp matches with fields of info dictionary
*/
public static Boolean doesInfoMatchXMP(COSDocument document) {
COSObject info = getInformationDictionary(document);
if (info == null) {
return Boolean.TRUE;
}
try (InputStream metadataStream = getMetadataStream(document)) {
if (metadataStream != null) {
VeraPDFMeta metadata = VeraPDFMeta.parse(metadataStream);
Map<ASAtom, Object> properties = new HashMap<>(
MAX_REQUIRED_RECORDS);
getTitleAuthorSubject(metadata, properties);
getProducerKeywords(metadata, properties);
getCreatorAndDates(metadata, properties);
return checkMatch(info, properties);
}
} catch (IOException e) {
LOGGER.log(Level.FINE,
"Problems with document parsing or structure. "
+ e.getMessage(), e);
} catch (XMPException e) {
LOGGER.log(Level.FINE, "Problems with XMP parsing. " + e.getMessage(), e);
}
return Boolean.FALSE;
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* Checks that a node not a struct and array at the same time;
* and URI cannot be a struct.
*
* @param options the bitmask to check.
* @throws XMPException Thrown if the options are not consistent.
*/
public void assertConsistency(int options) throws XMPException
{
if ((options & STRUCT) > 0 && (options & ARRAY) > 0)
{
throw new XMPException("IsStruct and IsArray options are mutually exclusive",
XMPError.BADOPTIONS);
}
else if ((options & URI) > 0 && (options & (ARRAY | STRUCT)) > 0)
{
throw new XMPException("Structs and arrays can't have \"value\" options",
XMPError.BADOPTIONS);
}
}
}
代码示例来源:origin: org.verapdf/pdfbox-validation-model
/**
* Matches properties of document information dictionary and xmp metadata.
*
* @param document
* which will be tested
* @return true if fields of xmp matches with fields of info dictionary
*/
public static Boolean doesInfoMatchXMP(COSDocument document) {
COSDictionary info = getInformationDictionary(document);
if (info == null) {
return Boolean.TRUE;
}
try {
COSStream meta = getMetadataDictionary(document);
if (meta != null) {
VeraPDFMeta metadata = VeraPDFMeta.parse(meta.getUnfilteredStream());
Map<String, Object> properties = new HashMap<>(MAX_REQUIRED_RECORDS);
getTitleAuthorSubject(metadata, properties);
getProducerKeywords(metadata, properties);
getCreatorAndDates(metadata, properties);
return checkMatch(info, properties);
}
} catch (IOException e) {
LOGGER.debug("Problems with document parsing or structure. " + e.getMessage(), e);
} catch (XMPException e) {
LOGGER.debug("Problems with XMP parsing. " + e.getMessage(), e);
}
return Boolean.FALSE;
}
代码示例来源:origin: veraPDF/veraPDF-library
/**
* Asserts that any string parameter is set.
* @param param any string parameter
* @throws XMPException Thrown if the parameter is null or has length 0.
*/
public static void assertNotNull(Object param) throws XMPException
{
if (param == null)
{
throw new XMPException("Parameter must not be null", XMPError.BADPARAM);
}
else if ((param instanceof String) && ((String) param).length() == 0)
{
throw new XMPException("Parameter must not be null or empty", XMPError.BADPARAM);
}
}
代码示例来源:origin: org.verapdf/validation-model
logger.log(Level.FINE, e.getMessage(), e);
return defaultFlavour;
} catch (IOException e) {
代码示例来源:origin: veraPDF/veraPDF-library
/**
* ParameterAsserts that a qualifier namespace is set.
* @param qualNS a qualifier namespace
* @throws XMPException Qualifier schema is null or empty
*/
private static void assertQualNS(String qualNS) throws XMPException
{
if (qualNS == null || qualNS.length() == 0)
{
throw new XMPException("Empty qualifier namespace URI", XMPError.BADSCHEMA);
}
}
内容来源于网络,如有侵权,请联系作者删除!