Author: nbubna
Date: Tue Nov 21 09:38:50 2006
New Revision: 477778
URL: http://svn.apache.org/viewvc?view=rev&rev=477778
Log:
add convenience method for loading a toolbox from a file path (thanks to Edgar
Poce, VELTOOLS-8)
Modified:
jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java
Modified:
jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java
URL:
http://svn.apache.org/viewvc/jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java?view=diff&rev=477778&r1=477777&r2=477778
==============================================================================
---
jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java
(original)
+++
jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java
Tue Nov 21 09:38:50 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
package org.apache.velocity.tools.view;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@@ -165,6 +167,31 @@
// ------------------------------- toolbox loading methods ------------
+
+ /**
+ * <p>Reads an XML document from the specified file path
+ * and sets up the toolbox from that. If the file does not
+ * exist, an [EMAIL PROTECTED] IllegalArgumentException} will be
thrown.</p>
+ *
+ * @param path the path to the file to be read from
+ * @since VelocityTools 1.3
+ */
+ public void load(String path) throws Exception
+ {
+ if (path == null)
+ {
+ throw new IllegalArgumentException("Path value cannot be null");
+ }
+
+ File file = new File(path);
+ if (!file.exists())
+ {
+ throw new IllegalArgumentException("Could not find toolbox config
file at: "+path);
+ }
+
+ // ok, load the file
+ load(new FileInputStream(file));
+ }
/**
* <p>Reads an XML document from an [EMAIL PROTECTED] InputStream}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]