/** * Report problems using console output. This clears the problem list after they've been reported, to avoid multiple * reports of the same problems. * * @param vctx * @return <code>true</code> if one or more errors, <code>false</code> if not */ private static boolean reportProblems(ValidationContext vctx) { ArrayList probs = vctx.getProblems(); boolean error = false; if (probs.size() > 0) { for (int j = 0; j < probs.size(); j++) { ValidationProblem prob = (ValidationProblem)probs.get(j); String text; if (prob.getSeverity() >= ValidationProblem.ERROR_LEVEL) { error = true; text = "Error: " + prob.getDescription(); s_logger.error(text); } else { text = "Warning: " + prob.getDescription(); s_logger.info(text); } System.out.println(text); } } probs.clear(); return error; }
/** * Load the customizations file. This method must load the specified customizations file, or create a default * customizations instance, of the appropriate type. * * @param path customization file path * @return <code>true</code> if successful, <code>false</code> if an error * @throws JiBXException JiBX error * @throws IOException I/O error */ protected boolean loadCustomizations(String path) throws JiBXException, IOException { // load customizations and check for errors String[] spaths = (String[])m_sourcePaths.toArray(new String[m_sourcePaths.size()]); ValidationContext vctx = new ValidationContext(); loadCustomizations(path, new ClassSourceLocator(spaths), vctx); ArrayList probs = vctx.getProblems(); if (probs.size() > 0) { for (int i = 0; i < probs.size(); i++) { ValidationProblem prob = (ValidationProblem)probs.get(i); System.out.print(prob.getSeverity() >= ValidationProblem.ERROR_LEVEL ? "Error: " : "Warning: "); System.out.println(prob.getDescription()); } if (vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) { return false; } } return true; }
org.jibx.schema.validation.ValidationProblem prob = (org.jibx.schema.validation.ValidationProblem)probs.get(j); System.out.print(prob.getSeverity() >= org.jibx.schema.validation.ValidationProblem.ERROR_LEVEL ? "Error: " : "Warning: "); System.out.println(prob.getDescription());
for (int i = 0; i < probs.size(); i++) { ValidationProblem prob = (ValidationProblem)probs.get(i); System.out.print(prob.getSeverity() >= ValidationProblem.ERROR_LEVEL ? "Error: " : "Warning: "); System.out.println(prob.getDescription());