Search in sources :

Example 1 with PDFAFieldType

use of org.apache.xmpbox.type.PDFAFieldType in project pdfbox by apache.

the class PdfaExtensionHelper method populatePDFAType.

private static void populatePDFAType(XMPMetadata meta, PDFATypeType type, TypeMapping tm) throws XmpParsingException {
    String ttype = type.getType();
    String tns = type.getNamespaceURI();
    String tprefix = type.getPrefixValue();
    String tdescription = type.getDescription();
    ArrayProperty fields = type.getFields();
    if (ttype == null || tns == null || tprefix == null || tdescription == null) {
        // all fields are mandatory
        throw new XmpParsingException(ErrorType.RequiredProperty, "Missing field in type definition");
    }
    // create the structured type
    // TODO
    DefinedStructuredType structuredType = new DefinedStructuredType(meta, tns, tprefix, null);
    // maybe a name exists
    if (fields != null) {
        List<AbstractField> definedFields = fields.getAllProperties();
        for (AbstractField af3 : definedFields) {
            if (af3 instanceof PDFAFieldType) {
                populatePDFAFieldType((PDFAFieldType) af3, structuredType);
            }
        // else TODO
        }
    }
    // add the structured type to list
    PropertiesDescription pm = new PropertiesDescription();
    for (Map.Entry<String, PropertyType> entry : structuredType.getDefinedProperties().entrySet()) {
        pm.addNewProperty(entry.getKey(), entry.getValue());
    }
    tm.addToDefinedStructuredTypes(ttype, tns, pm);
}
Also used : ArrayProperty(org.apache.xmpbox.type.ArrayProperty) DefinedStructuredType(org.apache.xmpbox.type.DefinedStructuredType) AbstractField(org.apache.xmpbox.type.AbstractField) PropertiesDescription(org.apache.xmpbox.type.PropertiesDescription) PDFAFieldType(org.apache.xmpbox.type.PDFAFieldType) PDFAPropertyType(org.apache.xmpbox.type.PDFAPropertyType) PropertyType(org.apache.xmpbox.type.PropertyType) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Aggregations

Map (java.util.Map)1 AbstractField (org.apache.xmpbox.type.AbstractField)1 ArrayProperty (org.apache.xmpbox.type.ArrayProperty)1 DefinedStructuredType (org.apache.xmpbox.type.DefinedStructuredType)1 PDFAFieldType (org.apache.xmpbox.type.PDFAFieldType)1 PDFAPropertyType (org.apache.xmpbox.type.PDFAPropertyType)1 PropertiesDescription (org.apache.xmpbox.type.PropertiesDescription)1 PropertyType (org.apache.xmpbox.type.PropertyType)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1