/** * Returns the ModeGroup of associated with the given name * * @return the ModelGroup of associated with the given name, or null if no ModelGroup with the * given name was found. */ public ModelGroup getModelGroup(String name) { String ns = null; if (name == null) { String err = NULL_ARGUMENT + "getModelGroup: "; err += " 'name' can not be null"; throw new IllegalArgumentException(err); } int idx = name.indexOf(':'); if (idx >= 0) { String nsPrefix = name.substring(0, idx); name = name.substring(idx + 1); ns = (String) namespaces.get(nsPrefix); if (ns == null) { String err = "getModelGroup: "; err += "Namespace prefix not recognized '" + nsPrefix + "'"; throw new IllegalArgumentException(err); } } if ((ns == null) || (ns.equals(targetNS))) return (ModelGroup) _group.get(name); else { Schema schema = getImportedSchema(ns); if (schema != null) { String warning = "Warning : do not forget to generate the source "; warning += "for the schema with this targetNamespace" + schema.getTargetNamespace(); System.out.println(warning); return schema.getModelGroup(name); } } return null; } // --getModelGroup
/** * Adds the given Schema definition to this Schema definition as an imported schenma * * @param schema the Schema to add to this Schema as an imported schema * @exception SchemaException if the Schema already exists */ public synchronized void addImportedSchema(Schema schema) throws SchemaException { String targetNamespace = schema.getTargetNamespace(); if (importedSchemas.get(targetNamespace) != null) { String err = "a Schema has already been imported with the given namespace: "; throw new SchemaException(err + targetNamespace); } importedSchemas.put(targetNamespace, schema); } // -- addImportedSchema