001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management.modelmbean;
023:
024: import java.io.IOException;
025: import java.io.ObjectInputStream;
026: import java.io.ObjectOutputStream;
027: import java.io.ObjectStreamField;
028:
029: import org.jboss.mx.util.Serialization;
030:
031: /**
032: * Exceptions related to XML handling.
033: *
034: * @see javax.management.modelmbean.DescriptorSupport
035: *
036: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
037: * @author <a href="mailto:adrian.brock@happeningtimes.com">Adrian Brock</a>.
038: * @version $Revision: 57200 $
039: *
040: * <p><b>Revisions:</b>
041: * <p><b>20020715 Adrian Brock:</b>
042: * <ul>
043: * <li> Serialization
044: * </ul>
045: *
046: */
047: public class XMLParseException extends Exception {
048: // Attributes ----------------------------------------------------
049:
050: // Static --------------------------------------------------------
051:
052: private static final long serialVersionUID;
053: private static final ObjectStreamField[] serialPersistentFields;
054:
055: static {
056: switch (Serialization.version) {
057: case Serialization.V1R0:
058: serialVersionUID = -7780049316655891976L;
059: serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField(
060: "msgStr", String.class) };
061: break;
062: default:
063: serialVersionUID = 3176664577895105181L;
064: serialPersistentFields = new ObjectStreamField[0];
065: }
066: }
067:
068: // Constructors --------------------------------------------------
069: public XMLParseException() {
070: super ();
071: }
072:
073: public XMLParseException(String s) {
074: super (s);
075: }
076:
077: public XMLParseException(Exception e, String s) {
078: // REVIEW Adrian Brock: The exception doesn't seem to be serialized so
079: // I'm including it in the constructed message.
080: super ("XMLParseException: " + s
081: + ((e == null) ? "" : "\nCause: " + e.toString()));
082: }
083:
084: // Object overrides ----------------------------------------------
085:
086: // Private -------------------------------------------------------
087:
088: private void readObject(ObjectInputStream ois) throws IOException,
089: ClassNotFoundException {
090: switch (Serialization.version) {
091: case Serialization.V1R0:
092: break;
093: default:
094: ois.defaultReadObject();
095: }
096: }
097:
098: private void writeObject(ObjectOutputStream oos) throws IOException {
099: switch (Serialization.version) {
100: case Serialization.V1R0:
101: ObjectOutputStream.PutField putField = oos.putFields();
102: putField.put("msgStr", getMessage());
103: oos.writeFields();
104: break;
105: default:
106: oos.defaultWriteObject();
107: }
108: }
109: }
|