RE: [Quickfix-developers] checking for field before getting it?
Brought to you by:
orenmnero
|
From: Oren M. <ore...@ya...> - 2003-02-28 18:56:09
|
Understood. That is why the method was added to C++ to begin with. I was trying to give a workaround until the JNI code is created. If you want you want a little better flow you can write a method like this in the base message class:
boolean isSet( Class fieldClass ) {
Field field = (Field)fieldClass.newInstance();
try {
getField( field );
return true;
}
catch( FieldNotFound fnf ) {}
return false;
}
then you can write your if statement like this.
if( inMsg.isSet(SecurityExchange.class) mSecurityDesc = inMsg.getSecurityDesc;
Again. Ugly and inneficient, but temporary workaround.
Rob Kulseth <ro...@ri...> wrote:
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 = inMsg.getSecurityDesc();
rather than
try{
mSecurityDesc = 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 != null)
{
mSymbol = inMsg.getSymbol();
mSecurityID = inMsg.getSecurityID();
mSecurityType = inMsg.getSecurityType();
mTradingSessionID = inMsg.getTradingSessionID();
mUnsolicitedUndicator = inMsg.getUnsolicitedIndicator();
mSecurityTradingstatus = inMsg.getSecurityTradingStatus();
//mTransactTime = inMsg.getTransactTime();
//mSecurityExchange = inMsg.getSecurityExchange();
//mSecurityDesc = inMsg.getSecurityDesc();
switch(mSecurityType.getValue())
{
case "OPT":
mMaturityMonthYear = inMsg.getMaturityMonthYear();
mMaturityDay = inMsg.getMaturityDay();
mPutOrCall = inMsg.getPutOrCall();
mStrikePrice = inMsg.getStrikePrice();
break;
case "FUT":
mMaturityMonthYear = inMsg.getMaturityMonthYear();
mMaturityDay = inMsg.getMaturityDay();
break;
}
}
}
-------------------------------------------------------
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
-------------------------------------------------------
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
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more |