Java Code Examples for org.apache.uima.jcas.cas.TOP#_getIntValueNc

The following examples show how to use org.apache.uima.jcas.cas.TOP#_getIntValueNc . 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: CASImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle some unusual backwards compatibility cases
 *   featureCode = 0 - implies getting the type code
 *   feature range is int - normal
 *   feature range is a fs reference, return the id 
 *   feature range is a string: add the string if not already present to the string heap, return the int handle.
 * @param fsRef -
 * @param featureCode -
 * @return -
 */
@Override
public final int ll_getIntValue(int fsRef, int featureCode) {
  TOP fs = getFsFromId_checked(fsRef);
  if (featureCode == 0) {
    return fs._getTypeImpl().getCode(); // case where the type is being requested
  }
  FeatureImpl fi = getFeatFromCode_checked(featureCode);
  
  SlotKind kind = fi.getSlotKind();
  switch(kind) {
  case Slot_HeapRef:
    return fs.getFeatureValue(fi)._id;

  case Slot_Boolean:
  case Slot_Byte:
  case Slot_Short:
  case Slot_Int:
  case Slot_Float:
    return fs._getIntValueNc(fi);
    
  case Slot_StrRef:
    return getCodeForString(fs._getStringValueNc(fi));
    
  case Slot_LongRef:
    return getCodeForLong(fs._getLongValueNc(fi));
  case Slot_DoubleRef:
    return getCodeForLong(CASImpl.double2long(fs._getDoubleValueNc(fi)));
    
  default: throw new CASRuntimeException(
        CASRuntimeException.INAPPROP_RANGE, 
        fi.getName(), 
        "int", 
        fi.getRange().getName());
  }
}
 
Example 2
Source File: BinaryCasSerDes4.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
private void serializeByKind(TOP fs, FeatureImpl feat) throws IOException {
      SlotKind kind = feat.getSlotKind();      
      switch (kind) {
      case Slot_Int: {
        final int prev = (prevFs == null) ? 0 : prevFs._getIntValueNc(feat);
        final int v = fs._getIntValueNc(feat);
//        if (TRACE_INT) System.out.format("writeInt value: %,d prev: %,d%n", v, prev); 
        writeDiff(kind.ordinal(), v, prev);
        break;
      }
      
      case Slot_Short: 
        writeDiff(kind.ordinal(), fs._getShortValueNc(feat), (prevFs == null) ? 0 : prevFs._getShortValueNc(feat));
        break;
        
      case Slot_HeapRef:
        final TOP ref = fs._getFeatureValueNc(feat);
        writeDiff(kind.ordinal(), fs2seq(ref), 
           (prevFs == null) ? 0 : fs2seq(prevFs._getFeatureValueNc(feat)));
        break;
        
      case Slot_Float:
        writeFloat(CASImpl.float2int(fs._getFloatValueNc(feat)));
        break;
        
      case Slot_Boolean:
        byte_dos.write(fs._getBooleanValueNc(feat) ? 1 : 0);
        break;
        
      case Slot_Byte:
        byte_dos.write(fs._getByteValueNc(feat));
        break;
        
      case Slot_StrRef: 
        writeString(fs._getStringValueNc(feat));
        break;
        
      case Slot_LongRef:
        writeLong(fs._getLongValueNc(feat), (prevFs == null) ? 0L : prevFs._getLongValueNc(feat));
        break;

      case Slot_DoubleRef: 
        writeDouble(CASImpl.double2long(fs._getDoubleValueNc(feat)));
        break;
        
      default: Misc.internalError(); 
      } // end of switch
    }