*/
public static NodeList tokenize(String toTokenize, String delims)
{
NodeSet resultSet = new NodeSet();
if (delims != null && delims.length() > 0)
{
StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
Document doc = DocumentHolder.m_doc;
synchronized (doc)
{
while (lTokenizer.hasMoreTokens())
{
Element element = doc.createElement("token");
element.appendChild(doc.createTextNode(lTokenizer.nextToken()));
resultSet.addNode(element);
}
}
}
// If the delimiter is an empty string, create one token Element for
// every single character.
else
{
Document doc = DocumentHolder.m_doc;
synchronized (doc)
{
for (int i = 0; i < toTokenize.length(); i++)
{
Element element = doc.createElement("token");
element.appendChild(doc.createTextNode(toTokenize.substring(i, i+1)));
resultSet.addNode(element);
}
}
}
return resultSet;