public abstract class AbstractType<T> extends java.lang.Object implements java.util.Comparator<java.nio.ByteBuffer>, AssignmentTestable
Modifier and Type | Class and Description |
---|---|
static class |
AbstractType.ComparisonType |
AssignmentTestable.TestResult
Modifier and Type | Field and Description |
---|---|
AbstractType.ComparisonType |
comparisonType |
boolean |
isByteOrderComparable |
java.util.Comparator<java.nio.ByteBuffer> |
reverseComparator |
Modifier | Constructor and Description |
---|---|
protected |
AbstractType(AbstractType.ComparisonType comparisonType) |
Modifier and Type | Method and Description |
---|---|
CQL3Type |
asCQL3Type() |
static java.util.List<java.lang.String> |
asCQLTypeStringList(java.util.List<AbstractType<?>> abstractTypes) |
void |
checkComparable() |
int |
compare(java.nio.ByteBuffer left,
java.nio.ByteBuffer right) |
int |
compareCollectionMembers(java.nio.ByteBuffer v1,
java.nio.ByteBuffer v2,
java.nio.ByteBuffer collectionName)
An alternative comparison function used by CollectionsType in conjunction with CompositeType.
|
int |
compareCustom(java.nio.ByteBuffer left,
java.nio.ByteBuffer right)
Implement IFF ComparisonType is CUSTOM
Compares the ByteBuffer representation of two instances of this class,
for types where this cannot be done by simple in-order comparison of the
unsigned bytes
Standard Java compare semantics
|
int |
compareForCQL(java.nio.ByteBuffer v1,
java.nio.ByteBuffer v2)
Same as compare except that this ignore ReversedType.
|
int |
componentsCount()
The number of subcomponents this type has.
|
T |
compose(java.nio.ByteBuffer bytes) |
java.nio.ByteBuffer |
decompose(T value) |
boolean |
equals(java.lang.Object other,
boolean ignoreFreezing)
Checks to see if two types are equal when ignoring or not ignoring differences in being frozen, depending on
the value of the ignoreFreezing parameter.
|
AbstractType<?> |
freeze() |
AbstractType<?> |
freezeNestedMulticellTypes()
Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections
explicitly frozen.
|
abstract Term |
fromJSONObject(java.lang.Object parsed)
Given a parsed JSON string, return a byte representation of the object.
|
abstract java.nio.ByteBuffer |
fromString(java.lang.String source)
get a byte representation of the given string.
|
java.util.List<AbstractType<?>> |
getComponents()
Return a list of the "subcomponents" this type has.
|
abstract TypeSerializer<T> |
getSerializer() |
java.lang.String |
getString(java.nio.ByteBuffer bytes)
get a string representation of the bytes used for various identifier (NOT just for log messages)
|
java.lang.String |
getString(java.util.Collection<java.nio.ByteBuffer> names) |
boolean |
isCollection() |
boolean |
isCompatibleWith(AbstractType<?> previous)
Returns true if this comparator is compatible with the provided
previous comparator, that is if previous can safely be replaced by this.
|
boolean |
isCounter() |
boolean |
isEmptyValueMeaningless()
|
boolean |
isFreezable() |
boolean |
isFrozenCollection() |
boolean |
isMultiCell() |
boolean |
isReversed() |
boolean |
isTuple() |
boolean |
isUDT() |
boolean |
isValueCompatibleWith(AbstractType<?> otherType)
Returns true if values of the other AbstractType can be read and "reasonably" interpreted by the this
AbstractType.
|
protected boolean |
isValueCompatibleWithInternal(AbstractType<?> otherType)
Needed to handle ReversedType in value-compatibility checks.
|
static AbstractType<?> |
parseDefaultParameters(AbstractType<?> baseType,
TypeParser parser) |
java.nio.ByteBuffer |
readValue(DataInputPlus in) |
java.nio.ByteBuffer |
readValue(DataInputPlus in,
int maxValueSize) |
boolean |
referencesDuration() |
boolean |
referencesUserType(java.lang.String userTypeName) |
void |
skipValue(DataInputPlus in) |
AssignmentTestable.TestResult |
testAssignment(java.lang.String keyspace,
ColumnSpecification receiver) |
java.lang.String |
toJSONString(java.nio.ByteBuffer buffer,
ProtocolVersion protocolVersion)
Converts the specified value into its JSON representation.
|
java.lang.String |
toString()
This must be overriden by subclasses if necessary so that for any
AbstractType, this == TypeParser.parse(toString()).
|
java.lang.String |
toString(boolean ignoreFreezing) |
void |
validate(java.nio.ByteBuffer bytes) |
void |
validateCellValue(java.nio.ByteBuffer cellValue)
Validate cell value.
|
void |
validateCollectionMember(java.nio.ByteBuffer bytes,
java.nio.ByteBuffer collectionName)
An alternative validation function used by CollectionsType in conjunction with CompositeType.
|
protected int |
valueLengthIfFixed()
The length of values for this type if all values are of fixed length, -1 otherwise.
|
void |
writeValue(java.nio.ByteBuffer value,
DataOutputPlus out) |
long |
writtenLength(java.nio.ByteBuffer value) |
public final java.util.Comparator<java.nio.ByteBuffer> reverseComparator
public final AbstractType.ComparisonType comparisonType
public final boolean isByteOrderComparable
protected AbstractType(AbstractType.ComparisonType comparisonType)
public static java.util.List<java.lang.String> asCQLTypeStringList(java.util.List<AbstractType<?>> abstractTypes)
public T compose(java.nio.ByteBuffer bytes)
public java.nio.ByteBuffer decompose(T value)
public java.lang.String getString(java.nio.ByteBuffer bytes)
public abstract java.nio.ByteBuffer fromString(java.lang.String source) throws MarshalException
MarshalException
public abstract Term fromJSONObject(java.lang.Object parsed) throws MarshalException
parsed
- the result of parsing a json stringMarshalException
public java.lang.String toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)
The buffer position will stay the same.
buffer
- the value to convertprotocolVersion
- the protocol version to use for the conversionpublic void validate(java.nio.ByteBuffer bytes) throws MarshalException
MarshalException
public final int compare(java.nio.ByteBuffer left, java.nio.ByteBuffer right)
compare
in interface java.util.Comparator<java.nio.ByteBuffer>
public int compareCustom(java.nio.ByteBuffer left, java.nio.ByteBuffer right)
public void validateCellValue(java.nio.ByteBuffer cellValue) throws MarshalException
cellValue
- ByteBuffer representing cell valueMarshalException
public CQL3Type asCQL3Type()
public int compareForCQL(java.nio.ByteBuffer v1, java.nio.ByteBuffer v2)
public abstract TypeSerializer<T> getSerializer()
public java.lang.String getString(java.util.Collection<java.nio.ByteBuffer> names)
public boolean isCounter()
public boolean isFrozenCollection()
public boolean isReversed()
public static AbstractType<?> parseDefaultParameters(AbstractType<?> baseType, TypeParser parser) throws SyntaxException
SyntaxException
public boolean isCompatibleWith(AbstractType<?> previous)
public boolean isValueCompatibleWith(AbstractType<?> otherType)
protected boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
public int compareCollectionMembers(java.nio.ByteBuffer v1, java.nio.ByteBuffer v2, java.nio.ByteBuffer collectionName)
public void validateCollectionMember(java.nio.ByteBuffer bytes, java.nio.ByteBuffer collectionName) throws MarshalException
MarshalException
public boolean isCollection()
public boolean isUDT()
public boolean isTuple()
public boolean isMultiCell()
public boolean isFreezable()
public AbstractType<?> freeze()
public AbstractType<?> freezeNestedMulticellTypes()
2.x -> 3.x
schema migrations, and can be removed in Cassandra 4.0.
See CASSANDRA-11609 and CASSANDRA-11613.public boolean isEmptyValueMeaningless()
public java.lang.String toString(boolean ignoreFreezing)
ignoreFreezing
- if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.public int componentsCount()
public java.util.List<AbstractType<?>> getComponents()
protected int valueLengthIfFixed()
public void writeValue(java.nio.ByteBuffer value, DataOutputPlus out) throws java.io.IOException
java.io.IOException
public long writtenLength(java.nio.ByteBuffer value)
public java.nio.ByteBuffer readValue(DataInputPlus in) throws java.io.IOException
java.io.IOException
public java.nio.ByteBuffer readValue(DataInputPlus in, int maxValueSize) throws java.io.IOException
java.io.IOException
public void skipValue(DataInputPlus in) throws java.io.IOException
java.io.IOException
public boolean referencesUserType(java.lang.String userTypeName)
public boolean referencesDuration()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other, boolean ignoreFreezing)
other
- type to compareignoreFreezing
- if true, differences in the types being frozen will be ignoredpublic void checkComparable()
public final AssignmentTestable.TestResult testAssignment(java.lang.String keyspace, ColumnSpecification receiver)
testAssignment
in interface AssignmentTestable
Copyright © 2019 The Apache Software Foundation