activemq-cpp-3.6.0
decaf::lang::System Class Reference

The System class provides static methods for accessing system level resources and performing some system dependent tasks such as looking up environment values and copying memory and arrays. More...

#include <src/main/decaf/lang/System.h>

Public Member Functions

virtual ~System ()

Static Public Member Functions

static void arraycopy (const char *src, std::size_t srcPos, char *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const unsigned char *src, std::size_t srcPos, unsigned char *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const short *src, std::size_t srcPos, short *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const int *src, std::size_t srcPos, int *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const long long *src, std::size_t srcPos, long long *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const float *src, std::size_t srcPos, float *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static void arraycopy (const double *src, std::size_t srcPos, double *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
template<typename E >
static void arraycopy (const E *src, std::size_t srcPos, E *dest, std::size_t destPos, std::size_t length)
 Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.
static const util::Map
< std::string, std::string > & 
getenv ()
 Enumerates the system environment and returns a map of env variable names to the string values they hold.
static std::string getenv (const std::string &name)
 Reads an environment value from the system and returns it as a string object.
static void unsetenv (const std::string &name)
 Clears a set environment value if one is set.
static void setenv (const std::string &name, const std::string &value)
 Sets the specified system property to the value given.
static long long currentTimeMillis ()
 Returns the current time in milliseconds.
static long long nanoTime ()
 Returns the current value of the most precise available system timer, in nanoseconds.
static int availableProcessors ()
 Returns the number of processors available for execution of Decaf Threads.
static decaf::util::PropertiesgetProperties ()
 Gets the Properties object that holds the Properties accessed from calls to getProperty and setProperty.
static std::string getProperty (const std::string &key)
 Gets the specified System property if set, otherwise returns an empty string.
static std::string getProperty (const std::string &key, const std::string &defaultValue)
 Gets the specified System property if set, otherwise returns the specified default value.
static std::string setProperty (const std::string &key, const std::string &value)
 Sets the System Property to the specified value.
static std::string clearProperty (const std::string &key)
 Clear any value associated with the system property specified.

Protected Member Functions

 System ()

Friends

class decaf::lang::Runtime

Detailed Description

The System class provides static methods for accessing system level resources and performing some system dependent tasks such as looking up environment values and copying memory and arrays.

Since
1.0

Constructor & Destructor Documentation

decaf::lang::System::System ( )
protected
virtual decaf::lang::System::~System ( )
inlinevirtual

Member Function Documentation

static void decaf::lang::System::arraycopy ( const char *  src,
std::size_t  srcPos,
char *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.

Referenced by decaf::util::concurrent::CopyOnWriteArrayList< E >::addAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addAllAbsent(), decaf::lang::ArrayPointer< HashMapEntry * >::clone(), decaf::util::ArrayList< Pointer< ActiveMQDestination > >::ensureCapacity(), decaf::util::ArrayList< Pointer< ActiveMQDestination > >::removeAt(), and decaf::util::ArrayList< Pointer< ActiveMQDestination > >::trimToSize().

static void decaf::lang::System::arraycopy ( const unsigned char *  src,
std::size_t  srcPos,
unsigned char *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
static void decaf::lang::System::arraycopy ( const short *  src,
std::size_t  srcPos,
short *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
static void decaf::lang::System::arraycopy ( const int *  src,
std::size_t  srcPos,
int *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
static void decaf::lang::System::arraycopy ( const long long *  src,
std::size_t  srcPos,
long long *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
static void decaf::lang::System::arraycopy ( const float *  src,
std::size_t  srcPos,
float *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
static void decaf::lang::System::arraycopy ( const double *  src,
std::size_t  srcPos,
double *  dest,
std::size_t  destPos,
std::size_t  length 
)
static

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.
template<typename E >
static void decaf::lang::System::arraycopy ( const E *  src,
std::size_t  srcPos,
E *  dest,
std::size_t  destPos,
std::size_t  length 
)
inlinestatic

Copies the number of elements specified by length from the source array starting at the given source offset specified by srcPos to the dest array starting at the given destination offset given by destPos.

Parameters
srcThe source array to copy from.
srcPosThe position in the array to start copying from.
destThe destination array to copy to.
destPosThe position in the destination array to start writing at.
lengthThe number of elements to copy from src to dest.
Exceptions
NullPointerExceptionif src or dest are NULL.

References NULL.

static int decaf::lang::System::availableProcessors ( )
static

Returns the number of processors available for execution of Decaf Threads.

This value may change during a particular execution of a Decaf based application. Applications that are sensitive to the number of available processors should therefore occasionally poll this property and adjust their resource usage appropriately.

Returns
the number of available processors.
static std::string decaf::lang::System::clearProperty ( const std::string &  key)
static

Clear any value associated with the system property specified.

Parameters
keyThe key name of the system property to clear.
Returns
the previous value of the property named by key if there was one, otherwise returns an empty string.
Exceptions
IllegalArgumentExceptionif key is an empty string.
static long long decaf::lang::System::currentTimeMillis ( )
static

Returns the current time in milliseconds.

Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC).

Returns
the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
static const util::Map<std::string, std::string>& decaf::lang::System::getenv ( )
static

Enumerates the system environment and returns a map of env variable names to the string values they hold.

Returns
A Map of all environment variables.
Exceptions
Exceptionif an error occurs while getting the Environment Map.
static std::string decaf::lang::System::getenv ( const std::string &  name)
static

Reads an environment value from the system and returns it as a string object.

Parameters
nameThe environment variable to read.
Returns
a string with the value from the variables or ""
Exceptions
anException if an error occurs while reading the Env.
static decaf::util::Properties& decaf::lang::System::getProperties ( )
static

Gets the Properties object that holds the Properties accessed from calls to getProperty and setProperty.

If the Properties has not yet been created or are not yet initialized then they will be on the first call to a Properties accessor.

Returns
a reference to the static system Properties object.
static std::string decaf::lang::System::getProperty ( const std::string &  key)
static

Gets the specified System property if set, otherwise returns an empty string.

If the Properties has not yet been created or are not yet initialized then they will be on the first call to a Properties accessor.

Parameters
keyThe key name of the desired system property to retrieve.
Returns
an empty string if the named property is not set, otherwise returns the value.
Exceptions
IllegalArgumentExceptionif key is an empty string.
static std::string decaf::lang::System::getProperty ( const std::string &  key,
const std::string &  defaultValue 
)
static

Gets the specified System property if set, otherwise returns the specified default value.

If the Properties has not yet been created or are not yet initialized then they will be on the first call to a Properties accessor.

Parameters
keyThe key name of the desired system property to retrieve.
defaultValueThe default value to return if the key is not set in the System properties.
Returns
the value of the named system property or the defaultValue if the property isn't set..
Exceptions
IllegalArgumentExceptionif key is an empty string.
static long long decaf::lang::System::nanoTime ( )
static

Returns the current value of the most precise available system timer, in nanoseconds.

This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary time (perhaps in the future, so values may be negative). This method provides nanosecond precision, but not necessarily nanosecond accuracy. No guarantees are made about how frequently values change. Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow.

For example, to measure how long some code takes to execute:

long long startTime = System::nanoTime(); // ... the code being measured ... long long estimatedTime = System::nanoTime() - startTime;

Returns
The current value of the system timer, in nanoseconds.
static void decaf::lang::System::setenv ( const std::string &  name,
const std::string &  value 
)
static

Sets the specified system property to the value given.

Parameters
nameThe name of the environment variables to set.
valueThe value to assign to name.
Exceptions
anException if an error occurs when setting the environment variable.
static std::string decaf::lang::System::setProperty ( const std::string &  key,
const std::string &  value 
)
static

Sets the System Property to the specified value.

Parameters
keyThe key name of the system property to set to the given value.
valueThe value to assign to the key.
Returns
the previous value of the property named by key if there was one, otherwise returns an empty string.
Exceptions
IllegalArgumentExceptionif key is an empty string.
static void decaf::lang::System::unsetenv ( const std::string &  name)
static

Clears a set environment value if one is set.

Parameters
nameThe environment variables to clear.
Exceptions
anException if an error occurs while reading the environment.

Friends And Related Function Documentation

friend class decaf::lang::Runtime
friend

The documentation for this class was generated from the following file: