net.sf.okapi.common.resource
Class BaseNameable

java.lang.Object
  extended by net.sf.okapi.common.resource.BaseNameable
All Implemented Interfaces:
IResource, INameable
Direct Known Subclasses:
BaseReferenceable, StartDocument, StartSubDocument

public class BaseNameable
extends java.lang.Object
implements INameable

Implements a nameable resource.


Field Summary
protected  Annotations annotations
           
protected  java.lang.String id
           
protected  boolean isTranslatable
           
protected  java.lang.String mimeType
           
protected  java.lang.String name
           
protected  boolean preserveWS
           
protected  java.util.LinkedHashMap<java.lang.String,Property> properties
           
protected  ISkeleton skeleton
           
protected  java.util.LinkedHashMap<java.lang.String,Property> sourceProperties
           
protected  java.lang.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
BaseNameable()
           
 
Method Summary
 Property createTargetProperty(LocaleId locId, java.lang.String name, boolean overwriteExisting, int creationOptions)
          Creates or get a target property based on the corresponding source.
<A extends IAnnotation>
A
getAnnotation(java.lang.Class<A> annotationType)
          Gets the annotation object for a given class for this resource.
 java.lang.Iterable<IAnnotation> getAnnotations()
          Gets the iterable list of the annotations for this resource.
 java.lang.String getId()
          Gets the identifier of the resource.
 java.lang.String getMimeType()
          Gets the type of content of this resource.
 java.lang.String getName()
          Gets the name of this resource.
 Property getProperty(java.lang.String name)
          Gets the resource-level property for a given name.
 java.util.Set<java.lang.String> getPropertyNames()
          Gets the names of all the resource-level properties for this resource.
 ISkeleton getSkeleton()
          Gets the skeleton object for this resource.
 Property getSourceProperty(java.lang.String name)
          Gets the source property for a given name.
 java.util.Set<java.lang.String> getSourcePropertyNames()
          Gets the names of all the source properties for this resource.
 java.util.Set<LocaleId> getTargetLocales()
          Gets all the target locales for this resource.
 Property getTargetProperty(LocaleId locId, java.lang.String name)
          Gets the target property for a given name and target locale.
 java.util.Set<java.lang.String> getTargetPropertyNames(LocaleId locId)
          Gets the names of all the properties for a given target locale in this resource.
 java.lang.String getType()
          Gets the type information associated with this resource.
 boolean hasProperty(java.lang.String name)
          Indicates if a resource-level property exists for a given name.
 boolean hasSourceProperty(java.lang.String name)
          Indicates if a source property exists for a given name.
 boolean hasTargetProperty(LocaleId locId, java.lang.String name)
          Indicates if a property exists for a given name and target locale.
 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(java.lang.String name)
          Removes a resource-level property of a given name.
 void removeSourceProperty(java.lang.String name)
          Removes a source property of a given name.
 void removeTargetProperty(LocaleId locId, java.lang.String name)
          Removes a target property of a given name.
 void setAnnotation(IAnnotation annotation)
          Sets an annotation object for this resource.
 void setId(java.lang.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(java.lang.String value)
          Sets the type of content of this resource.
 void setName(java.lang.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.
 Property setSourceProperty(Property property)
          Sets a source property.
 Property setTargetProperty(LocaleId locId, Property property)
          Sets a target property.
 void setType(java.lang.String value)
          Sets the type information associated with this resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id

skeleton

protected ISkeleton skeleton

name

protected java.lang.String name

type

protected java.lang.String type

mimeType

protected java.lang.String mimeType

isTranslatable

protected boolean isTranslatable

preserveWS

protected boolean preserveWS

properties

protected java.util.LinkedHashMap<java.lang.String,Property> properties

annotations

protected Annotations annotations

sourceProperties

protected java.util.LinkedHashMap<java.lang.String,Property> sourceProperties
Constructor Detail

BaseNameable

public BaseNameable()
Method Detail

getId

public java.lang.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).

Specified by:
getId in interface IResource
Returns:
the identifier of this resource.

setId

public void setId(java.lang.String id)
Description copied from interface: IResource
Sets the identifier of this resource.

Specified by:
setId in interface IResource
Parameters:
id - the new identifier value.
See Also:
IResource.getId()

getSkeleton

public ISkeleton getSkeleton()
Description copied from interface: IResource
Gets the skeleton object for this resource.

Specified by:
getSkeleton in interface IResource
Returns:
the skeleton object for this resource or null if there is none.

setSkeleton

public void setSkeleton(ISkeleton skeleton)
Description copied from interface: IResource
Sets the skeleton object for this resource.

Specified by:
setSkeleton in interface IResource
Parameters:
skeleton - the skeleton object to set.

getName

public java.lang.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).

