public abstract class Entity extends Object implements Identifiable, Comparable<Entity>
Modifier and Type | Field and Description |
---|---|
static String |
ID_ATTRIBUTE_NAME |
static String |
KIND_IDENTIFIER_DEFAULT |
static URI |
SCHEME_DEFAULT |
static String |
TERM_DEFAULT |
static String |
TITLE_ATTRIBUTE_NAME |
Constructor and Description |
---|
Entity(String id,
Kind kind)
Constructor.
|
Entity(String id,
Kind kind,
String title,
Model model)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String attributeIdentifier,
String value)
Adds attribute and its value.
|
void |
addAttributes(Map<String,String> attributes)
Adds attributes and their values.
|
boolean |
addMixin(Mixin mixin)
Adds mixin to the entity.
|
boolean |
addMixins(Collection<Mixin> mixins)
Adds all the mixins from given collection to the entity.
|
protected com.sun.net.httpserver.Headers |
attributesToHeaders()
Returns an occi text representation of entity's attributes in form of
headers.
|
protected String |
attributesToOneLineText()
Returns text representation of entity's attributes in one line.
|
protected String |
attributesToPrefixText()
Returns a text representation of entity's attributes with prefix.
|
void |
clearAttributes()
Removes all entity's attributes.
|
void |
clearMixins()
Removes all mixins from entity.
|
int |
compareTo(Entity e)
Comapres two entities lexicographically based on their identifier.
|
boolean |
containsAttribute(Attribute attribute)
Checks whether entity has given attribute.
|
boolean |
containsAttribute(String attributeName)
Checks whether entity has given attribute.
|
boolean |
containsMixin(Mixin mixin)
Checks whether the entity has given mixin.
|
boolean |
containsMixin(String mixinIdentifier)
Checks whether the entity has given mixin.
|
boolean |
equals(Object obj) |
Map<Attribute,String> |
getAttributes()
Returns all entity's attributes and their values in form of map.
|
static List<Attribute> |
getDefaultAttributes()
Returns entity's default attributes.
|
String |
getDefaultKindIdentifier()
Returns entity's default kind identifier (scheme+term).
|
String |
getId()
Returns entity's id.
|
String |
getIdentifier()
Returns entity's identifier.
|
Kind |
getKind()
Returns entity's kind.
|
Mixin |
getMixin(String mixinIdentifier)
Returns mixin form entity.
|
Set<Mixin> |
getMixins()
Returns all mixins from entity in form of a set.
|
Model |
getModel()
Returns entity's model.
|
String |
getTitle()
Returns entity's title.
|
String |
getValue(Attribute attribute)
Returns value of given attribute.
|
String |
getValue(String attributeName)
Returns value of given attribute.
|
int |
hashCode() |
void |
removeAttribute(String attributeIdentifier)
Removes attribute from entity.
|
boolean |
removeMixin(Mixin mixin)
Removes mixin from entity.
|
void |
setId(String id)
Sets entity's id.
|
void |
setKind(Kind kind)
Sets entity's kind.
|
void |
setModel(Model model)
Sets entity's model.
|
void |
setTitle(String title)
Sets entity's title.
|
abstract com.sun.net.httpserver.Headers |
toHeaders()
Renders entity to its occi text form as described in OCCI standard in
form of headers.
|
abstract String |
toJSON()
Renders entity to its JSON form as described in OCCI standard.
|
String |
toString()
Resturns string representation of the entity
|
abstract String |
toText()
Renders entity to its plain text form as described in OCCI standard.
|
public static final String ID_ATTRIBUTE_NAME
public static final String TITLE_ATTRIBUTE_NAME
public static final URI SCHEME_DEFAULT
public static final String TERM_DEFAULT
public static final String KIND_IDENTIFIER_DEFAULT
public Entity(String id, Kind kind, String title, Model model) throws InvalidAttributeValueException
id
- occi.core.id attribute. Cannot be null.kind
- entity's kind. Cannot be null.title
- occi.core.title attributemodel
- entity's modelInvalidAttributeValueException
- in case of invalid id or title
valuepublic Entity(String id, Kind kind) throws InvalidAttributeValueException
id
- occi.core.id attribute. Cannot be null.kind
- entity's kind. Cannot be null.InvalidAttributeValueException
- in case of invalid id or title
valuepublic String getId()
public void setId(String id) throws InvalidAttributeValueException
id
- entity's id. Cannot be null.InvalidAttributeValueException
- in case of invalid id valuepublic Kind getKind()
public void setKind(Kind kind)
kind
- entity's kind. Cannot be null.public String getIdentifier()
getIdentifier
in interface Identifiable
public String getTitle()
public void setTitle(String title) throws InvalidAttributeValueException
title
- entity's titleInvalidAttributeValueException
- in case of invalit tile valuepublic Model getModel()
public void setModel(Model model)
model
- entity's modelpublic void addAttribute(String attributeIdentifier, String value) throws InvalidAttributeValueException
attributeIdentifier
- value
- InvalidAttributeValueException
public void addAttributes(Map<String,String> attributes) throws InvalidAttributeValueException
attributes
- InvalidAttributeValueException
public void removeAttribute(String attributeIdentifier)
attributeIdentifier
- identifier of the attribute to be removedpublic boolean containsAttribute(Attribute attribute)
attribute
- attribute to be looked uppublic boolean containsAttribute(String attributeName)
attributeName
- name of the attribute to be looked uppublic String getValue(Attribute attribute)
attribute
- attribute which value will be returnedpublic String getValue(String attributeName)
attributeName
- name of the attribute which value will be returnedpublic Map<Attribute,String> getAttributes()
public void clearAttributes()
protected String attributesToOneLineText()
protected String attributesToPrefixText()
protected com.sun.net.httpserver.Headers attributesToHeaders()
public boolean containsMixin(Mixin mixin)
mixin
- mixin to be looked uppublic boolean containsMixin(String mixinIdentifier)
mixinIdentifier
- identifier of mixin to be looked uppublic boolean addMixin(Mixin mixin)
mixin
- mixin to be addedpublic boolean addMixins(Collection<Mixin> mixins)
mixins
- collection of mixinspublic Mixin getMixin(String mixinIdentifier)
mixinIdentifier
- identifier of requested mixinpublic boolean removeMixin(Mixin mixin)
mixin
- mixin to be removedpublic void clearMixins()
public Set<Mixin> getMixins()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
obj
- object to compare entity withObject.equals(java.lang.Object)
public String toString()
toString
in class Object
Object.toString()
public abstract String toText() throws RenderingException
RenderingException
public abstract com.sun.net.httpserver.Headers toHeaders() throws RenderingException
RenderingException
public abstract String toJSON()
public int compareTo(Entity e)
compareTo
in interface Comparable<Entity>
Comparable.compareTo(java.lang.Object)
public String getDefaultKindIdentifier()
Copyright © 2016. All Rights Reserved.