// if we are below a concrete class then we cannot declare any
// more primary key fields; thus, just use the parent invocation
if (hasConcreteSuperclass() || (hasSuperclass && _fields.length == 0))
return "";
CodeFormat code = newCodeFormat();
code.tab().append("public String toString").parens().
openBrace(2).endl();
String name;
Class type;
String appendDelimiter = "+ \"" + _token + "\" + ";
for (int i = 0; i < _fields.length; i++) {
// if this is not the first field, add a +
if (i == 0) {
code.tab(2).append("return ");
// add in the super.toString() if we have a parent
if (hasSuperclass && getDeclaredPrimaryKeyFields
(_meta.getPCSuperclassMetaData()).length > 0) {
code.append("super.toString").parens();
code.endl().tab(3).append(appendDelimiter);
}
} else
code.endl().tab(3).append(appendDelimiter);
name = _fields[i].getName();
type = _fields[i].getObjectIdFieldType();
if (type == String.class)
code.append(name);
else if (type == byte[].class)
code.append("toString").openParen(true).
append(name).closeParen();
else if (type == char[].class)
code.openParen(true).openParen(true).append(name).
append(" == null").closeParen().append(" ? \"null\"").
append(": String.valueOf").openParen(true).
append(name).closeParen().closeParen();
else if (type == Date.class)
code.openParen(true).openParen(true).append(name).
append(" == null").closeParen().append(" ? \"null\"").
endl().tab(4).append(": String.valueOf").
openParen(true).append(name).append(".getTime").
parens().closeParen().closeParen();
else
code.append("String.valueOf").openParen(true).
append(name).closeParen();
}
// no fields; just use ""
if (_fields.length == 0)
code.tab(2).append("return \"\"");
code.append(";").endl();
code.closeBrace(2);
return code.toString();
}