1 31 package org.pdfbox.pdmodel.interactive.documentnavigation.destination; 32 33 import java.io.IOException ; 34 35 import org.pdfbox.cos.COSBase; 36 import org.pdfbox.cos.COSName; 37 import org.pdfbox.cos.COSString; 38 39 45 public class PDNamedDestination extends PDDestination 46 { 47 private COSBase namedDestination; 48 49 54 public PDNamedDestination( COSString dest ) 55 { 56 namedDestination = dest; 57 } 58 59 64 public PDNamedDestination( COSName dest ) 65 { 66 namedDestination = dest; 67 } 68 69 72 public PDNamedDestination() 73 { 74 } 76 77 82 public PDNamedDestination( String dest ) 83 { 84 namedDestination = new COSString( dest ); 85 } 86 87 92 public COSBase getCOSObject() 93 { 94 return namedDestination; 95 } 96 97 102 public String getNamedDestination() 103 { 104 String retval = null; 105 if( namedDestination instanceof COSString ) 106 { 107 retval = ((COSString)namedDestination).getString(); 108 } 109 else if( namedDestination instanceof COSName ) 110 { 111 retval = ((COSName)namedDestination).getName(); 112 } 113 114 return retval; 115 } 116 117 124 public void setNamedDestination( String dest ) throws IOException 125 { 126 if( namedDestination instanceof COSString ) 127 { 128 COSString string = ((COSString)namedDestination); 129 string.reset(); 130 string.append( dest.getBytes() ); 131 } 132 else if( dest == null ) 133 { 134 namedDestination = null; 135 } 136 else 137 { 138 namedDestination = new COSString( dest ); 139 } 140 } 141 142 } 143 | Popular Tags |