|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.okapi.common.resource.RawDocument
public class RawDocument
Resource that carries all the information needed for a filter to open a given document, and also the resource associated with the event RAW_DOCUMENT. Documents are passed through the pipeline either as RawDocument, or a filter events. Specialized steps allows to convert one to the other and conversely. The RawDocument object has one (and only one) of three input objects: a CharSequence, a URI, or an InputStream.
| Field Summary | |
|---|---|
static java.lang.String |
UNKOWN_ENCODING
|
| Fields inherited from interface net.sf.okapi.common.IResource |
|---|
COPY_ALL, COPY_CONTENT, COPY_PROPERTIES, COPY_SEGMENTATION, COPY_SEGMENTED_CONTENT, CREATE_EMPTY |
| Constructor Summary | |
|---|---|
RawDocument(java.lang.CharSequence inputCharSequence,
LocaleId sourceLocale)
Creates a new RawDocument object with a given CharSequence and a source locale. |
|
RawDocument(java.lang.CharSequence inputCharSequence,
LocaleId sourceLocale,
LocaleId targetLocale)
Creates a new RawDocument object with a given CharSequence, a source locale and a target locale. |
|
RawDocument(java.io.InputStream inputStream,
java.lang.String defaultEncoding,
LocaleId sourceLocale)
Creates a new RawDocument object with a given InputStream, a default encoding and a source locale. |
|
RawDocument(java.io.InputStream inputStream,
java.lang.String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale)
Creates a new RawDocument object with a given InputStream, a default encoding and a source locale. |
|
RawDocument(java.net.URI inputURI,
java.lang.String defaultEncoding,
LocaleId sourceLocale)
Creates a new RawDocument object with a given URI, a default encoding and a source locale. |
|
RawDocument(java.net.URI inputURI,
java.lang.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(java.net.URI inputURI,
java.lang.String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale,
java.lang.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. |
|
| Method Summary | ||
|---|---|---|
void |
close()
Close the underlying stream of this RawDocument. |
|
java.io.File |
createOutputFile(java.net.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. |
|
|
getAnnotation(java.lang.Class<A> annotationType)
Gets the annotation object for a given class for this resource. |
|
Annotations |
getAnnotations()
Gets the iterable list of the annotations for this resource. |
|
java.lang.String |
getEncoding()
Gets the default encoding associated to this resource. |
|
java.lang.String |
getFilterConfigId()
Gets the identifier of the filter configuration to use with this document. |
|
java.lang.String |
getId()
Gets the identifier of the resource. |
|
java.lang.CharSequence |
getInputCharSequence()
Gets the CharSequence associated with this resource. |
|
java.net.URI |
getInputURI()
Gets the URI object associated with this resource. |
|
java.io.Reader |
getReader()
Returns a Reader based on the current Stream returned from getStream(). |
|
ISkeleton |
getSkeleton()
Always throws an exception as there is never a skeleton associated with a RawDocument. |
|
LocaleId |
getSourceLocale()
Gets the source locale associated to this resource. |
|
java.io.InputStream |
getStream()
Returns an InputStream based on the current input. |
|
LocaleId |
getTargetLocale()
Gets the target locale associated to this resource. |
|
void |
setAnnotation(IAnnotation annotation)
Sets an annotation object for this resource. |
|
void |
setEncoding(java.lang.String encoding)
Set the input encoding. |
|
void |
setFilterConfigId(java.lang.String filterConfigId)
Sets the identifier of the filter configuration to use with this document. |
|
void |
setId(java.lang.String id)
Sets the identifier of this resource. |
|
void |
setSkeleton(ISkeleton skeleton)
This method has no effect as there is never a skeleton for a RawDocument. |
|
void |
setSourceLocale(LocaleId locId)
Sets the source locale associated to this document. |
|
void |
setTargetLocale(LocaleId locId)
Sets the target locale associated to this document. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String UNKOWN_ENCODING
| Constructor Detail |
|---|
public RawDocument(java.lang.CharSequence inputCharSequence,
LocaleId sourceLocale)
inputCharSequence - the CharSequence for this RawDocument.sourceLocale - the source locale for this RawDocument.
public RawDocument(java.lang.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(java.net.URI inputURI,
java.lang.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(java.net.URI inputURI,
java.lang.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(java.io.InputStream inputStream,
java.lang.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(java.net.URI inputURI,
java.lang.String defaultEncoding,
LocaleId sourceLocale,
LocaleId targetLocale,
java.lang.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(java.io.InputStream inputStream,
java.lang.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.| Method Detail |
|---|
public java.io.Reader getReader()
public java.io.InputStream getStream()
OkapiIOExceptionpublic <A extends IAnnotation> A getAnnotation(java.lang.Class<A> annotationType)
IResource
getAnnotation in interface IResourceannotationType - the class of the annotation object to retrieve.
public java.lang.String getId()
IResource
getId in interface IResourcepublic ISkeleton getSkeleton()
getSkeleton in interface IResourceOkapiNotImplementedExceptionpublic void setAnnotation(IAnnotation annotation)
IResource
setAnnotation in interface IResourceannotation - the annotation object to set.public void setId(java.lang.String id)
IResource
setId in interface IResourceid - the new identifier value.IResource.getId()public void setSkeleton(ISkeleton skeleton)
setSkeleton in interface IResourceskeleton - the skeleton object to set.
OkapiNotImplementedExceptionpublic java.net.URI getInputURI()
public java.lang.CharSequence getInputCharSequence()
public java.lang.String getEncoding()
public LocaleId getSourceLocale()
public void setSourceLocale(LocaleId locId)
locId - the locale to set.public LocaleId getTargetLocale()
public void setTargetLocale(LocaleId locId)
locId - the locale to set.public void setEncoding(java.lang.String encoding)
encoding - public void setFilterConfigId(java.lang.String filterConfigId)
filterConfigId - the filter configuration identifier to set.public java.lang.String getFilterConfigId()
public void close()
InputStream
public Annotations getAnnotations()
IResource
getAnnotations in interface IResourcepublic java.io.File createOutputFile(java.net.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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||