/** * Reads an array. The tokeniser must be positioned past the "[" token. * @return an array * @throws java.io.IOException on error */ public CMapObject readArray() throws java.io.IOException { List<CMapObject> array = new ArrayList<CMapObject>(); while (true) { CMapObject obj = readObject(); if (obj.isToken()) { if (obj.toString().equals("]")) { break; } if (obj.toString().equals(">>")) { tokeniser.throwError(IOException.UnexpectedGtGt); } } array.add(obj); } return new CMapObject(CMapObject.ARRAY, array); }
/** * Reads an array. The tokeniser must be positioned past the "[" token. * @return an array * @throws java.io.IOException on error */ public CMapObject readArray() throws java.io.IOException { List<CMapObject> array = new ArrayList<CMapObject>(); while (true) { CMapObject obj = readObject(); if (obj.isToken()) { if (obj.toString().equals("]")) { break; } if (obj.toString().equals(">>")) { tokeniser.throwError(IOException.UnexpectedGtGt); } } array.add(obj); } return new CMapObject(CMapObject.ARRAY, array); }
protected PdfDictionary readDictionary(boolean objStm) throws IOException { PdfDictionary dic = new PdfDictionary(); while (true) { tokens.nextValidToken(); if (tokens.getTokenType() == PdfTokenizer.TokenType.EndDic) break; if (tokens.getTokenType() != PdfTokenizer.TokenType.Name) tokens.throwError(PdfException.DictionaryKey1IsNotAName, tokens.getStringValue()); PdfName name = readPdfName(true); PdfObject obj = readObject(true, objStm); if (obj == null) { if (tokens.getTokenType() == PdfTokenizer.TokenType.EndDic) tokens.throwError(PdfException.UnexpectedGtGt); if (tokens.getTokenType() == PdfTokenizer.TokenType.EndArray) tokens.throwError(PdfException.UnexpectedCloseBracket); } dic.put(name, obj); } return dic; }
protected PdfArray readArray(boolean objStm) throws IOException { PdfArray array = new PdfArray(); while (true) { PdfObject obj = readObject(true, objStm); if (obj == null) { if (tokens.getTokenType() == PdfTokenizer.TokenType.EndArray) break; if (tokens.getTokenType() == PdfTokenizer.TokenType.EndDic) tokens.throwError(PdfException.UnexpectedGtGt); } array.add(obj); } return array; }
/** * Reads a dictionary. The tokeniser must be positioned past the {@code "<<"} token. * @return the dictionary * @throws java.io.IOException on error */ public CMapObject readDictionary() throws java.io.IOException { Map<String, CMapObject> dic = new HashMap<>(); while (true) { if (!nextValidToken()) throw new IOException("Unexpected end of file."); if (tokeniser.getTokenType() == TokenType.EndDic) break; if (tokeniser.getTokenType() == TokenType.Other && "def".equals(tokeniser.getStringValue())) continue; if (tokeniser.getTokenType() != TokenType.Name) throw new IOException("Dictionary key {0} is not a name.").setMessageParams(tokeniser.getStringValue()); String name = tokeniser.getStringValue(); CMapObject obj = readObject(); if (obj.isToken()) { if (obj.toString().equals(">>")) { tokeniser.throwError(IOException.UnexpectedGtGt); } if (obj.toString().equals("]")) { tokeniser.throwError(IOException.UnexpectedCloseBracket); } } dic.put(name, obj); } return new CMapObject(CMapObject.DICTIONARY, dic); }
/** * Reads a dictionary. The tokeniser must be positioned past the {@code "<<"} token. * @return the dictionary * @throws java.io.IOException on error */ public CMapObject readDictionary() throws java.io.IOException { Map<String, CMapObject> dic = new HashMap<>(); while (true) { if (!nextValidToken()) throw new IOException("Unexpected end of file."); if (tokeniser.getTokenType() == TokenType.EndDic) break; if (tokeniser.getTokenType() == TokenType.Other && "def".equals(tokeniser.getStringValue())) continue; if (tokeniser.getTokenType() != TokenType.Name) throw new IOException("Dictionary key {0} is not a name.").setMessageParams(tokeniser.getStringValue()); String name = tokeniser.getStringValue(); CMapObject obj = readObject(); if (obj.isToken()) { if (obj.toString().equals(">>")) { tokeniser.throwError(IOException.UnexpectedGtGt); } if (obj.toString().equals("]")) { tokeniser.throwError(IOException.UnexpectedCloseBracket); } } dic.put(name, obj); } return new CMapObject(CMapObject.DICTIONARY, dic); }
/** * Reads an array. The tokeniser must be positioned past the "[" token. * @return an array * @throws IOException on error */ public PdfArray readArray() throws IOException { PdfArray array = new PdfArray(); while (true) { PdfObject obj = readObject(); if (!obj.isArray() && tokeniser.getTokenType() == PdfTokenizer.TokenType.EndArray) break; if (tokeniser.getTokenType() == PdfTokenizer.TokenType.EndDic && obj.getType() != PdfObject.DICTIONARY) tokeniser.throwError(PdfException.UnexpectedGtGt); array.add(obj); } return array; }
tokens.throwError(PdfException.DictionaryKey1IsNotAName, tokens.getStringValue()); tokens.throwError(PdfException.UnexpectedGtGt); if (tokens.getTokenType() == PdfTokenizer.TokenType.EndArray) tokens.throwError(PdfException.UnexpectedCloseBracket);
tokens.throwError(PdfException.DictionaryKey1IsNotAName, tokens.getStringValue()); tokens.throwError(PdfException.UnexpectedGtGt); if (tokens.getTokenType() == PdfTokenizer.TokenType.EndArray) tokens.throwError(PdfException.UnexpectedCloseBracket);
/** * Reads a dictionary. The tokeniser must be positioned past the "<<" token. * @return the dictionary * @throws IOException on error */ public PdfDictionary readDictionary() throws IOException { PdfDictionary dic = new PdfDictionary(); while (true) { if (!nextValidToken()) throw new PdfException(PdfException.UnexpectedEndOfFile); if (tokeniser.getTokenType() == PdfTokenizer.TokenType.EndDic) break; if (tokeniser.getTokenType() != PdfTokenizer.TokenType.Name) tokeniser.throwError(PdfException.DictionaryKey1IsNotAName, tokeniser.getStringValue()); PdfName name = new PdfName(tokeniser.getStringValue()); PdfObject obj = readObject(); dic.put(name, obj); } return dic; }
protected PdfDictionary readXrefSection() throws IOException { tokens.nextValidToken(); if (!tokens.tokenValueEqualsTo(PdfTokenizer.Xref)) tokens.throwError(PdfException.XrefSubsectionNotFound); PdfXrefTable xref = pdfDocument.getXref(); while (true) { tokens.throwError(PdfException.ObjectNumberOfTheFirstObjectInThisXrefSubsectionNotFound); tokens.throwError(PdfException.NumberOfEntriesInThisXrefSubsectionNotFound); tokens.throwError(PdfException.FilePosition1CrossReferenceEntryInThisXrefSubsection); tokens.throwError(PdfException.InvalidCrossReferenceEntryInThisXrefSubsection);
ch = file.read(); if (ch != '>') throwError(IOException.GtNotExpected); type = TokenType.EndDic; break; throwError(IOException.ErrorReadingString); break; throwError(IOException.ErrorReadingString); break;
ch = file.read(); if (ch != '>') throwError(IOException.GtNotExpected); type = TokenType.EndDic; break; throwError(IOException.ErrorReadingString); break; throwError(IOException.ErrorReadingString); break;
|| tokens.getObjNr() != reference.getObjNumber() || tokens.getGenNr() != reference.getGenNumber()) { tokens.throwError(PdfException.InvalidOffsetForObject1, reference.toString());