/** * Method called to report an error, when caller's signature only * allows runtime exceptions to be thrown. */ protected void throwLazyError(Exception e) { if (e instanceof XMLStreamException) { WstxLazyException.throwLazily((XMLStreamException) e); } ExceptionUtil.throwRuntimeException(e); }
protected ElementIdMap getIdMap() { /* should never be called; for now let's throw an exception, if it * turns out it does get called can/should return an empty immutable * map or something */ ExceptionUtil.throwGenericInternal(); return null; // never gets here }
public static void throwAsIllegalArgument(Throwable t) { // Unchecked? Can re-throw as is throwIfUnchecked(t); // Otherwise, let's just change its type: IllegalArgumentException rex = new IllegalArgumentException("[was "+t.getClass()+"] "+t.getMessage()); // And indicate the root cause setInitCause(rex, t); throw rex; }
/** * This method is just added for convenience, and only to be used for * assertion style of exceptions. For errors that actually occur, method * with the string arg should be called instead. */ public static void throwGenericInternal() { throwInternal(null); }
/** * Method that can be used to convert any Throwable to a RuntimeException; * conversion is only done for checked exceptions. */ public static void throwRuntimeException(Throwable t) { // Unchecked? Can re-throw as is throwIfUnchecked(t); // Otherwise, let's just change its type: throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
public WstxException(String msg, Location loc, Throwable th) { super(msg, loc, th); mMsg = msg; // 13-Aug-2004, TSa: Better make sure root cause is set... ExceptionUtil.setInitCause(this, th); }
/** * Helper method that tries to fully convert strange URL-specific exception * to more general IO exception. Also, to try to use JDK 1.4 feature without * creating requirement, uses reflection to try to set the root cause, if * we are running on JDK1.4 */ private static void throwIOException(Exception mex, String sysId) throws IOException { String msg = "[resolving systemId '"+sysId+"']: "+mex.toString(); throw ExceptionUtil.constructIOException(msg, mex); } }
private void verifyUndefined() { if (mAllowedContent != XMLValidator.CONTENT_ALLOW_UNDEFINED) { // sanity check ExceptionUtil.throwInternal("redefining defined element spec"); } }
/** * Method that can be used to convert any Throwable to a RuntimeException; * conversion is only done for checked exceptions. */ public static void throwRuntimeException(Throwable t) { // Unchecked? Can re-throw as is throwIfUnchecked(t); // Otherwise, let's just change its type: throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
public WstxLazyException(XMLStreamException origEx) { super(origEx.getMessage()); mOrig = origEx; // Let's additionally to set source message ExceptionUtil.setInitCause(this, origEx); }
/** * Helper method that tries to fully convert strange URL-specific exception * to more general IO exception. Also, to try to use JDK 1.4 feature without * creating requirement, uses reflection to try to set the root cause, if * we are running on JDK1.4 */ private static void throwIOException(Exception mex, String sysId) throws IOException { String msg = "[resolving systemId '"+sysId+"']: "+mex.toString(); throw ExceptionUtil.constructIOException(msg, mex); } }
/** * Method called on placeholder element, to create a real instance that * has all attribute definitions placeholder had (it'll always have at * least one -- otherwise no placeholder was needed). */ public DTDElement define(Location loc, StructValidator val, int allowedContent) { verifyUndefined(); if (allowedContent == XMLValidator.CONTENT_ALLOW_UNDEFINED) { // sanity check ExceptionUtil.throwInternal("trying to use CONTENT_ALLOW_UNDEFINED via define()"); } DTDElement elem = new DTDElement(loc, mName, val, allowedContent, mNsAware, mXml11); // Ok, need to copy state collected so far: elem.mAttrMap = mAttrMap; elem.mSpecAttrList = mSpecAttrList; elem.mAnyFixed = mAnyFixed; elem.mValidateAttrs = mValidateAttrs; elem.mAnyDefaults = mAnyDefaults; elem.mIdAttr = mIdAttr; elem.mNotationAttr = mNotationAttr; elem.mNsDefaults = mNsDefaults; return elem; }
public String fullyValid() { switch (mArity) { case '*': case '?': return null; case '+': // need at least one (and multiples checked earlier) case ' ': if (mCount > 0) { return null; } return "Expected "+(mArity == '+' ? "at least" : "") +" one of elements ("+mNames+")"; } // should never happen: ExceptionUtil.throwGenericInternal(); return null; } }
protected void throwFromSex(XMLStreamException sex) { /* Not sure what the best unchecked exception type is (esp. since some * of more logical types have no constructor that takes root cause), * but hopefully this will do */ ExceptionUtil.throwRuntimeException(sex); }
/** * Method that can be used to convert any Throwable to a RuntimeException; * conversion is only done for checked exceptions. */ public static void throwRuntimeException(Throwable t) { // Unchecked? Can re-throw as is throwIfUnchecked(t); // Otherwise, let's just change its type: RuntimeException rex = new RuntimeException("[was "+t.getClass()+"] "+t.getMessage()); // And indicate the root cause setInitCause(rex, t); throw rex; }
/** * Method that can be used to convert any Throwable to a RuntimeException; * conversion is only done for checked exceptions. */ public static void throwRuntimeException(Throwable t) { // Unchecked? Can re-throw as is throwIfUnchecked(t); // Otherwise, let's just change its type: throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
public WstxException(Throwable th) { super(th.getMessage(), th); mMsg = th.getMessage(); // 13-Aug-2004, TSa: Better make sure root cause is set... ExceptionUtil.setInitCause(this, th); }
/** * Helper method that tries to fully convert strange URL-specific exception * to more general IO exception. Also, to try to use JDK 1.4 feature without * creating requirement, uses reflection to try to set the root cause, if * we are running on JDK1.4 */ private static void throwIOException(Exception mex, String sysId) throws IOException { String msg = "[resolving systemId '"+sysId+"']: "+mex.toString(); throw ExceptionUtil.constructIOException(msg, mex); } }
/** * Method called to create an actual element definition, matching * an ELEMENT directive in a DTD subset. */ public static DTDElement createDefined(ReaderConfig cfg, Location loc, PrefixedName name, StructValidator val, int allowedContent) { if (allowedContent == XMLValidator.CONTENT_ALLOW_UNDEFINED) { // sanity check ExceptionUtil.throwInternal("trying to use XMLValidator.CONTENT_ALLOW_UNDEFINED via createDefined()"); } return new DTDElement(loc, name, val, allowedContent, cfg.willSupportNamespaces(), cfg.isXml11()); }
protected ElementIdMap getIdMap() { /* should never be called; for now let's throw an exception, if it * turns out it does get called can/should return an empty immutable * map or something */ ExceptionUtil.throwGenericInternal(); return null; // never gets here }