1 50 51 package org.apache.excalibur.configuration.validation; 52 53 import java.util.ArrayList ; 54 import java.util.List ; 55 56 60 public final class ValidationResult 61 { 62 private final List m_warnings = new ArrayList ( 16 ); 63 private final List m_errors = new ArrayList ( 16 ); 64 private boolean m_valid; 65 private boolean m_readOnly; 66 67 public void addWarning( final String warning ) 68 { 69 checkWriteable(); 70 71 m_warnings.add( warning ); 72 } 73 74 public void addError( final String error ) 75 { 76 checkWriteable(); 77 78 m_errors.add( error ); 79 } 80 81 public void setResult( final boolean valid ) 82 { 83 checkWriteable(); 84 85 m_valid = valid; 86 m_readOnly = true; 87 } 88 89 public List getWarnings() 90 { 91 return m_warnings; 92 } 93 94 public List getErrors() 95 { 96 return m_errors; 97 } 98 99 public boolean isValid() 100 { 101 return m_valid; 102 } 103 104 protected final void checkWriteable() 105 throws IllegalStateException 106 { 107 if( m_readOnly ) 108 { 109 throw new IllegalStateException ( "ValidationResult is read only " 110 + "and can not be modified" ); 111 } 112 } 113 } 114 | Popular Tags |