Package org.apache.uima.cas

Examples of org.apache.uima.cas.CASRuntimeException


    super(jcas);
  }

  public TOP getNthElement(int i) {
    if (this instanceof EmptyFSList) {
      CASRuntimeException casEx = new CASRuntimeException(
          CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST, new String[] { "EmptyFSList" });
      throw casEx;
    }
    if (i < 0) {
      CASRuntimeException casEx = new CASRuntimeException(
          CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX, new String[] { Integer.toString(i) });
      throw casEx;
    }
    int originali = i;
    FSList cg = this;
    for (;; i--) {
      if (cg instanceof EmptyFSList) {
        CASRuntimeException casEx = new CASRuntimeException(
            CASRuntimeException.JCAS_GET_NTH_PAST_END, new String[] { Integer.toString(originali) });
        throw casEx;
      }
      NonEmptyFSList c = (NonEmptyFSList) cg;
      if (i == 0)
View Full Code Here


      Assert.assertTrue(ind3.compare(fs5, fs6) < 0);
      Assert.assertTrue(ind3.compare(fs6, fs7) > 0);

      // only way to check if allowed values is correct is to try to set an
      // invalid value?
      CASRuntimeException ex = null;
      try {
        fs4.setStringValue(f2, "Three");
      } catch (CASRuntimeException e) {
        ex = e;
      }
View Full Code Here

  public TypeSystem getTypeSystem() {
    final TypeSystemImpl ts = this.svd.casMetadata.ts;
    if (ts.isCommitted()) {
      return ts;
    }
    throw new CASRuntimeException(CASRuntimeException.TYPESYSTEM_NOT_LOCKED);
  }
View Full Code Here

  }

  public FeatureStructure createFS(Type type) {
    final int typeCode = ((TypeImpl) type).getCode();
    if (!isCreatableType(typeCode)) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.NON_CREATABLE_TYPE,
          new String[] { type.getName(), "CAS.createFS()" });
      throw e;
    }
    final int addr = ll_createFS(typeCode);
    final TypeSystemImpl ts = this.svd.casMetadata.ts;
    final boolean isAnnot = ts.subsumes(ts.annotBaseTypeCode, typeCode);
    if (isAnnot && (this == this.getBaseCAS())) {
      CASRuntimeException e = new CASRuntimeException(
          CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS,
          new String[] { type.getName() });
      throw e;
    }
    if (isAnnot) {
View Full Code Here

  }

  public final void checkArrayPreconditions(int len) throws CASRuntimeException {
    // Check array size.
    if (len < 0) {
      throw new CASRuntimeException(CASRuntimeException.ILLEGAL_ARRAY_SIZE);
    }
  }
View Full Code Here

  }

  // Internal use only
  public void addSofa(FeatureStructure sofa, String sofaName, String mimeType) {
    if (this.svd.sofaNameSet.contains(sofaName)) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFANAME_ALREADY_EXISTS,
          new String[] { sofaName });
      throw e;
    }
    final TypeSystemImpl ts = this.svd.casMetadata.ts;
    final int llsofa = getLowLevelCAS().ll_getFSRef(sofa);
View Full Code Here

          this.svd.casMetadata.ts.sofaIdFeatCode))) {
        return sofa;
      }
      iterator.moveToNext();
    }
    CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFANAME_NOT_FOUND,
        new String[] { sofaName });
    throw e;
  }
View Full Code Here

  }

  SofaFS getSofa(int sofaRef) {
    SofaFS aSofa = (SofaFS) this.ll_getFSForRef(sofaRef);
    if (aSofa == null) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFAREF_NOT_FOUND);
      throw e;
    }
    return aSofa;
  }
View Full Code Here

        return url.openStream();
      } else {
        return null;
      }
    } catch (MalformedURLException exc) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFADATASTREAM_ERROR,
          new String[] { exc.getMessage() });
      throw e;
    } catch (CASRuntimeException exc) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFADATASTREAM_ERROR,
          new String[] { exc.getMessage() });
      throw e;
    } catch (IOException exc) {
      CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFADATASTREAM_ERROR,
          new String[] { exc.getMessage() });
      throw e;
    }
    return null;
  }
View Full Code Here

