| 1 19 package org.openharmonise.rm.resources.metadata.properties.ranges; 20 21 import java.text.*; 22 import java.util.StringTokenizer ; 23 24 import org.openharmonise.rm.metadata.GeneralPropertyInstance; 25 26 27 35 public class BooleanRange extends AbstractRange { 36 37 40 private static final String DEFAULT_TRUE_LABEL = "yes"; 41 42 45 private static final String DEFAULT_FALSE_LABEL = "no"; 46 47 50 private static final String SEPARATOR = "|"; 51 52 55 private String m_sTrueLabel = DEFAULT_TRUE_LABEL; 56 57 60 private String m_sFalseLabel = DEFAULT_FALSE_LABEL; 61 62 65 public final static String TAG_BOOLEAN_RANGE = "BooleanRange"; 66 67 70 public BooleanRange() { 71 super(Boolean .class.getName()); 72 } 73 74 75 78 public boolean isValid(Object obj) { 79 80 return obj instanceof Boolean ; 81 } 82 83 88 public String getTrueLabel() { 89 return m_sTrueLabel; 90 } 91 92 97 public String getFalseLabel() { 98 return m_sFalseLabel; 99 } 100 101 106 public void setTrueLabel(String sTrueLabel) { 107 if(sTrueLabel != null && m_sTrueLabel.equals(sTrueLabel) == false) { 108 isChanged(true); 109 m_sTrueLabel = sTrueLabel; 110 } 111 } 112 113 118 public void setFalseLabel(String sFalseLabel) { 119 if(sFalseLabel != null && m_sTrueLabel.equals(sFalseLabel) == false) { 120 isChanged(true); 121 m_sFalseLabel = sFalseLabel; 122 } 123 } 124 125 128 public boolean equals(Object obj) { 129 boolean bResult = false; 130 131 if (obj instanceof BooleanRange) { 132 bResult = super.equals(obj); 133 } 134 135 return bResult; 136 } 137 138 141 public Class getPropertyInstanceClass() throws ClassNotFoundException { 142 return GeneralPropertyInstance.class; 143 } 144 145 148 public String getTagName() { 149 return TAG_BOOLEAN_RANGE; 150 } 151 152 155 public String getDetails() { 156 157 if (isChanged()) { 158 StringBuffer strbuf = new StringBuffer (); 159 160 strbuf.append(m_sTrueLabel) 161 .append(SEPARATOR) 162 .append(m_sFalseLabel); 163 164 super.setDetails(strbuf.toString()); 165 } 166 167 return super.getDetails(); 168 } 169 170 173 public void setDetails(String sDetails) { 174 if (sDetails != null) { 175 StringTokenizer tokenizer = 176 new StringTokenizer (sDetails, SEPARATOR); 177 SimpleDateFormat formatter = null; 178 179 int i = 0; 180 int nTmp = 0; 181 while (tokenizer.hasMoreTokens()) { 182 String token = tokenizer.nextToken(); 183 184 if (token != null && token.length() > 0) { 185 186 if(i == 0) { 187 m_sTrueLabel = token; 188 } else { 189 m_sFalseLabel = token; 190 } 191 } 192 i++; 193 } 194 } 195 196 super.setDetails(sDetails); 197 } 198 } 199 | Popular Tags |