public AttributeType getType() { return delegate.getType(); }
/** * Validates content against an attribute. * * @param attribute The attribute. * @param attributeContent Content of attribute (often attribute.getValue() * @throws IllegalAttributeException In the event that content violates any restrictions * specified by the attribute. */ public static void validate(Attribute attribute, Object attributeContent) throws IllegalAttributeException { validate(attribute.getType(), attribute, attributeContent, false); } /**
/** * Ensures an attribute value is withing the restrictions of the AttributeDescriptor and * AttributeType. * * @param attribute * @return true if the attribute value is valid */ public static boolean isValid(Attribute attribute) { try { validate(attribute.getType(), attribute, attribute.getValue(), false); return true; } catch (IllegalAttributeException invalid) { return false; } } /**
AttributeType attType = att.getType(); boolean contains = false; for (Iterator sitr = schema.iterator(); sitr.hasNext(); ) {
simpleContent = buildSimpleContent(attribute.getType(), value); contents.add(simpleContent); ArrayList<Attribute> nestedAttContents = new ArrayList<Attribute>();
/** * Find the last element in the given path and set the index. * * @param parent Parent attribute where the path is going to be set in. * @param sl The path to be set. * @param index The index for the last element. */ private void setLastElementIndex(Attribute parent, StepList sl, int index) { if (!(parent.getType() instanceof ComplexTypeImpl)) { // not a complex type, so just set the first index as a simple type // can't have another complex type as children anyway sl.get(0).setIndex(index); return; } ComplexTypeImpl type = (ComplexTypeImpl) parent.getType(); // check the last step first and gradually move to the previous one int lastIndex = sl.size() - 1; Name lastStep = Types.toTypeName(sl.get(lastIndex).getName()); while (!Types.isElement(type, lastStep)) { lastIndex--; if (lastIndex < 0) { return; } lastStep = Types.toTypeName(sl.get(lastIndex).getName()); } sl.get(lastIndex).setIndex(index); }
public AttributeType getType() { return delegate.getType(); }
if (Types.isSimpleContentType(parent.getType()) || Types.canHaveTextContent(parent.getType())) { return setSimpleContentValue(parent, value); } else if (Types.isGeometryType(parent.getType())) { ComplexFeatureTypeFactoryImpl typeFactory = new ComplexFeatureTypeFactoryImpl(); GeometryType geomType; if (parent.getType() instanceof GeometryType) { geomType = (GeometryType) parent.getType(); } else { geomType = (GeometryType) ((NonFeatureTypeProxy) parent.getType()).getSubject(); final Name attributeName = Types.toName(stepName); final AttributeType _parentType = parent.getType(); if (_parentType.getName().equals(XSSchema.ANYTYPE_TYPE.getName()) && targetDescriptor != null) {
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; } }
type = attribute.getType();
/** * Validates content against an attribute. * * @param attribute * The attribute. * @param attributeContent * Content of attribute (often attribute.getValue() * * @throws IllegalAttributeException * In the event that content violates any restrictions specified * by the attribute. */ public static void validate(Attribute attribute, Object attributeContent) throws IllegalAttributeException { validate(attribute.getType(), attribute, attributeContent, false); } /**
/** * Set a simple content value for an attribute. * * @param attribute * Attribute of simple content type. * @param value * Value for the simple content. * @return The attribute with simple content type. */ private Attribute setSimpleContentValue(Attribute attribute, Object value) { ArrayList<Attribute> contents = new ArrayList<Attribute>(); Attribute simpleContent = buildSimpleContent(attribute.getType(), value); contents.add(simpleContent); attribute.setValue(contents); return simpleContent; }
public String[] getPropertyNames(Object o) { Attribute att = (Attribute) o; // we only work on complex attributes if (att instanceof ComplexAttribute) { ComplexType type = (ComplexType) att.getType(); Collection attributes = type.getDescriptors(); String[] propNames = new String[attributes.size()]; int i = 0; for (Iterator itr = attributes.iterator(); itr.hasNext(); i++) { AttributeDescriptor descriptor = (AttributeDescriptor) itr.next(); // JD: this ignores namespaces propNames[i] = descriptor.getName().getLocalPart(); } return propNames; } return null; }
/** * Ensures an attribute value is withing the restrictions of the AttributeDescriptor and * AttributeType. * @param attribute * @return true if the attribute value is valid */ public static boolean isValid( Attribute attribute ){ try { validate(attribute.getType(), attribute, attribute.getValue(), false ); return true; } catch (IllegalAttributeException invalid ){ return false; } } /**
String attName; if (descriptor == null) { attName = att.getType().getName().getLocalPart(); } else { attName = descriptor.getName().getLocalPart();
AttributeType attType = att.getType(); boolean contains = false; for (Iterator sitr = schema.iterator(); sitr.hasNext();) {
type = attribute.getType();
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; }