public Set entrySet() { if (entrySet == null) { entrySet = new LinkedHashSet<MapEntry>(); final Collection<PropertyDescriptor> types = feature.getType().getDescriptors(); Name attName; Map attributesMap; for (Iterator<PropertyDescriptor> iterator = types.iterator(); iterator.hasNext(); ) { attName = iterator.next().getName(); attributesMap = new AttributeMap(attName, feature); entrySet.add( new MapEntry<Object, Object>(attName.getLocalPart(), attributesMap)); } } return entrySet; } }
private SimpleHash buildType(ComplexType ft) { // create a variable "attributes" which his a list of all the // attributes, but at the same time, is a map keyed by name Map<String, Object> attributeMap = new LinkedHashMap<String, Object>(); Collection<PropertyDescriptor> descriptors = ft.getDescriptors(); for (Iterator<PropertyDescriptor> it = descriptors.iterator(); it.hasNext(); ) { PropertyDescriptor descr = it.next(); Map<String, Object> attribute = new HashMap<String, Object>(); attribute.put("name", descr.getName().getLocalPart()); attribute.put("namespace", getNamespace(descr.getName())); attribute.put("prefix", getPrefix(descr.getName())); attribute.put("type", descr.getType().getBinding().getName()); attribute.put( "isGeometry", Boolean.valueOf(Geometry.class.isAssignableFrom(descr.getType().getBinding()))); attributeMap.put(descr.getName().toString(), attribute); } // build up the result, feature type is represented by its name an // attributes SimpleHash map = new SimpleHash(); map.put("attributes", new SequenceMapModel(attributeMap, this)); map.put("name", ft.getName().getLocalPart()); map.put("namespace", getNamespace(ft.getName())); map.put("prefix", getPrefix(ft.getName())); return map; }
/** * Return only the schema descriptors * * @return */ public Collection<PropertyDescriptor> getTypeDescriptors() { if (subject instanceof ComplexType) { return ((ComplexType) subject).getDescriptors(); } else { return Collections.EMPTY_LIST; } }
/** * Returns the list of descriptors defined in the provided schema, preserving declaration order * when relevant. * * @param schema * @return */ // @SuppressWarnings("unchecked") public static List /* <? extends Descriptor> */ list(AttributeType type) { ArrayList list = new ArrayList(); if (type instanceof ComplexType) { list = new ArrayList(((ComplexType) type).getDescriptors()); } return list; // if (schema instanceof OrderedDescriptor) { // return ((OrderedDescriptor) schema).sequence(); // } else if (schema instanceof AllDescriptor) { // return new ArrayList/*<AttributeDescriptor>*/(((AllDescriptor) // schema) // .all()); // } else if (schema instanceof ChoiceDescriptor) { // return new ArrayList/*<Descriptor>*/(((ChoiceDescriptor) schema) // .options()); // } // // return Collections.EMPTY_LIST; }
/** * Returns The name of attributes defined in the type. * * @param type The type. */ public static Name[] names(ComplexType type) { ArrayList names = new ArrayList(); for (Iterator itr = type.getDescriptors().iterator(); itr.hasNext(); ) { AttributeDescriptor ad = (AttributeDescriptor) itr.next(); names.add(ad.getName()); } return (Name[]) names.toArray(new Name[names.size()]); }
private static void validateAll(ComplexType type, ComplexAttribute att, Collection content) throws IllegalAttributeException { processAll(type.getDescriptors(), content); }
public Collection<PropertyDescriptor> getDescriptors() { return ((ComplexType) getSubject()).getDescriptors(); }
/** * Returns the set of all descriptors of a complex type, including from supertypes. * * @param type The type, non null. * @return The list of all descriptors. */ public static List<PropertyDescriptor> descriptors(ComplexType type) { // get list of descriptors from types and all supertypes List<PropertyDescriptor> children = new ArrayList<PropertyDescriptor>(); ComplexType loopType = type; while (loopType != null) { children.addAll(loopType.getDescriptors()); loopType = loopType.getSuper() instanceof ComplexType ? (ComplexType) loopType.getSuper() : null; } return children; }
/** * Returns the set of descriptors matching the given local name within the given type. * * @param type The type, non null. * @param name The name, non null. * @return The list of descriptors named 'name', or an empty list if none such match. */ public static List /* <PropertyDescriptor> */ descriptors(ComplexType type, String name) { if (name == null) 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); } } // only look up in the super type if the descriptor is not found // as a direct child definition if (match.size() == 0) { AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name); match.addAll(superDescriptors); } } return match; }
/** * Returns the set of descriptors matching the given name. * * @param type The type, non null. * @param name The name, non null. * @return The list of descriptors named 'name', or an empty list if none such match. */ public static List /* <PropertyDescriptor> */ descriptors(ComplexType type, Name name) { if (name == null) 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); } } // only look up in the super type if the descriptor is not found // as a direct child definition if (match.size() == 0) { AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name); match.addAll(superDescriptors); } } return match; }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
/** * Complete the definition of a type and store it in the schema. * * <p>This method calls {@link AttributeType#getSuper()} (and {@link * ComplexType#getDescriptors()} where applicable) to ensure the construction of the type (a * concrete {@link AbstractLazyAttributeTypeImpl} or {@link AbstractLazyComplexTypeImpl} * sublass) is complete. This should be sufficient to avoid any nasty thread-safety surprises in * code using this schema. * * @param type the type to complete and store */ private void put(AttributeType type) { type.getSuper(); if (type instanceof ComplexType) { ((ComplexType) type).getDescriptors(); } put(type.getName(), type); } }
Collection schema = type.getDescriptors(); if (type.getDescriptors().isEmpty()) { if (!content.isEmpty()) { throw new IllegalAttributeException(
descriptors.addAll(((ComplexType) subject).getDescriptors());
properties.addAll(cType.getDescriptors());