-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] Reduce the ammount of duplicate code between regex functions
- Loading branch information
1 parent
9c652d3
commit 29c4489
Showing
5 changed files
with
153 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ | |
import org.exist.xquery.value.StringValue; | ||
import org.exist.xquery.value.Type; | ||
|
||
import static org.exist.xquery.regex.RegexUtil.*; | ||
|
||
/** | ||
* @author Wolfgang Meier ([email protected]) | ||
*/ | ||
|
@@ -166,7 +168,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc | |
} else { | ||
final int flags; | ||
if (getSignature().getArgumentCount() == 4) { | ||
flags = parseFlags(getArgument(3).eval(contextSequence, contextItem).getStringValue()); | ||
flags = parseFlags(this, getArgument(3).eval(contextSequence, contextItem).getStringValue()); | ||
} else { | ||
flags = 0; | ||
} | ||
|
@@ -187,7 +189,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc | |
.replace("\\", "\\\\") | ||
.replace("$", "\\$"); | ||
} else { | ||
pattern = translateRegexp(patternSeq.getStringValue(), hasIgnoreWhitespace(flags), hasCaseInsensitive(flags)); | ||
pattern = translateRegexp(this, patternSeq.getStringValue(), hasIgnoreWhitespace(flags), hasCaseInsensitive(flags)); | ||
} | ||
|
||
//An error is raised [err:FORX0004] if the value of $replacement contains a "$" character that is not immediately followed by a digit 0-9 and not immediately preceded by a "\". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import org.exist.xquery.value.ValueSequence; | ||
|
||
import static org.exist.xquery.FunctionDSL.*; | ||
import static org.exist.xquery.regex.RegexUtil.*; | ||
|
||
/** | ||
* @author Wolfgang Meier ([email protected]) | ||
|
@@ -100,7 +101,7 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr | |
} else { | ||
final int flags; | ||
if (getSignature().getArgumentCount() == 3) { | ||
flags = parseFlags(getArgument(2).eval(contextSequence, contextItem) | ||
flags = parseFlags(this, getArgument(2).eval(contextSequence, contextItem) | ||
.getStringValue()); | ||
} else { | ||
flags = 0; | ||
|
@@ -117,7 +118,7 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr | |
} else { | ||
final boolean ignoreWhitespace = hasIgnoreWhitespace(flags); | ||
final boolean caseBlind = !hasCaseInsensitive(flags); | ||
pattern = translateRegexp(getArgument(1).eval(contextSequence, contextItem).getStringValue(), ignoreWhitespace, caseBlind); | ||
pattern = translateRegexp(this, getArgument(1).eval(contextSequence, contextItem).getStringValue(), ignoreWhitespace, caseBlind); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.