1 50 51 package com.lowagie.text.pdf; 52 53 62 63 public class PdfBoolean extends PdfObject { 64 65 public static final PdfBoolean PDFTRUE = new PdfBoolean(true); 67 public static final PdfBoolean PDFFALSE = new PdfBoolean(false); 68 69 public static final String TRUE = "true"; 70 71 72 public static final String FALSE = "false"; 73 74 76 77 private boolean value; 78 79 81 86 87 public PdfBoolean(boolean value) { 88 super(BOOLEAN); 89 if (value) { 90 setContent(TRUE); 91 } 92 else { 93 setContent(FALSE); 94 } 95 this.value = value; 96 } 97 98 105 106 public PdfBoolean(String value) throws BadPdfFormatException { 107 super(BOOLEAN, value); 108 if (value.equals(TRUE)) { 109 this.value = true; 110 } 111 else if (value.equals(FALSE)) { 112 this.value = false; 113 } 114 else { 115 throw new BadPdfFormatException("The value has to be 'true' of 'false', instead of '" + value + "'."); 116 } 117 } 118 119 121 126 127 public boolean booleanValue() { 128 return value; 129 } 130 131 public String toString() { 132 return value ? TRUE : FALSE; 133 } 134 } | Popular Tags |