});
}
if (m_bValidatedOnly)
{
XMLUtil.withFirstChildElement(enumerationElement, "Locales", false, new ElementHandler()
{
public void handleElement(Element localesElement)
{
final Set localeSet = new HashHolder();
XMLUtil.forEachChildElement(localesElement, "Locale",
m_helper.new ElementHandler("locale")
{
public void handleElement(Element localeElement, String sLocale)
{
if (!localeSet.add(sLocale))
{
throw new MetadataException("err.meta.enumLocaleDup",
new Object[]{sLocale, sEnumerationName});
}
XMLUtil.getReqStringAttr(localeElement, "caption");
}
});
}
});
}
final Set valueSet = new HashHolder();
m_enumerationValueMap.put(sEnumerationName, valueSet);
XMLUtil.withFirstChildElement(enumerationElement, "Values", false, new ElementHandler()
{
public void handleElement(Element valuesElement)
{
final Set nameSet = new HashHolder();
final Set behaveAsSet = new HashHolder();
final Set externSet = new HashHolder();
final List fixupList = new ArrayList();
XMLUtil.forEachChildElement(valuesElement, "Value",
m_helper.new ElementHandler("value")
{
public void handleElement(Element valueElement, String sName)
{
XMLMetadataHelper.validateName(sName);
fixupList.add(sName);
if (!nameSet.add(sName))
{
throw new MetadataException("err.meta.enumValueNameDup",
new Object[]{sName, sEnumerationName});
}
final String sValue = XMLUtil.getReqStringAttr(valueElement, "value");
if (!valueSet.add(sValue))
{
throw new MetadataException("err.meta.enumValueDup",
new Object[]{sValue, sEnumerationName});
}
fixupList.add(sValue);
boolean bHasBehavior = XMLUtil.getBooleanAttr(valueElement, "hasBehavior", false);
fixupList.add(Boolean.valueOf(bHasBehavior));
String sBehaveAsValue = XMLUtil.getStringAttr(valueElement, "behaveAsValue");
if (sBehaveAsValue != null)
{
if (bHasBehavior)
{
if (!sBehaveAsValue.equals(sValue))
{
throw new MetadataException("err.meta.enumBehaveAsValueMismatch",
new Object[]{sBehaveAsValue, sValue, sEnumerationName});
}
}
else
{
if (sBehaveAsValue.equals(sValue))
{
throw new MetadataException("err.meta.enumInvalidSelfReference",
new Object[]{sValue, sEnumerationName});
}
behaveAsSet.add(sBehaveAsValue);
}
}
String sExternValue = XMLUtil.getStringAttr(valueElement, "externalValue");
if (sExternValue != null)
{
if (!externSet.add(sExternValue))
{
throw new MetadataException("err.meta.enumExternValueDup",
new Object[]{sExternValue, sEnumerationName});
}
}
final String sParentValue = XMLUtil.getStringAttr(valueElement, "parentValue");
if (sParentValue != null)
{
if (sParentEnumeration == null)
{
throw new MetadataException("err.meta.enumParentValue", new Object[]{sEnumerationName});
}
m_inheritanceFixupList.add(new ContextFixup(m_helper)
{
public void fixup()
{
Metaclass parent = m_metadata.getMetaclass(sParentEnumeration);
if (!((Set)m_enumerationValueMap.get(sParentEnumeration)).contains(parent.getAttribute("value").getType().convert(sParentValue)))
{
throw new MetadataLookupException("err.meta.enumParentValueLookup", sParentValue, sParentEnumeration);
}
}
});
}
else
{
if (sParentEnumeration != null)
{
throw new MetadataException("err.meta.enumNoParentValue", new Object[]{sValue, sEnumerationName});
}
}
if (m_bValidatedOnly)
{
XMLUtil.withFirstChildElement(valueElement, "Locales", false, new ElementHandler()
{
public void handleElement(Element localesElement)
{
final Set localeSet = new HashHolder();
XMLUtil.forEachChildElement(localesElement, "Locale",
m_helper.new ElementHandler("locale")
{
public void handleElement(Element localeElement, String sLocale)
{
if (!localeSet.add(sLocale))
{