KickJava   Java API By Example, From Geeks To Geeks.

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


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
27  * "Rev-Diagonal" 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: EPRev_Diagonal.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class EPRev_Diagonal 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 EPRev_Diagonal() {
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 =
66                 NumericConverter.extractInteger(
67                     getValue(_style_attribute),
68                     _style_validator);
69         }
70         return _style.intValue();
71     }
72
73     /**
74      * @return color
75      * @exception IOException
76      */

77     public ColorCode getColor() throws IOException JavaDoc {
78         if (!_color_fetched) {
79             String JavaDoc 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
88
Popular Tags