org.odata4j.core
Class OEntityKey

java.lang.Object
  extended by org.odata4j.core.OEntityKey

public class OEntityKey
extends Object

An immutable entity-key, made up of either a single unnamed-value or multiple named-values. Every entity must have an entity-key. The entity-key must be unique within the entity-set, and thus defines an entity's identity. (see OEntityId)

An entity-key made up a a single unnamed-value is called a single key. An entity-key made up of multiple named-values is called a complex key.

The string representation of an entity-key is wrapped with parentheses, such as (2), ('foo') or (a=1,foo='bar').

Entity-keys are equal if their string representations are equal.


Nested Class Summary
static class OEntityKey.KeyType
          SINGLE or COMPLEX
 
Method Summary
 Set<OProperty<?>> asComplexProperties()
          Gets the values of complex entity-key.
 Set<NamedValue<?>> asComplexValue()
          Gets the values of a complex entity-key.
 Object asSingleValue()
          Gets a the value of a single-valued entity-key.
static OEntityKey create(Map<String,Object> values)
          Creates an entity-key from a map of names and values.
static OEntityKey create(Object... values)
          Creates an entity-key.
 boolean equals(Object obj)
           
 Object getComplexKeyValue(String name)
          returns the value for a named value in a complex key.
 OEntityKey.KeyType getKeyType()
          Gets the entity-key type: SINGLE or COMPLEX.
 int hashCode()
           
static OEntityKey infer(EdmEntitySet entitySet, List<OProperty<?>> props)
          Creates an entity-key using key information from the given entity-set and values from the given property list.
static OEntityKey parse(String keyString)
          Creates an entity-key from its standard string representation.
 String toKeyString()
          Gets the standard string representation of this entity-key, including parentheses.
 String toKeyStringWithoutParentheses()
          Gets the standard string representation of this entity-key, excluding parentheses.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

asComplexProperties

public Set<OProperty<?>> asComplexProperties()
Gets the values of complex entity-key.

Returns:
the key values as a set of properties

asComplexValue

public Set<NamedValue<?>> asComplexValue()
Gets the values of a complex entity-key.

Returns:
the key values as a set of named-values

asSingleValue

public Object asSingleValue()
Gets a the value of a single-valued entity-key.

Returns:
the key value

create

public static OEntityKey create(Map<String,Object> values)
Creates an entity-key from a map of names and values.

Parameters:
values - the map of names and values
Returns:
a newly-created entity-key

create

public static OEntityKey create(Object... values)
Creates an entity-key.

Parameters:
values - the key values
Returns:
a newly-created entity-key

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getComplexKeyValue

public Object getComplexKeyValue(String name)
returns the value for a named value in a complex key.

Parameters:
name -
Returns:
the value

getKeyType

public OEntityKey.KeyType getKeyType()
Gets the entity-key type: SINGLE or COMPLEX.

Returns:
SINGLE or COMPLEX

hashCode

public int hashCode()
Overrides:
hashCode in class Object

infer

public static OEntityKey infer(EdmEntitySet entitySet,
                               List<OProperty<?>> props)
Creates an entity-key using key information from the given entity-set and values from the given property list.

Parameters:
entitySet - an entity-set to provide key information
props - a list of properties to provide key values
Returns:
a newly-created entity-key

parse

public static OEntityKey parse(String keyString)
Creates an entity-key from its standard string representation.

Parameters:
keyString - a standard key-string
Returns:
a newly-created entity-key

toKeyString

public String toKeyString()
Gets the standard string representation of this entity-key, including parentheses.

Returns:
the standard key-string

toKeyStringWithoutParentheses

public String toKeyStringWithoutParentheses()
Gets the standard string representation of this entity-key, excluding parentheses.

Returns:
the standard key-string, without parentheses

toString

public String toString()
Overrides:
toString in class Object


http://odata4j.org