/** * This is the actual line number within the read XML document. * The line number allows any problems within the source XML * document to be debugged if it does not match the schema. * This will return -1 if the line number cannot be determined. * * @return this returns the line number of an XML event */ public int getLine() { return source.getLine(); }
/** * Returns the name of the node that this represents. This is * an immutable property and should not change for any node. * This provides the name without the name space part. * * @return returns the name of the node that this represents */ public String getName() { return node.getName(); }
/** * This is used to acquire the namespace prefix for the node. * If there is no namespace prefix for the node then this will * return null. Acquiring the prefix enables the qualification * of the node to be determined. It also allows nodes to be * grouped by its prefix and allows group operations. * * @return this returns the prefix associated with this node */ public String getPrefix() { return node.getPrefix(); }
/** * Read the contents of the characters between the specified XML * element tags, if the read is currently at that element. This * allows characters associated with the element to be used. If * the specified node is not the current node, null is returned. * * @param from this is the input node to read the value from * * @return this returns the characters from the specified node */ private void fillText(InputNode from) throws Exception { EventNode event = reader.peek(); if(event.isText()) { String data = event.getValue(); text.append(data); } }
/** * Returns the next input node from the XML document, if it is a * child element of the specified input node. This essentially * determines whether the end tag has been read for the specified * node, if so then null is returned. If however the specified * node has not had its end tag read then this returns the next * element, if that element is a child of the that node. * * @param from this is the input node to read with * * @return this returns the next input node from the document */ public InputNode readElement(InputNode from) throws Exception { if(!stack.isRelevant(from)) { return null; } EventNode event = reader.next(); while(event != null) { if(event.isEnd()) { if(stack.pop() == from) { return null; } } else if(event.isStart()) { return readStart(from, event); } event = reader.next(); } return null; }
/** * This is used to determine if this input node is empty. An * empty node is one with no attributes or children. This can * be used to determine if a given node represents an empty * entity, with which no extra data can be extracted. * * @param from this is the input node to read the value from * * @return this returns true if the node is an empty element * * @throws Exception thrown if there was a parse error */ public boolean isEmpty(InputNode from) throws Exception { if(stack.top() == from) { EventNode event = reader.peek(); if(event.isEnd()) { return true; } } return false; }
/** * This is used to return the source object for this node. This * is used primarily as a means to determine which XML provider * is parsing the source document and producing the nodes. It * is useful to be able to determine the XML provider like this. * * @return this returns the source of this input node */ public Object getSource() { return node.getSource(); }
/** * This allows the namespace reference URI to be determined. * A reference is a globally unique string that allows the * node to be identified. Typically the reference will be a URI * but it can be any unique string used to identify the node. * This allows the node to be identified within the namespace. * * @return this returns the associated namespace reference URI */ public String getReference() { return node.getReference(); }
/** * This is used to convert the start element to an input node. * This will push the created input node on to the stack. The * input node created contains a reference to this reader. so * that it can be used to read child elements and values. * * @param from this is the parent element for the start event * @param event this is the start element to be wrapped * * @return this returns an input node for the given element */ private InputNode readStart(InputNode from, EventNode event) throws Exception { InputElement input = new InputElement(from, this, event); if(text.length() > 0) { text.setLength(0); } if(event.isStart()) { return stack.push(input); } return input; }
/** * Read the contents of the characters between the specified XML * element tags, if the read is currently at that element. This * allows characters associated with the element to be used. If * the specified node is not the current node, null is returned. * * @param from this is the input node to read the value from * * @return this returns the characters from the specified node */ private String readText(InputNode from) throws Exception { EventNode event = reader.peek(); while(stack.top() == from) { if(event.isText()) { fillText(from); } else { break; } event = reader.next(); event = reader.peek(); } return readBuffer(from); }
/** * Read the contents of the characters between the specified XML * element tags, if the read is currently at that element. This * allows characters associated with the element to be used. If * the specified node is not the current node, null is returned. * * @param from this is the input node to read the value from * * @return this returns the characters from the specified node */ private void fillText(InputNode from) throws Exception { EventNode event = reader.peek(); if(event.isText()) { String data = event.getValue(); text.append(data); } }
/** * Returns the next input node from the XML document, if it is a * child element of the specified input node. This essentially * determines whether the end tag has been read for the specified * node, if so then null is returned. If however the specified * node has not had its end tag read then this returns the next * element, if that element is a child of the that node. * * @param from this is the input node to read with * * @return this returns the next input node from the document */ public InputNode readElement(InputNode from) throws Exception { if(!stack.isRelevant(from)) { return null; } EventNode event = reader.next(); while(event != null) { if(event.isEnd()) { if(stack.pop() == from) { return null; } } else if(event.isStart()) { return readStart(from, event); } event = reader.next(); } return null; }
/** * This is used to determine if this input node is empty. An * empty node is one with no attributes or children. This can * be used to determine if a given node represents an empty * entity, with which no extra data can be extracted. * * @param from this is the input node to read the value from * * @return this returns true if the node is an empty element * * @throws Exception thrown if there was a parse error */ public boolean isEmpty(InputNode from) throws Exception { if(stack.top() == from) { EventNode event = reader.peek(); if(event.isEnd()) { return true; } } return false; }
/** * This is used to return the source object for this node. This * is used primarily as a means to determine which XML provider * is parsing the source document and producing the nodes. It * is useful to be able to determine the XML provider like this. * * @return this returns the source of this input node */ public Object getSource() { return node.getSource(); }
/** * This allows the namespace reference URI to be determined. * A reference is a globally unique string that allows the * node to be identified. Typically the reference will be a URI * but it can be any unique string used to identify the node. * This allows the node to be identified within the namespace. * * @return this returns the associated namespace reference URI */ public String getReference() { return node.getReference(); }
/** * This is used to convert the start element to an input node. * This will push the created input node on to the stack. The * input node created contains a reference to this reader. so * that it can be used to read child elements and values. * * @param from this is the parent element for the start event * @param event this is the start element to be wrapped * * @return this returns an input node for the given element */ private InputNode readStart(InputNode from, EventNode event) throws Exception { InputElement input = new InputElement(from, this, event); if(text.length() > 0) { text.setLength(0); } if(event.isStart()) { return stack.push(input); } return input; }
/** * Read the contents of the characters between the specified XML * element tags, if the read is currently at that element. This * allows characters associated with the element to be used. If * the specified node is not the current node, null is returned. * * @param from this is the input node to read the value from * * @return this returns the characters from the specified node */ private String readText(InputNode from) throws Exception { EventNode event = reader.peek(); while(stack.top() == from) { if(event.isText()) { fillText(from); } else { break; } event = reader.next(); event = reader.peek(); } return readBuffer(from); }