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.NumericResult;
21:
22: import java.io.IOException;
23:
24: /**
25: * Print order -- encapsulation of the strings representing the print
26: * ordering, and a simpler way to deal with them.
27: *
28: * @author Marc Johnson (marc_johnson27591@hotmail.com)
29: * @version CVS $Id: PrintOrder.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: public class PrintOrder {
32: private static final String _right_then_down = "r_then_d";
33: private static final String _down_then_right = "d_then_r";
34: public static final int PRINT_ORDER_RIGHT_THEN_DOWN = 0;
35: public static final int PRINT_ORDER_DOWN_THEN_RIGHT = 1;
36: private static final NumericResult _null_result = new NumericResult(
37: new IOException("print order cannot be null"));
38: private static final NumericResult _right_then_down_result = new NumericResult(
39: new Integer(PRINT_ORDER_RIGHT_THEN_DOWN));
40: private static final NumericResult _down_then_right_result = new NumericResult(
41: new Integer(PRINT_ORDER_DOWN_THEN_RIGHT));
42:
43: private PrintOrder() {
44: }
45:
46: /**
47: * convert a string into a NumericResult
48: * @param value the string describing the print order
49: * @return a NumericResult containing either one of the public enumeration
50: * values, or an appropriate IOException
51: */
52: public static NumericResult extractPrintOrder(final String value) {
53: NumericResult rval = null;
54: String input = (value == null) ? null : value.trim();
55:
56: if (input == null) {
57: rval = _null_result;
58: } else if (input.equalsIgnoreCase(_right_then_down)) {
59: rval = _right_then_down_result;
60: } else if (input.equalsIgnoreCase(_down_then_right)) {
61: rval = _down_then_right_result;
62: } else {
63: rval = new NumericResult(new IOException("\"" + input
64: + "\" is not a valid print order"));
65: }
66: return rval;
67: }
68: } // end public class PrintOrder
|