[Quickfix-developers] more message.getGroup questions.
Brought to you by:
orenmnero
|
From: Alvin W. <AW...@FF...> - 2005-10-10 21:06:59
|
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)
...
}
}
Hope this helps.
- Brian Erst
Thynk Software, Inc.
--- Alvin Wang <AW...@FF...> wrote:
> public native Group getGroup(int int0, Group group) throws
> FieldNotFound;
>
> Hi, Can anyone tell me how to use the getGroup method in Message
> class?
> What are the 2 parameters? what does it return?
>
> BTW, quickfix is wonderful. Hopefully its document is as good as it.
>
> Thanks
> Alvin
>
>
>
>
>
>
>
**********************************************************************
> This e-mail message is intended solely for the use of the addressee.
> The message may contain information that is privileged and
> confidential.
> Disclosure to anyone other than the intended recipient is
> prohibited. If you are not the intended recipient, please do not
> disseminate, distribute or copy this communication, by e-mail or
> otherwise. Instead, please notify us immediately by return e-mail
> (including the original message with your reply) and then delete
> and discard all copies of the message. We have taken precautions to
> minimize the risk of transmitting software viruses but nevertheless
> advise you to carry out your own virus checks on any attachment to
> this message. We accept no liability for any loss or damage caused
> by software viruses.
>
**********************************************************************
>
>
|