public static String formatErrorCodeName(ErrorCode errorCode) { String packageName = errorCode.getErrorGroup().getPackage().getName(); String errorCodeName = errorCode.getName(); return CorePackageDefinitions.CORE_PACKAGE_NAME.equals(packageName) ? errorCodeName : packageName + "/" + errorCodeName; }
public void addErrorCode(ErrorCode errorCode) { ConstraintUtilities.ensureNotNull(errorCode, "errorCode"); ErrorGroup errorGroup = errorCode.getErrorGroup(); ConstraintUtilities.ensureNotNull(errorGroup, "errorCode.errorGroup"); List<ErrorCode> errorCodesForGroup = errorGroupMap.get(errorGroup); if (errorCodesForGroup==null) { errorCodesForGroup = Collections.synchronizedList(new ArrayList<ErrorCode>()); errorGroupList.add(errorGroup); errorGroupMap.put(errorGroup, errorCodesForGroup); } errorCodesForGroup.add(errorCode); }
public void addErrorCode(ErrorCode errorCode) { ConstraintUtilities.ensureNotNull(errorCode, "errorCode"); ErrorGroup errorGroup = errorCode.getErrorGroup(); ConstraintUtilities.ensureNotNull(errorGroup, "errorCode.errorGroup"); List<ErrorCode> errorCodesForGroup = errorGroupMap.get(errorGroup); if (errorCodesForGroup==null) { errorCodesForGroup = new ArrayList<ErrorCode>(); errorGroupMap.put(errorGroup, errorCodesForGroup); } errorCodesForGroup.add(errorCode); }
public static String formatErrorCodeName(ErrorCode errorCode) { String packageName = errorCode.getErrorGroup().getPackage().getName(); String errorCodeName = errorCode.getName(); return CorePackageDefinitions.CORE_PACKAGE_NAME.equals(packageName) ? errorCodeName : packageName + "/" + errorCodeName; }
public void addErrorCode(ErrorCode errorCode) { ConstraintUtilities.ensureNotNull(errorCode, "errorCode"); ErrorGroup errorGroup = errorCode.getErrorGroup(); ConstraintUtilities.ensureNotNull(errorGroup, "errorCode.errorGroup"); List<ErrorCode> errorCodesForGroup = errorGroupMap.get(errorGroup); if (errorCodesForGroup==null) { errorCodesForGroup = new ArrayList<ErrorCode>(); errorGroupMap.put(errorGroup, errorCodesForGroup); } errorCodesForGroup.add(errorCode); }
public static String formatErrorCodeName(ErrorCode errorCode) { String packageName = errorCode.getErrorGroup().getPackage().getName(); String errorCodeName = errorCode.getName(); return CorePackageDefinitions.CORE_PACKAGE_NAME.equals(packageName) ? errorCodeName : packageName + "/" + errorCodeName; }
/** Constructs an error message for the given {@link ErrorCode} and arguments. */ public static String getErrorMessage(ErrorCode errorCode, Object... arguments) { ResourceBundle errorMessageBundle = errorCode.getErrorGroup().getPackage().getErrorMessageBundle(); String result; if (errorMessageBundle!=null) { /* Use ResourceBundle specified to format error */ result = MessageFormat.format(errorMessageBundle.getString(errorCode.toString()), arguments); } else { /* No ResourceBundle specified, so do as best as we can */ result = "Error " + formatErrorCodeName(errorCode) + ": " + Arrays.toString(arguments); } return result; }
/** * Creates a DOM {@link Element} containing information about the given error, including * either just the {@link ErrorCode} or full details. * * @param ownerDocument {@link Document} that will contain the resulting element. * @param error {@link InputError} to format * @param fullDetails false if you just want the error code, true for full details. */ public static Element formatErrorAsXML(Document ownerDocument, InputError error, boolean fullDetails) { Element result = ownerDocument.createElementNS(SnuggleConstants.SNUGGLETEX_NAMESPACE, "error"); result.setAttribute("code", error.getErrorCode().getName()); result.setAttribute("package", error.getErrorCode().getErrorGroup().getPackage().getName()); if (fullDetails) { /* Nicely format XML error content */ StringBuffer messageBuilder = new StringBuffer(getErrorMessage(error)); FrozenSlice errorSlice = error.getSlice(); if (errorSlice!=null) { appendSliceContext(messageBuilder, errorSlice); } /* Add message as child node */ result.appendChild(ownerDocument.createTextNode(messageBuilder.toString())); } /* That's it! */ return result; }
/** Constructs an error message for the given {@link ErrorCode} and arguments. */ public static String getErrorMessage(ErrorCode errorCode, Object... arguments) { ResourceBundle errorMessageBundle = errorCode.getErrorGroup().getPackage().getErrorMessageBundle(); String result; if (errorMessageBundle!=null) { /* Use ResourceBundle specified to format error */ result = MessageFormat.format(errorMessageBundle.getString(errorCode.toString()), arguments); } else { /* No ResourceBundle specified, so do as best as we can */ result = "Error " + formatErrorCodeName(errorCode) + ": " + Arrays.toString(arguments); } return result; }
/** * Creates a DOM {@link Element} containing information about the given error, including * either just the {@link ErrorCode} or full details. * * @param ownerDocument {@link Document} that will contain the resulting element. * @param error {@link InputError} to format * @param fullDetails false if you just want the error code, true for full details. */ public static Element formatErrorAsXML(Document ownerDocument, InputError error, boolean fullDetails) { Element result = ownerDocument.createElementNS(SnuggleConstants.SNUGGLETEX_NAMESPACE, "error"); result.setAttribute("code", error.getErrorCode().getName()); result.setAttribute("package", error.getErrorCode().getErrorGroup().getPackage().getName()); if (fullDetails) { /* Nicely format XML error content */ StringBuffer messageBuilder = new StringBuffer(getErrorMessage(error)); FrozenSlice errorSlice = error.getSlice(); if (errorSlice!=null) { appendSliceContext(messageBuilder, errorSlice); } /* Add message as child node */ result.appendChild(ownerDocument.createTextNode(messageBuilder.toString())); } /* That's it! */ return result; }
/** Constructs an error message for the given {@link ErrorCode} and arguments. */ public static String getErrorMessage(ErrorCode errorCode, Object... arguments) { ResourceBundle errorMessageBundle = errorCode.getErrorGroup().getPackage().getErrorMessageBundle(); String result; if (errorMessageBundle!=null) { /* Use ResourceBundle specified to format error */ result = MessageFormat.format(errorMessageBundle.getString(errorCode.toString()), arguments); } else { /* No ResourceBundle specified, so do as best as we can */ result = "Error " + formatErrorCodeName(errorCode) + ": " + Arrays.toString(arguments); } return result; }
result.setAttribute("code", error.getErrorCode().getName()); result.setAttribute("package", error.getErrorCode().getErrorGroup().getPackage().getName());