- java.lang.Object
-
- com.pervasive.datarush.tokens.record.SortKey
-
public class SortKey extends Object
A combination of a key field and an ordering. Used alone or in an ordered collection, specifies the ordering of record data.- See Also:
TokenOrder
-
-
Constructor Summary
Constructors Constructor Description SortKey(String name)
Create a key using ascending order.SortKey(String name, TokenOrder order)
Create a key using the specified order.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SortKey
asc(String name)
Create an ascending key.static SortKey[]
asc(String... names)
Create multiple ascending keys.static SortKey
desc(String name)
Create a descending key.static SortKey[]
desc(String... names)
Create multiple descending keys.boolean
equals(Object o)
String
getName()
Get the field name associated with this key.static String[]
getNames(SortKey... sortKeys)
Extract the field names from several keys.TokenOrder
getOrder()
Get the ordering associated with this key.static TokenOrder[]
getOrders(SortKey... sortKeys)
Extract the orderings from several keys.int
hashCode()
static SortKey[]
makeSortKeys(TokenOrder order, String... names)
Create multiple keys using the specified order.static SortKey[]
parseKey(String... keyExpressions)
Parse key expressions intoSortKey
s.String
toString()
Pretty-print thisSortKey
.
-
-
-
Constructor Detail
-
SortKey
public SortKey(String name)
Create a key using ascending order.- Parameters:
name
- Name of the key field
-
SortKey
public SortKey(String name, TokenOrder order)
Create a key using the specified order.- Parameters:
name
- Name of the key fieldorder
- Order of the data
-
-
Method Detail
-
getName
public String getName()
Get the field name associated with this key.- Returns:
- Name of the key field
-
getOrder
public TokenOrder getOrder()
Get the ordering associated with this key.- Returns:
- Key's ordering
-
toString
public String toString()
Pretty-print thisSortKey
.
-
asc
public static SortKey asc(String name)
Create an ascending key.- Parameters:
name
- Name of the key field- Returns:
- Descending sort key
-
asc
public static SortKey[] asc(String... names)
Create multiple ascending keys.- Parameters:
names
- Names of the key fields- Returns:
- Ascending sort keys, in the same order as the supplied field names
-
desc
public static SortKey desc(String name)
Create a descending key.- Parameters:
name
- Name of the key field- Returns:
- Descending sort key
-
desc
public static SortKey[] desc(String... names)
Create multiple descending keys.- Parameters:
names
- Names of the key fields- Returns:
- Descending sort keys, in the same order as the supplied field names
-
makeSortKeys
public static SortKey[] makeSortKeys(TokenOrder order, String... names)
Create multiple keys using the specified order.- Parameters:
order
- Ordering to use for the keysnames
- Names of the key fields- Returns:
- Sort keys, in the same order as the supplied field names
-
getNames
public static String[] getNames(SortKey... sortKeys)
Extract the field names from several keys.- Parameters:
sortKeys
- Keys from which to get the field names- Returns:
- Field names for the keys, in the same order as the supplied keys
-
getOrders
public static TokenOrder[] getOrders(SortKey... sortKeys)
Extract the orderings from several keys.- Parameters:
sortKeys
- Keys from which to get the orderings- Returns:
- Orderings for the keys, in the same order as the supplied keys
-
parseKey
public static SortKey[] parseKey(String... keyExpressions)
Parse key expressions intoSortKey
s. A key expression consists of a field name and optionally the sort order: either "asc" or "desc" for ascending and descending respectively. Ascending is the default. Field names with embedded white space characters can optionally use single or double quotes to surround the field name.Examples:
- "field desc" specifies to sort the column named "field" in descending order.
- "'field with spaces' desc" specifies to sort the column named "field with spaces" in descending order.
- Parameters:
keyExpressions
- list of expressions to parse into sort keys- Returns:
- a list of
SortKey
instances
-
-