in velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java [47:123]
public static StringBuilder getSpecialText(Parser parser, Token t)
{
StringBuilder sb = new StringBuilder();
Token tmp_t = t.specialToken;
while (tmp_t.specialToken != null)
{
tmp_t = tmp_t.specialToken;
}
while (tmp_t != null)
{
String st = tmp_t.image;
for(int i = 0, is = st.length(); i < is; i++)
{
char c = st.charAt(i);
if ( c == parser.hash() || c == parser.dollar() )
{
sb.append( c );
}
/*
* more dreaded MORE hack :)
*
* looking for ("\\")*"$" sequences
*/
if ( c == '\\')
{
boolean ok = true;
boolean term = false;
int j = i;
for( ok = true; ok && j < is; j++)
{
char cc = st.charAt( j );
if (cc == '\\')
{
/*
* if we see a \, keep going
*/
continue;
}
else if( cc == parser.dollar() )
{
/*
* a $ ends it correctly
*/
term = true;
ok = false;
}
else
{
/*
* nah...
*/
ok = false;
}
}
if (term)
{
String foo = st.substring( i, j );
sb.append( foo );
i = j;
}
}
}
tmp_t = tmp_t.next;
}
return sb;
}