Package org.intermine.pathquery
Class PathQueryBinding
- java.lang.Object
-
- org.intermine.pathquery.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
-
Constructor Summary
Constructors Constructor Description PathQueryBinding()
-
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 JSONstatic PathQuery
unmarshalJSONPathQuery(Model model, java.lang.String jsonQueryString)
Parse PathQuery from JSONstatic 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 byModel::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 byModel::getInstanceByName
.
-
-
-
Field Detail
-
INSTANCE
public static final PathQueryBinding INSTANCE
A single instance of this class
-
-
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 PathQueryqueryName
- the name of the querymodelName
- the model nameversion
- 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 PathQueryqueryName
- the name of the querymodelName
- the model namewriter
- the xml stream writer to write toversion
- 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 PathQueryqueryName
- the name of the querymodelName
- the model namewriter
- the xml stream writer to write toversion
- 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 queryconstraint
- the constraint being processedwriter
- 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 queriesversion
- 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 byModel::getInstanceByName
.- Parameters:
reader
- the saved queriesversion
- the version of the xml, an attribute on the profile managermodel
- 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 queriesmodel
- 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 modeljsonQueryString
- 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 XMLversion
- 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 byModel::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.
-
-