/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolvedto a direct object. * If it is a <CODE>PdfDictionary</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfDictionary</CODE> object, * or <CODE>null</CODE> */ public PdfDictionary getAsDict(int idx) { PdfDictionary dict = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isDictionary()) dict = (PdfDictionary) orig; return dict; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfArray</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfArray</CODE> object, * or <CODE>null</CODE> */ public PdfArray getAsArray(int idx) { PdfArray array = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isArray()) array = (PdfArray) orig; return array; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfStream</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfStream</CODE> object, * or <CODE>null</CODE> */ public PdfStream getAsStream(int idx) { PdfStream stream = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isStream()) stream = (PdfStream) orig; return stream; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, resolving * indirect references. * * The object corresponding to the specified index is retrieved and resolved * to a direct object. If it is a <CODE>PdfName</CODE>, it is cast down and * returned as such. Otherwise <CODE>null</CODE> is returned. * * @param idx * The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfName</CODE> object, or * <CODE>null</CODE> */ public PdfName getAsName(int idx) { PdfName name = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isName()) { name = (PdfName) orig; } return name; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, resolving * indirect references. * * The object corresponding to the specified index is retrieved and resolved * to a direct object. If it is a <CODE>PdfString</CODE>, it is cast down * and returned as such. Otherwise <CODE>null</CODE> is returned. * * @param idx * The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfString</CODE> object, or * <CODE>null</CODE> */ public PdfString getAsString(int idx) { PdfString string = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isString()) { string = (PdfString) orig; } return string; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfString</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfString</CODE> object, * or <CODE>null</CODE> */ public PdfString getAsString(int idx) { PdfString string = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isString()) string = (PdfString) orig; return string; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfName</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfName</CODE> object, * or <CODE>null</CODE> */ public PdfName getAsName(int idx) { PdfName name = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isName()) name = (PdfName) orig; return name; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, resolving * indirect references. * * The object corresponding to the specified index is retrieved and resolved * to a direct object. If it is a <CODE>PdfNumber</CODE>, it is cast down * and returned as such. Otherwise <CODE>null</CODE> is returned. * * @param idx * The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfNumber</CODE> object, or * <CODE>null</CODE> */ public PdfNumber getAsNumber(int idx) { PdfNumber number = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isNumber()) { number = (PdfNumber) orig; } return number; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfStream</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfStream</CODE> object, * or <CODE>null</CODE> */ public PdfStream getAsStream(int idx) { PdfStream stream = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isStream()) stream = (PdfStream) orig; return stream; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfNumber</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfNumber</CODE> object, * or <CODE>null</CODE> */ public PdfNumber getAsNumber(int idx) { PdfNumber number = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isNumber()) number = (PdfNumber) orig; return number; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfString</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfString</CODE> object, * or <CODE>null</CODE> */ public PdfString getAsString(int idx) { PdfString string = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isString()) string = (PdfString) orig; return string; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfName</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfName</CODE> object, * or <CODE>null</CODE> */ public PdfName getAsName(int idx) { PdfName name = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isName()) name = (PdfName) orig; return name; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfBoolean</CODE>, it is cast down and returned as * such. Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfBoolean</CODE> object, * or <CODE>null</CODE> */ public PdfBoolean getAsBoolean(int idx) { PdfBoolean bool = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isBoolean()) bool = (PdfBoolean) orig; return bool; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfArray</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfArray</CODE> object, * or <CODE>null</CODE> */ public PdfArray getAsArray(int idx) { PdfArray array = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isArray()) array = (PdfArray) orig; return array; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfBoolean</CODE>, it is cast down and returned as * such. Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfBoolean</CODE> object, * or <CODE>null</CODE> */ public PdfBoolean getAsBoolean(int idx) { PdfBoolean bool = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isBoolean()) bool = (PdfBoolean) orig; return bool; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolvedto a direct object. * If it is a <CODE>PdfDictionary</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfDictionary</CODE> object, * or <CODE>null</CODE> */ public PdfDictionary getAsDict(int idx) { PdfDictionary dict = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isDictionary()) dict = (PdfDictionary) orig; return dict; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfNumber</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfNumber</CODE> object, * or <CODE>null</CODE> */ public PdfNumber getAsNumber(int idx) { PdfNumber number = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isNumber()) number = (PdfNumber) orig; return number; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, resolving * indirect references. * * The object corresponding to the specified index is retrieved and resolved * to a direct object. If it is a <CODE>PdfArray</CODE>, it is cast down and * returned as such. Otherwise <CODE>null</CODE> is returned. * * @param idx * The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfArray</CODE> object, or * <CODE>null</CODE> */ public PdfArray getAsArray(int idx) { PdfArray array = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isArray()) { array = (PdfArray) orig; } return array; }
private String[] getListOption(String fieldName, int idx) { Item fd = getFieldItem(fieldName); if (fd == null) return null; PdfArray ar = fd.getMerged(0).getAsArray(PdfName.OPT); if (ar == null) return null; String[] ret = new String[ar.size()]; for (int k = 0; k < ar.size(); ++k) { PdfObject obj = ar.getDirectObject( k ); try { if (obj.isArray()) { obj = ((PdfArray)obj).getDirectObject(idx); } if (obj.isString()) ret[k] = ((PdfString)obj).toUnicodeString(); else ret[k] = obj.toString(); } catch (Exception e) { ret[k] = ""; } } return ret; }
private String[] getListOption(String fieldName, int idx) { Item fd = getFieldItem(fieldName); if (fd == null) { return null; } PdfArray ar = fd.getMerged(0).getAsArray(PdfName.OPT); if (ar == null) { return null; } String[] ret = new String[ar.size()]; for (int k = 0; k < ar.size(); ++k) { PdfObject obj = ar.getDirectObject(k); try { if (obj.isArray()) { obj = ((PdfArray) obj).getDirectObject(idx); } if (obj.isString()) { ret[k] = ((PdfString) obj).toUnicodeString(); } else { ret[k] = obj.toString(); } } catch (Exception e) { ret[k] = ""; } } return ret; }