Package org.apache.uima.cas.impl

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


    if (!(aCAS instanceof CASImpl) &&
        !(aCAS instanceof JCas)) {
      throw new UIMARuntimeException(UIMARuntimeException.UNSUPPORTED_CAS_INTERFACE,
          new Object[] {aCAS.getClass()});
    }
    CASImpl baseCas = (aCAS instanceof JCas) ? ((JCas)aCAS).getCasImpl().getBaseCAS()
                                             : ((CASImpl)aCAS).getBaseCAS();

    CasPool pool = (CasPool) mCasToCasPoolMap.get(baseCas);
    if (pool == null) {
      // CAS doesn't belong to this CasManager!
View Full Code Here


  /**
   * (Internal) create a new instance of TOP (or subclass of TOP) in Java and Cas, and make them
   * correspond.
   */
  public TOP(JCas jcas) {
    CASImpl casImpl = (CASImpl)jcas.getCas();
    this.jcasType = jcas.getType(getTypeIndexID());
    if (null == jcasType) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS,
          new String[] { this.getClass().getName() });
      throw e;
    }
    boolean isSubtypeOfAnnotationBase = casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode);
    if (isSubtypeOfAnnotationBase &&
        (casImpl.getBaseCAS() == casImpl)) {
      throw new CASRuntimeException(CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS,
          new String[] { this.getClass().getName() });
    }
    this.addr = jcasType.ll_cas.ll_createFS(jcasType.casTypeCode);
    jcas.putJfsFromCaddr(addr, this);
   
    if (casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode)) {
      casImpl.setSofaFeat(addr, casImpl.getSofaRef());
    }
  }
View Full Code Here

      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);
      type = jcas.getType(Annotation.typeIndexID);
      assertTrue(type instanceof Annotation_Type);
View Full Code Here

      Object [] initargs = new Object[2];
      JCasImpl jcasView = null;
      // this funny logic is because although the annotationView should always be set if
      //  a type is a subtype of annotation, it isn't always set if an application uses low-level
      //  api's.  Rather than blow up, we limp along.
      CASImpl maybeAnnotationView = null
      if (isSubtypeOfAnnotationBase) {
        final int sofaNbr = getSofaNbr(addr, casView);
        if (sofaNbr > 0) {
          maybeAnnotationView = (CASImpl)casView.getView(sofaNbr);
        }
      }
      final CASImpl view = (null != maybeAnnotationView) ? maybeAnnotationView : casView;

      try {
        jcasView = (JCasImpl)view.getJCas();
      } catch (CASException e1) {
       logAndThrow(e1, jcasView);
      }
    
     // Return eq fs instance if already created
