package ever.workflowRepresentation; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; /** * Option obejcts are used in combination with an XOR element. Every possible disjunctiv path of an XOR corresponds to an * Option. The option contains the condition and the Sequence(= the path) to be executed. * @author Pol Schumacher, Wirtschaftsinformatik, Institut fuer Informatik, Goethe Universitaet Frankfurt * */ public class Option { /** * The sequence to be executed. */ private Sequence seq; /** * The condition for the option. */ private String cond; /** * * @param sequence The sequence of tasks that should be performed * @param condition The condition that must be fulfilled to call sequence. */ public Option(Sequence seq, String cond) { this.seq=seq; this.cond=cond; } /** * Return the sequence of the option. * @return The sequence of the option */ public Sequence getSeq() { return seq; } /** * Sets a new sequence to the option * @param sequence */ public void setSeq(Sequence seq) { this.seq = seq; } /** * Get the condition of an option. * @return condition */ public String getCond() { return cond; } /** * Set the condition of an option. * @param condition */ public void setCond(String cond) { this.cond = cond; } /** * Write the xml representation of an option to the XMLStreamWriter * @param writer * @throws XMLStreamException */ public void exportWf2Xml(XMLStreamWriter writer) throws XMLStreamException { seq.exportWf2Xml(writer, this.cond); } // /** // * Write the xml representation of an option to the XMLStreamWriter. With special adaptations for the artificially generated workflow // * @param writer // * @throws XMLStreamException // */ // public void exportWf2XmlArti(XMLStreamWriter writer) throws XMLStreamException // { // seq.exportWf2XmlArti(writer); // // } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((cond == null) ? 0 : cond.hashCode()); result = prime * result + ((seq == null) ? 0 : seq.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Option other = (Option) obj; if (cond == null) { if (other.cond != null) return false; } else if (!cond.equals(other.cond)) return false; if (seq == null) { if (other.seq != null) return false; } else if (!seq.equals(other.seq)) return false; return true; } }