• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

interogating an array object

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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());
}

}
}
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic