tecgraf.javautils.excel.v1.util
Class XmlNode

java.lang.Object
  extended by tecgraf.javautils.excel.v1.util.XmlNode
All Implemented Interfaces:
Comparable<XmlNode>

public class XmlNode
extends Object
implements Comparable<XmlNode>

Estrutura simples de Xml para fazer parse. O parse pode ser feito pelo construtor da classe.

Author:
bernardobreder

Nested Class Summary
static class XmlNode.StringInputStream
          Leitor de String em UTF8
 
Constructor Summary
XmlNode(InputStream input, boolean onlyHeader)
          Construtor
XmlNode(String name)
          Construtor
 
Method Summary
 XmlNode addNode(XmlNode node)
          Adiciona uma tag
 XmlNode addNodes(Collection<XmlNode> list)
          Adiciona varios nodes
 int compareTo(XmlNode o)
          
 boolean equals(Object obj)
          
 String getAttribute(String attribute)
          Indica se tem o atributo
 Boolean getAttribute(String attribute, Boolean defaultValue)
          Indica se tem o atributo
 Double getAttribute(String attribute, Double defaultValue)
          Indica se tem o atributo
 Float getAttribute(String attribute, Float defaultValue)
          Indica se tem o atributo
 Integer getAttribute(String attribute, Integer defaultValue)
          Indica se tem o atributo
 Long getAttribute(String attribute, Long defaultValue)
          Indica se tem o atributo
 String getAttribute(String attribute, String defaultValue)
          Indica se tem o atributo
 Map<String,String> getAttributes()
           
 byte[] getBytes()
          Recupera os bytes do xml
 String getName()
           
 XmlNode getNodeByAttributeContainValue(String attribute, String value)
           
 XmlNode getNodeByAttributeKey(String attribute, String value)
           
 XmlNode getNodeByAttributeMatchValue(String attribute, String value)
           
 XmlNode getNodeByAttributeValue(String attribute, String value)
           
 XmlNode getNodeByTagName(String name)
           
 int getNodeCount()
           
 SortedSet<XmlNode> getNodes()
           
 List<XmlNode> getNodesByAttributeContainValue(String attribute, String value)
           
 List<XmlNode> getNodesByAttributeKey(String attribute, String value)
           
 List<XmlNode> getNodesByAttributeMatchValue(String attribute, String value)
           
 List<XmlNode> getNodesByAttributeValue(String attribute, String value)
           
 List<XmlNode> getNodesByTagName(String name)
           
 boolean hasAttribute(String attribute)
          Indica se tem o atributo
 int hashCode()
          
 XmlNode setAttribute(String key, String value)
          Adiciona ou modifica um atributo
 XmlNode setName(String name)
           
 String toString()
          
 void write(OutputStream output)
          Escreve no output
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlNode

public XmlNode(String name)
Construtor

Parameters:
name -

XmlNode

public XmlNode(InputStream input,
               boolean onlyHeader)
        throws ParseException,
               IOException
Construtor

Parameters:
input -
onlyHeader -
Throws:
ParseException
IOException
Method Detail

getName

public String getName()
Returns:
the name

getAttributes

public Map<String,String> getAttributes()
Returns:
the attributes

hasAttribute

public boolean hasAttribute(String attribute)
Indica se tem o atributo

Parameters:
attribute -
Returns:
tem o atributo

getAttribute

public String getAttribute(String attribute)
Indica se tem o atributo

Parameters:
attribute -
Returns:
tem o atributo

getAttribute

public Integer getAttribute(String attribute,
                            Integer defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

getAttribute

public String getAttribute(String attribute,
                           String defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

getAttribute

public Double getAttribute(String attribute,
                           Double defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

getAttribute

public Long getAttribute(String attribute,
                         Long defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

getAttribute

public Float getAttribute(String attribute,
                          Float defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

getAttribute

public Boolean getAttribute(String attribute,
                            Boolean defaultValue)
Indica se tem o atributo

Parameters:
attribute -
defaultValue -
Returns:
tem o atributo

setAttribute

public XmlNode setAttribute(String key,
                            String value)
Adiciona ou modifica um atributo

Parameters:
key -
value -
Returns:
owner

setName

public XmlNode setName(String name)
Parameters:
name - the name to set
Returns:
this

getNodes

public SortedSet<XmlNode> getNodes()
Returns:
the nodes

getNodeCount

public int getNodeCount()
Returns:
the nodes

addNode

public XmlNode addNode(XmlNode node)
Adiciona uma tag

Parameters:
node -
Returns:
owner

addNodes

public XmlNode addNodes(Collection<XmlNode> list)
Adiciona varios nodes

Parameters:
list -
Returns:
this

getNodesByTagName

public List<XmlNode> getNodesByTagName(String name)
Parameters:
name -
Returns:
the nodes

getNodesByAttributeValue

public List<XmlNode> getNodesByAttributeValue(String attribute,
                                              String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodesByAttributeKey

public List<XmlNode> getNodesByAttributeKey(String attribute,
                                            String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodesByAttributeContainValue

public List<XmlNode> getNodesByAttributeContainValue(String attribute,
                                                     String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodesByAttributeMatchValue

public List<XmlNode> getNodesByAttributeMatchValue(String attribute,
                                                   String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodeByTagName

public XmlNode getNodeByTagName(String name)
Parameters:
name -
Returns:
the nodes

getNodeByAttributeValue

public XmlNode getNodeByAttributeValue(String attribute,
                                       String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodeByAttributeKey

public XmlNode getNodeByAttributeKey(String attribute,
                                     String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodeByAttributeContainValue

public XmlNode getNodeByAttributeContainValue(String attribute,
                                              String value)
Parameters:
attribute -
value -
Returns:
the nodes

getNodeByAttributeMatchValue

public XmlNode getNodeByAttributeMatchValue(String attribute,
                                            String value)
Parameters:
attribute -
value -
Returns:
the nodes

toString

public String toString()

Overrides:
toString in class Object

getBytes

public byte[] getBytes()
                throws IOException
Recupera os bytes do xml

Returns:
bytes
Throws:
IOException

write

public void write(OutputStream output)
           throws IOException
Escreve no output

Parameters:
output -
Throws:
IOException

compareTo

public int compareTo(XmlNode o)

Specified by:
compareTo in interface Comparable<XmlNode>

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object


Copyright © 2014 Tecgraf/PUC-Rio. All rights reserved.