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

Check if valid FpML document #1982

Merged
merged 2 commits into from May 29, 2019
Merged

Check if valid FpML document #1982

merged 2 commits into from May 29, 2019

Conversation

@jodastephen
Copy link
Member

@jodastephen jodastephen commented May 24, 2019

Provide method to check if document is FpML.
Build on top of filtered parse method in XmlFile.

Provide method to check if document is FpML
Build on top of filtered parse method in `XmlFile`
* Parses the element names and structure from the specified XML, filtering to reduce memory usage.
* <p>
* This parses the specified byte source expecting an XML file format.
* The filter function should return the number of levels below the current one
Copy link
Contributor

@headphonejack headphonejack May 28, 2019

Choose a reason for hiding this comment

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

The filter function operates on the element name and... maybe?

* This parses the specified byte source expecting an XML file format.
* The filter function should return the number of levels below the current one
* that should be included in the response.
* Always returning {@code Integer.MAX_VALUE} will not filter the children.
Copy link
Contributor

@headphonejack headphonejack May 28, 2019

Choose a reason for hiding this comment

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

So the range of Integer.MIN_VALUE <= x < 0 is invalid values? Talking of which Integer.MIN_VALUE could cause interesting behaviour underflowing back to MAX_VALUE, which would remain for all children, and have the same effect as MAX_VALUE!

* <p>
* Sometimes, the FpML document is embedded in a non-FpML wrapper.
* This method will intelligently find the FpML document at the root or within one or two levels
* of wrapper by searching for an element that contains both {@code <trade>} and {@code <party>}.
Copy link
Contributor

@headphonejack headphonejack May 28, 2019

Choose a reason for hiding this comment

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

of wrapper missing a word?

@@ -216,7 +272,7 @@ private static XmlElement findFpmlRoot(XmlElement root) {
}
}
}
throw new FpmlParseException("Unable to find FpML root element");
return null;
Copy link
Contributor

@headphonejack headphonejack May 28, 2019

Choose a reason for hiding this comment

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

Is this a deliberate decision to avoid Optional for performance?

Copy link
Member Author

@jodastephen jodastephen May 28, 2019

Choose a reason for hiding this comment

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

There is no need to use Optional between two private methods of the same class. Sometimes it may make sense for other reasons, but didn't seem to do so here.

@jodastephen jodastephen merged commit bcfb572 into master May 29, 2019
15 checks passed
@delete-merged-branch delete-merged-branch bot deleted the topic/fpml branch May 29, 2019
@jodastephen jodastephen added this to the v2.4 milestone May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants