Class FpmlDocumentParser


  • public final class FpmlDocumentParser
    extends java.lang.Object
    Loader of trade data in FpML format.

    This handles the subset of FpML necessary to populate the trade model. The standard parsers accept FpML v5.8, which is often the same as earlier versions.

    The trade parsers implement FpmlParserPlugin and are pluggable using the FpmlParserPlugin.ini configuration file.

    • Method Detail

      • of

        public static FpmlDocumentParser of​(FpmlPartySelector ourPartySelector,
                                            FpmlTradeInfoParserPlugin tradeInfoParser,
                                            java.util.Map<java.lang.String,​FpmlParserPlugin> tradeParsers)
        Obtains an instance of the parser, based on the specified selector and plugins.

        The FpML parser has a number of plugin points that can be controlled:

        This method uses the standard reference data.
        Parameters:
        ourPartySelector - the selector used to find "our" party within the set of parties in the FpML document
        tradeInfoParser - the trade info parser
        tradeParsers - the map of trade parsers, keyed by the FpML element name
        Returns:
        the document parser
      • of

        public static FpmlDocumentParser of​(FpmlPartySelector ourPartySelector,
                                            FpmlTradeInfoParserPlugin tradeInfoParser,
                                            java.util.Map<java.lang.String,​FpmlParserPlugin> tradeParsers,
                                            ReferenceData refData)
        Obtains an instance of the parser, based on the specified selector and plugins.

        The FpML parser has a number of plugin points that can be controlled:

        Parameters:
        ourPartySelector - the selector used to find "our" party within the set of parties in the FpML document
        tradeInfoParser - the trade info parser
        tradeParsers - the map of trade parsers, keyed by the FpML element name
        refData - the reference data to use
        Returns:
        the document parser
      • parseTrades

        public java.util.List<Trade> parseTrades​(com.google.common.io.ByteSource source)
        Parses FpML from the specified source, extracting the trades.

        This parses the specified byte source which must be an XML document.

        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 <trade> and <party>.

        Parameters:
        source - the source of the FpML XML document
        Returns:
        the parsed trades
        Throws:
        java.lang.RuntimeException - if a parse error occurred
      • parseTrades

        public java.util.List<Trade> parseTrades​(XmlElement fpmlRootEl,
                                                 java.util.Map<java.lang.String,​XmlElement> references)
        Parses the FpML document extracting the trades.

        This parses the specified FpML root element, using the map of references. The FpML specification uses references to link one part of the XML to another. For example, if one part of the XML has <foo id="fooId">, the references map will contain an entry mapping "fooId" to the parsed element <foo>.

        Parameters:
        fpmlRootEl - the source of the FpML XML document
        references - the map of id/href to referenced element
        Returns:
        the parsed trades
        Throws:
        java.lang.RuntimeException - if a parse error occurred