RE: [Quickfix-developers] checking for field before getting it?
Brought to you by:
orenmnero
|
From: Rob K. <ro...@ri...> - 2003-02-28 18:29:22
|
I wanted to try to avoid having to wrap each attempt to extract a tag =
with a try catch statment. That is what I would have to do in order to =
ensure I can adiquitly handle all messages from my counterparty, while =
still extracting the maximum amount of data I can from each message. If =
there is no SecurityDesc, It isn't a big deal, I would still like to =
continue to process the message. however, if there is a SecurityDesc, I =
would like to know what is is. Maybe I'm just being lazy, but it dosent =
make sense to me to add four lines of code for each attempted =
extraction, when i can just use one to check for the field before trying =
to extract it. something like
if(inMsg.SecurityDescIsPresent) mSecurityDesc =3D =
inMsg.getSecurityDesc();
rather than
try{
mSecurityDesc =3D inMsg.getSecurityDesc();
}
catch(FieldNotFound e){
//do nothing, really.
}
-----Original Message-----
From: Bishop, Barry [mailto:Bar...@gs...]
Sent: Friday, February 28, 2003 12:09 PM
To: Rob Kulseth
Subject: RE: [Quickfix-developers] checking for field before getting it?
Hi Rob,
I assume something is going wrong when you try and extract a value for a =
tag
that is not in the message.
Are you catching FieldNotFound exception?
This will be thrown if your tag is not present. If you catch this for =
each
non-mandatory field you try to access then you can handle a missing tag
there.
Does that make sense?
Best of luck,
barry
-----Original Message-----
From: Rob Kulseth [mailto:ro...@ri...]
Sent: 28 February 2003 17:59
To: Qui...@li...
Subject: [Quickfix-developers] checking for field before getting it?
is there a way to check if a field exists in a message before trying to
extract it. For example the following code extracts FIX info into a =
data
structure. if one of the fields I try to extract are missing, my app =
will
send a reject message. without looking at the actual fix message =
string, I
would like to see if a field is there before I try to get it. If a
particular field is not there, I can maybe fill it in with the correct =
data.
Any help would be appreciated.
public void Update(Fix42.SecurityStatus inMsg){
if(inMsg !=3D null)
{
mSymbol =3D inMsg.getSymbol();
mSecurityID =3D inMsg.getSecurityID();
mSecurityType =3D inMsg.getSecurityType();
mTradingSessionID =3D inMsg.getTradingSessionID();
mUnsolicitedUndicator =3D inMsg.getUnsolicitedIndicator();
mSecurityTradingstatus =3D inMsg.getSecurityTradingStatus();
//mTransactTime =3D inMsg.getTransactTime();
//mSecurityExchange =3D inMsg.getSecurityExchange();
//mSecurityDesc =3D inMsg.getSecurityDesc();
switch(mSecurityType.getValue())
{
case "OPT":
mMaturityMonthYear =3D inMsg.getMaturityMonthYear();
mMaturityDay =3D inMsg.getMaturityDay();
mPutOrCall =3D inMsg.getPutOrCall();
mStrikePrice =3D inMsg.getStrikePrice();
break;
case "FUT":
mMaturityMonthYear =3D inMsg.getMaturityMonthYear();
mMaturityDay =3D inMsg.getMaturityDay();
break;
}
}=09
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Quickfix-developers mailing list
Qui...@li...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers
|