* @return the updated instance.
* @exception JDOMException if there is an error consuming the message.
*/
private Select consumeMsg(Select object, Element selectElement) throws JDOMException {
Select select = (object != null) ? (Select) object : new Select();
// --------------------------------
// Read the DISTINCT attribute
// --------------------------------
String distinct = selectElement.getAttributeValue(TagNames.Attributes.DISTINCT);
if ( distinct != null ) {
if ( distinct.equalsIgnoreCase("true") ) { //$NON-NLS-1$
select.setDistinct(true);
}
}
// --------------------------------
// Read the STAR attribute
// --------------------------------
String star = selectElement.getAttributeValue(TagNames.Attributes.STAR);
if ( star != null ) {
if ( star.equalsIgnoreCase("true") ) { //$NON-NLS-1$
if ( selectElement.getChildren() != null ) {
throw new JDOMException("No children expected when star is chosen."); //$NON-NLS-1$
}
return select;
}
}
// --------------------------------
// Read the IDENTIFIER elements ...
// --------------------------------
List idents = selectElement.getChildren();
Iterator identIter = idents.iterator();
while ( identIter.hasNext() ) {
Element dataElement = (Element) identIter.next();
Attribute dataType = dataElement.getAttribute(TagNames.Attributes.TYPE);
// add the dataType of the element to the list containing dataTypes
ElementSymbol nodeID = new ElementSymbol(dataElement.getText());
Class nodeType = (Class) TagNames.TYPE_MAP.get(dataType.getValue());
if (nodeType == null) {
throw new JDOMException("Unknown class for type \"" + dataType.getValue() + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
}
nodeID.setType(nodeType);
select.addSymbol(nodeID);
}
return select;
}