KickJava   Java API By Example, From Geeks To Geeks.

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


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.Validator;
21
22 import java.io.IOException JavaDoc;
23
24 /**
25  * Style orientation is written as an integer, and each bit in the
26  * integer specifies a particular boolean attribute. This class deals
27  * with all that information in an easily digested form.
28  *
29  * @author Marc Johnson (marc_johnson27591@hotmail.com)
30  * @version CVS $Id: StyleOrientation.java 30932 2004-07-29 17:35:38Z vgritsenko $
31  */

32 public class StyleOrientation {
33     private int _alignment;
34     private static final int _horiz = 1;
35     private static final int _vert_horiz_text = 2;
36     private static final int _vert_vert_text = 4;
37     private static final int _vert_vert_text2 = 8;
38     private static final Validator _validator = new Validator() {
39         public IOException JavaDoc validate(final Number JavaDoc number) {
40             int value = number.intValue();
41
42             return (value >= 0 && value <= 15) ? null
43                 : new IOException JavaDoc("\"" + number + "\" is out of range");
44         }
45     };
46
47     /**
48      * Create a StyleOrientation object
49      * @param value the string containing the style orientation data
50      * @exception IOException if the data is malformed
51      */

52     public StyleOrientation(final String JavaDoc value) throws IOException JavaDoc {
53         _alignment =
54             NumericConverter.extractInteger(value, _validator).intValue();
55     }
56
57     /**
58      * @return true if horiz bit is set
59      */

60     public boolean isHoriz() {
61         return (_alignment & _horiz) == _horiz;
62     }
63
64     /**
65      * @return true if vert horiz text bit is set
66      */

67     public boolean isVertHorizText() {
68         return (_alignment & _vert_horiz_text) == _vert_horiz_text;
69     }
70
71     /**
72      * @return true if vert vert text bit is set
73      */

74     public boolean isVertVertText() {
75         return (_alignment & _vert_vert_text) == _vert_vert_text;
76     }
77
78     /**
79      * @return true if vert vert text2 bit is set
80      */

81     public boolean isVertVertText2() {
82         return (_alignment & _vert_vert_text2) == _vert_vert_text2;
83     }
84 } // end public class StyleOrientation
85
Popular Tags