Specified by:
getName in interface INameable
Returns:
This resource name, or null if there is none.

setName

public void setName(java.lang.String value)
Description copied from interface: INameable
Sets the name of this resource. The resource name is the equivalent of the XLIFF resname attribute.

Specified by:
setName in interface INameable
Parameters:
value - New name to set.

getType

public java.lang.String getType()
Description copied from interface: INameable
Gets the type information associated with this resource. For example "button".

Specified by:
getType in interface INameable
Returns:
The type information associated with this resource.

setType

public void setType(java.lang.String value)
Description copied from interface: INameable
Sets the type information associated with this resource. For example "button".

Specified by:
setType in interface INameable
Parameters:
value - The new type information.

getMimeType

public java.lang.String getMimeType()
Description copied from interface: INameable
Gets the type of content of this resource. For example "text/xml".

Specified by:
getMimeType in interface INameable
Returns:
The type of content of this resource.

setMimeType

public void setMimeType(java.lang.String value)
Description copied from interface: INameable
Sets the type of content of this resource. For example "text/xml".

Specified by:
setMimeType in interface INameable
Parameters:
value - The new type of content of this resource.

getAnnotation

public <A extends IAnnotation> A getAnnotation(java.lang.Class<A> annotationType)
Description copied from interface: IResource
Gets the annotation object for a given class for this resource.

Specified by:
getAnnotation in interface IResource
Parameters:
annotationType - the class of the annotation object to retrieve.
Returns:
the annotation for the given class for this resource.

setAnnotation

public void setAnnotation(IAnnotation annotation)
Description copied from interface: IResource
Sets an annotation object for this resource.

Specified by:
setAnnotation in interface IResource
Parameters:
annotation - the annotation object to set.

getProperty

public Property getProperty(java.lang.String name)
Description copied from interface: INameable
Gets the resource-level property for a given name.

Specified by:
getProperty in interface INameable
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: INameable
Sets a resource-level property. If a property already exists it is overwritten.

Specified by:
setProperty in interface INameable
Parameters:
property - The new property to set.
Returns:
The property that has been set.

removeProperty

public void removeProperty(java.lang.String name)
Description copied from interface: INameable
Removes a resource-level property of a given name. If the property does not exists nothing happens.

Specified by:
removeProperty in interface INameable
Parameters:
name - The name of the property to remove.

getPropertyNames

public java.util.Set<java.lang.String> getPropertyNames()
Description copied from interface: INameable
Gets the names of all the resource-level properties for this resource.

Specified by:
getPropertyNames in interface INameable
Returns:
All the names of the resource-level properties for this resource.

hasProperty

public boolean hasProperty(java.lang.String name)
Description copied from interface: INameable
Indicates if a resource-level property exists for a given name.

Specified by:
hasProperty in interface INameable
Parameters:
name - The name of the resource-level property to query.
Returns:
True if a resource-level property exists, false otherwise.

getSourceProperty

public Property getSourceProperty(java.lang.String name)
Description copied from interface: INameable
Gets the source property for a given name.

Specified by:
getSourceProperty in interface INameable
Parameters:
name - The name of the source property to retrieve.
Returns:
The property or null if it does not exist.

setSourceProperty

public Property setSourceProperty(Property property)
Description copied from interface: INameable
Sets a source property. If a property already exists it is overwritten.

