com.wewebu.ow.server.util
Class OwStandardXMLUtil

java.lang.Object
  extended by com.wewebu.ow.server.util.OwStandardXMLUtil
All Implemented Interfaces:
OwXMLUtil
Direct Known Subclasses:
OwStandardOptionXMLUtil

public class OwStandardXMLUtil
extends Object
implements OwXMLUtil

Implements OwXMLUtil utility class for structured configuration data access.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
static String DEPTH_FIRST_PREORDER
          Defines a search order based on the order in which the searched nodes are encountered in a pre-order traversal of the Document tree.
static String WIDTH_FIRST_LEVEL_ORDER
          Defines a search order based on the order in which the searched nodes are encountered in level-first-order traversal of the Document tree.
 
Constructor Summary
OwStandardXMLUtil()
          construct an empty configuration
OwStandardXMLUtil(InputStream inputStream_p, String strRootNodeName_p)
          Construct the utility class, wrap around the given first root node.
OwStandardXMLUtil(InputStream inputStream_p, String strRootNodeName_p, String rootSearchMode_p)
          Construct the utility class, wrap around the given first root node.
OwStandardXMLUtil(Node node_p)
          construct the utility class, wrap around the given node
 
Method Summary
 String getFileEncoding()
           
protected  String getKeyName(Node node_p)
          (overridable) get the name the node is keyed in the lookup map
 Node getNode()
          return the wrapped DOM Node reference
 boolean getSafeBooleanAttributeValue(String strAttributeName_p, boolean fDefault_p)
          get the value of a boolean attribute [true | false], catch exception
 boolean getSafeBooleanValue(String strNodeName_p, boolean fDefault_p)
          get the value of a sub boolean node [true | false], catch exception
 List getSafeCDATAList()
          retrieve a CDATA strings list in the node
 List getSafeCDATAList(String strNodeName_p)
          retrieve a CDATA string list in a subnode
 int getSafeIntegerAttributeValue(String strAttributeName_p, int iDefault_p)
          get the value of a string attribute, catch exception
 int getSafeIntegerValue(String strNodeName_p, int fDefault_p)
          get the value of a sub Integer node, catch exception
 List getSafeNodeList()
          retrieve a node list in a subnode
 List getSafeNodeList(String strNodeName_p)
          retrieve a node list in a subnode
 String getSafeStringAttributeValue(String strAttributeName_p, String strDefault_p)
          get the value of a string attribute, catch exception
 List getSafeStringList()
          retrieve a string list in the node
 List getSafeStringList(String strNodeName_p)
          retrieve a string list in a subnode
 Set getSafeStringSet(String strNodeName_p)
          retrieve a string list in a subnode
 String getSafeTextValue(String strDefault_p)
          get the value of THE node, catch exception
 String getSafeTextValue(String strNodeName_p, String strDefault_p)
          get the value of a sub text node, catch exception
 List getSafeUtilList(String itemName_p)
          get a list with OwXMLUtil's
 List getSafeUtilList(String nodeName_p, String itemName_p)
          get a list with OwXMLUtil's with the given subname
 Node getSubNode(String strNodeName_p)
          get the subnode with the given tag name
 OwXMLUtil getSubUtil(String strName_p)
          get a sub util node with the given name
 URL getURLFromNode(String nodeName_p)
          Helper method to create an URL from given configuration node.
 void setFileEncoding(String mFileEncoding_p)
           
protected  void setNode(Node node_p)
           
 void writeHtmlDump(Writer w_p)
          write configuration as HTML to a writer object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPTH_FIRST_PREORDER

public static final String DEPTH_FIRST_PREORDER
Defines a search order based on the order in which the searched nodes are encountered in a pre-order traversal of the Document tree.

See Also:
Constant Field Values

WIDTH_FIRST_LEVEL_ORDER

public static final String WIDTH_FIRST_LEVEL_ORDER
Defines a search order based on the order in which the searched nodes are encountered in level-first-order traversal of the Document tree.

See Also:
Constant Field Values
Constructor Detail

OwStandardXMLUtil

public OwStandardXMLUtil()
                  throws Exception
