{
m_simpleString = stringedValue; // then do the simple thing
}
else
{
FastStringBuffer buffer = null;
FastStringBuffer exprBuffer = null;
if(USE_OBJECT_POOL){
buffer = StringBufferPool.get();
exprBuffer = StringBufferPool.get();
}else{
buffer = new FastStringBuffer(6);
exprBuffer = new FastStringBuffer(6);
}
try
{
m_parts = new Vector(nTokens + 1);
String t = null; // base token
String lookahead = null; // next token
String error = null; // if non-null, break from loop
while (tokenizer.hasMoreTokens())
{
if (lookahead != null)
{
t = lookahead;
lookahead = null;
}
else
t = tokenizer.nextToken();
if (t.length() == 1)
{
switch (t.charAt(0))
{
case ('\"') :
case ('\'') :
{
// just keep on going, since we're not in an attribute template
buffer.append(t);
break;
}
case ('{') :
{
try
{
// Attribute Value Template start
lookahead = tokenizer.nextToken();
if (lookahead.equals("{"))
{
// Double curlys mean escape to show curly
buffer.append(lookahead);
lookahead = null;
break; // from switch
}
/*
else if(lookahead.equals("\"") || lookahead.equals("\'"))
{
// Error. Expressions can not begin with quotes.
error = "Expressions can not begin with quotes.";
break; // from switch
}
*/
else
{
if (buffer.length() > 0)
{
m_parts.addElement(new AVTPartSimple(buffer.toString()));
buffer.setLength(0);
}
exprBuffer.setLength(0);
while (null != lookahead)
{
if (lookahead.length() == 1)
{
switch (lookahead.charAt(0))
{
case '\'' :
case '\"' :
{
// String start
exprBuffer.append(lookahead);
String quote = lookahead;
// Consume stuff 'till next quote
lookahead = tokenizer.nextToken();
while (!lookahead.equals(quote))
{
exprBuffer.append(lookahead);
lookahead = tokenizer.nextToken();
}
exprBuffer.append(lookahead);
lookahead = tokenizer.nextToken();
break;
}
case '{' :
{
// What's another curly doing here?
error = XSLMessages.createMessage(
XSLTErrorResources.ER_NO_CURLYBRACE, null); //"Error: Can not have \"{\" within expression.";
lookahead = null; // breaks out of inner while loop
break;
}
case '}' :
{
// Proper close of attribute template.
// Evaluate the expression.
buffer.setLength(0);
XPath xpath =
handler.createXPath(exprBuffer.toString(), owner);
m_parts.addElement(new AVTPartXPath(xpath));
lookahead = null; // breaks out of inner while loop
break;
}
default :
{
// part of the template stuff, just add it.
exprBuffer.append(lookahead);
lookahead = tokenizer.nextToken();
}
} // end inner switch
} // end if lookahead length == 1
else
{
// part of the template stuff, just add it.
exprBuffer.append(lookahead);
lookahead = tokenizer.nextToken();
}
} // end while(!lookahead.equals("}"))