KickJava   Java API By Example, From Geeks To Geeks.

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


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.NumericResult;
20
21 import java.io.IOException JavaDoc;
22
23 /**
24  * Print order -- encapsulation of the strings representing the print
25  * ordering, and a simpler way to deal with them.
26  *
27  * @author Marc Johnson (marc_johnson27591@hotmail.com)
28  * @version CVS $Id: PrintOrder.java 30932 2004-07-29 17:35:38Z vgritsenko $
29  */

30 public class PrintOrder {
31     private static final String JavaDoc _right_then_down = "r_then_d";
32     private static final String JavaDoc _down_then_right = "d_then_r";
33     public static final int PRINT_ORDER_RIGHT_THEN_DOWN = 0;
34     public static final int PRINT_ORDER_DOWN_THEN_RIGHT = 1;
35     private static final NumericResult _null_result =
36         new NumericResult(new IOException JavaDoc("print order cannot be null"));
37     private static final NumericResult _right_then_down_result =
38         new NumericResult(new Integer JavaDoc(PRINT_ORDER_RIGHT_THEN_DOWN));
39     private static final NumericResult _down_then_right_result =
40         new NumericResult(new Integer JavaDoc(PRINT_ORDER_DOWN_THEN_RIGHT));
41
42     private PrintOrder() {}
43
44     /**
45      * convert a string into a NumericResult
46      * @param value the string describing the print order
47      * @return a NumericResult containing either one of the public enumeration
48      * values, or an appropriate IOException
49      */

50     public static NumericResult extractPrintOrder(final String JavaDoc value) {
51         NumericResult rval = null;
52         String JavaDoc input = (value == null) ? null : value.trim();
53
54         if (input == null) {
55             rval = _null_result;
56         } else if (input.equalsIgnoreCase(_right_then_down)) {
57             rval = _right_then_down_result;
58         } else if (input.equalsIgnoreCase(_down_then_right)) {
59             rval = _down_then_right_result;
60         } else {
61             rval = new NumericResult(new IOException JavaDoc(
62                     "\"" + input + "\" is not a valid print order"));
63         }
64         return rval;
65     }
66 } // end public class PrintOrder
67
Popular Tags