User Tools

Site Tools


longvalueobjects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
longvalueobjects [2021/10/12 14:42] – created wikiadminlongvalueobjects [2021/10/12 17:12] (current) – [Storing a Specific Data Type] wikiadmin
Line 34: Line 34:
 See also the examples in this article: [[createvalueobjectscripts| Creating Value Objects in Scripts]] See also the examples in this article: [[createvalueobjectscripts| Creating Value Objects in Scripts]]
  
 +===Storing a Specific Data Type===
 +
 +LongValueObject can store java types boolean,byte,short,int, and long. By default when a new LongValueObject is created, the type is long. To force a specific type to be stored (in case you need to return this value as a specific type), create an Long object and get the value as a specific type:
 +
 +<code javascript>
 +
 +var LongValueObject = Java.type("com.ergotech.vib.valueobjects.LongValueObject");
 +var Long = Java.type("java.lang.Long");
 +
 +javaLong = new Long(100);
 +
 +//now you can get any java type for this value (if it is in range)
 +byteValue = javaLong.byteValue(); //java byte
 +shortValue = javaLong.shortValue(); //java short
 +longValue = javaLong.intValue(); //java int
 +intValue = javaLong.longValue(); //java long
 +
 +
 +//create the LongValueObject and with a specific type
 +vo = new LongValueObject(shortValue); //stores the value as a short in the LongValueObject
 +
 +</code>
longvalueobjects.1634064167.txt.gz · Last modified: by wikiadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki