|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ValidationResult.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* Copyright (C) The Spice Group. All rights reserved.
|
|
| 3 |
*
|
|
| 4 |
* This software is published under the terms of the Spice
|
|
| 5 |
* Software License version 1.1, a copy of which has been included
|
|
| 6 |
* with this distribution in the LICENSE.txt file.
|
|
| 7 |
*/
|
|
| 8 |
package org.codehaus.spice.configkit;
|
|
| 9 |
|
|
| 10 |
/**
|
|
| 11 |
* Result of validating a document against a schema. The result indicates
|
|
| 12 |
* whether validation was successful, any exception throws by validator and any
|
|
| 13 |
* {@link ValidationIssue}s that were reported.
|
|
| 14 |
*
|
|
| 15 |
* @author Peter Donald
|
|
| 16 |
* @author <a href="mailto:proyal at apache.org">Peter Royal</a>
|
|
| 17 |
* @version $Revision: 1.1 $ $Date: 2003/12/03 03:19:28 $
|
|
| 18 |
*/
|
|
| 19 |
public class ValidationResult |
|
| 20 |
{
|
|
| 21 |
/** Validation exception if validation not successful, else null. */
|
|
| 22 |
private final ValidateException m_exception;
|
|
| 23 |
|
|
| 24 |
/** The issues that were reported during validation. */
|
|
| 25 |
private final ValidationIssue[] m_issues;
|
|
| 26 |
|
|
| 27 |
/**
|
|
| 28 |
* Create a ValidationResult.
|
|
| 29 |
*
|
|
| 30 |
* @param exception the exception thrown if validation failed
|
|
| 31 |
* @param issues the issues that were reported during validation.
|
|
| 32 |
*/
|
|
| 33 | 120 |
public ValidationResult( final ValidateException exception,
|
| 34 |
final ValidationIssue[] issues ) |
|
| 35 |
{
|
|
| 36 | 120 |
if( null == issues ) |
| 37 |
{
|
|
| 38 | 1 |
throw new NullPointerException( "issues" ); |
| 39 |
} |
|
| 40 | 119 |
for( int i = 0; i < issues.length; i++ ) |
| 41 |
{
|
|
| 42 | 83 |
final ValidationIssue issue = issues[ i ]; |
| 43 | 83 |
if( null == issue ) |
| 44 |
{
|
|
| 45 | 1 |
throw new NullPointerException( "issues[" + i + "]" ); |
| 46 |
} |
|
| 47 |
} |
|
| 48 | 118 |
m_exception = exception; |
| 49 | 118 |
m_issues = issues; |
| 50 |
} |
|
| 51 |
|
|
| 52 |
/**
|
|
| 53 |
* Return true if validation successful. false otherwise.
|
|
| 54 |
*
|
|
| 55 |
* @return true if validation successful. false otherwise.
|
|
| 56 |
*/
|
|
| 57 | 118 |
public boolean isValid() |
| 58 |
{
|
|
| 59 | 118 |
return null == getException(); |
| 60 |
} |
|
| 61 |
|
|
| 62 |
/**
|
|
| 63 |
* Return the exception thrown if validation not successful.
|
|
| 64 |
*
|
|
| 65 |
* @return the exception thrown if validation not successful.
|
|
| 66 |
*/
|
|
| 67 | 118 |
public ValidateException getException()
|
| 68 |
{
|
|
| 69 | 118 |
return m_exception;
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/**
|
|
| 73 |
* Return the issues that were reported during validation.
|
|
| 74 |
*
|
|
| 75 |
* @return the issues that were reported during validation.
|
|
| 76 |
*/
|
|
| 77 | 118 |
public ValidationIssue[] getIssues()
|
| 78 |
{
|
|
| 79 | 118 |
return m_issues;
|
| 80 |
} |
|
| 81 |
} |
|
| 82 |
|
|
||||||||||