Package net.sf.okapi.common.skeleton
Class StorageList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<IResource>
-
- net.sf.okapi.common.skeleton.StorageList
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<IResource>,Collection<IResource>,List<IResource>,RandomAccess,IResource,IMultilingual,INameable,IReferenceable,IWithAnnotations,IWithProperties,IWithSkeleton,IWithSourceProperties,IWithTargetProperties
public class StorageList extends ArrayList<IResource> implements IReferenceable, IMultilingual
provides a way to store a list of resources and implements the different interfaces of the resources.This class is designed to be used with
GenericSkeletonWriterand derived classes.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
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 StorageList()StorageList(StartGroup startGroup)Creates a new StorageList object with w StartGroup.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertycreateTargetProperty(LocaleId locId, String name, boolean overwrite, int creationOptions)Create targetPropertywithout access to the source property<A extends IAnnotation>
AgetAnnotation(Class<A> annotationType)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.intgetReferenceCount()Gets the number of time this referent is referenced to.ISkeletongetSkeleton()Gets the skeleton object for this resource.Map<String,Property>getSourceProperties()PropertygetSourceProperty(String name)Gets the source property for a given name.Set<String>getSourcePropertyNames()Gets the names of all the source properties for this resource.StartGroupgetStartGroup()Set<LocaleId>getTargetLocales()Gets all the target locales for this resource.PropertygetTargetProperty(LocaleId language, String name)Gets the target property for a given name and target locale.Set<String>getTargetPropertyNames(LocaleId language)Gets the names of all the properties for a given target locale in 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.booleanhasSourceProperty(String name)Indicates if a source property exists for a given name.booleanhasTargetProperty(LocaleId language, String name)Indicates if a property exists for a given name and target locale.booleanisReferent()Indicates if this resource is a referent (i.e.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.voidremoveSourceProperty(String name)Removes a source property of a given name.voidremoveTargetProperty(LocaleId language, String name)Removes a target property of a given name.voidsetAnnotation(IAnnotation annotation)Sets an annotation object for this resource.voidsetId(String id)Sets the identifier of this resource.voidsetIsReferent(boolean value)Sets the flag indicating if this resource is a referent (i.e.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 name)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.voidsetReferenceCount(int value)Sets the number of time this referent is referenced to.voidsetSkeleton(ISkeleton skeleton)Sets the skeleton object for this resource.PropertysetSourceProperty(Property property)Sets a source property.PropertysetTargetProperty(LocaleId language, Property property)Sets a target property.voidsetType(String value)Sets the type information associated with this resource.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
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
-
Methods inherited from interface net.sf.okapi.common.resource.IWithTargetProperties
createTargetProperty, getTargetProperties
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Constructor Detail
-
StorageList
public StorageList()
-
StorageList
public StorageList(StartGroup startGroup)
Creates a new StorageList object with w StartGroup.- Parameters:
startGroup- StartGroup to start with.
-
-
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()
-
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.
-
isReferent
public boolean isReferent()
Description copied from interface:IReferenceableIndicates if this resource is a referent (i.e. is referred to by another resource) or not.- Specified by:
isReferentin interfaceIReferenceable- Returns:
- true if this resource is a referent, false if it is not.
-
setIsReferent
public void setIsReferent(boolean value)
Description copied from interface:IReferenceableSets the flag indicating if this resource is a referent (i.e. is referred to by another resource) or not. This also sets the count of time this referent is referenced to 1.- Specified by:
setIsReferentin interfaceIReferenceable- Parameters:
value- true if the resource is a referent, false if it is not.
-
getReferenceCount
public int getReferenceCount()
Description copied from interface:IReferenceableGets the number of time this referent is referenced to.- Specified by:
getReferenceCountin interfaceIReferenceable- Returns:
- the number of time this referent is referenced to.
-
setReferenceCount
public void setReferenceCount(int value)
Description copied from interface:IReferenceableSets the number of time this referent is referenced to.- Specified by:
setReferenceCountin interfaceIReferenceable- Parameters:
value- the number of time this referent is referenced to.
-
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).
-
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.
-
setName
public void setName(String name)
Description copied from interface:INameableSets the name of this resource. The resource name is the equivalent of the XLIFF resname attribute.
-
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.
-
getAnnotation
public <A extends IAnnotation> A getAnnotation(Class<A> annotationType)
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.
-
createTargetProperty
public Property createTargetProperty(LocaleId locId, String name, boolean overwrite, int creationOptions)
Description copied from interface:IWithTargetPropertiesCreate targetPropertywithout access to the source property- Specified by:
createTargetPropertyin interfaceIWithTargetProperties- Returns:
-
setTargetProperty
public Property setTargetProperty(LocaleId language, Property property)
Description copied from interface:IWithTargetPropertiesSets a target property. If a property already exists it is overwritten.- Specified by:
setTargetPropertyin interfaceIWithTargetProperties- Parameters:
language- 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.
-
getTargetProperty
public Property getTargetProperty(LocaleId language, String name)
Description copied from interface:IWithTargetPropertiesGets the target property for a given name and target locale.- Specified by:
getTargetPropertyin interfaceIWithTargetProperties- Parameters:
language- 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.
-
hasTargetProperty
public boolean hasTargetProperty(LocaleId language, String name)
Description copied from interface:IWithTargetPropertiesIndicates if a property exists for a given name and target locale.- Specified by:
hasTargetPropertyin interfaceIWithTargetProperties- Parameters:
language- the target locale to query.name- the name of the property to query.- Returns:
- true if a property exists, false otherwise.
-
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.
-
getTargetPropertyNames
public Set<String> getTargetPropertyNames(LocaleId language)
Description copied from interface:IWithTargetPropertiesGets the names of all the properties for a given target locale in this resource.- Specified by:
getTargetPropertyNamesin interfaceIWithTargetProperties- Parameters:
language- the target locale to query.- Returns:
- all the names of the target properties for the given locale in this resource.
-
getSourceProperty
public Property getSourceProperty(String name)
Description copied from interface:IWithSourcePropertiesGets the source property for a given name.- Specified by:
getSourcePropertyin interfaceIWithSourceProperties- Parameters:
name- The name of the source property to retrieve.- Returns:
- The property or null if it does not exist.
-
getSourcePropertyNames
public Set<String> getSourcePropertyNames()
Description copied from interface:IWithSourcePropertiesGets the names of all the source properties for this resource.- Specified by:
getSourcePropertyNamesin interfaceIWithSourceProperties- Returns:
- All the names of the source properties for this resource.
-
getTargetLocales
public Set<LocaleId> getTargetLocales()
Description copied from interface:IWithTargetPropertiesGets all the target locales for this resource.- Specified by:
getTargetLocalesin interfaceIWithTargetProperties- Returns:
- all the target locales for this resource.
-
setSourceProperty
public Property setSourceProperty(Property property)
Description copied from interface:IWithSourcePropertiesSets a source property. If a property already exists it is overwritten.- Specified by:
setSourcePropertyin interfaceIWithSourceProperties- Parameters:
property- The new property to set.- Returns:
- The property that has been set.
-
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.
-
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".
-
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.
-
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.
-
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.
-
hasSourceProperty
public boolean hasSourceProperty(String name)
Description copied from interface:IWithSourcePropertiesIndicates if a source property exists for a given name.- Specified by:
hasSourcePropertyin interfaceIWithSourceProperties- Parameters:
name- The name of the source property to query.- Returns:
- True if a source property exists, false otherwise.
-
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.
-
removeSourceProperty
public void removeSourceProperty(String name)
Description copied from interface:IWithSourcePropertiesRemoves a source property of a given name. If the property does not exists nothing happens.- Specified by:
removeSourcePropertyin interfaceIWithSourceProperties- Parameters:
name- The name of the property to remove.
-
removeTargetProperty
public void removeTargetProperty(LocaleId language, String name)
Description copied from interface:IWithTargetPropertiesRemoves a target property of a given name. If the property does not exists nothing happens.- Specified by:
removeTargetPropertyin interfaceIWithTargetProperties- Parameters:
language- The target locale for which this property should be set.name- The name of the property to remove.
-
getStartGroup
public StartGroup getStartGroup()
-
getSourceProperties
public Map<String,Property> getSourceProperties()
- Specified by:
getSourcePropertiesin interfaceIWithSourceProperties- Returns:
Mapof source properties for the implementer of interface
-
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- Specified by:
getAnnotationsin interfaceIWithTargetProperties- Returns:
Annotationsfor the implementer of interface
-
-