Package org.omegat.util.xml
Class XMLStreamReader
- java.lang.Object
-
- org.omegat.util.xml.XMLStreamReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class XMLStreamReader extends java.lang.Object implements java.io.Closeable
A reader for XML stream.
-
-
Constructor Summary
Constructors Constructor Description XMLStreamReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XMLBlock
advanceToTag(java.lang.String tagname)
void
breakOnWhitespace(boolean brk)
void
close()
Closes the TMX filejava.util.List<XMLBlock>
closeBlock(XMLBlock block)
java.util.List<XMLBlock>
closeBlock(XMLBlock block, boolean includeTerminationBlock)
void
compressWhitespace(boolean tof)
XMLBlock
getHeadBlock()
XMLBlock
getNextBlock()
Returns next object in stream - either a tag or a string.void
killEmptyBlocks()
java.lang.String
makeValidXML(int cp)
Converts a single code point into valid XML.java.lang.String
makeValidXML(java.lang.String plaintext)
Converts a stream of plaintext into valid XML.void
setEntityFilter(DefaultEntityFilter filter)
void
setStream(java.io.File name)
void
setStream(java.io.InputStream stream)
Provide an interface where stream can be opened elsewhere.void
setStream(java.io.InputStream stream, java.lang.String encoding)
Provide an interface where stream can be opened elsewhere.void
setStream(java.lang.String name, java.lang.String encoding)
-
-
-
Method Detail
-
setStream
public final void setStream(java.io.File name) throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException, java.io.IOException, TranslationException
- Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
java.io.IOException
TranslationException
-
setStream
public final void setStream(java.lang.String name, java.lang.String encoding) throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException, java.io.IOException, TranslationException
- Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
java.io.IOException
TranslationException
-
setStream
public void setStream(java.io.InputStream stream) throws java.io.IOException, TranslationException
Provide an interface where stream can be opened elsewhere.- Throws:
java.io.IOException
TranslationException
-
setStream
public void setStream(java.io.InputStream stream, java.lang.String encoding) throws java.io.IOException, TranslationException
Provide an interface where stream can be opened elsewhere.- Throws:
java.io.IOException
TranslationException
-
getNextBlock
public XMLBlock getNextBlock() throws TranslationException
Returns next object in stream - either a tag or a string.- Throws:
TranslationException
-
killEmptyBlocks
public final void killEmptyBlocks()
-
breakOnWhitespace
public final void breakOnWhitespace(boolean brk)
-
compressWhitespace
public final void compressWhitespace(boolean tof)
-
setEntityFilter
public final void setEntityFilter(DefaultEntityFilter filter)
-
makeValidXML
public java.lang.String makeValidXML(int cp)
Converts a single code point into valid XML. Output stream must convert stream to UTF-8 when saving to disk.
-
makeValidXML
public java.lang.String makeValidXML(java.lang.String plaintext)
Converts a stream of plaintext into valid XML. Output stream must convert stream to UTF-8 when saving to disk.
-
closeBlock
public final java.util.List<XMLBlock> closeBlock(XMLBlock block) throws TranslationException
- Throws:
TranslationException
-
closeBlock
public java.util.List<XMLBlock> closeBlock(XMLBlock block, boolean includeTerminationBlock) throws TranslationException
- Throws:
TranslationException
-
advanceToTag
public final XMLBlock advanceToTag(java.lang.String tagname) throws TranslationException
- Throws:
TranslationException
-
getHeadBlock
public final XMLBlock getHeadBlock()
-
close
public void close() throws java.io.IOException
Closes the TMX file- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-