Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/template In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24176
Modified Files: TemplateEngine.java Log Message: Tidy up handling of PrettyPrintWriter (XDT-1290). Also javadocs (XDT-1225). Index: TemplateEngine.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/template/TemplateEngine.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** TemplateEngine.java 16 Aug 2004 04:52:50 -0000 1.38 --- TemplateEngine.java 6 Apr 2005 23:54:38 -0000 1.39 *************** *** 108,113 **** /** ! * Skips whitespaces, starting from index i till the first non-whitespace character or end of template and returns ! * the new index. * * @param template Description of Parameter --- 108,113 ---- /** ! * Skips whitespaces, starting from index <code>i</code> till the first non-whitespace character or end of <code>template</code> ! * and returns the new index. * * @param template Description of Parameter *************** *** 125,129 **** /** ! * Loops over the template content till reaching tillIndex index and returns the number of lines it has encountered. * * @param template Description of Parameter --- 125,130 ---- /** ! * Loops over the <code>template</code> content till reaching <code>tillIndex</code> index and returns the number of ! * lines it has encountered. * * @param template Description of Parameter *************** *** 248,253 **** /** ! * A config parameter settable from Ant build file. It sets the current template file to templateURL, so thereafter ! * the new template file is used. * * @param templateURL The new TemplateFile value --- 249,254 ---- /** ! * A config parameter settable from Ant build file. It sets the current template file to <code>templateURL</code>, ! * so thereafter the new template file is used. * * @param templateURL The new TemplateFile value *************** *** 312,326 **** /** ! * The main template parsing/processing/running logic. It searches for <XDoclet: string, parses what is found after ! * it till a matching </XDoclet: is found in case of a block tag, or till a /> is found in case of a content tag. It ! * automatically calls the relevent tag implementation method with the correct parameters. If a block tag, then the ! * tag implementation accepts two parameters, the body of the block tag as a string and a Properties object ! * containing all attributes. Note that if the tag doesn't have any attributes the corresponding tag implementation ! * typically only accepts a single string value denoting the block body, though it can also accept a Properties as ! * the second parameter. Tags that may or may not have attributes can safely accept the second Properties object, ! * which will be filled either by nothing or by all the given attributes. Content tag implementation methods have no ! * parameter but should return a String containing the result that should be printed to the generated file. XTag ! * implementation methods should define and throw org.apache.tools.ant.TemplateException if any serious error ! * occurs. * * @param template Description of Parameter --- 313,327 ---- /** ! * The main template parsing/processing/running logic. It searches for <XDoclet: string, parses what is found ! * after it till a matching </XDoclet: is found in case of a block tag, or till a /> is found in case of a ! * content tag. It automatically calls the relevent tag implementation method with the correct parameters. If a ! * block tag, then the tag implementation accepts two parameters, the body of the block tag as a string and a ! * Properties object containing all attributes. Note that if the tag doesn't have any attributes the corresponding ! * tag implementation typically only accepts a single string value denoting the block body, though it can also ! * accept a Properties as the second parameter. Tags that may or may not have attributes can safely accept the ! * second Properties object, which will be filled either by nothing or by all the given attributes. Content tag ! * implementation methods have no parameter but should return a String containing the result that should be printed ! * to the generated file. XTag implementation methods should define and throw org.apache.tools.ant.TemplateException ! * if any serious error occurs. * * @param template Description of Parameter *************** *** 351,359 **** /** ! * Calls generate() of the specified template content but instead of outputing it to the generated file, it returns ! * the generated content. It's useful for cases where you want to synthesize the result but use it instead of ! * roughly outputing it, for example it's used for the content tags nested inside an attribute value such as: ! * <XDoclet:blabla param1=" <XDoclet:aContentTag/>"/> where we obviously don't want to output the result of ! * aContentTag but use it as the value of the param1 parameter. * * @param template Description of Parameter --- 352,360 ---- /** ! * Calls <code>generate()</code> of the specified template content but instead of outputing it to the generated ! * file, it returns the generated content. It's useful for cases where you want to synthesize the result but use it ! * instead of roughly outputing it, for example it's used for the content tags nested inside an attribute value such ! * as: <code><XDoclet:blabla param1="<XDoclet:aContentTag/>"/></code> where we obviously don't want to ! * output the result of <code>aContentTag</code> but use it as the value of the <code>param1</code> parameter. * * @param template Description of Parameter *************** *** 389,392 **** --- 390,395 ---- if (content != null) { + PrettyPrintWriter out = null; + try { String encoding = docEncoding; *************** *** 396,401 **** } - PrettyPrintWriter out = null; - if (encoding == null) { out = new PrettyPrintWriter( --- 399,402 ---- *************** *** 413,417 **** setCurrentLineNum(0); generate(content); ! out.close(); } catch (IOException ex) { --- 414,418 ---- setCurrentLineNum(0); generate(content); ! setWriter(null); } catch (IOException ex) { *************** *** 422,426 **** } finally { ! out.close(); } } --- 423,429 ---- } finally { ! if (out != null) { ! out.close(); ! } } } *************** *** 477,483 **** /** ! * Invokes content tag implementation method named cmd. It first tries with parameters params1, if not successful ! * tries param2. This is used for cases where it's not obvious whether the tag implementation method expects a ! * Properties object or no parameter at all (the tag takes no attributes). * * @param cmd The command to be executed. Everything after the <code><XDoclet:</code> in the --- 480,486 ---- /** ! * Invokes content tag implementation method named <code>cmd</code>. It first tries with parameters <code>params1</code> ! * then if not successful tries <code>param2</code>. This is used for cases where it's not obvious whether the tag ! * implementation method expects a Properties object or no parameter at all (the tag takes no attributes). * * @param cmd The command to be executed. Everything after the <code><XDoclet:</code> in the *************** *** 588,592 **** /** ! * Invokes content tag implementation method named cmd with the specified set of attributes. If attributes * Properties object is not empty it tries to find a method taking one parameter (Properties attributes), otherwise * a method with no parameter. --- 591,595 ---- /** ! * Invokes content tag implementation method named <code>cmd</code> with the specified set of attributes. If <code>attributes</code> * Properties object is not empty it tries to find a method taking one parameter (Properties attributes), otherwise * a method with no parameter. *************** *** 700,704 **** /** ! * Extract the name of the tag starting at index <code>i</code> from the specified <code>template</code> . * * @param template The template containing the tag. --- 703,707 ---- /** ! * Extract the name of the tag starting at index <code>i</code> from the specified <code>template</code>. * * @param template The template containing the tag. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel