01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
19:
20: import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
21: import org.apache.cocoon.components.elementprocessor.types.NumericResult;
22: import org.apache.cocoon.components.elementprocessor.types.Validator;
23:
24: import java.io.IOException;
25:
26: /**
27: * No-op implementation of ElementProcessor to handle the
28: * "Rev-Diagonal" tag
29: *
30: * This element has two attributes and no content.
31: *
32: * This element is not used in HSSFSerializer 1.0
33: *
34: * @author Marc Johnson (marc_johnson27591@hotmail.com)
35: * @version CVS $Id: EPRev_Diagonal.java 433543 2006-08-22 06:22:54Z crossley $
36: */
37: public class EPRev_Diagonal extends BaseElementProcessor {
38: private NumericResult _style;
39: private boolean _color_fetched;
40: private ColorCode _color;
41: private static final String _style_attribute = "Style";
42: private static final String _color_attribute = "Color";
43: private static final Validator _style_validator = new Validator() {
44: public IOException validate(final Number number) {
45: return BorderStyle.isValid(number.intValue()) ? null
46: : new IOException("\"" + number
47: + "\" is not a legal value");
48: }
49: };
50:
51: /**
52: * constructor
53: */
54: public EPRev_Diagonal() {
55: super (null);
56: _style = null;
57: _color = null;
58: _color_fetched = false;
59: }
60:
61: /**
62: * @return style as an int from BorderStyle
63: * @exception IOException
64: */
65: public int getStyle() throws IOException {
66: if (_style == null) {
67: _style = NumericConverter.extractInteger(
68: getValue(_style_attribute), _style_validator);
69: }
70: return _style.intValue();
71: }
72:
73: /**
74: * @return color
75: * @exception IOException
76: */
77: public ColorCode getColor() throws IOException {
78: if (!_color_fetched) {
79: String colorString = getValue(_color_attribute);
80: if (colorString != null) {
81: _color = new ColorCode(colorString);
82: }
83: _color_fetched = true;
84: }
85: return _color;
86: }
87: } // end public class EPRev_Diagonal
|