001: package org.zilonis.network.production;
002:
003: /**
004: * Copyright (c) 2005 Elie Levy <elie.levy@zilonis.org>
005: * All rights reserved
006: *
007: * This License governs use of the accompanying Software, and your use of the
008: * Software constitutes acceptance of this license.
009: *
010: * You may use this Software for any non-commercial purpose, subject to the
011: * restrictions in this license. Some purposes which can be non-commercial are
012: * teaching, academic research, and personal experimentation. You may also
013: * distribute this Software with books or other teaching materials, or publish
014: * the Software on websites, that are intended to teach the use of the
015: * Software.
016: *
017: *
018: * You may not use or distribute this Software or any derivative works in any
019: * form for commercial purposes. Examples of commercial purposes would be
020: * running business operations, licensing, leasing, or selling the Software, or
021: * distributing the Software for use with commercial products.
022: *
023: * You may modify this Software and distribute the modified Software for
024: * non-commercial purposes, however, you may not grant rights to the Software
025: * or derivative works that are broader than those provided by this License.
026: * For example, you may not distribute modifications of the Software under
027: * terms that would permit commercial use, or under terms that purport to
028: * require the Software or derivative works to be sublicensed to others.
029: *
030: * You may use any information in intangible form that you remember after
031: * accessing the Software. However, this right does not grant you a license to
032: * any of the copyrights or patents for anything you might create using such
033: * information.
034: *
035: * In return, we simply require that you agree:
036: *
037: * Not to remove any copyright or other notices from the Software.
038: *
039: *
040: * That if you distribute the Software in source or object form, you will
041: * include a verbatim copy of this license.
042: *
043: *
044: * That if you distribute derivative works of the Software in source code form
045: * you do so only under a license that includes all of the provisions of this
046: * License, and if you distribute derivative works of the Software solely in
047: * object form you do so only under a license that complies with this License.
048: *
049: *
050: * That if you have modified the Software or created derivative works, and
051: * distribute such modifications or derivative works, you will cause the
052: * modified files to carry prominent notices so that recipients know that they
053: * are not receiving the original Software. Such notices must state: (i) that
054: * you have changed the Software; and (ii) the date of any changes.
055: *
056: *
057: * THAT THE SOFTWARE COMES "AS IS", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,
058: * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF
059: * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR ANY WARRANTY OF TITLE
060: * OR NON-INFRINGEMENT. ALSO, YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU
061: * DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
062: *
063: *
064: * THAT NEITHER ZILONIS NOR THE AUTHOR WILL BE LIABLE FOR ANY DAMAGES RELATED
065: * TO THE SOFTWARE OR THIS LICENSE, INCLUDING DIRECT, INDIRECT, SPECIAL,
066: * CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS,
067: * NO MATTER WHAT LEGAL THEORY IT IS BASED ON. ALSO, YOU MUST PASS THIS
068: * LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR
069: * DERIVATIVE WORKS.
070: *
071: *
072: * That if you sue anyone over patents that you think may apply to the Software
073: * or anyone's use of the Software, your license to the Software ends
074: * automatically.
075: *
076: *
077: * That your rights under the License end automatically if you breach it in any
078: * way.
079: *
080: *
081: * Elie Levy reserves all rights not expressly granted to you in this
082: * license.
083: *
084: */
085:
086: import org.zilonis.network.Deletable;
087: import org.zilonis.scope.Scope;
088: import org.zilonis.symbol.Triplet;
089: import org.zilonis.util.BinaryTree;
090: import org.zilonis.util.IMultiListElement;
091: import org.zilonis.util.MultiListElement;
092: import org.zilonis.util.NextHolder;
093:
094: public class ActionResult extends MultiListElement implements
095: BinaryTree<ActionResult>, Deletable {
096:
097: public final static int ASSERT = 0;
098:
099: public final static int RETRACT = 1;
100:
101: public final static int PRINT = 2;
102:
103: public final static int MODIFY = 4;
104:
105: public final static int EXPRESSION = 5;
106:
107: private Triplet triplet;
108:
109: private Triplet tripletToRemove;
110:
111: private int type;
112:
113: private int priority;
114:
115: private Scope scope;
116:
117: private boolean valid;
118:
119: private ActionResult left;
120:
121: private ActionResult right;
122:
123: public ActionResult(Scope scope, int type, Triplet triplet,
124: int priority) {
125: super (4);
126: this .scope = scope;
127: this .type = type;
128: this .triplet = triplet;
129: this .priority = priority;
130: valid = true;
131: }
132:
133: public ActionResult(Scope scope, int type, Triplet triplet,
134: Triplet tripletToRemove, int priority) {
135: super (1);
136: this .scope = scope;
137: this .type = type;
138: this .triplet = triplet;
139: this .tripletToRemove = tripletToRemove;
140: this .priority = priority;
141: valid = true;
142: }
143:
144: public boolean isValid() {
145: return valid;
146: }
147:
148: public void deleteItAndDescendents() {
149: valid = false;
150: }
151:
152: public void remove(int list) {
153: super .remove(0);
154: }
155:
156: public void setNext(int list, IMultiListElement element) {
157: super .setNext(0, element);
158: }
159:
160: public void setPrev(int list, NextHolder element) {
161: super .setPrev(0, element);
162: }
163:
164: public IMultiListElement getNext(int list) {
165: return super .getNext(0);
166: }
167:
168: public NextHolder getPrev(int list) {
169: return super .getPrev(0);
170: }
171:
172: public void removeLast(int list, IMultiListElement element) {
173: super .removeLast(0, element);
174: }
175:
176: public Scope getScope() {
177: return scope;
178: }
179:
180: public int getPriority() {
181: return priority;
182: }
183:
184: public void setLeft(ActionResult left) {
185: this .left = left;
186: }
187:
188: public void setRight(ActionResult right) {
189: this .right = right;
190: }
191:
192: public ActionResult getLeft() {
193: return left;
194: }
195:
196: public ActionResult getRight() {
197: return right;
198: }
199:
200: public Triplet getTriplet() {
201: return triplet;
202: }
203:
204: public Triplet getTripletToRemove() {
205: return tripletToRemove;
206: }
207:
208: public boolean isType(int type) {
209: return (this .type == type);
210: }
211:
212: public int getType() {
213: return type;
214: }
215:
216: public int compareTo(ActionResult actionResult) {
217: return getPriority() - actionResult.getPriority();
218: }
219: }
|