Logo Search packages:      
Sourcecode: uimaj version File versions  Download package

SimplePrecondition_impl.java

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.uima.resource.metadata.impl;

import org.apache.uima.UIMA_IllegalArgumentException;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSMatchConstraint;
import org.apache.uima.resource.metadata.SimplePrecondition;

/**
 * Reference implementation of {@link SimplePrecondition}.
 * 
 * 
 */
00032 public class SimplePrecondition_impl extends MetaDataObject_impl implements SimplePrecondition {

  static final long serialVersionUID = -3736364411654445630L;

  /**
   * Value to compare against the feature.
   */
00039   private Object mComparisonValue;

  /**
   * Predicate used to compare.
   */
00044   private String mPredicate;

  private FSMatchConstraint mFsMatchConstraint;

  private String mFsIndexName;

  private String mFeatureName;

  private boolean mDefault;

  /**
   * @see org.apache.uima.analysis_engine.metadata.Precondition#getPreconditionType()
   */
00057   public String getPreconditionType() {
    return PRECONDITION_TYPE;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#getDefault()
   */
00064   public boolean getDefault() {
    return mDefault;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#getFeatureName()
   */
00071   public String getFeatureName() {
    return mFeatureName;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#getFsIndexName()
   */
00078   public String getFsIndexName() {
    return mFsIndexName;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#getFsMatchConstraint()
   */
00085   public FSMatchConstraint getFsMatchConstraint() {
    return mFsMatchConstraint;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#setDefault(boolean)
   */
00092   public void setDefault(boolean aDefault) {
    mDefault = aDefault;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#setFeatureName(java.lang.String)
   */
00099   public void setFeatureName(String aFeatureName) {
    mFeatureName = aFeatureName;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#setFsIndexName(java.lang.String)
   */
00106   public void setFsIndexName(String aIndexName) {
    mFsIndexName = aIndexName;
  }

  /**
   * @see org.apache.uima.resource.metadata.SimplePrecondition#setFsMatchConstraint(org.apache.uima.cas.FSMatchConstraint)
   */
00113   public void setFsMatchConstraint(FSMatchConstraint aConstraint) {
    mFsMatchConstraint = aConstraint;

  }

  /**
   * @see org.apache.uima.resource.metadata.Precondition#evaluate(org.apache.uima.cas.CAS)
   */
00121   public boolean evaluate(CAS aCAS) {
    return false;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.SimplePrecondition#getComparisonValue()
   */
00128   public Object getComparisonValue() {
    return mComparisonValue;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.SimplePrecondition#setComparisonValue(Object)
   */
00135   public void setComparisonValue(Object aValue) {
    mComparisonValue = aValue;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.SimplePrecondition#getPredicate()
   */
00142   public String getPredicate() {
    return mPredicate;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.SimplePrecondition#setPredicate(String)
   */
00149   public void setPredicate(String aPredicate) {
    // check to make sure value is legal
    if (!isValidPredicateName(aPredicate)) {
      throw new UIMA_IllegalArgumentException(
              UIMA_IllegalArgumentException.METADATA_ATTRIBUTE_TYPE_MISMATCH, new Object[] {
                  aPredicate, "predicate" });
    }
    mPredicate = aPredicate;
  }

  /**
   * Determines whether the given String is a valid name a predicate defined by this class. Valid
   * predicate names are legal arguments to the {@link setPredicate(String)} method, and are defined
   * by constants on the {@link SimplePrecondition} interface.
   * 
   * @param aName
   *          an Object to test
   * 
   * @return true if and only if <code>aName</code> is a <code>String</code> that is a valid
   *         predicate name.
   */
00170   protected static boolean isValidPredicateName(Object aName) {
    return EQUAL.equals(aName) || ELEMENT_OF.equals(aName) || LANGUAGE_SUBSUMED.equals(aName);
  }

00174   protected XmlizationInfo getXmlizationInfo() {
    return XMLIZATION_INFO;
  }

  static final private XmlizationInfo XMLIZATION_INFO = new XmlizationInfo(
          "simplePrecondition",
          new PropertyXmlInfo[] { new PropertyXmlInfo("featureDescription", null),
              new PropertyXmlInfo("comparisonValue"), new PropertyXmlInfo("predicate", "predicate") });
}

Generated by  Doxygen 1.6.0   Back to index