Package org.apache.uima.cas.impl

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


    }
    if (this.addr == 0) {
      return;
    }
    Type type = getType();
    CASImpl cas = this.fSTreeModel.getCas();
    if (this.fSTreeModel.getCas().isArrayType(type)) {
      int arrayLength = cas.ll_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.ll_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().ll_getTypeForCode(cas.getHeapValue((int) this.addr));
  }
View Full Code Here

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

  public 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

    }
    return false;
  }

  public int getStart() {
    CASImpl cas = this.fSTreeModel.getCas();
    if (isAnnotation()) {
      final FeatureImpl feat1 = (FeatureImpl) cas.getBeginFeature();
      return cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
    }
    return -1;
  }
View Full Code Here

    }
    return -1;
  }

  public int getEnd() {
    CASImpl cas = this.fSTreeModel.getCas();
    if (isAnnotation()) {
      final FeatureImpl feat1 = (FeatureImpl) cas.getEndFeature();
      return cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
    }
    return -1;
  }
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

public class Util {
 
  public static CASImpl getStartingView(CAS cas, boolean sofaAware, ComponentInfo componentInfo) {  
    // if this is a sofa-aware component, give it the Base CAS
    // if it is a sofa-unaware component, give it whatever view maps to the _InitialView
    CASImpl ci;
    // need to set the componentInfo for the getView to find the sofa mappings
    // Do this *before* the getView call below
    // note: this is in a shared view part of the CAS
    cas.setCurrentComponentInfo(componentInfo)
    if (sofaAware) {
View Full Code Here

      CAS cas,
      boolean sofaAware,
      ComponentInfo componentInfo,
      ResourceManager resourceManager,
      Class<? extends AbstractCas> casInterface) {
    CASImpl ci = getStartingView(cas, sofaAware, componentInfo);
    // get requested interface to CAS (CAS or JCas)
    // next will create JCas if needed, but not already created
    // must precede the switchClassLoader call - that one needs the JCas link, if it is being used
    AbstractCas r = CasManager_impl.getCasInterfaceStatic(ci, casInterface);
    // This cas will be unlocked and its class loader restored when the
    //   next() method returns it
    // Insure the same view is passed for switching/restoring  https://issues.apache.org/jira/browse/UIMA-2211
    ci.switchClassLoaderLockCasCL(resourceManager.getExtensionClassLoader());   
    return r;
  }
View Full Code Here

      CAS cas,
      boolean sofaAware,
      ComponentInfo componentInfo,
      ResourceManager resourceManager,
      Class<? extends AbstractCas> casInterface) {
    CASImpl ci = getStartingView(cas, sofaAware, componentInfo);
    // get requested interface to CAS (CAS or JCas)
    // next will create JCas if needed, but not already created
    // must precede the switchClassLoader call - that one needs the JCas link, if it is being used
    AbstractCas r = CasManager_impl.getCasInterfaceStatic(ci, casInterface);
    // This cas will be unlocked and its class loader restored when the
    //   next() method returns it
    // Insure the same view is passed for switching/restoring  https://issues.apache.org/jira/browse/UIMA-2211
    ci.switchClassLoader(resourceManager.getExtensionClassLoader());   
    return r;
  }
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.