public class Token
extends java.lang.Object
Token
s.
The entire IR of an entity is a List
of Token
objects. The order of this list is very
important. Encoding of fields is done by nodes pointing to specific encoding
PrimitiveType
objects. Each encoding node contains encodedLength, offset, byte order,
and Encoding
. Entities relevant to the encoding such as fields, messages, repeating groups, etc. are
encapsulated in the list as nodes themselves. Although, they will in most cases never be serialized. The boundaries
of these entities are delimited by BEGIN and END Signal
values in the node Encoding
.
A list structure like this allows for each concatenation of encodings as well as easy traversal.
An example encoding of a message headerStructure might be like this.
Modifier and Type | Class and Description |
---|---|
static class |
Token.Builder |
static class |
Token.VersionContext
Indicates how the version field should be interpreted.
|
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_ID
Invalid ID value.
|
static int |
UNKNOWN_OFFSET
Offset not computed or set
|
static int |
VARIABLE_LENGTH
Length not determined
|
Constructor and Description |
---|
Token(Signal signal,
java.lang.String name,
java.lang.String referencedName,
java.lang.String description,
int id,
int version,
int deprecated,
int encodedLength,
int offset,
int componentTokenCount,
Encoding encoding)
Construct an
Token by providing values for all fields. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
applicableTypeName()
Get the name of the type that should be applied in context.
|
int |
arrayLength()
The number of encoded primitives in this type.
|
int |
componentTokenCount()
The number of tokens that make up this component.
|
void |
componentTokenCount(int componentTokenCount)
Set the number of tokens this component has.
|
int |
deprecated()
The version in which this context was deprecated.
|
java.lang.String |
description()
Description for what the token is to be used for.
|
int |
encodedLength()
The encodedLength of this token in bytes.
|
void |
encodedLength(int encodedLength)
Set the encoded length for this node.
|
Encoding |
encoding()
|
int |
id()
Return the ID of the token assigned by the specification
|
boolean |
isConstantEncoding() |
boolean |
isOptionalEncoding() |
java.lang.CharSequence |
matchOnLength(java.util.function.Supplier<java.lang.CharSequence> one,
java.util.function.Supplier<java.lang.CharSequence> many)
Match which approach to take based on the length of the token.
|
java.lang.String |
name()
Return the name of the token
|
int |
offset()
The offset for this token in the message.
|
java.lang.String |
referencedName()
Get the name of the type when this is from a reference.
|
Signal |
signal()
Signal the role of this token.
|
java.lang.String |
toString() |
int |
version()
The version context for this token.
|
Token.VersionContext |
versionContext()
The context in which the version field should be interpreted.
|
public static final int INVALID_ID
public static final int VARIABLE_LENGTH
public static final int UNKNOWN_OFFSET
public Token(Signal signal, java.lang.String name, java.lang.String referencedName, java.lang.String description, int id, int version, int deprecated, int encodedLength, int offset, int componentTokenCount, Encoding encoding)
Token
by providing values for all fields.signal
- for the token role.name
- of the token in the message.referencedName
- of the type when created from a ref in a composite.description
- of what the token is for.id
- as the identifier in the message declaration.version
- application within the template.deprecated
- as of this version.encodedLength
- of the component part.offset
- in the underlying message as octets.componentTokenCount
- number of tokens in this component.encoding
- of the primitive field.public java.lang.String name()
public java.lang.String referencedName()
public java.lang.String description()
public int id()
public int version()
versionContext()
public int deprecated()
public java.lang.String applicableTypeName()
public Token.VersionContext versionContext()
public int encodedLength()
VARIABLE_LENGTH
means this node represents a variable length field.public void encodedLength(int encodedLength)
encodedLength()
.encodedLength
- that is overriding existing value.public int arrayLength()
public java.lang.CharSequence matchOnLength(java.util.function.Supplier<java.lang.CharSequence> one, java.util.function.Supplier<java.lang.CharSequence> many)
String
is returned.one
- to be used when length is one.many
- to be used when length is greater than one.CharSequence
representing the token depending on the length.public int offset()
UNKNOWN_OFFSET
means this nodes true offset is dependent on variable length
fields ahead of it in the encoding.public int componentTokenCount()
public void componentTokenCount(int componentTokenCount)
componentTokenCount
- the number of tokens this component has.public boolean isConstantEncoding()
public boolean isOptionalEncoding()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.