Beispiel #1
0
 /**
  * Removes the given top level SimpleType from this Schema
  *
  * @param SimpleType the SimpleType to remove
  * @return true if the SimpleType has been removed, or false if the SimpleType wasn't top level or
  *     didn't exist in this Schema
  */
 public boolean removeSimpleType(SimpleType simpleType) {
   if (simpleTypes.contains(simpleType)) {
     simpleTypes.remove(simpleType.getName());
     return true;
   }
   return false;
 } // -- removeSimpleType
Beispiel #2
0
  /**
   * Adds the given SimpletType definition to this Schema defintion
   *
   * @param simpletype the SimpleType to add to this Schema
   * @exception SchemaException if the SimpleType does not have a name or if another SimpleType
   *     already exists with the same name
   */
  public synchronized void addSimpleType(SimpleType simpleType) throws SchemaException {

    String name = simpleType.getName();

    if ((name == null) || (name.length() == 0)) {
      String err =
          "No name found for top-level SimpleType. " + " A top-level SimpleType must have a name.";
      throw new SchemaException(err);
    }

    if (simpleType.getSchema() != this) {
      String err = "invalid attempt to add a SimpleType which ";
      err += "belongs to a different Schema; type name: " + name;
      throw new SchemaException(err);
    }
    if (simpleTypes.get(name) != null) {
      String err = "a SimpleType already exists with the given name: ";
      throw new SchemaException(err + name);
    }

    simpleType.setParent(this);
    simpleTypes.put(name, simpleType);
  } // -- addSimpleType