org.apache.ftpserver.config.spring
Class SpringUtil

java.lang.Object
  extended by org.apache.ftpserver.config.spring.SpringUtil

public class SpringUtil
extends java.lang.Object

Various util methods for the Spring config parsing and configuration

Version:
$Rev$, $Date$
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
SpringUtil()
           
 
Method Summary
static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent, java.lang.String ns, java.lang.String localName)
          Get the first child element matching the local name and namespace
static java.util.List<org.w3c.dom.Element> getChildElements(org.w3c.dom.Element elm)
          Get all child elements for the element
static java.lang.String getChildElementText(org.w3c.dom.Element parent, java.lang.String ns, java.lang.String localName)
          Get the text context of first child element matching the local name and namespace
static boolean parseBoolean(org.w3c.dom.Element parent, java.lang.String attrName, boolean defaultValue)
          Parses a attribute value into a boolean.
static java.io.File parseFile(org.w3c.dom.Element parent, java.lang.String attrName)
          Return an attribute value as a File
static java.net.InetAddress parseInetAddress(org.w3c.dom.Element parent, java.lang.String attrName)
          Return an attribute value as an InetAddress
static int parseInt(org.w3c.dom.Element parent, java.lang.String attrName)
          Parses a attribute value into an integer.
static int parseInt(org.w3c.dom.Element parent, java.lang.String attrName, int defaultValue)
          Parses a attribute value into an integer.
static java.lang.Object parseSpringChildElement(org.w3c.dom.Element parent, org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder builder)
          Parse specific Spring elements, bean and ref
static java.lang.String parseString(org.w3c.dom.Element parent, java.lang.String attrName)
          Return the string value of an attribute, or null if the attribute is missing
static java.lang.String parseStringFromInetAddress(org.w3c.dom.Element parent, java.lang.String attrName)
          Return an attribute value after checking it is a valid InetAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringUtil

public SpringUtil()
Method Detail

getChildElements

public static java.util.List<org.w3c.dom.Element> getChildElements(org.w3c.dom.Element elm)
Get all child elements for the element

Parameters:
elm - The element for which to locate children
Returns:
All children

getChildElement

public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent,
                                                  java.lang.String ns,
                                                  java.lang.String localName)
Get the first child element matching the local name and namespace

Parameters:
parent - The element for which to locate the child
ns - The namespace to match, or null for any namespace
localName - The local name to match, or null for any local name
Returns:
The first child matching the criteria

getChildElementText

public static java.lang.String getChildElementText(org.w3c.dom.Element parent,
                                                   java.lang.String ns,
                                                   java.lang.String localName)
Get the text context of first child element matching the local name and namespace

Parameters:
parent - The element for which to locate the child
ns - The namespace to match, or null for any namespace
localName - The local name to match, or null for any local name
Returns:
The text content of the first child matching the criteria or null if element not found

parseSpringChildElement

public static java.lang.Object parseSpringChildElement(org.w3c.dom.Element parent,
                                                       org.springframework.beans.factory.xml.ParserContext parserContext,
                                                       org.springframework.beans.factory.support.BeanDefinitionBuilder builder)
Parse specific Spring elements, bean and ref

Parameters:
parent - The element in which we will look for Spring elements
parserContext - The Spring parser context
builder - The Spring bean definition builder
Returns:
The Spring bean definition

parseBoolean

public static boolean parseBoolean(org.w3c.dom.Element parent,
                                   java.lang.String attrName,
                                   boolean defaultValue)
Parses a attribute value into a boolean. If the attribute is missing or has no content, a default value is returned

Parameters:
parent - The element
attrName - The attribute name
defaultValue - The default value
Returns:
The value, or the default value

parseInt

public static int parseInt(org.w3c.dom.Element parent,
                           java.lang.String attrName)
Parses a attribute value into an integer.

Parameters:
parent - The element
attrName - The attribute name
Returns:
The value
Throws:
java.lang.NumberFormatException - If the attribute does not contain a number

parseInt

public static int parseInt(org.w3c.dom.Element parent,
                           java.lang.String attrName,
                           int defaultValue)
Parses a attribute value into an integer. If the attribute is missing or has no content, a default value is returned

Parameters:
parent - The element
attrName - The attribute name
defaultValue - The default value
Returns:
The value, or the default value

parseString

public static java.lang.String parseString(org.w3c.dom.Element parent,
                                           java.lang.String attrName)
Return the string value of an attribute, or null if the attribute is missing

Parameters:
parent - The element
attrName - The attribute name
Returns:
The attribute string value

parseFile

public static java.io.File parseFile(org.w3c.dom.Element parent,
                                     java.lang.String attrName)
Return an attribute value as a File

Parameters:
parent - The element
attrName - The attribute name
Returns:
The file representing the path used in the attribute

parseInetAddress

public static java.net.InetAddress parseInetAddress(org.w3c.dom.Element parent,
                                                    java.lang.String attrName)
Return an attribute value as an InetAddress

Parameters:
parent - The element
attrName - The attribute name
Returns:
The attribute value parsed into a InetAddress

parseStringFromInetAddress

public static java.lang.String parseStringFromInetAddress(org.w3c.dom.Element parent,
                                                          java.lang.String attrName)
Return an attribute value after checking it is a valid InetAddress

Parameters:
parent - The element
attrName - The attribute name
Returns:
The attribute string value.


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.