if(tag.hasDefaultValue()) {
Map<String, TagLibTagAttr> hash = tag.getAttributes();
Iterator<String> it = hash.keySet().iterator();
while(it.hasNext()) {
TagLibTagAttr att=hash.get(it.next());
if(!parent.containsAttribute(att.getName()) && att.hasDefaultValue()) {
Attribute attr=new Attribute(tag.getAttributeType()==TagLibTag.ATTRIBUTE_TYPE_DYNAMIC,
att.getName(),
CastOther.toExpression(LitString.toExprString(Caster.toString(att.getDefaultValue(),null)),att.getType()),att.getType()
);
parent.addAttribute(attr);
}
}
}
boolean hasAttributeCollection=args.contains("attributecollection");
// to less attributes
if(!hasAttributeCollection && min>count)
throw createTemplateException(data.cfml,"the tag "+tag.getFullName()+" must have at least "+min+" attributes",tag);
// too much attributes
if(!hasAttributeCollection && max>0 && max<count)
throw createTemplateException(data.cfml,"the tag "+tag.getFullName()+" can have a maximum of "+max+" attributes",tag);
// not defined attributes
if(type==TagLibTag.ATTRIBUTE_TYPE_FIXED || type==TagLibTag.ATTRIBUTE_TYPE_MIXED) {
Map<String, TagLibTagAttr> hash = tag.getAttributes();
Iterator<String> it = hash.keySet().iterator();
while(it.hasNext()) {
TagLibTagAttr att=hash.get(it.next());
if(att.isRequired() && !args.contains(att.getName()) && att.getDefaultValue()==null) {
if(!hasAttributeCollection)throw createTemplateException(data.cfml,"attribute "+att.getName()+" is required for tag "+tag.getFullName(),tag);
parent.addMissingAttribute(att.getName(),att.getType());
}
}
}
}
catch(TemplateException te){
data.cfml.setPos(start);
// if the tag supports a non name attribute try this
TagLibTagAttr sa = tag.getSingleAttr();
if(sa!=null) attrNoName(parent,tag,data,sa);
else throw te;
}
}
// tag without attributes name