info.textgrid.utils.linkrewriter
Class SimpleTextRewriter

java.lang.Object
  extended by info.textgrid.utils.linkrewriter.AbstractRewriter
      extended by info.textgrid.utils.linkrewriter.SimpleTextRewriter
All Implemented Interfaces:
ILinkRewriter

public class SimpleTextRewriter
extends AbstractRewriter
implements ILinkRewriter

A simple rewriter for plain-text files. Reads a file line by line and performs simple text replacement from a to b.

Author:
vitt
See Also:
RewriteMethod.TEXT

Constructor Summary
Constructor and Description
SimpleTextRewriter(ImportMapping mapping, boolean export)
          A rewriter that can rewrite simple text files by replacing everything at word boundaries.
 
Method Summary
Modifier and Type Method and Description
 void rewrite(InputStream input, OutputStream output)
          Copies contents from input to output, rewriting links according to the mapping and the export setting, in an implementation dependent manner.
 
Methods inherited from class info.textgrid.utils.linkrewriter.AbstractRewriter
getMapping, isExport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.textgrid.utils.linkrewriter.ILinkRewriter
getMapping, isExport
 

Constructor Detail

SimpleTextRewriter

public SimpleTextRewriter(ImportMapping mapping,
                          boolean export)
A rewriter that can rewrite simple text files by replacing everything at word boundaries.

Parameters:
mapping - The mapping between TextGrid URIs and other (local) files.
export - If true, we're exporting from TextGrid (i.e. we need to replace TextGrid URIs with local URIs).
Method Detail

rewrite

public void rewrite(InputStream input,
                    OutputStream output)
             throws IOException
Copies contents from input to output, rewriting links according to the mapping and the export setting, in an implementation dependent manner. The SimpleTextRewriter implementation rewrites links by simple text replacements.

Specified by:
rewrite in interface ILinkRewriter
Specified by:
rewrite in class AbstractRewriter
Parameters:
input - the stream from which the rewriter reads
output - the stream to which the rewriter writes the rewritten code
Throws:
IOException - if reading or writing fails


Copyright © 2012 TextGrid. All Rights Reserved.