1 28 29 package org.jibx.runtime; 30 31 38 39 public class ValidationException extends RecoverableException 40 { 41 44 45 private Object m_object; 46 47 52 53 public ValidationException(String msg) { 54 super(msg); 55 } 56 57 63 64 public ValidationException(String msg, Throwable root) { 65 super(msg, root); 66 } 67 68 74 75 public ValidationException(String msg, Object obj) { 76 super(addDescription(msg, obj)); 77 } 78 79 86 87 public ValidationException(String msg, Throwable root, Object obj) { 88 super(addDescription(msg, obj), root); 89 } 90 91 98 99 public ValidationException(String msg, Object obj, 100 IUnmarshallingContext ctx) { 101 super(addDescription(msg, obj)); 102 } 103 104 113 114 public static String describe(Object obj) { 115 if (obj instanceof ITrackSource) { 116 ITrackSource track = (ITrackSource)obj; 117 StringBuffer text = new StringBuffer (); 118 text.append("(line "); 119 text.append(track.jibx_getLineNumber()); 120 text.append(", col "); 121 text.append(track.jibx_getColumnNumber()); 122 if (track.jibx_getDocumentName() != null) { 123 text.append(", in "); 124 text.append(track.jibx_getDocumentName()); 125 } 126 text.append(')'); 127 return text.toString(); 128 } else { 129 return "(unknown source for object of type " + 130 obj.getClass().getName(); 131 } 132 } 133 134 143 144 public static String addDescription(String msg, Object obj) { 145 return msg + " (" + describe(obj) + ")"; 146 } 147 148 153 154 public String getMessage() { 155 return super.getMessage(); 156 } 157 } 158 | Popular Tags |