1 51 package org.apache.fop.datatypes; 52 53 import org.apache.fop.fo.Property; 54 55 60 public class LengthRange implements CompoundDatatype { 61 62 private Property minimum; 63 private Property optimum; 64 private Property maximum; 65 private static final int MINSET = 1; 66 private static final int OPTSET = 2; 67 private static final int MAXSET = 4; 68 private int bfSet = 0; private boolean bChecked = false; 70 71 public void setComponent(String sCmpnName, Property cmpnValue, 73 boolean bIsDefault) { 74 if (sCmpnName.equals("minimum")) 75 setMinimum(cmpnValue, bIsDefault); 76 else if (sCmpnName.equals("optimum")) 77 setOptimum(cmpnValue, bIsDefault); 78 else if (sCmpnName.equals("maximum")) 79 setMaximum(cmpnValue, bIsDefault); 80 } 81 82 public Property getComponent(String sCmpnName) { 84 if (sCmpnName.equals("minimum")) 85 return getMinimum(); 86 else if (sCmpnName.equals("optimum")) 87 return getOptimum(); 88 else if (sCmpnName.equals("maximum")) 89 return getMaximum(); 90 else 91 return null; } 93 94 101 protected void setMinimum(Property minimum, boolean bIsDefault) { 102 this.minimum = minimum; 103 if (!bIsDefault) 104 bfSet |= MINSET; 105 } 106 107 108 114 protected void setMaximum(Property max, boolean bIsDefault) { 115 maximum = max; 116 if (!bIsDefault) 117 bfSet |= MAXSET; 118 } 119 120 121 127 protected void setOptimum(Property opt, boolean bIsDefault) { 128 optimum = opt; 129 if (!bIsDefault) 130 bfSet |= OPTSET; 131 } 132 133 private void checkConsistency() { 135 if (bChecked) 136 return; 137 140 186 bChecked = true; 187 } 188 189 public Property getMinimum() { 190 checkConsistency(); 191 return this.minimum; 192 } 193 194 public Property getMaximum() { 195 checkConsistency(); 196 return this.maximum; 197 } 198 199 public Property getOptimum() { 200 checkConsistency(); 201 return this.optimum; 202 } 203 204 } 205 | Popular Tags |