org.javalid.core.support
Class XMLSupport

java.lang.Object
  extended by org.javalid.core.support.XMLSupport

public class XMLSupport
extends java.lang.Object

This class provides some support for loading xml files.

Since:
1.0
Version:
1.1
Author:
M.Reuvers

Method Summary
static java.lang.String getAttributeValue(org.w3c.dom.NamedNodeMap map, java.lang.String attributeName, boolean required, java.lang.String defaultValue)
          Method to get a value from an attribute, returns null if not found.
static org.w3c.dom.Document loadDocument(java.lang.String fileName)
          Tries to load given filename using getClass().getResource(..).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadDocument

public static final org.w3c.dom.Document loadDocument(java.lang.String fileName)
Tries to load given filename using getClass().getResource(..). If not found raises JvException

Parameters:
fileName - The filename (full path) to load
Returns:
w3 Document
Throws:
JavalidException - If loading of file fails

getAttributeValue

public static final java.lang.String getAttributeValue(org.w3c.dom.NamedNodeMap map,
                                                       java.lang.String attributeName,
                                                       boolean required,
                                                       java.lang.String defaultValue)
Method to get a value from an attribute, returns null if not found.

Parameters:
map - The map to use
attributeName - The attributeName to lookup in the map
defaultValue - Set if return value would be null, can be left null if you really want null returned
required - Set to true if the method must return a value, raises JvException if attribute would return null.
Returns:
String value if found, null otherwise. If null would be returned and required=true, raises exception.