Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

Primitive Class Template Reference

#include <coherence/lang/Primitive.hpp>

Inherits Object, and Comparable.

List of all members.


Detailed Description

template<class T>
class coherence::lang::Primitive< T >

Template class which converts primitive data types into immutable managed objects.

Author:
jh/mf 2007.07.05
 

Public Types

typedef spec::Handle Handle
 Primitive<T> Handle definition.
typedef spec::View View
 Primitive<T> View definition.
typedef spec::Holder Holder
 Primitive<T> Holder definition.
typedef T BoxedType
 The boxed primitive type.

Public Member Functions

virtual T getValue () const
 Return the primitive value.
 operator T () const
 Return the primitive value.
virtual int32_t compareTo (Object::View v) const
 Compare this object with the specified object for order.

Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.

It is strongly recommended, but not strictly required, that (x->compareTo(y) == 0) == (x->equals(y)).

Parameters:
 v the Object to be compared
Returns:
a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object
Exceptions:
 ClassCastException if the specified Object's type prevents it from being compared to this Object
virtual bool equals (Object::View v) const
 Return true iff the specified Object is "equal" to this Object.

This method implements an equivalence relation on Objects:

  • It is reflexive: for any non-null handle h, h->equals(h) must return true.
  • It is symmetric: for any non-null handles h1 and h2, h1->equals(h2) should return true if and only if h2->equals(h1) returns true.
  • It is transitive: for any non-null handles h1, h2, and h3, if h1->equals(h2) returns true and h2->equals(h3) returns true, then h1->equals(h3) should return true.
  • It is consistent: for any non-null handles h1 and h2, multiple invocations of h1->equals(h2) consistently return true or consistently return false, provided no information used in comparisons on the objects is modified.
  • If the supplied handle is NULL then false must be returned.

The default implementation is a reference equality comparison.

Parameters:
 v the Object::View to compare against, may be NULL
Returns:
true iff the given handle references an Object that is "equal" to this Object
See also:
equals(Object::View v1, Object::View v2)
virtual size32_t hashCode () const
 Return a hash code value for the Object.

This method is supported for the benefit of hash-based containers.

The general contract of hashCode is:

  • Whenever it is invoked on the same Object more than once during an execution of an application, the hashCode method must consistently return the same value, provided no information used in equals comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application.
  • If two Objects are equal according to the equals method, then calling the hashCode method on each of the two Objects must produce the same value.
  • It is not required that if two Objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers.

The default implementation is identity based.

Returns:
a hash code value for this Object
virtual bool isImmutable () const
 
Returns:
true
virtual void toStream (std::ostream &out) const
 
Returns:
true

Static Public Member Functions

static T parse (String::View vs)
 Return the primitive representation of a String.

Protected Member Functions

 Primitive (const Primitive< T > &that)
 Copy constructor.

Protected Attributes

m_value
 The wrapped primitive value.

Member Function Documentation

virtual T getValue (  )  const [virtual]

Return the primitive value.

Returns:
the primitive value

operator T (  )  const

Return the primitive value.

Returns:
The primitive value

static T parse ( String::View  vs  )  [static]

Return the primitive representation of a String.

Parameters:
 vs the String to covert to a primitive type
Returns:
the primitive representation of the string
Exceptions:
 IllegalArgumentException if the supplied String is not convertible to the primitive type. NULL is considered an illegal argument except for the bool type, where it results in a bool(false).


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.