Lookup { {{ public static final int BUILT_IN_JAVA_TYPE = 0; public static final int BUILT_IN_NON_JAVA_TYPE = 1; public static final int USER_DEFINED_TYPE = 10; private static Hashtable builtInJavaTypes = null; private static Hashtable builtInNonJavaTypes = null; private static Hashtable typeNames = null; }} public static TypeInfo resolveXMLTypeName(String XMLType) {{ if ((builtInJavaTypes == null) && (builtInNonJavaTypes == null)) createTypeTables(); TypeInfo typeinfo = new TypeInfo(); typeinfo.typeName = "Unknown"; // First, check if it's a built-in type with a corresponding Java type Object o = builtInJavaTypes.get(XMLType); if (o != null) { typeinfo.category = BUILT_IN_JAVA_TYPE; typeinfo.typeName = (String) o; typeinfo.classDef = null; } else // check if it's a built-in type with no corresponding Java type { o = builtInNonJavaTypes.get(XMLType); if (o != null) { typeinfo.category = BUILT_IN_NON_JAVA_TYPE; typeinfo.classDef = (DataClass) o; typeinfo.typeName = typeinfo.classDef.get_name(); } else // it's not an implemented built-in data type { typeinfo.category = USER_DEFINED_TYPE; typeinfo.typeName = XMLType; typeinfo.classDef = null; } } return typeinfo; }} public static boolean isBuiltInXMLType(String XMLType) {{ if ((builtInJavaTypes == null) && (builtInNonJavaTypes == null)) createTypeTables(); return (builtInJavaTypes.containsKey(XMLType) || builtInNonJavaTypes.containsKey(XMLType)); }} public static String useObjectType(String typeName) {{ if (typeName.equals("byte")) return "Byte"; if (typeName.equals("char")) return "Character"; if (typeName.equals("double")) return "Double"; if (typeName.equals("float")) return "Float"; if (typeName.equals("int")) return "Integer"; if (typeName.equals("short")) return "Short"; return typeName; }} public static String getUniqueName(String baseName) {{ // COMPLETE LATER String newName = baseName; return newName; }} private static void createTypeTables() {{ builtInJavaTypes = new Hashtable(); builtInNonJavaTypes = new Hashtable(); // Add the entries for the XML built-in data types that have a // corresponding Java type builtInJavaTypes.put("byte", "byte"); builtInJavaTypes.put("CDATA", "String"); builtInJavaTypes.put("decimal", "double"); builtInJavaTypes.put("float", "float"); builtInJavaTypes.put("int", "int"); builtInJavaTypes.put("NMTOKEN", "String"); builtInJavaTypes.put("string", "String"); // ADD REMAINING ENTRIES LATER // Add the entries for the XML built-in data types that do not have a // corresponding Java type - and equivalent classes are to be created // to implement them DataClass classDef; classDef = DataClass.parse( "DataClass \"XMLpositiveInteger\" \"SIMPLE\" false () () " + "(ElementClassPart Constraint 1 1 minV \"1\" minI true " + "\"value\" \"int\")"); builtInNonJavaTypes.put("positiveInteger", classDef); classDef = DataClass.parse( "DataClass \"XMLdate\" \"SIMPLE\" false () () " + "(ElementClassPart Constraint 1 1 \"date\" \"String\")"); builtInNonJavaTypes.put("date", classDef); // ADD REMAINING ENTRIES LATER }} {{ public static class TypeInfo { String typeName; int category; DataClass classDef; } }} }