//          throw new CASRuntimeException(CASRuntimeException.DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED);
          // Only works for cases where the type systems match, and delta is false.
          try {
            (new BinaryCasSerDes6(this)).deserializeAfterVersion(dis, delta, AllowPreexistingFS.allow);
          } catch (ResourceInitializationException e) {
            throw new CASRuntimeException(CASRuntimeException.DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED, null, e);
          }
          return SerialFormat.COMPRESSED_FILTERED;
        }
      }
     
      // main fsheap
      final int fsheapsz = readInt(dis, swap);
     
      int startPos = 0;
      if (!delta) {
        this.getHeap().reinitSizeOnly(fsheapsz);
      } else {
      startPos = this.getHeap().getNextId();
      this.getHeap().grow(fsheapsz);
      }
           
      for (int i = startPos; i < fsheapsz+startPos; i++) {
        this.getHeap().heap[i] = readInt(dis, swap);
      }
     
      // string heap
      int stringheapsz = readInt(dis, swap);

      final StringHeapDeserializationHelper shdh = new StringHeapDeserializationHelper();
     
      shdh.charHeap = new char[stringheapsz];
      for (int i = 0; i < stringheapsz; i++) {
        shdh.charHeap[i] = (char) readShort(dis, swap);
      }
      shdh.charHeapPos = stringheapsz;

      // word alignment
      if (stringheapsz % 2 != 0) {
        dis.readChar();
      }

      // string ref heap
      int refheapsz = readInt(dis, swap);

      refheapsz--;
      refheapsz = refheapsz / 2;
      refheapsz = refheapsz * 3;

      // read back into references consisting to three ints
      // --stringheap offset,length, stringlist offset
      shdh.refHeap = new int[StringHeapDeserializationHelper.FIRST_CELL_REF + refheapsz];

      dis.readInt(); // 0
      for (int i = shdh.refHeapPos; i < shdh.refHeap.length; i += StringHeapDeserializationHelper.REF_HEAP_CELL_SIZE) {
        shdh.refHeap[i + StringHeapDeserializationHelper.CHAR_HEAP_POINTER_OFFSET] = readInt(dis, swap);
        shdh.refHeap[i + StringHeapDeserializationHelper.CHAR_HEAP_STRLEN_OFFSET] = readInt(dis, swap);
        shdh.refHeap[i + StringHeapDeserializationHelper.STRING_LIST_ADDR_OFFSET] = 0;
      }
      shdh.refHeapPos = refheapsz + StringHeapDeserializationHelper.FIRST_CELL_REF;
     
      this.getStringHeap().reinit(shdh, delta);
     
      //if delta, handle modified fs heap cells
      if (delta) {
        int fsmodssz = readInt(dis, swap);
        for (int i = 0; i < fsmodssz; i++) {
          this.getHeap().heap[readInt(dis, swap)] = readInt(dis, swap);
        }
      }

      // indexed FSs
      int fsindexsz = readInt(dis, swap);
      int[] fsindexes = new int[fsindexsz];
      for (int i = 0; i < fsindexsz; i++) {
        fsindexes[i] = readInt(dis, swap);
      }

      // build the index
      if (delta) {
      reinitDeltaIndexedFSs(fsindexes)
      } else {
        reinitIndexedFSs(fsindexes);
      }
     
      // byte heap
      int heapsz = readInt(dis, swap);

      if (!delta) {
        this.getByteHeap().heap = new byte[Math.max(16, heapsz)]; // must be > 0
        dis.readFully(this.getByteHeap().heap, 0, heapsz);
        this.getByteHeap().heapPos = heapsz;
      else {
        for (int i=0; i < heapsz; i++) {
          this.getByteHeap().addByte(dis.readByte());
        }
      }
      // word alignment
      int align = (4 - (heapsz % 4)) % 4;
      BinaryCasSerDes6.skipBytes(dis, align);

      // short heap
      heapsz = readInt(dis, swap);
     
      if (!delta) {
        this.getShortHeap().heap = new short[Math.max(16, heapsz)]; // must be > 0
        for (int i = 0; i < heapsz; i++) {
          this.getShortHeap().heap[i] = readShort(dis, swap);
        }
        this.getShortHeap().heapPos = heapsz;
      } else {
        for (int i = 0; i < heapsz; i++) {
          this.getShortHeap().addShort(readShort(dis, swap));
        }
      }
      // word alignment
      if (heapsz % 2 != 0) {
        dis.readShort();
      }

      // long heap
      heapsz = readInt(dis, swap);
     
      if (!delta) {
        this.getLongHeap().heap = new long[Math.max(16, heapsz)]; // must be > 0
        for (int i = 0; i < heapsz; i++) {
          this.getLongHeap().heap[i] = readLong(dis, swap);
        }
        this.getLongHeap().heapPos = heapsz;
      } else {
        for (int i = 0; i < heapsz; i++) {
          this.getLongHeap().addLong(readLong(dis, swap));
        }
      }
     
      if (delta)  {
          //modified Byte Heap
        heapsz = readInt(dis, swap);
        if (heapsz > 0) {
          int[] heapAddrs = new int[heapsz];
          for (int i = 0; i < heapsz; i++) {
            heapAddrs[i] = readInt(dis, swap);
          }
          for (int i = 0; i < heapsz; i++) {
            this.getByteHeap().heap[heapAddrs[i]] = dis.readByte();
          }
        }
        // word alignment
        align = (4 - (heapsz % 4)) % 4;
        BinaryCasSerDes6.skipBytes(dis, align);
       
        //modified Short Heap
        heapsz = readInt(dis, swap);
        if (heapsz > 0) {
          int[] heapAddrs = new int[heapsz];
          for (int i = 0; i < heapsz; i++) {
            heapAddrs[i] = readInt(dis, swap);
          }
          for (int i = 0; i < heapsz; i++) {
            this.getShortHeap().heap[heapAddrs[i]] = readShort(dis, swap);
           }
        }
       
        // word alignment
        if (heapsz % 2 != 0) {
          dis.readShort();
        }
     
        //modified Long Heap
        heapsz = readInt(dis, swap);
        if (heapsz > 0) {
          int[] heapAddrs = new int[heapsz];
          for (int i = 0; i < heapsz; i++) {
            heapAddrs[i] = readInt(dis, swap);
          }
          for (int i = 0; i < heapsz; i++) {
            this.getLongHeap().heap[heapAddrs[i]] = readLong(dis, swap);
          }
        }
      } // of delta - modified processing
    } catch (IOException e) {
      String msg = e.getMessage();
      if (msg == null) {
        msg = e.toString();
      }
      CASRuntimeException exception = new CASRuntimeException(
          CASRuntimeException.BLOB_DESERIALIZATION, new String[] { msg });
      throw exception;
    }
    return SerialFormat.BINARY;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.CASRuntimeException

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.