| Method from com.lowagie.text.pdf.PdfDictionary Detail: |
public boolean contains(PdfName key) {
return hashMap.containsKey(key);
}
Returns true if this PdfDictionary contains a
mapping for the specified key. |
public PdfObject get(PdfName key) {
return (PdfObject) hashMap.get(key);
}
Returns the PdfObject associated to the specified
key. |
public PdfArray getAsArray(PdfName key) {
PdfArray array = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isArray())
array = (PdfArray) orig;
return array;
}
Returns a PdfObject as a PdfArray,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfArray, it is cast down and returned as such.
Otherwise null is returned. |
public PdfBoolean getAsBoolean(PdfName key) {
PdfBoolean bool = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isBoolean())
bool = (PdfBoolean)orig;
return bool;
}
Returns a PdfObject as a PdfBoolean,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfBoolean, it is cast down and returned as such.
Otherwise null is returned. |
public PdfDictionary getAsDict(PdfName key) {
PdfDictionary dict = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isDictionary())
dict = (PdfDictionary) orig;
return dict;
}
Returns a PdfObject as a PdfDictionary,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfDictionary, it is cast down and returned as
such. Otherwise null is returned. |
public PdfIndirectReference getAsIndirectObject(PdfName key) {
PdfIndirectReference ref = null;
PdfObject orig = get(key); // not getDirect this time.
if (orig != null && orig.isIndirect())
ref = (PdfIndirectReference) orig;
return ref;
}
Returns a PdfObject as a PdfIndirectReference.
The object associated with the PdfName given is retrieved
If it is a PdfIndirectReference, it is cast down and returned
as such. Otherwise null is returned. |
public PdfName getAsName(PdfName key) {
PdfName name = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isName())
name = (PdfName) orig;
return name;
}
Returns a PdfObject as a PdfName,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfName, it is cast down and returned as such.
Otherwise null is returned. |
public PdfNumber getAsNumber(PdfName key) {
PdfNumber number = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isNumber())
number = (PdfNumber) orig;
return number;
}
Returns a PdfObject as a PdfNumber,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfNumber, it is cast down and returned as such.
Otherwise null is returned. |
public PdfStream getAsStream(PdfName key) {
PdfStream stream = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isStream())
stream = (PdfStream) orig;
return stream;
}
Returns a PdfObject as a PdfStream,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfStream, it is cast down and returned as such.
Otherwise null is returned. |
public PdfString getAsString(PdfName key) {
PdfString string = null;
PdfObject orig = getDirectObject(key);
if (orig != null && orig.isString())
string = (PdfString) orig;
return string;
}
Returns a PdfObject as a PdfString,
resolving indirect references.
The object associated with the PdfName given is retrieved
and resolved to a direct object.
If it is a PdfString, it is cast down and returned as such.
Otherwise null is returned. |
public PdfObject getDirectObject(PdfName key) {
return PdfReader.getPdfObject(get(key));
}
Returns the PdfObject associated to the specified
key, resolving a possible indirect reference to a direct
object.
This method will never return a PdfIndirectReference
object. |
public Set getKeys() {
return hashMap.keySet();
}
Get all keys that are set. |
public boolean isCatalog() {
return CATALOG.equals(dictionaryType);
}
Checks if a Dictionary is of the type CATALOG. |
public boolean isFont() {
return FONT.equals(dictionaryType);
}
Checks if a Dictionary is of the type FONT. |
public boolean isOutlineTree() {
return OUTLINES.equals(dictionaryType);
}
Checks if a Dictionary is of the type OUTLINES. |
public boolean isPage() {
return PAGE.equals(dictionaryType);
}
Checks if a Dictionary is of the type PAGE. |
public boolean isPages() {
return PAGES.equals(dictionaryType);
}
Checks if a Dictionary is of the type PAGES. |
public void merge(PdfDictionary other) {
hashMap.putAll(other.hashMap);
}
|
public void mergeDifferent(PdfDictionary other) {
for (Iterator i = other.hashMap.keySet().iterator(); i.hasNext();) {
Object key = i.next();
if (!hashMap.containsKey(key))
hashMap.put(key, other.hashMap.get(key));
}
}
|
public void put(PdfName key,
PdfObject object) {
if (object == null || object.isNull())
hashMap.remove(key);
else
hashMap.put(key, object);
}
Associates the specified PdfObject as value with
the specified PdfName as key in this map.
If the map previously contained a mapping for this key, the
old value is replaced. If the value is
null or PdfNull the key is deleted. |
public void putAll(PdfDictionary dic) {
hashMap.putAll(dic.hashMap);
}
Copies all of the mappings from the specified PdfDictionary
to this PdfDictionary.
These mappings will replace any mappings previously contained in this
PdfDictionary. |
public void putEx(PdfName key,
PdfObject value) {
if (value == null)
return;
put(key, value);
}
Associates the specified PdfObject as value to the
specified PdfName as key in this map.
If the value is a PdfNull, it is treated just as
any other PdfObject. If the value is
null however nothing is done. |
public void remove(PdfName key) {
hashMap.remove(key);
}
Removes a PdfObject and its key from the
PdfDictionary. |
public int size() {
return hashMap.size();
}
Returns the number of key-value mappings in this
PdfDictionary. |
public void toPdf(PdfWriter writer,
OutputStream os) throws IOException {
os.write('< ');
os.write('< ');
// loop over all the object-pairs in the HashMap
PdfName key;
PdfObject value;
int type = 0;
for (Iterator i = hashMap.keySet().iterator(); i.hasNext(); ) {
key = (PdfName) i.next();
value = (PdfObject) hashMap.get(key);
key.toPdf(writer, os);
type = value.type();
if (type != PdfObject.ARRAY && type != PdfObject.DICTIONARY && type != PdfObject.NAME && type != PdfObject.STRING)
os.write(' ');
value.toPdf(writer, os);
}
os.write(' >');
os.write(' >');
}
Writes the PDF representation of this PdfDictionary as an
array of byte to the given OutputStream. |
public String toString() {
if (get(PdfName.TYPE) == null)
return "Dictionary";
return "Dictionary of type: " + get(PdfName.TYPE);
}
Returns a string representation of this PdfDictionary.
The string doesn't contain any of the content of this dictionary.
Rather the string "dictionary" is returned, possibly followed by the
type of this PdfDictionary, if set. |