Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr.cache
Class NodeKey

    java.lang.Object
      org.modeshape.jcr.cache.NodeKey

All Implemented Interfaces:
  Serializable, Comparable<NodeKey>

    @Immutable
    public final class NodeKey

extends Object
implements Serializable, Comparable<NodeKey>

An immutable unique key for a node within the `repository`'s `database`.

A node key consists of three parts:

1. A multi-character key uniquely identifying the repository's storage source in which this node appears;
2. A multi-character key uniquely identifying the workspace in which the node appears; and
3. A multi-character key representing the JCR identifier of a node, which is usually a UUID.

This class contains methods for

See Also:
  Serialized Form

Field Summary
`protected static int` | `SOURCE_LENGTH`
`protected static int` | `WORKSPACE_LENGTH`

Constructor Summary
`NodeKey(String key)` Reconstitute a node key from the supplied string.
`NodeKey(String sourceKey, String workspaceKey, String identifier)` Reconstitute a node key from the supplied source key, workspace key, and node identifier.

Method Summary
`int` | `compareTo(NodeKey that)`
`boolean` | `equals(Object obj)`
`String` | `getIdentifier()` Get the multi-character key representing the JCR identifier of a node, which is usually a UUID.
`String` | `getIdentifierHash()` Get the SHA-1 hash of the `identifier`.
`String` | `getSourceKey()` Get the multi-character key uniquely identifying the repository's storage source in which this node appears.
`String` | `getWorkspaceKey()` Get the multi-character key uniquely identifying the workspace in which the node appears.
`int` | `hashCode()`
`static boolean` | `isValidFormat(String key)` Determine if the supplied string may be a valid identifier.
`static String` | `keyForSourceName(String name)`
`static String` | `keyForWorkspaceName(String name)`
`String` | `toString()`
`NodeKey` | `withId(String identifier)`
`NodeKey` | `withRandomId()`
`NodeKey` | `withSourceKeyAndId(String sourceKey, String identifier)`
`NodeKey` | `withWorkspaceKey(String workspaceKey)`
`NodeKey` | `withWorkspaceKeyAndId(String workspaceKey, String identifier)`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### SOURCE_LENGTH

    protected static final int SOURCE_LENGTH

See Also:
  Constant Field Values

### WORKSPACE_LENGTH

    protected static final int WORKSPACE_LENGTH

See Also:
  Constant Field Values

Constructor Detail

### NodeKey

    public NodeKey(String key)

  Reconstitute a node key from the supplied string.

  Parameters:
    `key` - the string representation of the key; may not be null

### NodeKey

    public NodeKey(String sourceKey,
                   String workspaceKey,
                   String identifier)

  Reconstitute a node key from the supplied source key, workspace key, and node identifier.

  Parameters:
    `sourceKey` - the source key; may not be null and must be 4 characters
    `workspaceKey` - the workspace key; may not be null and must be 4 characters
    `identifier` - the node identifier; may not be null and must be at least 1 character

Method Detail

### isValidFormat

    public static boolean isValidFormat(String key)

  Determine if the supplied string may be a valid identifier. This method returns 'false' only if the identifier is known to be invalid (e.g., it is not of the correct format). This method may return true even if the identifier itself does not reference an existing node.

  Parameters:
    `key` -
  Returns:
    true if the string is of the correct format for a node key, or false if it not the correct format

### getSourceKey

    public String getSourceKey()

  Get the multi-character key uniquely identifying the repository's storage source in which this node appears.

  Returns:
    the source key; never null and always contains at least one character

### getWorkspaceKey

    public String getWorkspaceKey()

  Get the multi-character key uniquely identifying the workspace in which the node appears.

  Returns:
    the workspace key; never null and always contains at least one character

### getIdentifier

    public String getIdentifier()

  Get the multi-character key representing the JCR identifier of a node, which is usually a UUID.

  Returns:
    the JCR identifier for the node; never null and always contains at least one character

### getIdentifierHash

    public String getIdentifierHash()

  Get the SHA-1 hash of the `identifier`.

  Returns:
    the hexadecimal representation of the identifier's SHA-1 hash; never null

### compareTo

    public int compareTo(NodeKey that)

  Specified by:
    `compareTo` in interface `Comparable<NodeKey>`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### withRandomId

    public NodeKey withRandomId()

### withId

    public NodeKey withId(String identifier)

### withWorkspaceKey

    public NodeKey withWorkspaceKey(String workspaceKey)

### withWorkspaceKeyAndId

    public NodeKey withWorkspaceKeyAndId(String workspaceKey,
                                         String identifier)

### withSourceKeyAndId

    public NodeKey withSourceKeyAndId(String sourceKey,
                                      String identifier)

### keyForSourceName

    public static String keyForSourceName(String name)

### keyForWorkspaceName

    public static String keyForWorkspaceName(String name)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.