1 16 17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; 18 19 import org.apache.cocoon.components.elementprocessor.types.NumericConverter; 20 21 import java.io.IOException ; 22 23 37 public class Offsets { 38 private static final int _component_count = 4; 39 private double[] _components = new double[_component_count]; 40 41 46 public Offsets(final String value) throws IOException { 47 if (value == null) { 48 throw new IOException ("cannot process a null offsets string"); 49 } 50 char[] input = value.trim().toCharArray(); 51 int index = 0; 52 53 for (int j = 0; j < _component_count; j++) { 54 while (index < input.length 55 && Character.isWhitespace(input[index])) { 56 ++index; 57 } 58 if (index == input.length) { 59 throw new IOException ("insufficient offsets in string"); 60 } 61 int tailIndex = index; 62 63 while (tailIndex < input.length 64 && !Character.isWhitespace(input[tailIndex])) { 65 ++tailIndex; 66 } 67 _components[j] = NumericConverter 68 .extractDouble(new String (input, index, tailIndex - index)) 69 .doubleValue(); 70 index = tailIndex; 71 } 72 if (new String (input, index, input.length - index).trim().length() 73 != 0) { 74 throw new IOException ( 75 "Too much data in string for " + _component_count + " offsets"); 76 } 77 } 78 79 82 public double[] getComponents() { 83 return _components; 84 } 85 } | Popular Tags |