Class PathQueryBinding

  • Direct Known Subclasses:
    TemplateQueryBinding

    public class PathQueryBinding
    extends java.lang.Object
    Convert PathQueries to and from XML or JSON
    Author:
    Matthew Wakeling
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static PathQueryBinding INSTANCE
      A single instance of this class
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doAdditionalConstraintStuff​(PathQuery query, PathConstraint constraint, javax.xml.stream.XMLStreamWriter writer)
      Adds any extra information for a constraint, like say Template extras.
      void doMarshal​(PathQuery query, java.lang.String queryName, java.lang.String modelName, javax.xml.stream.XMLStreamWriter writer, int version)
      Marshal to an XMLStreamWriter.
      static java.lang.String marshal​(PathQuery query, java.lang.String queryName, java.lang.String modelName, int version)
      Convert a PathQuery to XML.
      static void marshal​(PathQuery query, java.lang.String queryName, java.lang.String modelName, javax.xml.stream.XMLStreamWriter writer, int version)
      Marshal to an XMLStreamWriter.
      static java.util.Map<java.lang.String,​PathQuery> unmarshalJSONPathQueries​(java.io.Reader reader, Model model)
      Parse PathQueries from JSON
      static PathQuery unmarshalJSONPathQuery​(Model model, java.lang.String jsonQueryString)
      Parse PathQuery from JSON
      static java.util.Map<java.lang.String,​PathQuery> unmarshalPathQueries​(java.io.Reader reader, int version)
      Parse PathQueries from XML.
      static java.util.Map<java.lang.String,​PathQuery> unmarshalPathQueries​(java.io.Reader reader, int version, Model model)
      Parse PathQueries from XML, declaring which model should be used in preference to the default model retrieved by Model::getInstanceByName.
      static PathQuery unmarshalPathQuery​(java.io.Reader reader, int version)
      Parses PathQuery from XML.
      static PathQuery unmarshalPathQuery​(java.io.Reader reader, int version, Model model)
      Parses a PathQuery from XML, declaring which model should be used in preference to the default model retrieved by Model::getInstanceByName.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final PathQueryBinding INSTANCE
        A single instance of this class
    • Constructor Detail

      • PathQueryBinding

        public PathQueryBinding()
    • Method Detail

      • marshal

        public static java.lang.String marshal​(PathQuery query,
                                               java.lang.String queryName,
                                               java.lang.String modelName,
                                               int version)
        Convert a PathQuery to XML.
        Parameters:
        query - the PathQuery
        queryName - the name of the query
        modelName - the model name
        version - the version number of the xml format, an attribute of the ProfileManager
        Returns:
        the corresponding XML String
      • marshal

        public static void marshal​(PathQuery query,
                                   java.lang.String queryName,
                                   java.lang.String modelName,
                                   javax.xml.stream.XMLStreamWriter writer,
                                   int version)
        Marshal to an XMLStreamWriter.
        Parameters:
        query - the PathQuery
        queryName - the name of the query
        modelName - the model name
        writer - the xml stream writer to write to
        version - the version number of the xml format, an attribute of the ProfileManager
      • doMarshal

        public void doMarshal​(PathQuery query,
                              java.lang.String queryName,
                              java.lang.String modelName,
                              javax.xml.stream.XMLStreamWriter writer,
                              int version)
        Marshal to an XMLStreamWriter.
        Parameters:
        query - the PathQuery
        queryName - the name of the query
        modelName - the model name
        writer - the xml stream writer to write to
        version - the version number of the xml format, an attribute of the ProfileManager
      • doAdditionalConstraintStuff

        public void doAdditionalConstraintStuff​(PathQuery query,
                                                PathConstraint constraint,
                                                javax.xml.stream.XMLStreamWriter writer)
                                         throws javax.xml.stream.XMLStreamException
        Adds any extra information for a constraint, like say Template extras.
        Parameters:
        query - the query
        constraint - the constraint being processed
        writer - a writer to add data to
        Throws:
        javax.xml.stream.XMLStreamException - if something goes wrong
      • unmarshalPathQueries

        public static java.util.Map<java.lang.String,​PathQuery> unmarshalPathQueries​(java.io.Reader reader,
                                                                                           int version)
        Parse PathQueries from XML.
        Parameters:
        reader - the saved queries
        version - the version of the xml, an attribute on the profile manager
        Returns:
        a Map from query name to PathQuery
      • unmarshalPathQueries

        public static java.util.Map<java.lang.String,​PathQuery> unmarshalPathQueries​(java.io.Reader reader,
                                                                                           int version,
                                                                                           Model model)
        Parse PathQueries from XML, declaring which model should be used in preference to the default model retrieved by Model::getInstanceByName.
        Parameters:
        reader - the saved queries
        version - the version of the xml, an attribute on the profile manager
        model - The model to use in preference. May be null.
        Returns:
        a Map from query name to PathQuery
      • unmarshalJSONPathQueries

        public static java.util.Map<java.lang.String,​PathQuery> unmarshalJSONPathQueries​(java.io.Reader reader,
                                                                                               Model model)
        Parse PathQueries from JSON
        Parameters:
        reader - the saved queries
        model - The model to use in preference. May be null.
        Returns:
        a Map from query name to PathQuery
      • unmarshalJSONPathQuery

        public static PathQuery unmarshalJSONPathQuery​(Model model,
                                                       java.lang.String jsonQueryString)
                                                throws org.json.JSONException
        Parse PathQuery from JSON
        Parameters:
        model - the data model
        jsonQueryString - the query in JSON format
        Returns:
        a Map from query name to PathQuery
        Throws:
        org.json.JSONException - if poorly formatted JSON
      • unmarshalPathQuery

        public static PathQuery unmarshalPathQuery​(java.io.Reader reader,
                                                   int version)
        Parses PathQuery from XML.
        Parameters:
        reader - reader containing XML
        version - the version of the xml, an attribute on the profile manager
        Returns:
        PathQuery
      • unmarshalPathQuery

        public static PathQuery unmarshalPathQuery​(java.io.Reader reader,
                                                   int version,
                                                   Model model)
        Parses a PathQuery from XML, declaring which model should be used in preference to the default model retrieved by Model::getInstanceByName.
        Parameters:
        reader - The source of the model XML.
        version - The version of the path-query format.
        model - The model to use in preference. May be null.
        Returns:
        The path-query, or null if none were found.