Class IqlQuery


  • public class IqlQuery
    extends java.lang.Object
    OQL representation of an object-based Query
    Author:
    Andrew Varley, Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      IqlQuery()
      No-arg constructor (for deserialization)
      IqlQuery​(java.lang.String queryString, java.lang.String packageName)
      Construct an IQL query from a String.
      IqlQuery​(java.lang.String queryString, java.lang.String packageName, java.util.List<?> parameters)
      Construct an IQL query from a String.
      IqlQuery​(Query q)
      Construct an IQL query from a Query object.
    • Constructor Detail

      • IqlQuery

        public IqlQuery()
        No-arg constructor (for deserialization)
      • IqlQuery

        public IqlQuery​(java.lang.String queryString,
                        java.lang.String packageName,
                        java.util.List<?> parameters)
        Construct an IQL query from a String. NOTE: The query string is not validated on construction
        Parameters:
        queryString - the string-based query
        packageName - the package name with which to qualify unqualified classnames. Note that this can be null if every class name is fully qualified
        parameters - values to substitute for '?' in query text
        Throws:
        java.lang.NullPointerException - if queryString is null
      • IqlQuery

        public IqlQuery​(java.lang.String queryString,
                        java.lang.String packageName)
        Construct an IQL query from a String. NOTE: The query string is not validated on construction
        Parameters:
        queryString - the string-based query
        packageName - the package name with which to qualify unqualified classnames. Note that this can be null if every class name is fully qualified
        Throws:
        java.lang.NullPointerException - if queryString is null
      • IqlQuery

        public IqlQuery​(Query q)
        Construct an IQL query from a Query object.
        Parameters:
        q - the Query object
        Throws:
        java.lang.NullPointerException - if query is null
    • Method Detail

      • nodeToString

        public static java.lang.String nodeToString​(Query q,
                                                    java.lang.Object qn,
                                                    java.util.List<java.lang.Object> parameters,
                                                    java.util.Set<QueryObjectPathExpression> pathList)
        Converts an Object into a String.
        Parameters:
        q - a Query, to provide aliases
        qn - an Object to convert
        parameters - a List, in which this method will place objects corresponding to the question marks in the resulting String
        pathList - QueryObjectPathExpressions will be added to this for PathExpressionField objects in the SELECT list
        Returns:
        a String
      • queryCollectionPathExpressionToString

        public static java.lang.String queryCollectionPathExpressionToString​(Query q,
                                                                             java.util.List<java.lang.Object> parameters,
                                                                             QueryCollectionPathExpression col)
        Converts a QueryObjectPathExpression into a String.
        Parameters:
        q - a Query, to provide aliases
        parameters - a List, in which this method will place objects corresponding to the question marks in the resulting String
        col - an Object to convert
        Returns:
        a String
      • queryObjectPathExpressionToString

        public static java.lang.String queryObjectPathExpressionToString​(Query q,
                                                                         java.util.List<java.lang.Object> parameters,
                                                                         QueryObjectPathExpression ref)
        Converts a QueryObjectPathExpression into a String.
        Parameters:
        q - a Query, to provide aliases
        parameters - a List, in which this method will place objects corresponding to the question marks in the resulting String
        ref - an Object to convert
        Returns:
        a String
      • queryExpressionToString

        public static java.lang.String queryExpressionToString​(Query q,
                                                               QueryExpression qe,
                                                               java.util.List<java.lang.Object> parameters)
        Converts a QueryExpression into a String.
        Parameters:
        q - a Query, to provide aliases
        qe - an Object to convert
        parameters - a List, in which this method will place objects corresponding to the question marks in the resulting String
        Returns:
        a String
      • constraintToString

        public static java.lang.String constraintToString​(Query q,
                                                          Constraint cc,
                                                          java.util.List<java.lang.Object> parameters)
        Converts a Constraint into a String.
        Parameters:
        q - a Query, to provide aliases
        cc - a Constraint to convert
        parameters - a List, in which this method will place objects corresponding to the question marks in the resulting String
        Returns:
        a String
      • queryReferenceToString

        public static java.lang.String queryReferenceToString​(Query q,
                                                              QueryReference ref,
                                                              java.util.List<java.lang.Object> parameters)
        Converts a QueryReference into a String.
        Parameters:
        q - a Query, from which to get aliases
        ref - a QueryReference
        parameters - a List to which parameters will be added
        Returns:
        a String
      • toQuery

        public Query toQuery()
        Convert to a InterMine query
        Returns:
        the InterMine Query object
      • getQueryString

        public java.lang.String getQueryString()
        Get the query String NOTE: this will be unvalidated
        Returns:
        the query String
      • setQueryString

        public void setQueryString​(java.lang.String queryString)
        Set the query String NOTE: this method is merely here to make this a Bean.
        Parameters:
        queryString - the query String
      • getPackageName

        public java.lang.String getPackageName()
        Get the package name
        Returns:
        the package name
      • setPackageName

        public void setPackageName​(java.lang.String packageName)
        Set the package name NOTE: this method is merely here to make this a Bean.
        Parameters:
        packageName - the package name
      • getParameters

        public java.util.List<?> getParameters()
        Get the parameters
        Returns:
        the parameters
      • setParameters

        public void setParameters​(java.util.List<?> parameters)
        Set the parameters
        Parameters:
        parameters - the parameters
      • toString

        public java.lang.String toString()
        Return a string version of the IqlQuery
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String version of the query
      • toStringTruncateParameters

        public java.lang.String toStringTruncateParameters​(int maxSize)
        Return a string version of the IqlQuery but truncated the parameters (lists of bag contents) to the specified length.
        Parameters:
        maxSize - the maximum length
        Returns:
        a String version of the query
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isReservedWord

        public static boolean isReservedWord​(java.lang.String word)
        Returns true if the given String is an IQL reserved word.
        Parameters:
        word - the String
        Returns:
        a boolean
      • escapeReservedWord

        public static java.lang.String escapeReservedWord​(java.lang.String word)
        Converts words into escaped form.
        Parameters:
        word - the String
        Returns:
        an escaped String