| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"> |
| <!--NewPage--> |
| <HTML> |
| <HEAD> |
| <!-- Generated by javadoc on Wed Apr 14 08:26:32 EDT 2004 --> |
| <TITLE> |
| Velocity 1.4 API: Class FieldMethodizer |
| </TITLE> |
| <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> |
| </HEAD> |
| <BODY BGCOLOR="white"> |
| |
| <!-- ========== START OF NAVBAR ========== --> |
| <A NAME="navbar_top"><!-- --></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_top_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/FieldMethodizer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| PREV CLASS |
| <A HREF="../../../../org/apache/velocity/app/Velocity.html"><B>NEXT CLASS</B></A></FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A> |
| <A HREF="FieldMethodizer.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <!-- =========== END OF NAVBAR =========== --> |
| |
| <HR> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <H2> |
| <FONT SIZE="-1"> |
| org.apache.velocity.app</FONT> |
| <BR> |
| Class FieldMethodizer</H2> |
| <PRE> |
| java.lang.Object |
| | |
| +--<B>org.apache.velocity.app.FieldMethodizer</B> |
| </PRE> |
| <HR> |
| <DL> |
| <DT>public class <B>FieldMethodizer</B><DT>extends java.lang.Object</DL> |
| |
| <P> |
| <p> |
| This is a small utility class allow easy access to static fields in a class, |
| such as string constants. Velocity will not introspect for class |
| fields (and won't in the future :), but writing setter/getter methods to do |
| this really is a pain, so use this if you really have |
| to access fields. |
| |
| <p> |
| The idea it so enable access to the fields just like you would in Java. |
| For example, in Java, you would access a static field like |
| <blockquote><pre> |
| MyClass.STRING_CONSTANT |
| </pre></blockquote> |
| and that is the same thing we are trying to allow here. |
| |
| <p> |
| So to use in your Java code, do something like this : |
| <blockquote><pre> |
| context.put("runtime", new FieldMethodizer( "org.apache.velocity.runtime.Runtime" )); |
| </pre></blockquote> |
| and then in your template, you can access any of your static fields in this way : |
| <blockquote><pre> |
| $runtime.RUNTIME_LOG_WARN_STACKTRACE |
| </pre></blockquote> |
| |
| <p> |
| Right now, this class only methodizes <code>public static</code> fields. It seems |
| that anything else is too dangerous. This class is for convenience accessing |
| 'constants'. If you have fields that aren't <code>static</code> it may be better |
| to handle them by explicitly placing them into the context. |
| <P> |
| <DL> |
| <DT><B>Version: </B><DD>$Id: FieldMethodizer.java,v 1.3.14.1 2004/03/03 23:22:53 geirm Exp $</DD> |
| <DT><B>Author: </B><DD><a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a></DD> |
| </DL> |
| <HR> |
| |
| <P> |
| <!-- ======== INNER CLASS SUMMARY ======== --> |
| |
| |
| <!-- =========== FIELD SUMMARY =========== --> |
| |
| <A NAME="field_summary"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=2><FONT SIZE="+2"> |
| <B>Field Summary</B></FONT></TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>private java.util.HashMap</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#classHash">classHash</A></B></CODE> |
| |
| <BR> |
| Hold the class objects by field name</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>private java.util.HashMap</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#fieldHash">fieldHash</A></B></CODE> |
| |
| <BR> |
| Hold the field objects by field name</TD> |
| </TR> |
| </TABLE> |
| |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| |
| <A NAME="constructor_summary"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=2><FONT SIZE="+2"> |
| <B>Constructor Summary</B></FONT></TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#FieldMethodizer()">FieldMethodizer</A></B>()</CODE> |
| |
| <BR> |
| Allow object to be initialized without any data.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#FieldMethodizer(java.lang.Object)">FieldMethodizer</A></B>(java.lang.Object o)</CODE> |
| |
| <BR> |
| Constructor that takes as it's arg a living |
| object to methodize.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#FieldMethodizer(java.lang.String)">FieldMethodizer</A></B>(java.lang.String s)</CODE> |
| |
| <BR> |
| Constructor that takes as it's arg the name of the class |
| to methodize.</TD> |
| </TR> |
| </TABLE> |
| |
| <!-- ========== METHOD SUMMARY =========== --> |
| |
| <A NAME="method_summary"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=2><FONT SIZE="+2"> |
| <B>Method Summary</B></FONT></TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#addObject(java.lang.Object)">addObject</A></B>(java.lang.Object o)</CODE> |
| |
| <BR> |
| Add an Object to methodize</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#addObject(java.lang.String)">addObject</A></B>(java.lang.String s)</CODE> |
| |
| <BR> |
| Add the Name of the class to methodize</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> java.lang.Object</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#get(java.lang.String)">get</A></B>(java.lang.String fieldName)</CODE> |
| |
| <BR> |
| Accessor method to get the fields by name.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>private void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../org/apache/velocity/app/FieldMethodizer.html#inspect(java.lang.Class)">inspect</A></B>(java.lang.Class clas)</CODE> |
| |
| <BR> |
| Method that retrieves all public static fields |
| in the class we are methodizing.</TD> |
| </TR> |
| </TABLE> |
| <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
| <TD><B>Methods inherited from class java.lang.Object</B></TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE><clinit>, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait</CODE></TD> |
| </TR> |
| </TABLE> |
| |
| <P> |
| |
| <!-- ============ FIELD DETAIL =========== --> |
| |
| <A NAME="field_detail"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=1><FONT SIZE="+2"> |
| <B>Field Detail</B></FONT></TD> |
| </TR> |
| </TABLE> |
| |
| <A NAME="fieldHash"><!-- --></A><H3> |
| fieldHash</H3> |
| <PRE> |
| private java.util.HashMap <B>fieldHash</B></PRE> |
| <DL> |
| <DD>Hold the field objects by field name</DL> |
| <HR> |
| |
| <A NAME="classHash"><!-- --></A><H3> |
| classHash</H3> |
| <PRE> |
| private java.util.HashMap <B>classHash</B></PRE> |
| <DL> |
| <DD>Hold the class objects by field name</DL> |
| |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| |
| <A NAME="constructor_detail"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=1><FONT SIZE="+2"> |
| <B>Constructor Detail</B></FONT></TD> |
| </TR> |
| </TABLE> |
| |
| <A NAME="FieldMethodizer()"><!-- --></A><H3> |
| FieldMethodizer</H3> |
| <PRE> |
| public <B>FieldMethodizer</B>()</PRE> |
| <DL> |
| <DD>Allow object to be initialized without any data. You would use |
| addObject() to add data later.</DL> |
| <HR> |
| |
| <A NAME="FieldMethodizer(java.lang.String)"><!-- --></A><H3> |
| FieldMethodizer</H3> |
| <PRE> |
| public <B>FieldMethodizer</B>(java.lang.String s)</PRE> |
| <DL> |
| <DD>Constructor that takes as it's arg the name of the class |
| to methodize.<DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>s</CODE> - Name of class to methodize.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="FieldMethodizer(java.lang.Object)"><!-- --></A><H3> |
| FieldMethodizer</H3> |
| <PRE> |
| public <B>FieldMethodizer</B>(java.lang.Object o)</PRE> |
| <DL> |
| <DD>Constructor that takes as it's arg a living |
| object to methodize. Note that it will still |
| only methodized the public static fields of |
| the class.<DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>s</CODE> - Name of class to methodize.</DL> |
| </DD> |
| </DL> |
| |
| <!-- ============ METHOD DETAIL ========== --> |
| |
| <A NAME="method_detail"><!-- --></A> |
| <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TD COLSPAN=1><FONT SIZE="+2"> |
| <B>Method Detail</B></FONT></TD> |
| </TR> |
| </TABLE> |
| |
| <A NAME="addObject(java.lang.String)"><!-- --></A><H3> |
| addObject</H3> |
| <PRE> |
| public void <B>addObject</B>(java.lang.String s) |
| throws java.lang.Exception</PRE> |
| <DL> |
| <DD>Add the Name of the class to methodize</DL> |
| <HR> |
| |
| <A NAME="addObject(java.lang.Object)"><!-- --></A><H3> |
| addObject</H3> |
| <PRE> |
| public void <B>addObject</B>(java.lang.Object o) |
| throws java.lang.Exception</PRE> |
| <DL> |
| <DD>Add an Object to methodize</DL> |
| <HR> |
| |
| <A NAME="get(java.lang.String)"><!-- --></A><H3> |
| get</H3> |
| <PRE> |
| public java.lang.Object <B>get</B>(java.lang.String fieldName)</PRE> |
| <DL> |
| <DD>Accessor method to get the fields by name.<DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>fieldName</CODE> - Name of static field to retrieve<DT><B>Returns:</B><DD>The value of the given field.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="inspect(java.lang.Class)"><!-- --></A><H3> |
| inspect</H3> |
| <PRE> |
| private void <B>inspect</B>(java.lang.Class clas)</PRE> |
| <DL> |
| <DD>Method that retrieves all public static fields |
| in the class we are methodizing.</DL> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <HR> |
| |
| <!-- ========== START OF NAVBAR ========== --> |
| <A NAME="navbar_bottom"><!-- --></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_bottom_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/FieldMethodizer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| PREV CLASS |
| <A HREF="../../../../org/apache/velocity/app/Velocity.html"><B>NEXT CLASS</B></A></FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A> |
| <A HREF="FieldMethodizer.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <!-- =========== END OF NAVBAR =========== --> |
| |
| <HR> |
| Copyright © 2002 Apache Software Foundation. All Rights Reserved. |
| </BODY> |
| </HTML> |