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.glm.ldm.plan.GeolocLocation;
033: import org.cougaar.planning.ldm.plan.Transferable;
034:
035: public class DFSP extends OwnedUniqueObject implements Transferable,
036: Cloneable {
037: private String name;
038: private GeolocLocation geoLoc;
039:
040: public DFSP() {
041: }
042:
043: public DFSP(String name) {
044: this .name = unique(name);
045: }
046:
047: public void setName(String name) {
048: this .name = unique(name);
049:
050: }//setname
051:
052: public void setGeoLoc(GeolocLocation geoLoc) {
053: this .geoLoc = geoLoc;
054: }//addGeoLoc
055:
056: public GeolocLocation getGeoLoc() {
057: return geoLoc;
058: }
059:
060: public String getName() {
061: return name;
062: }//getname
063:
064: public Object clone() {
065: DFSP dfsp = new DFSP(name);
066: dfsp.setUID(getUID());
067: dfsp.setOwner(getOwner());
068: dfsp.setGeoLoc((GeolocLocation) geoLoc.clone());
069: return dfsp;
070: }
071:
072: //dummy PropertyChangeSupport for the Jess Interpreter.
073: protected transient PropertyChangeSupport pcs = new PropertyChangeSupport(
074: this );
075:
076: public void addPropertyChangeListener(PropertyChangeListener pcl) {
077: pcs.addPropertyChangeListener(pcl);
078: }
079:
080: public void removePropertyChangeListener(PropertyChangeListener pcl) {
081: pcs.removePropertyChangeListener(pcl);
082: }
083:
084: private boolean matches(Object a, Object b) {
085: return (a == null) ? (b == null) : (a.equals(b));
086: }
087:
088: public boolean same(Transferable t) {
089: if (t instanceof DFSP) {
090: DFSP pod = (DFSP) t;
091: return matches(name, pod.getName())
092: && matches(geoLoc, pod.getGeoLoc());
093: } else {
094: return false;
095: }
096: }
097:
098: public void setAll(Transferable t) {
099: if (t instanceof DFSP) {
100: DFSP pod = (DFSP) t;
101: setUID(pod.getUID());
102: setOwner(pod.getOwner());
103: setName(pod.getName());
104: setGeoLoc(pod.getGeoLoc());
105: }
106: }
107:
108: public static final String unique(String s) {
109: return (s == null) ? null : (s.intern());
110: }
111:
112: }
|