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); } if (!(descriptor instanceof AttributeDescriptor)) { String msg = name + " references a non attribute"; throw new IllegalArgumentException(msg); } return (AttributeDescriptor) descriptor; }
/** * Wraps a {@link AttributeType} in {@link AttributeDescriptor}. * * @param type The attribute type. * @return The attribute descriptor. */ public static final AttributeDescriptor wrapAttributeType(AttributeType type) { if (type == null) { return null; } return new AttributeDescriptorImpl(type, type.getName(), 1, 1, true, null); }
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); } if (!(descriptor instanceof AssociationDescriptor)) { String msg = name + " references a non association"; throw new IllegalArgumentException(msg); } return (AssociationDescriptor) descriptor; }
public void add(AttributeType type) { put(type.getName(), type); }
public AttributeImpl(Object content, AttributeType type, Identifier id) { this(content, new AttributeDescriptorImpl(type, type.getName(), 1, 1, true, null), id); }
/** * Equality by name. Yes, this may be a surprise to some client code, but how else do you define * equality in the face of cyclic type definitions, without breaking encapsulation to analyse * the full graph of types? * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object other) { if (!(other instanceof AttributeType)) { return false; } else { return name.equals(((AttributeType) other).getName()); } }
/** * Returns the attribute descriptor from a list which matches the specified name, or <code>null * </code> if no such descriptor is found. * * @param descriptors The list of {@link AttributeDescriptor}. * @param name The name to match. * @return The matching attribute descriptor, or <code>null</code>. */ public static final AttributeDescriptor find(List descriptors, Name name) { if (name == null) return null; for (Iterator i = descriptors.iterator(); i.hasNext(); ) { AttributeDescriptor attributeType = (AttributeDescriptor) i.next(); if (name.equals(attributeType.getType().getName())) { return attributeType; } } return null; // no default geometry here? }
public int visit(Graphable element, GraphTraversal traversal) { AttributeType type = (AttributeType) element.getObject(); //only add if in this schema if (type.getName().getNamespaceURI().equals(schema.getTargetNamespace())) { sorted.add(element.getObject()); } return GraphTraversal.CONTINUE; }
public String toString() { StringBuffer sb = new StringBuffer(getClass().getSimpleName()).append(":"); sb.append(getDescriptor().getName().getLocalPart()); if (!getDescriptor() .getName() .getLocalPart() .equals(getDescriptor().getType().getName().getLocalPart()) || id != null) { sb.append("<"); sb.append(getDescriptor().getType().getName().getLocalPart()); if (id != null) { sb.append(" id="); sb.append(id); } sb.append(">"); } sb.append("="); sb.append(value); return sb.toString(); }
/** * 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); } }
/** Initializes builder state from another attribute type. */ public AttributeTypeBuilder init(AttributeType type) { name = type.getName().getLocalPart(); separator = type.getName().getSeparator(); namespaceURI = type.getName().getNamespaceURI(); isAbstract = type.isAbstract(); if (type.getRestrictions() != null) { restrictions().addAll(type.getRestrictions()); } description = type.getDescription() != null ? type.getDescription().toString() : null; isIdentifiable = type.isIdentified(); binding = type.getBinding(); superType = type.getSuper(); if (type instanceof GeometryType) { crs = ((GeometryType) type).getCoordinateReferenceSystem(); } return this; }
XSDParticle particle(Attribute att) { XSDFactory factory = XSDFactory.eINSTANCE; AttributeType attType = att.getType(); XSDTypeDefinition xsdType = schemaIndex.getTypeDefinition( new QName( attType.getName().getNamespaceURI(), attType.getName().getLocalPart())); XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(att.getName().getLocalPart()); element.setTargetNamespace(att.getName().getNamespaceURI()); element.setTypeDefinition(xsdType); XSDParticle particle = factory.createXSDParticle(); particle.setContent(element); return particle; } }