This class represents a PDF object.
Method from org.apache.pdfbox.cos.COSObject Detail: |
public Object accept(ICOSVisitor visitor) throws COSVisitorException {
return getObject() != null ? getObject().accept( visitor ) : COSNull.NULL.accept( visitor );
}
visitor pattern double dispatch method. |
public COSBase getDictionaryObject(COSName key) {
COSBase retval =null;
if( baseObject instanceof COSDictionary )
{
retval = ((COSDictionary)baseObject).getDictionaryObject( key );
}
return retval;
}
This will get the dictionary object in this object that has the name key and
if it is a pdfobjref then it will dereference that and return it. |
public COSInteger getGenerationNumber() {
return generationNumber;
}
Getter for property generationNumber. |
public COSBase getItem(COSName key) {
COSBase retval =null;
if( baseObject instanceof COSDictionary )
{
retval = ((COSDictionary)baseObject).getItem( key );
}
return retval;
}
This will get the dictionary object in this object that has the name key. |
public COSBase getObject() {
return baseObject;
}
This will get the object that this object encapsulates. |
public COSInteger getObjectNumber() {
return objectNumber;
}
Getter for property objectNumber. |
public void setGenerationNumber(COSInteger generationNumberValue) {
generationNumber = generationNumberValue;
}
Setter for property generationNumber. |
public void setObject(COSBase object) throws IOException {
baseObject = object;
/*if( baseObject == null )
{
baseObject = object;
}
else
{
//This is for when an object appears twice in the
//pdf file we really want to replace it such that
//object references still work correctly.
//see owcp-as-received.pdf for an example
if( baseObject instanceof COSDictionary )
{
COSDictionary dic = (COSDictionary)baseObject;
COSDictionary dicObject = (COSDictionary)object;
dic.clear();
dic.addAll( dicObject );
}
else if( baseObject instanceof COSArray )
{
COSArray array = (COSArray)baseObject;
COSArray arrObject = (COSArray)object;
array.clear();
for( int i=0; i< arrObject.size(); i++ )
{
array.add( arrObject.get( i ) );
}
}
else if( baseObject instanceof COSStream )
{
COSStream oldStream = (COSStream)baseObject;
System.out.println( "object:" + object.getClass().getName() );
COSStream newStream = (COSStream)object;
oldStream.replaceWithStream( newStream );
}
else if( baseObject instanceof COSInteger )
{
COSInteger oldInt = (COSInteger)baseObject;
COSInteger newInt = (COSInteger)object;
oldInt.setValue( newInt.longValue() );
}
else if( baseObject == null )
{
baseObject = object;
}
else
{
throw new IOException( "Unknown object substitution type:" + baseObject );
}
}*/
}
This will set the object that this object encapsulates. |
public void setObjectNumber(COSInteger objectNum) {
objectNumber = objectNum;
}
Setter for property objectNumber. |
public String toString() {
return "COSObject{" +
(objectNumber == null ? "unknown" : "" + objectNumber.intValue() ) + ", " +
(generationNumber == null ? "unknown" : "" + generationNumber.intValue() ) +
"}";
}
|