1 56 57 package org.objectstyle.cayenne.validation; 58 59 66 public class SimpleValidationFailure implements ValidationFailure { 67 protected Object source; 68 protected Object error; 69 70 public SimpleValidationFailure(Object source, Object error) { 71 this.source = source; 72 this.error = error; 73 } 74 75 78 public String getDescription() { 79 return String.valueOf(error); 80 } 81 82 85 public Object getSource() { 86 return source; 87 } 88 89 public Object getError() { 90 return error; 91 } 92 93 96 public String toString() { 97 StringBuffer buffer = new StringBuffer (); 98 99 buffer.append("Validation failure for "); 100 Object source = getSource(); 101 102 if (source == null) { 103 buffer.append("[General]"); 104 } 105 else { 106 String sourceLabel = (source instanceof String ) ? source.toString() : source 107 .getClass() 108 .getName(); 109 buffer.append(sourceLabel); 110 } 111 buffer.append(": "); 112 buffer.append(getDescription()); 113 return buffer.toString(); 114 } 115 } 116 | Popular Tags |