Specified by:
setSourceProperty in interface INameable
Parameters:
property - The new property to set.
Returns:
The property that has been set.

removeSourceProperty

public void removeSourceProperty(java.lang.String name)
Description copied from interface: INameable
Removes a source property of a given name. If the property does not exists nothing happens.

Specified by:
removeSourceProperty in interface INameable
Parameters:
name - The name of the property to remove.

getSourcePropertyNames

public java.util.Set<java.lang.String> getSourcePropertyNames()
Description copied from interface: INameable
Gets the names of all the source properties for this resource.

Specified by:
getSourcePropertyNames in interface INameable
Returns:
All the names of the source properties for this resource.

hasSourceProperty

public boolean hasSourceProperty(java.lang.String name)
Description copied from interface: INameable
Indicates if a source property exists for a given name.

Specified by:
hasSourceProperty in interface INameable
Parameters:
name - The name of the source property to query.
Returns:
True if a source property exists, false otherwise.

getTargetProperty

public Property getTargetProperty(LocaleId locId,
                                  java.lang.String name)
Description copied from interface: INameable
Gets the target property for a given name and target locale.

Specified by:
getTargetProperty in interface INameable
Parameters:
locId - the locale of the property to retrieve.
name - The name of the property to retrieve. This name is case-sensitive.
Returns:
The property or null if it does not exist.

setTargetProperty

public Property setTargetProperty(LocaleId locId,
                                  Property property)
Description copied from interface: INameable
Sets a target property. If a property already exists it is overwritten.

Specified by:
setTargetProperty in interface INameable
Parameters:
locId - The target locale for which this property should be set.
property - The new property to set. This name is case-sensitive.
Returns:
The property that has been set.

getTargetPropertyNames

public java.util.Set<java.lang.String> getTargetPropertyNames(LocaleId locId)
Description copied from interface: INameable
Gets the names of all the properties for a given target locale in this resource.

Specified by:
getTargetPropertyNames in interface INameable
Parameters:
locId - the target locale to query.
Returns:
all the names of the target properties for the given locale in this resource.

removeTargetProperty

public void removeTargetProperty(LocaleId locId,
                                 java.lang.String name)
Description copied from interface: INameable
Removes a target property of a given name. If the property does not exists nothing happens.

Specified by:
removeTargetProperty in interface INameable
Parameters:
locId - The target locale for which this property should be set.
name - The name of the property to remove.

hasTargetProperty

public boolean hasTargetProperty(LocaleId locId,
                                 java.lang.String name)
Description copied from interface: INameable
Indicates if a property exists for a given name and target locale.

Specified by:
hasTargetProperty in interface INameable
Parameters:
locId - the target locale to query.
name - the name of the property to query.
Returns:
true if a property exists, false otherwise.

getTargetLocales

public java.util.Set<LocaleId> getTargetLocales()
Description copied from interface: INameable
Gets all the target locales for this resource.

Specified by:
getTargetLocales in interface INameable
Returns:
all the target locales for this resource.

createTargetProperty

public Property createTargetProperty(LocaleId locId,
                                     java.lang.String name,
                                     boolean overwriteExisting,
                                     int creationOptions)
Description copied from interface: INameable
Creates or get a target property based on the corresponding source.

Specified by:
createTargetProperty in interface INameable
Parameters:
locId - The target locale to use.
name - The name of the property to create (or retrieve)
overwriteExisting - True to overwrite any existing property. False to not create a new property if one exists already.
creationOptions - Creation options:
  • CREATE_EMPTY: Creates an empty property, only the read-only flag of the source is copied.
  • COPY_CONTENT: Creates a new property with all its data copied from the source.
Returns:
The property that was created, or retrieved.

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 interface INameable
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 interface INameable
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 interface INameable
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 interface INameable
Parameters:
value - True to indicate that the white-spaces in the content of this resource should be preserved.

getAnnotations

public java.lang.Iterable<IAnnotation> getAnnotations()
Description copied from interface: IResource
Gets the iterable list of the annotations for this resource.

Specified by:
getAnnotations in interface IResource
Returns:
the iterable list of the annotations for this resource.