1 6 7 package com.hp.hpl.jena.rdf.model; 8 9 import com.hp.hpl.jena.shared.*; 10 11 19 public class RDFException extends JenaException { 20 21 protected int errorCode = 0; 22 protected int otherCode = 0; 23 protected Exception nestedException = null; 24 protected String message = null; 25 26 29 public static final int NOTRELATEDTOMODEL = 1; 30 32 public static final int INVALIDPROPERTYURI = 2; 33 35 public static final int UNSUPPORTEDOPERATION = 3; 36 38 public static final int OBJECTNOTRESOURCE = 4; 39 41 public static final int OBJECTNOTLITERAL = 5; 42 44 public static final int PROPERTYNOTFOUND = 6; 45 47 public static final int NOTANONRESOURCE = 7; 48 50 public static final int ITERATORCLOSED = 8; 51 53 public static final int INVALIDERRORCODE = 9; 54 57 public static final int NESTEDEXCEPTION = 10; 58 60 public static final int INVALIDBOOLEANFORMAT = 11; 61 63 public static final int LITERALNOTCHAR = 12; 64 66 public static final int ALTHASNODEFAULT = 13; 67 70 public static final int SELECTOREXCEPTION = 14; 71 73 public static final int OBJECTWRONGTYPE = 15; 74 76 public static final int NOSUCHELEMENT = 16; 77 79 public static final int ASSERTIONFAILURE = 17; 80 82 public static final int SEQINDEXBOUNDS = 18; 83 86 public static final int NORESOURCECONSTRUCTOR = 19; 87 88 90 public static final int NOREADERFORLANG = 20; 91 92 94 public static final int NOWRITERFORLANG = 21; 95 96 98 public static final int UNKNOWNPROPERTY = 22; 99 100 102 public static final int STATEMENTNOTPRESENT = 23; 103 104 106 public static final int SYNTAXERROR = 24; 107 108 protected static final int MAXERRORCODE = 24; 109 110 protected static final String [] errorMessage = 111 { "not used", 112 "Object is not related to a model", 113 "Invalid property URI", 114 "Unsupported operation", 115 "Object of statement is not a resource", 116 "Object of statement is not a literal", 117 "Subject does not have that property", 118 "Resource is not anonymous", 119 "Iterator has been closed", 120 "Invalid error code", 121 "Nested Exception", 122 "Literal is not a boolean", 123 "Literal is not a single character", 124 "Alt container has no default", 125 "Selector threw exception", 126 "Statement object does match requested type", 127 "Iterator does not have an element", 128 "Assertion failure", 129 "Sequence index out of range", 130 "Enhanced Resource lacks Resource constructor", 131 "No RDFReader is defined for that language", 132 "No RDFWriter is defined for that lanaguage", 133 "Property not known", 134 "Statement not present", 135 "Syntax errors in input stream" 136 }; 137 138 protected RDFException(){} 139 140 143 public RDFException(int errorCode) { 144 if (1<=errorCode && errorCode<=MAXERRORCODE) { 145 this.errorCode = errorCode; 146 } else { 147 this.errorCode = INVALIDERRORCODE; 148 this.otherCode = errorCode; 149 } 150 message = errorMessage[this.errorCode]; 151 } 152 153 156 157 public RDFException(Exception e) { 158 this.errorCode = NESTEDEXCEPTION; 159 this.message = errorMessage[this.errorCode]; 160 nestedException = e; 161 } 162 163 167 168 public RDFException(int errorCode, String message) { 169 this.errorCode = errorCode; 170 this.message = message; 171 } 172 173 public RDFException(String s) { 174 super(s); this.message = s; 175 } 176 177 178 181 public String toString() { 182 String m = getMessage(), name = this.getClass().getName(); 183 return m == null ? name : name + ": " + m; 184 } 185 186 public String getMessage() { 187 String result = Integer.toString(errorCode) + " " + this.message; 188 if (errorCode == INVALIDERRORCODE) { 189 result = result + " = " + Integer.toString(otherCode); 190 } else if (errorCode == NESTEDEXCEPTION 191 || errorCode == SELECTOREXCEPTION) { 192 result = this.message + " = " + nestedException.toString(); 193 } 194 return result; 195 } 196 197 public int getErrorCode() { 198 return errorCode; 199 } 200 201 205 public Throwable getCause() { 206 return nestedException ; } 208 public Exception getNestedException() { 209 210 return nestedException; 211 } 212 } 213 243 | Popular Tags |