construct an empty configuration

Throws:
Exception

OwStandardXMLUtil

public OwStandardXMLUtil(Node node_p)
                  throws Exception
construct the utility class, wrap around the given node

Parameters:
node_p - DOM Node
Throws:
Exception

OwStandardXMLUtil

public OwStandardXMLUtil(InputStream inputStream_p,
                         String strRootNodeName_p)
                  throws Exception
Construct the utility class, wrap around the given first root node. The search order is DEPTH_FIRST_PREORDER.

Parameters:
inputStream_p - Input Stream with XML Content
strRootNodeName_p - Name of the root node to be wrapped by the utility class. The root node is searched in the order in which nodes are encountered in a pre-order traversal of the Document tree (see DEPTH_FIRST_PREORDER).
Throws:
Exception

OwStandardXMLUtil

public OwStandardXMLUtil(InputStream inputStream_p,
                         String strRootNodeName_p,
                         String rootSearchMode_p)
                  throws Exception
Construct the utility class, wrap around the given first root node.

Parameters:
inputStream_p - Input Stream with XML Content
strRootNodeName_p - Name of the root node to be wrapped by the utility class. The root node is searched in the order given by rootSearchMode_p parameter.
rootSearchMode_p - Defines the search order for the root node search. Must be one of DEPTH_FIRST_PREORDER or WIDTH_FIRST_LEVEL_ORDER.
Throws:
Exception
Method Detail

getKeyName

protected String getKeyName(Node node_p)
(overridable) get the name the node is keyed in the lookup map

Parameters:
node_p -

getSafeStringList

public List getSafeStringList()
retrieve a string list in the node

Specified by:
getSafeStringList in interface OwXMLUtil
Returns:
List of Strings

getSafeCDATAList

public List getSafeCDATAList()
retrieve a CDATA strings list in the node

Specified by:
getSafeCDATAList in interface OwXMLUtil
Returns:
List of CDATA Strings

getSafeCDATAList

public List getSafeCDATAList(String strNodeName_p)
retrieve a CDATA string list in a subnode

Specified by:
getSafeCDATAList in interface OwXMLUtil
Returns:
List of Strings

getSafeStringList

public List getSafeStringList(String strNodeName_p)
retrieve a string list in a subnode

Specified by:
getSafeStringList in interface OwXMLUtil
Parameters:
strNodeName_p - String name of the subnode with the string list
Returns:
List of Strings

getSafeStringSet

public Set getSafeStringSet(String strNodeName_p)
retrieve a string list in a subnode

Specified by:
getSafeStringSet in interface OwXMLUtil
Parameters:
strNodeName_p - String name of the subnode with the string list
Returns:
List of Strings

getSafeStringAttributeValue

public String getSafeStringAttributeValue(String strAttributeName_p,
                                          String strDefault_p)
get the value of a string attribute, catch exception

Specified by:
getSafeStringAttributeValue in interface OwXMLUtil
Parameters:
strAttributeName_p - name of the String attribute
strDefault_p - Default string in case the attribute could not be found
Returns:
string value of attribute or strDefault_p on failure

getSafeIntegerAttributeValue

public int getSafeIntegerAttributeValue(String strAttributeName_p,
                                        int iDefault_p)
get the value of a string attribute, catch exception

Specified by:
getSafeIntegerAttributeValue in interface OwXMLUtil
Parameters:
strAttributeName_p - name of the String attribute
iDefault_p - Default int in case the attribute could not be found
Returns:
int value of attribute or iDefault_p on failure

getSafeBooleanAttributeValue

public boolean getSafeBooleanAttributeValue(String strAttributeName_p,
                                            boolean fDefault_p)
get the value of a boolean attribute [true | false], catch exception

Specified by:
getSafeBooleanAttributeValue in interface OwXMLUtil
Parameters:
strAttributeName_p - name of the String attribute
fDefault_p - Default string in case the attribute could not be found
Returns:
boolean value of attribute or fDefault_p on failure

getSafeBooleanValue

public boolean getSafeBooleanValue(String strNodeName_p,
                                   boolean fDefault_p)
