}
if (value != null) {
Node node = ConstantNode.UNDEFINED;
switch(attr.getType()) {
case Attribute.TYPE_STRING:
node = new ConstantNode(Any.create(value));
break;
case Attribute.TYPE_DOUBLE:
try {
node = new ConstantNode(Any.create(Double.parseDouble(value)));
} catch (NumberFormatException nfe) {
parser.error(parser.getLocation(), "Value of attribute '"+name+"' is not a floating point number");
}
break;
case Attribute.TYPE_INT:
try {
node = new ConstantNode(Any.create(anvil.util.Conversions.parseNumberUnsafe(value)));
} catch (NumberFormatException nfe) {
parser.error(parser.getLocation(), "Value of attribute '"+name+"' is not an integer");
}
break;
case Attribute.TYPE_BOOLEAN:
node = new ConstantNode(Any.create(Any.IS_BOOLEAN, value));
break;
case Attribute.TYPE_EXPR:
value = value.trim();
if (value.length() > 0) {
ExpressionParser p = new ExpressionParser(parser, parser.getLocation(), value);
node = p.parseExpression(p.TYPE_VALUE).getChild();
} else {
node = ConstantNode.UNDEFINED;
}
break;
}
nodes.add(new MappingNode(new ConstantNode(name), node));
}
}
if (_tagdef.allowAnyAttributes()) {
Iterator iter = _tag.getAttributes();
while(iter.hasNext()) {
anvil.parser.Attribute attr = (anvil.parser.Attribute)iter.next();
String name = attr.getName();
if (!_tagdef.hasAttribute(name)) {
nodes.add(new MappingNode(
new ConstantNode(name),
new ConstantNode(attr.getValue())));
}
}
}
int n = nodes.size();
ExpressionList childs = new ExpressionList(n);
for(int i=0; i<n; i++) {
childs.setChild(i, (Node)nodes.get(i));
}
Location location = getLocation();
_init = buildExpr(location,
_tagdef.getInitHandler(),
null,
new ExpressionList(
new ParentNode(), new ConstantNode(_name),
new ArrayNode(childs)));
_start = buildExpr(location,
_tagdef.getStartHandler(),
_tagdef.getStartMethod(),