// 
// The Waveset SPML General License 
// 
// Version 0.1, April 2003
// Copyright (C) 2003 Waveset Technologies, Inc..
// 6034 West Courtyard Drive, Suite 210, Austin, Texas 78730
// All rights reserved.
// 
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// 
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions, and the disclaimers in Sections 6
//    and 7 below.
// 
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the disclaimers in Sections 6
//    and 7 below in the documentation and/or other materials provided
//    with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if
//    any, must include the following acknowledgment:
// 
//    "This product includes software developed by 
//     Waveset Technologies, Inc. (www.waveset.com)."
// 
//    Alternately, this acknowledgment may appear in the software itself, if
//    and wherever such third-party acknowledgments normally appear.
//  
// 4. The names "Waveset" and "Waveset Technologies, Inc." must not be
//    used to endorse or promote products derived from this software
//    without the prior written permission of Waveset. For written
//    permission, please contact www.waveset.com.
//  
// 5. Products derived from this software may not be called "Waveset",
//    nor may "Waveset" appear in their name, without the prior written
//    permission of Waveset.
//  
// 6. NO WARRANTY 
// 
//    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED
//    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//    DISCLAIMED.
// 
// 7.  LIMITATION OF LIABILITY
// 
//    IN NO EVENT SHALL THE WAVESET OR ITS LICENSORS BE LIABLE FOR ANY
//    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
//    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
//    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
//    IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
//    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// End of Terms and Conditions
// ====================================================================
//
// Component Name: org.openspml.message.CancelResponse
//
// Author(s): Jeff Larson
//
// Description:
//
// Memory representation for a <spml:cancelResponse> message.
//
// The spec doesn't have this extending SpmlResponse, but in this
// model it does, so we get handling of resultCode, errorMessage,
// and requestId from there.  
//
// The only thing not provided by SpmlResponse is a "cancelResults"
// attribute and a "resultCode" ELEMENT.
//
// There can be only resultCode element, so it would appear this
// could be modeled with the "results" attribute of SpmlRequest which
// we will do in this model, and raise it as an issue for the spec.
//
// I would like to know what the difference is between the
// resultCode element and the cancelResults attribute? 
// 
//
//

package org.openspml.message;

import java.util.*;

import org.openspml.util.*;

/**
 * A class representing a <code>cancelResponse</code> message.
 */
public class CancelResponse extends SpmlResponse {

    //////////////////////////////////////////////////////////////////////
    //
    // Constants
    //
    //////////////////////////////////////////////////////////////////////

    static final String ELEMENT = "cancelResponse";

    //
    // CancelResultsType enumeration constants
    //

    public static final String RESULT_NO_SUCH_REQUEST = 
    ENUM_PREFIX + "nosuchRequest";

    public static final String RESULT_CANCELED = 
    ENUM_PREFIX + "canceled";

    public static final String RESULT_COULD_NOT_CANCEL = 
    ENUM_PREFIX + "couldnotcancel";

    //////////////////////////////////////////////////////////////////////
    //
    // Constructors
    //
    //////////////////////////////////////////////////////////////////////

    /**
     * Cancel result code.
     // NOTE: It seems possible to model this simply as a restriction
     // on the "results" attriute inherited from SpmlResponse?
    */
    String _cancelResult;

    //////////////////////////////////////////////////////////////////////
    //
    // Constructors
    //
    //////////////////////////////////////////////////////////////////////

    public CancelResponse() {
    }

    CancelResponse(XmlElement e) {
	parseXml(e);
    }

    public void setCancelResult(String s) {
        _cancelResult = s;
    }

    public String getCancelResult() {
        return _cancelResult;
    }

    //////////////////////////////////////////////////////////////////////
    //
    // XML
    //
    //////////////////////////////////////////////////////////////////////

    String getElementName() {
        return ELEMENT;
    }

    void addSubclassAttributes(SpmlBuffer b) {
        
        b.addAttribute("cancelResults", _cancelResult);
    }

    void parseXml(XmlElement e) {
        super.parseXml(e);

        _cancelResult = e.getAttribute("cancelResults");
    }

}
