com.flexive.shared.content
Class FxPK

java.lang.Object
  extended by com.flexive.shared.content.FxPK
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<FxPK>
Direct Known Subclasses:
ReferencedContent

public class FxPK
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<FxPK>

Primary key for FxContents

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
protected  long id
           
static int LIVE
          Constant to select the version whose workflow step is flagged as live
static int MAX
          Constant to select the maximum available version
static int NEW_ID
          Id to use for new instances (flags them as new)
protected  int version
           
 
Constructor Summary
FxPK()
          Constructor for new FxContents
FxPK(long id)
          Ctor, version is initialized with MAX
FxPK(long id, int version)
          Ctor
 
Method Summary
 int compareTo(FxPK o)
           
static FxPK createNewPK()
          Create a new primary key
 boolean equals(java.lang.Object obj)
           Note: FxPKs with generic version information like LIVE or MAX will return "false" if they are checked for equality with FxPKs that contain a distinct version information.
static FxPK fromObject(java.lang.Object value)
          Extract a PK from the given object.
static FxPK fromString(java.lang.String value)
          Construct a primary key from a String
 long getId()
          Getter for the id
static java.util.List<java.lang.Long> getIds(java.util.Collection<? extends FxPK> pks)
          Extracts the IDs of the given PK collection.
static java.util.List<FxPK> getPks(java.util.Collection<java.lang.Long> ids)
          Wrap the content IDs in FxPK objects.
 TypeStorageMode getStorageMode()
          Get the storage mode for this primary key.
 int getVersion()
          Getter for the version.
 int hashCode()
          
 boolean isDistinctVersion()
          Does this primary key point to a distinct version or is it something like maximum or live version?
 boolean isNew()
          Is this primary key for a new FxContent?
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NEW_ID

public static final int NEW_ID
Id to use for new instances (flags them as new)

See Also:
Constant Field Values

MAX

public static final int MAX
Constant to select the maximum available version

See Also:
Constant Field Values

LIVE

public static final int LIVE
Constant to select the version whose workflow step is flagged as live

See Also:
Step.isLiveStep(), Constant Field Values

id

protected long id

version

protected int version
Constructor Detail

FxPK

public FxPK(long id,
            int version)
Ctor

Parameters:
id - id
version - version

FxPK

public FxPK(long id)
Ctor, version is initialized with MAX

Parameters:
id - id
See Also:
MAX

FxPK

public FxPK()
Constructor for new FxContents

Method Detail

isNew

public boolean isNew()
Is this primary key for a new FxContent?

Returns:
if this primary key is for a new FxContent

getId

public long getId()
Getter for the id

Returns:
id

getVersion

public int getVersion()
Getter for the version. Can be an arbitrary number or a constant for maximum or live version

Returns:
version
See Also:
MAX, LIVE

getStorageMode

public TypeStorageMode getStorageMode()
Get the storage mode for this primary key. This method is reserved for future uses when different storage modes will be implemented!

Returns:
storage mode

createNewPK

public static FxPK createNewPK()
Create a new primary key

Returns:
a new primary key

isDistinctVersion

public boolean isDistinctVersion()
Does this primary key point to a distinct version or is it something like maximum or live version?

Returns:
distinct version

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

fromString

public static FxPK fromString(java.lang.String value)
Construct a primary key from a String

Parameters:
value - string value
Returns:
primary key
Throws:
java.lang.IllegalArgumentException - if the string does not represent a valid PK value
See Also:
toString()

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Note: FxPKs with generic version information like LIVE or MAX will return "false" if they are checked for equality with FxPKs that contain a distinct version information. Consider using FxContent.matchesPk(FxPK) if appropriate.

Overrides:
equals in class java.lang.Object

fromObject

public static FxPK fromObject(java.lang.Object value)

Extract a PK from the given object. Useful for scripting or JSF-related calls where the actual value type may vary.

Current, following types for value are supported:

Parameters:
value - the value to be interpreted as an FxPK obejct
Returns:
the primary key

compareTo

public int compareTo(FxPK o)
Specified by:
compareTo in interface java.lang.Comparable<FxPK>

getIds

public static java.util.List<java.lang.Long> getIds(java.util.Collection<? extends FxPK> pks)
Extracts the IDs of the given PK collection.

Parameters:
pks - the PKs to be processed
Returns:
the IDs of the given PK collection.
Since:
3.1

getPks

public static java.util.List<FxPK> getPks(java.util.Collection<java.lang.Long> ids)
Wrap the content IDs in FxPK objects.

Parameters:
ids - the content IDs
Returns:
the FxPK wrappers
Since:
3.2.0