|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.proteios.io.TagFactory
public abstract class TagFactory
Extend this factory when you want to read an xml file and create a set of objects out of each tag. Define newCLASS() methods for each tag you want to match returning an object of type CLASS. For each tag that you want to handel implement a done(CLASS c) method.
| Field Summary | |
|---|---|
protected javax.xml.stream.XMLStreamReader |
reader
|
| Constructor Summary | |
|---|---|
TagFactory(javax.xml.stream.XMLStreamReader reader)
|
|
| Method Summary | ||
|---|---|---|
|
create(E template)
This method tries to find a method in this factory named "newCLASS" where the CLASS is the classname of the template. |
|
|
done(E tag)
Tries to find the method done(E) and calls it with the supplied object. |
|
protected Double |
readDouble(String key)
Convenience method to read an attribute and convert it to a Float. |
|
protected Float |
readFloat(String key)
Convenience method to read an attribute and convert it to a Float. |
|
protected Integer |
readInt(String key)
Convenience method to read an attribute and convert it to an Integer |
|
protected Integer |
readInteger(String key)
The same as readInt(String) |
|
protected Long |
readLong(String key)
Convenience method to read an attribute and convert it to a Long |
|
protected String |
readString(String key)
Reads value of the attribute name |
|
protected String |
readText()
Read the content of a tag |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected javax.xml.stream.XMLStreamReader reader
| Constructor Detail |
|---|
public TagFactory(javax.xml.stream.XMLStreamReader reader)
| Method Detail |
|---|
protected String readString(String key)
key - name of the attribute
protected String readText()
protected Long readLong(String key)
key - name of the attribute
NumberFormatException - if the value is not a valid Longprotected Integer readInt(String key)
key - name of the attribute
NumberFormatException - if the value is not a valid Integerprotected Integer readInteger(String key)
key - name of the attribute
protected Float readFloat(String key)
key - name of the attribute
NumberFormatException - if the value is not a Floatprotected Double readDouble(String key)
key - name of the attribute
NumberFormatException - if the value is not a Floatpublic <E extends XMLTag> E create(E template)
E - a XMLTag classtemplate - class to find
public <E extends XMLTag> void done(E tag)
E - tag - to end
|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||