ASF Bugzilla – Attachment 11754 Details for
Bug 29347
Recursive property expansion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
This new file accompanies the PropertyHandler.java patch and goes in ..ant/util
RecursivePropertyParser.java (text/plain), 3.55 KB, created by
Jack J. Woehr
on 2004-06-03 19:07:19 UTC
(
hide
)
Description:
This new file accompanies the PropertyHandler.java patch and goes in ..ant/util
Filename:
MIME Type:
Creator:
Jack J. Woehr
Created:
2004-06-03 19:07:19 UTC
Size:
3.55 KB
patch
obsolete
>/* > * RecursivePropertyParser.java > * > * Created on June 2, 2004, 3:29 PM > */ > >package org.apache.tools.ant.util; > >/** > * Class of static methods to parse property expressions > * @author jax > */ >public class RecursivePropertyParser { > > /** No marker found in a string search */ > public final static int NO_MARKER = -1; > public final static String OPENER = "${"; > public final static String CLOSER = "}"; > public final static int OPENER_LENGTH = OPENER.length(); > public final static int CLOSER_LENGTH = CLOSER.length(); > > /** Never creates a new instance of RecursivePropertyParser */ > protected RecursivePropertyParser() { > } > > /** > * Find the next expression opener > * > * @param value The source string > * @return The index of the start of the opener, NO_MARKER if not found > */ > public static int nextOpener(final String value, int index) { > int result = NO_MARKER; > if (value != null && !(index > value.length())) { > result = value.indexOf(OPENER, index); > } > return result; > } > > /** > * Find the next expression closer > * > * @param index offsetr in the source string from which to start looking for a closer > * @param value The source string > * @return The index of the closer, NO_MARKER if not found > */ > public static int nextCloser(final String value, int index) { > int result = NO_MARKER; > > if (value != null && !(index > value.length())) { > result = value.indexOf(CLOSER, index); > // /* debug */ System.out.println("nextCloser: result = " + result); > } > return result; > } > > /** > * Finds the balancing expression closer. > * > * @param index offset in the source string from which to start looking for a closer > * @param value The source string > * @return The index of the closer, NO_MARKER if not found > */ > public static int balancingCloser(final String value, int index) { > int result = NO_MARKER; > int lastOpener = index; > if (value != null) { > int unbalancedOpeners = 1; > int currentOpener = nextOpener(value, lastOpener+1); > int currentCloser = nextCloser(value, lastOpener); > > while (unbalancedOpeners > 0) { > // /* debug */ System.out.println("balancingCloser(): unbalancedOpeners=" + unbalancedOpeners +"currentOpener=" + currentOpener + " currentCloser=" + currentCloser); > > // We can't find a matching closing '}' > if (currentCloser == NO_MARKER) { > break; // doom > } > > // We found another '${' before finding a '}' > if (currentOpener != NO_MARKER && currentOpener < currentCloser) { > unbalancedOpeners++; > lastOpener = currentOpener; > currentOpener = nextOpener(value, lastOpener+1); > } > > // We found a closer '}' before any new openers '${' > else { > unbalancedOpeners--; > > if (unbalancedOpeners == 0) { // We're done if we are balanced > result = currentCloser; > } > > else { // We have to go round again trying to find closers to balance > currentCloser=nextCloser(value, currentCloser+1); > } > } > } > } > return result; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 29347
:
11753
| 11754 |
11755
|
11961