|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--myoPyx
myoPyx
A PYX document parser.
Still to do:
| Nested Class Summary | |
static interface |
myoPyx.Listener
Implement this to create an object that can listen to myoPyx events. |
| Constructor Summary | |
myoPyx()
|
|
| Method Summary | |
void |
addListener(java.lang.String tag_name,
myoPyx.Listener listener)
Add a listener for parsing events. |
void |
addPIListener(java.util.Observer listener)
Attaches a listener of processing instruction (PI) events. |
void |
parse(java.io.Reader s)
Parses a Reader stream, generating events that are sent to myoPyx.Listeners that are added with addListener() or addPIListener(). |
void |
removeListener(java.lang.String tag_name,
java.lang.Object listener)
Removes a listener. |
void |
removePIListener(java.lang.Object listener)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public myoPyx()
| Method Detail |
public void parse(java.io.Reader s)
throws java.io.IOException,
java.lang.Exception
myoPyx p = new myoPyx();
p.addListener( my_listener );
try {
InputStreamReader input = new InputStreamReader(
new FileInputStream( "my.pyx" );
p.parse( input );
} catch (Exception e) {
e.printStackTrace();
}
java.io.IOException - if there is a problem reading from the
reader
java.lang.Exception - if there is a parsing exception, such as
bad markup or bad document formatting. The error message
will contnain the line number where the error occurred.
public void addListener(java.lang.String tag_name,
myoPyx.Listener listener)
myoPyx.Listener my_listener = new myoPyx.Listener() {
public void startElement( String name, HashMap attrs ) {
System.out.println("MyTag has attributes:");
for (Iterator i=attrs.keys(); i.hasNext(); ) {
Object key = i.next();
System.out.println("\t"+key.toString()+" -> "+
attrs.get(key).toString());
}
}
public void endElement( String name ) { }
public void text( String content ) { }
};
myoPyx.Listener all = new myoPyx.Listener() {
public void startElement( String name, HashMap attrs ) {
System.out.println("Got tag "+name);
}
public void endElement( String name ) { }
public void text( String content ) { }
};
pyx.addListener( null, all );
pyx.addListener( "MyTag", my_listener );
Listeners for all events will be notified before listeners of
specific events. After this, Listeners are notified in the
order they are added.
tag_name - if null, the listener will be notified of all
events. If not null, the listener will be notified of only
events pertaining to elements matching the tag_name.public void addPIListener(java.util.Observer listener)
public void removePIListener(java.lang.Object listener)
public void removeListener(java.lang.String tag_name,
java.lang.Object listener)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||