...
Attribute | Description | Required |
---|---|---|
type | The type of the element. If the type is defined in this namespace or is a primitive or collection type, only the simple name of the type need be used. If the type belongs to another namespace from an imported file, then the fully qualified name should be used. The best practice when importing a type from another model is to use the fully qualified name of the imported type (e.g. com.example.importedmodel.MyEntity), as this insulates your model from future conflicts in the event that imported models are changed. If the field is an arraytypearray type, it should be suffixed with array indices such as MyEntity[] to denote it as an array. | ![]() |
name | The name of the field , must be unique within the model. | ![]() |
jsonName | Contains the name of the JSON property that will be used for the field when the message is serialized to JSON. Defaults to use using the value defined in name. | |
id | The id of the field. The id must be unique with the scope of the containing type. For Xbuf/Protobuf encoding this tag is used as the tag value for the field on the wire. If not set, a unique id will be generated by the source code generator. For better control over compatibility, it is reccomended recommended that the application set this value manually. Field ids must be between 0 and 32767 inclusive | |
length | If this field refers to a variable length type (such as a string), this indicates the maximum length of the field. | |
doc | A brief, one-line string describing the field. If more detailed documentation is desired, a child <documentation> element may be used. | |
deprecated | When true all methods generated for the field will be marked as deprecated. |
Note | |||||||
---|---|---|---|---|---|---|---|
| |||||||
It is not possible to define two types with the same name in a given model. One exception to this rule is that it is possible (though strongly discouraged) to define a type with the same name as a built-in type. In this case, using an unqualified type reference will favor the built-in type. In this case, it is possible to reference the local type by using the this keyword, or the fully qualified name:
|
...
Attribute | Description | Required |
---|---|---|
ref | The name of the referenced field. Name may be with or without the namespace of owner model (i.e. full-qualified name). In both cases, the field will be looked up in both the current model and its imports. If the non-fully-qualified name is declared in the current model and in one of the imports, the field from the current model will take precedence. If multiple imports define the same name, an error will be reported. The best practice when importing a field from another model is to use the fully qualified name of the imported field (e.g. com.example.importedmodel.someField), as this insulates your model from future conflicts in the event that imported models are changed. | ![]() |
name | Optionally, a name for the field that overrides the referenced field's name. Otherwise, the field name defaults to that of the referenced field. | |
jsonName | Optionally overrides the referenced field's jsonName. | |
id | Optionally overrides the id specified by the field being referenced. Field ids must be between 0 and 32767 inclusive | |
required | Whether or not the field is a required field for the type. Fields declared as required will cause a check to be added for the value being set in the generated types isValid() method. | |
pinned | Indicates whether or not the field is pinned. A pinned field always occupies the same space on the wire. | |
isKey | True if this field should serve as the key when inserting the entity into a LongMap or StringMap collection. In this case, insertion of the message in the collection with a given key will update this field with the key value. | |
doc | The doc to use for the field which overrides that specified by the referenced field. | |
deprecated | When true all methods generated for the field will be marked as deprecated. |
Generated Field Accessors
...
List Accessors for array types
When xbuf Xbuf encoding is used for an array type and pooling is enabled, the underlying implementation doesn't store the field value in an array because pooling varying array sizes is impractical. To achieve zero garbage for fields modeled as arrays, a List interface is more appropriate, and an XIndexedList is returned. An XIndexedList implements java.util.List, but also provides reusable iterators. These accessors are discussed in detail in the section Zero Garbage Array Accessors.
...
For zero garbage access on date fields, it is possible to use the 'AsTimestamp' accessors to access the field as the number of milliseconds since the epoch.
...
Type | Unset Field Return Value | hasXXX | Notes |
---|---|---|---|
Java Primitive | Default The default value for java primitive type | ![]() | For numeric values 0, for boolean false, for char ''. |
String, Date, | null | ![]() | |
Enum | null | ![]() | |
Entity | null | ![]() | |
Array | Empty Array | Depends on code gen configuration property generateArrayGetterEmptyIfNull |
...
Default | ||
---|---|---|
<qualifiedClassName>.initialLength | The initial length of the backing buffer to allocate to back the string in serialized form. | taken from length attribute if specified in the model, otherwise 1 |
<qualifiedClassName>.isNative | Whether or not a native backing buffer should be used. This is recommend for is recommended performance sensitive apps. | true |
<qualifiedClassName>.pool.enabled | Whether the factory is backed by a pool or if new instances are created on demand. | true |
<qualifiedClassName>.pool.threaded | Whether or not the backing pool is thread-safe. The pool must be thread safe if more than one thread will create strings from this factory, or, crucially, if a separate thread may return the item to the pool. For the default pool, this value should almost always be true, because the thread creating the string and the one that ultimately disposed it are usually different. | true |
<qualifiedClassName>.pool.preallocateCount | The number of objects to preallocate, or 0 if no preallocation should be done. Note that preallocation is not done until the class is loaded. | 0 |
...
Messages can only declare primitive types, built in types, embedded types as fields (or arrays of those types). Collections, Messages and non embedded Entities can't be used.
Generated Source
For an entity named "MyMessage" an interface and an implementation will be generated using the model's namespace. Entities will extend IRogNode or IRogMessage, marking that they can be used as nodes with the platform's Replicated Object Graph (ROG) framework and the platform's Simple Message Abstraction (SMA) Layer.
...
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmXbufGenerator", date="Fri Jan 23 02:03:22 PST 2015") final public class MyMessage extends RogNode implements IMessage, ILnkMessage, MessageReflector, IXbufDesyncer, IRogJsonizable {...} |
Collections
Collections are defined in the
...
<collections> element and must also have a unique id with respect to other types within the scope of their factory. Collections may not be declared as embedded at this time.
XML
Code Block | ||
---|---|---|
| ||
<collections> <collection name="MyQueue" is="Queue" contains="MyEntity" factoryid="1" id="5" /> <collection name="MySet" is="Set" contains="MyEntity" factoryid="1" id="6" /> <collection name="MyLongMap" contains="MyEntity" is="LongMap" factoryid="1" id="7" /> <collection name="MyStringMap" contains="CollectionObjectMyEntity" is="LongMap" factoryid="1" id="8" /> </collections> <entity name="MyEntity" factoryid="1" id="1"> <field name="longKey <field name="aQueue" type="MyQueue"/> <field name="aMap" type="MyStringMap/> </entity> |
Generated Source
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015") public interface IChildLongMap extends IRogLongMap<Child1>, Map<Long, Child1> {} @Generated(value="com.neeve.adm.AdmXbufGenerator", date="Fri Jan 23 02:03:22 PST 2015") final public class ChildLongMap extends RogLongMap<Child1> implements IChildLongMap, IXbufDesyncer, IRogJsonizable {...} |
...
- An embedded entity cannot be inlined into another embedded entity in a manner that will produce inlining cycles.
- An embedded entity cannot inline a Message or Entity.
- Messages and non embedded entites cannot be inlined.
- A Message can't inline 2 embedded entities that have conflicting field definitions (e.g. fields with the same name but with attributes that differ in any way other than their doc or required attributes). In the case of required, if an embedded entity defines a field as required, then it will be required on the message.
- The isKey and pinned field attributes on an embedded entity are ignored when the entity is inlined into another message or entity.
- A Message can't define fields that conflict with any of its inlined embedded entities (e.g. fields with the same name but with attributes that differ in any way other than their doc or required attributes).
Exceptions to this rule are:- required: In the case of the required attribute, the value set on a message field wins (a particular message can override the required field attribute on an inlined embedded entity).
- isKeyField: entity or message inlining the embedded entity can set the isKey attribute for a given inlined field.
- pinned: the pinned attribute can be overridden by the inlinining entity.
Generated Source
Note that javadoc is omitted below and only the simple accessors are listed for brevity.
...