Skip to content
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

Merged
merged 13 commits into from
Oct 18, 2018
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withSearchPath

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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please help me teach users to use an IonReaderBuilder for constructing IonReaders. I dream of deprecating all of the miscellaneous non-DOM-related utility methods from IonSystem one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Expand Down