String base = Character.toUpperCase(pname.charAt(0)) +
pname.substring(1);
String gname = "get" + base;
ClassItem gmeth = cf.getMethod(gname, "()");
if (gmeth == null) {
throw new JiBXException("No method " + gname +
"() found for property " + base + " in class " +
cf.getName());
} else {
String tname = gmeth.getTypeName();
String sname = "set" + base;
String sig = "(" + gmeth.getSignature().substring(2) + ")V";
ClassItem smeth = cf.getMethod(sname, sig);
if (smeth == null) {
throw new JiBXException("No method " + sname + "(" + tname +
") found for property " + base + " in class " +
cf.getName());
} else {
// find type of handling needed for field type
boolean simple = false;
boolean object = true;
boolean attribute = true;
if (ClassItem.isPrimitive(tname)) {
simple = true;
object = false;
} else if (s_objectPrimitiveSet.contains(tname)) {
simple = true;
} else if (tname.equals("byte[]")) {
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);