Package net.sf.okapi.common.resource
Class BaseNameable
- java.lang.Object
-
- net.sf.okapi.common.resource.BaseNameable
-
- All Implemented Interfaces:
Cloneable
,IResource
,INameable
,IWithAnnotations
,IWithProperties
,IWithSkeleton
- Direct Known Subclasses:
BaseReferenceable
,StartDocument
,StartSubDocument
,TextContainer
public class BaseNameable extends Object implements INameable
Implements a nameable resource.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
id
protected boolean
isTranslatable
protected String
mimeType
protected String
name
protected boolean
preserveWS
protected String
type
-
Fields inherited from interface net.sf.okapi.common.IResource
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY
-
-
Constructor Summary
Constructors Constructor Description BaseNameable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends IAnnotation>
AgetAnnotation(Class<A> type)
Gets the annotation object for a given class for this resource.Annotations
getAnnotations()
String
getId()
Gets the identifier of the resource.String
getMimeType()
Gets the type of content of this resource.String
getName()
Gets the name of this resource.Map<String,Property>
getProperties()
Property
getProperty(String name)
Gets the resource-level property for a given name.Set<String>
getPropertyNames()
Gets the names of all the resource-level properties for this resource.ISkeleton
getSkeleton()
Gets the skeleton object for this resource.String
getType()
Gets the type information associated with this resource.boolean
hasProperty(String name)
Indicates if a resource-level property exists for a given name.boolean
isTranslatable()
Indicates if the content of this resource is translatable.boolean
preserveWhitespaces()
Indicates if the white-spaces in the content of this resource should be preserved.void
removeProperty(String name)
Removes a resource-level property of a given name.void
setAnnotation(IAnnotation annotation)
Sets an annotation object for this resource.void
setId(String id)
Sets the identifier of this resource.void
setIsTranslatable(boolean value)
Sets the flag indicating if the content of this resource is translatable.void
setMimeType(String value)
Sets the type of content of this resource.void
setName(String value)
Sets the name of this resource.void
setPreserveWhitespaces(boolean value)
sets the flag indicating if the white-spaces in the content of this resource should be preserved.Property
setProperty(Property property)
Sets a resource-level property.void
setSkeleton(ISkeleton skeleton)
Sets the skeleton object for this resource.void
setType(String value)
Sets the type information associated with this resource.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.resource.IWithAnnotations
annotationIterator, clear, getAnnotationsTypesAsSet, hasAnnotation, hasAnnotations, remove
-
Methods inherited from interface net.sf.okapi.common.resource.IWithProperties
propertyIterator
-
-
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:IResource
Gets the identifier of the resource. This identifier is unique per extracted document and by type of resource. This value is filter-specific. It and may be different from one extraction of the same document to the next. It can a sequential number or not, incremental or not, and it can be not a number. It has no correspondence in the source document ("IDs" coming from the source document are "names" and not available for all resources).
-
setId
public void setId(String id)
Description copied from interface:IResource
Sets the identifier of this resource.- Specified by:
setId
in interfaceIResource
- Parameters:
id
- the new identifier value.- See Also:
IResource.getId()
-
getName
public String getName()
Description copied from interface:INameable
Gets the name of this resource. The resource name corresponds to different things depending on the type of resource. For a StartDocument the name is the URI of the document. Otherwise, in most cases the name is the identifier of the resource (This is the equivalent of the XLIFF resname attribute).
-
setName
public void setName(String value)
Description copied from interface:INameable
Sets the name of this resource. The resource name is the equivalent of the XLIFF resname attribute.
-
getType
public String getType()
Description copied from interface:INameable
Gets the type information associated with this resource. For example "button".
-
setType
public void setType(String value)
Description copied from interface:INameable
Sets the type information associated with this resource. For example "button".
-
getMimeType
public String getMimeType()
Description copied from interface:INameable
Gets the type of content of this resource. For example "text/xml".- Specified by:
getMimeType
in interfaceINameable
- Returns:
- The type of content of this resource.
-
setMimeType
public void setMimeType(String value)
Description copied from interface:INameable
Sets the type of content of this resource. For example "text/xml".- Specified by:
setMimeType
in interfaceINameable
- Parameters:
value
- The new type of content of this resource.
-
isTranslatable
public boolean isTranslatable()
Description copied from interface:INameable
Indicates if the content of this resource is translatable. By default this indicator is set to true for all resources.- Specified by:
isTranslatable
in interfaceINameable
- Returns:
- True if the content of this resource is translatable. False if it is not translatable.
-
setIsTranslatable
public void setIsTranslatable(boolean value)
Description copied from interface:INameable
Sets the flag indicating if the content of this resource is translatable.- Specified by:
setIsTranslatable
in interfaceINameable
- Parameters:
value
- True to indicate that the content of this resource is translatable.
-
preserveWhitespaces
public boolean preserveWhitespaces()
Description copied from interface:INameable
Indicates if the white-spaces in the content of this resource should be preserved. By default this indicator is set to false for all resources.- Specified by:
preserveWhitespaces
in interfaceINameable
- Returns:
- True if the white-spaces in the content of this resource should be preserved.
-
setPreserveWhitespaces
public void setPreserveWhitespaces(boolean value)
Description copied from interface:INameable
sets the flag indicating if the white-spaces in the content of this resource should be preserved.- Specified by:
setPreserveWhitespaces
in interfaceINameable
- Parameters:
value
- True to indicate that the white-spaces in the content of this resource should be preserved.
-
getSkeleton
public ISkeleton getSkeleton()
Description copied from interface:IWithSkeleton
Gets the skeleton object for this resource.- Specified by:
getSkeleton
in interfaceIWithSkeleton
- Returns:
- the skeleton object for this resource or null if there is none.
-
setSkeleton
public void setSkeleton(ISkeleton skeleton)
Description copied from interface:IWithSkeleton
Sets the skeleton object for this resource.- Specified by:
setSkeleton
in interfaceIWithSkeleton
- Parameters:
skeleton
- the skeleton object to set.
-
getProperties
public Map<String,Property> getProperties()
- Specified by:
getProperties
in interfaceIWithProperties
- Returns:
Map
of properties for the implementer of interface
-
getAnnotations
public Annotations getAnnotations()
- Specified by:
getAnnotations
in interfaceIWithAnnotations
- Returns:
Annotations
for the implementer of interface
-
hasProperty
public boolean hasProperty(String name)
Description copied from interface:IWithProperties
Indicates if a resource-level property exists for a given name.- Specified by:
hasProperty
in interfaceIWithProperties
- Parameters:
name
- The name of the resource-level property to query.- Returns:
- True if a resource-level property exists, false otherwise.
-
getProperty
public Property getProperty(String name)
Description copied from interface:IWithProperties
Gets the resource-level property for a given name.- Specified by:
getProperty
in interfaceIWithProperties
- Parameters:
name
- Name of the property to retrieve.- Returns:
- The property or null if it does not exist.
-
setProperty
public Property setProperty(Property property)
Description copied from interface:IWithProperties
Sets a resource-level property. If a property already exists it is overwritten.- Specified by:
setProperty
in interfaceIWithProperties
- Parameters:
property
- The new property to set.- Returns:
- The property that has been set.
-
removeProperty
public void removeProperty(String name)
Description copied from interface:IWithProperties
Removes a resource-level property of a given name. If the property does not exists nothing happens.- Specified by:
removeProperty
in interfaceIWithProperties
- Parameters:
name
- The name of the property to remove.
-
getPropertyNames
public Set<String> getPropertyNames()
Description copied from interface:IWithProperties
Gets the names of all the resource-level properties for this resource.- Specified by:
getPropertyNames
in interfaceIWithProperties
- Returns:
- All the names of the resource-level properties for this resource.
-
getAnnotation
public <A extends IAnnotation> A getAnnotation(Class<A> type)
Description copied from interface:IWithAnnotations
Gets the annotation object for a given class for this resource.- Specified by:
getAnnotation
in interfaceIWithAnnotations
- Returns:
-
setAnnotation
public void setAnnotation(IAnnotation annotation)
Description copied from interface:IWithAnnotations
Sets an annotation object for this resource.- Specified by:
setAnnotation
in interfaceIWithAnnotations
- Parameters:
annotation
- the annotation object to set.
-
-