| Author |
interogating an array object
|
k duffy
Greenhorn
Joined: Aug 29, 2004
Posts: 11
|
|
Hello: I am working with the Bridge2Java API from the IBM AlphaWorks. Bridge2Java allows java to communicate with ActiveX objects under Windows. I need to work with the Bloomberg ActiveX object. The object allows you to extact data from the Bloomberg market data service. Refering to the code below. Is there a smarter way to determine if the object returned from the call to blpData.get_BLPSubscribe is an object and what are its dimensions? Many thanks for your help KD import blpdata.*; public class QuickblpData { public static void main(java.lang.String[] args) { blpdata.BlpData blpData; String bbTicker; String[] aFields; String reqField, tmpString ; Object overrideFields; Object overrides; String[] aResults; Object monitor; Class objType; Object[] aObj, aObjd2 ; try { //System.loadLibrary("bridge2java"); com.ibm.bridge2java.OleEnvironment.Initialize(); System.out.println("hello"); blpData = new blpdata.BlpData(); bbTicker = "RHAT.US Equity"; int cookie = 1; aFields = new String[] {"Name", "Company_Tel_Number"}; reqField = "Name"; overrideFields = null; overrides = null; aResults = new String[] { " Name " } ; //new Object(); //monitor = new Object(); blpData.set_SubscriptionMode( _FIRE_EVENT_TYPES.ByRequest ); //blpData.Subscribe( bbTicker, cookie , reqField, overrideFields, overrides, aResults ); Object objResults = blpData.get_BLPSubscribe( bbTicker, reqField ); System.out.println( objResults ); objType = objResults.getClass(); System.out.println( objType.getName() ); if ( objResults instanceof Object ) { if ( objResults instanceof Object[] ) { System.out.println( "it is Object[]" ); aObj = (Object[]) objResults ; System.out.println( aObj.length ); if (aObj[0] instanceof Object[] ) { System.out.println( "aObh[0] is Object[]" ); aObjd2 = (Object[]) aObj[0] ; System.out.println( aObjd2.length ); tmpString = (String) aObjd2[0]; System.out.println( tmpString ); } } } } //try catch (com.ibm.bridge2java.ComException e) { System.out.println( "COM Exception:" ); System.out.println( Long.toHexString((e.getHResult())) ); System.out.println( e.getMessage() ); } catch (Exception e) { System.err.println( e ); System.out.println("message: " + e.getMessage()); } } }
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
|
You're assigning the result to a variable of type Object, so you don't need to check instance of Object again. And you're getting the Class from the object. Look at the JavaDoc for Class for how to tell if it's an array. If it is an array, you can do the same kinda thing for the objects inside the array. Hope that helps!
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: interogating an array object
|
|
|