Package org.apache.uima.fsvars

Examples of org.apache.uima.fsvars.FsVariablesException


  }

  public void declareFsVariable(String name, Type type) {
    // If a fsvar of that name already exists, throw an exception.
    if (isFsVariable(name)) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_variable_already_defined, new Object[] { name });
    }
    // Create the FS.
    FeatureStructure fs = this.cas.createFS(this.fsVariableType);
    // Set name and type features.
View Full Code Here


    // Get the type name, and corresponding type.
    String typeName = fs.getStringValue(this.typeFeature);
    Type type = this.cas.getTypeSystem().getType(typeName);
    // Check that the type name is valid.
    if (type == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.bad_typename_in_fsvar, new Object[] { typeName, name });
    }
    return type;
  }
View Full Code Here

    // Get fsvar (must exist).
    FeatureStructure fsvar = getFsVarForName(name);
    // Get type of fsvar.
    Type type = this.cas.getTypeSystem().getType(fsvar.getStringValue(this.typeFeature));
    if (type == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.bad_typename_in_fsvar, new Object[] {
              fsvar.getStringValue(this.nameFeature), name });
    }
    if (this.cas.getTypeSystem().subsumes(type, fs.getType())) {
      // Set variable value if type of var subsumes type of FS.
      fsvar.setFeatureValue(this.valueFeature, fs);
    } else {
      // If var type does not subsume value type, throw an exception.
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.illegal_fsvar_value, new Object[] { fs.getType().getName(), name,
              type.getName() });
    }
  }
View Full Code Here

      throw new NullPointerException("CAS");
    }
    // Get the fsvars index.
    this.index = this.cas.getIndexRepository().getIndex(FsVariables.INDEX_NAME);
    if (this.index == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_index_doesnt_exist, new Object[] { FsVariables.INDEX_NAME });
    }
    // Get the fsvars type.
    this.fsVariableType = this.cas.getTypeSystem().getType(FsVariables.TYPE_NAME);
    if (this.fsVariableType == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_type_doesnt_exist, new Object[] { FsVariables.TYPE_NAME });
    }
    // Get the name, type, and value features.
    this.nameFeature = this.fsVariableType.getFeatureByBaseName(FsVariables.NAME_FEATURE_NAME);
    if (this.nameFeature == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_feature_doesnt_exist,
          new Object[] { FsVariables.NAME_FEATURE_NAME });
    }
    this.typeFeature = this.fsVariableType.getFeatureByBaseName(FsVariables.TYPE_FEATURE_NAME);
    if (this.typeFeature == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_feature_doesnt_exist,
          new Object[] { FsVariables.TYPE_FEATURE_NAME });
    }
    this.valueFeature = this.fsVariableType.getFeatureByBaseName(FsVariables.VALUE_FEATURE_NAME);
    if (this.valueFeature == null) {
      throw new FsVariablesException(messageCatalog,
          FsVariablesException.fsvars_feature_doesnt_exist,
          new Object[] { FsVariables.VALUE_FEATURE_NAME });
    }
  }
View Full Code Here

    // Check that the fsvar FS is valid (not null and correct name)
    if ((fs != null) && fs.getStringValue(this.nameFeature).equals(name)) {
      return fs;
    }
    // If fsvar with "name" exists, throw an exception.
    throw new FsVariablesException(messageCatalog,
        FsVariablesException.no_such_fsvar, new Object[] { name });
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.fsvars.FsVariablesException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.