protected void addExpressions (Collection tags, String selector, PrintWriter pw, String collectionName, File sourceFile) {
String fileName = sourceFile != null ? sourceFile.getPath ().replace ('\\', '/') : "<unknown>";
Iterator iter = tags.iterator ();
while (iter.hasNext ()) {
XTag tag = (XTag) iter.next ();
if (isAttribute (tag)) {
String expression = tag.getName () + " " + tag.getValue ();
expression = expression.trim ();
// Remove the second @-sign.
expression = expression.substring (1);
if (selector != null) {
if (expression.startsWith (".")) {
// We have selector, tag does...
String tagSelector = expression.substring (1, expression.indexOf (" "));
expression = expression.substring (expression.indexOf (" ")).trim ();
if (!selector.equals (tagSelector)) {
// ...but they didn't match.
continue;
}
} else {
// We have selector, but tag doesn't
continue;
}
} else {
// No selector, but tag has selector.
if (expression.startsWith (".")) {
continue;
}
}
pw.println (" {");
outputAttributeExpression (pw, expression, fileName, tag.getLineNumber (), "_attr");
pw.println (" Object _oattr = _attr; // Need to erase type information");
pw.println (" if (_oattr instanceof org.apache.commons.attributes.Sealable) {");
pw.println (" ((org.apache.commons.attributes.Sealable) _oattr).seal ();");
pw.println (" }");
pw.println (" " + collectionName + ".add ( _attr );");