@Override public COSBase getCOSObject() { return obj.getCOSObject(); }
/** * This will add an object to the array. * * @param object The object to add to the array. */ public void add( COSObjectable object ) { objects.add( object.getCOSObject() ); }
/** * This will set an object at a specific index. * * @param index zero based index into array. * @param object The object to set. */ public void set( int index, COSObjectable object ) { COSBase base = null; if( object != null ) { base = object.getCOSObject(); } objects.set( index, base ); }
/** * Appends an objectable kid. * * @param objectable the objectable */ protected void appendObjectableKid(COSObjectable objectable) { if (objectable == null) { return; } this.appendKid(objectable.getCOSObject()); }
/** * Inserts an objectable kid before a reference kid. * * @param newKid the objectable * @param refKid the reference kid */ protected void insertObjectableBefore(COSObjectable newKid, Object refKid) { if (newKid == null) { return; } this.insertBefore(newKid.getCOSObject(), refKid); }
/** * Removes an objectable kid. * * @param objectable the objectable * @return <code>true</code> if the kid was removed, <code>false</code> otherwise */ protected boolean removeObjectableKid(COSObjectable objectable) { if (objectable == null) { return false; } return this.removeKid(objectable.getCOSObject()); }
/** * This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ). * * @param key The key to the dictionary object. * @param value The value to the dictionary object. */ public void setItem(COSName key, COSObjectable value) { COSBase base = null; if (value != null) { base = value.getCOSObject(); } setItem(key, base); }
private List<COSBase> toCOSObjectList( Collection<?> list ) { List<COSBase> cosObjects = new ArrayList<>(); for (Object next : list) { if( next instanceof String ) { cosObjects.add( new COSString( (String)next ) ); } else { COSObjectable cos = (COSObjectable)next; cosObjects.add( cos.getCOSObject() ); } } return cosObjects; }
/** * {@inheritDoc} */ @Override public V put(K key, V value) { COSObjectable object = (COSObjectable)value; map.setItem( COSName.getPDFName( (String)key ), object.getCOSObject() ); return actuals.put( key, value ); }
/** * This will take a map<java.lang.String,org.apache.pdfbox.pdmodel.COSObjectable> * and convert it into a COSDictionary. * * @param someMap A map containing COSObjectables * * @return A proper COSDictionary */ public static COSDictionary convert(Map<String, ?> someMap) { COSDictionary dic = new COSDictionary(); for (Entry<String, ?> entry : someMap.entrySet()) { String name = entry.getKey(); COSObjectable object = (COSObjectable) entry.getValue(); dic.setItem( COSName.getPDFName( name ), object.getCOSObject() ); } return dic; }
/** * Adds the given resource if it does not already exist. */ private COSName add(COSName kind, String prefix, COSObjectable object) { // return the existing key if the item exists already COSDictionary dict = (COSDictionary)resources.getDictionaryObject(kind); if (dict != null && dict.containsValue(object.getCOSObject())) { return dict.getKeyForValue(object.getCOSObject()); } // add the item with a new key COSName name = createKey(kind, prefix); put(kind, name, object); return name; }
/** * {@inheritDoc} */ @Override public E set(int index, E element) { if( element instanceof String ) { COSString item = new COSString( (String)element ); if( parentDict != null && index == 0 ) { parentDict.setItem( dictKey, item ); } array.set( index, item ); } else { if( parentDict != null && index == 0 ) { parentDict.setItem( dictKey, ((COSObjectable)element).getCOSObject() ); } array.set( index, ((COSObjectable)element).getCOSObject() ); } return actual.set( index, element ); }
/** * You should pass in a string, or a java.util.List of strings to set the value. * * @param value The value that should populate when imported. * * @throws IOException If there is an error setting the value. */ public void setValue(Object value) throws IOException { COSBase cos = null; if (value instanceof List) { cos = COSArrayList.convertStringListToCOSStringCOSArray((List<String>) value); } else if (value instanceof String) { cos = new COSString((String) value); } else if (value instanceof COSObjectable) { cos = ((COSObjectable) value).getCOSObject(); } else if (value != null) { throw new IOException("Error:Unknown type for field import" + value); } field.setItem(COSName.V, cos); }
/** * {@inheritDoc} */ @Override public void add(int index, E element) { //when adding if there is a parentDict then change the item //in the dictionary from a single item to an array. if( parentDict != null ) { parentDict.setItem( dictKey, array ); //clear the parent dict so it doesn't happen again, there might be //a usecase for keeping the parentDict around but not now. parentDict = null; } actual.add( index, element ); if( element instanceof String ) { array.add( index, new COSString( (String)element ) ); } else { array.add( index, ((COSObjectable)element).getCOSObject() ); } }
/** * {@inheritDoc} */ @Override public boolean add(E o) { //when adding if there is a parentDict then change the item //in the dictionary from a single item to an array. if( parentDict != null ) { parentDict.setItem( dictKey, array ); //clear the parent dict so it doesn't happen again, there might be //a usecase for keeping the parentDict around but not now. parentDict = null; } //string is a special case because we can't subclass to be COSObjectable if( o instanceof String ) { array.add( new COSString( (String)o ) ); } else { if(array != null) { array.add(((COSObjectable)o).getCOSObject()); } } return actual.add(o); }
array.add( object.getCOSObject() );
cloneMerge(base.getCOSObject(), target.getCOSObject()); clonedVersion.put(base, retval);
retval = cloneForNewDocument( ((COSObjectable)base).getCOSObject() ); clonedVersion.put( base, retval );
if (refKid instanceof COSObjectable) refKidBase = ((COSObjectable) refKid).getCOSObject();
/** * This will add an object to the array. * * @param object The object to add to the array. */ public void add( COSObjectable object ) { objects.add( object.getCOSObject() ); }