1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.pdfbox.cos; 18 19 20 21 import java.io.IOException; 22 import java.io.OutputStream; 23 24 import org.apache.pdfbox.exceptions.COSVisitorException; 25 26 /** 27 * This class represents a null PDF object. 28 * 29 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a> 30 * @version $Revision: 1.13 $ 31 */ 32 public class COSNull extends COSBase 33 { 34 /** 35 * The null token. 36 */ 37 public static final byte[] NULL_BYTES = new byte[] {110, 117, 108, 108}; //"null".getBytes( "ISO-8859-1" ); 38 39 /** 40 * The one null object in the system. 41 */ 42 public static final COSNull NULL = new COSNull(); 43 44 /** 45 * Constructor. 46 */ 47 private COSNull() 48 { 49 //limit creation to one instance. 50 } 51 52 /** 53 * visitor pattern double dispatch method. 54 * 55 * @param visitor The object to notify when visiting this object. 56 * @return any object, depending on the visitor implementation, or null 57 * @throws COSVisitorException If an error occurs while visiting this object. 58 */ 59 public Object accept( ICOSVisitor visitor ) throws COSVisitorException 60 { 61 return visitor.visitFromNull( this ); 62 } 63 64 /** 65 * This will output this string as a PDF object. 66 * 67 * @param output The stream to write to. 68 * @throws IOException If there is an error writing to the stream. 69 */ 70 public void writePDF( OutputStream output ) throws IOException 71 { 72 output.write(NULL_BYTES); 73 } 74 }