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 HorizontalAlignment { 33 private int _alignment; 34 private static final int _general = 1; 35 private static final int _left = 2; 36 private static final int _right = 4; 37 private static final int _center = 8; 38 private static final int _fill = 16; 39 private static final int _justify = 32; 40 private static final int _center_across_selection = 64; 41 private static final Validator _validator = new Validator() { 42 public IOException validate(final Number number) { 43 int value = number.intValue(); 44 45 return ((value >= 0) && (value <= 127)) ? null 46 : new IOException ("\"" + number + "\" is out of range"); 47 } 48 }; 49 50 55 public HorizontalAlignment(final String value) throws IOException { 56 _alignment = 57 NumericConverter.extractInteger(value, _validator).intValue(); 58 } 59 60 63 public boolean isGeneral() { 64 return (_alignment & _general) == _general; 65 } 66 67 70 public boolean isLeft() { 71 return (_alignment & _left) == _left; 72 } 73 74 77 public boolean isRight() { 78 return (_alignment & _right) == _right; 79 } 80 81 84 public boolean isCenter() { 85 return (_alignment & _center) == _center; 86 } 87 88 91 public boolean isFill() { 92 return (_alignment & _fill) == _fill; 93 } 94 95 98 public boolean isJustify() { 99 return (_alignment & _justify) == _justify; 100 } 101 102 105 public boolean isCenterAcrossSelection() { 106 return (_alignment & _center_across_selection) 107 == _center_across_selection; 108 } 109 110 short getCode() { 111 return (short)_alignment; 112 } 113 } | Popular Tags |