-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PathExtraction initinal implementaion #1
Changes from 1 commit
33ad390
304a356
7a22315
aaaa169
7536374
ec97718
90ab6dd
9788b3a
0ef0b5d
ae5525c
1fd9398
9697962
f96a8f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,37 @@ Each time the `PathExtractor` encounters a value that matches a registered searc | |
callback passing the reader positioned at the current value. See `PathExtractorBuilder#register` methods for more | ||
information on the callback contract. | ||
|
||
### Examples: | ||
|
||
```java | ||
// Capture all matched values into a List | ||
final IonSystem ion = IonSystemBuilder.standard().build(); | ||
|
||
final List<IonValue> list = new ArrayList<>(); | ||
final Function<IonReader, Integer> callback = (reader) -> { | ||
IonValue ionValue = ion.newValue(reader); | ||
list.add(ionValue); | ||
|
||
return 0; | ||
}; | ||
|
||
final PathExtractor pathExtractor = PathExtractorBuilder.standard() | ||
.register("(foo)", callback) | ||
.register("(bar)", callback) | ||
.register("(baz 1)", callback) | ||
.build(); | ||
|
||
IonReader ionReader = ion.newReader("{foo: 1}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please help me teach users to use an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. Also added a test for the example to avoid breaking in the future, which already happened... |
||
+ "{bar: 2}" | ||
+ "{baz: [10,20,30,40]}" | ||
+ "{other: 99}" | ||
); | ||
|
||
pathExtractor.match(ionReader); | ||
|
||
// list will contain 1, 2 and 20 | ||
``` | ||
|
||
## Ion Developer information | ||
See the developer guide on: http://amzn.github.io/ion-docs/guides/path-extractor-guide.html | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withSearchPath