/** * This is used to read the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the document */ private EventNode read() throws Exception { int event = parser.next(); if(event != END_DOCUMENT) { if(event == START_TAG){ return start(); } if(event == TEXT) { return text(); } if(event == END_TAG) { return end(); } return read(); } return null; }
/** * This is used to peek at the node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode peek() throws Exception { if(peek == null) { peek = next(); } return peek; }
/** * This provides an <code>EventReader</code> that will read from * the specified input stream. When reading from an input stream * the character encoding should be taken from the XML prolog or * it should default to the UTF-8 character encoding. * * @param source this is the stream to read the document with * * @return this is used to return the event reader implementation */ public EventReader provide(InputStream source) throws Exception { XmlPullParser parser = factory.newPullParser(); if(source != null) { parser.setInput(source, null); } return new PullReader(parser); }
/** * This is used to take the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode next() throws Exception { EventNode next = peek; if(next == null) { next = read(); } else { peek = null; } return next; }
/** * This is used to convert the next event to a start event. The * conversion process ensures the node can be digested by the core * reader and used to provide an <code>InputNode</code> that can * be used to represent an XML elements within the source document. * * @return this returns a start event created from the parser */ private Start start() throws Exception { Start event = new Start(parser); if(event.isEmpty()) { return build(event); } return event; }
/** * This is used to build the attributes that are to be used to * populate the start event. Populating the start event with the * attributes it contains is required so that each element will * contain its associated attributes. Only attributes that are * not reserved will be added to the start event. * * @param event this is the start event that is to be populated * * @return this returns a start event with its attributes */ private Start build(Start event) throws Exception { int count = parser.getAttributeCount(); for(int i = 0; i < count; i++) { Entry entry = attribute(i); if(!entry.isReserved()) { event.add(entry); } } return event; }
/** * This provides an <code>EventReader</code> that will read from * the specified input stream. When reading from an input stream * the character encoding should be taken from the XML prolog or * it should default to the UTF-8 character encoding. * * @param source this is the stream to read the document with * * @return this is used to return the event reader implementation */ public EventReader provide(InputStream source) throws Exception { XmlPullParser parser = factory.newPullParser(); if(source != null) { parser.setInput(source, null); } return new PullReader(parser); }
/** * This is used to take the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode next() throws Exception { EventNode next = peek; if(next == null) { next = read(); } else { peek = null; } return next; }
/** * This is used to convert the next event to a start event. The * conversion process ensures the node can be digested by the core * reader and used to provide an <code>InputNode</code> that can * be used to represent an XML elements within the source document. * * @return this returns a start event created from the parser */ private Start start() throws Exception { Start event = new Start(parser); if(event.isEmpty()) { return build(event); } return event; }
/** * This is used to build the attributes that are to be used to * populate the start event. Populating the start event with the * attributes it contains is required so that each element will * contain its associated attributes. Only attributes that are * not reserved will be added to the start event. * * @param event this is the start event that is to be populated * * @return this returns a start event with its attributes */ private Start build(Start event) throws Exception { int count = parser.getAttributeCount(); for(int i = 0; i < count; i++) { Entry entry = attribute(i); if(!entry.isReserved()) { event.add(entry); } } return event; }
/** * This is used to read the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the document */ private EventNode read() throws Exception { int event = parser.next(); if(event != END_DOCUMENT) { if(event == START_TAG){ return start(); } if(event == TEXT) { return text(); } if(event == END_TAG) { return end(); } return read(); } return null; }
/** * This provides an <code>EventReader</code> that will read from * the specified reader. When reading from a reader the character * encoding should be the same as the source XML document. * * @param source this is the reader to read the document with * * @return this is used to return the event reader implementation */ public EventReader provide(Reader source) throws Exception { XmlPullParser parser = factory.newPullParser(); if(source != null) { parser.setInput(source); } return new PullReader(parser); } }
/** * This is used to peek at the node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode peek() throws Exception { if(peek == null) { peek = next(); } return peek; }
/** * This is used to take the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode next() throws Exception { EventNode next = peek; if(next == null) { next = read(); } else { peek = null; } return next; }
/** * This is used to convert the next event to a start event. The * conversion process ensures the node can be digested by the core * reader and used to provide an <code>InputNode</code> that can * be used to represent an XML elements within the source document. * * @return this returns a start event created from the parser */ private Start start() throws Exception { Start event = new Start(parser); if(event.isEmpty()) { return build(event); } return event; }
/** * This is used to build the attributes that are to be used to * populate the start event. Populating the start event with the * attributes it contains is required so that each element will * contain its associated attributes. Only attributes that are * not reserved will be added to the start event. * * @param event this is the start event that is to be populated * * @return this returns a start event with its attributes */ private Start build(Start event) throws Exception { int count = parser.getAttributeCount(); for(int i = 0; i < count; i++) { Entry entry = attribute(i); if(!entry.isReserved()) { event.add(entry); } } return event; }
/** * This is used to read the next node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the document */ private EventNode read() throws Exception { int event = parser.next(); if(event != END_DOCUMENT) { if(event == START_TAG){ return start(); } if(event == TEXT) { return text(); } if(event == END_TAG) { return end(); } return read(); } return null; }
/** * This provides an <code>EventReader</code> that will read from * the specified reader. When reading from a reader the character * encoding should be the same as the source XML document. * * @param source this is the reader to read the document with * * @return this is used to return the event reader implementation */ public EventReader provide(Reader source) throws Exception { XmlPullParser parser = factory.newPullParser(); if(source != null) { parser.setInput(source); } return new PullReader(parser); } }
/** * This is used to peek at the node from the document. This will * scan through the document, ignoring any comments to find the * next relevant XML event to acquire. Typically events will be * the start and end of an element, as well as any text nodes. * * @return this returns the next event taken from the source XML */ public EventNode peek() throws Exception { if(peek == null) { peek = next(); } return peek; }
/** * This provides an <code>EventReader</code> that will read from * the specified input stream. When reading from an input stream * the character encoding should be taken from the XML prolog or * it should default to the UTF-8 character encoding. * * @param source this is the stream to read the document with * * @return this is used to return the event reader implementation */ public EventReader provide(InputStream source) throws Exception { XmlPullParser parser = factory.newPullParser(); if(source != null) { parser.setInput(source, null); } return new PullReader(parser); }