Re: [Quickfix-developers] Re: more message.getGroup questions.
Brought to you by:
orenmnero
|
From: Brian E. <azz...@ya...> - 2005-10-11 14:40:41
|
Alvin -
The setGroup method appears to only be supported by the C++ and Python
APIs. It does not appear in the .NET or Java (native or JNI) versions.
I don't think setGroup would provide the functionality you require
anyway. setGroup appears to be primarily a string parsing routine - if
you have a string representation of a group, you can ADD that to a
message via setGroup (in a somewhat complicated way). It really is a
support routine for setString (a FIX string parsing routine that takes
a string and populates a FIX message).
Modifying an existing group appears to be impossible with the current
implementation. What you'd really have to do is get copies/clones of
all the group elements via getGroup(), modify each element via
group.setXXX(), delete the existing group (via the patch that I sent
yesterday) and reinsert the group elements via addGroup(). Not exactly
pretty, but it would work.
You should probably add a bug to the tracker asking for better group
manipulation routines - the addition of removeGroup (both the entire
group and single elements of the group) and updateGroup (probably just
at the group element level) would probably be enough.
- Brian Erst
Thynk Software, Inc.
--- Alvin Wang <AW...@FF...> wrote:
> Oren, I am not sure if you are talking about C++ API. But there is no
>
> message.setGroup method in Java API. Pls clarify.
>
> Thanks
> Alvin
>
>
>
>
>
>
> "Oren Miller" <or...@qu...>
> Sent by: qui...@li...
> 10/10/2005 06:16 PM
>
>
> To: <azz...@ya...>, "Alvin Wang"
> <AW...@FF...>
> cc: "Caleb Epstein" <cal...@gm...>,
> <qui...@li...>,
> <qui...@li...>
> bcc:
> Subject: [Quickfix-developers] Re: more
> message.getGroup questions.
>
>
> You are actually getting a clone of the group, you will need to call
> setGroup with the modified group.
>
> --oren
> ----- Original Message -----
> From: Alvin Wang
> To: azz...@ya...
> Cc: Caleb Epstein ; Oren Miller ;
> qui...@li... ;
> qui...@li...
> Sent: Tuesday, October 11, 2005 12:18 AM
> Subject: more message.getGroup questions.
>
>
> OK, now I am doing something like this:
>
> Group group = new Group(NoAllocs.FIELD,
> AllocAccount.FIELD);
> allocationInstruction.getGroup(1, group);
> group.setDouble(9047, 100);//add a custom tag 9047 to the
> group
> //Then send out allocationInstruction
>
> However, tag 9047 will not show up in the Allocation Message I
> created.
> Why?
>
>
> Also, I wrote my own removeGroup mehtod as below:
>
> public static void removeGroups(Message message, int noField, int
>
> delimField)
> throws Exception
> {
> for (int i = 1; i <= message.getInt(noField); i++)
> {
> Group group = new Group(noField, delimField);
> message.getGroup(i, group);
> for (Iterator it = group.iterator(); it.hasNext();)
> {
> Field field = (Field)it.next();
> group.removeField(field.getField());
> }
> }
>
> message.removeField(noField);
> }
>
> But after running it, I found the group is still there. Can anyone
> explain
> for me what is going on here? It seems that the group in
> message.getGroup(i, group) method is a "cloned" copy of the original.
> So changing it will not change
> the original. So how to change the original? What about the returned
> value
> of message.getGroup method?
>
> Thanks a lot!
> Also Brian, thanks so much for your help.
> Alvin
>
>
>
>
>
> Brian Erst <azz...@ya...>
> 10/10/2005 02:47 PM
> Please respond to azzipsderf-quickfix
>
> To: Alvin Wang <AW...@FF...>,
> qui...@li...,
> qui...@li...,
> azz...@ya...
> cc: Caleb Epstein <cal...@gm...>, Oren
> Miller
> <or...@qu...>
> bcc:
> Subject: Re: [Quickfix-developers] getGroup
>
>
>
> Alvin -
>
> I don't know the Java side very well (I've coded to the C++ and .NET
> versions), but the getGroup function is pretty simple.
>
> First, you need to know the name of the field that acts as the
> group's
> enumerator/designator. These almost always start with "No" (as in
> "number"). You should check for the existence of that field - if it
> isn't there, there won't be any group members either.
>
> One example of this is the Legs group in NewOrderMultileg. This group
> begins with a "NoLegs" field (defined as an IntField) that contains
> the
> number of legs.
>
> In C++ -
>
> FIX::NoLegs noLegs;
> if (message.isSetField(noLegs))
> {
> message.getField(noLegs);
> for (int i=0; i<noLegs.getValue(); i++)
> ...
>
>
> In C#, we'd use the built-in field getters -
>
> if (message.isSetNoLegs())
> {
> for (int i=0; i<message.getNoLegs().getValue(); i++)
> ...
>
> Second, you need to create a group object of the type you wish to
> extract. In the C++ and .NET versions, these are defined as
> sub-classes
> of the parent message type with a class name that is the same as the
> field name of the enumeration field mentioned above.
>
> In C++ -
>
> FIX::NewOrderMultileg::NoLegs leg;
>
> In C# -
>
> QuickFix43.NewOrderMultileg.NoLegs leg = new
> QuickFix43.NewOrderMultileg.NoLegs();
>
>
> Third, you use the "getGroup" method of the Message object to
> retrieve
> a single element of the repeating group list. These elements are
> indexed starting at "1", not "0".
>
> In C++ -
>
> message.getGroup(1, leg);
>
> In C# -
>
> message.getGroup(1, leg);
>
>
> Full example, C++:
>
> FIX::NoLegs noLegs;
> if (message.isSetField(noLegs))
> {
> FIX::NewOrderMultileg::NoLegs leg;
> FIX::LegSide legSide;
>
> message.getField(noLegs);
> for (int i=0; i<noLegs.getValue(); i++)
> {
> message.getGroup(i+1, leg);
> leg.get(legSide);
> if (legSide.getValue() == FIX::Side_BUY)
> ...
> }
> }
>
> Full example, C#:
>
> if (message.isSetNoLegs())
> {
> QuickFix43.NewOrderMultileg.NoLegs leg = new
> QuickFix43.NewOrderMultileg.NoLegs();
>
> for (int i=0; i<message.getNoLegs().getValue(); i++)
> {
> message.getGroup(i+1, leg);
> if (leg.getLegSide().getValue() == QuickFix.Side.BUY)
>
=== message truncated ===
|