Package org.restlet.engine.local
Class Entity
- java.lang.Object
-
- org.restlet.engine.local.Entity
-
- Direct Known Subclasses:
FileEntity,ZipEntryEntity
public abstract class Entity extends java.lang.ObjectRepresents a local entity, for example a regular file or a directory.
-
-
Field Summary
Fields Modifier and Type Field Description private MetadataServicemetadataServiceThe metadata service to use.
-
Constructor Summary
Constructors Constructor Description Entity(MetadataService metadataService)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanexists()Indicates if the entity does exist.java.lang.StringgetBaseName()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 java.lang.StringgetBaseName(java.lang.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 java.util.List<Entity>getChildren()Returns the list of contained entities if the current entity is a directory, null otherwise.java.util.Collection<java.lang.String>getExtensions()Returns the list of known extensions.static java.util.Collection<java.lang.String>getExtensions(java.lang.String name, MetadataService metadataService)Returns the list of known extensions taken from a given entity name.static java.util.Collection<java.lang.String>getExtensions(Variant variant, MetadataService metadataService)Returns the list of known extensions taken from a given variant.MetadataServicegetMetadataService()Returns the metadata service to use.abstract java.lang.StringgetName()Returns the name.abstract EntitygetParent()Returns the parent directory (if any).abstract RepresentationgetRepresentation(MediaType defaultMediaType, int timeToLive)Returns a representation of this local entity.VariantgetVariant()Returns a variant corresponding to the extensions of this entity.abstract booleanisDirectory()Indicates if the entity is a directory.abstract booleanisNormal()Indicates if the entity is a normal entity, especially if it is not a directory.static voidupdateMetadata(java.lang.String entryName, Variant variant, boolean applyDefault, MetadataService metadataService)Updates some variant metadata based on a given entry name with extensions.
-
-
-
Field Detail
-
metadataService
private volatile MetadataService metadataService
The metadata service to use.
-
-
Constructor Detail
-
Entity
public Entity(MetadataService metadataService)
Constructor.- Parameters:
metadataService- The metadata service to use.
-
-
Method Detail
-
getBaseName
public static java.lang.String getBaseName(java.lang.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 java.util.Collection<java.lang.String> getExtensions(java.lang.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.
-
getExtensions
public static java.util.Collection<java.lang.String> getExtensions(Variant variant, MetadataService metadataService)
Returns the list of known extensions taken from a given variant.- Parameters:
variant- the given variant.metadataService- Service that holds the known extensions.- Returns:
- The list of known extensions taken from the variant.
-
updateMetadata
public static void updateMetadata(java.lang.String entryName, Variant variant, boolean applyDefault, MetadataService metadataService)Updates some variant metadata based on a given entry name with extensions.- Parameters:
entryName- The entry name with extensions.variant- The variant to update.applyDefault- Indicate if default metadata must be applied.metadataService- The parent metadata service.
-
exists
public abstract boolean exists()
Indicates if the entity does exist.- Returns:
- True if the entity does exists.
-
getBaseName
public java.lang.String getBaseName()
Return the base name of this entity that is to say the longest part of the name without known extensions (beginning from the left).- Returns:
- The base name of this entity.
-
getChildren
public abstract java.util.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 java.util.Collection<java.lang.String> getExtensions()
Returns the list of known extensions.- Returns:
- The list of known extensions taken from the entity name.
-
getMetadataService
public MetadataService getMetadataService()
Returns the metadata service to use.- Returns:
- The metadata service to use.
-
getName
public abstract java.lang.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.- Returns:
- A representation of this entity.
-
getVariant
public Variant getVariant()
Returns a variant corresponding to the extensions of this entity.- Returns:
- A variant corresponding to the extensions 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()
-
-