Esempio n. 1
0
 /**
  * Add a new namespace Mapping for specific schema declared in PDF/A Extension schema
  *
  * @param desc The schemaDescription associated to the schema
  * @throws XmpUnknownValueTypeException When a Value Type associated is unknown
  */
 public void setNamespaceDefinition(SchemaDescription desc) throws XmpUnknownValueTypeException {
   PropMapping propMap = new PropMapping(desc.getNameSpaceURI());
   List<PDFAPropertyDescription> props = desc.getProperties();
   for (int i = 0; i < props.size(); i++) {
     String type = getValueTypeEquivalence(desc, props.get(i).getValueTypeValue());
     propMap.addNewProperty(props.get(i).getNameValue(), type, null);
     if (type.equals("Field")) {
       declareAssociatedFieldType(desc, props.get(i).getValueTypeValue(), propMap);
     }
   }
   String nsName = desc.getPrefix();
   String ns = desc.getNameSpaceURI();
   nsMaps.put(ns, new XMPSchemaFactory(nsName, ns, XMPSchema.class, propMap));
 }
Esempio n. 2
0
 /**
  * Initialize the Property Mapping for a given schema
  *
  * @param ns Namespace URI
  * @param classSchem The class representation of the schema linked to the namespace
  * @return Construct expected properties types representation
  * @throws XmpSchemaException When could not read property name in field with properties
  *     annotations
  */
 private PropMapping initializePropMapping(String ns, Class<? extends XMPSchema> classSchem)
     throws XmpSchemaException {
   PropertyType propType;
   PropertyAttributesAnnotation propAtt;
   Field[] fields;
   PropMapping propMap = new PropMapping(ns);
   fields = classSchem.getFields();
   String propName = null;
   for (Field field : fields) {
     if (field.isAnnotationPresent(PropertyType.class)) {
       try {
         propName = (String) field.get(propName);
       } catch (Exception e) {
         throw new XmpSchemaException(
             "couldn't read one type declaration, please check accessibility and declaration of fields annoted in "
                 + classSchem.getName(),
             e.getCause());
       }
       // System.out.println("nameField:"+propName);
       propType = field.getAnnotation(PropertyType.class);
       // System.out.println("Type '"+propInfo.propertyType()+"' defined for "+propName);
       if (!field.isAnnotationPresent(PropertyAttributesAnnotation.class)) {
         propMap.addNewProperty(propName, propType.propertyType(), null);
       } else {
         // TODO Case where a special annotation is used to specify
         // attributes
         // NOT IMPLEMENTED YET, JUST TO GIVE A CLUE TO MAKE THIS
         propAtt = field.getAnnotation(PropertyAttributesAnnotation.class);
         List<String> attributes = new ArrayList<String>();
         for (String att : propAtt.expectedAttributes()) {
           attributes.add(att);
         }
         propMap.addNewProperty(propName, propType.propertyType(), attributes);
       }
     }
   }
   return propMap;
 }
Esempio n. 3
0
  /**
   * . For a specific valuetype declared in this schema. This method decompose it if field are
   * present. and add types expected
   *
   * @param desc The schema description associated to the schema which declare a property with
   *     specific value type
   * @param valueType valueType to analyze
   * @param prop Expected properties types representation
   * @throws XmpUnknownValueTypeException When a Value Type associated is unknown
   */
  private void declareAssociatedFieldType(
      SchemaDescription desc, String valueType, PropMapping prop)
      throws XmpUnknownValueTypeException {

    PDFAValueTypeDescription val = findValueTypeDescription(desc, valueType);
    for (PDFAFieldDescription field : val.getFields()) {
      // TODO case where a field call another nspace property ???
      String fieldType = getValueTypeEquivalence(desc, field.getValueTypeValue());
      if (fieldType.equals("Field")) {
        throw new XmpUnknownValueTypeException("ValueType Field reference a valuetype unknown");
      }
      prop.addNewProperty(field.getNameValue(), fieldType, null);
    }
  }