Java tutorial
/******************************************************************************* * This file is part of OpenNMS(R). * * Copyright (C) 2011-2012 The OpenNMS Group, Inc. * OpenNMS(R) is Copyright (C) 1999-2012 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/ *******************************************************************************/ /* * This class was automatically generated with * <a href="http://www.castor.org">Castor 1.1.2.1</a>, using an XML * Schema. * $Id$ */ package org.opennms.netmgt.xml.eventconf; //---------------------------------/ //- Imported classes and packages -/ //---------------------------------/ 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 javax.xml.bind.annotation.XmlValue; import org.apache.commons.lang.builder.HashCodeBuilder; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** * The event logmsg with the destination attribute defining * if event is for display only, logonly, log and display or * neither. A * destination attribute of 'donotpersist' indicates that Eventd * is not to * persist the event to the database. A value of 'discardtraps' * instructs * the SNMP trap daemon to not create events for incoming traps * that match * this event. The optional notify attributed can be used to * suppress notices * on a particular event (by default it is true - i.e. a notice * will be sent. * * @version $Revision$ $Date$ */ @XmlRootElement(name = "logmsg") @XmlAccessorType(XmlAccessType.FIELD) @SuppressWarnings("serial") public class Logmsg implements java.io.Serializable { //--------------------------/ //- Class/Member Variables -/ //--------------------------/ /** * internal content storage */ @XmlValue private String m_content = ""; /** * Field _notify. */ @XmlAttribute(name = "notify", required = false) private Boolean m_notify; /** * Field _dest. */ @XmlAttribute(name = "dest", required = false) private String m_dest; //----------------/ //- Constructors -/ //----------------/ public Logmsg() { super(); } //-----------/ //- Methods -/ //-----------/ /** */ public void deleteNotify() { m_notify = null; } /** * Overrides the java.lang.Object.equals method. * * @param obj * @return true if the objects are equal. */ @Override() public boolean equals(final java.lang.Object obj) { if (this == obj) return true; if (obj instanceof Logmsg) { Logmsg temp = (Logmsg) obj; if (this.m_content != null) { if (temp.m_content == null) return false; else if (!(this.m_content.equals(temp.m_content))) return false; } else if (temp.m_content != null) return false; if (this.m_notify != temp.m_notify) return false; if (this.m_dest != null) { if (temp.m_dest == null) return false; else if (!(this.m_dest.equals(temp.m_dest))) return false; } else if (temp.m_dest != null) return false; return true; } return false; } /** * Returns the value of field 'content'. The field 'content' * has the following description: internal content storage * * @return the value of field 'Content'. */ public String getContent() { return m_content; } /** * Returns the value of field 'dest'. * * @return the value of field 'Dest'. */ public String getDest() { return m_dest; } /** * Returns the value of field 'notify'. * * @return the value of field 'Notify'. */ public Boolean getNotify() { return m_notify == null ? Boolean.TRUE : m_notify; // Default is true according to XSD } /** * Method hasNotify. * * @return true if at least one Notify has been added */ public boolean hasNotify() { return m_notify != null; } /** * 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() { return new HashCodeBuilder(17, 37).append(getContent()).append(getNotify()).append(getDest()).toHashCode(); } /** * Returns the value of field 'notify'. * * @return the value of field 'Notify'. */ public boolean isNotify() { return this.m_notify; } /** * Method isValid. * * @return true if this object is valid according to the schema */ public boolean isValid() { try { validate(); } catch (org.exolab.castor.xml.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 */ public void marshal(final java.io.Writer out) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.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 */ public void marshal(final org.xml.sax.ContentHandler handler) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); } /** * Sets the value of field 'content'. The field 'content' has * the following description: internal content storage * * @param content the value of field 'content'. */ public void setContent(final String content) { this.m_content = content; } /** * Sets the value of field 'dest'. * * @param dest the value of field 'dest'. */ public void setDest(final String dest) { this.m_dest = dest.intern(); } /** * Sets the value of field 'notify'. * * @param notify the value of field 'notify'. */ public void setNotify(final boolean notify) { this.m_notify = notify; } /** * 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.xml.eventconf.Logmsg */ public static org.opennms.netmgt.xml.eventconf.Logmsg unmarshal(final java.io.Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { return (org.opennms.netmgt.xml.eventconf.Logmsg) Unmarshaller .unmarshal(org.opennms.netmgt.xml.eventconf.Logmsg.class, reader); } /** * * * @throws org.exolab.castor.xml.ValidationException if this * object is an invalid instance according to the schema */ public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); } }