public String parse(String inputTemplate,String intputEncoding,String outputFile,String outputEncoding,String objectID,Object object) throws Exception {
  if (objectID != null && object != null) {
    controlContext.put(objectID,object);
  }
  Template template=getTemplate(inputTemplate,inputEncoding != null ? inputEncoding : this.inputEncoding);
  if (outputFile == null || outputFile.equals("")) {
    StringWriter sw=new StringWriter();
    template.merge(controlContext,sw);
    return sw.toString();
  }
 else {
    Writer writer=null;
    if (writers.get(outputFile) == null) {
      writer=getWriter(getOutputPath() + File.separator + outputFile,outputEncoding != null ? outputEncoding : this.outputEncoding);
      writers.put(outputFile,writer);
    }
 else {
      writer=(Writer)writers.get(outputFile);
    }
    VelocityContext vc=new VelocityContext(controlContext);
    template.merge(vc,writer);
    return "";
  }
}

public String parse ( String inputTemplate , String intputEncoding , String outputFile , String outputEncoding , String objectID , Object object ) throws Exception { if ( objectID != null && object != null ) { controlContext . put ( objectID , object ) ; } Template template = getTemplate ( inputTemplate , inputEncoding != null ? inputEncoding : this . inputEncoding ) ; if ( outputFile == null || outputFile . equals ( "" ) ) { StringWriter sw = new StringWriter ( ) ; template . merge ( controlContext , sw ) ; return sw . toString ( ) ; } else { Writer writer = null ; if ( writers . get ( outputFile ) == null ) { writer = getWriter ( getOutputPath ( ) + File . separator + outputFile , outputEncoding != null ? outputEncoding : this . outputEncoding ) ; writers . put ( outputFile , writer ) ; } else { writer = ( Writer ) writers . get ( outputFile ) ; } VelocityContext vc = new VelocityContext ( controlContext ) ; template . merge ( vc , writer ) ; return "" ; } }
parse an input and write the output to an output file . if the output file parameter is null or an empty string the result is returned as a string object . otherwise an empty string is returned . you can add objects to the context with the objs hashtable .
