public final class StorageUtil extends Object
Constructor and Description |
---|
StorageUtil() |
Modifier and Type | Method and Description |
---|---|
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,
Credentials c)
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
|
Credentials |
toCredentials(Element el,
String attributeUser,
String attributePassword)
reads 2 XML Element Attribute ans cast it to a Credential
|
Credentials |
toCredentials(Element el,
String attributeUser,
String attributePassword,
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
|
public StorageUtil()
public void loadFile(File file, String resourcePath) throws IOException
file
- resourcePath
- IOException
public void loadFile(Resource res, String resourcePath) throws IOException
res
- resourcePath
- IOException
public Document loadDocument(Resource file) throws SAXException, IOException
file
- XML File to loadSAXException
IOException
public Document loadDocument(String content) throws SAXException, IOException
SAXException
IOException
public Element getElement(NodeList list, String key, String value)
list
- source node listkey
- key to comparevalue
- value to comparepublic void store(Document doc, File file) throws IOException
doc
- file
- IOException
public void store(Document doc, Resource res) throws IOException
doc
- res
- IOException
public String toString(Element el, String attributeName)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic String toString(Element el, String attributeName, String defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic Resource toResource(Config config, Element el, String attributeName)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic boolean toBoolean(Element el, String attributeName)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic boolean toBoolean(Element el, String attributeName, boolean defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic int toInt(Element el, String attributeName)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic int toInt(Element el, String attributeName, int defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic DateTime toDateTime(Config config, Element el, String attributeName)
config
- el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic DateTime toDateTime(Element el, String attributeName, DateTime defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic Date toDate(Config config, Element el, String attributeName)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic Date toDate(Element el, String attributeName, Date defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic Time toTime(Config config, Element el, String attributeName)
config
- el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readpublic Time toTime(Element el, String attributeName, Time defaultValue)
el
- XML Element to read Attribute from itattributeName
- Name of the Attribute to readdefaultValue
- if attribute doesn't exist return default valuepublic Credentials toCredentials(Element el, String attributeUser, String attributePassword)
el
- XML Element to read Attribute from itattributeUser
- Name of the user Attribute to readattributePassword
- Name of the password Attribute to readpublic Credentials toCredentials(Element el, String attributeUser, String attributePassword, Credentials defaultCredentials)
el
- XML Element to read Attribute from itattributeUser
- Name of the user Attribute to readattributePassword
- Name of the password Attribute to readdefaultCredentials
- public void setString(Element el, String key, String value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setFile(Element el, String key, File value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setFile(Element el, String key, Resource value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setBoolean(Element el, String key, boolean value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setInt(Element el, String key, int value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setDateTime(Element el, String key, DateTime value)
el
- Element to set value on itkey
- key to setvalue
- value to setpublic void setCredentials(Element el, String username, String password, Credentials c)
el
- username
- password
- credentials
- Copyright © 2015 Lucee