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:
027: package org.cougaar.glm.ldm.plan;
028:
029: import java.util.Collection;
030:
031: import org.cougaar.core.blackboard.DirectiveImpl;
032: import org.cougaar.core.mts.MessageAddress;
033: import org.cougaar.util.UnaryPredicate;
034:
035: /**
036: * The message sent back from a cluster containing the result of
037: * a QueryRequest.
038: */
039:
040: public class QueryReplyAssignment extends DirectiveImpl {
041: private Collection _queryReply;
042:
043: /** predicate from request. Used in for reporting in case the object is missing */
044: private UnaryPredicate _predicate;
045:
046: private UnaryPredicate _localPredicate;
047:
048: public QueryReplyAssignment(Collection reply,
049: UnaryPredicate queryPredicate, MessageAddress source,
050: MessageAddress dest) {
051:
052: _queryReply = reply;
053: _predicate = queryPredicate;
054: super .setSource(source);
055: super .setDestination(dest);
056: _localPredicate = null;
057: }
058:
059: public QueryReplyAssignment(Collection reply,
060: UnaryPredicate queryPredicate,
061: UnaryPredicate localPredicate, MessageAddress source,
062: MessageAddress dest) {
063:
064: _queryReply = reply;
065: _predicate = queryPredicate;
066: _localPredicate = localPredicate;
067: super .setSource(source);
068: super .setDestination(dest);
069: }
070:
071: /**
072: * @return the found object
073: */
074: public Collection getQueryResponse() {
075: return _queryReply;
076: }
077:
078: /**
079: * @return the UnaryPredicate from the request. Used when queryResponse is null
080: */
081: public UnaryPredicate getRequestPredicate() {
082: return _predicate;
083: }
084:
085: /**
086: * @return the UnaryPredicate from the request. Used when queryResponse is null
087: */
088: public UnaryPredicate getLocalPredicate() {
089: return _localPredicate;
090: }
091:
092: // Shouldn't really be used, but here for completeness.
093: // The other "set" methods are inherited
094: public void setQueryReply(Collection reply) {
095: _queryReply = reply;
096: }
097:
098: public String toString() {
099: String descr = "(Null AssignedQueryReply)";
100: if (_queryReply != null)
101: descr = _queryReply.toString();
102:
103: return "<QueryReplyAssignment " + descr + ", " + ">"
104: + super.toString();
105: }
106: }
|