From: Arne V. <cob...@us...> - 2004-07-11 22:03:00
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6890/org/jrobin/core Modified Files: XmlTemplate.java Log Message: JRobin 1.4.0 - Several tweaks - Added print() option to ExportData - Added time() option to RrdGraphDef - Added variables options to XmlTemplate Index: XmlTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/XmlTemplate.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** XmlTemplate.java 20 May 2004 10:29:33 -0000 1.8 --- XmlTemplate.java 11 Jul 2004 22:02:52 -0000 1.9 *************** *** 32,39 **** import java.io.IOException; import java.io.File; ! import java.util.HashMap; ! import java.util.HashSet; ! import java.util.Date; ! import java.util.GregorianCalendar; import java.util.regex.Pattern; import java.util.regex.Matcher; --- 32,36 ---- import java.io.IOException; import java.io.File; ! import java.util.*; import java.util.regex.Pattern; import java.util.regex.Matcher; *************** *** 163,166 **** --- 160,193 ---- } + /** + * Searches the XML template to see if there are variables in there that + * will need to be set. + * + * @return True if variables were detected, false if not. + */ + public boolean hasVariables() { + return PATTERN.matcher( root.toString() ).find(); + } + + /** + * Returns the list of variables that should be set in this template. + * + * @return List of variable names as an array of strings. + */ + public String[] getVariables() + { + ArrayList list = new ArrayList(); + Matcher m = PATTERN.matcher( root.toString() ); + + while ( m.find() ) + { + String var = m.group(1); + if ( !list.contains( var ) ) + list.add( var ); + } + + return (String[]) list.toArray( new String[list.size()] ); + } + protected static Node[] getChildNodes(Node parentNode, String childName) { return Util.Xml.getChildNodes(parentNode, childName); |