/** * Creates blank XMP doc with specified parameters. * * @param xpacketBegin Value of xpacketBegin * @param xpacketId Value of xpacketId * @param xpacketBytes Value of xpacketBytes * @param xpacketEncoding Value of xpacket encoding */ protected XMPMetadata(String xpacketBegin, String xpacketId, String xpacketBytes, String xpacketEncoding) { this.schemas = new ArrayList<>(); this.typeMapping = new TypeMapping(this); this.xpacketBegin = xpacketBegin; this.xpacketId = xpacketId; this.xpacketBytes = xpacketBytes; this.xpacketEncoding = xpacketEncoding; }
StructuredType st = clz.getAnnotation(StructuredType.class); String ns = st.namespace(); PropertiesDescription pm = initializePropMapping(clz); structuredNamespaces.put(ns, type); structuredMappings.put(type, pm); addNameSpace(XMPBasicSchema.class); addNameSpace(DublinCoreSchema.class); addNameSpace(PDFAExtensionSchema.class); addNameSpace(XMPMediaManagementSchema.class); addNameSpace(AdobePDFSchema.class); addNameSpace(PDFAIdentificationSchema.class); addNameSpace(XMPRightsManagementSchema.class); addNameSpace(PhotoshopSchema.class); addNameSpace(XMPBasicJobTicketSchema.class); addNameSpace(ExifSchema.class); addNameSpace(TiffSchema.class); addNameSpace(XMPageTextSchema.class);
ArrayProperty properties = st.getProperty(); ArrayProperty valueTypes = st.getValueType(); XMPSchemaFactory xsf = tm.getSchemaFactory(namespaceUri); tm.addNewNameSpace(namespaceUri, prefix); xsf = tm.getSchemaFactory(namespaceUri);
XMPSchemaFactory factory = getSchemaFactory(name.getNamespaceURI()); if (factory != null) if (st != null) return createPropertyType(st, Cardinality.Simple); return createPropertyType(Types.DefinedType, Cardinality.Simple);
return TypeMapping.createPropertyType(Types.LangAlt, Cardinality.Simple); if (tm.isDefinedType(vt)) return TypeMapping.createPropertyType(type, card);
if (tt.isStructured()) pm = tm.getStructuredPropMapping(tt); pm = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI()); ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card()); ast.getContainer().addProperty(array); Element bagOrSeq = DomHelper.getUniqueElementChild(element); AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name, element.getTextContent(), type.type()); loadAttributes(sp, element);
if (schema == null && tm.getSchemaFactory(namespace) != null) schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, attr.getPrefix()); loadAttributes(schema, description); type = TypeMapping.createPropertyType(Types.Text, Cardinality.Simple); AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, schema.getPrefix(), attr.getLocalName(), attr.getValue(), type.type()); container.addProperty(sp);
public void addAlternatePath(String value) { ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class); if (seq == null) { seq = getMetadata().getTypeMapping().createArrayProperty(null, getPreferedPrefix(), ALTERNATE_PATHS, Cardinality.Seq); addProperty(seq); } TypeMapping tm = getMetadata().getTypeMapping(); TextType tt = (TextType) tm.instanciateSimpleProperty(null, "rdf", "li", value, Types.Text); seq.addProperty(tt); }
private void parseChildrenAsProperties(XMPMetadata xmp, List<Element> properties, TypeMapping tm, Element description) throws XmpParsingException, XmpSchemaException { // parse children elements as properties for (Element property : properties) { String namespace = property.getNamespaceURI(); PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(property)); // create the container if (!tm.isDefinedSchema(namespace)) { throw new XmpParsingException(ErrorType.NoSchema, "This namespace is not a schema or a structured type : " + namespace); } XMPSchema schema = xmp.getSchema(namespace); if (schema == null) { schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, property.getPrefix()); loadAttributes(schema, description); } ComplexPropertyContainer container = schema.getContainer(); // create property createProperty(xmp, property, type, container); } }
private void manageLangAlt(XMPMetadata xmp, Element property, ComplexPropertyContainer container) throws XmpParsingException { manageArray(xmp, property, TypeMapping.createPropertyType(Types.LangAlt, Cardinality.Alt), container); }
public ArrayProperty createArrayProperty(String propertyName, Cardinality type) { return getMetadata().getTypeMapping().createArrayProperty(getNamespace(), getPrefix(), propertyName, type); }
public TextType createTextType(String propertyName, String value) { return getMetadata().getTypeMapping().createText(getNamespace(), getPrefix(), propertyName, value); }
/** * Add a date sequence value to the list. * * @param seqName * The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords" * @param date * The date to add to the sequence property. */ public void addUnqualifiedSequenceDateValue(String seqName, Calendar date) { addUnqualifiedSequenceValue( seqName, getMetadata().getTypeMapping().createDate(null, XmpConstants.DEFAULT_RDF_LOCAL_NAME, XmpConstants.LIST_NAME, date)); }
/** * Return the specialized schema class representation if it's known (create and add it to metadata). In other cases, * return null * * @param metadata * Metadata to link the new schema * @param namespace * The namespace URI * @param prefix The namespace prefix * @return Schema representation * @throws XmpSchemaException * When Instancing specified Object Schema failed */ public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix) throws XmpSchemaException { if (schemaMap.containsKey(namespace)) { XMPSchemaFactory factory = schemaMap.get(namespace); return factory.createXMPSchema(metadata, prefix); } else { XMPSchemaFactory factory = getSchemaFactory(namespace); return factory != null ? factory.createXMPSchema(metadata, prefix) : null; } }
tm.addToDefinedStructuredTypes(ttype, tns, pm);
if (tt.isStructured()) pm = tm.getStructuredPropMapping(tt); pm = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI()); ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card()); ast.getContainer().addProperty(array); Element bagOrSeq = DomHelper.getUniqueElementChild(element); AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name, element.getTextContent(), type.type()); loadAttributes(sp, element);
if (schema == null && tm.getSchemaFactory(namespace) != null) schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, attr.getPrefix()); loadAttributes(schema, description); type = TypeMapping.createPropertyType(Types.Text, Cardinality.Simple); AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, schema.getPrefix(), attr.getLocalName(), attr.getValue(), type.type()); container.addProperty(sp);
public void addAlternatePath(String value) { ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class); if (seq == null) { seq = getMetadata().getTypeMapping().createArrayProperty(null, getPreferedPrefix(), ALTERNATE_PATHS, Cardinality.Seq); addProperty(seq); } TypeMapping tm = getMetadata().getTypeMapping(); TextType tt = (TextType) tm.instanciateSimpleProperty(null, "rdf", "li", value, Types.Text); seq.addProperty(tt); }
private void parseChildrenAsProperties(XMPMetadata xmp, List<Element> properties, TypeMapping tm, Element description) throws XmpParsingException, XmpSchemaException { // parse children elements as properties for (Element property : properties) { String namespace = property.getNamespaceURI(); PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(property)); // create the container if (!tm.isDefinedSchema(namespace)) { throw new XmpParsingException(ErrorType.NoSchema, "This namespace is not a schema or a structured type : " + namespace); } XMPSchema schema = xmp.getSchema(namespace); if (schema == null) { schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, property.getPrefix()); loadAttributes(schema, description); } ComplexPropertyContainer container = schema.getContainer(); // create property createProperty(xmp, property, type, container); } }
XMPSchemaFactory factory = getSchemaFactory(name.getNamespaceURI()); if (factory != null) if (st != null) return createPropertyType(st, Cardinality.Simple); return createPropertyType(Types.DefinedType, Cardinality.Simple);