Package org.apache.uima.cas.impl

Examples of org.apache.uima.cas.impl.LowLevelCAS


        System.out.println(e2);
      }

      CAS localCas = jcas.getCas();
      assertTrue(localCas == this.cas);
      LowLevelCAS ll_cas = jcas.getLowLevelCas();
      assertTrue(ll_cas == this.cas);
      CASImpl casImpl = jcas.getCasImpl();
      assertTrue(casImpl == this.cas);
      TOP_Type type = jcas.getType(org.apache.uima.jcas.tcas.Annotation.type);
      assertTrue(type instanceof org.apache.uima.jcas.tcas.Annotation_Type);
View Full Code Here


     assertTrue(token.getFeatureValue(lemmaList) == null);
     token.setFeatureValue(lemmaList, casArray);
     this.cas.addFsToIndexes(token);
     assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(0) == "1");
     assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(1) == null);
     LowLevelCAS llc = casArray.getCAS().getLowLevelCAS();
     assertTrue(llc.ll_getIntArrayValue(llc.ll_getFSRef(casArray), 1) == LowLevelCAS.NULL_FS_REF);
  }
View Full Code Here

      casEx.initCause(e);
      throw casEx;     
    }

    private int getSofaNbr(int addr, CASImpl casView) {
      final LowLevelCAS llCas = casView.getLowLevelCAS();
      final int sofa = llCas.ll_getIntValue(addr, annotSofaFeatCode, false);
      return (sofa == 0) ? 0 : llCas.ll_getIntValue(sofa, sofaNbrFeatCode);
    }
View Full Code Here

  public void testAnnotationWithNullSofaRef() throws Exception {
    CAS srcCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    CAS srcCasView = srcCas.createView("TestView");
    srcCasView.setDocumentText("This is a test");
    CAS destCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    LowLevelCAS lowLevelSrcCasView = srcCasView.getLowLevelCAS();
    int typeCode = lowLevelSrcCasView.ll_getTypeSystem().ll_getCodeForType(
            srcCas.getAnnotationType());
    int destFsAddr = lowLevelSrcCasView.ll_createFS(typeCode);
    AnnotationFS fs = (AnnotationFS) lowLevelSrcCasView.ll_getFSForRef(destFsAddr);
    fs.setIntValue(srcCas.getBeginFeature(), 0);
    fs.setIntValue(srcCas.getEndFeature(), 4);
    assertEquals("This", fs.getCoveredText());
    srcCasView.addFsToIndexes(fs);
    CasCopier.copyCas(srcCas, destCas, true);
View Full Code Here

        System.out.println(e2);
      }

      CAS localCas = jcas.getCas();
      assertTrue(localCas == this.cas);
      LowLevelCAS ll_cas = jcas.getLowLevelCas();
      assertTrue(ll_cas == this.cas);
      CASImpl casImpl = jcas.getCasImpl();
      assertTrue(casImpl == this.cas);
      TOP_Type type = jcas.getType(org.apache.uima.jcas.tcas.Annotation.type);
      assertTrue(type instanceof org.apache.uima.jcas.tcas.Annotation_Type);
View Full Code Here

  // }

  /** return the indexed value from the corresponding Cas FSArray as a Java Model object. */
  public FeatureStructure get(int i) {
    jcasType.casImpl.checkArrayBounds(addr, i);
    final LowLevelCAS ll_cas = jcasType.ll_cas;
    return ll_cas.ll_getFSForRef(ll_cas.ll_getRefArrayValue(addr, i));
  }
View Full Code Here

    }
    assertTrue(exCaught);
  }

  public void testLowLevelCas() {
    LowLevelCAS cas = this.jcas.getLowLevelCas();
    LowLevelTypeSystem ts = cas.ll_getTypeSystem();
    final int annotType = ts.ll_getCodeForTypeName(annotationTypeName);
    final int addr = cas.ll_createFS(annotType);
    final int stringSetFeat = ts.ll_getCodeForFeatureName(annotationTypeName
  + TypeSystem.FEATURE_SEPARATOR + stringSetFeatureName);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue1);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue2);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue3);
    // next should be ok https://issues.apache.org/jira/browse/UIMA-1839
    cas.ll_setStringValue(addr, stringSetFeat, null);
    boolean exCaught = false;
    try {
      cas.ll_setStringValue(addr, stringSetFeat, undefinedValue);
    } catch (CASRuntimeException e) {
      exCaught = true;
    }
    assertTrue(exCaught);
  }
