1 16 17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; 18 19 import org.apache.cocoon.components.elementprocessor.types.Attribute; 20 import org.apache.cocoon.components.elementprocessor.types.BooleanConverter; 21 import org.apache.cocoon.components.elementprocessor.types.BooleanResult; 22 import org.apache.cocoon.components.elementprocessor.types.NumericConverter; 23 import org.apache.cocoon.components.elementprocessor.types.NumericResult; 24 import org.apache.cocoon.components.elementprocessor.types.Validator; 25 26 import java.io.IOException ; 27 28 37 public class EPColInfo extends BaseElementProcessor { 38 39 private NumericResult _no; 41 42 private NumericResult _unit; 44 45 private NumericResult _margin_a; 47 48 private NumericResult _margin_b; 50 51 private BooleanResult _hard_size; 53 54 private BooleanResult _hidden; 56 57 private BooleanResult _collapsed; 59 60 private NumericResult _outline_level; 62 63 private NumericResult _count; 65 private static final String _no_attribute = "No"; 66 private static final String _unit_attribute = "Unit"; 67 private static final String _margin_a_attribute = "MarginA"; 68 private static final String _margin_b_attribute = "MarginB"; 69 private static final String _hard_size_attribute = "HardSize"; 70 private static final String _hidden_attribute = "Hidden"; 71 private static final String _collapsed_attribute = "Collapsed"; 72 private static final String _outline_level_attribute = "OutlineLevel"; 73 private static final String _count_attribute = "Count"; 74 private static final Validator _margin_validator = new Validator() { 75 public IOException validate(final Number number) { 76 int val = number.intValue(); 77 78 return (val >= 0 && val <= 7) ? null 79 : new IOException ("\"" + number + "\" is not a legal value"); 80 } 81 }; 82 83 private static final Attribute[] _implied_attributes = 84 { 85 new Attribute(_hard_size_attribute, "0"), 86 new Attribute(_hidden_attribute, "0"), 87 new Attribute(_collapsed_attribute, "0"), 88 new Attribute(_outline_level_attribute, "0"), 89 new Attribute(_count_attribute, "1") 90 }; 91 92 95 public EPColInfo() { 96 super(_implied_attributes); 97 _no = null; 98 _unit = null; 99 _margin_a = null; 100 _margin_b = null; 101 _hard_size = null; 102 _hidden = null; 103 _collapsed = null; 104 _outline_level = null; 105 _count = null; 106 } 107 108 112 public int getColumnNo() throws IOException { 113 if (_no == null) { 114 _no = NumericConverter.extractNonNegativeInteger( 115 getValue(_no_attribute)); 116 } 117 return _no.intValue(); 118 } 119 120 124 public double getPoints() throws IOException { 125 if (_unit == null) { 126 _unit = NumericConverter.extractDouble(getValue(_unit_attribute)); 127 } 128 return _unit.doubleValue(); 129 } 130 131 135 public int getTopMargin() throws IOException { 136 if (_margin_a == null) { 137 _margin_a = NumericConverter.extractInteger( 138 getValue(_margin_a_attribute), _margin_validator); 139 } 140 return _margin_a.intValue(); 141 } 142 143 147 public int getBottomMargin() throws IOException { 148 if (_margin_b == null) { 149 _margin_b = NumericConverter.extractInteger( 150 getValue(_margin_b_attribute), _margin_validator); 151 } 152 return _margin_b.intValue(); 153 } 154 155 159 public boolean getHardSize() throws IOException { 160 if (_hard_size == null) { 161 _hard_size = 162 BooleanConverter.extractBoolean(getValue(_hard_size_attribute)); 163 } 164 return _hard_size.booleanValue(); 165 } 166 167 171 public boolean getHidden() throws IOException { 172 if (_hidden == null) { 173 _hidden = 174 BooleanConverter.extractBoolean(getValue(_hidden_attribute)); 175 } 176 return _hidden.booleanValue(); 177 } 178 179 183 public boolean getCollapsed() throws IOException { 184 if (_collapsed == null) { 185 _collapsed = 186 BooleanConverter.extractBoolean(getValue(_collapsed_attribute)); 187 } 188 return _collapsed.booleanValue(); 189 } 190 191 195 public int getOutlineLevel() throws IOException { 196 if (_outline_level == null) { 197 _outline_level = 198 NumericConverter.extractInteger( 199 getValue(_outline_level_attribute)); 200 } 201 return _outline_level.intValue(); 202 } 203 204 208 public int getRLECount() throws IOException { 209 if (_count == null) { 210 _count = 211 NumericConverter.extractInteger(getValue(_count_attribute)); 212 } 213 return _count.intValue(); 214 } 215 216 220 public void endProcessing() throws IOException { 221 getSheet().setColumnWidth(getColumnNo(), getPoints()); 222 } 223 } | Popular Tags |