public class UnifiedMetaData extends Object
This class aggregates information about messages, fields, composite/enum types, repeating groups, presence and nullability, offsets/sizes, encodings, and domain-specific hints in a single structure that can be consumed by decoders/encoders and higher–level utilities.
Thread-safety: Instances are not guaranteed to be thread-safe unless documented otherwise; treat them as confined to the parsing/building thread.
Terminology:
The instance can represent actual schema members as well as virtual or synthesized fields
(e.g., special IDs defined by biz.onixs.sbe.SpecialFieldIds).
Usage examples:
// Iterate groups in a message and print their names
UnifiedMetaData message = ...;
for (UnifiedMetaData g : message.getGroups()) {
if (g.isGroup()) {
System.out.println(g.getName());
}
}
// Print composite member names and primitive types
UnifiedMetaData field = ...;
if (field.isComposite()) {
for (UnifiedMetaData m : field.getCompositeMembers()) {
System.out.println(m.getName() + ": " + m.getPrimitiveType());
}
}
// Compute offsets within a fixed-length field set
int running = 0;
for (UnifiedMetaData f : field.getCompositeMembers()) {
int off = f.getOffsetInFieldSet(running);
System.out.println(f.getName() + " @ " + off);
running = off + f.getSize();
}
Chained search
In a number of cases instances of the class in the compiled SBE template are chained through the getUnderlayingType() member.
For instance, the message field metadata keeps this reference to the fiel type metadata, and this metadata refers to the primitive type.
This chaining is used to search particular traits of the particular item: the request for particular data is delegated through the getUnderlayingType()
until non-null data will be found.
Such an algorithm is used to retrieve field size, field offset, field and type traits, etc. Here and below it is called "chained search". Getters that implement this approach are marked as "chained".
| Modifier and Type | Class and Description |
|---|---|
static class |
UnifiedMetaData.Kind
Kind of the metadata instance.
|
static class |
UnifiedMetaData.Presence
Presence.
|
static class |
UnifiedMetaData.PrimitiveType
Primitive types definitions.
|
static class |
UnifiedMetaData.SemanticType
FIX semantic type.
|
static class |
UnifiedMetaData.WellKnownComposite
Marks for well-known composites.
|
| Constructor and Description |
|---|
UnifiedMetaData(MessageSchema messageSchema) |
| Modifier and Type | Method and Description |
|---|---|
UnifiedMetaData |
findCompositeMember(Function<UnifiedMetaData,Boolean> func)
Find a field of composite.
|
UnifiedMetaData |
findCompositeMember(String name)
Find a field of composite.
|
UnifiedMetaData |
findField(int tag)
Find field by tag.
|
UnifiedMetaData |
findField(String name)
Find field by name.
|
UnifiedMetaData |
findOwnValue(String name)
Find enumeration or set element.
|
Integer |
getCalculatedOffset()
Effective offset.
|
String |
getCharacterEncoding()
Character encoding.
|
UnifiedMetaData[] |
getCompositeMembers()
Composite data fields.
|
UnifiedMetaData |
getCompositeMembersContainer()
Gets container of composite fields.
|
UnifiedMetaData[] |
getData()
Variadic-length fields of the field set.
|
String |
getDescription()
Returns description.
|
String |
getDimensionTypeName()
Repeating group dimension type name.
|
Integer |
getExplicitAlignment()
Explicitly defined alignment.
|
Integer |
getExplicitOffset()
Explicitly defined offset.
|
int |
getFieldSetHeaderSize()
Size of the field set header.
|
int |
getFixedSize()
Size of the fixed part.
|
UnifiedMetaData[] |
getFixedSizeBlock()
Fixed block of the field set.
|
String |
getFixMessageType()
FIX message type.
|
Object |
getGeneratingData()
Internal usage.
|
UnifiedMetaData[] |
getGroups()
Repeating groups of the field set.
|
String |
getInheritedName()
Returns inherited name.
|
Class<?> |
getInternalJavaClass()
Internal class.
|
int |
getIntValue()
Integer value.
|
UnifiedMetaData.Kind |
getKind()
Returns kind of the metadata instance.
|
Integer |
getLength()
Length specification.
|
long |
getLongValue()
Long value.
|
String |
getMaxValue()
Maximum value.
|
MessageSchema |
getMessageSchema()
Message schema of the metadata.
|
String |
getMinValue()
Minimum value.
|
String |
getName()
Returns name.
|
String |
getNullValue()
Null value.
|
int |
getOffsetInFieldSet(int ownFieldSetOffset)
Offset of the field in the containing field set.
|
Object |
getOwnGeneratingData()
Internal usage.
|
int |
getPaddingAfter() |
int |
getPaddingBefore()
Padding before the field.
|
UnifiedMetaData |
getParent()
Parent metadata.
|
UnifiedMetaData.Presence |
getPresence()
Presence.
|
Class<?> |
getPresentativeJavaClass()
Presentative class.
|
UnifiedMetaData.PrimitiveType |
getPrimitiveType()
Primitive type.
|
String |
getRawSemanticType()
Semantic type in raw form.
|
UnifiedMetaData |
getResolvedDimensionType()
Repeating group dimension type metadata.
|
UnifiedMetaData |
getResolvedUnderlayingType()
Underlying type.
|
UnifiedMetaData.SemanticType |
getSemanticType()
Semantic type.
|
Integer |
getSinceVersion()
Returns sinceVersion value.
|
Integer |
getTag()
Returns the tag.
|
String |
getTimeEpoch()
Epoch value.
|
String |
getTimeUnit()
Time unit value.
|
UnifiedMetaData |
getUnderlayingPrimitiveType()
Finds the deepest primitive type if one present.
|
String |
getUnderlayingPrimitiveTypeName()
Underlying primitive type name.
|
String |
getUnderlayingType()
Underlying type name.
|
String |
getValue()
Value of the constant.
|
String |
getValueRef()
Referred value.
|
UnifiedMetaData[] |
getValues()
Enumeration or set values.
|
UnifiedMetaData[] |
getVirtualFields()
Virtual fields.
|
UnifiedMetaData.WellKnownComposite |
getWellKnownComposite()
Well-known composite.
|
boolean |
hasVirtualFields()
Checks if the virtual fields present.
|
void |
initGeneratingData(Object object)
Internal usage.
|
boolean |
isArray()
Checks if the object is fixed-size array.
|
boolean |
isComposite()
Checks if the object is composite or has type of composite.
|
boolean |
isConstant()
Checks if the object is constant.
|
boolean |
isCustomComposite()
Checks if the object is custom composite or has type of custom composite.
|
boolean |
isEnum()
Checks if the object is enumeration or has type of enumeration.
|
boolean |
isFixedLengthField()
Checks if the object is a field of fixed length.
|
boolean |
isGroup()
Checks if the object is repeating group.
|
boolean |
isOffsetsResolved()
Checks if fields offsets successfully calculated.
|
boolean |
isOptional()
Checks if the object has "optional" presence.
|
boolean |
isRequired()
Checks if the object is required (mandatory) field.
|
boolean |
isSet()
Checks if the object is set or has type of set.
|
UnifiedMetaData |
isSimpleFixField()
Checks if the object is simple FIX field.
|
boolean |
isVarData()
Checks if the object is varidaic-length data or has type of variadic-length data.
|
boolean |
isVirtual()
Checks if the object is virtual field.
|
void |
resolveOffsets()
Calculate offsets of the fields.
|
public UnifiedMetaData(MessageSchema messageSchema)
public Integer getTag()
Returns tag associated with the given item. This can be a field tag or message numeric ID in dependency on the object that is described by this metadata.
Chained
public String getName()
Returns name of the given item. That is the value of the "name" attribute in the SBE template.
public String getInheritedName()
Returns name of the given item. That is the value of the "name" attribute in the SBE template.
Chained
public String getDescription()
Returns description of the given item. That is the value of the "description" attribute in the SBE template.
public String getValue()
null.
Chained
public UnifiedMetaData.Kind getKind()
UnifiedMetaData.Kind enumeration.public Integer getSinceVersion()
null.
Chained
public String getRawSemanticType()
Returns value of the "semanticType" SBE XML template attribute or null.
Chained
public UnifiedMetaData.SemanticType getSemanticType()
Returns SemanticType member if the raw value of the "semanticType" attribute can be recognized as standard FIX semantic type.
SemanticType enumeration or null.
Chained
public String getFixMessageType()
null.
Chained
public UnifiedMetaData.PrimitiveType getPrimitiveType()
Returns member of the UnifiedMetaData.PrimitiveType enumeration that corresponds to the primitive type of the field (if applicable).
null.
Chained
public Integer getLength()
Returns value of the "length" SBE XML attribute.
Chained
public UnifiedMetaData.Presence getPresence()
Returns presence value of the current item. If the item represents composite type, the method returns presence of the first non-constant composite field.
UnifiedMetaData.Presence enumeration.
Chained
public String getNullValue()
Returns value of the "nullValue" SBE XML attribute or null.
Chained
public String getMinValue()
Returns value of the "minValue" SBE XML attribute or null.
Chained
public String getMaxValue()
Returns value of the "maxValue" SBE XML attribute or null.
Chained
public String getValueRef()
Returns value of the "valueRef" SBE XML attribute or null.
Chained
public Integer getExplicitOffset()
Returns value of the "offset" SBE XML attribute or null.
Chained
public Integer getExplicitAlignment()
Returns value of the "alignment" SBE XML attribute or null.
Chained
public Integer getCalculatedOffset()
Returns real offset of the given field. The offset is calculated on the base of explicitly defined fields offsets and sizes.
public int getPaddingBefore()
Returns number of empty bytes before the field (zero in the most of cases).
public int getPaddingAfter()
public int getFixedSize()
Returns the number of bytes occupied by fixed part of the given item.
Chained for simple data types.
public String getTimeEpoch()
Returns value of the "epoch" SBE XML attribute or null.
Chained
public String getTimeUnit()
Returns value of the "timeUnit" SBE XML attribute or null.
Chained
public String getUnderlayingType()
Returns name of the type used to encode data object described by the current UnifiedMetaData instance, or null.
Chained
public String getUnderlayingPrimitiveTypeName()
Returns name of the primitive type used to encode data object described by the current UnifiedMetaData instance, or null.
Chained
public UnifiedMetaData getResolvedUnderlayingType()
Returns metadata of the type used to encode data object described by the current UnifiedMetaData instance, or null.
UnifiedMetaData value.public UnifiedMetaData getParent()
Returns reference to the UnifiedMetaData that is a parent for the data object described by the current UnifiedMetaData instance, or null.
The "parent" value differs for different kinds of data. Here is the list of possible parents:
UnifiedMetaData value.public UnifiedMetaData[] getFixedSizeBlock()
Returns array of metadata that represents fields of the given field set fixed-size part. If non-applicable, returns null.
UnifiedMetaData.public UnifiedMetaData[] getGroups()
Returns array of metadata that represents repeating groups of the given field set. If non-applicable, returns null.
UnifiedMetaData.public UnifiedMetaData[] getData()
Returns array of metadata that represents variadic data fields of the given field set. If non-applicable, returns null.
UnifiedMetaData.public UnifiedMetaData[] getCompositeMembers()
Returns array of metadata that represents fields of the given composite type. If non-applicable, returns null.
UnifiedMetaData.public String getDimensionTypeName()
Returns value of the "dimensionType" SBE XML attribute, or null.
Chained
public UnifiedMetaData getResolvedDimensionType()
Returns metadata of the dimension type used for given repeating group, or null.
UnifiedMetaData value.
Chained
public UnifiedMetaData[] getValues()
Returns array of enumeration or set elements, or null.
UnifiedMetaData.Kind.Choice kind.UnifiedMetaData.Kind.ValidValue kind.UnifiedMetaData.
Chained
public boolean isOffsetsResolved()
public UnifiedMetaData.WellKnownComposite getWellKnownComposite()
Returns UnifiedMetaData.WellKnownComposite value if the metadata refers data object of the sndarda (well-known) SBE composite type.
UnifiedMetaData.WellKnownComposite value.
Chained
public String getCharacterEncoding()
Returns value of the "characterEncoding" SBE XML attribute, or null.
Chained
public boolean isEnum()
Chained
public boolean isSet()
Chained
public boolean isComposite()
Chained
public boolean isCustomComposite()
Chained
public UnifiedMetaData getCompositeMembersContainer()
UnifiedMetaData that owns metadata of the composite fields.UnifiedMetaData value.public boolean isVarData()
Chained
public boolean isGroup()
Chained
public UnifiedMetaData isSimpleFixField()
Returns true if the object represents simple FIX field, i.e. it is not one of the following: UnifiedMetaData.Kind.VarData, UnifiedMetaData.Kind.CompositeType or UnifiedMetaData.Kind.FixGroup.
Chained
public boolean isFixedLengthField()
Chained
public boolean isConstant()
Chained
public boolean isOptional()
Chained
public boolean isVirtual()
public boolean isRequired()
Chained
public int getOffsetInFieldSet(int ownFieldSetOffset)
Calculates offset of the field in the field set.
ownFieldSetOffset - Offset of the field set.public int getFieldSetHeaderSize()
Returns sum of Simple Open Framing Header and Message header sizes for FIX messages only (UnifiedMetaData.Kind.FixMessageType), or 0 (zero) otherwise.
public boolean isArray()
Returns true if the "length" SBE XML attribute has value greater than 1.
Chained
public UnifiedMetaData findCompositeMember(String name)
Finds composite field by its name, or null.
The object must be container of composite fields (see getCompositeMembersContainer()).
name - name of the field to find.UnifiedMetaData value.public UnifiedMetaData findCompositeMember(Function<UnifiedMetaData,Boolean> func)
Finds composite field by the customized condition.
The object must be container of composite fields (see getCompositeMembersContainer()).
func - filter function.UnifiedMetaData value.public UnifiedMetaData findOwnValue(String name)
Finds element of set or enumeration by its name. Returns null if the element not found.
The object must be container of the values (it should has getKind() equal to UnifiedMetaData.Kind.SetType or UnifiedMetaData.Kind.EnumType).
name - name of the field to find.UnifiedMetaData value.
Chained
public UnifiedMetaData findField(String name)
Finds field in the field set by its name. Returns null if the field not found.The result can has getKind() of UnifiedMetaData.Kind.FixField, UnifiedMetaData.Kind.FixGroup or UnifiedMetaData.Kind.VarData.
The object must be the field set (it should has getKind() equal to UnifiedMetaData.Kind.FixMessageType or UnifiedMetaData.Kind.FixGroup).
name - name of the field to find.UnifiedMetaData value.
Chained
public UnifiedMetaData findField(int tag)
Finds field in the field set by its tag. Returns null if the field not found.The result can has getKind() of UnifiedMetaData.Kind.FixField, UnifiedMetaData.Kind.FixGroup or UnifiedMetaData.Kind.VarData.
The object must be the field set (it should has getKind() equal to UnifiedMetaData.Kind.FixMessageType or UnifiedMetaData.Kind.FixGroup).
tag - tag of the field to find.UnifiedMetaData value.
Chained
public MessageSchema getMessageSchema()
MessageSchema value.public UnifiedMetaData getUnderlayingPrimitiveType()
public boolean hasVirtualFields()
public UnifiedMetaData[] getVirtualFields()
Returns array of virtual fields that appear in the field set.
UnifiedMetaData.
Chained
public void resolveOffsets()
This method is used during template parsing. It calculates field offsets on the base of their size and eplicitly specified offsets.
Does nothing if the metadata does not represent group of fields.
public Class<?> getPresentativeJavaClass()
Returns public class that corresponds to the metadata item.
public Class<?> getInternalJavaClass()
Returns internal class that corresponds to the metadata item.
Internal usage only.
public void initGeneratingData(Object object)
object - data.public Object getOwnGeneratingData()
public Object getGeneratingData()
public long getLongValue()
Returns constant value as long number. Throws exception if inapplicable.
public int getIntValue()
Returns constant value as int number. Throws exception if inapplicable.
Copyright © 2005–2025 Onix Solutions. All rights reserved.