1 19 20 21 package org.apache.cayenne.validation; 22 23 30 public class SimpleValidationFailure implements ValidationFailure { 31 protected Object source; 32 protected Object error; 33 34 public SimpleValidationFailure(Object source, Object error) { 35 this.source = source; 36 this.error = error; 37 } 38 39 42 public String getDescription() { 43 return String.valueOf(error); 44 } 45 46 49 public Object getSource() { 50 return source; 51 } 52 53 public Object getError() { 54 return error; 55 } 56 57 60 public String toString() { 61 StringBuffer buffer = new StringBuffer (); 62 63 buffer.append("Validation failure for "); 64 Object source = getSource(); 65 66 if (source == null) { 67 buffer.append("[General]"); 68 } 69 else { 70 String sourceLabel = (source instanceof String ) ? source.toString() : source 71 .getClass() 72 .getName(); 73 buffer.append(sourceLabel); 74 } 75 buffer.append(": "); 76 buffer.append(getDescription()); 77 return buffer.toString(); 78 } 79 } 80 | Popular Tags |