dion 2003/01/10 20:03:49 Modified: jelly/src/java/org/apache/commons/jelly/tags/core ImportTag.java Log: - Refactor JellyContext.runScript so that the various methods are consistent. - Add a file option to the core:import tag Revision Changes Path 1.5 +47 -10 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ImportTag.java Index: ImportTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ImportTag.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ImportTag.java 11 Dec 2002 12:40:54 -0000 1.4 +++ ImportTag.java 11 Jan 2003 04:03:48 -0000 1.5 @@ -80,23 +80,51 @@ public class ImportTag extends TagSupport { + /** + * the location of the script being imported, relative to the + * current script + */ private String uri; + + /** + * Whether the imported script has access to the caller's variables + */ private boolean inherit; + + /** + * The file to be imported. Mutually exclusive with uri. + * uri takes precedence. + */ + private String file; + /** + * Create a new Import tag. + * @see java.lang.Object#Object() + */ public ImportTag() { } // Tag interface - //------------------------------------------------------------------------- + //------------------------------------------------------------------------- + /** + * Perform tag processing + * @param output the destination for output + * @throws Exception Any exception can be thrown + */ public void doTag(XMLOutput output) throws Exception { - if (uri == null) { + if (uri == null && file == null) { throw new MissingAttributeException( "uri" ); } - // we need to create a new JellyContext of the URI - // take off the script name from the URL - context.runScript(uri, output, true, isInherit() ); + if (uri != null) { + // we need to create a new JellyContext of the URI + // take off the script name from the URL + context.runScript(uri, output, true, isInherit() ); + } else { + context.runScript(new java.io.File(file), output, true, + isInherit()); + } } // Properties @@ -121,6 +149,15 @@ */ public void setUri(String uri) { this.uri = uri; + } + + + /** + * Sets the file for the script to evaluate. + * @param file The file to set + */ + public void setFile(String file) { + this.file = file; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>