01: /*
02: *
03: * <copyright>
04: *
05: * Copyright 1997-2004 BBNT Solutions, LLC
06: * under sponsorship of the Defense Advanced Research Projects
07: * Agency (DARPA).
08: *
09: * You can redistribute this software and/or modify it under the
10: * terms of the Cougaar Open Source License as published on the
11: * Cougaar Open Source Website (www.cougaar.org).
12: *
13: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24: *
25: * </copyright>
26: */
27: package org.cougaar.planning.servlet;
28:
29: import org.cougaar.planning.ldm.plan.AllocationResult;
30: import org.cougaar.planning.ldm.plan.PlanElement;
31: import org.cougaar.planning.ldm.plan.Task;
32:
33: /**
34: * These are example "public static boolean" methods for use by the
35: * <code>PlanViewServlet</code> as examples in the "Advanced Search".
36: *
37: * The file <tt>PlanViewServlet.DEFAULT_PRED_FILENAME</tt> uses these as
38: * examples, such as:<pre>
39: * (org.cougaar.planning.servlet.PredExamples:examplePredicateA (this))
40: * </pre>.
41: */
42: public class PredExamples {
43:
44: /**
45: * This is an example of a "public static boolean" predicate for the
46: * predicate search -- this one happens to check for a <code>Task</code>,
47: * but one could write arbitrarily complicated code here.
48: *
49: * This is here for the examples only! Other "utility" predicates should
50: * be placed in a different class (e.g. "SearchUtils")!
51: */
52: public static boolean examplePredicateA(Object o) {
53: return (o instanceof Task);
54: }
55:
56: /** @see #examplePredicateA(Object) */
57: public static boolean examplePredicateB(Task t, String verbStr) {
58: return t.getVerb().equals(verbStr);
59: }
60:
61: /** @see #examplePredicateA(Object) */
62: public static boolean examplePredicateC(Object o, String verbStr,
63: double minConf) {
64: if (o instanceof Task) {
65: Task t = (Task) o;
66: if ((verbStr == null) || (t.getVerb().equals(verbStr))) {
67: PlanElement pe = t.getPlanElement();
68: if (pe != null) {
69: AllocationResult est = pe.getEstimatedResult();
70: return ((est != null) && (est.getConfidenceRating() >= minConf));
71: }
72: }
73: }
74: return false;
75: }
76: }
|