public class KeyRange extends Object implements oracle.kv.impl.util.FastExternalizable
The KeyRange defines a range of String values for the key components immediately following the last component of a parent key that is used in a multiple-key operation. In terms of a tree structure, the range defines the parent key's immediate children that are selected by the multiple-key operation.
Constructor and Description |
---|
KeyRange(String prefix)
Creates a prefix KeyRange.
|
KeyRange(String start,
boolean startInclusive,
String end,
boolean endInclusive)
Creates a start/end KeyRange.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
static KeyRange |
fromByteArray(byte[] keyBytes)
Deserializes the given bytes that were returned earlier by
toByteArray() and returns the resulting KeyRange. |
static KeyRange |
fromString(String keyRangeStringArg)
Converts an encoded KeyRange back to a KeyRange.
|
String |
getEnd()
Returns the String component that defines upper bound of the key range,
or null if no upper bound is enforced.
|
boolean |
getEndInclusive()
Returns whether end is included in the range, i.e., end is greater than
or equal to the last String component in the key range.
|
String |
getStart()
Returns the String component that defines lower bound of the key range,
or null if no lower bound is enforced.
|
boolean |
getStartInclusive()
Returns whether start is included in the range, i.e., start is less than
or equal to the first String component in the key range.
|
int |
hashCode() |
boolean |
inRange(Key parentKey,
Key checkKey)
Returns true if a Key is within the bounds of this range with respect to
a parent Key.
|
boolean |
isPrefix()
Returns whether this is a prefix range, i.e., whether start and end are
equal and both inclusive.
|
byte[] |
toByteArray()
Returns this KeyRange as a serialized byte array, such that
fromByteArray(byte[]) may be used to reconstitute the KeyRange. |
String |
toString()
Encodes the KeyRange object and returns the resulting String which can
later be decoded using
fromString(java.lang.String) . |
public KeyRange(String start, boolean startInclusive, String end, boolean endInclusive)
start
- is the String component that defines lower bound of the key
range. If null, no lower bound is enforced.startInclusive
- is true if start is included in the range, i.e.,
start is less than or equal to the first String component in the key
range.end
- is the String component that defines upper bound of the key
range. If null, no upper bound is enforced.endInclusive
- is true if end is included in the range, i.e., end
is greater than or equal to the last String component in the key range.IllegalArgumentException
- if either start and end are null or
start is not less than end.public KeyRange(String prefix)
For a KeyRange created using this constructor, isPrefix()
will
return true.
Additionally, both getStart()
and getEnd()
will return
the prefix, and both getStartInclusive()
and getEndInclusive()
will return true. However, the KeyRange
will
be treated as a prefix, not an inclusive range.
prefix
- is the value that is a prefix of all matching key
components. The KeyRange matches a key component if the component
starts with (as in String.startsWith
) the prefix value.public byte[] toByteArray()
fromByteArray(byte[])
may be used to reconstitute the KeyRange.public static KeyRange fromByteArray(byte[] keyBytes)
toByteArray()
and returns the resulting KeyRange.public String getStart()
public boolean getStartInclusive()
public String getEnd()
public boolean getEndInclusive()
public boolean isPrefix()
public boolean inRange(Key parentKey, Key checkKey)
parentKey
- the parent of the key range, or null to check the first
key component.checkKey
- the full key being checked.public String toString()
fromString(java.lang.String)
. The format is:
<startType>/<start>/<end>/<endType>
where the startType/endType
is either "I"
or "E"
for Inclusive or Exclusive and start
and end
are the start/end key strings. The leading
startType/start
specification is omitted from the String
representation if the range does not have a lower bound. Similarly, the
trailing end/endType
specification is omitted if the range
does not have an upper bound. Since a KeyRange
requires at
least one bound, at least one of the specifications is always present in
the String representation. Here are some examples:
alpha
inclusive
to beta
exclusive0123
inclusivechi
inclusive to infinitychi
exclusivepublic static KeyRange fromString(String keyRangeStringArg)
toString()
. See toString()
for more information about the KeyRange String format.keyRangeStringArg
- a non null KeyRange encoding string, which
should normally be created using toString()
.IllegalArgumentException
- if keyRangeStringArg does not contain
a valid KeyRange encoding.Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.