Re: [Quickfix-developers] checking for field before getting it?
Brought to you by:
orenmnero
From: Oren M. <ore...@ya...> - 2003-02-28 18:20:39
|
In C++ there is a isSetField and isSet methods. It just got overlooked when creating the Java API. It will be added at some point. In the meantime you can use exception handling to do the same thing. try { mSecurityExchange = inMsg.getSecurityExchange(); } catch( FieldNotFound fnf ) { mSecurityExchange = DEFAULT_EXCHANGE; } You can also throw fnf back up if you decide you can't determine an appropriate default value. Rob Kulseth <ro...@ri...> wrote: 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 --------------------------------- Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, and more |