|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mmbase.applications.editwizard.Utils
This class contains static utility methods used by the editwizard. Most methods handle xml functions for you and are just to support ease and lazyness.
| Constructor Summary | |
Utils()
|
|
| Method Summary | |
static java.util.Collection |
appendNodeList(org.w3c.dom.NodeList list,
org.w3c.dom.Node dest)
This method clones, imports and places all nodes in the list. |
static void |
copyAllAttributes(org.w3c.dom.Node source,
org.w3c.dom.Node dest)
Copies all attributes from one node to the other. |
static void |
copyAllAttributes(org.w3c.dom.Node source,
org.w3c.dom.Node dest,
java.util.List except)
Same as above, but now you can supply a Vector with names which should NOT be copied. |
static org.w3c.dom.Node |
createAndAppendNode(org.w3c.dom.Node parentnode,
java.lang.String nodename,
java.lang.String nodevalue)
This method creates a new node, places text and attaches it to the parent. |
static org.w3c.dom.Document |
emptyDocument()
This method returns an empty XMLDocument. |
static java.lang.String |
fillInParams(java.lang.String text,
java.util.Map params)
This method fills in params in a string. |
static java.lang.String |
getAttribute(org.w3c.dom.Node node,
java.lang.String name)
Gets an attribute of an node. |
static java.lang.String |
getAttribute(org.w3c.dom.Node node,
java.lang.String name,
java.lang.String defaultvalue)
Gets an attribute of an node. |
static javax.xml.parsers.DocumentBuilder |
getDocumentBuilder(boolean validate)
This method returns a new instance of a DocumentBuilder. |
static java.lang.String |
getSerializedXML(org.w3c.dom.Node node)
Serialize a node to a string, and return the result. |
static java.lang.String |
getText(org.w3c.dom.Node node)
Returns the text value of the given node |
static java.lang.String |
getText(org.w3c.dom.Node node,
java.lang.String defaultvalue)
Returns the text value of the given node. |
static java.lang.String |
getText(org.w3c.dom.Node node,
java.lang.String defaultvalue,
java.util.Map params)
Returns the text value of the given node. |
static java.lang.String |
getXML(org.w3c.dom.Node node)
Serialize a node and returns the resulting String. |
static java.lang.String |
getXML(org.w3c.dom.NodeList nodeList)
Serialize a nodelist and returns the resulting String (for debugging). |
static org.w3c.dom.Document |
loadXMLFile(java.io.File file)
This method can load a xml file and returns the resulting document. |
static java.lang.String |
multipleReplace(java.lang.String text,
java.lang.String searchfor,
java.lang.String replacewith)
replaces single or multiple occurences of a string in a given source string. |
static org.w3c.dom.Document |
parseXML(java.lang.String xml)
With this method you can parse a xml string and get the resulting Document. |
static void |
printXML(org.w3c.dom.Node node,
java.io.Writer writer)
Serialize a node to the given writer. |
static org.w3c.dom.NodeList |
selectNodeList(org.w3c.dom.Node contextnode,
java.lang.String xpath)
This method selects a multiple nodes using the given contextnode and xpath. |
static org.w3c.dom.Node |
selectSingleNode(org.w3c.dom.Node contextnode,
java.lang.String xpath)
This method selects a single node using the given contextnode and xpath. |
static java.lang.String |
selectSingleNodeText(org.w3c.dom.Node node,
java.lang.String xpath,
java.lang.String defaultvalue)
Selects a single node using the given xpath and uses the given node a a starting context and returns the textnode found. |
static java.lang.String |
selectSingleNodeText(org.w3c.dom.Node node,
java.lang.String xpath,
java.lang.String defaultvalue,
Cloud cloud)
Selects a single node using the given xpath and uses the given node a a starting context and returns the textnode found. |
static void |
setAttribute(org.w3c.dom.Node node,
java.lang.String name,
java.lang.String value)
Sets an attribute of a specific node. |
protected static void |
setStylesheetParams(javax.xml.transform.Transformer transformer,
java.util.Map params)
This method can set the stylesheetparams for a transformer. |
static void |
storeText(org.w3c.dom.Node node,
java.lang.String text)
Same as above, but without the params. |
static void |
storeText(org.w3c.dom.Node node,
java.lang.String text,
java.util.Map params)
This method stores text in a node. |
static java.lang.String |
stringFormatted(org.w3c.dom.Node node)
For debugging purposes. |
static int |
tagNodeList(org.w3c.dom.NodeList list,
java.lang.String name,
java.lang.String pre)
This method tags all nodes in the nodelist. |
static int |
tagNodeList(org.w3c.dom.NodeList list,
java.lang.String name,
java.lang.String pre,
int start)
Same as above, but now you can supply a startnumber. |
static java.lang.String |
transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate)
transforms an attribute. |
static java.lang.String |
transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate,
boolean plainTextIsPath)
same as above, but now you can supply if the given attributeTemplate is already a xpath or not. |
static java.lang.String |
transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate,
boolean plainTextIsXpath,
java.util.Map params)
Executes an attribute template. |
static org.w3c.dom.Node |
transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri)
same as above, but now the result is returned in a new Node and some less params. |
static org.w3c.dom.Node |
transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.util.Map params)
same as above, but now you can supply a params hashtable. |
static void |
transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
javax.xml.transform.Result result,
java.util.Map params)
This method does a standard XSL(T) transform on a node as a base context node and sends it to the given Result result. |
static void |
transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.io.Writer out)
same as above, but now the result is written to the writer. |
static void |
transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.io.Writer out,
java.util.Map params)
same as above, but now the result is written to the writer and you can use params. |
static org.w3c.dom.Node |
transformNode(org.w3c.dom.Node node,
java.lang.String xslFile,
URIResolver uri,
java.io.Writer out,
java.util.Map params)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Utils()
| Method Detail |
public static javax.xml.parsers.DocumentBuilder getDocumentBuilder(boolean validate)
public static org.w3c.dom.Document emptyDocument()
public static org.w3c.dom.Document loadXMLFile(java.io.File file)
throws WizardException
file - the file to be loaded.
WizardException - if the document is invalid
public static org.w3c.dom.Document parseXML(java.lang.String xml)
throws WizardException
xml - The xml string to be parsed. Note that you should supply xml for a valid document (one root node, etc)
WizardException - if something went wrong
public static void printXML(org.w3c.dom.Node node,
java.io.Writer writer)
node - The node to serializewriter - The writer where the stream should be written to.public static java.lang.String getSerializedXML(org.w3c.dom.Node node)
node - The node to serializepublic static java.lang.String getXML(org.w3c.dom.Node node)
node - The node to serialize
public static java.lang.String getXML(org.w3c.dom.NodeList nodeList)
public static void setAttribute(org.w3c.dom.Node node,
java.lang.String name,
java.lang.String value)
node - The node of which the
public static java.lang.String getAttribute(org.w3c.dom.Node node,
java.lang.String name)
node - the node to get the attribute fromname - the attributename requested
public static java.lang.String getAttribute(org.w3c.dom.Node node,
java.lang.String name,
java.lang.String defaultvalue)
node - the node to get the attribute fromname - the attributename requesteddefaultvalue - the defaultvalue what should be returned if attribute was not found.
public static java.lang.String getText(org.w3c.dom.Node node)
node - the node where you want the text from.
public static java.lang.String getText(org.w3c.dom.Node node,
java.lang.String defaultvalue,
java.util.Map params)
node - the node where you want the text from.defaultvalue - of no text is found, this defaultvalue will be returnedparams - params to be used. eg.: $username will be replaced by the values in the hashtable, if a 'username' key is in the hashtable.
public static java.lang.String getText(org.w3c.dom.Node node,
java.lang.String defaultvalue)
node - the node where you want the text from.defaultvalue - if no text is found, this defaultvalue will be returned
public static java.lang.String selectSingleNodeText(org.w3c.dom.Node node,
java.lang.String xpath,
java.lang.String defaultvalue)
node - the contextnode to start the xpath from.xpath - the xpath which should be fired.defaultvalue - this value will be returned when no node is found using the xpath.
public static java.lang.String selectSingleNodeText(org.w3c.dom.Node node,
java.lang.String xpath,
java.lang.String defaultvalue,
Cloud cloud)
node - the contextnode to start the xpath from.xpath - the xpath which should be fired.defaultvalue - this value will be returned when no node is found using the xpath.cloud - the cloud whose locale is to be used for selecting language-specific texts
public static void storeText(org.w3c.dom.Node node,
java.lang.String text,
java.util.Map params)
node - the parentnode on which a textnode should be created or overwritten.text - The text what should be placed in the textnode.params - optional params which should be used in a replace action.
public static void storeText(org.w3c.dom.Node node,
java.lang.String text)
public static java.util.Collection appendNodeList(org.w3c.dom.NodeList list,
org.w3c.dom.Node dest)
public static org.w3c.dom.Node createAndAppendNode(org.w3c.dom.Node parentnode,
java.lang.String nodename,
java.lang.String nodevalue)
parentnode - Place where new node should be appendednodename - the name of the new nodenodevalue - the new nodevalue
public static int tagNodeList(org.w3c.dom.NodeList list,
java.lang.String name,
java.lang.String pre)
list - the nodelistname - the name of the tagspre - the prefix what should be used in the tag-values
public static int tagNodeList(org.w3c.dom.NodeList list,
java.lang.String name,
java.lang.String pre,
int start)
public static void copyAllAttributes(org.w3c.dom.Node source,
org.w3c.dom.Node dest)
source - One nodedest - The other node
public static void copyAllAttributes(org.w3c.dom.Node source,
org.w3c.dom.Node dest,
java.util.List except)
protected static void setStylesheetParams(javax.xml.transform.Transformer transformer,
java.util.Map params)
transformer - The transformer.params - The params to be placed. Standard name/value pairs.
public static void transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
javax.xml.transform.Result result,
java.util.Map params)
throws javax.xml.transform.TransformerException
node - the base context node to run the xsl(t) against.xslFile - the xsl fileresult - The place where to put the result of the transformationparams - Optional params.
javax.xml.transform.TransformerExceptionpublic static java.lang.String stringFormatted(org.w3c.dom.Node node)
public static org.w3c.dom.Node transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri)
throws javax.xml.transform.TransformerException
node - the base context node.xslFile - the xslFile.
javax.xml.transform.TransformerException
public static org.w3c.dom.Node transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.util.Map params)
throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static void transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.io.Writer out)
throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static void transformNode(org.w3c.dom.Node node,
java.io.File xslFile,
URIResolver uri,
java.io.Writer out,
java.util.Map params)
throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static org.w3c.dom.Node transformNode(org.w3c.dom.Node node,
java.lang.String xslFile,
URIResolver uri,
java.io.Writer out,
java.util.Map params)
throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static java.lang.String transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate)
context - the contextnodeattributeTemplate - the template to evaluate.
public static java.lang.String transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate,
boolean plainTextIsPath)
public static java.lang.String transformAttribute(org.w3c.dom.Node context,
java.lang.String attributeTemplate,
boolean plainTextIsXpath,
java.util.Map params)
context - the Node on which any xpaths are fired.attributeTemplate - the String containting an attribute template.plainTextIsXpath - true means that if the template doesn't contain
any curly braces, the template is assumed to be a valid xpath (instead
of plain data). Else the template is assumed to be a valid attribute template.
public static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextnode,
java.lang.String xpath)
contextnode - xpath -
public static org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextnode,
java.lang.String xpath)
contextnode - xpath -
public static java.lang.String fillInParams(java.lang.String text,
java.util.Map params)
text - the source text to be usedparams - the table with params (name/value pairs)
public static java.lang.String multipleReplace(java.lang.String text,
java.lang.String searchfor,
java.lang.String replacewith)
text - the source text (the haystack)searchfor - the needle. the this we're looking forreplacewith - the string which should be placed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||