org.gcube.common.resources
Class DefaultResource

java.lang.Object
  extended by org.gcube.common.resources.DefaultResource
All Implemented Interfaces:
Resource

public final class DefaultResource
extends Object
implements Resource

Default Resource implementation.

Author:
Fabio Simeoni

Method Summary
 void afterUnmarshal(Unmarshaller u, Object parent)
          Invoked after resource unmarshalling, validates generic constraints on the resource
 void bumpVersion()
           
 String description()
          Returns the description of the resource.
 boolean equals(Object obj)
           
<T extends TypedFacet>
T
facet(Class<T> type)
          Returns a facet bound to a given type.
 Facet facet(QName name)
          Returns a facet with a given name.
 Set<Facet> facets()
          Returns the facets of the resource.
<T extends TypedFacet>
boolean
hasFacet(Class<T> type)
          Returns true if the resource has a facet bound to a given type.
 boolean hasFacet(QName name)
          Returns true if the resource has a facet with a given name.
 int hashCode()
           
 String id()
          Returns the identifier of the resource
 QName name()
          Returns the name of the resource.
 void removeFacet(QName name)
          Removes a facet with a given name.
 void setDescription(String description)
          Sets the description of the resource.
 void setFacet(Element facet)
          Adds a UntypedFacet with a given data to the resource
 void setFacet(Facet facet)
          Adds a facet to the resource.
 void setId(String id)
           
 void setName(QName name)
          Sets the name of the resource.
 long version()
          Returns the edit version of the resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

id

public String id()
Description copied from interface: Resource
Returns the identifier of the resource

Specified by:
id in interface Resource
Returns:
the identifier

setId

public void setId(String id)

version

public long version()
Description copied from interface: Resource
Returns the edit version of the resource.

Specified by:
version in interface Resource
Returns:
the version

bumpVersion

public void bumpVersion()

name

public QName name()
Description copied from interface: Resource
Returns the name of the resource.

Specified by:
name in interface Resource
Returns:
the name

setName

public void setName(QName name)
Description copied from interface: Resource
Sets the name of the resource.

Specified by:
setName in interface Resource
Parameters:
name - the name

description

public String description()
Description copied from interface: Resource
Returns the description of the resource.

Specified by:
description in interface Resource
Returns:
the description

setDescription

public void setDescription(String description)
Description copied from interface: Resource
Sets the description of the resource.

Specified by:
setDescription in interface Resource
Parameters:
description - the description

facets

public Set<Facet> facets()
Description copied from interface: Resource
Returns the facets of the resource.

Specified by:
facets in interface Resource
Returns:
the facets

hasFacet

public boolean hasFacet(QName name)
Description copied from interface: Resource
Returns true if the resource has a facet with a given name.

Specified by:
hasFacet in interface Resource
Parameters:
name - the name
Returns:
true if the resource has a facet with the given name, false otherwise

hasFacet

public <T extends TypedFacet> boolean hasFacet(Class<T> type)
Description copied from interface: Resource
Returns true if the resource has a facet bound to a given type.

Specified by:
hasFacet in interface Resource
Parameters:
type - the type
Returns:
true if the resource has a facet bound to the given type, false otherwise

facet

public Facet facet(QName name)
            throws IllegalArgumentException
Description copied from interface: Resource
Returns a facet with a given name.

Specified by:
facet in interface Resource
Parameters:
name - the name
Returns:
the facet
Throws:
IllegalArgumentException - if the resource does not have a facet with the given name

facet

public <T extends TypedFacet> T facet(Class<T> type)
                           throws IllegalArgumentException
Description copied from interface: Resource
Returns a facet bound to a given type.

Specified by:
facet in interface Resource
Parameters:
type - the type
Returns:
the facet
Throws:
IllegalArgumentException - if the resource does not have a facet bound to the given type

removeFacet

public void removeFacet(QName name)
                 throws IllegalArgumentException
Description copied from interface: Resource
Removes a facet with a given name.

Specified by:
removeFacet in interface Resource
Parameters:
name - the name
Throws:
IllegalArgumentException - if the resource does not have a facet with the given name

setFacet

public void setFacet(Facet facet)
Description copied from interface: Resource
Adds a facet to the resource.

Specified by:
setFacet in interface Resource
Parameters:
facet - the facet

setFacet

public void setFacet(Element facet)
Description copied from interface: Resource
Adds a UntypedFacet with a given data to the resource

Specified by:
setFacet in interface Resource
Parameters:
facet - the facet's data

afterUnmarshal

public void afterUnmarshal(Unmarshaller u,
                           Object parent)
                    throws UnmarshalException
Invoked after resource unmarshalling, validates generic constraints on the resource

Parameters:
u - the unmarshaller
parent - the parent
Throws:
UnmarshalException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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


Copyright © 2012. All Rights Reserved.