railo.runtime.schedule
Class StorageUtil

java.lang.Object
  extended by railo.runtime.schedule.StorageUtil

public final class StorageUtil
extends Object


Constructor Summary
StorageUtil()
           
 
Method Summary
 Element getElement(NodeList list, String key, String value)
          return XML Element matching name
 Document loadDocument(Resource file)
          load a XML Document as DOM representation
 Document loadDocument(String content)
           
 void loadFile(File file, String resourcePath)
          create xml file from a resource definition
 void loadFile(Resource res, String resourcePath)
          create xml file from a resource definition
 void setBoolean(Element el, String key, boolean value)
          sets a boolean value to a XML Element
 void setCredentials(Element el, String username, String password, org.apache.commons.httpclient.Credentials credentials)
          sets a Credentials to a XML Element
 void setDateTime(Element el, String key, DateTime value)
          sets a datetime value to a XML Element
 void setFile(Element el, String key, File value)
          sets a file value to a XML Element
 void setFile(Element el, String key, Resource value)
          sets a file value to a XML Element
 void setInt(Element el, String key, int value)
          sets a int value to a XML Element
 void setString(Element el, String key, String value)
          sets a string value to a XML Element
 void store(Document doc, File file)
          store loaded data to xml file
 void store(Document doc, Resource res)
          store loaded data to xml file
 boolean toBoolean(Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a boolean value
 boolean toBoolean(Element el, String attributeName, boolean defaultValue)
          reads a XML Element Attribute ans cast it to a boolean value
 org.apache.commons.httpclient.Credentials toCredentials(Element el, String attributeUser, String attributePassword)
          reads 2 XML Element Attribute ans cast it to a Credential
 org.apache.commons.httpclient.Credentials toCredentials(Element el, String attributeUser, String attributePassword, org.apache.commons.httpclient.Credentials defaultCredentials)
          reads 2 XML Element Attribute ans cast it to a Credential
 Date toDate(Config config, Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a Date Object
 Date toDate(Element el, String attributeName, Date defaultValue)
          reads a XML Element Attribute ans cast it to a Date
 DateTime toDateTime(Config config, Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a DateTime Object
 DateTime toDateTime(Element el, String attributeName, DateTime defaultValue)
          reads a XML Element Attribute ans cast it to a DateTime
 int toInt(Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a int value
 int toInt(Element el, String attributeName, int defaultValue)
          reads a XML Element Attribute ans cast it to a int value
 long toLong(Element el, String attributeName)
           
 Resource toResource(Config config, Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a File
 String toString(Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a String
 String toString(Element el, String attributeName, String defaultValue)
          reads a XML Element Attribute ans cast it to a String
 Time toTime(Config config, Element el, String attributeName)
          reads a XML Element Attribute ans cast it to a Time Object
 Time toTime(Element el, String attributeName, Time defaultValue)
          reads a XML Element Attribute ans cast it to a Date
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageUtil

public StorageUtil()
Method Detail

loadFile

public void loadFile(File file,
                     String resourcePath)
              throws IOException
create xml file from a resource definition

Parameters:
file -
resourcePath -
Throws:
IOException

loadFile

public void loadFile(Resource res,
                     String resourcePath)
              throws IOException
create xml file from a resource definition

Parameters:
res -
resourcePath -
Throws:
IOException

loadDocument

public Document loadDocument(Resource file)
                      throws SAXException,
                             IOException
load a XML Document as DOM representation

Parameters:
file - XML File to load
Returns:
DOM Object
Throws:
SAXException
IOException

loadDocument

public Document loadDocument(String content)
                      throws SAXException,
                             IOException
Throws:
SAXException
IOException

getElement

public Element getElement(NodeList list,
                          String key,
                          String value)
return XML Element matching name

Parameters:
list - source node list
key - key to compare
value - value to compare
Returns:
matching XML Element

store

public void store(Document doc,
                  File file)
           throws IOException
store loaded data to xml file

Parameters:
doc -
file -
Throws:
IOException

store

public void store(Document doc,
                  Resource res)
           throws IOException
store loaded data to xml file

Parameters:
doc -
res -
Throws:
IOException

toString

public String toString(Element el,
                       String attributeName)
reads a XML Element Attribute ans cast it to a String

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toString

public String toString(Element el,
                       String attributeName,
                       String defaultValue)
reads a XML Element Attribute ans cast it to a String

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toResource

public Resource toResource(Config config,
                           Element el,
                           String attributeName)
reads a XML Element Attribute ans cast it to a File

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toBoolean

public boolean toBoolean(Element el,
                         String attributeName)
reads a XML Element Attribute ans cast it to a boolean value

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toBoolean

public boolean toBoolean(Element el,
                         String attributeName,
                         boolean defaultValue)
reads a XML Element Attribute ans cast it to a boolean value

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toInt

public int toInt(Element el,
                 String attributeName)
reads a XML Element Attribute ans cast it to a int value

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toLong

public long toLong(Element el,
                   String attributeName)

toInt

public int toInt(Element el,
                 String attributeName,
                 int defaultValue)
reads a XML Element Attribute ans cast it to a int value

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toDateTime

public DateTime toDateTime(Config config,
                           Element el,
                           String attributeName)
reads a XML Element Attribute ans cast it to a DateTime Object

Parameters:
config -
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toDateTime

public DateTime toDateTime(Element el,
                           String attributeName,
                           DateTime defaultValue)
reads a XML Element Attribute ans cast it to a DateTime

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toDate

public Date toDate(Config config,
                   Element el,
                   String attributeName)
reads a XML Element Attribute ans cast it to a Date Object

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toDate

public Date toDate(Element el,
                   String attributeName,
                   Date defaultValue)
reads a XML Element Attribute ans cast it to a Date

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toTime

public Time toTime(Config config,
                   Element el,
                   String attributeName)
reads a XML Element Attribute ans cast it to a Time Object

Parameters:
config -
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
Returns:
Attribute Value

toTime

public Time toTime(Element el,
                   String attributeName,
                   Time defaultValue)
reads a XML Element Attribute ans cast it to a Date

Parameters:
el - XML Element to read Attribute from it
attributeName - Name of the Attribute to read
defaultValue - if attribute doesn't exist return default value
Returns:
Attribute Value

toCredentials

public org.apache.commons.httpclient.Credentials toCredentials(Element el,
                                                               String attributeUser,
                                                               String attributePassword)
reads 2 XML Element Attribute ans cast it to a Credential

Parameters:
el - XML Element to read Attribute from it
attributeUser - Name of the user Attribute to read
attributePassword - Name of the password Attribute to read
Returns:
Attribute Value

toCredentials

public org.apache.commons.httpclient.Credentials toCredentials(Element el,
                                                               String attributeUser,
                                                               String attributePassword,
                                                               org.apache.commons.httpclient.Credentials defaultCredentials)
reads 2 XML Element Attribute ans cast it to a Credential

Parameters:
el - XML Element to read Attribute from it
attributeUser - Name of the user Attribute to read
attributePassword - Name of the password Attribute to read
defaultCredentials -
Returns:
Attribute Value

setString

public void setString(Element el,
                      String key,
                      String value)
sets a string value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setFile

public void setFile(Element el,
                    String key,
                    File value)
sets a file value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setFile

public void setFile(Element el,
                    String key,
                    Resource value)
sets a file value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setBoolean

public void setBoolean(Element el,
                       String key,
                       boolean value)
sets a boolean value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setInt

public void setInt(Element el,
                   String key,
                   int value)
sets a int value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setDateTime

public void setDateTime(Element el,
                        String key,
                        DateTime value)
sets a datetime value to a XML Element

Parameters:
el - Element to set value on it
key - key to set
value - value to set

setCredentials

public void setCredentials(Element el,
                           String username,
                           String password,
                           org.apache.commons.httpclient.Credentials credentials)
sets a Credentials to a XML Element

Parameters:
el -
username -
password -
credentials -


Copyright © 2012 Railo