OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
if (name == null) {
handleException("The 'name' attribute is required for a property definition");
return null;
} else {
Property property = new Property();
property.setName(name.getAttributeValue());
String value = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "value"));
String src = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "src"));
String key = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "key"));
OMElement content = elem.getFirstElement();
if(value != null) {
property.setType(Property.VALUE_TYPE);
property.setValue(value);
} else if(src != null) {
property.setType(Property.SRC_TYPE);
try {
property.setSrc(new URL(src));
} catch (MalformedURLException e) {
handleException("Given src attribute " + src + "is not a propper URL.");
}
} else if(key != null) {
property.setType(Property.DYNAMIC_TYPE);
property.setKey(key);
} else if(content != null) {
if (content instanceof OMText) {
property.setType(Property.INLINE_STRING_TYPE);
property.setValue(content.getText());
} else {
property.setType(Property.INLINE_XML_TYPE);
property.setValue(content);
}
}
return property;
}
}