Package org.apache.uima.cas

Examples of org.apache.uima.cas.CASException


   * @see org.apache.uima.jcas.JCas#getRequiredType(java.lang.String)
   */
  public Type getRequiredType(String s) throws CASException {
    Type t = getTypeSystem().getType(s);
    if (null == t) {
      CASException casEx = new CASException(CASException.JCAS_TYPENOTFOUND_ERROR,
          new String[] { s });
      throw casEx;
    }
    return t;
  }
View Full Code Here


   * @see org.apache.uima.jcas.JCas#getRequiredFeature(org.apache.uima.cas.Type, java.lang.String)
   */
  public Feature getRequiredFeature(Type t, String s) throws CASException {
    Feature f = t.getFeatureByBaseName(s);
    if (null == f) {
      CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
          t.getName(), s });
      throw casEx;
    }
    return f;
  }
View Full Code Here

  public Feature getRequiredFeatureDE(Type t, String s, String rangeName, boolean featOkTst) {
    Feature f = t.getFeatureByBaseName(s);
    Type rangeType = this.getTypeSystem().getType(rangeName);
    if (null == f && !featOkTst) {
      CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
          t.getName(), s });
      sharedView.errorSet.add(casEx);
    }
    if (null != f)
      try {
        casImpl.checkTypingConditions(t, rangeType, f);
      } catch (LowLevelException e) {
        CASException casEx = new CASException(CASException.JCAS_FEATURE_WRONG_TYPE, new String[] {
            t.getName(), s, rangeName, f.getRange().toString() });
        sharedView.errorSet.add(casEx);
      }
    return f;
  }
View Full Code Here

      assertTrue(false);
  }

  public void checkExpectedBadCASError(Exception e1, String err) {
    if (e1 instanceof CASException) {
      CASException e = (CASException) e1;
      System.out.print("\nCaught CAS Exception with message: ");
      String m = e1.getMessage();
      System.out.println(m);
      if (!(e.getMessageKey().equals(err))) {
        assertTrue(false);
      }
    } else
      assertTrue(false);
  }
View Full Code Here

  /**
   * @see org.apache.uima.cas.admin.CASMgr#initCASIndexes()
   */
  public void initCASIndexes() throws CASException {
    if (null == this.ts.getType(CAS.TYPE_NAME_SOFA)) {
      throw new CASException(CASException.MUST_COMMIT_TYPE_SYSTEM, null);
    }
    if (this.annotIndexInitialized) {
      return;
    }
    FSIndexComparator comp = this.indexRepository.createComparator();
View Full Code Here

      this.featurePathString = featurePath;
      this.builtInFunction = NO_BUILT_IN_FUNCTION;

      // throw exception if featurePath is null
      if (featurePath == null) {
         throw new CASException(MESSAGE_DIGEST, "INVALID_FEATURE_PATH_SYNTAX",
               new Object[] { featurePath, "null for a feature path" });
      }

      // check featurePath for invalid character sequences
      if (this.featurePathString.indexOf("//") > -1) {
         // invalid featurePath syntax
         throw new CASException(MESSAGE_DIGEST, "INVALID_FEATURE_PATH_SYNTAX",
               new Object[] { this.featurePathString, "//" });
      }

      // parse feature path into path elements
      StringTokenizer tokenizer = new StringTokenizer(this.featurePathString,
            FEATURE_PATH_SEPARATOR);
      while (tokenizer.hasMoreTokens()) {
         String token = tokenizer.nextToken();
         // check if there are more tokens available, if we are at the last
         // token we have to check for built-in functions
         if (tokenizer.hasMoreTokens()) {
            this.featurePathElementNames.add(token);
         } else {
            // we have the last token, check for built-in functions
            int index = -1;
            if ((index = token.indexOf(BUILT_IN_FUNCTION_SEPARATOR)) != -1) {
               if (index > 0) {
                  // we have a built-in function that is separated with a ":"
                  this.featurePathElementNames.add(token.substring(0, index));
               }
               // get built-in function
               String builtInFunctionName = token.substring(index + 1)
                     .toLowerCase();
               if (builtInFunctionName.equals(FUNCTION_NAME_COVERED_TEXT)) {
                  this.builtInFunction = FUNCTION_COVERED_TEXT;
               } else if (builtInFunctionName.equals(FUNCTION_NAME_ID)) {
                  this.builtInFunction = FUNCTION_ID;
               } else if (builtInFunctionName.equals(FUNCTION_NAME_TYPE_NAME)) {
                  this.builtInFunction = FUNCTION_TYPE_NAME;
               } else {
                  throw new CASException(MESSAGE_DIGEST,
                        "INVALID_FEATURE_PATH_SYNTAX", new Object[] {
                              this.featurePathString, builtInFunctionName });
               }
            } else {
               this.featurePathElementNames.add(token);
View Full Code Here

         // validate featurePath for given type
         PathValid pathValid = TypeSystemUtils.isPathValid(featurePathType,
               this.featurePathElementNames);
         if (PathValid.NEVER == pathValid) {
            // invalid featurePath - throw an configuration exception
            throw new CASException(MESSAGE_DIGEST,
                  "ERROR_VALIDATE_FEATURE_PATH", new Object[] {
                        this.featurePathString, featurePathType.getName() });
         } else if (PathValid.ALWAYS == pathValid) {
            // the featurePath is always valid, so we can resolve and cache the
            // path elements
View Full Code Here

   * @see org.apache.uima.cas.admin.CASMgr#initCASIndexes()
   */
  public void initCASIndexes() throws CASException {
    final TypeSystemImpl ts = this.svd.casMetadata.ts;
    if (!ts.isCommitted()) {
      throw new CASException(CASException.MUST_COMMIT_TYPE_SYSTEM, null);
    }

    FSIndexComparator comp = this.indexRepository.createComparator();
    comp.setType(ts.sofaType);
    comp.addKey(ts.sofaNum, FSIndexComparator.STANDARD_COMPARE);
View Full Code Here

      assertTrue(false);
  }

  public void checkExpectedBadCASError(Exception e1, String err) {
    if (e1 instanceof CASException) {
      CASException e = (CASException) e1;
      System.out.print("\nCaught CAS Exception with message: ");
      String m = e1.getMessage();
      System.out.println(m);
      if (!(e.getMessageKey().equals(err))) {
        assertTrue(false);
      }
    } else
      assertTrue(false);
  }
View Full Code Here

      while (iter.hasNext()) {
        Exception f = (Exception) iter.next();
        msg.append(f.getMessage());
        msg.append("\n");
      }
      CASException e = new CASException(CASException.JCAS_INIT_ERROR,
          new String[] { msg.toString() });
      throw e;
    }
    return jcas;
  }
View Full Code Here

TOP

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

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.