1 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 ; 22 23 30 public class PrintUnits { 31 private static final String _cm = "cm"; 32 private static final String _in = "in"; 33 private static final String _mm = "mm"; 34 private static final String _points = "points"; 35 public static final int PRINT_UNITS_CM = 0; 36 public static final int PRINT_UNITS_IN = 1; 37 public static final int PRINT_UNITS_MM = 2; 38 public static final int PRINT_UNITS_POINTS = 3; 39 private static final NumericResult _null_result = 40 new NumericResult(new IOException ("print units cannot be null")); 41 private static final NumericResult _cm_result = 42 new NumericResult(new Integer (PRINT_UNITS_CM)); 43 private static final NumericResult _in_result = 44 new NumericResult(new Integer (PRINT_UNITS_IN)); 45 private static final NumericResult _mm_result = 46 new NumericResult(new Integer (PRINT_UNITS_MM)); 47 private static final NumericResult _points_result = 48 new NumericResult(new Integer (PRINT_UNITS_POINTS)); 49 50 private PrintUnits() {} 51 52 58 public static NumericResult extractPrintUnits(final String value) { 59 NumericResult rval = null; 60 String input = (value == null) ? null : value.trim(); 61 62 if (input == null) { 63 rval = _null_result; 64 } else if (input.equalsIgnoreCase(_cm)) { 65 rval = _cm_result; 66 } else if (input.equalsIgnoreCase(_in)) { 67 rval = _in_result; 68 } else if (input.equalsIgnoreCase(_mm)) { 69 rval = _mm_result; 70 } else if (input.equalsIgnoreCase(_points)) { 71 rval = _points_result; 72 } else { 73 rval = new NumericResult(new IOException ( 74 "\"" + input + "\" is not a valid print unit")); 75 } 76 return rval; 77 } 78 } | Popular Tags |