1 16 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; 17 18 import org.apache.cocoon.components.elementprocessor.types.NumericConverter; 19 import org.apache.cocoon.components.elementprocessor.types.NumericResult; 20 import org.apache.cocoon.components.elementprocessor.types.Validator; 21 22 import java.io.IOException ; 23 24 35 public class EPSheetObjectFilled extends BaseElementProcessor { 36 private String _object_bound; 37 private Offsets _object_offset; 38 private Anchors _object_anchor_type; 39 private NumericResult _direction; 40 private ColorCode _outline_color; 41 private ColorCode _fill_color; 42 private NumericResult _type; 43 private NumericResult _width; 44 private NumericResult _arrow_shape_a; 45 private NumericResult _arrow_shape_b; 46 private NumericResult _arrow_shape_c; 47 private boolean _arrow_shape_a_fetched; 48 private boolean _arrow_shape_b_fetched; 49 private boolean _arrow_shape_c_fetched; 50 private static final String _object_bound_attribute = "ObjectBound"; 51 private static final String _object_offset_attribute = "ObjectOffset"; 52 private static final String _object_anchor_type_attribute = 53 "ObjectAnchorType"; 54 private static final String _direction_attribute = "Direction"; 55 private static final String _outline_color_attribute = "OutlineColor"; 56 private static final String _fill_color_attribute = "FillColor"; 57 private static final String _type_attribute = "Type"; 58 private static final String _width_attribute = "Width"; 59 private static final String _arrow_shape_a_attribute = "ArrowShapeA"; 60 private static final String _arrow_shape_b_attribute = "ArrowShapeB"; 61 private static final String _arrow_shape_c_attribute = "ArrowShapeC"; 62 private static final Validator _direction_validator = new Validator() { 63 public IOException validate(final Number number) { 64 return Direction.isValid(number.intValue()) ? null 65 : new IOException ("\"" + number + "\" is not a legal value"); 66 } 67 }; 68 private static final Validator _object_fill_validator = new Validator() { 69 public IOException validate(final Number number) { 70 return ObjectFill.isValid(number.intValue()) ? null 71 : new IOException ("\"" + number + "\" is not a legal value"); 72 } 73 }; 74 75 78 public EPSheetObjectFilled() { 79 super(null); 80 _object_bound = null; 81 _object_offset = null; 82 _object_anchor_type = null; 83 _direction = null; 84 _outline_color = null; 85 _fill_color = null; 86 _type = null; 87 _width = null; 88 _arrow_shape_a = null; 89 _arrow_shape_b = null; 90 _arrow_shape_c = null; 91 _arrow_shape_a_fetched = false; 92 _arrow_shape_b_fetched = false; 93 _arrow_shape_c_fetched = false; 94 } 95 96 100 public String getObjectBound() throws IOException { 101 if (_object_bound == null) { 102 _object_bound = getValue(_object_bound_attribute); 103 if (_object_bound == null) { 104 throw new IOException ( 105 "missing " + _object_bound_attribute + " attribute"); 106 } 107 } 108 return _object_bound; 109 } 110 111 115 public Offsets getOffsets() throws IOException { 116 if (_object_offset == null) { 117 _object_offset = new Offsets(getValue(_object_offset_attribute)); 118 } 119 return _object_offset; 120 } 121 122 126 public Anchors getAnchors() throws IOException { 127 if (_object_anchor_type == null) { 128 _object_anchor_type = 129 new Anchors(getValue(_object_anchor_type_attribute)); 130 } 131 return _object_anchor_type; 132 } 133 134 138 public int getDirection() throws IOException { 139 if (_direction == null) { 140 _direction = NumericConverter.extractInteger( 141 getValue(_direction_attribute), _direction_validator); 142 } 143 return _direction.intValue(); 144 } 145 146 150 public ColorCode getOutlineColor() throws IOException { 151 if (_outline_color == null) { 152 _outline_color = new ColorCode(getValue(_outline_color_attribute)); 153 } 154 return _outline_color; 155 } 156 157 161 public ColorCode getFillColor() throws IOException { 162 if (_fill_color == null) { 163 _fill_color = new ColorCode(getValue(_fill_color_attribute)); 164 } 165 return _fill_color; 166 } 167 168 172 public int getType() throws IOException { 173 if (_type == null) { 174 _type = NumericConverter.extractInteger( 175 getValue(_type_attribute), _object_fill_validator); 176 } 177 return _type.intValue(); 178 } 179 180 184 public int getWidth() throws IOException { 185 if (_width == null) { 186 _width = NumericConverter.extractPositiveInteger( 187 getValue(_width_attribute)); 188 } 189 return _width.intValue(); 190 } 191 192 197 public double getArrowShapeA() throws IOException , NullPointerException { 198 if (!_arrow_shape_a_fetched) { 199 _arrow_shape_a_fetched = true; 200 String arrowShapeString = getValue(_arrow_shape_a_attribute); 201 if (arrowShapeString != null) { 202 _arrow_shape_a = 203 NumericConverter.extractDouble(arrowShapeString); 204 } else { 205 throw new NullPointerException ( 206 "attribute " + _arrow_shape_a_attribute + " is absent"); 207 } 208 } 209 return _arrow_shape_a.doubleValue(); 210 } 211 212 217 public double getArrowShapeB() throws IOException , NullPointerException { 218 if (!_arrow_shape_b_fetched) { 219 _arrow_shape_b_fetched = true; 220 String arrowShapeString = getValue(_arrow_shape_b_attribute); 221 if (arrowShapeString != null) { 222 _arrow_shape_b = 223 NumericConverter.extractDouble(arrowShapeString); 224 } else { 225 throw new NullPointerException ( 226 "attribute " + _arrow_shape_b_attribute + " is absent"); 227 } 228 } 229 return _arrow_shape_b.doubleValue(); 230 } 231 232 237 public double getArrowShapeC() throws IOException , NullPointerException { 238 if (!_arrow_shape_c_fetched) { 239 _arrow_shape_c_fetched = true; 240 String arrowShapeString = getValue(_arrow_shape_c_attribute); 241 if (arrowShapeString != null) { 242 _arrow_shape_c = 243 NumericConverter.extractDouble(arrowShapeString); 244 } else { 245 throw new NullPointerException ( 246 "attribute " + _arrow_shape_c_attribute + " is absent"); 247 } 248 } 249 return _arrow_shape_c.doubleValue(); 250 } 251 } | Popular Tags |