com.noelios.restlet.local
Class Entity

java.lang.Object
  extended by com.noelios.restlet.local.Entity
Direct Known Subclasses:
FileEntity

public abstract class Entity
extends Object

Represents a local entity, for example a regular file or a directory.

Author:
Thierry Boileau

Constructor Summary
Entity()
           
 
Method Summary
abstract  boolean exists()
          Indicates if the entity does exist.
 String getBaseName(MetadataService metadataService)
          Return the base name of this entity that is to say the longest part of the name without known extensions (beginning from the left).
static String getBaseName(String name, MetadataService metadataService)
          Return the base name that is to say the longest part of a given name without known extensions (beginning from the left).
abstract  List<Entity> getChildren()
          Returns the list of contained entities if the current entity is a directory, null otherwise.
 Collection<String> getExtensions(MetadataService metadataService)
          Returns the list of known extensions.
static Collection<String> getExtensions(String name, MetadataService metadataService)
          Returns the list of known extensions taken from a given entity name.
abstract  String getName()
          Returns the name.
abstract  Entity getParent()
          Returns the parent directory (if any).
abstract  Representation getRepresentation(MediaType defaultMediaType, int timeToLive)
          Returns a representation of this local entity.
abstract  boolean isDirectory()
          Indicates if the entity is a directory.
abstract  boolean isNormal()
          Indicates if the entity is a normal entity, especially if it is not a directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Entity

public Entity()
Method Detail

getBaseName

public static String getBaseName(String name,
                                 MetadataService metadataService)
Return the base name that is to say the longest part of a given name without known extensions (beginning from the left).

Parameters:
name - The given name.
metadataService - Service that holds the known extensions.
Returns:
The base name of this entity.

getExtensions

public static Collection<String> getExtensions(String name,
                                               MetadataService metadataService)
Returns the list of known extensions taken from a given entity name.

Parameters:
name - the given name.
metadataService - Service that holds the known extensions.
Returns:
The list of known extensions taken from the entity name.

exists

public abstract boolean exists()
Indicates if the entity does exist.

Returns:
True if the entity does exists.

getBaseName

public String getBaseName(MetadataService metadataService)
Return the base name of this entity that is to say the longest part of the name without known extensions (beginning from the left).

Parameters:
metadataService - Service that holds the known extensions.
Returns:
The base name of this entity.

getChildren

public abstract List<Entity> getChildren()
Returns the list of contained entities if the current entity is a directory, null otherwise.

Returns:
The list of contained entities.

getExtensions

public Collection<String> getExtensions(MetadataService metadataService)
Returns the list of known extensions.

Parameters:
metadataService - Service that maps extension names to metadata.
Returns:
The list of known extensions taken from the entity name.

getName

public abstract String getName()
Returns the name.

Returns:
The name.

getParent

public abstract Entity getParent()
Returns the parent directory (if any).

Returns:
The parent directory, null otherwise.

getRepresentation

public abstract Representation getRepresentation(MediaType defaultMediaType,
                                                 int timeToLive)
Returns a representation of this local entity.

Parameters:
defaultMediaType - The default media type
timeToLive - the time to live of this representation
Returns:
A representation of this entity.

isDirectory

public abstract boolean isDirectory()
Indicates if the entity is a directory.

Returns:
True if the entity is a directory.

isNormal

public abstract boolean isNormal()
Indicates if the entity is a normal entity, especially if it is not a directory.

Returns:
True if the entity is a normal entity.
See Also:
File.isFile(), File.isDirectory()


Copyright © 2005-2008 Noelios Technologies.