public static FastMessage convert(Group group, FastMessage groupMsg, ConversionContext context) {
   setNameAndId(group, groupMsg);
   if (group.getTypeReference() != null
       && !FastConstants.ANY_TYPE.equals(group.getTypeReference())) {
     GroupValue typeRef =
         new GroupValue(
             (Group)
                 SessionControlProtocol_1_1.TYPE_REF.getField(
                     new QName("TypeRef", SessionControlProtocol_1_1.NAMESPACE)));
     setName(typeRef, group.getTypeReference());
     groupMsg.setFieldValue("TypeRef", typeRef);
   }
   SequenceValue instructions =
       new SequenceValue(
           SessionControlProtocol_1_1.TEMPLATE_DEFINITION.getSequence("Instructions"));
   int i = group instanceof MessageTemplate ? 1 : 0;
   Field[] fields = group.getFieldDefinitions();
   for (; i < fields.length; i++) {
     Field field = fields[i];
     FieldInstructionConverter converter = context.getConverter(field);
     if (converter == null)
       throw new IllegalStateException("No converter found for type " + field.getClass());
     FieldValue value = converter.convert(field, context);
     instructions.add(new FieldValue[] {value});
   }
   groupMsg.setFieldValue("Instructions", instructions);
   return groupMsg;
 }
 public Field convert(
     GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context) {
   String name = fieldDef.getString("Name");
   String namespace = "";
   if (fieldDef.isDefined("Ns")) namespace = fieldDef.getString("Ns");
   Field[] fields = parseFieldInstructions(fieldDef, templateRegistry, context);
   boolean optional = fieldDef.getBool("Optional");
   Group group = new Group(new QName(name, namespace), fields, optional);
   if (fieldDef.isDefined("TypeRef")) {
     GroupValue typeRef = fieldDef.getGroup("TypeRef");
     String typeRefName = typeRef.getString("Name");
     String typeRefNs = ""; // context.getNamespace();
     if (typeRef.isDefined("Ns")) typeRefNs = typeRef.getString("Ns");
     group.setTypeReference(new QName(typeRefName, typeRefNs));
   }
   if (fieldDef.isDefined("AuxId")) {
     group.setId(fieldDef.getString("AuxId"));
   }
   return group;
 }