Project Wonder 5.0

er.rest.entityDelegates
Class ERXRestKey

java.lang.Object
  extended by er.rest.entityDelegates.ERXRestKey

public class ERXRestKey
extends java.lang.Object

ERXRestKey represents the keypath that was embodied in the request URL. This differs from a normal keypath in that it can contain object IDs. An ERXRestKey is basically a doubly-linked list of keypath entries.

Author:
mschrag

Constructor Summary
protected ERXRestKey()
           
  ERXRestKey(ERXRestContext context, com.webobjects.eoaccess.EOEntity entity, java.lang.String keyAlias)
          Constructs an ERXRestKey.
  ERXRestKey(ERXRestContext context, com.webobjects.eoaccess.EOEntity entity, java.lang.String keyAlias, java.lang.Object value)
          Constructs an ERXRestKey.
 
Method Summary
protected  void _extend(ERXRestKey nextKey, boolean clone)
          Extends this key to the next key (optionally cloning).
protected  ERXRestKey _extendWithoutClone(java.lang.String key)
          Extends this key "in-place" to the next key in the path.
protected  java.lang.Object _value(boolean checkToOnePermissions)
          Returns (possibly fetching) the destination value of this key.
protected  void appendKey(java.lang.StringBuffer pathBuffer, boolean skipGID)
          Appends this key to the given keypath buffer.
protected  ERXRestKey cloneKey(boolean clonePrevious, boolean cloneNext)
          Returns a clone of this key, optionally also cloning back up the keypath.
