SpringBeanElement bean,
List<SpringBeanElement> beans) throws ContributionReadException {
SpringBeanElement innerbean = null;
SpringPropertyElement property = null;
SpringConstructorArgElement constructorArg = null;
try {
boolean completed = false;
while (!completed) {
switch (reader.next()) {
case START_ELEMENT:
QName qname = reader.getName();
if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
.getAttributeValue(null, "class"));
// Set the first name as bean name, when the @id attribute is absent.
if (reader.getAttributeValue(null, "id") == null) {
if (reader.getAttributeValue(null, "name") != null) {
String[] names = (reader.getAttributeValue(null, "name")).split(",");
innerbean.setId(names[0]);
}
}
innerbean.setInnerBean(true);
beans.add(innerbean);
readBeanDefinition(reader, innerbean, beans);
} else if (SpringImplementationConstants.PROPERTY_ELEMENT.equals(qname)) {
property = new SpringPropertyElement(reader.getAttributeValue(null, "name"));
if (reader.getAttributeValue(null, "ref") != null)
property.addRef(reader.getAttributeValue(null, "ref"));
bean.addProperty(property);
} else if (SpringImplementationConstants.CONSTRUCTORARG_ELEMENT.equals(qname)) {
constructorArg = new SpringConstructorArgElement(reader.getAttributeValue(null, "type"));
if (reader.getAttributeValue(null, "ref") != null)
constructorArg.addRef(reader.getAttributeValue(null, "ref"));
if (reader.getAttributeValue(null, "index") != null)
constructorArg.setIndex((new Integer(reader.getAttributeValue(null, "index"))).intValue());
if (reader.getAttributeValue(null, "value") != null)
constructorArg.addValue(reader.getAttributeValue(null, "value"));
bean.addCustructorArgs(constructorArg);
} else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
String ref = reader.getAttributeValue(null, "bean");
// Check if the parent element is a property
if (property != null) property.addRef(ref);
// Check if the parent element is a constructor-arg
if (constructorArg != null) constructorArg.addRef(ref);
} else if (SpringImplementationConstants.VALUE_ELEMENT.equals(qname)) {
String value = reader.getElementText();
// Check if the parent element is a constructor-arg
if (constructorArg != null) constructorArg.addValue(value);
} else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) ||
SpringImplementationConstants.SET_ELEMENT.equals(qname) ||
SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
if (property != null)
readCollections(reader, bean, beans, property, null);