private void addSingleMappings(int cidBegin, COSArray arr) { for (int i = 0; i < arr.size().intValue(); i++) { if (!arr.at(i).getType().isNumber()) { LOGGER.log(Level.SEVERE, "W array in CIDFont has invalid entry."); continue; } this.singleMappings.put(Integer.valueOf(cidBegin + i), arr.at(i).getReal()); } }
public static COSObject construct(final int i, final COSObject obj) { return new COSObject(new COSArray(i, obj)); }
public COSObject at(final int i) { if (i >= this.entries.size()) { return new COSObject(); } return _at(i); }
/** * Constructor used by child classes * * @param array greenfield COSArray * @param type type of object */ public GFCosArray(COSArray array, String type) { super(array, type); this.size = array.size().intValue(); }
/** * @return COSObject that is font dictionary for descendant font. */ public COSObject getDescendantFontObject() { if (this.type0FontDict != null) { COSArray array = (COSArray) this.type0FontDict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return array.at(0); } } return null; }
/** * This method makes sure that Index array is correctly initialized. * * @throws IOException */ private void initializeIndex() throws IOException { index = (COSArray) xrefCOSStream.getKey(ASAtom.INDEX).getDirectBase(); if (index == null) { COSObject[] defaultIndex = new COSObject[2]; defaultIndex[0] = COSInteger.construct(0); defaultIndex[1] = xrefCOSStream.getKey(ASAtom.SIZE); index = (COSArray) COSArray.construct(2, defaultIndex).getDirectBase(); } else if (index.size() % 2 != 0) { throw new IOException("Index array in xref stream has odd amount of elements."); } }
public void setArrayKey(final ASAtom key, final int size, final COSObject[] value) { if (value != null && (this.base == null || !this.base.setArrayKey(key, size, value))) { COSObject obj = COSArray.construct(size, value); this.base = new COSDictionary(key, obj); } }
private static String parseFilters(COSBase base) { StringBuilder filters = new StringBuilder(); if (base == null) { return null; } else if (base instanceof COSName) { return base.getString(); } else if (base instanceof COSArray) { Iterator<?> iterator = ((COSArray) base).iterator(); while (iterator.hasNext()) { COSBase filter = (COSBase) iterator.next(); if (filter instanceof COSName) { filters.append(((COSName) filter).getName()).append(" "); } else { LOGGER.log(Level.SEVERE, "Incorrect type for stream filter " + filter.getClass().getName()); } } } else { LOGGER.log(Level.SEVERE, "Incorrect type for stream filter " + base.getClass().getName()); return null; } // need to discard last white space return filters.substring(0, filters.length() - 1); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if(obj instanceof COSObject) { return this.equals(((COSObject) obj).get()); } if (getClass() != obj.getClass()) { return false; } List<COSBasePair> checkedObjects = new LinkedList<>(); return this.equals(obj, checkedObjects); }
/** * @return signature reference dictionaries. */ private List<PDSigRef> getSigRefs() { COSArray reference = ((org.verapdf.pd.PDSignature) this.simplePDObject).getReference(); if (reference == null || reference.size().intValue() == 0) { return Collections.emptyList(); } List<PDSigRef> list = new ArrayList<>(); for (COSObject sigRef : reference) { list.add(new GFPDSigRef((COSDictionary) sigRef.getDirectBase())); } return Collections.unmodifiableList(list); }
private static COSDictionary getDescendantCOSDictionary(COSDictionary dict) { if (dict != null) { COSArray array = (COSArray) dict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return (COSDictionary) array.at(0).getDirectBase(); } } return null; }
public void setArrayKey(final ASAtom key) { if (this.base == null || !this.base.setArrayKey(key)) { COSObject obj = COSArray.construct(); this.base = new COSDictionary(key, obj); } }
private static String getRequirementsString(COSArray reqArray) { String result = ""; Iterator<COSObject> iterator = reqArray.iterator(); while (iterator.hasNext()) { COSObject element = iterator.next(); COSBase base = element.getDirectBase(); if (base.getType() == COSObjType.COS_DICT) { result += getRequirementsString((COSDictionary) base); result += " "; } } return result; }
private Double getRequiredValue(final int position) { COSArray array = (COSArray) this.baseObject; if (array.size().intValue() > position) { COSBase base = array.at(position).get(); if (base instanceof COSNumber) { return base.getReal(); } LOGGER.log(Level.WARNING, "In bbox expected number but got " + base.getClass().getSimpleName()); } else { LOGGER.log(Level.WARNING, "Expected size of bbox array greater than" + position + "but got " + array.size()); } return null; }
/** * This is an entry point for parsing xref stream and trailer. * * @throws IOException */ void parseStreamAndTrailer() throws IOException { try { xrefInputStream = xrefCOSStream.getData(COSStream.FilterFlags.DECODE); fieldSizes = (COSArray) xrefCOSStream.getKey(ASAtom.W).getDirectBase(); if (fieldSizes.size() != 3) { throw new IOException("W array in xref should have 3 elements."); } initializeIndex(); initializeObjIDs(); parseStream(); setTrailer(); } finally { xrefInputStream.close(); } }
public static COSObject construct(final int size) { return new COSObject(new COSArray(size)); }
private void array() throws PostScriptException { try { COSObject arraySize = getTopNumber(); this.operandStack.push(COSArray.construct(arraySize.getInteger().intValue())); } catch (PostScriptException e) { throw new PostScriptException("Can't execute array operator", e); } }