diff options
Diffstat (limited to 'NET/worlds/scape/VectorProperty.java')
| -rw-r--r-- | NET/worlds/scape/VectorProperty.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/NET/worlds/scape/VectorProperty.java b/NET/worlds/scape/VectorProperty.java new file mode 100644 index 0000000..cbd9573 --- /dev/null +++ b/NET/worlds/scape/VectorProperty.java @@ -0,0 +1,76 @@ +package NET.worlds.scape; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +public class VectorProperty extends Property { + private PropAdder adder; + private boolean allowSorting = true; + + public VectorProperty(Properties owner, int index, String propName) { + super(owner, index, propName); + } + + public static Vector toVector(Object[] arr) { + Vector v = new Vector(arr.length); + + for (int i = 0; i < arr.length; i++) { + v.addElement(arr[i]); + } + + return v; + } + + public static Vector toVector(Hashtable hash) { + Vector v = new Vector(hash.size()); + Enumeration e = hash.elements(); + + while (e.hasMoreElements()) { + v.addElement(e.nextElement()); + } + + return v; + } + + public Object delete(Object obj) { + assert obj != null; + + assert this.adder != null; + + return this.operate(4, obj); + } + + public Object add(Object obj) { + assert obj != null; + + assert this.adder != null; + + return this.operate(3, obj); + } + + public boolean addTest(Object obj) { + assert obj != null; + + assert this.adder != null; + + return this.operate(5, obj) != null; + } + + public VectorProperty setAdder(PropAdder adder) { + this.adder = adder; + return this; + } + + public PropAdder getAdder() { + return this.adder; + } + + public void allowSorting(boolean allow) { + this.allowSorting = allow; + } + + public boolean shouldSort() { + return this.allowSorting; + } +} |