it.geosolutions.tools.commons.string
Class Regex
java.lang.Object
it.geosolutions.tools.commons.string.Regex
public class Regex
- extends Object
- Author:
- Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
Constructor Summary |
Regex()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Regex
public Regex()
replace
public static final String replace(String template,
String regex,
String value,
boolean all)
- replace the string 'value' into the string 'template' where the string 'regex' matches.
- Parameters:
template - regex - value - all - if true replace all the occurrence
- Returns:
- the modified string if success (find), null otherwise (bad pattern or something else)
resolveTemplate
public static final String resolveTemplate(String template,
Map<String,String> map)
- resolve the 'template' String looking for keys found into the passed map substituting their
values into the template.
- Parameters:
template - map -
- Returns:
resolveDelimitedTemplate
public static final String resolveDelimitedTemplate(String suffix,
String postfix,
String template,
Map<String,String> map)
- /**
resolve the 'template' String looking for keys found into the passed map substituting their
values into the template. The keys into the template should be into the form: prefixKEYpostfix
NOTE: only [A-z] characters are permitted for keys.
F.E.:
template -> ${ROOT}/${PATH}/${TO}/${FILE}
map:
ROOT, /opt
PATH, program
AT, url
FILE, file.txt
returns:
The string: /opt/program//file.txt
modify map removing all but the not found keys:
AT, url
- Parameters:
suffix - postfix - template - map -
- Returns:
- modify the Map leaving only not found keys and return the resolved
template string or null if any arguments are null with no changes to the map
Copyright © 2011-2012 GeoSolutions. All Rights Reserved.