Package org.opengis.feature.type

Examples of org.opengis.feature.type.PropertyDescriptor


     * @param type The type to search in.
     * @param att The attribute name.
     * @return True if the attribute exists in the type and is an element.
     */
    public static boolean isElement(ComplexType type, Name att) {
        PropertyDescriptor descriptor = Types.descriptor(type, att);
        if (descriptor == null) {
            return false;
        }
        Map<Object, Object> userData = descriptor.getUserData();
        if (userData.isEmpty()) {
            return false;
        }
        return userData.get(XSDElementDeclaration.class) != null;
    }
View Full Code Here


                if (currStepDescriptor == null) {
                    StringBuffer parentAtts = new StringBuffer();
                    Collection properties = parentType.getDescriptors();
                    for (Iterator it = properties.iterator(); it.hasNext();) {
                        PropertyDescriptor desc = (PropertyDescriptor) it.next();
                        Name name = desc.getName();
                        parentAtts.append(name.getNamespaceURI());
                        parentAtts.append("#");
                        parentAtts.append(name.getLocalPart());
                        if (it.hasNext()) {
                            parentAtts.append(", ");
View Full Code Here

    }

    public static boolean contains(Collection collection, PropertyDescriptor descriptor) {
        // check for a descriptor with the same name
        for (Iterator itr = collection.iterator(); itr.hasNext();) {
            PropertyDescriptor d = (PropertyDescriptor) itr.next();
            if (d.getName().equals(descriptor.getName())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        return properties;
    }

    protected AssociationDescriptor associationDescriptor(Name name) {
        PropertyDescriptor descriptor = Types.descriptor((ComplexType) type, name);

        if (descriptor == null) {
            String msg = "Could not locate association: " + name + " in type: " + type.getName();
            throw new IllegalArgumentException(msg);
        }
View Full Code Here

        return (AssociationDescriptor) descriptor;
    }

    protected AttributeDescriptor attributeDescriptor(Name name) {
        PropertyDescriptor descriptor = Types.findDescriptor((ComplexType) type, name);

        if (descriptor == null) {
            String msg = "Could not locate attribute: " + name + " in type: " + type.getName();
            throw new IllegalArgumentException(msg);
        }
View Full Code Here

        // doing a hardcode property name black list
        final List<String> ignoreList = Arrays.asList(new String[] { "location",
                "metaDataProperty", "description", "name", "boundedBy" });

        for (Iterator<PropertyDescriptor> it = attributes.iterator(); it.hasNext();) {
            PropertyDescriptor property = it.next();
            if (!(property instanceof AttributeDescriptor)) {
                continue;
            }
            AttributeDescriptor descriptor = (AttributeDescriptor) property;
            Name name = descriptor.getName();
View Full Code Here

        List<PropertyName> properties = new ArrayList<PropertyName>();

        while (ii.hasNext()) {

            PropertyDescriptor descr = ii.next();
            PropertyName propName = ff.property(descr.getName());

            if (oldProps != null && oldProps.contains(propName)) {
                properties.add(propName);
            } else if (((descr.getMinOccurs() > 0) && (descr.getMaxOccurs() != 0))) {
                // mandatory, add it
                properties.add(propName);
            }
        }
View Full Code Here

   *     The name of the property you wish to set.
   * @param value
   *     The value of the property to append.
   */
  public void append(Name name, Property value) {
    PropertyDescriptor propertyDescriptor = featureType.getDescriptor(name);

    // The 'name' must exist in the type, if not, throw an exception:
    if (propertyDescriptor == null) {
      throw new IllegalArgumentException(
          String.format(
              "The name '%s' is not a valid descriptor name for the type '%s'.",
              name, this.featureType.getName()));
    }

    Class<?> expectedClass = propertyDescriptor.getType().getBinding();
    if (value != null) {
      Class<?> providedClass = value.getType().getBinding();

      // Make sure that the provided class and the expected class match or
      // that the expectedClass is a base class of the providedClass:
      if (!providedClass.equals(expectedClass)
          && !expectedClass.isAssignableFrom(providedClass)) {
        throw new IllegalArgumentException(
            String.format(
                "The value provided contains an object of '%s' but the method expects an object of '%s'.",
                providedClass, expectedClass));
      }
    } else { // value == null
      if (propertyDescriptor.isNillable()) {
        value = (Property) expectedClass.cast(null);
      } else {
        // NOTE: This could possibly to changed to allow for processing
        // remote xlinks.
        value = (Property) expectedClass.cast(null);
      }
    }

    // At this point the converted value has been set so we must persist it
    // to the object's state:
    ArrayList<Property> valueList;

    if (values.containsKey(name)) {
      valueList = values.get(name);

      // Make sure that the list isn't already at capacity:
      int maxOccurs = propertyDescriptor.getMaxOccurs();
      if (valueList.size() == maxOccurs) {
        throw new IndexOutOfBoundsException(
            String.format(
                "You can't add another object with the name of '%s' because you already have the maximum number (%s) allowed by the property descriptor.",
                name, maxOccurs));
View Full Code Here

            if (!cType.getDescriptors().isEmpty()) {

    stringBuffer.append(TEXT_18);
   
                for (Iterator adItr = cType.getDescriptors().iterator(); adItr.hasNext();) {
                    PropertyDescriptor pd = (PropertyDescriptor) adItr.next();
                    if ( !(pd instanceof AttributeDescriptor) ) {
                        continue;
                    }
                   
                    AttributeDescriptor ad = (AttributeDescriptor) pd;
                   
                    AttributeType adType = ad.getType();
                   
                    String adTypeName = adType.getName().getLocalPart().toUpperCase() +
                        "_TYPE";
                    String adTypeURI = adType.getName().getNamespaceURI();
                    if (!uri.equals(adTypeURI)) {
                        adTypeName = ns2import.get(adTypeURI) + "." + adTypeName;
                    }
                    String adName = "new NameImpl(\"" + ad.getName().getNamespaceURI() +
                        "\",\"" + ad.getName().getLocalPart() + "\")";
                    String min = ad.getMinOccurs() + "";
                    String max = ad.getMaxOccurs() + "";
                    String isNillable = ad.isNillable() ? "true" : "false";        

    stringBuffer.append(TEXT_19);
    stringBuffer.append(TEXT_20);
    stringBuffer.append(adTypeName);
    stringBuffer.append(TEXT_21);
    stringBuffer.append(adName);
    stringBuffer.append(TEXT_22);
    stringBuffer.append(min);
    stringBuffer.append(TEXT_23);
    stringBuffer.append(max);
    stringBuffer.append(TEXT_24);
    stringBuffer.append(isNillable);
    stringBuffer.append(TEXT_25);
   
                }

    stringBuffer.append(TEXT_26);
    stringBuffer.append(uri);
    stringBuffer.append(TEXT_27);
    stringBuffer.append(local);
    stringBuffer.append(TEXT_28);
    stringBuffer.append(isIdentified);
    stringBuffer.append(TEXT_29);
    stringBuffer.append(TEXT_30);
    stringBuffer.append(isAbstract);
    stringBuffer.append(TEXT_31);
    stringBuffer.append(restrictions);
    stringBuffer.append(TEXT_32);
    stringBuffer.append(superType);
    stringBuffer.append(TEXT_33);
    stringBuffer.append(description);
    stringBuffer.append(TEXT_34);
   
            }
            else {

    stringBuffer.append(TEXT_35);
    stringBuffer.append(uri);
    stringBuffer.append(TEXT_36);
    stringBuffer.append(local);
    stringBuffer.append(TEXT_37);
    stringBuffer.append(isIdentified);
    stringBuffer.append(TEXT_38);
    stringBuffer.append(TEXT_39);
    stringBuffer.append(isAbstract);
    stringBuffer.append(TEXT_40);
    stringBuffer.append(restrictions);
    stringBuffer.append(TEXT_41);
    stringBuffer.append(superType);
    stringBuffer.append(TEXT_42);
    stringBuffer.append(description);
    stringBuffer.append(TEXT_43);
             
            }
        }
        else {

    stringBuffer.append(TEXT_44);
    stringBuffer.append(uri);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(local);
    stringBuffer.append(TEXT_46);
    stringBuffer.append(binding);
    stringBuffer.append(TEXT_47);
    stringBuffer.append(isIdentified);
    stringBuffer.append(TEXT_48);
    stringBuffer.append(TEXT_49);
    stringBuffer.append(isAbstract);
    stringBuffer.append(TEXT_50);
    stringBuffer.append(restrictions);
    stringBuffer.append(TEXT_51);
    stringBuffer.append(superType);
    stringBuffer.append(TEXT_52);
    stringBuffer.append(description);
    stringBuffer.append(TEXT_53);
         
        }
       
        if (!type.getUserData().isEmpty()) {
            //attributes
            for (Iterator i = type.getUserData().entrySet().iterator(); i.hasNext(); ) {
               Map.Entry entry = (Map.Entry) i.next();
               Name n = (Name) entry.getKey();
               PropertyDescriptor pd = (PropertyDescriptor) entry.getValue();
               PropertyType pdType = pd.getType();
              
               String pdTypeName = pdType.getName().getLocalPart().toUpperCase() +
                            "_TYPE";
               if (ns2import.containsKey(pdType.getName().getNamespaceURI())) {
                    String importClassName = (String) ns2import.get(pdType.getName().getNamespaceURI());
                    pdTypeName = importClassName + "." + pdTypeName;
               }
               String pdName = "new NameImpl(\"" + pd.getName().getNamespaceURI() +
                            "\",\"" + pd.getName().getLocalPart() + "\")";
          

    stringBuffer.append(TEXT_54);
    stringBuffer.append(pdName);
    stringBuffer.append(TEXT_55);
View Full Code Here

   
       
            if (!type.getUserData().isEmpty()) {
                //attributes
                for (Map.Entry<Object, Object> entry : type.getUserData().entrySet()) {
                    PropertyDescriptor pd = (PropertyDescriptor) entry.getValue();
                    PropertyType pdType = pd.getType();
                    String pdTypeName = pdType.getName().getLocalPart().toUpperCase() +
                        "_TYPE";
                    if (ns2import.containsKey(pdType.getName().getNamespaceURI())) {
                        String importClassName = (String) ns2import.get(pdType.getName().getNamespaceURI());
                        pdTypeName = importClassName + "." + pdTypeName;
                    }
                    String pdName = "new NameImpl(\"" + pd.getName().getNamespaceURI() +
                        "\",\"" + pd.getName().getLocalPart() + "\")";
          

    stringBuffer.append(TEXT_50);
    stringBuffer.append(pdName);
    stringBuffer.append(TEXT_51);
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.PropertyDescriptor

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.