KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > impl > poi > hssf > elements > EPDiagonal


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
18
19 import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
20 import org.apache.cocoon.components.elementprocessor.types.NumericResult;
21 import org.apache.cocoon.components.elementprocessor.types.Validator;
22
23 import java.io.IOException JavaDoc;
24
25 /**
26  * No-op implementation of ElementProcessor to handle the "Diagonal"
27  * tag
28  *
29  * This element has two attributes and no content.
30  *
31  * This element is not used in HSSFSerializer 1.0
32  *
33  * @author Marc Johnson (marc_johnson27591@hotmail.com)
34  * @version CVS $Id: EPDiagonal.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class EPDiagonal extends BaseElementProcessor {
37     private NumericResult _style;
38     private boolean _color_fetched;
39     private ColorCode _color;
40     private static final String JavaDoc _style_attribute = "Style";
41     private static final String JavaDoc _color_attribute = "Color";
42     private static final Validator _style_validator = new Validator() {
43         public IOException JavaDoc validate(final Number JavaDoc number) {
44             return BorderStyle.isValid(number.intValue()) ? null
45                 : new IOException JavaDoc("\"" + number + "\" is not a legal value");
46         }
47     };
48
49     /**
50      * constructor
51      */

52     public EPDiagonal() {
53         super(null);
54         _style = null;
55         _color = null;
56         _color_fetched = false;
57     }
58
59     /**
60      * @return style as an int from BorderStyle
61      * @exception IOException
62      */

63     public int getStyle() throws IOException JavaDoc {
64         if (_style == null) {
65             _style = NumericConverter.extractInteger(
66                     getValue(_style_attribute), _style_validator);
67         }
68         return _style.intValue();
69     }
70
71     /**
72      * @return color
73      * @exception IOException
74      */

75     public ColorCode getColor() throws IOException JavaDoc {
76         if (!_color_fetched) {
77             String JavaDoc colorString = getValue(_color_attribute);
78             if (colorString != null) {
79                 _color = new ColorCode(colorString);
80             }
81             _color_fetched = true;
82         }
83         return _color;
84     }
85 } // end public class EPDiagonal
86
Popular Tags