/** * Get the XMPSchema for the specified Class. * * Return the schema corresponding to this Class<br> * BE CAREFUL: typically, Metadata should contain one schema for each type. * This method returns the first schema encountered * corresponding to this Class.<br> * Return null if unknown * * @param clz The Class corresponding to the schema wanted * @return The matching XMP schema representation */ public XMPSchema getSchema(Class<? extends XMPSchema> clz) { StructuredType st = clz.getAnnotation(StructuredType.class); return getSchema(st.namespace()); }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
private void addNameSpace(Class<? extends XMPSchema> classSchem) { StructuredType st = classSchem.getAnnotation(StructuredType.class); String ns = st.namespace(); schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem))); }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
AbstractStructuredType.class); StructuredType st = clz.getAnnotation(StructuredType.class); String ns = st.namespace(); PropertiesDescription pm = initializePropMapping(clz); structuredNamespaces.put(ns, type);
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }
/** * Get the XMPSchema for the specified Class. * * Return the schema corresponding to this Class<br> * BE CAREFUL: typically, Metadata should contain one schema for each type. * This method returns the first schema encountered * corresponding to this Class.<br> * Return null if unknown * * @param clz The Class corresponding to the schema wanted * @return The matching XMP schema representation */ public XMPSchema getSchema(Class<? extends XMPSchema> clz) { StructuredType st = clz.getAnnotation(StructuredType.class); return getSchema(st.namespace()); }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
/** * Get the XMPSchema for the specified Class. * * Return the schema corresponding to this Class<br> * BE CAREFUL: typically, Metadata should contain one schema for each type. * This method returns the first schema encountered * corresponding to this Class.<br> * Return null if unknown * * @param clz The Class corresponding to the schema wanted * @return The matching XMP schema representation */ public XMPSchema getSchema(Class<? extends XMPSchema> clz) { StructuredType st = clz.getAnnotation(StructuredType.class); return getSchema(st.namespace()); }
private void addNameSpace(Class<? extends XMPSchema> classSchem) { StructuredType st = classSchem.getAnnotation(StructuredType.class); String ns = st.namespace(); schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem))); }
private void addNameSpace(Class<? extends XMPSchema> classSchem) { StructuredType st = classSchem.getAnnotation(StructuredType.class); String ns = st.namespace(); schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem))); }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }