public class ReplacementString
extends java.lang.Object
implements java.lang.Cloneable
Unless specified otherwise, the default group reference indicator is '$'. It may be escaped using the backslash '\' and will appear as such in the canonical string of this object. However, instead of escaping '$', other characters may be used as group reference indicator, typically the backslash it self is used for this purpose.
Constructor and Description |
---|
ReplacementString(java.lang.String replacementString)
Creates a new ReplacementString with the specified pattern and the current
default group reference indicator.
|
ReplacementString(java.lang.String replacementString,
char groupReference)
Creates a new ReplacementString with the specified pattern and group reference indicator.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a copy of this object.
|
boolean |
doesApply(java.util.regex.Pattern pattern)
Verifies that this replacement string may be applied to the regex pattern.
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getCanonicalString()
Returns the canonical form of this replacement string object using '$' as group reference indicator.
|
char |
getGroupReferenceIndicator()
Returns the group reference indicator that was used in the
original replacement string.
|
int |
getMaxGroupReference()
Returns the highest group reference in the replacement pattern.
|
java.lang.String |
getOriginalString()
Returns the replacement string as it was supplied with the constructor.
|
int |
hashCode() |
static void |
setDefaultGroupReferenceIndicator(char groupReference)
Sets the default group reference indicator that applies for new instances created
with the single argument constructor.
|
java.lang.String |
toString()
Returns a string representation of this object, actually the canonical form of the replacement string.
|
public ReplacementString(java.lang.String replacementString)
replacementString
- with capturing group referencespublic ReplacementString(java.lang.String replacementString, char groupReference)
replacementString
- with capturing group referencesgroupReference
- group reference indicatorpublic static void setDefaultGroupReferenceIndicator(char groupReference)
groupReference
- default group reference indicatorpublic boolean doesApply(java.util.regex.Pattern pattern)
pattern
- possibly containing capturing groupspublic int getMaxGroupReference()
public java.lang.String getCanonicalString()
public java.lang.String getOriginalString()
public char getGroupReferenceIndicator()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object