// Index out of bound exception public void GetStaticStruct(String[] args) throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(15); // obtained from the IDL or TypeLib. // Object results[]; JIStruct varStruct = new JIStruct(); varStruct.addMember(JIUnsignedInteger.class); varStruct.addMember(Float.class); varStruct.addMember(Float.class); varStruct.addMember(JIUnsignedShort.class); varStruct.addMember(Float.class); varStruct.addMember(Date.class); varStruct.addMember(JIUnsignedInteger.class); JIStruct pointStruct = new JIStruct(); pointStruct.addMember(JIUnsignedInteger.class); pointStruct.addMember(JIUnsignedInteger.class); pointStruct.addMember(Byte.class); JIArray structArray = new JIArray(varStruct, null, 1, true); pointStruct.addMember(new JIPointer(structArray)); JIArray DataArray = new JIArray(pointStruct, null, 1, true); callObject.addOutParamAsType(JIUnsignedShort.class, JIFlags.FLAG_NULL); callObject.addOutParamAsObject(new JIPointer(DataArray, false), JIFlags.FLAG_NULL); results = comObject.call(callObject); System.out.println(((JIUnsignedShort) results[0]).getValue()); }
// [helpstring("20 method GetSimpleArrayStructArray")] HRESULT GetSimpleArrayStructArray([out] // unsigned short* unDataSize, // [out, size_is(,*unDataSize)] SimpleArrayStruct** pp); public void GetSimpleArrayStructArray(String[] args) throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(20); // obtained from the IDL or TypeLib. // Object results[]; JIStruct simpleStruct = new JIStruct(); simpleStruct.addMember(Integer.class); simpleStruct.addMember(Double.class); simpleStruct.addMember(Float.class); JIStruct simpleArrayStruct = new JIStruct(); simpleArrayStruct.addMember(Integer.class); simpleArrayStruct.addMember(Double.class); simpleArrayStruct.addMember(JIUnsignedShort.class); JIArray structArray = new JIArray(simpleStruct, null, 1, true); simpleArrayStruct.addMember(new JIPointer(structArray)); // try no pointer next JIArray DataArray = new JIArray(simpleArrayStruct, null, 1, true); callObject.addOutParamAsType(JIUnsignedShort.class, JIFlags.FLAG_NULL); callObject.addOutParamAsObject(new JIPointer(DataArray), JIFlags.FLAG_NULL); results = comObject.call(callObject); System.out.println(((JIUnsignedShort) results[0]).getValue()); }
public void getSimpleStruct(String[] args) throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(12); // obtained from the IDL or TypeLib. // Object results[]; JIStruct struct = new JIStruct(); struct.addMember(Integer.class); struct.addMember(Double.class); struct.addMember(Float.class); callObject.addOutParamAsObject(new JIPointer(struct), JIFlags.FLAG_NULL); results = comObject.call(callObject); System.out.println(results[0]); }
public void getTCharArray() throws JIException, InterruptedException, UnknownHostException { System.gc(); JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(6); Object results[]; callObject.addOutParamAsObject( new JIArray(Byte.class, new int[] {50}, 1, false), JIFlags.FLAG_NULL); results = comObject.call(callObject); JIArray arrayOfResults = (JIArray) results[0]; Byte[] arrayOfBytes = (Byte[]) arrayOfResults.getArrayInstance(); int length = 50; for (int i = 0; i < length; i++) { System.out.println(arrayOfBytes[i].byteValue()); } }
public void getConformantStruct(String[] args) throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(14); // obtained from the IDL or TypeLib. // Object results[]; JIStruct struct = new JIStruct(); struct.addMember(Integer.class); struct.addMember(Double.class); struct.addMember(JIUnsignedShort.class); JIArray longArray = new JIArray(Integer.class, null, 1, true); struct.addMember(new JIPointer(longArray)); callObject.addOutParamAsObject(new JIPointer(struct), JIFlags.FLAG_NULL); results = comObject.call(callObject); System.out.println(results[0]); }
public void GetStruct(String[] args) throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(10); // obtained from the IDL or TypeLib. // Object results[]; // change the struct to have the array as the last item JIStruct struct = new JIStruct(); JIArray longArray = new JIArray(Integer.class, new int[] {50}, 1, false); struct.addMember(Integer.class); struct.addMember(Float.class); struct.addMember(longArray); callObject.addOutParamAsObject(new JIPointer(struct), JIFlags.FLAG_NULL); results = comObject.call(callObject); System.out.println(results[0]); }
public void getConformantIntArray() throws JIException, InterruptedException, UnknownHostException { JICallBuilder callObject = new JICallBuilder(true); callObject.setOpnum(8); Object results[]; callObject.addOutParamAsType(Integer.class, JIFlags.FLAG_NULL); callObject.addOutParamAsObject( new JIPointer(new JIArray(Integer.class, null, 1, true)), JIFlags.FLAG_NULL); results = comObject.call(callObject); JIArray arrayOfResults = (JIArray) ((JIPointer) results[1]).getReferent(); Integer[] arrayOfIntegers = (Integer[]) arrayOfResults.getArrayInstance(); int length = ((Integer) results[0]).intValue(); for (int i = 0; i < length; i++) { System.out.println(arrayOfIntegers[i].intValue()); } }