View Full Code Here

    if (!(aCAS instanceof CASImpl) &&
        !(aCAS instanceof JCas)) {
      throw new UIMARuntimeException(UIMARuntimeException.UNSUPPORTED_CAS_INTERFACE,
          new Object[] {aCAS.getClass()});
    }
    CASImpl baseCas = (aCAS instanceof JCas) ? ((JCas)aCAS).getCasImpl().getBaseCAS()
                                             : ((CASImpl)aCAS).getBaseCAS();

    CasPool pool = (CasPool) mCasToCasPoolMap.get(baseCas);
    if (pool == null) {
      // CAS doesn't belong to this CasManager!
View Full Code Here

        progressMonitor.beginTask("", 5);
        progressMonitor.subTask("Output going to '" + outputDirectory + "'");
        progressMonitor.subTask(getString("ReadingDescriptorAndCreatingTypes",
                new Object[] { inputFile }));
        // code to read xml and make cas type instance
        CASImpl casLocal = null;
        // handle classpath
        try {
          XMLInputSource in = new XMLInputSource(url);
          XMLizable specifier = UIMAFramework.getXMLParser().parse(in);
View Full Code Here

    }
    if (this.addr == 0) {
      return;
    }
    Type type = getType();
    CASImpl cas = this.fSTreeModel.getCas();
    if (this.fSTreeModel.getCas().isArrayType(type)) {
      int arrayLength = cas.getArraySize((int) this.addr);
      if (arrayLength > 20) {
        arrayLength = 20;
      }
      FSNode node = null;
      int arrayPos = cas.getArrayStartAddress((int) this.addr);
      int nodeClass1;
      if (cas.isIntArrayType(type)) {
        nodeClass1 = FSNode.INT_FS;
      } else if (cas.isFloatArrayType(type)) {
        nodeClass1 = FSNode.FLOAT_FS;
      } else if (cas.isStringArrayType(type)) {
        nodeClass1 = FSNode.STRING_FS;
      } else if (cas.isByteArrayType(type)) {
        nodeClass1 = FSNode.BYTE_FS;
      } else if (cas.isBooleanArrayType(type)) {
        nodeClass1 = FSNode.BOOL_FS;
      } else if (cas.isShortArrayType(type)) {
        nodeClass1 = FSNode.SHORT_FS;
      } else if (cas.isLongArrayType(type)) {
        nodeClass1 = FSNode.LONG_FS;
      } else if (cas.isDoubleArrayType(type)) {
        nodeClass1 = FSNode.DOUBLE_FS;
      } else {
        nodeClass1 = FSNode.STD_FS;
      }
      ArrayList arrayNodes = new ArrayList(arrayLength);
      if (nodeClass1 == INT_FS || nodeClass1 == FLOAT_FS || nodeClass1 == STRING_FS
              || nodeClass1 == STD_FS) {
        for (int i = 0; i < arrayLength; i++) {
          node = new FSNode(this.fSTreeModel, nodeClass1, cas.getHeapValue(arrayPos), i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      } else if (nodeClass1 == BYTE_FS) {
        for (int i = 0; i < arrayLength; i++) {
          node = new FSNode(this.fSTreeModel, nodeClass1, cas.ll_getByteArrayValue((int) this.addr,
                  i), i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      } else if (nodeClass1 == SHORT_FS) {
        for (int i = 0; i < arrayLength; i++) {
          node = new FSNode(this.fSTreeModel, nodeClass1, cas.ll_getShortArrayValue(
                  (int) this.addr, i), i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      } else if (nodeClass1 == BOOL_FS) {
        for (int i = 0; i < arrayLength; i++) {
          int temp = cas.ll_getBooleanArrayValue((int) this.addr, i) ? 1 : 0;
          node = new FSNode(this.fSTreeModel, nodeClass1, temp, i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      } else if (nodeClass1 == LONG_FS) {
        for (int i = 0; i < arrayLength; i++) {
          long temp = cas.ll_getLongArrayValue((int) this.addr, i);
          node = new FSNode(this.fSTreeModel, nodeClass1, temp, i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      } else if (nodeClass1 == DOUBLE_FS) {
        for (int i = 0; i < arrayLength; i++) {
          double temp = cas.ll_getDoubleArrayValue((int) this.addr, i);
          node = new FSNode(this.fSTreeModel, nodeClass1, CASImpl.double2long(temp), i);
          arrayNodes.add(node);
          ++arrayPos;
        }
      }
      this.children = FSTreeModel.createArrayChildren(0, arrayLength, arrayNodes, this.fSTreeModel);
    } else {
      this.children = new ArrayList();
      List feats = type.getFeatures();
      for (int i = 0; i < feats.size(); i++) {
        FeatureImpl feat1 = (FeatureImpl) feats.get(i);
        long featAddr = cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
        if (cas.isDoubleType(feat1.getRange()) || cas.isLongType(feat1.getRange())) {
          featAddr = cas.ll_getLongValue((int) featAddr);
        }
        FSNode childNode = new FSNode(this.fSTreeModel, this.fSTreeModel.getNodeType(
                (int) this.addr, feat1), featAddr, feat1);
        this.children.add(childNode);
      }
View Full Code Here

    }
    return this.fSTreeModel.getCas().getStringForCode((int) this.addr);
  }

  private String getValueString() {
    CASImpl cas = this.fSTreeModel.getCas();
    switch (this.nodeClass) {
      case INT_FS:
      case BYTE_FS:
      case SHORT_FS: {
        return Long.toString(this.addr);
      }
      case FLOAT_FS: {
        return Float.toString(CASImpl.int2float((int) this.addr));
      }
      case BOOL_FS: {
        return (0 == this.addr) ? "false" : "true";
      }
      case LONG_FS: {
        return Long.toString(this.addr);
      }
      case DOUBLE_FS: {
        return Double.toString(CASImpl.long2double(this.addr));
      }
      case STRING_FS: {
        if (this.addr == LowLevelCAS.NULL_FS_REF) {
          return getNullString();
        }
        String s = cas.getStringForCode((int) this.addr);
        // Check if we need to shorten the string for display purposes
        String s1 = shortenString(s);
        // Remember if string is shortened
        this.isShortenedString = (s != s1);
        return "\"" + escapeLt(s1) + "\"";
      }
      case ARRAY_FS: {
        if (cas.getHeapValue((int) this.addr) == LowLevelCAS.NULL_FS_REF) {
          return getNullString();
        }
        return "<font color=blue>" + getType().getName() + "</font>["
                + cas.getArraySize((int) this.addr) + "]";
      }
      case STD_FS: {
        if (cas.getHeapValue((int) this.addr) == LowLevelCAS.NULL_FS_REF) {
          return getNullString();
        }
        return "<font color=blue>" + getType().getName() + "</font>";
      }
    }
View Full Code Here

  int getArrayPos() {
    return this.arrayElem;
  }

  Type getType() {
    CASImpl cas = this.fSTreeModel.getCas();
    return cas.getTypeSystemImpl().getType(cas.getHeapValue((int) this.addr));
  }
View Full Code Here

    CASImpl cas = this.fSTreeModel.getCas();
    return cas.getTypeSystemImpl().getType(cas.getHeapValue((int) this.addr));
  }

  boolean isAnnotation() {
    CASImpl cas = this.fSTreeModel.getCas();
    if (this.nodeClass != STD_FS || this.addr == 0) {
      return false;
    }
    if (cas.getTypeSystem().subsumes(cas.getAnnotationType(), getType())) {
      if (cas == ((AnnotationFS) cas.createFS((int) this.addr)).getView()) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

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

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.