RFR: 8065554: MatchResult should provide values of named-capturing groups [v2]
Stuart Marks
smarks at openjdk.org
Fri Aug 26 00:50:58 UTC 2022
On Thu, 25 Aug 2022 09:24:20 GMT, Raffaello Giulietti <duke at openjdk.org> wrote:
>> Add support for named groups to java.util.regex.MatchResult
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>
> 8065554: MatchResult should provide values of named-capturing groups
src/java.base/share/classes/java/util/regex/MatchResult.java line 111:
> 109: * The default implementation of this method throws
> 110: * {@link UnsupportedOperationException} if {@link #namedGroups()} is not
> 111: * overridden.
The essential thing for `@implSpec` is to describe "self-use" of methods on this object. This is important for subclassers to know whether they can inherit the default implementation or whether they should override it. It looks like `start(String)` does the following:
- calls namedGroups() to obtain a mapping from group names to group numbers, propagating UOE if namedGroups() throws it
- if `name` is not present in the group map, throws IAE
- calls `start()` on the group number obtained from the map, and returns that value
I don't think we need to go to the level of detail about whether `get` or `containsKey` is called on the map, but I think the self-calls to `namedGroups()` and `start(int)` are important.
Similar comments apply to the `@implSpec` comments of `end(String)` and `group(String)`.
-------------
PR: https://git.openjdk.org/jdk/pull/10000
More information about the core-libs-dev
mailing list