|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.uc3m.it.xbe32.XBE32ElementParser
This XBE32ParseListener
is able to process a XBE32-encoded
stream and return all its XBE32 Elements as a tree.
Once the full stream is parsed the rootElements()
method will return
the list of the upper XBE32 Elements, that could contain themselves other
XBE32 Elements, both Attrbiutes or Complex ones. If just a single XBE32
Element is parsed, use the getFirstElement()
method to obtain it.
For example, the following sequence of XBE32ParseListener
events:
listener.startParsing(); listener.complexElementStart(false, 0x0001, "service", false, false); listener.attributeElement(false, 0x2102, "type", false, false, XBE32Element.STRING_VALUE_TYPE, "printer"); listener.attributeElement(false, 0x2C03, "addr", false, false, XBE32Element.OPAQUE4_VALUES_TYPE, new byte[][] {{ 0xA9, 0xFE, 0x55, 0x8B }}); listener.attributeElement(false, 0x2904, "ports", false, false, XBE32Element.INT16_VALUES_TYPE, new short[] { 515, 631 }); listener.complexElementStart(false, 0x0003, "options", true, true); listener.attributeElement(true, 0x000006, "color", false, true, XBE32Element.BOOLEAN_VALUES_TYPE, new boolean[] { false }); listener.attributeElement(true, 0, "ppm", true, false, XBE32Element.FLOAT32_VALUES_TYPE, new float[] { 20.5 }); listener.complexElementEnd(false, 0x0003, "options", true, true); listener.complexElementEnd(false, 0x0001, "service", false, false); listener.endParsing(76);
It would create a root XBE32 Element with the same result as the following code:
XBE32Element root, elem; XBE32Element attr; root = new XBE32Element(false, 0x0001, "service", false, false); listener.rootElements().add(elem); attr = new XBE32Element(false, 0x2102, "type", false, false, XBE32Element.STRING_VALUE_TYPE, "printer"); root.subelements.add(attr); attr = new XBE32Element(false, 0x2C03, "addr", false, false, XBE32Element.OPAQUE4_VALUES_TYPE, new byte[][] {{ 0xA9, 0xFE, 0x55, 0x8B }}); root.subelements.add(attr); attr = new XBE32Element(false, 0x2904, "ports", false, false, XBE32Element.INT16_VALUES_TYPE, new short[] { 515, 631 }); root.subelements.add(attr); elem = new XBE32Element(false, 0x0003, "options", true, true); root.subelements.add(elem); attr = new XBE32Element(true, 0x000006, "color", false, true, XBE32Element.BOOLEAN_VALUES_TYPE, new boolean[] { false }); elem.subelements.add(attr); attr = new XBE32Element(true, 0, "ppm", true, false, XBE32Element.FLOAT32_VALUES_TYPE, new float[] { 20.5 }); elem.subelements.add(attr);
XBE32Element
,
XBE32Parser.setListener()
,
XBE32Reader.setListener()
Constructor Summary | |
XBE32ElementParser()
Creates a new XBE32ElementParser listener. |
Method Summary | |
void |
attributeElement(boolean ext,
int id,
String name,
boolean c,
boolean e,
int type,
Object val)
This method is called when an Attribute Element is processed by the XBE32Parser . |
void |
complexElementEnd(boolean ext,
int id,
String name,
boolean c,
boolean e)
This method is called when a Complex Element has been just processed by the XBE32Parser . |
void |
complexElementStart(boolean ext,
int id,
String name,
boolean c,
boolean e)
This method is called when a Complex Element is found by the XBE32Parser . |
void |
endParsing(int length)
This method is called when the XBE32Parser successfully ends
parsing the full XBE32-encoded stream. |
XBE32Element |
getFirstElement()
Returns the first root XBE32 Element that has been parsed. |
Vector |
rootElements()
Returns the list of XBE32 Elements located at the upper-level of the XBE32-encoded stream. |
void |
startParsing()
This method is called when the XBE32Parser.parse() method is
called, thus the parsing process starts. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XBE32ElementParser()
Method Detail |
public Vector rootElements()
XBE32Parser.parse()
public XBE32Element getFirstElement()
XBE32Parser.parseElement()
public void startParsing()
XBE32ParseListener
XBE32Parser.parse()
method is
called, thus the parsing process starts.
startParsing
in interface XBE32ParseListener
XBE32Parser.parse()
public void complexElementStart(boolean ext, int id, String name, boolean c, boolean e) throws XBE32ParseException
XBE32ParseListener
XBE32Parser
.
complexElementStart
in interface XBE32ParseListener
ext
- whether the Complex Element that to be parsed is an Extensible
or a Compact oneid
- the identifier of the Complex Element to be parsedname
- the name of the Complex Element to be parsedc
- the Continue flag of the Complex Element to be parsede
- the Notify Error flag of the Complex Element to be parsed
XBE32ParseException
- the listener may throw this exception if any
syntax error occurs while processing this eventXBE32Parser.parse()
,
XBE32Parser.parseElement()
public void complexElementEnd(boolean ext, int id, String name, boolean c, boolean e) throws XBE32ParseException
XBE32ParseListener
XBE32Parser
.
complexElementEnd
in interface XBE32ParseListener
ext
- whether the Complex Element that has been parsed is an extensible
or a compact oneid
- the identifier of the Complex Element that has been parsedname
- the name of the Complex Element that has been parsedc
- the Continue flag of the Complex Element that has been parsede
- the Notify Error flag of the Complex Element that has beee
parsed
XBE32ParseException
- the listener may throw this exception if any
syntax error occurs while processing this eventXBE32Parser.parse()
,
XBE32Parser.parseElement()
public void attributeElement(boolean ext, int id, String name, boolean c, boolean e, int type, Object val) throws XBE32ParseException
XBE32ParseListener
XBE32Parser
.
attributeElement
in interface XBE32ParseListener
ext
- whether the Attrbiute Element being parsed is an Extensible or
a Compact oneid
- the identifier of the Attribute Element being parsedname
- the name of the Attribute Element being parsedc
- the Continue flag of the Attribute Element being parsede
- the Notify Error flag of the Attribute Element being parsedtype
- the Type of the Attribute's Value being parsedval
- the Values field of the Attribute Element being parsed
XBE32ParseException
- the listener may throw this exception if any
syntax error occurs while processing this eventXBE32Element.OPAQUE_VALUE_TYPE
,
XBE32Element.STRING_VALUE_TYPE
,
XBE32Element.OPAQUE1_VALUES_TYPE
,
XBE32Element.INT8_VALUES_TYPE
,
XBE32Element.BOOLEAN_VALUES_TYPE
,
XBE32Element.OPAQUE2_VALUES_TYPE
,
XBE32Element.INT16_VALUES_TYPE
,
XBE32Element.OPAQUE4_VALUES_TYPE
,
XBE32Element.INT32_VALUES_TYPE
,
XBE32Element.FLOAT32_VALUES_TYPE
,
XBE32Element.OPAQUE8_VALUES_TYPE
,
XBE32Element.INT64_VALUES_TYPE
,
XBE32Element.FLOAT64_VALUES_TYPE
,
XBE32Element.OPAQUE12_VALUES_TYPE
,
XBE32Element.OPAQUE16_VALUES_TYPE
,
XBE32Parser.parse()
,
XBE32Parser.parseElement()
public void endParsing(int length)
XBE32ParseListener
XBE32Parser
successfully ends
parsing the full XBE32-encoded stream.
endParsing
in interface XBE32ParseListener
XBE32Parser.parse()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |