001: /*
002: * <copyright>
003: *
004: * Copyright 2002-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:
027: package org.cougaar.servicediscovery.description;
028:
029: import org.cougaar.planning.ldm.plan.Role;
030:
031: import org.cougaar.util.log.Logger;
032: import org.cougaar.util.log.Logging;
033: import org.cougaar.util.TimeSpan;
034:
035: public class MMRoleQueryBase implements MMQuery, java.io.Serializable {
036: private static Logger logger = Logging
037: .getLogger(MMRoleQueryBase.class);
038: private Role myRole = null;
039: private TimeSpan myTimeSpan = null;
040: private boolean myObsolete = false;
041:
042: public MMRoleQueryBase(Role role) {
043: myRole = role;
044: }
045:
046: public MMRoleQueryBase(Role role, TimeSpan timeSpan) {
047: this (role);
048: myTimeSpan = timeSpan;
049: }
050:
051: public void setRole(Role role) {
052: if (role != null) {
053: logger
054: .warn("setRole: ignoring attempt to change Role from "
055: + myRole + " to " + role);
056: } else {
057: myRole = role;
058: }
059: }
060:
061: public Role getRole() {
062: return myRole;
063: }
064:
065: public void setTimeSpan(TimeSpan timeSpan) {
066: if (timeSpan != null) {
067: logger
068: .warn("setTimeSpan: ignoring attempt to change TimeSpan from "
069: + myTimeSpan + " to " + timeSpan);
070: } else {
071: myTimeSpan = timeSpan;
072: }
073: }
074:
075: public TimeSpan getTimeSpan() {
076: return myTimeSpan;
077: }
078:
079: public boolean getObsolete() {
080: return myObsolete;
081: }
082:
083: public void setObsolete(boolean obsoleteFlag) {
084: if ((myObsolete) && (!obsoleteFlag)) {
085: logger
086: .warn("setObsolete: ignoring attempt to toggle obsolete "
087: + "back to false.");
088: } else {
089: myObsolete = obsoleteFlag;
090: }
091: }
092:
093: public String toString() {
094: return "Role: " + myRole + " TimeSpan: " + myTimeSpan
095: + " Obsolete: " + myObsolete;
096: }
097:
098: public boolean equals(Object o) {
099: if (o instanceof MMRoleQueryBase) {
100: MMRoleQueryBase query = (MMRoleQueryBase) o;
101: return ((query.getObsolete() == myObsolete)
102: && (query.getRole().equals(myRole))
103: && (query.getTimeSpan().getStartTime() == myTimeSpan
104: .getStartTime()) && (query.getTimeSpan()
105: .getEndTime() == myTimeSpan.getEndTime()));
106: } else {
107: return false;
108: }
109: }
110: }
|