Java Code Examples for org.apache.uima.cas.CAS#TYPE_NAME_SHORT_ARRAY

The following examples show how to use org.apache.uima.cas.CAS#TYPE_NAME_SHORT_ARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebAnnoCasUtil.java    From webanno with Apache License 2.0 4 votes vote down vote up
public static boolean isNativeUimaType(String aType)
{
    Validate.notNull(aType, "Type must not be null");
    
    switch (aType) {
    case CAS.TYPE_NAME_ANNOTATION:
    case CAS.TYPE_NAME_ANNOTATION_BASE:
    case CAS.TYPE_NAME_ARRAY_BASE:
    case CAS.TYPE_NAME_BOOLEAN:
    case CAS.TYPE_NAME_BOOLEAN_ARRAY:
    case CAS.TYPE_NAME_BYTE:
    case CAS.TYPE_NAME_BYTE_ARRAY:
    case CAS.TYPE_NAME_DOCUMENT_ANNOTATION:
    case CAS.TYPE_NAME_DOUBLE:
    case CAS.TYPE_NAME_DOUBLE_ARRAY:
    case CAS.TYPE_NAME_EMPTY_FLOAT_LIST:
    case CAS.TYPE_NAME_EMPTY_FS_LIST:
    case CAS.TYPE_NAME_EMPTY_INTEGER_LIST:
    case CAS.TYPE_NAME_EMPTY_STRING_LIST:
    case CAS.TYPE_NAME_FLOAT:
    case CAS.TYPE_NAME_FLOAT_ARRAY:
    case CAS.TYPE_NAME_FLOAT_LIST:
    case CAS.TYPE_NAME_FS_ARRAY:
    case CAS.TYPE_NAME_FS_LIST:
    case CAS.TYPE_NAME_INTEGER:
    case CAS.TYPE_NAME_INTEGER_ARRAY:
    case CAS.TYPE_NAME_INTEGER_LIST:
    case CAS.TYPE_NAME_LIST_BASE:
    case CAS.TYPE_NAME_LONG:
    case CAS.TYPE_NAME_LONG_ARRAY:
    case CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST:
    case CAS.TYPE_NAME_NON_EMPTY_FS_LIST:
    case CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST:
    case CAS.TYPE_NAME_NON_EMPTY_STRING_LIST:
    case CAS.TYPE_NAME_SHORT:
    case CAS.TYPE_NAME_SHORT_ARRAY:
    case CAS.TYPE_NAME_SOFA:
    case CAS.TYPE_NAME_STRING:
    case CAS.TYPE_NAME_STRING_ARRAY:
    case CAS.TYPE_NAME_STRING_LIST:
    case CAS.TYPE_NAME_TOP:
        return true;
    }
    
    return false;
}
 
Example 2
Source File: FSUtil.java    From uima-uimafit with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void setFeature(FeatureStructure aFS, String aFeature, Collection aValue) {
  Feature feat = getMandatoryFeature(aFS, aFeature);
  if (aValue == null) {
    aFS.setFeatureValue(feat, null);
  }
  else if (feat.getRange().isArray()) {
    switch (feat.getRange().getName()) {
      case CAS.TYPE_NAME_BOOLEAN_ARRAY:
        aFS.setFeatureValue(feat, createBooleanArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_BYTE_ARRAY:
        aFS.setFeatureValue(feat, createByteArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_DOUBLE_ARRAY:
        aFS.setFeatureValue(feat, createDoubleArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_FLOAT_ARRAY:
        aFS.setFeatureValue(feat, createFloatArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_INTEGER_ARRAY:
        aFS.setFeatureValue(feat, createIntArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_LONG_ARRAY:
        aFS.setFeatureValue(feat, createLongArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_SHORT_ARRAY:
        aFS.setFeatureValue(feat, createShortArrayFS(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_STRING_ARRAY:
        aFS.setFeatureValue(feat, createStringArrayFS(aFS.getCAS(), aValue));
        break;
      default:
        aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue));
        break;
    }
  }
  else {
    switch (feat.getRange().getName()) {
      case CAS.TYPE_NAME_FLOAT_LIST:
        aFS.setFeatureValue(feat, createFloatList(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_INTEGER_LIST:
        aFS.setFeatureValue(feat, createIntegerList(aFS.getCAS(), aValue));
        break;
      case CAS.TYPE_NAME_STRING_LIST:
        aFS.setFeatureValue(feat, createStringList(aFS.getCAS(), aValue));
        break;
      default: 
        aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue));
        break;
    }
  }
}
 
Example 3
Source File: EditViewPage.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the FS.
 *
 * @param type the type
 * @param arraySize the array size
 * @return the feature structure
 */
FeatureStructure createFS(Type type, int arraySize) {

  if (type.isPrimitive()) {
    throw new IllegalArgumentException("Cannot create FS for primitive type!");
  }

  FeatureStructure fs;

  TypeSystem ts = document.getCAS().getTypeSystem();

  if (type.isArray()) {
    switch (type.getName()) {
      case CAS.TYPE_NAME_BOOLEAN_ARRAY:
        fs = document.getCAS().createBooleanArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_BYTE_ARRAY:
        fs = document.getCAS().createByteArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_SHORT_ARRAY:
        fs = document.getCAS().createShortArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_INTEGER_ARRAY:
        fs = document.getCAS().createIntArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_LONG_ARRAY:
        fs = document.getCAS().createLongArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_FLOAT_ARRAY:
        fs = document.getCAS().createFloatArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_DOUBLE_ARRAY:
        fs = document.getCAS().createDoubleArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_STRING_ARRAY:
        fs = document.getCAS().createStringArrayFS(arraySize);
        break;
      case CAS.TYPE_NAME_FS_ARRAY:
        fs = document.getCAS().createArrayFS(arraySize);
        break;
      default:
        throw new CasEditorError("Unkown array type: " + type.getName() + "!");
    }
  }
  else if (ts.subsumes(ts.getType(CAS.TYPE_NAME_ANNOTATION), type)) {

	// get begin of selection from editor, if any
	// TODO: Add an interface to retrieve the span from the editor

	int begin = 0;
	int end = 0;

	if (editor instanceof AnnotationEditor) {
	  Point selection = ((AnnotationEditor) editor).getSelection();

	  begin = selection.x;
	  end = selection.y;
	}

	fs = document.getCAS().createAnnotation(type, begin, end);
  }
  else if (!type.isArray()) {
    fs = document.getCAS().createFS(type);
  }
  else {
    throw new TaeError("Unexpected error!");
  }

  return fs;
}