|
xmlgraphics-commons 1.3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xmlgraphics.ps.dsc.DSCParser
public class DSCParser
Parser for DSC-compliant PostScript files (DSC = Document Structuring Conventions). The parser is implemented as a pull parser but has the ability to act as a push parser through the DSCHandler interface.
Field Summary |
---|
Fields inherited from interface org.apache.xmlgraphics.ps.dsc.DSCParserConstants |
---|
COMMENT, DSC_COMMENT, EOF, HEADER_COMMENT, LINE |
Constructor Summary | |
---|---|
DSCParser(java.io.InputStream in)
Creates a new DSC parser. |
Method Summary | |
---|---|
DSCEvent |
getCurrentEvent()
Returns the current event. |
java.io.InputStream |
getInputStream()
Returns the InputStream the PostScript code is read from. |
java.lang.String |
getLine()
Returns the current PostScript line. |
boolean |
hasNext()
Indicates whether there are additional items. |
boolean |
isCheckEOF()
Indicates whether the parser is configured to check for content after the EOF comment. |
int |
next()
Steps to the next item indicating the type of event. |
DSCComment |
nextDSCComment(java.lang.String name)
Advances to the next DSC comment with the given name. |
DSCComment |
nextDSCComment(java.lang.String name,
PSGenerator gen)
Advances to the next DSC comment with the given name. |
DSCEvent |
nextEvent()
Steps to the next item returning the new event. |
PostScriptComment |
nextPSComment(java.lang.String prefix,
PSGenerator gen)
Advances to the next PostScript comment with the given prefix. |
void |
parse(DSCHandler handler)
Starts the parser in push parsing mode sending events to the DSCHandler instance. |
protected void |
parseNext()
Parses the next event. |
DSCEvent |
peek()
Returns the next event without moving the cursor to the next event. |
protected java.lang.String |
readLine()
Reads one line from the input file |
void |
setCheckEOF(boolean value)
Tells the parser whether to check for content after the EOF comment. |
void |
setFilter(DSCFilter filter)
Sets a filter for DSC events. |
void |
setNestedDocumentHandler(NestedDocumentHandler handler)
Sets a NestedDocumentHandler which is used to skip nested documents like embedded EPS files. |
protected void |
warn(java.lang.String msg)
This method is used to write out warning messages for the parsing process. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DSCParser(java.io.InputStream in) throws java.io.IOException, DSCException
in
- InputStream to read the PostScript file from
(the stream is not closed by this class, the caller is responsible for that)
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specMethod Detail |
---|
public java.io.InputStream getInputStream()
protected void warn(java.lang.String msg)
msg
- the warning messageprotected java.lang.String readLine() throws java.io.IOException, DSCException
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic void parse(DSCHandler handler) throws java.io.IOException, DSCException
handler
- the DSCHandler instance to send the events to
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic boolean hasNext()
public int next() throws java.io.IOException, DSCException
DSCParserConstants
)
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC spec
java.util.NoSuchElementException
- If an attempt was made to advance beyond the end of the filepublic DSCEvent nextEvent() throws java.io.IOException, DSCException
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic DSCEvent getCurrentEvent()
public DSCEvent peek()
protected void parseNext() throws java.io.IOException, DSCException
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic java.lang.String getLine()
java.lang.IllegalStateException
- if the current event is not a normal PostScript linepublic DSCComment nextDSCComment(java.lang.String name) throws java.io.IOException, DSCException
name
- the name of the DSC comment
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic DSCComment nextDSCComment(java.lang.String name, PSGenerator gen) throws java.io.IOException, DSCException
name
- the name of the DSC commentgen
- PSGenerator to pass the skipped events though to
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic PostScriptComment nextPSComment(java.lang.String prefix, PSGenerator gen) throws java.io.IOException, DSCException
Example: To find FOP's custom comments, pass in "FOP" as a prefix. This will find comments like "%FOPFontSetup".
prefix
- the prefix of the extension commentgen
- PSGenerator to pass the skipped events though to
java.io.IOException
- In case of an I/O error
DSCException
- In case of a violation of the DSC specpublic void setFilter(DSCFilter filter)
filter
- the filter to use or null to disable filteringpublic void setNestedDocumentHandler(NestedDocumentHandler handler)
handler
- the NestedDocumentHandler instance or null to disable the featurepublic void setCheckEOF(boolean value)
value
- true if the check is enabledpublic boolean isCheckEOF()
|
xmlgraphics-commons 1.3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |