1 31 package org.pdfbox.cos; 32 33 import java.io.IOException ; 34 import java.io.OutputStream ; 35 36 import org.pdfbox.exceptions.COSVisitorException; 37 38 44 public class COSBoolean extends COSBase 45 { 46 49 public static final byte[] TRUE_BYTES = new byte[]{ 116, 114, 117, 101 }; 53 public static final byte[] FALSE_BYTES = new byte[]{ 102, 97, 108, 115, 101 }; 55 58 public static final COSBoolean TRUE = new COSBoolean( true ); 59 60 63 public static final COSBoolean FALSE = new COSBoolean( false ); 64 65 private boolean value; 66 67 72 private COSBoolean(boolean aValue ) 73 { 74 value = aValue; 75 } 76 77 82 public boolean getValue() 83 { 84 return value; 85 } 86 87 92 public Boolean getValueAsObject() 93 { 94 return (value?Boolean.TRUE:Boolean.FALSE); 95 } 96 97 104 public static COSBoolean getBoolean( boolean value ) 105 { 106 return (value?TRUE:FALSE); 107 } 108 109 116 public static COSBoolean getBoolean( Boolean value ) 117 { 118 return getBoolean( value.booleanValue() ); 119 } 120 121 128 public Object accept(ICOSVisitor visitor) throws COSVisitorException 129 { 130 return visitor.visitFromBoolean(this); 131 } 132 133 138 public String toString() 139 { 140 return String.valueOf( value ); 141 } 142 143 150 public void writePDF( OutputStream output ) throws IOException 151 { 152 if( value ) 153 { 154 output.write( TRUE_BYTES ); 155 } 156 else 157 { 158 output.write( FALSE_BYTES ); 159 } 160 } 161 } | Popular Tags |