1 10 11 package com.triactive.jdo.test; 12 13 14 public class StringWidget extends Widget 15 { 16 private String fixedLengthString; 17 private String normalString; 18 private String hugeString; 19 20 21 public StringWidget() 22 { 23 super(); 24 } 25 26 27 public String getFixedLengthString() 28 { 29 return fixedLengthString; 30 } 31 32 33 public String getNormalString() 34 { 35 return normalString; 36 } 37 38 39 public String getHugeString() 40 { 41 return hugeString; 42 } 43 44 45 public void setNormalString(String normalString) 46 { 47 this.normalString = normalString; 48 } 49 50 51 56 57 public void fillRandom() 58 { 59 super.fillRandom(); 60 61 fixedLengthString = nextNull() ? null : nextString(20); 62 normalString = nextNull() ? null : nextString(r.nextInt(21)); 63 hugeString = nextNull() ? null : nextString(r.nextInt(101)); 64 } 65 66 67 78 79 public boolean compareTo(Object obj) 80 { 81 if (obj == this) 82 return true; 83 84 if (!(obj instanceof StringWidget) || !super.compareTo(obj)) 85 return false; 86 87 StringWidget w = (StringWidget)obj; 88 89 if (fixedLengthString == null) { if (w.fixedLengthString != null) return false; } 90 else if (!fixedLengthString.equals(w.fixedLengthString)) return false; 91 92 if (normalString == null) { if (w.normalString != null) return false; } 93 else if (!normalString.equals(w.normalString)) return false; 94 95 if (hugeString == null) { if (w.hugeString != null) return false; } 96 else if (!hugeString.equals(w.hugeString)) return false; 97 98 return true; 99 } 100 101 102 108 109 public String toString() 110 { 111 StringBuffer s = new StringBuffer (super.toString()); 112 113 s.append(" fixedLengthString = ").append(fixedLengthString); 114 s.append('\n'); 115 s.append(" normalString = ").append(normalString); 116 s.append('\n'); 117 s.append(" hugeString = ").append(hugeString); 118 s.append('\n'); 119 120 return s.toString(); 121 } 122 } 123 | Popular Tags |