|
xmlgraphics-commons 2.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(InputStream in)
Creates a new DSC parser. |
|
| Method Summary | |
|---|---|
void |
addListener(DSCListener listener)
Adds a DSC event listener. |
DSCEvent |
getCurrentEvent()
Returns the current event. |
InputStream |
getInputStream()
Returns the InputStream the PostScript code is read from. |
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. |
boolean |
isListenersDisabled()
Indicates whether the listeners are currently disabled. |
int |
next()
Steps to the next item indicating the type of event. |
DSCComment |
nextDSCComment(String name)
Advances to the next DSC comment with the given name. |
DSCComment |
nextDSCComment(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(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 String |
readLine()
Reads one line from the input file |
void |
removeListener(DSCListener listener)
Removes a DSC event listener. |
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 |
setListenersDisabled(boolean value)
Allows to disable all listeners. |
void |
setNestedDocumentHandler(NestedDocumentHandler handler)
Sets a NestedDocumentHandler which is used to skip nested documents like embedded EPS files. |
protected void |
warn(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(InputStream in)
throws IOException,
DSCException
in - InputStream to read the PostScript file from
(the stream is not closed by this class, the caller is responsible for that)
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC spec| Method Detail |
|---|
public InputStream getInputStream()
protected void warn(String msg)
msg - the warning message
protected String readLine()
throws IOException,
DSCException
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC spec
public void parse(DSCHandler handler)
throws IOException,
DSCException
handler - the DSCHandler instance to send the events to
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC specpublic boolean hasNext()
public int next()
throws IOException,
DSCException
DSCParserConstants)
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC spec
NoSuchElementException - If an attempt was made to advance beyond the end of the file
public DSCEvent nextEvent()
throws IOException,
DSCException
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 IOException,
DSCException
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC specpublic String getLine()
IllegalStateException - if the current event is not a normal PostScript line
public DSCComment nextDSCComment(String name)
throws IOException,
DSCException
name - the name of the DSC comment
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC spec
public DSCComment nextDSCComment(String name,
PSGenerator gen)
throws IOException,
DSCException
name - the name of the DSC commentgen - PSGenerator to pass the skipped events though to
IOException - In case of an I/O error
DSCException - In case of a violation of the DSC spec
public PostScriptComment nextPSComment(String prefix,
PSGenerator gen)
throws 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
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 addListener(DSCListener listener)
listener - the listenerpublic void removeListener(DSCListener listener)
listener - the listener to removepublic void setListenersDisabled(boolean value)
value - true to disable all listeners, false to re-enable thempublic boolean isListenersDisabled()
public void setNestedDocumentHandler(NestedDocumentHandler handler)
It is suggested to use the more generally usable addListener(DSCListener) and
removeListener(DSCListener) instead. NestedDocumentHandler is internally
mapped onto a DSCListener.
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 2.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||