/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2011 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2011 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/
package org.opennms.netmgt.config.datacollection;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;
/**
* Parameters to be used for configuration this strategy.
*/
@XmlRootElement(name="parameter", namespace="http://xmlns.opennms.org/xsd/config/datacollection")
@XmlAccessorType(XmlAccessType.NONE)
public class Parameter implements Serializable {
private static final long serialVersionUID = -81271205406892996L;
/**
* Field _key.
*/
private String m_key;
/**
* Field _value.
*/
private String m_value;
//----------------/
//- Constructors -/
//----------------/
public Parameter() {
super();
}
public Parameter(final String key, final String value) {
m_key = key.intern();
m_value = value.intern();
}
/**
* Overrides the java.lang.Object.equals method.
*
* @param obj
* @return true if the objects are equal.
*/
@Override()
public boolean equals(final Object obj) {
if ( this == obj )
return true;
if (obj instanceof Parameter) {
final Parameter temp = (Parameter)obj;
if (m_key != null) {
if (temp.m_key == null) return false;
else if (!(m_key.equals(temp.m_key)))
return false;
}
else if (temp.m_key != null)
return false;
if (m_value != null) {
if (temp.m_value == null) return false;
else if (!(m_value.equals(temp.m_value)))
return false;
}
else if (temp.m_value != null)
return false;
return true;
}
return false;
}
/**
* Returns the value of field 'key'.
*
* @return the value of field 'Key'.
*/
@XmlAttribute(name="key", required=true)
public String getKey() {
return m_key;
}
/**
* Returns the value of field 'value'.
*
* @return the value of field 'Value'.
*/
@XmlAttribute(name="value", required=true)
public String getValue() {
return m_value;
}
/**
* Overrides the java.lang.Object.hashCode method.
* <p>
* The following steps came from <b>Effective Java Programming
* Language Guide</b> by Joshua Bloch, Chapter 3
*
* @return a hash code value for the object.
*/
public int hashCode() {
int result = 17;
if (m_key != null) {
result = 37 * result + m_key.hashCode();
}
if (m_value != null) {
result = 37 * result + m_value.hashCode();
}
return result;
}
/**
* Method isValid.
*
* @return true if this object is valid according to the schema
*/
@Deprecated
public boolean isValid() {
try {
validate();
} catch (ValidationException vex) {
return false;
}
return true;
}
/**
*
*
* @param out
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
*/
@Deprecated
public void marshal(final Writer out) throws MarshalException, ValidationException {
Marshaller.marshal(this, out);
}
/**
*
*
* @param handler
* @throws java.io.IOException if an IOException occurs during
* marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
*/
@Deprecated
public void marshal(final ContentHandler handler) throws IOException, MarshalException, ValidationException {
Marshaller.marshal(this, handler);
}
/**
* Sets the value of field 'key'.
*
* @param key the value of field 'key'.
*/
public void setKey(final String key) {
m_key = key.intern();
}
/**
* Sets the value of field 'value'.
*
* @param value the value of field 'value'.
*/
public void setValue(final String value) {
m_value = value.intern();
}
/**
* Method unmarshal.
*
* @param reader
* @throws org.exolab.castor.xml.MarshalException if object is
* null or if any SAXException is thrown during marshaling
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
* @return the unmarshaled
* org.opennms.netmgt.config.datacollection.types.Parameter
*/
@Deprecated
public static Parameter unmarshal(final Reader reader) throws MarshalException, ValidationException {
return (Parameter)Unmarshaller.unmarshal(Parameter.class, reader);
}
/**
*
*
* @throws org.exolab.castor.xml.ValidationException if this
* object is an invalid instance according to the schema
*/
@Deprecated
public void validate() throws ValidationException {
new org.exolab.castor.xml.Validator().validate(this);
}
}