001: /*
002: * <copyright>
003: *
004: * Copyright 2003-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.logistics.servlet;
027:
028: import org.cougaar.planning.servlet.data.xml.*;
029:
030: import java.io.Writer;
031: import java.io.IOException;
032: import java.io.Serializable;
033:
034: import org.xml.sax.Attributes;
035:
036: /** simple piece of data returned from the ConditionServlet */
037: public class ConditionData implements XMLable, DeXMLable, Serializable {
038:
039: //Variables:
040: ////////////
041:
042: public static final String NAME_TAG = "ConditionData";
043: boolean wasSet = false;
044:
045: //Constructors:
046: ///////////////
047:
048: public ConditionData(boolean val) {
049: setWasSet(val);
050: }
051:
052: //Members:
053: //////////
054:
055: public void setWasSet(boolean val) {
056: wasSet = val;
057: }
058:
059: public boolean wasSet() {
060: return wasSet;
061: }
062:
063: //XMLable members:
064: //----------------
065:
066: /**
067: * Write this class out to the Writer in XML format
068: * @param w output Writer
069: **/
070: public void toXML(XMLWriter w) throws IOException {
071: w.optagln(NAME_TAG, "result", "true");
072: w.cltagln(NAME_TAG);
073: }
074:
075: //DeXMLable members:
076: //------------------
077:
078: /**
079: * Report a startElement that pertains to THIS object, not any
080: * sub objects. Call also provides the elements Attributes and data.
081: * Note, that unlike in a SAX parser, data is guaranteed to contain
082: * ALL of this tag's data, not just a 'chunk' of it.
083: * @param name startElement tag
084: * @param attr attributes for this tag
085: * @param data data for this tag
086: **/
087: public void openTag(String name, Attributes attr, String data)
088: throws UnexpectedXMLException {
089: if (name.equals(NAME_TAG)) {
090: wasSet = attr.getValue("result").equals("true");
091: } else
092: throw new UnexpectedXMLException("Unexpected tag: " + name);
093: }
094:
095: /**
096: * Report an endElement.
097: * @param name endElement tag
098: * @return true iff the object is DONE being DeXMLized
099: **/
100: public boolean closeTag(String name) throws UnexpectedXMLException {
101:
102: return name.equals(NAME_TAG);
103: }
104:
105: /**
106: * This function will be called whenever a subobject has
107: * completed de-XMLizing and needs to be encorporated into
108: * this object.
109: * @param name the startElement tag that caused this subobject
110: * to be created
111: * @param obj the object itself
112: **/
113: public void completeSubObject(String name, DeXMLable obj)
114: throws UnexpectedXMLException {
115: }
116:
117: //Inner Classes:
118:
119: /**
120: * Set the serialVersionUID to keep the object serializer from seeing
121: * xerces (org.xml.sax.Attributes).
122: */
123: // private static final long serialVersionUID = 1389218378192871398L;
124: }
|