protected  ERXRestKey cloneKeyWithNewEntity(com.webobjects.eoaccess.EOEntity entity, boolean clonePrevious, boolean cloneNext)
          Returns a clone of this key, optionally also cloning back up the keypath.
 ERXRestContext context()
          Returns the rest context that was used to create this key.
 com.webobjects.eoaccess.EOEntity entity()
          Returns the entity that contains this key.
 ERXRestKey extend(java.lang.String key)
          Clones and extends this key to the next key in a path.
 ERXRestKey extend(java.lang.String key, java.lang.Object value)
          Clones and extends this key to the next key in a path with the given cached value.
 ERXRestKey firstKey()
          Returns the first key in this path (can be this).
 boolean isKeyAll()
          Returns whether or not this key requests a query against all the values of an Entity (/Site.xml = all Sites).
 boolean isKeyGID()
          Returns whether or not this key requests a primary key.
 java.lang.String key()
          Returns the actual key property name for this key.
 java.lang.String keyAlias()
          Returns the key alias property name for this key.
 ERXRestKey lastKey()
          Returns the last key in this path (can be this).
 com.webobjects.eoaccess.EOEntity nextEntity()
          Returns the next entity in this key path (i.e.
 ERXRestKey nextKey()
          Returns the next key in this path (can be null).
static ERXRestKey parse(ERXRestContext context, ERXRestRequestNode node, java.lang.String path)
           
static ERXRestKey parse(ERXRestContext context, java.lang.String path)
          Parse the given URL path and return an ERXRestKey that represents it.
 java.lang.String path(boolean skipGID)
          Returns the key path from this key to the end of the path.
 ERXRestKey previousKey()
          Returns the previous key in the path (or null if this is the first key).
 java.lang.String toString()
           
 ERXRestKey trimPrevious()
          Returns a new ERXRestKey with the previous key path removed, so it appears that this key is the start of the path.
 java.lang.Object value()
          Returns (possibly fetching) the destination value of this key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXRestKey

protected ERXRestKey()

ERXRestKey

public ERXRestKey(ERXRestContext context,
                  com.webobjects.eoaccess.EOEntity entity,
                  java.lang.String keyAlias)
           throws ERXRestException
Constructs an ERXRestKey.

Parameters:
context - the context
entity - the entity that this key is in
keyAlias - the alias of the key
Throws:
ERXRestException

ERXRestKey

public ERXRestKey(ERXRestContext context,
                  com.webobjects.eoaccess.EOEntity entity,
                  java.lang.String keyAlias,
                  java.lang.Object value)
           throws ERXRestException
Constructs an ERXRestKey.

Parameters:
context - the context
entity - the entity that this key is in
keyAlias - the alias of the key
value - the cached value of the key at this point in the path
Throws:
ERXRestException
Method Detail

trimPrevious

public ERXRestKey trimPrevious()
                        throws ERXRestException,
                               ERXRestSecurityException,
                               ERXRestNotFoundException
Returns a new ERXRestKey with the previous key path removed, so it appears that this key is the start of the path. This method will have to resolve the value of this key.

Returns:
a key path starting at this key
Throws:
ERXRestException - if a general exception occurs
ERXRestSecurityException - if a security error occurs
ERXRestNotFoundException - if an object is not found in the kaypath

cloneKeyWithNewEntity

protected ERXRestKey cloneKeyWithNewEntity(com.webobjects.eoaccess.EOEntity entity,
                                           boolean clonePrevious,
                                           boolean cloneNext)
                                    throws ERXRestException
Returns a clone of this key, optionally also cloning back up the keypath. If you choose not to clone the previous key, it will not have a previous key.

Parameters:
entity - the new entity to clone with (typically a superentity)
clonePrevious - if true, the previous key is also cloned
Returns:
the cloned key
Throws:
ERXRestException - if a general exception occurs

cloneKey

protected ERXRestKey cloneKey(boolean clonePrevious,
                              boolean cloneNext)
                       throws ERXRestException
Returns a clone of this key, optionally also cloning back up the keypath. If you choose not to clone the previous key, it will not have a previous key.

Parameters:
clonePrevious - if true, the previous key is also cloned
cloneNext - if true, the next key is also cloned
Returns:
the cloned key
Throws:
ERXRestException - if a general exception occurs

context

public ERXRestContext context()
Returns the rest context that was used to create this key.

Returns:
the rest context that was used to create this key

extend

public ERXRestKey extend(java.lang.String key,
                         java.lang.Object value)
                  throws ERXRestException
Clones and extends this key to the next key in a path with the given cached value.

Parameters:
key - the next key
value - the current cached value
Returns:
a cloned and extended key
Throws:
ERXRestException - if a general failure occurs

extend

public ERXRestKey extend(java.lang.String key)
                  throws ERXRestException
Clones and extends this key to the next key in a path.

Parameters:
key - the next key
Returns:
a cloned and extended key
Throws:
ERXRestException - if a general failure occurs

_extendWithoutClone

protected ERXRestKey _extendWithoutClone(java.lang.String key)
                                  throws ERXRestException
Extends this key "in-place" to the next key in the path.

Parameters:
key - the next key
Returns:
an extended key
Throws:
ERXRestException - if a general failure occurs

_extend

protected void _extend(ERXRestKey nextKey,
                       boolean clone)
                throws ERXRestException
Extends this key to the next key (optionally cloning).

Parameters:
nextKey - the next key
clone - if true, clone ourselves
Throws:
ERXRestException - if a general failure occurs

entity

public com.webobjects.eoaccess.EOEntity entity()
Returns the entity that contains this key. Note that this is the containing entity NOT the destination entity of the key.

Returns:
the entity

keyAlias

public java.lang.String keyAlias()
Returns the key alias property name for this key.

Returns:
the key alias property name for this key

key

public java.lang.String key()
Returns the actual key property name for this key.

Returns:
the actual key property name for this key

previousKey

public ERXRestKey previousKey()
Returns the previous key in the path (or null if this is the first key).

Returns:
the previous key in the path (or null if this is the first key)

firstKey

public ERXRestKey firstKey()
Returns the first key in this path (can be this).

Returns:
the first key in this path (can be this)

lastKey

public ERXRestKey lastKey()
Returns the last key in this path (can be this).

Returns:
the last key in this path (can be this)

path

public java.lang.String path(boolean skipGID)
Returns the key path from this key to the end of the path.

Parameters:
skipGID - if true, global ids will be skipped in the generated path
Returns:
the key path from this key to the end of the path

appendKey

protected void appendKey(java.lang.StringBuffer pathBuffer,
                         boolean skipGID)
Appends this key to the given keypath buffer.

Parameters:
pathBuffer - the current key path buffer
skipGID - if true, global ids will be skipped in the generated path

nextKey

public ERXRestKey nextKey()
Returns the next key in this path (can be null).

Returns:
the next key in this path (can be null)

nextEntity

public com.webobjects.eoaccess.EOEntity nextEntity()
                                            throws ERXRestException
Returns the next entity in this key path (i.e. the destination entity). This can be null.

Returns:
the next entity in this key path (i.e. the destination entity). This can be null.
Throws:
ERXRestException - if a general error occurs

value

public java.lang.Object value()
                       throws ERXRestException,
                              ERXRestSecurityException,
                              ERXRestNotFoundException
Returns (possibly fetching) the destination value of this key. This can be an expensive call, but it will cache its results.

Returns:
the destination value of this key
Throws:
ERXRestException - if a general error occurs
ERXRestSecurityException - if fetching the value triggers a security violation
ERXRestNotFoundException - if the referenced value does not exist

_value

protected java.lang.Object _value(boolean checkToOnePermissions)
                           throws ERXRestException,
                                  ERXRestSecurityException,
                                  ERXRestNotFoundException
Returns (possibly fetching) the destination value of this key. This can be an expensive call, but it will cache its results.

Parameters:
checkToOnePermissions - if false, this will not check permissions on a to-one call (this is necessary under certain circumstances to provide a more appropriate error messaga).
Returns:
the destination value of this key
Throws:
ERXRestException - if a general error occurs
ERXRestSecurityException - if fetching the value triggers a security violation
ERXRestNotFoundException - if the referenced value does not exist

isKeyAll

public boolean isKeyAll()
Returns whether or not this key requests a query against all the values of an Entity (/Site.xml = all Sites).

Returns:
whether or not this key requests a query against all the values of an Entity

isKeyGID

public boolean isKeyGID()
Returns whether or not this key requests a primary key. Right now, only integer primary keys are supported.

Returns:
whether or not this key requests a primary key

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parse

public static ERXRestKey parse(ERXRestContext context,
                               ERXRestRequestNode node,
                               java.lang.String path)
                        throws ERXRestException,
                               ERXRestNotFoundException
Throws:
ERXRestException
ERXRestNotFoundException

parse

public static ERXRestKey parse(ERXRestContext context,
                               java.lang.String path)
                        throws ERXRestException,
                               ERXRestNotFoundException
Parse the given URL path and return an ERXRestKey that represents it.

Parameters:
context - the rest context
path - the path to parse
Returns:
the corresponding ERXRestKey
Throws:
ERXRestException - if a general exception occurs
ERXRestNotFoundException - if an object can not be found in the path

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.