Class PropertyQuery


  • public class PropertyQuery
    extends java.lang.Object
    Query for a specific property; create using Query.property(Property). Note: Property values do currently not consider any order defined for the main Query object (subject to change in a future version).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double avg()
      Calculates the average of all values for the given number property over all Objects matching the query.
      long avgLong()
      Calculates the average of all values for the given integer property over all Objects matching the query.
      long count()
      The count of non-null values.
      PropertyQuery distinct()
      Only distinct values should be returned (e.g.
      PropertyQuery distinct​(QueryBuilder.StringOrder stringOrder)
      For string properties you can specify QueryBuilder.StringOrder.CASE_SENSITIVE if you want to have case sensitive distinct values (e.g.
      java.lang.Boolean findBoolean()  
      java.lang.Byte findByte()  
      byte[] findBytes()
      Find the values for the given byte property for objects matching the query.
      java.lang.Character findChar()  
      char[] findChars()
      Find the values for the given int property for objects matching the query.
      java.lang.Double findDouble()  
      double[] findDoubles()
      Find the values for the given int property for objects matching the query.
      java.lang.Float findFloat()  
      float[] findFloats()
      Find the values for the given int property for objects matching the query.
      java.lang.Integer findInt()  
      int[] findInts()
      Find the values for the given int property for objects matching the query.
      java.lang.Long findLong()  
      long[] findLongs()
      Find the values for the given long property for objects matching the query.
      private java.lang.Object findNumber()  
      java.lang.Short findShort()  
      short[] findShorts()
      Find the values for the given int property for objects matching the query.
      java.lang.String findString()  
      java.lang.String[] findStrings()
      Find the values for the given string property for objects matching the query.
      long max()
      Finds the maximum value for the given property over all Objects matching the query.
      double maxDouble()
      Finds the maximum value for the given property over all Objects matching the query.
      long min()
      Finds the minimum value for the given property over all Objects matching the query.
      double minDouble()
      Finds the minimum value for the given property over all objects matching the query.
      (package private) double nativeAvg​(long handle, long cursorHandle, int propertyId)  
      (package private) long nativeAvgLong​(long handle, long cursorHandle, int propertyId)  
      (package private) long nativeCount​(long handle, long cursorHandle, int propertyId, boolean distinct)  
      (package private) byte[] nativeFindBytes​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, byte nullValue)  
      (package private) char[] nativeFindChars​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, char nullValue)  
      (package private) double[] nativeFindDoubles​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, double nullValue)  
      (package private) float[] nativeFindFloats​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, float nullValue)  
      (package private) int[] nativeFindInts​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, int nullValue)  
      (package private) long[] nativeFindLongs​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, long nullValue)  
      (package private) java.lang.Object nativeFindNumber​(long handle, long cursorHandle, int propertyId, boolean unique, boolean distinct, boolean enableNull, long nullValue, float nullValueFloat, double nullValueDouble)  
      (package private) short[] nativeFindShorts​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean enableNull, short nullValue)  
      (package private) java.lang.String nativeFindString​(long handle, long cursorHandle, int propertyId, boolean unique, boolean distinct, boolean distinctCase, boolean enableNull, java.lang.String nullValue)  
      (package private) java.lang.String[] nativeFindStrings​(long handle, long cursorHandle, int propertyId, boolean distinct, boolean distinctNoCase, boolean enableNull, java.lang.String nullValue)  
      (package private) long nativeMax​(long handle, long cursorHandle, int propertyId)  
      (package private) double nativeMaxDouble​(long handle, long cursorHandle, int propertyId)  
      (package private) long nativeMin​(long handle, long cursorHandle, int propertyId)  
      (package private) double nativeMinDouble​(long handle, long cursorHandle, int propertyId)  
      (package private) long nativeSum​(long handle, long cursorHandle, int propertyId)  
      (package private) double nativeSumDouble​(long handle, long cursorHandle, int propertyId)  
      PropertyQuery nullValue​(java.lang.Object nullValue)
      By default, null values are not returned by find methods (primitive arrays cannot contains nulls).
      PropertyQuery reset()
      Clears all values (e.g.
      long sum()
      Sums up all values for the given property over all Objects matching the query.
      double sumDouble()
      Sums up all values for the given property over all Objects matching the query.
      PropertyQuery unique()
      For find methods returning single values, e.g.
      • Methods inherited from class java.lang.Object

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

      • query

        final Query<?> query
      • queryHandle

        final long queryHandle
      • propertyId

        final int propertyId
      • distinct

        boolean distinct
      • noCaseIfDistinct

        boolean noCaseIfDistinct
      • enableNull

        boolean enableNull
      • unique

        boolean unique
      • nullValueDouble

        double nullValueDouble
      • nullValueFloat

        float nullValueFloat
      • nullValueString

        java.lang.String nullValueString
      • nullValueLong

        long nullValueLong
    • Constructor Detail

      • PropertyQuery

        PropertyQuery​(Query<?> query,
                      Property<?> property)
    • Method Detail

      • nativeFindStrings

        java.lang.String[] nativeFindStrings​(long handle,
                                             long cursorHandle,
                                             int propertyId,
                                             boolean distinct,
                                             boolean distinctNoCase,
                                             boolean enableNull,
                                             java.lang.String nullValue)
      • nativeFindLongs

        long[] nativeFindLongs​(long handle,
                               long cursorHandle,
                               int propertyId,
                               boolean distinct,
                               boolean enableNull,
                               long nullValue)
      • nativeFindInts

        int[] nativeFindInts​(long handle,
                             long cursorHandle,
                             int propertyId,
                             boolean distinct,
                             boolean enableNull,
                             int nullValue)
      • nativeFindShorts

        short[] nativeFindShorts​(long handle,
                                 long cursorHandle,
                                 int propertyId,
                                 boolean distinct,
                                 boolean enableNull,
                                 short nullValue)
      • nativeFindChars

        char[] nativeFindChars​(long handle,
                               long cursorHandle,
                               int propertyId,
                               boolean distinct,
                               boolean enableNull,
                               char nullValue)
      • nativeFindBytes

        byte[] nativeFindBytes​(long handle,
                               long cursorHandle,
                               int propertyId,
                               boolean distinct,
                               boolean enableNull,
                               byte nullValue)
      • nativeFindFloats

        float[] nativeFindFloats​(long handle,
                                 long cursorHandle,
                                 int propertyId,
                                 boolean distinct,
                                 boolean enableNull,
                                 float nullValue)
      • nativeFindDoubles

        double[] nativeFindDoubles​(long handle,
                                   long cursorHandle,
                                   int propertyId,
                                   boolean distinct,
                                   boolean enableNull,
                                   double nullValue)
      • nativeFindNumber

        java.lang.Object nativeFindNumber​(long handle,
                                          long cursorHandle,
                                          int propertyId,
                                          boolean unique,
                                          boolean distinct,
                                          boolean enableNull,
                                          long nullValue,
                                          float nullValueFloat,
                                          double nullValueDouble)
      • nativeFindString

        java.lang.String nativeFindString​(long handle,
                                          long cursorHandle,
                                          int propertyId,
                                          boolean unique,
                                          boolean distinct,
                                          boolean distinctCase,
                                          boolean enableNull,
                                          java.lang.String nullValue)
      • nativeSum

        long nativeSum​(long handle,
                       long cursorHandle,
                       int propertyId)
      • nativeSumDouble

        double nativeSumDouble​(long handle,
                               long cursorHandle,
                               int propertyId)
      • nativeMax

        long nativeMax​(long handle,
                       long cursorHandle,
                       int propertyId)
      • nativeMaxDouble

        double nativeMaxDouble​(long handle,
                               long cursorHandle,
                               int propertyId)
      • nativeMin

        long nativeMin​(long handle,
                       long cursorHandle,
                       int propertyId)
      • nativeMinDouble

        double nativeMinDouble​(long handle,
                               long cursorHandle,
                               int propertyId)
      • nativeAvg

        double nativeAvg​(long handle,
                         long cursorHandle,
                         int propertyId)
      • nativeAvgLong

        long nativeAvgLong​(long handle,
                           long cursorHandle,
                           int propertyId)
      • nativeCount

        long nativeCount​(long handle,
                         long cursorHandle,
                         int propertyId,
                         boolean distinct)
      • reset

        public PropertyQuery reset()
        Clears all values (e.g. distinct and null value).
      • unique

        public PropertyQuery unique()
        For find methods returning single values, e.g. findInt(), this will additional verify that the resulting value is unique. If there is any other resulting value resulting from this query, an exception will be thrown.

        Can be combined with distinct().

        Will be ignored for find methods returning multiple values, e.g. findInts().

      • nullValue

        public PropertyQuery nullValue​(java.lang.Object nullValue)
        By default, null values are not returned by find methods (primitive arrays cannot contains nulls). However, using this function, you can define an alternative value that will be returned for null values. E.g. -1 for ins/longs or "NULL" for strings.
      • findStrings

        public java.lang.String[] findStrings()
        Find the values for the given string property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct(), distinct(QueryBuilder.StringOrder)

        Returns:
        Found strings
      • findLongs

        public long[] findLongs()
        Find the values for the given long property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

        Returns:
        Found longs
      • findInts

        public int[] findInts()
        Find the values for the given int property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

      • findShorts

        public short[] findShorts()
        Find the values for the given int property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

      • findChars

        public char[] findChars()
        Find the values for the given int property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

      • findBytes

        public byte[] findBytes()
        Find the values for the given byte property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

      • findFloats

        public float[] findFloats()
        Find the values for the given int property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

      • findDoubles

        public double[] findDoubles()
        Find the values for the given int property for objects matching the query.

        Note: null values are excluded from results.

        Note: results are not guaranteed to be in any particular order.

        See also: distinct()

      • findString

        public java.lang.String findString()
      • findNumber

        private java.lang.Object findNumber()
      • findLong

        public java.lang.Long findLong()
      • findInt

        public java.lang.Integer findInt()
      • findShort

        public java.lang.Short findShort()
      • findChar

        public java.lang.Character findChar()
      • findByte

        public java.lang.Byte findByte()
      • findBoolean

        public java.lang.Boolean findBoolean()
      • findFloat

        public java.lang.Float findFloat()
      • findDouble

        public java.lang.Double findDouble()
      • sum

        public long sum()
        Sums up all values for the given property over all Objects matching the query.

        Note: this method is not recommended for properties of type long unless you know the contents of the DB not to overflow. Use sumDouble() instead if you cannot guarantee the sum to be in the long value range.

        Returns:
        0 in case no elements matched the query
        Throws:
        NumericOverflowException - if the sum exceeds the numbers Long can represent. This is different from Java arithmetic where it would "wrap around" (e.g. max. value + 1 = min. value).
      • sumDouble

        public double sumDouble()
        Sums up all values for the given property over all Objects matching the query.

        Note: for integer types int and smaller, sum() is usually preferred for sums.

        Returns:
        0 in case no elements matched the query
      • max

        public long max()
        Finds the maximum value for the given property over all Objects matching the query.
        Returns:
        Long.MIN_VALUE in case no elements matched the query
      • maxDouble

        public double maxDouble()
        Finds the maximum value for the given property over all Objects matching the query.
        Returns:
        NaN in case no elements matched the query
      • min

        public long min()
        Finds the minimum value for the given property over all Objects matching the query.
        Returns:
        Long.MAX_VALUE in case no elements matched the query
      • minDouble

        public double minDouble()
        Finds the minimum value for the given property over all objects matching the query.
        Returns:
        NaN in case no elements matched the query
      • avg

        public double avg()
        Calculates the average of all values for the given number property over all Objects matching the query.

        For integer properties you can also use avgLong().

        Returns:
        NaN in case no elements matched the query
      • avgLong

        public long avgLong()
        Calculates the average of all values for the given integer property over all Objects matching the query.

        For floating-point properties use avg().

        Returns:
        0 in case no elements matched the query
      • count

        public long count()
        The count of non-null values.

        See also: distinct()