1 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 ; 23 24 32 public class VerticalAlignment { 33 private int _alignment; 34 private static final int _top = 1; 35 private static final int _bottom = 2; 36 private static final int _center = 4; 37 private static final int _justify = 8; 38 private static final Validator _validator = new Validator() { 39 public IOException validate(final Number number) { 40 int value = number.intValue(); 41 42 return (value >= 0 && value <= 15) ? null 43 : new IOException ("\"" + number + "\" is out of range"); 44 } 45 }; 46 47 52 public VerticalAlignment(final String value) throws IOException { 53 _alignment = 54 NumericConverter.extractInteger(value, _validator).intValue(); 55 } 56 57 60 public boolean isTop() { 61 return (_alignment & _top) == _top; 62 } 63 64 67 public boolean isBottom() { 68 return (_alignment & _bottom) == _bottom; 69 } 70 71 74 public boolean isCenter() { 75 return (_alignment & _center) == _center; 76 } 77 78 81 public boolean isJustify() { 82 return (_alignment & _justify) == _justify; 83 } 84 85 public short getCode() { 86 return (short)_alignment; 87 } 88 } | Popular Tags |