private Type createGxpType(Node node, AttributeMap attrMap, Attribute gxpType) {
String kind = gxpType.getValue().getStaticString(alertSink, null);
GxpType type = GxpType.parse(kind);
if (type == null) {
alertSink.add(new InvalidAttributeValueError(gxpType));
return null;
}
switch (type) {
case BOOL:
return new BooleanType(node);
case BUNDLE:
String from = attrMap.get("from-element", null);
if (from == null || rootSchema == null) {
return null;
}
Map<String, AttributeValidator> subAttrMap = Maps.newHashMap(
rootSchema.getElementValidator(from).getAttributeValidatorMap());
// remove items from the exclude list
String exclude = attrMap.getOptional("exclude", null);
if (exclude != null) {
for (String eItem : exclude.split(",")) {
// TODO(harryh): make sure items in exclude list
// actually remove elements
subAttrMap.remove(eItem.trim());
}
}
return new BundleType(node, rootSchema, subAttrMap);
default:
alertSink.add(new InvalidAttributeValueError(gxpType));
return null;
}
}