Instruction.java
Go to the documentation of this file.
00001 package instruction.semanticObjects;
00002 
00003 
00004 import java.util.ArrayList;
00005 import java.util.Iterator;
00006 import java.util.List;
00007 
00008 public class Instruction extends SemanticObject {
00009         
00010         public static final int OPTIONAL_FALSE = 0;
00011         public static final int OPTIONAL_LOCAL = 1;
00012         public static final int OPTIONAL_GLOBAL = 2;
00013         
00014         Action action = new Action();
00015         
00016         String nlSentence = "";
00017         
00018         List<ObjectX> objects = new ArrayList<ObjectX>();
00019         
00020         List<Precondition> preconditions = new ArrayList<Precondition>();
00021         
00022         List<Postcondition> postconditions = new ArrayList<Postcondition>();
00023         
00024         List<Preposition> prepositions = new ArrayList<Preposition>();
00025         
00026         Quantifier timeConstraint = null;
00027         
00028         int optional = OPTIONAL_FALSE;
00029                 
00030         
00031         public Instruction() {
00032         }
00033         
00034         public void setTimeConstraint(Quantifier q) {
00035                 timeConstraint = q;
00036         }
00037         
00038         public Quantifier getTimeConstraint() {
00039                 return timeConstraint;
00040         }
00041         
00042         public void setAction(Action action) {
00043                 this.action = action;
00044         }
00045         
00046         public void addObject(ObjectX object) {
00047                 objects.add(object);
00048         }
00049         
00050         public void setObjects(List<ObjectX> os) {
00051                 objects = os;
00052         }
00053         
00054         public void setPrepositions(List<Preposition> pp) {
00055                 prepositions = pp;
00056         }
00057         
00058         public void setPreconditions(List<Precondition> pc) {
00059                 preconditions = pc;
00060         }
00061         
00062         public void setPostconditions(List<Postcondition> pc) {
00063                 postconditions = pc;
00064         }
00065 
00066         public void addPreposition(Preposition prep) {
00067                 prepositions.add(prep);
00068         }
00069         
00070         public Action getAction() {
00071                 return action;
00072         }
00073         
00074         public List<ObjectX> getObjects() {
00075                 return objects;
00076         }
00077         
00078         public List<Preposition> getPrepositions() {
00079                 return prepositions;
00080         }
00081         
00082         public List<Postcondition> getPostconditions() {
00083                 return postconditions;
00084         }
00085         
00086         public List<Precondition> getPreconditions() {
00087                 return preconditions;
00088         }
00089         
00090         public String toString() {
00091                 String str = "(";
00092 //              str += "preconditions: ";
00093 //              for (Iterator i = preconditions.iterator(); i.hasNext(); ) {
00094 //                      str += ((Precondition) i.next()).toString();
00095 //                      if (i.hasNext())
00096 //                              str += ", ";
00097 //              }
00098                 str += "\n\t" + action.getAction();
00099                 
00100                 str += ",\n\t{";
00101                 for (Iterator i = objects.iterator(); i.hasNext(); ) {
00102                         str += ((ObjectX) i.next()).toString();
00103                         if (i.hasNext())
00104                                 str += ", ";
00105                 }
00106         
00107                 str += "},\n\t{";
00108                 for (Iterator i = prepositions.iterator(); i.hasNext(); ) {
00109                         str += ((Preposition) i.next()).toString();
00110                         if (i.hasNext())
00111                                 str += ", ";
00112                 }
00113                 if (timeConstraint != null) {
00114                         str += "},\n\t";
00115                         str += timeConstraint.toString();
00116                 }
00117                 str += ")";
00118                 
00119 //              str += "\n\tpostconditions: ";
00120 //              for (Iterator i = postconditions.iterator(); i.hasNext(); ) {
00121 //                      str += ((Postcondition) i.next()).toString();
00122 //                      if (i.hasNext())
00123 //                              str += ", ";
00124 //              }
00125                 
00126                 
00127                 return str;
00128         }
00129 
00130         
00131         public boolean equals(Object i) {
00132                 if (! (i instanceof Instruction))
00133                         return false;
00134                 boolean equals = true;
00135                 
00136                 equals = equals && action.equals( ((Instruction) i).getAction() );
00137                 equals = equals && objects.equals( ((Instruction) i).getObjects() );
00138                 equals = equals && preconditions.equals( ((Instruction) i).getPreconditions() );
00139                 equals = equals && postconditions.equals( ((Instruction) i).getPostconditions() );
00140                 equals = equals && prepositions.equals( ((Instruction) i).getPrepositions() );
00141                 
00142                 return equals;
00143 
00144         }
00145         
00146         public void setNLSentence(String sentence) {
00147                 nlSentence = sentence;
00148         }
00149         
00150         public String getNLSentence() {
00151                 return nlSentence;
00152         }
00153         
00154         public boolean isOptional() {
00155 
00156                 return optional == OPTIONAL_GLOBAL || optional == OPTIONAL_LOCAL;
00157         }
00158         
00159         public boolean isGlobalOptional() {
00160                 return optional == OPTIONAL_GLOBAL;
00161         }
00162         
00163         public void setOptional( int optional ) {
00164 
00165                 this.optional = optional;
00166         }
00167 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


comp_ehow
Author(s): Moritz Tenorth, Daniel Nyga
autogenerated on Tue Apr 16 2013 00:18:02