<Default Package>
Type integer


64-bit signed integer type.

Values of the integer type are negative, zero, and positive integers encoded as 64-bit signed two's complement binary integers. The lowest negative value that can be stored in a variable of type integer is -9223372036854775808 (or -263) and the highest positive value that can be stored is 9223372036854775807 (or 263 - 1). The default value is 0.

Integers can be parsed and they are routable and comparable. Integers are non-cyclic.

Integers have the following operators available on them:

<Less-than comparison
<=Less-than or equal comparison
=Equal comparison
!=Not equal comparison
>Greater-than comparison
>=Greater-than or equals comparison
+Unary integral identity
-Unary integral additive inverse
+Integral addition
-Integral subtraction
*Integral multiplication
/Integral division
%Integral remainder
orBitwise or
andBitwise and
xorBitwise exclusive or
notUnary bitwise inverse
>>Bitwise shift right
<<Bitwise shift left


An attempt to divide by zero (0) or to compute a remainder of zero will throw an exception. Overflows and underflows are ignored.

When you use the shift operators, the sign of a result value can differ from that of the operand value being shifted. When you use not, the sign of the result value will be the opposite of that of its operand.
Constant summary
 integerMAX

Largest positive value an integer can take (263-1).
 integerMIN

Largest negative value an integer can take (-263).
 
Action summary
 integerabs()

Get the absolute value of i.
 booleanstatic canParse(string s)

Check if the string argument can be parsed as an integer.
 integerstatic getUnique()

Get a globally-unique integer.
 integerhash()

Get an integer hash representation of the underlying object.
 integerstatic incrementCounter(string name)

Increment and return the value of a named counter. Counters are useful as unique identifiers for request-response.
 integerstatic max(integer a, integer b)

Return the larger of two integers.
 integerstatic min(integer a, integer b)

Return the smaller of two integers.
 integerstatic parse(string s)

Parse a string into an integer.
 integerpow(integer exp)

Calculate this number to the power of the exponent.
 integerrand()

Generate a random number.
 decimaltoDecimal()

Convert this integer to a decimal.
 floattoFloat()

Convert this integer to a float.
 stringtoString()

Convert this integer to a string.
 
Constant detail

MAX

integer MAX
Largest positive value an integer can take (263-1).

MIN

integer MIN
Largest negative value an integer can take (-263).
Action detail

abs

integer abs()
Get the absolute value of i.

If i is negative, this returns -i. Otherwise, it returns i.
Returns:
The absolute value of i.

canParse

boolean static canParse(string s)
Check if the string argument can be parsed as an integer.
Parameters:
s - The string to test for parseability.
Returns:
True if the string could be parsed as an integer, false otherwise.
See Also:
integer#parse() - See the parse method for what is parseable.

getUnique

integer static getUnique()
Get a globally-unique integer.

Generates a unique integer in the scope of the correlator. It returns an integer that is unique for the correlator session's lifetime.

With correlator persistence enabled, the getUnique() counter is persisted and recovered so that it is not lost on a restart. Without persistence, when the correlator is shut down and restarted, then the integers returned might be the same as some or all of the values produced in the earlier session.

No guarantees about the value of the integer are made, other than being unique within a single correlator.
Returns:
A unique integer.
See Also:
integer#incrementCounter() - Use incrementCounter if you want a monotonically increasing counter. Due to the increased predictability of the values returned by incrementCounter() and the fact they're unaffected by identifiers generated by other parts of the application, use of incrementCounter (with a suitable key) is recommended over getUnique() in situations where the value will be shared with components outside the correlator, such as for request-response identifiers passed to a connectivity plugin or adapter. This can make unit testing easier, and increases the chance of successfully reproducing application behaviour from an input log. However getUnique() is a great choice for identifiers that are not shared outside the correlator.
com.apama.correlator.Component#getComponentPhysicalId() - Combine this with the PhysicalId to get a number that is unique across a cluster of correlators.

hash

integer hash()
Get an integer hash representation of the underlying object.

This function will return an integer evenly distributed over the whole range suitable for partitioning or indexing of that structure. Multiple different object can resolve to the same hash value.
Returns:
An integer respresentation of the underlying object.

incrementCounter

integer static incrementCounter(string name)
Increment and return the value of a named counter. Counters are useful as unique identifiers for request-response.

Generates a monotonically increasing integer for the specified string key, in the scope of this correlator instance. It returns an integer that is larger than the previously returned value in the correlator session's lifetime for the string key provided.

With correlator persistence enabled, counters are persisted and recovered so that they are not lost on a restart. Without persistence, when the correlator is shut down and restarted, then the integers returned might be the same as some or all of the values produced in the earlier session.

Due to the increased predictability of the values returned by incrementCounter() and the fact they're unaffected by identifiers generated by other parts of the application, use of incrementCounter (with a suitable key) is recommended over getUnique() in situations where the value will be shared with components outside the correlator, such as for request-response identifiers passed to a connectivity plugin or adapter. Predictable identifiers make unit testing easier, and also increase the chance of successfully reproducing application behaviour from an input log if needed.

Keep in mind that using this function with a large number of keys will result in a memory leak. Therefore the keys should be static rather than dynamic, and the total number of keys in use should be kept small.
Parameters:
name - The unique key identifying the counter to increment, for example "HTTPClientRequestId".
Returns:
The next integer for the named counter. Returned values will be 1, 2, 3, and so on for each key. The returned numbers are 64-bit signed integers.

max

integer static max(integer a, integer b)
Return the larger of two integers.
Parameters:
a - The first number to compare.
b - The second number to compare.
Returns:
The larger of a and b.

min

integer static min(integer a, integer b)
Return the smaller of two integers.
Parameters:
a - The first number to compare.
b - The second number to compare.
Returns:
The smaller of a and b.

parse

integer static parse(string s)
Parse a string into an integer.

Integers are written in base 10 and may not have any extra trailing or preceeding characters.
Parameters:
s - The string to parse.
Returns:
The integer corresponding to the string.
Throws:
Throws ParseException if the string cannot be parsed as an integer.
See Also:
string#toInteger() - string.toInteger will convert an integer in the presence of trailing characters.

pow

integer pow(integer exp)
Calculate this number to the power of the exponent.
Parameters:
exp - The exponent to raise this integer to.
Returns:
Returns iexp.
Throws:
Throws ArithmeticException if exp is negative.

rand

integer rand()
Generate a random number.

Returns a random integer value from 0 up to (but not including) the value of the variable the method was invoked on. If the operand is negative, then it returns a random integer from the value of the variable the method was invoked on up to 0. 0.rand() always returns 0.

Caution: This random number generator is verified not to be cryptographically strong. Therefore, it should not be used for purposes where a strong random number is required.
Returns:
A random integer between 0 and n.

toDecimal

decimal toDecimal()
Convert this integer to a decimal.
Returns:
The nearest representable decimal to this integer.

toFloat

float toFloat()
Convert this integer to a float.
Returns:
The nearest representable float to this integer.

toString

string toString()
Convert this integer to a string.
Returns:
This integer as a string of base-10 digits.