/** * Creates standard xml attributes present on all xs:element elements. * These are name, maxOccurs, minOccurs and nillable. * * @param attribute the attribute type from which the information is * retrieved * * @return an org.xml.sax.helpers.AttributesImpl object that contains * the standard attributes */ protected AttributesImpl createStandardAttributes( AttributeType attribute) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "name", "name", "", attribute.getName()); if (attribute.isNillable() && attribute.getMinOccurs() == 0) { atts.addAttribute("", "minOccurs", "minOccurs", "", "0"); atts.addAttribute("", "nillable", "nillable", "", "true"); } else { atts.addAttribute("", "minOccurs", "minOccurs", "", "1"); atts.addAttribute("", "nillable", "nillable", "", "false"); } return atts; } }
private AttributeType override(AttributeType type, AttributeType override ){ int max = override.getMaxOccurs(); if( max < 0 ) max = type.getMinOccurs(); int min = override.getMinOccurs(); if( min < 0 ) min = type.getMinOccurs(); String name = override.getName(); if( name == null ) name = type.getName(); Filter restriction = override( type.getRestriction(), override.getRestriction() ); Class javaType = override.getType(); if( javaType == null ) javaType = type.getType(); boolean isNilable = override.isNillable(); Object defaultValue = override.createDefaultValue(); if( defaultValue == null ) defaultValue = type.createDefaultValue(); // WARNING cannot copy metadata! return AttributeTypeFactory.newAttributeType( name, javaType, isNilable, restriction, defaultValue, null ); }
protected DefaultAttributeType(AttributeType copy) { this.name = copy.getName(); this.type = copy.getType(); this.nillable = copy.isNillable(); this.min = copy.getMinOccurs(); this.max = copy.getMaxOccurs(); this.defaultValue = copy.createDefaultValue(); }
protected DefaultAttributeType(AttributeType copy) { super(copy.getType(),copy.getName(),copy.getMinOccurs(),copy.getMaxOccurs(),copy.isNillable(),copy.getDefaultValue()); }