1 19 package org.openharmonise.rm.resources.metadata.properties.ranges; 20 21 import org.openharmonise.rm.metadata.GeneralPropertyInstance; 22 import org.openharmonise.rm.publishing.Publishable; 23 import org.w3c.dom.Element ; 24 25 26 35 public abstract class NumberRange extends AbstractRange implements Range, Publishable { 36 37 public static final String TAG_MAX = "Max"; 38 public static final String TAG_MIN = "Min"; 39 public static final String ATTRIB_EXCLUSIVE = "exclusive"; 40 41 45 protected boolean m_bHasMax = false; 46 47 51 protected boolean m_bHasMin = false; 52 53 58 protected boolean m_bMinExclusive = false; 59 60 65 protected boolean m_bMaxExclusive = false; 66 67 71 public NumberRange() { 72 super(Number .class.getName()); 73 } 74 75 80 public NumberRange(String sObjClassName) { 81 super(sObjClassName); 82 } 83 84 91 public NumberRange(String sObjClassName, String sDetails) { 92 super(sObjClassName, sDetails); 93 } 94 95 98 public boolean isValid(Object obj) { 99 return (obj instanceof Number ); 100 } 101 102 107 public boolean hasMin() { 108 return m_bHasMin; 109 } 110 111 117 public void hasMin(boolean bHasMin) { 118 m_bHasMin = bHasMin; 119 } 120 121 126 public boolean hasMax() { 127 return m_bHasMax; 128 } 129 130 136 public void hasMax(boolean bHasMax) { 137 m_bHasMax = bHasMax; 138 } 139 140 141 146 public boolean isMinExclusive() { 147 return m_bMinExclusive; 148 } 149 150 155 public boolean isMaxExclusive() { 156 return m_bMaxExclusive; 157 } 158 159 162 public boolean equals(Object obj) { 163 boolean bResult = false; 164 165 if (obj instanceof NumberRange) { 166 if (super.equals(obj) == true) { 167 NumberRange nRange = (NumberRange) obj; 168 169 if (hasMin() == nRange.hasMin() 170 && hasMax() == nRange.hasMax()) { 171 bResult = true; 172 } 173 } 174 } 175 176 return bResult; 177 } 178 179 182 public Class getPropertyInstanceClass() throws ClassNotFoundException { 183 return GeneralPropertyInstance.class; 184 } 185 186 195 protected boolean isExclusive(Element el) { 196 boolean bExcl = false; 197 String sExcl = el.getAttribute(ATTRIB_EXCLUSIVE); 198 199 if(sExcl != null) { 200 bExcl = Boolean.getBoolean(sExcl); 201 } 202 203 return bExcl; 204 } 205 } 206 | Popular Tags |