1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
40 * the property is guaranteed to remain unchanged, as if the setter were never
41 * called.
42 *
43 * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
44 * @see ValidationEvent
45 * @since JAXB1.0
46 */
47
48 public class TypeConstraintException extends java.lang.RuntimeException {
49
50 /**
51 * Vendor specific error code
52 *
53 */
54 private String errorCode;
55
56 /**
57 * Exception reference
58 *
59 */
60 private volatile Throwable linkedException;
61
62
63 /**
64 * Construct a TypeConstraintException with the specified detail message. The
65 * errorCode and linkedException will default to null.
66 *
67 * @param message a description of the exception
68 */
69 public TypeConstraintException(String message) {
70 this( message, null, null );
71 }
72
73 /**
74 * Construct a TypeConstraintException with the specified detail message and vendor
75 * specific errorCode. The linkedException will default to null.
76 *
77 * @param message a description of the exception
78 * @param errorCode a string specifying the vendor specific error code
79 */
80 public TypeConstraintException(String message, String errorCode) {
124 public String getErrorCode() {
125 return this.errorCode;
126 }
127
128 /**
129 * Get the linked exception
130 *
131 * @return the linked Exception, null if none exists
132 */
133 public Throwable getLinkedException() {
134 return linkedException;
135 }
136
137 /**
138 * Add a linked Exception.
139 *
140 * @param exception the linked Exception (A null value is permitted and
141 * indicates that the linked exception does not exist or
142 * is unknown).
143 */
144 public void setLinkedException( Throwable exception ) {
145 this.linkedException = exception;
146 }
147
148 /**
149 * Returns a short description of this TypeConstraintException.
150 *
151 */
152 public String toString() {
153 return linkedException == null ?
154 super.toString() :
155 super.toString() + "\n - with linked exception:\n[" +
156 linkedException.toString()+ "]";
157 }
158
159 /**
160 * Prints this TypeConstraintException and its stack trace (including the stack trace
161 * of the linkedException if it is non-null) to the PrintStream.
162 *
163 * @param s PrintStream to use for output
164 */
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
40 * the property is guaranteed to remain unchanged, as if the setter were never
41 * called.
42 *
43 * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
44 * @see ValidationEvent
45 * @since JAXB1.0
46 */
47
48 public class TypeConstraintException extends java.lang.RuntimeException {
49
50 /**
51 * Vendor specific error code
52 *
53 */
54 private String errorCode;
55
56 /**
57 * Exception reference
58 *
59 */
60 private Throwable linkedException;
61
62
63 /**
64 * Construct a TypeConstraintException with the specified detail message. The
65 * errorCode and linkedException will default to null.
66 *
67 * @param message a description of the exception
68 */
69 public TypeConstraintException(String message) {
70 this( message, null, null );
71 }
72
73 /**
74 * Construct a TypeConstraintException with the specified detail message and vendor
75 * specific errorCode. The linkedException will default to null.
76 *
77 * @param message a description of the exception
78 * @param errorCode a string specifying the vendor specific error code
79 */
80 public TypeConstraintException(String message, String errorCode) {
124 public String getErrorCode() {
125 return this.errorCode;
126 }
127
128 /**
129 * Get the linked exception
130 *
131 * @return the linked Exception, null if none exists
132 */
133 public Throwable getLinkedException() {
134 return linkedException;
135 }
136
137 /**
138 * Add a linked Exception.
139 *
140 * @param exception the linked Exception (A null value is permitted and
141 * indicates that the linked exception does not exist or
142 * is unknown).
143 */
144 public synchronized void setLinkedException( Throwable exception ) {
145 this.linkedException = exception;
146 }
147
148 /**
149 * Returns a short description of this TypeConstraintException.
150 *
151 */
152 public String toString() {
153 return linkedException == null ?
154 super.toString() :
155 super.toString() + "\n - with linked exception:\n[" +
156 linkedException.toString()+ "]";
157 }
158
159 /**
160 * Prints this TypeConstraintException and its stack trace (including the stack trace
161 * of the linkedException if it is non-null) to the PrintStream.
162 *
163 * @param s PrintStream to use for output
164 */
|