1 4 5 package com.etymon.pjx; 6 7 import java.io.*; 8 9 13 public class PdfBoolean 14 extends PdfObject { 15 16 19 protected boolean _b; 20 21 25 public static final PdfBoolean FALSE = new PdfBoolean(false); 26 27 31 public static final PdfBoolean TRUE = new PdfBoolean(true); 32 33 40 public PdfBoolean(boolean b) { 41 _b = b; 42 } 43 44 public boolean equals(Object obj) { 45 46 if ( (obj == null) || ( !(obj instanceof PdfBoolean) ) ) { 47 return false; 48 } 49 50 return (_b == ((PdfBoolean)obj)._b); 51 } 52 53 57 public boolean getBoolean() { 58 return _b; 59 } 60 61 public int hashCode() { 62 return _b ? 1231 : 1237; 63 } 64 65 73 public static PdfBoolean valueOf(boolean b) { 74 return b ? PdfBoolean.TRUE : PdfBoolean.FALSE; 75 } 76 77 protected int writePdf(PdfWriter w, boolean spacing) throws IOException { 78 79 DataOutputStream dos = w.getDataOutputStream(); 80 81 int count; 82 83 if (spacing) { 84 dos.write(' '); 85 count = 1; 86 } else { 87 count = 0; 88 } 89 90 if (_b) { 91 dos.writeBytes("true"); 92 return count + 4; 93 } else { 94 dos.writeBytes("false"); 95 return count + 5; 96 } 97 98 } 99 100 } 101 | Popular Tags |