An array of PDFBase objects as part of the PDF document.
Method from org.apache.pdfbox.cos.COSArray Detail: |
public Object accept(ICOSVisitor visitor) throws COSVisitorException {
return visitor.visitFromArray(this);
}
visitor pattern double dispatch method. |
public void add(COSBase object) {
objects.add( object );
}
This will add an object to the array. |
public void add(COSObjectable object) {
objects.add( object.getCOSObject() );
}
This will add an object to the array. |
public void add(int i,
COSBase object) {
objects.add( i, object );
}
Add the specified object at the ith location and push the rest to the
right. |
public void addAll(Collection<COSBase> objectsList) {
objects.addAll( objectsList );
}
This will add an object to the array. |
public void addAll(COSArray objectList) {
if( objectList != null )
{
objects.addAll( objectList.objects );
}
}
This will add all objects to this array. |
public void addAll(int i,
Collection<COSBase> objectList) {
objects.addAll( i, objectList );
}
Add the specified object at the ith location and push the rest to the
right. |
public void clear() {
objects.clear();
}
This will remove all of the objects in the collection. |
public COSBase get(int index) {
return (COSBase)objects.get( index );
}
This will get an object from the array. This will NOT derefernce
the COS object. |
public int getInt(int index) {
return getInt( index, -1 );
}
Get the value of the array as an integer. |
public int getInt(int index,
int defaultValue) {
int retval = defaultValue;
if ( index < size() )
{
Object obj = objects.get( index );
if( obj instanceof COSNumber )
{
retval = ((COSNumber)obj).intValue();
}
}
return retval;
}
Get the value of the array as an integer, return the default if it does
not exist. |
public String getName(int index) {
return getName( index, null );
}
Get the value of the array as a string. |
public String getName(int index,
String defaultValue) {
String retval = defaultValue;
if( index < size() )
{
Object obj = objects.get( index );
if( obj instanceof COSName )
{
retval = ((COSName)obj).getName();
}
}
return retval;
}
Get an entry in the array that is expected to be a COSName. |
public COSBase getObject(int index) {
Object obj = objects.get( index );
if( obj instanceof COSObject )
{
obj = ((COSObject)obj).getObject();
}
else if( obj instanceof COSNull )
{
obj = null;
}
return (COSBase)obj;
}
This will get an object from the array. This will dereference the object.
If the object is COSNull then null will be returned. |
public String getString(int index) {
return getString( index, null );
}
Get the value of the array as a string. |
public String getString(int index,
String defaultValue) {
String retval = defaultValue;
if( index < size() )
{
Object obj = objects.get( index );
if( obj instanceof COSString )
{
retval = ((COSString)obj).getString();
}
}
return retval;
}
Get an entry in the array that is expected to be a COSName. |
public void growToSize(int size) {
growToSize( size, null );
}
This will add null values until the size of the array is at least
as large as the parameter. If the array is already larger than the
parameter then nothing is done. |
public void growToSize(int size,
COSBase object) {
while( size() < size )
{
add( object );
}
}
This will add the object until the size of the array is at least
as large as the parameter. If the array is already larger than the
parameter then nothing is done. |
public int indexOf(COSBase object) {
int retval = -1;
for( int i=0; retval < 0 && i< size(); i++ )
{
if( get( i ).equals( object ) )
{
retval = i;
}
}
return retval;
}
This will return the index of the entry or -1 if it is not found. |
public int indexOfObject(COSBase object) {
int retval = -1;
for (int i = 0; retval < 0 && i < this.size(); i++)
{
COSBase item = this.get(i);
if (item.equals(object))
{
retval = i;
break;
}
else if (item instanceof COSObject)
{
if (((COSObject) item).getObject().equals(object))
{
retval = i;
break;
}
}
}
return retval;
}
This will return the index of the entry or -1 if it is not found.
This method will also find references to indirect objects. |
public Iterator<COSBase> iterator() {
return objects.iterator();
}
|
public COSBase remove(int i) {
return (COSBase)objects.remove( i );
}
This will remove an element from the array. |
public boolean remove(COSBase o) {
return objects.remove( o );
}
This will remove an element from the array. |
public void removeAll(Collection<COSBase> objectsList) {
objects.removeAll( objectsList );
}
This will remove all of the objects in the collection. |
public boolean removeObject(COSBase o) {
boolean removed = this.remove(o);
if (!removed)
{
for (int i = 0; i < this.size(); i++)
{
COSBase entry = this.get(i);
if (entry instanceof COSObject)
{
COSObject objEntry = (COSObject) entry;
if (objEntry.getObject().equals(o))
{
return this.remove(entry);
}
}
}
}
return removed;
}
This will remove an element from the array.
This method will also remove a reference to the object. |
public void retainAll(Collection<COSBase> objectsList) {
objects.retainAll( objectsList );
}
This will retain all of the objects in the collection. |
public void set(int index,
COSBase object) {
objects.set( index, object );
}
This will set an object at a specific index. |
public void set(int index,
int intVal) {
objects.set( index, COSInteger.get(intVal) );
}
This will set an object at a specific index. |
public void set(int index,
COSObjectable object) {
COSBase base = null;
if( object != null )
{
base = object.getCOSObject();
}
objects.set( index, base );
}
This will set an object at a specific index. |
public void setFloatArray(float[] value) {
this.clear();
for( int i=0; i< value.length; i++ )
{
add( new COSFloat( value[i] ) );
}
}
Clear the current contents of the COSArray and set it with the float[]. |
public void setInt(int index,
int value) {
set( index, COSInteger.get( value ) );
}
Set the value in the array as an integer. |
public void setName(int index,
String name) {
set( index, COSName.getPDFName( name ) );
}
Set the value in the array as a name. |
public void setString(int index,
String string) {
set( index, new COSString( string ) );
}
Set the value in the array as a string. |
public int size() {
return objects.size();
}
This will get the size of this array. |
public float[] toFloatArray() {
float[] retval = new float[size()];
for( int i=0; i< size(); i++ )
{
retval[i] = ((COSNumber)getObject( i )).floatValue();
}
return retval;
}
This will take an COSArray of numbers and convert it to a float[]. |
public List<COSBase> toList() {
ArrayList< COSBase > retList = new ArrayList< COSBase >(size());
for (int i = 0; i < size(); i++)
{
retList.add(get(i));
}
return retList;
}
Return contents of COSArray as a Java List. |
public String toString() {
return "COSArray{" + objects + "}";
}
|