Package org.apache.padaf.xmpbox.schema

Examples of org.apache.padaf.xmpbox.schema.PropertyType


    }
    Field[] fields = schemaClass.getFields();
    for (Field field : fields) {
      if (field.isAnnotationPresent(PropertyType.class)) {
        if (!field.get(schema).equals(property)) {
          PropertyType pt = field.getAnnotation(PropertyType.class);
          if (pt.propertyType().equals("Lang Alt")) {
            // do not check method existence
          } else if (pt.propertyType().equals("Alt Thumbnail")) {
            // do not check method existence
          } else {
            // type test
            String getName = "get"
                + firstUpper(field.get(schema).toString());
View Full Code Here


    }
    Field[] fields;
    fields = classSchem.getFields();
    SchemaExtensionDefinition schemDefAnnot;
    PropertyExtensionDefinition propExtDefAnnot;
    PropertyType propTypeAnnot;
    String propName = null;
    String propDesc;
    List<PropertyDescription> xmlPropDesc = null;
    if (classSchem.isAnnotationPresent(SchemaExtensionDefinition.class)) {
      schemDefAnnot = classSchem
          .getAnnotation(SchemaExtensionDefinition.class);
      // Try to find and load XML Properties Descriptions file path
      if (!schemDefAnnot.property_descriptions().equals("")) {
        XMLPropertiesDescriptionManager propManag = new XMLPropertiesDescriptionManager();
        propManag.loadListFromXML(classSchem, schemDefAnnot
            .property_descriptions());
        xmlPropDesc = propManag.getPropertiesDescriptionList();
      }
      SchemaDescription desc = ext.createSchemaDescription();
      desc.setSchemaValue(schemDefAnnot.schema());
      desc.setNameSpaceURIValue(schema.getNamespaceValue());
      desc.setPrefixValue(schema.getPrefix());
      ext.addSchemaDescription(desc);
      // Try to find and load XML ValueType Description file path
      if (!schemDefAnnot.valueType_description().equals("")) {
        XMLValueTypeDescriptionManager valTypesManag = new XMLValueTypeDescriptionManager();
        valTypesManag.loadListFromXML(classSchem, schemDefAnnot
            .valueType_description());
        addValueTypesToSchem(metadata, desc, valTypesManag
            .getValueTypesDescriptionList());
      }
      for (Field field : fields) {
        if (field
            .isAnnotationPresent(PropertyExtensionDefinition.class)
            && field.isAnnotationPresent(PropertyType.class)) {
          try {
            propName = (String) field.get(propName);
          } catch (Exception e) {
            throw propertyDescriptionError(
                classSchem.getName(),
                field.getName(),
                "Couldn't read content, please check accessibility and declaration of field associated",
                e);
          }
          propExtDefAnnot = field
              .getAnnotation(PropertyExtensionDefinition.class);
          propTypeAnnot = field.getAnnotation(PropertyType.class);
          try {
            if (xmlPropDesc != null) {
              Iterator<PropertyDescription> it = xmlPropDesc
                  .iterator();
              PropertyDescription tmp;
              propDesc = null;
              while (it.hasNext() && (propDesc == null)) {
                tmp = it.next();
                if (tmp.getPropertyName().equals(propName)) {
                  propDesc = tmp.getDescription();
                }
              }

            } else {
              propDesc = propExtDefAnnot.propertyDescription();
            }
            if ((propDesc == null) || propDesc.equals("")) {
              propDesc = "Not documented description";
            }
            desc.addProperty(propName,
                propTypeAnnot.propertyType(), propExtDefAnnot
                    .propertyCategory(), propDesc);
          } catch (BadFieldValueException e) {
            throw propertyDescriptionError(classSchem.getName(),
                propName, "Wrong value for property Category",
                e);
View Full Code Here

     *             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);
                }
                // 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;
View Full Code Here

TOP

Related Classes of org.apache.padaf.xmpbox.schema.PropertyType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.