Package org.opengis.feature.type

Examples of org.opengis.feature.type.PropertyDescriptor


        ComplexType cType = (ComplexType) type;
       
        //add an edge for each descriptor
        Collection atts = cType.getDescriptors();
        for (Iterator aitr = atts.iterator(); aitr.hasNext();) {
          PropertyDescriptor ad = (PropertyDescriptor) aitr.next();
          gg.add(new Object[]{type,ad.getType()});
        }
      }
    }
   
    Graph graph = gg.getGraph();
View Full Code Here


     */
    private boolean isNillable(String name) {
        if (schema == null) {
            return true;
        }
        PropertyDescriptor descriptor = schema.getDescriptor(name);
        return descriptor == null || descriptor.isNillable();
    }
View Full Code Here

                                .getContent();

                        if (element.isElementDeclarationReference()) {
                            element = element.getResolvedElementDeclaration();
                        }
                        PropertyDescriptor childDesc = null;
                        for (PropertyDescriptor desc : children) {
                            if (desc.getName().getLocalPart().equals(element.getName())
                                    && desc.getName().getNamespaceURI()
                                            .equals(element.getTargetNamespace())) {
                                childDesc = desc;
View Full Code Here

            // set substitution group for descriptors here
            for (XSDElementDeclaration elemDecl : children) {
                if (elemDecl.isElementDeclarationReference()) {
                    elemDecl = elemDecl.getResolvedElementDeclaration();
                }
                PropertyDescriptor att = null;
                for (PropertyDescriptor desc : schema) {
                    if (desc.getName().getLocalPart().equals(elemDecl.getName())
                            && desc.getName().getNamespaceURI()
                                    .equals(elemDecl.getTargetNamespace())) {
                        att = desc;
View Full Code Here

        //first try regular way
        PropertyType pt = descriptor.getType();
        if (pt instanceof ComplexType) {
            ComplexType ct = (ComplexType) pt;
            PropertyDescriptor ad = ct.getDescriptor("@" + name.getLocalPart());
            if (ad != null) {
                return ad;
            }
        }
View Full Code Here

            } else {
                return null;
            }
            for (Object complex : complexAtts) {
                if (complex instanceof ComplexAttribute) {
                    PropertyDescriptor descriptor = ((Attribute) complex).getDescriptor();
                    if (descriptor.getUserData() != null) {
                        Object propertyElement = descriptor.getUserData().get(
                                XSDElementDeclaration.class);
                        if (propertyElement != null
                                && propertyElement instanceof XSDElementDeclaration) {
                            XSDParticle substitutedChildParticle = XSDFactory.eINSTANCE
                                    .createXSDParticle();
                            substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs());
                            substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs());
                            XSDElementDeclaration wrapper = XSDFactory.eINSTANCE
                                    .createXSDElementDeclaration();
                            wrapper
                                    .setResolvedElementDeclaration((XSDElementDeclaration) propertyElement);
                            substitutedChildParticle.setContent(wrapper);
                            properties.add(new Object[] { substitutedChildParticle, complex });
                        }
                    }
                }
            }
            return properties;
        }
        if (object instanceof ComplexAttribute) {
            ComplexAttribute complex = (ComplexAttribute) object;
            for (XSDParticle childParticle : (List<XSDParticle>) Schemas.getChildElementParticles(
                    element.getTypeDefinition(), true)) {
                XSDElementDeclaration childElement = (XSDElementDeclaration) childParticle
                        .getContent();
                if (childElement.isElementDeclarationReference()) {
                    childElement = childElement.getResolvedElementDeclaration();
                }
                for (XSDElementDeclaration e : (List<XSDElementDeclaration>) childElement
                        .getSubstitutionGroup()) {
                    Name name = new NameImpl(e.getTargetNamespace(), e.getName());
                    Collection<Property> nameProperties = complex.getProperties(name);
                    if (!nameProperties.isEmpty()) {
                        // Particle creation stolen from BindingPropertyExtractor.
                        // I do not know why a wrapper is required; monkey see, monkey do.
                        // Without the wrapper, get an NPE in BindingPropertyExtractor.
                        XSDParticle substitutedChildParticle = XSDFactory.eINSTANCE
                                .createXSDParticle();
                        substitutedChildParticle.setMaxOccurs(childParticle.getMaxOccurs());
                        substitutedChildParticle.setMinOccurs(childParticle.getMinOccurs());
                        XSDElementDeclaration wrapper = XSDFactory.eINSTANCE
                                .createXSDElementDeclaration();
                        wrapper.setResolvedElementDeclaration(e);
                        substitutedChildParticle.setContent(wrapper);
                        for (Property property : nameProperties) {
                            /*
                             * Note : Returning simple feature value is not necessary as it has been
                             * taken care in the 1st For Loop of BindingPropertyExtractor.java -
                             * List properties(Object, XSDElementDeclaration) method
                             */
                            if (property instanceof ComplexAttribute) {
                                properties.add(new Object[] { substitutedChildParticle, property });
                            } else if (property instanceof GeometryAttribute) {
                                Object attType = complex.getType().getUserData()
                                        .get(XSDTypeDefinition.class);
                                boolean duplicate = false;
                                // handle substitution group for geometries too, but make sure
                                // it's not already handled in BindingPropertyExtractor
                                // otherwise it would be encoded as xlink:href as the id has already
                                // been seen
                                if (attType != null && attType instanceof XSDTypeDefinition) {
                                    XSDTypeDefinition attTypeDef = (XSDTypeDefinition) attType;
                                    for (XSDParticle attChild : (List<XSDParticle>) Schemas
                                            .getChildElementParticles(attTypeDef, true)) {
                                        XSDElementDeclaration childEl = (XSDElementDeclaration) attChild
                                                .getContent();
                                        if (childEl.isElementDeclarationReference()) {
                                            childEl = childEl.getResolvedElementDeclaration();
                                        }
                                        if (childEl.equals(e)) {
                                            duplicate = true;
                                            break;
                                        }
                                    }
                                }
                                if (!duplicate) {
                                    properties.add(new Object[] { substitutedChildParticle,
                                            property.getValue() });
                                }
                            }
                        }
                    }
                }
            }
        }

        List<XSDParticle> anyElementParticles = new ArrayList<XSDParticle>(Schemas
                .getAnyElementParticles(element.getTypeDefinition()));
        if (anyElementParticles.size() > 0) {
            Collection complexAtts = null;
            if (object instanceof Collection) {
                // collection of features
                complexAtts = (Collection) object;
            } else if (object instanceof ComplexAttribute) {
                // get collection of features from this attribute
                complexAtts = ((ComplexAttribute) object).getProperties();
            }

            // If child elements can't be retrieved from
            // Schemas.getChildElementParticles(element.getTypeDefinition(), true)),
            // properties list is empty. In this case, add all the complex
            // attributes in the object to the properties list.
            if (properties.isEmpty()) {
                for (Object complex : complexAtts) {
                    // only process complex attributes
                    if (complex instanceof ComplexAttribute) {
                        ComplexAttribute newComplexAtt = (ComplexAttribute) complex;
                        PropertyDescriptor descriptor = newComplexAtt.getDescriptor();
                        if (descriptor.getUserData() != null) {
                            Object propertyElement = descriptor.getUserData().get(
                                    XSDElementDeclaration.class);
                            if (propertyElement != null
                                    && propertyElement instanceof XSDElementDeclaration) {
                                XSDParticle substitutedChildParticle = XSDFactory.eINSTANCE
                                        .createXSDParticle();
                                substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs());
                                substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs());
                                XSDElementDeclaration wrapper = XSDFactory.eINSTANCE
                                        .createXSDElementDeclaration();
                                wrapper
                                        .setResolvedElementDeclaration((XSDElementDeclaration) propertyElement);
                                substitutedChildParticle.setContent(wrapper);
                                properties.add(new Object[] { substitutedChildParticle,
                                        newComplexAtt });
                            }
                        }
                    }
                }
            }

            /*
             * properties list is not empty.
             *
             * It's possible <any> and <element> co-exist in the same type. For example,
             *
             * <sequence>
             *     <any/>
             *     <element name="..." type="...">
             * </sequence>
             *
             * In this case, only add <any> complex attributes to the properties list. The following
             * code is not covered in unit test, as app-schema, doesn't support <any> as a
             * targetAttribute in a mapping file.
             */
            else {
                List<XSDParticle> elementParticles = new ArrayList<XSDParticle>(Schemas
                        .getChildElementParticles(element.getTypeDefinition(), false));
                for (Object complex : complexAtts) {
                    if (complex instanceof ComplexAttribute) {
                        ComplexAttribute newComplexAtt = (ComplexAttribute) complex;
                        PropertyDescriptor descriptor = ((Attribute) complex).getDescriptor();
                        if (descriptor.getUserData() != null) {
                            Object propertyElement = descriptor.getUserData().get(
                                    XSDElementDeclaration.class);
                            if (propertyElement != null
                                    && propertyElement instanceof XSDElementDeclaration) {
                                XSDParticle substitutedChildParticle = XSDFactory.eINSTANCE
                                        .createXSDParticle();
                                substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs());
                                substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs());
                                XSDElementDeclaration wrapper = XSDFactory.eINSTANCE
                                        .createXSDElementDeclaration();
                                wrapper
                                        .setResolvedElementDeclaration((XSDElementDeclaration) propertyElement);
                                substitutedChildParticle.setContent(wrapper);
View Full Code Here

  public PropertyDescriptor getDescriptor(Name name) {
      return propertyMap.get(name);
  }
 
    public PropertyDescriptor getDescriptor(String name) {
        PropertyDescriptor result = getDescriptor(new NameImpl(name));
        if (result == null) {
            // look in the same namespace as the complex type
            result = getDescriptor(new NameImpl(getName().getNamespaceURI(), name));
            if (result == null) {
                // full scan
View Full Code Here

        }
       
        // check attribute bindings
        for( PropertyDescriptor expectedDescriptor : expected.getDescriptors() ){
            expectedName = expectedDescriptor.getName().getLocalPart();           
            PropertyDescriptor actualDescriptor = actual.getDescriptor( expectedName );
           
            Class<?> expectedBinding = expectedDescriptor.getType().getBinding();
            Class<?> actualBinding = actualDescriptor.getType().getBinding();
            if( !actualBinding.isAssignableFrom( expectedBinding )){
                throw new IllegalArgumentException( "Expected "+expectedBinding.getSimpleName()+" for "+expectedName+" but was "+actualBinding.getSimpleName() );
            }
        }
    }
View Full Code Here

            return Collections.EMPTY_LIST;

        List match = new ArrayList();

        for (Iterator itr = type.getDescriptors().iterator(); itr.hasNext();) {
            PropertyDescriptor descriptor = (PropertyDescriptor) itr.next();
            String localPart = descriptor.getName().getLocalPart();
            if (name.equals(localPart)) {
                match.add(descriptor);
            }
        }
View Full Code Here

            return Collections.EMPTY_LIST;

        List match = new ArrayList();

        for (Iterator itr = type.getDescriptors().iterator(); itr.hasNext();) {
            PropertyDescriptor descriptor = (PropertyDescriptor) itr.next();
            Name descriptorName = descriptor.getName();
            if (name.equals(descriptorName)) {
                match.add(descriptor);
            }
        }
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.