001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026: package org.cougaar.glm.ldm.oplan;
027:
028: import java.beans.PropertyChangeListener;
029: import java.beans.PropertyChangeSupport;
030:
031: import org.cougaar.core.util.OwnedUniqueObject;
032: import org.cougaar.planning.ldm.plan.Transferable;
033:
034: public class POD extends OwnedUniqueObject implements Transferable,
035: Cloneable {
036: private String type;
037: private String value;
038:
039: public void setType(String type) {
040: this .type = unique(type);
041: }//setType
042:
043: public void setValue(String value) {
044: this .value = unique(value);
045: }//setValue
046:
047: public String getType() {
048: return type;
049: }//getType
050:
051: public String getValue() {
052: return value;
053: }//getValue
054:
055: public Object clone() {
056: POD pod = new POD();
057: pod.setUID(getUID());
058: pod.setOwner(getOwner());
059: pod.setType(type);
060: pod.setValue(value);
061:
062: return pod;
063: }// clone
064:
065: //dummy PropertyChangeSupport for the Jess Interpreter.
066: protected transient PropertyChangeSupport pcs = new PropertyChangeSupport(
067: this );
068:
069: public void addPropertyChangeListener(PropertyChangeListener pcl) {
070: pcs.addPropertyChangeListener(pcl);
071: }
072:
073: public void removePropertyChangeListener(PropertyChangeListener pcl) {
074: pcs.removePropertyChangeListener(pcl);
075: }
076:
077: private boolean matches(Object a, Object b) {
078: return (a == null) ? (b == null) : (a.equals(b));
079: }
080:
081: public boolean same(Transferable t) {
082: if (t instanceof POD) {
083: POD pod = (POD) t;
084: return matches(type, pod.getType())
085: && matches(value, pod.getValue());
086: } else {
087: return false;
088: }
089: }
090:
091: public void setAll(Transferable t) {
092: if (t instanceof POD) {
093: POD pod = (POD) t;
094: setUID(pod.getUID());
095: setOwner(pod.getOwner());
096: setType(pod.getType());
097: setValue(pod.getValue());
098: }
099: }
100:
101: public static final String unique(String s) {
102: return (s == null) ? null : (s.intern());
103: }
104:
105: }// POD
|