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 Stringidprotected booleanisTranslatableprotected StringmimeTypeprotected Stringnameprotected booleanpreserveWSprotected Stringtype-
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.AnnotationsgetAnnotations()StringgetId()Gets the identifier of the resource.StringgetMimeType()Gets the type of content of this resource.StringgetName()Gets the name of this resource.Map<String,Property>getProperties()PropertygetProperty(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.ISkeletongetSkeleton()Gets the skeleton object for this resource.StringgetType()Gets the type information associated with this resource.booleanhasProperty(String name)Indicates if a resource-level property exists for a given name.booleanisTranslatable()Indicates if the content of this resource is translatable.booleanpreserveWhitespaces()Indicates if the white-spaces in the content of this resource should be preserved.voidremoveProperty(String name)Removes a resource-level property of a given name.voidsetAnnotation(IAnnotation annotation)Sets an annotation object for this resource.voidsetId(String id)Sets the identifier of this resource.voidsetIsTranslatable(boolean value)Sets the flag indicating if the content of this resource is translatable.voidsetMimeType(String value)Sets the type of content of this resource.voidsetName(String value)Sets the name of this resource.voidsetPreserveWhitespaces(boolean value)sets the flag indicating if the white-spaces in the content of this resource should be preserved.PropertysetProperty(Property property)Sets a resource-level property.voidsetSkeleton(ISkeleton skeleton)Sets the skeleton object for this resource.voidsetType(String value)Sets the type information associated with this resource.StringtoString()-
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:IResourceGets 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:IResourceSets the identifier of this resource.- Specified by:
setIdin interfaceIResource- Parameters:
id- the new identifier value.- See Also:
IResource.getId()
-
getName
public String getName()
Description copied from interface:INameableGets 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:INameableSets the name of this resource. The resource name is the equivalent of the XLIFF resname attribute.
-
getType
public String getType()
Description copied from interface:INameableGets the type information associated with this resource. For example "button".
-
setType
public void setType(String value)
Description copied from interface:INameableSets the type information associated with this resource. For example "button".
-
getMimeType
public String getMimeType()
Description copied from interface:INameableGets the type of content of this resource. For example "text/xml".- Specified by:
getMimeTypein interfaceINameable- Returns:
- The type of content of this resource.
-
setMimeType
public void setMimeType(String value)
Description copied from interface:INameableSets the type of content of this resource. For example "text/xml".- Specified by:
setMimeTypein interfaceINameable- Parameters:
value- The new type of content of this resource.
-
isTranslatable
public boolean isTranslatable()
Description copied from interface:INameableIndicates if the content of this resource is translatable. By default this indicator is set to true for all resources.- Specified by:
isTranslatablein 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:INameableSets the flag indicating if the content of this resource is translatable.- Specified by:
setIsTranslatablein interfaceINameable- Parameters:
value- True to indicate that the content of this resource is translatable.
-
preserveWhitespaces
public boolean preserveWhitespaces()
Description copied from interface:INameableIndicates 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:
preserveWhitespacesin 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:INameablesets the flag indicating if the white-spaces in the content of this resource should be preserved.- Specified by:
setPreserveWhitespacesin 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:IWithSkeletonGets the skeleton object for this resource.- Specified by:
getSkeletonin interfaceIWithSkeleton- Returns:
- the skeleton object for this resource or null if there is none.
-
setSkeleton
public void setSkeleton(ISkeleton skeleton)
Description copied from interface:IWithSkeletonSets the skeleton object for this resource.- Specified by:
setSkeletonin interfaceIWithSkeleton- Parameters:
skeleton- the skeleton object to set.
-
getProperties
public Map<String,Property> getProperties()
- Specified by:
getPropertiesin interfaceIWithProperties- Returns:
Mapof properties for the implementer of interface
-
getAnnotations
public Annotations getAnnotations()
- Specified by:
getAnnotationsin interfaceIWithAnnotations- Returns:
Annotationsfor the implementer of interface
-
hasProperty
public boolean hasProperty(String name)
Description copied from interface:IWithPropertiesIndicates if a resource-level property exists for a given name.- Specified by:
hasPropertyin 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:IWithPropertiesGets the resource-level property for a given name.- Specified by:
getPropertyin 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:IWithPropertiesSets a resource-level property. If a property already exists it is overwritten.- Specified by:
setPropertyin 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:IWithPropertiesRemoves a resource-level property of a given name. If the property does not exists nothing happens.- Specified by:
removePropertyin interfaceIWithProperties- Parameters:
name- The name of the property to remove.
-
getPropertyNames
public Set<String> getPropertyNames()
Description copied from interface:IWithPropertiesGets the names of all the resource-level properties for this resource.- Specified by:
getPropertyNamesin 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:IWithAnnotationsGets the annotation object for a given class for this resource.- Specified by:
getAnnotationin interfaceIWithAnnotations- Returns:
-
setAnnotation
public void setAnnotation(IAnnotation annotation)
Description copied from interface:IWithAnnotationsSets an annotation object for this resource.- Specified by:
setAnnotationin interfaceIWithAnnotations- Parameters:
annotation- the annotation object to set.
-
-