Java Code Examples for org.apache.uima.UIMARuntimeException#INTERNAL_ERROR

The following examples show how to use org.apache.uima.UIMARuntimeException#INTERNAL_ERROR . 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: FSIndexRepositoryImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public LinearTypeOrder getDefaultTypeOrder() {
  if (this.sii.defaultTypeOrder == null) {
    if (this.sii.defaultOrderBuilder == null) {
      this.sii.defaultOrderBuilder = new LinearTypeOrderBuilderImpl(this.sii.tsi);
    }
    try {
      this.sii.defaultTypeOrder = this.sii.defaultOrderBuilder.getOrder();
    } catch (final CASException e) {
      // Since we're doing this on an existing type names, we can't
      // get here.
      throw new UIMARuntimeException(UIMARuntimeException.INTERNAL_ERROR, new Object[0], e);
    }
  }
  return this.sii.defaultTypeOrder;
}
 
Example 2
Source File: XCASDeserializer.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Common code run at finalize time, to set ref values and handle out-of-typesystem data
 * 
 * @param extId the external ID identifying either a deserialized FS or an out-of-typesystem instance
 * @param fs Feature Structure whose fi reference feature is to be set with a value derived from extId and FSinfo
 * @param fi the featureImpl
*/
private void finalizeRefValue(int extId, TOP fs, FeatureImpl fi) {
  FSInfo fsInfo = fsTree.get(extId);
  if (fsInfo == null) {

    // this feature may be a ref to an out-of-typesystem FS.
    // add it to the Out-of-typesystem features list (APL)
    if (extId != 0 && outOfTypeSystemData != null) {
      List<Pair<String, Object>> ootsAttrs = outOfTypeSystemData.extraFeatureValues.computeIfAbsent(fs, k -> new ArrayList<>());
      String featFullName = fi.getName();
      int separatorOffset = featFullName.indexOf(TypeSystem.FEATURE_SEPARATOR);
      String featName = "_ref_" + featFullName.substring(separatorOffset + 1);
      ootsAttrs.add(new Pair(featName, Integer.toString(extId)));
    }
    CASImpl.setFeatureValueMaybeSofa(fs, fi, null);
  } else {
    // the sofa ref in annotationBase is set when the fs is created, not here
    if (fi.getCode() != TypeSystemConstants.annotBaseSofaFeatCode) { 
      if (fs instanceof Sofa) {
        // special setters for sofa values
        Sofa sofa = (Sofa) fs;
        switch (fi.getRangeImpl().getCode()) {
        case TypeSystemConstants.sofaArrayFeatCode: sofa.setLocalSofaData(fsInfo.fs); break;
        default: throw new CASRuntimeException(UIMARuntimeException.INTERNAL_ERROR);
        }
        return;
      }
      
      // handle case where feature is xyz[] (an array ref, not primitive) but the value of fs is FSArray
      ts.fixupFSArrayTypes(fi.getRangeImpl(), fsInfo.fs);
      CASImpl.setFeatureValueMaybeSofa(fs, fi, fsInfo.fs);
    }
  }
}
 
Example 3
Source File: FSClassRegistry.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Return a Functional Interface for a generator for creating instances of a type.
 *   Function takes a casImpl arg, and returning an instance of the JCas type.
 * @param jcasClass the class of the JCas type to construct
 * @param typeImpl the UIMA type
 * @return a Functional Interface whose createFS method takes a casImpl 
 *         and when subsequently invoked, returns a new instance of the class
 */
private static FsGenerator3 createGenerator(Class<?> jcasClass, Lookup lookup) {
  try {
    
    MethodHandle mh = lookup.findConstructor(jcasClass, findConstructorJCasCoverType);
    MethodType mtThisGenerator = methodType(jcasClass, TypeImpl.class, CASImpl.class);
 
    CallSite callSite = LambdaMetafactory.metafactory(
        lookup, // lookup context for the constructor 
        "createFS", // name of the method in the Function Interface 
        callsiteFsGenerator, // signature of callsite, return type is functional interface, args are captured args if any
        fsGeneratorType,  // samMethodType signature and return type of method impl by function object 
        mh,  // method handle to constructor 
        mtThisGenerator);
    return (FsGenerator3) callSite.getTarget().invokeExact();
  } catch (Throwable e) {
    if (e instanceof NoSuchMethodException) {
      String classname = jcasClass.getName();
      add2errors(errorSet, new CASRuntimeException(e, CASRuntimeException.JCAS_CAS_NOT_V3, 
          classname,
          jcasClass.getClassLoader().getResource(classname.replace('.', '/') + ".class").toString()
          ));
      return null;
    }
    /** An internal error occurred, please report to the Apache UIMA project; nested exception if present: {0} */
    throw new UIMARuntimeException(e, UIMARuntimeException.INTERNAL_ERROR);
  }
}
 
Example 4
Source File: FeatureStructureImplC.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public int getTypeIndexID() {
  throw new CASRuntimeException(UIMARuntimeException.INTERNAL_ERROR); // dummy, always overridden
}
 
Example 5
Source File: CASImpl.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
public int size() {
  throw new UIMARuntimeException(UIMARuntimeException.INTERNAL_ERROR);
}
 
Example 6
Source File: Misc.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/** 
 * Check and throw UIMA Internal Error if false
 * @param v if false, throws
 */
public static void assertUie(boolean v) {
  if (!v) 
    throw new UIMARuntimeException(UIMARuntimeException.INTERNAL_ERROR);
}
 
Example 7
Source File: Misc.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public static void assertUie(boolean v, Throwable e) {
  if (!v) 
    throw new UIMARuntimeException(e, UIMARuntimeException.INTERNAL_ERROR, e);
}