1 5 package javax.xml.bind.helpers; 6 7 import java.text.MessageFormat ; 8 9 import javax.xml.bind.ValidationEvent; 10 import javax.xml.bind.ValidationEventLocator; 11 12 28 public class ValidationEventImpl implements ValidationEvent 29 { 30 31 41 public ValidationEventImpl( int _severity, String _message, 42 ValidationEventLocator _locator ) { 43 44 this(_severity,_message,_locator,null); 45 } 46 47 59 public ValidationEventImpl( int _severity, String _message, 60 ValidationEventLocator _locator, 61 Throwable _linkedException ) { 62 63 setSeverity( _severity ); 64 this.message = _message; 65 this.locator = _locator; 66 this.linkedException = _linkedException; 67 } 68 69 private int severity; 70 private String message; 71 private Throwable linkedException; 72 private ValidationEventLocator locator; 73 74 public int getSeverity() { 75 return severity; 76 } 77 78 79 86 public void setSeverity( int _severity ) { 87 88 if( _severity != ValidationEvent.WARNING && 89 _severity != ValidationEvent.ERROR && 90 _severity != ValidationEvent.FATAL_ERROR ) { 91 throw new IllegalArgumentException ( 92 Messages.format( Messages.ILLEGAL_SEVERITY ) ); 93 } 94 95 this.severity = _severity; 96 } 97 98 public String getMessage() { 99 return message; 100 } 101 106 public void setMessage( String _message ) { 107 this.message = _message; 108 } 109 110 public Throwable getLinkedException() { 111 return linkedException; 112 } 113 118 public void setLinkedException( Throwable _linkedException ) { 119 this.linkedException = _linkedException; 120 } 121 122 public ValidationEventLocator getLocator() { 123 return locator; 124 } 125 130 public void setLocator( ValidationEventLocator _locator ) { 131 this.locator = _locator; 132 } 133 134 140 public String toString() { 141 String s; 142 switch(getSeverity()) { 143 case WARNING: s="WARNING";break; 144 case ERROR: s="ERROR";break; 145 case FATAL_ERROR: s="FATAL_ERROR";break; 146 default: s=String.valueOf(getSeverity());break; 147 } 148 return MessageFormat.format("[severity={0},message={1},locator={2}]", 149 new Object []{ 150 s, 151 getMessage(), 152 getLocator() 153 }); 154 } 155 } 156 | Popular Tags |