コード例 #1
0
  /**
   * 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
コード例 #2
0
  /**
   * Returns the ComplexType of associated with the given name
   *
   * @return the ComplexType of associated with the given name, or null if no ComplexType with the
   *     given name was found.
   */
  public ComplexType getComplexType(String name) {

    // -- Null?
    if (name == null) {
      String err = NULL_ARGUMENT + "getComplexType: ";
      err += "'name' cannot be null.";
      throw new IllegalArgumentException(err);
    }

    // -- Namespace prefix?
    String canonicalName = name;
    String nsprefix = "";
    String ns = targetNS;
    int colon = name.indexOf(':');
    if (colon != -1) {
      canonicalName = name.substring(colon + 1);
      nsprefix = name.substring(0, colon);
      ns = (String) namespaces.get(nsprefix);
      if (ns == null) {
        String err = "getComplexType: ";
        err += "Namespace prefix not recognized '" + name + "'";
        throw new IllegalArgumentException(err);
      }
    }

    // -- Get GetComplexType object
    if ((ns == null) || (ns.equals(targetNS))) return (ComplexType) complexTypes.get(canonicalName);
    else {
      Schema schema = getImportedSchema(ns);
      if (schema != null) return schema.getComplexType(canonicalName);
    }

    return null;
  } // -- getComplexType
コード例 #3
0
  /**
   * Returns the SimpleType associated with the given name, or null if no such SimpleType exists.
   *
   * @return the SimpleType associated with the given name, or null if no such SimpleType exists.
   */
  public SimpleType getSimpleType(String name) {

    // -- Null?
    if (name == null) {
      String err = NULL_ARGUMENT + "getSimpleType: ";
      err += "'name' cannot be null.";
      throw new IllegalArgumentException(err);
    }

    // -- Namespace prefix?
    String canonicalName = name;
    String nsPrefix = "";
    String ns = null;
    int colon = name.indexOf(':');
    if (colon >= 0) {
      canonicalName = name.substring(colon + 1);
      nsPrefix = name.substring(0, colon);
      ns = (String) namespaces.get(nsPrefix);
      if (ns == null) {
        String err = "getSimpleType: ";
        err += "Namespace prefix not recognised '" + name + "'";
        throw new IllegalArgumentException(err);
      }
    }

    // -- Get SimpleType object
    SimpleType result = null;
    if (ns == null) {
      // -- first try built-in types
      result = simpleTypesFactory.getBuiltInType(name);
      // if we have a built-in type not declared in the good namespace -> Exception
      if ((result != null) && (namespaces.containsValue(DEFAULT_SCHEMA_NS))) {
        String err =
            "getSimpleType: the simple type '"
                + name
                + "' has not been declared in XML Schema namespace.";
        throw new IllegalArgumentException(err);
      }

      // -- otherwise check user-defined types
      if (result == null) result = (SimpleType) simpleTypes.get(name);
    } else if (ns.equals(schemaNS)) result = simpleTypesFactory.getBuiltInType(canonicalName);
    else if (ns.equals(targetNS)) result = (SimpleType) simpleTypes.get(canonicalName);
    else {
      Schema schema = getImportedSchema(ns);
      if (schema != null) result = schema.getSimpleType(canonicalName);
    }

    // -- Result could be a deferredSimpleType => getType will resolve it
    if (result != null) result = (SimpleType) result.getType();

    return result;
  } // -- getSimpleType
コード例 #4
0
 /**
  * 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
コード例 #5
0
 /**
  * Returns the reference if any
  *
  * @returns the reference if any
  */
 public ModelGroup getReference() {
   if (groupRef != null) return _schema.getModelGroup(groupRef);
   return null;
 } // -- getReference