View Full Code Here

        System.out.println(e2);
      }

      CAS localCas = jcas.getCas();
      assertTrue(localCas == this.cas);
      LowLevelCAS ll_cas = jcas.getLowLevelCas();
      assertTrue(ll_cas == this.cas);
      CASImpl casImpl = jcas.getCasImpl();
      assertTrue(casImpl == this.cas);
      TOP_Type type = jcas.getType(org.apache.uima.jcas.tcas.Annotation.type);
      assertTrue(type instanceof org.apache.uima.jcas.tcas.Annotation_Type);
View Full Code Here

      casEx.initCause(e);
      throw casEx;     
    }

    private int getSofaNbr(int addr, CASImpl casView) {
      final LowLevelCAS llCas = casView.getLowLevelCAS();
      final int sofa = llCas.ll_getIntValue(addr, annotSofaFeatCode, false);
      return (sofa == 0) ? 0 : llCas.ll_getIntValue(sofa, sofaNbrFeatCode);
    }
View Full Code Here

     * Throw in tests of the byte, short and long heaps as well
     *
     */
  String testString = "testString";
  cas.reset();
  LowLevelCAS ll_cas = cas.getLowLevelCAS();
  FSIndexRepository ir = cas.getIndexRepository();
  int ll_strfeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theStringFeature);
  int ll_bytefeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theByteFeature);
  int ll_shortfeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theShortFeature);
  int ll_bytearrayfeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theByteArrayFeature);
  int ll_shortarrayfeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theShortArrayFeature);
  int ll_longfeatcode = ll_cas.ll_getTypeSystem().ll_getCodeForFeature(theLongFeature);
 
  for (int cycle=0; cycle<10; cycle+=2) {
    FeatureStructure newFS1 = cas.createFS(theTypeType);
    ir.addFS(newFS1);
    newFS1.setIntValue(startFeature, cycle);
    newFS1.setIntValue(endFeature, cycle+1);
    // set string using normal string feature create
    newFS1.setStringValue(theStringFeature, testString);
    newFS1.setByteValue(theByteFeature, (byte)cycle);
    newFS1.setShortValue(theShortFeature, (short)cycle);
    newFS1.setLongValue(theLongFeature, (long)cycle);
    ByteArrayFS newBA1 = cas.createByteArrayFS(1);
    ShortArrayFS newSA1 = cas.createShortArrayFS(1);
    newBA1.set(0, (byte)cycle);
    newSA1.set(0, (short)cycle);
    newFS1.setFeatureValue(theByteArrayFeature, newBA1);
    newFS1.setFeatureValue(theShortArrayFeature, newSA1);

    FeatureStructure newFS2 = cas.createFS(theTypeType);
    ByteArrayFS newBA2 = cas.createByteArrayFS(1);
    ShortArrayFS newSA2 = cas.createShortArrayFS(1);
    newFS2.setIntValue(startFeature, cycle+1);
    newFS2.setIntValue(endFeature, cycle+2);
    ir.addFS(newFS2);
    // set string using lowlevel string create API
    final int llfs2 = ll_cas.ll_getFSRef(newFS2);
    final int llba2 = ll_cas.ll_getFSRef(newBA2);
    final int llsa2 = ll_cas.ll_getFSRef(newSA2);
    ll_cas.ll_setCharBufferValue(llfs2, ll_strfeatcode,
            testString.toCharArray(), 0, testString.length());
    ll_cas.ll_setByteValue(llfs2, ll_bytefeatcode, (byte)(cycle+1));
    ll_cas.ll_setShortValue(llfs2, ll_shortfeatcode, (short)(cycle+1));
    ll_cas.ll_setLongValue(llfs2, ll_longfeatcode, (long)(cycle+1));
    ll_cas.ll_setByteArrayValue(llba2, 0, (byte)(cycle+1));
    ll_cas.ll_setShortArrayValue(llsa2, 0, (short)(cycle+1));
    newFS2.setFeatureValue(theByteArrayFeature, newBA2);
    newFS2.setFeatureValue(theShortArrayFeature, newSA2);

    ByteArrayOutputStream fos = new ByteArrayOutputStream();
    Serialization.serializeCAS(cas, fos);
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.impl.LowLevelCAS

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.