The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixing some typos

...

AttributeDescriptionRequired
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.

(tick)
nameThe name of the field , must be unique within the model.(tick)
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.

 
docA brief, one-line string describing the field. If more detailed documentation is desired, a child <documentation> element may be used. 
deprecatedWhen true all methods generated for the field will be marked as deprecated. 
Note
titleQualifying conflicting type names

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:

Code Block
xml
xml
<model xmlns="http://www.neeveresearch.com/schema/x-adml" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
       name="Trading" 
       namespace="com.mycompany.trading" 
       defaultFactoryId="100">
       doc="Contains Messages used by the Trading Application">
 
  <import model="../orderprocessing.xml"/>
 
  <!--An unfortunately named entity:-->
  <entity name="Currency" id="1">
    <field name="currencyCode" type="String"/>
  </entity>
 
  <entity name="MyEntity" id="2">
    <!-- 
      Without qualifying the Currency type, the built 
      in Currency type is used, and the generated entity
      will return a java.util.Currency.
    -->
    <field name="javaCurrency" type="Currency" />
    <!-- 
      The 'this' keyword indicates that this is the Currency
      entity defined in this model:
    -->
    <field name="currencyEntity" type="this.Currency"/>
    <!-- 
      Namespace qualifying the typeindicates that this is the Currency
      entity defined in this model:
    -->
    <field name="currencyEntity2" type="com.mycompany.trading.Currency"/>
    <!-- 
      Namespace qualifying the type indicates that this is the Currency
      entity defined in some imported model:
    -->
    <field name="currencyEntity3" type="com.mycompany.orderprocessing.Currency"/>
  </entity>
</model>

...

AttributeDescriptionRequired
refThe 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.(tick)
nameOptionally, a name for the field that overrides the referenced field's name. Otherwise, the field name defaults to that of the referenced field. 
jsonNameOptionally 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

 
requiredWhether 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.

 
docThe doc to use for the field which overrides that specified by the referenced field. 
deprecatedWhen 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 PrimitiveDefault The default value for java primitive type(tick)For numeric values 0, for boolean false, for char ''.
String, Date,null(tick) 
Enumnull(tick) 
Entitynull(tick) 
ArrayEmpty Array

(error)

Depends on code gen configuration property generateArrayGetterEmptyIfNull

...

  Default
<qualifiedClassName>.initialLengthThe 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>.isNativeWhether or not a native backing buffer should be used. This is recommend for is recommended performance sensitive apps.true
<qualifiedClassName>.pool.enabledWhether the factory is backed by a pool or if new instances are created on demand.true
<qualifiedClassName>.pool.threadedWhether 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.preallocateCountThe 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
java
java
@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
languagexml
<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
java
java
@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.

...