* @param property the Property used to build the Attribute
* @param schema the schema currently being generated
* @return
*/
private Attribute buildAttribute(Property property, Schema schema) {
Attribute attribute = new Attribute();
QName attributeName = property.getSchemaName();
attribute.setName(attributeName.getLocalPart());
if (property.isRequired()) {
attribute.setUse(Attribute.REQUIRED);
}
String fixedValue = property.getFixedValue();
if (fixedValue != null){
attribute.setFixed(fixedValue);
}
// Check to see if it's a collection
TypeInfo info = (TypeInfo) typeInfo.get(property.getActualType().getQualifiedName());
String typeName = getTypeNameForComponent(property, schema, property.getActualType(), attribute, false);
if (isCollectionType(property)) {
if(!property.isXmlList() && null != property.getXmlPath() && property.getXmlPath().contains("/")) {
attribute.setType(typeName);
} else {
// assume XmlList for an attribute collection
SimpleType localType = new SimpleType();
org.eclipse.persistence.internal.oxm.schema.model.List list = new org.eclipse.persistence.internal.oxm.schema.model.List();
list.setItemType(typeName);
localType.setList(list);
attribute.setSimpleType(localType);
}
} else {
// may need to qualify the type
if (typeName != null && !typeName.contains(COLON)) {
if (info.getSchema() == schema) {
String uri = schema.getTargetNamespace();
if(uri == null) {
uri = EMPTY_STRING;
}
String prefix = getPrefixForNamespace(schema, uri);
if (prefix != null) {
typeName = prefix + COLON + typeName;
}
}
}
attribute.setType(typeName);
}
return attribute;
}