public class RawDocument extends Object implements IResource, Closeable
| Modifier and Type | Field and Description |
|---|---|
static String |
UNKOWN_ENCODING |
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY| Constructor and Description |
|---|
RawDocument() |
RawDocument(CharSequence inputCharSequence,
LocaleId sourceLocale)
Creates a new RawDocument object with a given CharSequence and a source locale.
|
RawDocument(CharSequence inputCharSequence,
LocaleId sourceLocale,
LocaleId targetLocale)
Creates a new RawDocument object with a given CharSequence, a source locale and a target locale.
|
RawDocument(InputStream inputStream,
String defaultEncoding,
LocaleId sourceLocale)
Creates a new RawDocument object with a given InputStream, a default encoding and a source locale.
|
RawDocument(InputStream inputStream,
String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale)
Creates a new RawDocument object with a given InputStream, a default encoding and a source locale.
|
RawDocument(URI inputURI,
String defaultEncoding,
LocaleId sourceLocale)
Creates a new RawDocument object with a given URI, a default encoding and a source locale.
|
RawDocument(URI inputURI,
String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale)
Creates a new RawDocument object with a given URI, a default encoding, a source locale and a target locale.
|
RawDocument(URI inputURI,
String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale,
String filterConfigId)
Creates a new RawDocument object with a given URI, a default encoding, a source locale and a target locale,
and the filter configuration id.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Destroy the underlying stream of this RawDocument and delete all temp reosurces.
|
File |
createOutputFile(URI outputURI)
Creates a new output file object based on a given output URI and the URI of the raw document.
|
void |
finalizeOutput()
Finalizes the name for this output file.
|
<A extends IAnnotation> |
getAnnotation(Class<A> annotationType)
Gets the annotation object for a given class for this resource.
|
Annotations |
getAnnotations() |
String |
getEncoding()
Gets the default encoding associated to this resource.
|
String |
getFilterConfigId()
Gets the identifier of the filter configuration to use with this document.
|
String |
getId()
Gets the identifier of the resource.
|
CharSequence |
getInputCharSequence()
Gets the CharSequence associated with this resource.
|
URI |
getInputURI()
Gets the URI object associated with this resource.
|
Map<String,Property> |
getProperties() |
Reader |
getReader()
Returns a Reader based on the current Stream returned from getStream().
|
LocaleId |
getSourceLocale()
Gets the source locale associated to this resource.
|
InputStream |
getStream()
Returns an InputStream based on the current input.
|
LocaleId |
getTargetLocale()
Gets the target locale associated to this resource.
|
List<LocaleId> |
getTargetLocales()
Gets the list of target locales associated to this resource.
|
void |
setEncoding(Charset encoding) |
void |
setEncoding(String encoding)
Set the input encoding.
|
void |
setFilterConfigId(String filterConfigId)
Sets the identifier of the filter configuration to use with this document.
|
void |
setId(String id)
Sets the identifier of this resource.
|
void |
setSourceLocale(LocaleId locId)
Sets the source locale associated to this document.
|
void |
setTargetLocale(LocaleId locId)
Sets the target locale associated to this document.
|
void |
setTargetLocales(List<LocaleId> locIds)
Sets the list of target locales associated to this document.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopy, getProperty, getPropertyNames, hasProperty, propertyIterator, removeProperty, setPropertyannotationIterator, clear, copy, getAnnotationsTypesAsSet, hasAnnotation, hasAnnotations, remove, setAnnotationgetSkeleton, setSkeletonpublic static final String UNKOWN_ENCODING
public RawDocument()
public RawDocument(CharSequence inputCharSequence, LocaleId sourceLocale)
inputCharSequence - the CharSequence for this RawDocument.sourceLocale - the source locale for this RawDocument.public RawDocument(CharSequence inputCharSequence, LocaleId sourceLocale, LocaleId targetLocale)
inputCharSequence - the CharSequence for this RawDocument.sourceLocale - the source locale for this RawDocument.targetLocale - the target locale for this RawDocument.public RawDocument(URI inputURI, String defaultEncoding, LocaleId sourceLocale)
inputURI - the URI for this RawDocument.defaultEncoding - the default encoding for this RawDocument.sourceLocale - the source locale for this RawDocument.public RawDocument(URI inputURI, String defaultEncoding, LocaleId sourceLocale, LocaleId targetLocale)
inputURI - the URI for this RawDocument.defaultEncoding - the default encoding for this RawDocument.sourceLocale - the source locale for this RawDocument.targetLocale - the target locale for this RawDocument.public RawDocument(InputStream inputStream, String defaultEncoding, LocaleId sourceLocale)
inputStream - the InputStream for this RawDocument.defaultEncoding - the default encoding for this RawDocument.sourceLocale - the source locale for this RawDocument.public RawDocument(URI inputURI, String defaultEncoding, LocaleId sourceLocale, LocaleId targetLocale, String filterConfigId)
inputURI - the URI for this RawDocument.defaultEncoding - the default encoding for this RawDocument.sourceLocale - the source locale for this RawDocument.targetLocale - the target locale for this RawDocument.filterConfigId - the filter configuration id.public RawDocument(InputStream inputStream, String defaultEncoding, LocaleId sourceLocale, LocaleId targetLocale)
inputStream - the InputStream for this RawDocument.defaultEncoding - the default encoding for this RawDocument.sourceLocale - the source locale for this RawDocument.targetLocale - the target locale for this RawDocument.public String getId()
IResourcepublic void setId(String id)
IResourcesetId in interface IResourceid - the new identifier value.IResource.getId()public Reader getReader()
public InputStream getStream()
FileCachedInputStream is reset
and reopened if needed.OkapiIOException - if there was any problem creating the steam.public <A extends IAnnotation> A getAnnotation(Class<A> annotationType)
IWithAnnotationsgetAnnotation in interface IWithAnnotationspublic URI getInputURI()
public CharSequence getInputCharSequence()
public String getEncoding()
public LocaleId getSourceLocale()
public void setSourceLocale(LocaleId locId)
locId - the locale to set.public LocaleId getTargetLocale()
If several targets are set, this method returns the first one.
public void setTargetLocale(LocaleId locId)
This call overrides any existing target locale or list of target locales.
locId - the locale to set.public List<LocaleId> getTargetLocales()
If the target locale was set using a constructor or setTargetLocale(LocaleId),
this list return that locale.
public void setTargetLocales(List<LocaleId> locIds)
If the target locale was set with a constructor or setTargetLocale(LocaleId),
this method overrides that locale.
locIds - the locales to set. If the value is null, an empty list will be associated.public void setEncoding(String encoding)
encoding - the encoding to use with the reader.public void setEncoding(Charset encoding)
public void setFilterConfigId(String filterConfigId)
filterConfigId - the filter configuration identifier to set.public String getFilterConfigId()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic File createOutputFile(URI outputURI)
If the path of the raw document is the same as the path of the output a temporary file is created,
otherwise the output URI is used directly.
You must call finalizeOutput() when all writing is done and both the input file and output file
are closed to make sure the proper output file name is used.
If one or more directories of the output path do not exist, they are created automatically.
If the input of the raw document is a CharSequence or a Stream, the method assumes it can use directly the path of the output URI.
outputURI - the URI of the output file.OkapiIOException - if an error occurs when creating the work file or its directory.finalizeOutput()public void finalizeOutput()
OkapiIOException - if the original input file cannot be deleted or if the work file cannot be renamed.createOutputFile(URI)public Map<String,Property> getProperties()
getProperties in interface IWithPropertiesMap of properties for the implementer of interfacepublic Annotations getAnnotations()
getAnnotations in interface IWithAnnotationsAnnotations for the implementer of interfaceCopyright © 2022. All rights reserved.