All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rationals.Transition Maven / Gradle / Ivy

Go to download

HermiT is reasoner for ontologies written using the Web Ontology Language (OWL). Given an OWL file, HermiT can determine whether or not the ontology is consistent, identify subsumption relationships between classes, and much more. This is the maven build of HermiT and is designed for people who wish to use HermiT from within the OWL API. It is now versioned in the main HermiT version repository, although not officially supported by the HermiT developers. The version number of this package is a composite of the HermiT version and an value representing releases of this packaged version. So, 1.3.7.1 is the first release of the mavenized version of HermiT based on the 1.3.7 release of HermiT. This package includes the Jautomata library (http://jautomata.sourceforge.net/), and builds with it directly. This library appears to be no longer under active development, and so a "fork" seems appropriate. No development is intended or anticipated on this code base.

There is a newer version: 1.3.8.4
Show newest version
package rationals;

/**
 * Defines a Transition (an edge from a state to a state) in an Automaton
 * 
 * This class defines the notion of transition of an automaton. a transition is
 * a triple (q , l , q') where q, q' are states and
 * l a label. States q and q' must belong to
 * the same automaton A and the transition may only be used with this
 * automaton A.
 * 
 * @author [email protected]
 * @version 1.0
 * @see Automaton
 */
public class Transition {

  private int hash = Integer.MIN_VALUE;

  private State start;

  private Object label;

  private State end;

  /**
   * Creates a new transition (q , l , q').
   * 
   * @param start
   *          the state q for this transition (q , l , q').
   * @param label
   *          the label l
   * @param end
   *          the state q' for this transition (q , l , q').
   */
  public Transition(State start, Object label, State end) {
    this.start = start;
    this.label = label;
    this.end = end;
  }

  /**
   * Creates a new (invalid) transition. This transition is meant to be updated
   * internally by an automaton.
   * 
   * @param start
   *          the starting state.
   */
  Transition(State start) {
    this.start = start;
  }

  /**
   * Returns the starting state of this transition.
   * 
   * @return the starting state of this transition, that is the state q
   *         for this transition (q , l , q').
   */
  public State start() {
    return start;
  }

  /**
   * Returns the label this transition.
   * 
   * @return the label state of this transition, that is the object l
   *         for this transition (q , l , q').
   */
  public Object label() {
    return label;
  }

  /**
   * Returns the ending state of this transition.
   * 
   * @return the ending state of this transition, that is the state q'
   *         for this transition (q , l , q').
   */
  public State end() {
    return end;
  }

  /**
   * returns a textual representation of this transition.
   * 
   * @return a textual representation of this transition based
   */
  public String toString() {
    if (label == null) {
      return "(" + start + " , 1 , " + end + ")";
    } else {
      return "(" + start + " , " + label + " , " + end + ")";
    }
  }

  /**
   * Determines if this transition is equal to the parameter.
   * 
   * @param o
   *          any object.
   * @return true iff this transition is equal to the parameter. That is if
   *         o is a transition which is composed same states and
   *         label (in the sense of method equals).
   */
  public boolean equals(Object o) {
    if (o == null)
      return false;
    try {
      Transition t = (Transition) o;
      if (label != t.label) {
        if (label == null || t.label == null)
          return false;
        if (!t.label.equals(label))
          return false;
      }
      return (start == t.start()) && (end == t.end());
    } catch (ClassCastException x) {
      return false;
    }
  }

  /**
   * Returns a hashcode value for this transition.
   * 
   * @return a hashcode value for this transition.
   */
  public int hashCode() {
    /* store computed value */
    if (hash != Integer.MIN_VALUE)
      return hash;
    int x, y, z;
    if (start == null)
      x = 0;
    else
      x = start.hashCode();
    if (end == null)
      y = 0;
    else
      y = end.hashCode();
    if (label == null)
      z = 0;
    else
      z = label.hashCode();
    int t = new java.awt.Point(x, y).hashCode();
    return hash = new java.awt.Point(t, z).hashCode();
  }

  /**
   * Replaces the label for this transition
   * 

* WARNING: this method is extremely dangerous as it does not update the * alphabet of the automaton this transition is part of. Be sure you know what * you are doing or else everything could break down * * @param msg */ void setLabel(Object obj) { this.label = obj; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy