1 /* Copyright 2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 package org.apache.xmlbeans;
17
18 /**
19 * An exception that is thrown if there is corruption or a version mismatch
20 * in a compiled schema type system.
21 */
22 public class SchemaTypeLoaderException extends XmlRuntimeException
23 {
24 private int _code;
25
26 /** Constructs an exception with the given message, filename, extension, and code */
27 public SchemaTypeLoaderException(String message, String name, String handle, int code)
28 {
29 super(message + " (" + name + "." + handle + ") - code " + code);
30 _code = code;
31 }
32
33 /** Constructs an exception with the given message, filename, extension, code, and cause */
34 public SchemaTypeLoaderException(String message, String name, String handle, int code, Exception cause)
35 {
36 super(message + " (" + name + "." + handle + ") - code " + code);
37 _code = code;
38 initCause(cause);
39 }
40
41 /** Returns the reason for the failure, given by one of the numeric constants in this class */
42 public int getCode()
43 {
44 return _code;
45 }
46
47 /* See {@link #getCode}. */
48 public static final int NO_RESOURCE = 0;
49 /* See {@link #getCode}. */
50 public static final int WRONG_MAGIC_COOKIE = 1;
51 /* See {@link #getCode}. */
52 public static final int WRONG_MAJOR_VERSION = 2;
53 /* See {@link #getCode}. */
54 public static final int WRONG_MINOR_VERSION = 3;
55 /* See {@link #getCode}. */
56 public static final int WRONG_FILE_TYPE = 4;
57 /* See {@link #getCode}. */
58 public static final int UNRECOGNIZED_INDEX_ENTRY = 5;
59 /* See {@link #getCode}. */
60 public static final int WRONG_PROPERTY_TYPE = 6;
61 /* See {@link #getCode}. */
62 public static final int MALFORMED_CONTENT_MODEL = 7;
63 /* See {@link #getCode}. */
64 public static final int WRONG_SIMPLE_VARIETY = 8;
65 /* See {@link #getCode}. */
66 public static final int IO_EXCEPTION = 9;
67 /* See {@link #getCode}. */
68 public static final int INT_TOO_LARGE = 10;
69 /* See {@link #getCode}. */
70 public static final int BAD_PARTICLE_TYPE = 11;
71 /* See {@link #getCode}. */
72 public static final int NOT_WRITEABLE = 12;
73 /* See {@link #getCode}. */
74 public static final int BAD_HANDLE = 13;
75 /* See {@link #getCode}. */
76 public static final int NESTED_EXCEPTION = 14;
77 }
78