48.9. 6.KeyValuePairField
KeyValuePairField 注释定义键值对字段的 属性。每个 KeyValuePairField 由一个标签(= key)及其关联的值(字符串、int、date、…)标识,可选模式,以及字段(如果需要)
| 注解名称 | 记录类型 | 级别 |
|---|---|---|
| KeyValuePairField | Key Value Pair - FIX | 属性 |
| 参数名称 | type | info |
|---|---|---|
| tag | int | mandatory - 标识消息中字段的数字号 - 必须是唯一的 |
| pattern | 字符串 | 可选 - 默认值 = "" - 将用于格式化 Decimal、Date、… |
| 精度 | int | 可选 - 数字号 - 代表当拒绝号被格式化/parsed 时使用的精度 |
| position | int | 可选 - 当 FIX 消息中的键/标签的位置必须不同时,必须使用 |
| required | 布尔值 | optional - default value = "false" |
| impliedDecimalSeparator | 布尔值 | Camel 2.11: 可选 - 默认值 = "false" - 如果指定位置有小点表示 |
case 1 : tag
此参数表示消息中字段的键
FIX 消息 - Tag
@Message(keyValuePairSeparator = "=", pairSeparator = "\u0001", type="FIX", version="4.1")
public class Order {
@Link Header header;
@Link Trailer trailer;
@KeyValuePairField(tag = 1) // Client reference
private String Account;
@KeyValuePairField(tag = 11) // Order reference
private String ClOrdId;
@KeyValuePairField(tag = 22) // Fund ID type (Sedol, ISIN, ...)
private String IDSource;
@KeyValuePairField(tag = 48) // Fund code
private String SecurityId;
@KeyValuePairField(tag = 54) // Movement type ( 1 = Buy, 2 = sell)
private String Side;
@KeyValuePairField(tag = 58) // Free text
private String Text;
}案例 2:输出中的不同位置
如果我们将放置在 FIX 消息的标签/键必须按照预定义的顺序排序,则使用注释 @KeyValuePairField 的属性 'position'
FIX 消息 - Tag - sort
@Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type = "FIX", version = "4.1", isOrdered = true)
public class Order {
@Link Header header;
@Link Trailer trailer;
@KeyValuePairField(tag = 1, position = 1) // Client reference
private String account;
@KeyValuePairField(tag = 11, position = 3) // Order reference
private String clOrdId;
}