Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.launcher.commons.text
Class TextTemplate

java.lang.Object
  extended by org.nuxeo.launcher.commons.text.TextTemplate

public class TextTemplate
extends Object

Text template processing.

Copy files or directories replacing parameters matching pattern '${[a-zA-Z_0-9\-\.]+}' with values from a Map (deprecated) or a Properties.

Method setParsingExtensions(String) allow to set list of files being processed when using processDirectory(File, File) or #pro, others are simply copied.

Author:
Bogdan Stefanescu

Constructor Summary
TextTemplate()
           
TextTemplate(Map<String,String> vars)
          Deprecated. prefer use of TextTemplate(Properties)
TextTemplate(Properties vars)
           
 
Method Summary
 String getVariable(String name)
           
 Properties getVariables()
           
 boolean isTrim()
           
 String process(CharSequence text)
           
 String process(InputStream in)
           
 void process(InputStream in, OutputStream out)
           
 void process(InputStream is, OutputStream os, boolean processText)
           
 void processDirectory(File in, File out)
          Recursive call process(InputStream, OutputStream, boolean) on each file from "in" directory to "out" directory.
 void setParsingExtensions(String extensionsList)
           
 void setTrim(boolean trim)
          Set to true in order to trim invisible characters (spaces) from values.
 void setVariable(String name, String value)
           
 void setVariables(Map<String,String> vars)
          Deprecated. prefer use of getVariables() then Properties .load()
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTemplate

public TextTemplate()

TextTemplate

@Deprecated
public TextTemplate(Map<String,String> vars)
Deprecated. prefer use of TextTemplate(Properties)


TextTemplate

public TextTemplate(Properties vars)
Parameters:
vars - Properties containing keys and values for template processing
Method Detail

isTrim

public boolean isTrim()

setTrim

public void setTrim(boolean trim)
Set to true in order to trim invisible characters (spaces) from values.


setVariables

@Deprecated
public void setVariables(Map<String,String> vars)
Deprecated. prefer use of getVariables() then Properties .load()


setVariable

public void setVariable(String name,
                        String value)

getVariable

public String getVariable(String name)

getVariables

public Properties getVariables()

process

public String process(CharSequence text)

process

public String process(InputStream in)
               throws IOException
Throws:
IOException

process

public void process(InputStream in,
                    OutputStream out)
             throws IOException
Throws:
IOException

processDirectory

public void processDirectory(File in,
                             File out)
                      throws FileNotFoundException,
                             IOException
Recursive call process(InputStream, OutputStream, boolean) on each file from "in" directory to "out" directory.

Parameters:
in - Directory to read files from
out - Directory to write files to
Throws:
FileNotFoundException
IOException

process

public void process(InputStream is,
                    OutputStream os,
                    boolean processText)
             throws IOException
Parameters:
processText - if true, text is processed for parameters replacement
Throws:
IOException

setParsingExtensions

public void setParsingExtensions(String extensionsList)
Parameters:
extensionsList - comma-separated list of files extensions to parse

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.