Element element = (Element)node;
if (Exmlc.EXML_IMPORT_NODE_NAME.equals(node.getLocalName())) {
String importedClassName = element.getAttribute(Exmlc.EXML_IMPORT_CLASS_ATTRIBUTE);
if (importedClassName == null || importedClassName.equals("")) {
int lineNumber = getLineNumber(componentNode);
throw new ExmlcException("<exml:import> element must contain a non-empty class attribute", lineNumber);
}
model.addImport(importedClassName);
} else if (Exmlc.EXML_ANNOTATION_NODE_NAME.equals(node.getLocalName())) {
AnnotationAt annotationAt = Exmlc.parseAnnotationAtValue(element.getAttribute(Exmlc.EXML_ANNOTATION_AT_ATTRIBUTE));
if (annotationAt != AnnotationAt.CONFIG) {
model.addAnnotation(element.getTextContent());
}
} else if (Exmlc.EXML_CONSTANT_NODE_NAME.equals(node.getLocalName())) {
String constantTypeName = element.getAttribute(Exmlc.EXML_DECLARATION_TYPE_ATTRIBUTE);
model.addImport(constantTypeName);
} else if (Exmlc.EXML_DESCRIPTION_NODE_NAME.equals(node.getLocalName())) {
model.setDescription(node.getTextContent());
} else if (Exmlc.EXML_VAR_NODE_NAME.equals(node.getLocalName())) {
Declaration var = new Declaration(element.getAttribute(Exmlc.EXML_DECLARATION_NAME_ATTRIBUTE),
element.getAttribute(Exmlc.EXML_DECLARATION_VALUE_ATTRIBUTE),
element.getAttribute(Exmlc.EXML_DECLARATION_TYPE_ATTRIBUTE));
if (!model.getVars().contains(var)) {
model.addVar(var);
}
} else if (Exmlc.EXML_CFG_NODE_NAME.equals(node.getLocalName())) {
String cfgName = element.getAttribute(Exmlc.EXML_CFG_NAME_ATTRIBUTE);
String cfgDefault = element.getAttribute(Exmlc.EXML_CFG_DEFAULT_ATTRIBUTE);
Element defaultValueElement = findChildElement(element,
Exmlc.EXML_NAMESPACE_URI, Exmlc.EXML_CFG_DEFAULT_NODE_NAME);
if (cfgDefault.length() != 0 && defaultValueElement != null) {
throw new ExmlcException("<exml:cfg> default value must be specified as either an attribute or a sub-element, not both for config '" + cfgName + "'.", getLineNumber(element));
}
if (cfgDefault.length() > 0) {
model.getJsonObject().set(cfgName, cfgDefault);
String cfgType = element.getAttribute(Exmlc.EXML_CFG_TYPE_ATTRIBUTE);
model.addImport(cfgType);
} else if (defaultValueElement != null) {
defaultValues.put(cfgName, getChildElements(defaultValueElement));
}
}
} else {
if (componentNode != null) {
int lineNumber = getLineNumber(componentNode);
throw new ExmlcException("root node of EXML contained more than one component definition", lineNumber);
}
componentNode = (Element)node;
}
}
}
if (componentNode == null) {
return;
}
String superFullClassName = createFullConfigClassNameFromNode(componentNode);
if (superFullClassName.equals(model.getConfigClass().getFullName())) {
int lineNumber = getLineNumber(componentNode);
throw new ExmlcException("Cyclic inheritance error: super class and this component are the same!. There is something wrong!", lineNumber);
}
ConfigClass superConfigClass = getConfigClassByName(superFullClassName, componentNode);
String superComponentClassName = superConfigClass.getComponentClassName();
if (model.getSuperClassName() == null) {
model.setSuperClassName(superComponentClassName);