com.cc.framework.xml
Class XMLHelp

java.lang.Object
  extended bycom.cc.framework.xml.XMLHelp

public abstract class XMLHelp
extends java.lang.Object

Helper for managing XML-Structures

Since:
1.0
Version:
$Revision: 1.20 $
Author:
Harald Schulz

Field Summary
private static java.util.Hashtable ENTITIES
          XML Entities
 
Constructor Summary
private XMLHelp()
          Constructor
 
Method Summary
static java.lang.String asString(org.w3c.dom.Node node)
          Converts the XML Document into a String
static java.lang.String encodeXml(java.lang.String str)
          Method encodeXml
static java.lang.String getAttribute(org.w3c.dom.Node node, java.lang.String attribute)
          Returns the value for an attribute from a node
static java.lang.String getSafeAttribute(org.w3c.dom.Element element, java.lang.String node, java.lang.String attribute)
          Method getSafeAttribute
static java.lang.String getSafeAttribute(org.w3c.dom.Node node, java.lang.String attribute)
          Method getSafeAttribute
static boolean getSafeAttributeBoolean(org.w3c.dom.Node node, java.lang.String attribute, boolean defValue)
          Method getSafeAttributeBoolean
static double getSafeAttributeDouble(org.w3c.dom.Node node, java.lang.String attribute, double defValue)
          Method getSafeAttributeDouble
static int getSafeAttributeInt(org.w3c.dom.Node node, java.lang.String attribute, int defValue)
          Method getSafeAttributeInt
static boolean getSafeBoolean(org.w3c.dom.Node element, java.lang.String node)
          Method getSafeBoolean
static int getSafeInt(org.w3c.dom.Element element, java.lang.String node, int defValue)
          Method getSafeInt
static java.lang.String getSafeString(org.w3c.dom.Element element, java.lang.String node, java.lang.String subNode)
          Method getSafeString
static java.lang.String getSafeString(org.w3c.dom.Node element)
          Method getSafeString
static java.lang.String getSafeString(org.w3c.dom.Node element, java.lang.String node)
          Method getSafeString
static void setNodePrefix(org.w3c.dom.Node node, java.lang.String prefix)
          Sets a node prefix
static boolean toBool(java.lang.String str)
          Converts a string to a boolean
static byte[] toByteVector(org.w3c.dom.Node node)
          Converts a Node to a byte vector
static void writeDomTree(java.io.OutputStream out, org.w3c.dom.Node node)
          Prints the specified node, recursively.
static void writeDomTree(java.io.OutputStream out, org.w3c.dom.Node node, java.nio.charset.Charset encoding)
          Prints the specified node, recursively.
static void writeNode(java.io.PrintStream out, org.w3c.dom.Node node, java.lang.String encoding)
          Prints the specified node, recursively.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTITIES

private static final java.util.Hashtable ENTITIES
XML Entities

Constructor Detail

XMLHelp

private XMLHelp()
Constructor

Method Detail

encodeXml

public static java.lang.String encodeXml(java.lang.String str)
Method encodeXml

Parameters:
str - String to encode
Returns:
String

asString

public static java.lang.String asString(org.w3c.dom.Node node)
                                 throws java.io.IOException
Converts the XML Document into a String

Parameters:
node - Node
Returns:
XML Structure as a String
Throws:
java.io.IOException - If an input or output exception occurred

writeDomTree

public static void writeDomTree(java.io.OutputStream out,
                                org.w3c.dom.Node node)
                         throws java.io.IOException
Prints the specified node, recursively.

Parameters:
out - OutputStream
node - Node
Throws:
java.io.IOException - If an input or output exception occurred

writeDomTree

public static void writeDomTree(java.io.OutputStream out,
                                org.w3c.dom.Node node,
                                java.nio.charset.Charset encoding)
                         throws java.io.IOException
Prints the specified node, recursively.

Parameters:
out - OutputStream
node - Node
encoding - The character encoding
Throws:
java.io.IOException - If an input or output exception occurred

writeNode

public static void writeNode(java.io.PrintStream out,
                             org.w3c.dom.Node node,
                             java.lang.String encoding)
                      throws java.io.IOException
Prints the specified node, recursively.

Parameters:
out - OutputStream
node - Node
encoding - The character encoding
Throws:
java.io.IOException - If an input or output exception occurred

setNodePrefix

public static void setNodePrefix(org.w3c.dom.Node node,
                                 java.lang.String prefix)
                          throws java.io.IOException
Sets a node prefix

Parameters:
node - The node
prefix - The prefix
Throws:
java.io.IOException - If an input or output exception occurred

toByteVector

public static byte[] toByteVector(org.w3c.dom.Node node)
                           throws java.io.IOException
Converts a Node to a byte vector

Parameters:
node - Node
Returns:
byte array
Throws:
java.io.IOException - If an input or output exception occurred

getAttribute

public static java.lang.String getAttribute(org.w3c.dom.Node node,
                                            java.lang.String attribute)
Returns the value for an attribute from a node

Parameters:
node - The node
attribute - The wanted attribute
Returns:
The attribute value

getSafeAttribute

public static java.lang.String getSafeAttribute(org.w3c.dom.Element element,
                                                java.lang.String node,
                                                java.lang.String attribute)
Method getSafeAttribute

Parameters:
element - Element
node - Node
attribute - Attribute
Returns:
String

getSafeAttribute

public static java.lang.String getSafeAttribute(org.w3c.dom.Node node,
                                                java.lang.String attribute)
Method getSafeAttribute

Parameters:
node - Node
attribute - Attribute
Returns:
String

getSafeAttributeBoolean

public static boolean getSafeAttributeBoolean(org.w3c.dom.Node node,
                                              java.lang.String attribute,
                                              boolean defValue)
Method getSafeAttributeBoolean

Parameters:
node - Node
attribute - Attribute
defValue - Default value
Returns:
boolean

getSafeAttributeInt

public static int getSafeAttributeInt(org.w3c.dom.Node node,
                                      java.lang.String attribute,
                                      int defValue)
Method getSafeAttributeInt

Parameters:
node - Node
attribute - Attribute
defValue - The default value
Returns:
integer

getSafeAttributeDouble

public static double getSafeAttributeDouble(org.w3c.dom.Node node,
                                            java.lang.String attribute,
                                            double defValue)
Method getSafeAttributeDouble

Parameters:
node - Node
attribute - Attribute
defValue - default value
Returns:
double

getSafeBoolean

public static boolean getSafeBoolean(org.w3c.dom.Node element,
                                     java.lang.String node)
Method getSafeBoolean

Parameters:
element - Element
node - Node
Returns:
boolean

getSafeInt

public static int getSafeInt(org.w3c.dom.Element element,
                             java.lang.String node,
                             int defValue)
Method getSafeInt

Parameters:
element - Element
node - Node
defValue - The default value
Returns:
integer

getSafeString

public static java.lang.String getSafeString(org.w3c.dom.Node element)
Method getSafeString

Parameters:
element - Element
Returns:
String

getSafeString

public static java.lang.String getSafeString(org.w3c.dom.Element element,
                                             java.lang.String node,
                                             java.lang.String subNode)
Method getSafeString

Parameters:
element - Element
node - Node
subNode - SubNode
Returns:
String

getSafeString

public static java.lang.String getSafeString(org.w3c.dom.Node element,
                                             java.lang.String node)
Method getSafeString

Parameters:
element - Element
node - Node
Returns:
string

toBool

public static boolean toBool(java.lang.String str)
Converts a string to a boolean

Parameters:
str - String to converter
Returns:
true if the argument stands for true; false otherwise.


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.