Class PModelHandle

java.lang.Object
com.portal.bas.PModelHandle
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
PCollectingModelHandle

public class PModelHandle extends Object implements Serializable
PModelHandle passes a reference to a database object: basically, a handle to an flist, whether that flist is an opcode return value, a POID member of another flist, a substruct, or an array element. Because it is a handle, it may not have actually been read from the Portal database yet, so calls to access fields must make a connection.

A model handle provides a hash value: however, it can also be typed to indicate the type of the object it refers to. Also, when a model handle is created from a POID, it is very useful to use the POID's type as the handle's type and the POID's ID as the hash value. However, the POID's ID is a different size than provided by Object.hashCode(). To re-create the original POID from the model handle, the full value is needed, which is why there are two hash methods included in this class.

Version:
5
Author:
Larry Lynch-Freshner
See Also:
  • Field Details

    • UNTYPED

      public static final String UNTYPED
      A constant that provides a default value for creating an untyped model handle.
      See Also:
    • LOOKUP_UPDATE_IF_NEEDED

      public static final int LOOKUP_UPDATE_IF_NEEDED
      See Also:
    • LOOKUP_FORCE_UPDATE

      public static final int LOOKUP_FORCE_UPDATE
      See Also:
    • LOOKUP_DONT_UPDATE

      public static final int LOOKUP_DONT_UPDATE
      See Also:
  • Constructor Details

    • PModelHandle

      protected PModelHandle()
      Creates a model handle by assigning it a simple seed value.
    • PModelHandle

      protected PModelHandle(PModelHandle mh)
      Copies a model handle.
      Parameters:
      mh - the model handle to copy
    • PModelHandle

      protected PModelHandle(String type, long hash, boolean hashGiven, Object model)
      Initializes the model handle with type, hash, and hashGiven. This is the ctor that all other ctors call.
  • Method Details

    • getType

      public String getType()
      Returns the type of model. May correspond to database type.
      Returns:
      A String that defines the type of model.
    • hashCode

      public int hashCode()
      Gets the hash value. Called by collection using hashing. This produces a valid hash value even if the internal number is a different size. Overrides Object.hashCode().
      Overrides:
      hashCode in class Object
      Returns:
      The hash value.
    • getHash

      public long getHash()
      Gets the actual hashCode (a long). This is usually called by the framework when re-creating a POID from a model handle.
      Returns:
      The hashCode.
    • isGivenHash

      public boolean isGivenHash()
      Tests to determine if the handle was given the hash value to use. For example, it returns true if the handle was created from a POID.
      Returns:
      True if the handle was given the hash value to use; false otherwise.
    • getModel

      public Object getModel()
    • equals

      public boolean equals(Object other)
      Overrides Object.equals. Used as an equality test.
      Overrides:
      equals in class Object
      Parameters:
      other - the Object to test against
      Returns:
      True if equal; false otherwise.
    • toString

      public String toString()
      Gets a string representation of the model.
      Overrides:
      toString in class Object
      Returns:
      The model's String representation.