org.openspml.message.Modification Maven / Gradle / Ivy
Show all versions of openspml Show documentation
//
// 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.Modification
//
// Author(s): Jeff Larson
//
// Description:
//
// Memory representation for an SPML (and DSML) element.
//
//
package org.openspml.message;
import java.util.*;
import org.openspml.util.*;
/**
* Memory representation for a modification
element, found
* within a modifyRequest
message.
*
* Currently this is the same as a DmslModification, though it is
* likely to be extended to provide a richer set of value types.
* DSML only allows xsd:string, xsd:base64binary and xsd:anyURI values.
*/
public class Modification extends Attribute {
//////////////////////////////////////////////////////////////////////
//
// Fields
//
// _name, _value, and _values inherited from Attribute.
//
//////////////////////////////////////////////////////////////////////
static final String ELEMENT = "modification";
//
// Operation types
// These come from the DSML spec, note that DSML does
// not use an enumeration prefix like SPML does.
//
/**
* Constant used with setOperation
to indicate that
* the modification list is to replace the entire value of the attribute.
*/
public static final String OP_REPLACE = "replace";
/**
* Constant used with setOperation
to indicate that
* the modification list is to be merged with the current value
* of the attribute. This is relevant only for multi-valued
* attributes.
*/
public static final String OP_ADD = "add";
/**
* Constant used with setOperation
to indicate that
* the values on the modification list are to be removed from
* the current value of the attribute. This is relevant only
* for multi-valued attributes.
*/
public static final String OP_DELETE = "delete";
/**
* Type of modification to perform. Defaults to "replace".
*/
String _operation;
//////////////////////////////////////////////////////////////////////
//
// Construtors
//
//////////////////////////////////////////////////////////////////////
public Modification() {
}
Modification(XmlElement e) {
parseXml(e);
}
public Modification(String name, Object value) {
super(name, value);
}
public void setOperation(String s) {
_operation = s;
}
//////////////////////////////////////////////////////////////////////
//
// Accessors
//
//////////////////////////////////////////////////////////////////////
public String getOperation() {
return _operation;
}
//////////////////////////////////////////////////////////////////////
//
// XML
//
//////////////////////////////////////////////////////////////////////
String getElementName() {
return ELEMENT;
}
void addSubclassAttributes(SpmlBuffer b) {
// does this have a default?
// does this have to be dsml: qualified?
// the attribute is ours, but the type is dsml:Modification,
// so we may need to
if (_operation != null)
b.addAttribute("operation", _operation);
else
b.addAttribute("operation", OP_REPLACE);
}
void parseXml(XmlElement e) {
super.parseXml(e);
// !! if the operation attribute can be quallified, will
// need to strip the prefix
_operation = e.getAttribute("operation");
}
}