get the value of a sub boolean node [true | false], catch exception

Specified by:
getSafeBooleanValue in interface OwXMLUtil
Parameters:
strNodeName_p - name of the subnode
fDefault_p - Default value in case the node could not be found
Returns:
boolean value of node or fDefault_p on failure

getURLFromNode

public URL getURLFromNode(String nodeName_p)
                   throws MalformedURLException
Helper method to create an URL from given configuration node.

Specified by:
getURLFromNode in interface OwXMLUtil
Parameters:
nodeName_p - String name of child node, where to extract the URL
Returns:
java.net.URL
Throws:
MalformedURLException - if the extracted text is not URL conform string
Since:
4.0.0.0

getSafeIntegerValue

public int getSafeIntegerValue(String strNodeName_p,
                               int fDefault_p)
get the value of a sub Integer node, catch exception

Specified by:
getSafeIntegerValue in interface OwXMLUtil
Parameters:
strNodeName_p - name of the subnode
fDefault_p - Default value in case the node could not be found
Returns:
int value of node or fDefault_p on failure

getSafeTextValue

public String getSafeTextValue(String strNodeName_p,
                               String strDefault_p)
get the value of a sub text node, catch exception

Specified by:
getSafeTextValue in interface OwXMLUtil
Parameters:
strNodeName_p - name of the text subnode
strDefault_p - Default string in case the node could not be found
Returns:
string value of subnode or strDefault_p on failure

getSafeTextValue

public String getSafeTextValue(String strDefault_p)
get the value of THE node, catch exception

Specified by:
getSafeTextValue in interface OwXMLUtil
Parameters:
strDefault_p - Default string in case the node could not be found
Returns:
string value of subnode or strDefault_p on failure

getNode

public Node getNode()
return the wrapped DOM Node reference

Specified by:
getNode in interface OwXMLUtil
Returns:
Node

setNode

protected void setNode(Node node_p)

getSubNode

public Node getSubNode(String strNodeName_p)
                throws Exception
get the subnode with the given tag name

Specified by:
getSubNode in interface OwXMLUtil
Parameters:
strNodeName_p - tag name of requested node
Returns:
org.w3c.dom.Node
Throws:
Exception

getSafeNodeList

public List getSafeNodeList()
retrieve a node list in a subnode

Specified by:
getSafeNodeList in interface OwXMLUtil
Returns:
List of DOM Nodes

getSafeNodeList

public List getSafeNodeList(String strNodeName_p)
retrieve a node list in a subnode

Specified by:
getSafeNodeList in interface OwXMLUtil
Parameters:
strNodeName_p - String name of the subnode with the node list
Returns:
List of DOM Nodes

writeHtmlDump

public void writeHtmlDump(Writer w_p)
                   throws Exception
write configuration as HTML to a writer object

Specified by:
writeHtmlDump in interface OwXMLUtil
Parameters:
w_p - a Writer
Throws:
Exception

getSafeUtilList

public List getSafeUtilList(String nodeName_p,
                            String itemName_p)
Description copied from interface: OwXMLUtil
get a list with OwXMLUtil's with the given subname

Specified by:
getSafeUtilList in interface OwXMLUtil
Parameters:
nodeName_p - the subnode name
itemName_p - the name of the item's or null to retrieve all items
Returns:
a List

getSafeUtilList

public List getSafeUtilList(String itemName_p)
Description copied from interface: OwXMLUtil
get a list with OwXMLUtil's

Specified by:
getSafeUtilList in interface OwXMLUtil
Parameters:
itemName_p - the name of the item's or null to retrieve all items
Returns:
a List

getSubUtil

public OwXMLUtil getSubUtil(String strName_p)
                     throws Exception
Description copied from interface: OwXMLUtil
get a sub util node with the given name

Specified by:
getSubUtil in interface OwXMLUtil
Parameters:
strName_p - the subnode name
Returns:
OwXMLUtil or null if not found
Throws:
Exception

getFileEncoding

public String getFileEncoding()

setFileEncoding

public void setFileEncoding(String mFileEncoding_p)


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.