simple = true;
attribute = false;
} else if (tname.startsWith("java.")) {
// check for standard library classes we can handle
ClassFile pcf = ClassCache.requireClassFile(tname);
if (pcf.getInitializerMethod("()") != null) {
simple = pcf.getMethod("toString",
"()Ljava/lang/String;") != null;
attribute = false;
}
}
if (simple) {
// define a simple value
ValueElement value = new ValueElement();
value.setGetName(gname);
value.setSetName(sname);
value.setName(valueName(pname));
if (object) {
value.setUsageName("optional");
}
if (!attribute) {
value.setStyleName("element");
}
contain.addChild(value);
} else if (m_enumerationNames.get(tname) != null) {
// define a value using deserializer method
String mname = (String)m_enumerationNames.get(tname);
int split = mname.lastIndexOf('.');
ClassFile dcf = ClassCache.
requireClassFile(mname.substring(0, split));
ClassItem dser =
dcf.getStaticMethod(mname.substring(split+1),
"(Ljava/lang/String;)");
if (dser == null || !tname.equals(dser.getTypeName())) {
throw new JiBXException("Deserializer method not " +
"found for enumeration class " + tname);
}
ValueElement value = new ValueElement();
value.setGetName(gname);
value.setSetName(sname);
value.setName(valueName(pname));
value.setUsageName("optional");
value.setStyleName("element");
value.setDeserializerName(mname);
contain.addChild(value);
} else if (m_mappedNames.get(tname) != null) {
// use mapping definition for class
StructureElement structure = new StructureElement();
structure.setUsageName("optional");
structure.setGetName(gname);
structure.setSetName(sname);
if (((String)m_mappedNames.get(tname)).length() == 0) {
// add a name for reference to abstract mapping
structure.setName(elementName(tname));
}
contain.addChild(structure);
if (m_verbose) {
nestingIndent(System.out);
System.out.println
("referenced existing binding for " + tname);
}
} else if (tname.endsWith("[]")) {
// array, only supported for mapped base type
String bname = tname.substring(0, tname.length()-2);
if (m_mappedNames.get(bname) == null) {
throw new JiBXException("Base element type " +
bname + " must be mapped");
} else {
StructureElement structure = new StructureElement();
structure.setUsageName("optional");
structure.setGetName(gname);
structure.setSetName(sname);
structure.setMarshallerName
("org.jibx.extras.TypedArrayMapper");
structure.setUnmarshallerName
("org.jibx.extras.TypedArrayMapper");
contain.addChild(structure);
}
} else {
// no defined handling, check collection vs. structure
ClassFile pcf = ClassCache.requireClassFile(tname);
StructureElementBase element;
if (pcf.isImplements("Ljava/util/List;")) {
// create a collection for list subclass
System.err.println("Warning: property " + pname +
" requires mapped implementation of item " +
"classes");
element = new CollectionElement();
element.setComment(" add details of collection " +
"items to complete binding definition ");
element.setGetName(gname);
element.setSetName(sname);
// specify factory method if just typed as interface
if ("java.util.List".equals(tname)) {
element.setFactoryName("org.jibx.runtime." +
"Utility.arrayListFactory");
}
} else if (pcf.isInterface() ||
m_ignoreNames.contains(tname)) {
// mapping reference with warning for interface
nestingIndent(System.err);
System.err.println("Warning: reference to " +