You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(97) |
Dec
(35) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
(55) |
Mar
(21) |
Apr
(3) |
May
(7) |
Jun
(25) |
Jul
(108) |
Aug
(23) |
Sep
|
Oct
|
Nov
|
Dec
(4) |
2006 |
Jan
|
Feb
|
Mar
(6) |
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
(13) |
Feb
|
Mar
(257) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(38) |
Dec
|
2009 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(63) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dr...@us...> - 2003-07-02 15:34:08
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv10923/src/org/tcdi/opensource/wiki Modified Files: Wiki.java Log Message: sort the list of "current page names", case insensitivly Index: Wiki.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/Wiki.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Wiki.java 2 Jul 2003 06:55:13 -0000 1.10 --- Wiki.java 2 Jul 2003 15:34:05 -0000 1.11 *************** *** 372,375 **** --- 372,380 ---- } + Collections.sort(l, new Comparator() { + public int compare(Object o1, Object o2) { + return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase()); + } + }); _pageNames = (String[]) l.toArray(new String[0]); _pageLookup = pageLookup; |
From: <dr...@us...> - 2003-07-02 06:55:17
|
Update of /cvsroot/webmacro/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv5523 Modified Files: wiki.jar wiki1.iml wiki1.iws Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too Index: wiki.jar =================================================================== RCS file: /cvsroot/webmacro/wiki/wiki.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsqHgg37 and /tmp/cvsyKzBP5 differ Index: wiki1.iml =================================================================== RCS file: /cvsroot/webmacro/wiki/wiki1.iml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Index: wiki1.iws =================================================================== RCS file: /cvsroot/webmacro/wiki/wiki1.iws,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wiki1.iws 2 Jul 2003 03:01:52 -0000 1.1 --- wiki1.iws 2 Jul 2003 06:55:13 -0000 1.2 *************** *** 21,25 **** </component> <component name="ToolWindowManager"> ! <frame x="63" y="22" width="1317" height="1021" extended-state="0" /> <editor active="false" /> <layout> --- 21,25 ---- </component> <component name="ToolWindowManager"> ! <frame x="14" y="48" width="1317" height="1021" extended-state="0" /> <editor active="false" /> <layout> *************** *** 27,38 **** <window_info id="CVS" active="false" anchor="bottom" auto_hide="true" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="2" /> ! <window_info id="Hierarchy" active="true" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.13217938" order="2" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="sliding" type="sliding" visible="false" weight="0.4" order="0" /> ! <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.26357198" order="0" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="3" /> <window_info id="App Server" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" /> ! <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="1" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="6" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> --- 27,38 ---- <window_info id="CVS" active="false" anchor="bottom" auto_hide="true" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="2" /> ! <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.13217938" order="2" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="sliding" type="sliding" visible="false" weight="0.4" order="0" /> ! <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.26357198" order="0" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="3" /> <window_info id="App Server" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" /> ! <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.33002207" order="1" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="6" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> *************** *** 60,79 **** <navigator currentView="ProjectPane" flattenPackages="false" showMembers="true" showStructure="false" autoscrollToSource="false" splitterProportion="0.5" /> <view id="ProjectPane"> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/etc" /> ! <expanded_node type="class" url="org.tcdi.opensource.wiki.WikiPage" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/builds" /> ! <expanded_node type="directory" url="file:///tcdi/wiki/deploy/WEB-INF" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/templates" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/admin" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src" /> - <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi" /> - <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki" /> </view> <view id="SourcepathPane" /> --- 60,80 ---- <navigator currentView="ProjectPane" flattenPackages="false" showMembers="true" showStructure="false" autoscrollToSource="false" splitterProportion="0.5" /> <view id="ProjectPane"> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/util" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs" /> + <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org" /> + <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/etc" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/templates" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/renderer" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource" /> ! <expanded_node type="class" url="org.tcdi.opensource.wiki.renderer.WikiPageRenderer" /> ! <expanded_node type="directory" url="file://$PROJECT_DIR$/builds" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki" /> + <expanded_node type="directory" url="file://$PROJECT_DIR$" /> + <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi" /> + <expanded_node type="directory" url="file:///tcdi/wiki/deploy/WEB-INF" /> + <expanded_node type="class" url="org.tcdi.opensource.wiki.renderer.TextPageRenderer" /> </view> <view id="SourcepathPane" /> *************** *** 103,173 **** </todo-panel> </component> ! <component name="editorManager" selected-file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/WikiServlet.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="73" column="0" selection-start="2434" selection-end="2434" vertical-scroll-proportion="0.5255042" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="38" column="6" selection-start="1308" selection-end="1308" vertical-scroll-proportion="0.41162515" horizontal-scroll-proportion="0.06158358"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="12" column="14" selection-start="532" selection-end="532" vertical-scroll-proportion="0.107947804" horizontal-scroll-proportion="0.14369501"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="30" column="0" selection-start="1358" selection-end="1397" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/FindPagesAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/IndexPageAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/PageTreeAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/AdminAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="30" column="33" selection-start="1115" selection-end="1115" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.34070796"> <folding /> </state> --- 104,174 ---- </todo-panel> </component> ! <component name="editorManager" selected-file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/DiffPageAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="161" column="64" selection-start="6233" selection-end="6233" vertical-scroll-proportion="0.3172542" horizontal-scroll-proportion="0.66766024"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/diff.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="11" column="56" selection-start="363" selection-end="363" vertical-scroll-proportion="0.3265306" horizontal-scroll-proportion="0.57478005"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs/site-style.css"> <provider selected="true" editor-type-id="text-editor"> ! <state line="106" column="9" selection-start="1348" selection-end="1348" vertical-scroll-proportion="0.8812616" horizontal-scroll-proportion="0.093333334"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/footer.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="31" column="0" selection-start="1086" selection-end="1086" vertical-scroll-proportion="0.46567717" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="50" column="18" selection-start="1914" selection-end="1914" vertical-scroll-proportion="1.4155844" horizontal-scroll-proportion="0.18475074"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="32" column="3" selection-start="1333" selection-end="1333" vertical-scroll-proportion="0.13914657" horizontal-scroll-proportion="0.03079179"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/view.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/WebMacro.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="32" column="32" selection-start="1489" selection-end="1489" vertical-scroll-proportion="0.9406308" horizontal-scroll-proportion="0.33185184"> <folding /> </state> </provider> </entry> ! <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="16" column="0" selection-start="797" selection-end="857" vertical-scroll-proportion="0.3172542" horizontal-scroll-proportion="0.0"> <folding /> </state> *************** *** 176,280 **** </component> <component name="editorHistoryManager"> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UserListAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="30" column="0" selection-start="864" selection-end="999" vertical-scroll-proportion="0.4365362" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/indexpage.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="4" column="48" selection-start="114" selection-end="114" vertical-scroll-proportion="0.07591934" horizontal-scroll-proportion="0.49266863"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/admin/update_user.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="23" column="12" selection-start="1007" selection-end="1007" vertical-scroll-proportion="0.4365362" horizontal-scroll-proportion="0.12316716"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs/site-style.css"> <provider selected="true" editor-type-id="text-editor"> ! <state line="78" column="0" selection-start="961" selection-end="961" vertical-scroll-proportion="0.7402135" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/adminoptionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="25" selection-start="25" selection-end="25" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.2539913"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/WikiSystem.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="83" column="28" selection-start="2871" selection-end="2871" vertical-scroll-proportion="0.8351127" horizontal-scroll-proportion="0.29923666"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="38" column="6" selection-start="1308" selection-end="1308" vertical-scroll-proportion="0.41162515" horizontal-scroll-proportion="0.06158358"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="12" column="14" selection-start="532" selection-end="532" vertical-scroll-proportion="0.107947804" horizontal-scroll-proportion="0.14369501"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="30" column="0" selection-start="1358" selection-end="1397" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/FindPagesAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/IndexPageAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/PageTreeAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/AdminAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="30" column="33" selection-start="1115" selection-end="1115" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.34070796"> <folding /> </state> --- 177,281 ---- </component> <component name="editorHistoryManager"> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/WikiPage.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="205" column="27" selection-start="6515" selection-end="6515" vertical-scroll-proportion="0.48051947" horizontal-scroll-proportion="0.28166914"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/Wiki.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="125" column="18" selection-start="4376" selection-end="4376" vertical-scroll-proportion="0.25788498" horizontal-scroll-proportion="0.18777943"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/WikiServlet.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="61" column="33" selection-start="2135" selection-end="2135" vertical-scroll-proportion="0.23747681" horizontal-scroll-proportion="0.3442623"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/util/Diff.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="512" column="29" selection-start="20021" selection-end="20021" vertical-scroll-proportion="0.064935066" horizontal-scroll-proportion="0.30253354"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/util/DiffPrint.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="111" column="21" selection-start="3825" selection-end="3825" vertical-scroll-proportion="0.035250463" horizontal-scroll-proportion="0.22442748"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs/site-style.css"> <provider selected="true" editor-type-id="text-editor"> ! <state line="106" column="9" selection-start="1348" selection-end="1348" vertical-scroll-proportion="0.8812616" horizontal-scroll-proportion="0.093333334"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/DiffPageAction.java"> <provider selected="true" editor-type-id="text-editor"> ! <state line="161" column="64" selection-start="6233" selection-end="6233" vertical-scroll-proportion="0.3172542" horizontal-scroll-proportion="0.66766024"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/diff.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="11" column="56" selection-start="363" selection-end="363" vertical-scroll-proportion="0.3265306" horizontal-scroll-proportion="0.57478005"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/footer.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="31" column="0" selection-start="1086" selection-end="1086" vertical-scroll-proportion="0.46567717" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/view.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="50" column="18" selection-start="1914" selection-end="1914" vertical-scroll-proportion="1.4155844" horizontal-scroll-proportion="0.18475074"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> ! <state line="32" column="3" selection-start="1333" selection-end="1333" vertical-scroll-proportion="0.13914657" horizontal-scroll-proportion="0.03079179"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/WebMacro.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> ! <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="32" column="32" selection-start="1489" selection-end="1489" vertical-scroll-proportion="0.9406308" horizontal-scroll-proportion="0.33185184"> <folding /> </state> </provider> </entry> ! <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> ! <state line="16" column="0" selection-start="797" selection-end="857" vertical-scroll-proportion="0.3172542" horizontal-scroll-proportion="0.0"> <folding /> </state> |
From: <dr...@us...> - 2003-07-02 06:55:17
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv5523/src/org/tcdi/opensource/wiki Modified Files: Wiki.java WikiPage.java WikiUtil.java Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too Index: Wiki.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/Wiki.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Wiki.java 2 Jul 2003 03:01:52 -0000 1.9 --- Wiki.java 2 Jul 2003 06:55:13 -0000 1.10 *************** *** 133,145 **** public void savePage(WikiPage page, String title) { ! WikiPage oldVersion = (WikiPage) _pageStore.get(title); boolean isnew = false; ! if (oldVersion != null) { // backup old version of this page ! oldVersion.setTitle(oldVersion.getTitle() + "." + oldVersion.getVersion()); ! _pageStore.put(oldVersion.getTitle() + "." + oldVersion.getVersion(), page); } else { // this is a brand new page isnew = true; } --- 133,146 ---- public void savePage(WikiPage page, String title) { ! WikiPage currentVersion = (WikiPage) _pageStore.get (title); boolean isnew = false; ! if (currentVersion != null) { // backup old version of this page ! _pageStore.put (currentVersion.getTitle() + "." + currentVersion.getVersion(), currentVersion); ! page.setVersion (currentVersion.getVersion()+1); } else { // this is a brand new page isnew = true; + page.setVersion(0); } Index: WikiPage.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiPage.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** WikiPage.java 30 Sep 2001 08:28:27 -0000 1.1.1.1 --- WikiPage.java 2 Jul 2003 06:55:13 -0000 1.2 *************** *** 196,199 **** --- 196,210 ---- public long getVersion() { return _version; } + /** increment the version number of this page. You'll probably want to re-save it + * to the page store after this + */ + public void incrementVersion () { + _version++; + } + + public void setVersion (long version) { + _version = version; + } + /** * @return Author of this page. Index: WikiUtil.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WikiUtil.java 2 Jul 2003 03:01:52 -0000 1.4 --- WikiUtil.java 2 Jul 2003 06:55:13 -0000 1.5 *************** *** 208,210 **** --- 208,232 ---- return l; } + + /** + * take a delimited string and convert to a String[] + * @param in the delimited string + * @param delim the delimiter + * @return a String[] + */ + public static final String[] delimitedToArray(String in, String delim) { + if (in == null || delim == null) + return new String[0]; + StringTokenizer st = new StringTokenizer(in, delim); + String[] rc = new String[st.countTokens()]; + if (rc.length == 0) + return new String[]{in}; + + int x = 0; + while (st.hasMoreTokens()) { + rc[x++] = st.nextToken(); + } + + return rc; + } } |
From: <dr...@us...> - 2003-07-02 06:55:17
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/util In directory sc8-pr-cvs1:/tmp/cvs-serv5523/src/org/tcdi/opensource/wiki/util Added Files: Diff.java DiffPrint.java Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too --- NEW FILE: Diff.java --- /* * $Log: Diff.java,v $ * Revision 1.6 2003/03/06 22:51:32 stuart * Convert to CVS * * Revision 1.5 2002/07/19 19:14:40 stuart * fix reverseScript, make change ctor public, update docs * * Revision 1.4 2002/04/09 17:53:39 stuart * More flexible interface for diff() function. * * Revision 1.3 2000/03/03 21:58:03 stuart * move discard_confusing_lines and shift_boundaries to class file_data * * Revision 1.2 2000/03/02 16:37:38 stuart * Add GPL and copyright * */ package org.tcdi.opensource.wiki.util; import java.util.Hashtable; /** A class to compare vectors of objects. The result of comparison is a list of <code>change</code> objects which form an edit script. The objects compared are traditionally lines of text from two files. Comparison options such as "ignore whitespace" are implemented by modifying the <code>equals</code> and <code>hashcode</code> methods for the objects compared. <p> The basic algorithm is described in: </br> "An O(ND) Difference Algorithm and its Variations", Eugene Myers, Algorithmica Vol. 1 No. 2, 1986, p 251. <p> This class outputs different results from GNU diff 1.15 on some inputs. Our results are actually better (smaller change list, smaller total size of changes), but it would be nice to know why. Perhaps there is a memory overwrite bug in GNU diff 1.15. @author Stuart D. Gathman, translated from GNU diff 1.15 Copyright (C) 2000 Business Management Systems, Inc. <p> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. <p> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <p> You should have received a copy of the <a href=COPYING.txt> GNU General Public License</a> along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ public class Diff { /** Prepare to find differences between two arrays. Each element of the arrays is translated to an "equivalence number" based on the result of <code>equals</code>. The original Object arrays are no longer needed for computing the differences. They will be needed again later to print the results of the comparison as an edit script, if desired. */ public Diff(Object[] a, Object[] b) { Hashtable h = new Hashtable(a.length + b.length); filevec[0] = new file_data(a, h); filevec[1] = new file_data(b, h); } /** 1 more than the maximum equivalence value used for this or its sibling file. */ private int equiv_max = 1; /** When set to true, the comparison uses a heuristic to speed it up. With this heuristic, for files with a constant small density of changes, the algorithm is linear in the file size. */ public boolean heuristic = false; /** When set to true, the algorithm returns a guarranteed minimal set of changes. This makes things slower, sometimes much slower. */ public boolean no_discards = false; private int[] xvec, yvec; /* Vectors being compared. */ private int[] fdiag; /* Vector, indexed by diagonal, containing the X coordinate of the point furthest along the given diagonal in the forward search of the edit matrix. */ private int[] bdiag; /* Vector, indexed by diagonal, containing the X coordinate of the point furthest along the given diagonal in the backward search of the edit matrix. */ private int fdiagoff, bdiagoff; private final file_data[] filevec = new file_data[2]; private int cost; /** Find the midpoint of the shortest edit script for a specified portion of the two files. We scan from the beginnings of the files, and simultaneously from the ends, doing a breadth-first search through the space of edit-sequence. When the two searches meet, we have found the midpoint of the shortest edit sequence. The value returned is the number of the diagonal on which the midpoint lies. The diagonal number equals the number of inserted lines minus the number of deleted lines (counting only lines before the midpoint). The edit cost is stored into COST; this is the total number of lines inserted or deleted (counting only lines before the midpoint). This function assumes that the first lines of the specified portions of the two files do not match, and likewise that the last lines do not match. The caller must trim matching lines from the beginning and end of the portions it is going to specify. Note that if we return the "wrong" diagonal value, or if the value of bdiag at that diagonal is "wrong", the worst this can do is cause suboptimal diff output. It cannot cause incorrect diff output. */ private int diag(int xoff, int xlim, int yoff, int ylim) { final int[] fd = fdiag; // Give the compiler a chance. final int[] bd = bdiag; // Additional help for the compiler. final int[] xv = xvec; // Still more help for the compiler. final int[] yv = yvec; // And more and more . . . final int dmin = xoff - ylim; // Minimum valid diagonal. final int dmax = xlim - yoff; // Maximum valid diagonal. final int fmid = xoff - yoff; // Center diagonal of top-down search. final int bmid = xlim - ylim; // Center diagonal of bottom-up search. int fmin = fmid, fmax = fmid; // Limits of top-down search. int bmin = bmid, bmax = bmid; // Limits of bottom-up search. /* True if southeast corner is on an odd diagonal with respect to the northwest. */ final boolean odd = (fmid - bmid & 1) != 0; fd[fdiagoff + fmid] = xoff; bd[bdiagoff + bmid] = xlim; for (int c = 1; ; ++c) { int d; /* Active diagonal. */ boolean big_snake = false; /* Extend the top-down search by an edit step in each diagonal. */ if (fmin > dmin) fd[fdiagoff + --fmin - 1] = -1; else ++fmin; if (fmax < dmax) fd[fdiagoff + ++fmax + 1] = -1; else --fmax; for (d = fmax; d >= fmin; d -= 2) { int x, y, oldx, tlo = fd[fdiagoff + d - 1], thi = fd[fdiagoff + d + 1]; if (tlo >= thi) x = tlo + 1; else x = thi; oldx = x; y = x - d; while (x < xlim && y < ylim && xv[x] == yv[y]) { ++x; ++y; } if (x - oldx > 20) big_snake = true; fd[fdiagoff + d] = x; if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { cost = 2 * c - 1; return d; } } /* Similar extend the bottom-up search. */ if (bmin > dmin) bd[bdiagoff + --bmin - 1] = Integer.MAX_VALUE; else ++bmin; if (bmax < dmax) bd[bdiagoff + ++bmax + 1] = Integer.MAX_VALUE; else --bmax; for (d = bmax; d >= bmin; d -= 2) { int x, y, oldx, tlo = bd[bdiagoff + d - 1], thi = bd[bdiagoff + d + 1]; if (tlo < thi) x = tlo; else x = thi - 1; oldx = x; y = x - d; while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1]) { --x; --y; } if (oldx - x > 20) big_snake = true; bd[bdiagoff + d] = x; if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { cost = 2 * c; return d; } } /* Heuristic: check occasionally for a diagonal that has made lots of progress compared with the edit distance. If we have any such, find the one that has made the most progress and return it as if it had succeeded. With this heuristic, for files with a constant small density of changes, the algorithm is linear in the file size. */ if (c > 200 && big_snake && heuristic) { int best = 0; int bestpos = -1; for (d = fmax; d >= fmin; d -= 2) { int dd = d - fmid; if ((fd[fdiagoff + d] - xoff) * 2 - dd > 12 * (c + (dd > 0 ? dd : -dd))) { if (fd[fdiagoff + d] * 2 - dd > best && fd[fdiagoff + d] - xoff > 20 && fd[fdiagoff + d] - d - yoff > 20) { int k; int x = fd[fdiagoff + d]; /* We have a good enough best diagonal; now insist that it end with a significant snake. */ for (k = 1; k <= 20; k++) if (xvec[x - k] != yvec[x - d - k]) break; if (k == 21) { best = fd[fdiagoff + d] * 2 - dd; bestpos = d; } } } } if (best > 0) { cost = 2 * c - 1; return bestpos; } best = 0; for (d = bmax; d >= bmin; d -= 2) { int dd = d - bmid; if ((xlim - bd[bdiagoff + d]) * 2 + dd > 12 * (c + (dd > 0 ? dd : -dd))) { if ((xlim - bd[bdiagoff + d]) * 2 + dd > best && xlim - bd[bdiagoff + d] > 20 && ylim - (bd[bdiagoff + d] - d) > 20) { /* We have a good enough best diagonal; now insist that it end with a significant snake. */ int k; int x = bd[bdiagoff + d]; for (k = 0; k < 20; k++) if (xvec[x + k] != yvec[x - d + k]) break; if (k == 20) { best = (xlim - bd[bdiagoff + d]) * 2 + dd; bestpos = d; } } } } if (best > 0) { cost = 2 * c - 1; return bestpos; } } } } /** Compare in detail contiguous subsequences of the two files which are known, as a whole, to match each other. The results are recorded in the vectors filevec[N].changed_flag, by storing a 1 in the element for each line that is an insertion or deletion. The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1. Note that XLIM, YLIM are exclusive bounds. All line numbers are origin-0 and discarded lines are not counted. */ private void compareseq(int xoff, int xlim, int yoff, int ylim) { /* Slide down the bottom initial diagonal. */ while (xoff < xlim && yoff < ylim && xvec[xoff] == yvec[yoff]) { ++xoff; ++yoff; } /* Slide up the top initial diagonal. */ while (xlim > xoff && ylim > yoff && xvec[xlim - 1] == yvec[ylim - 1]) { --xlim; --ylim; } /* Handle simple cases. */ if (xoff == xlim) while (yoff < ylim) filevec[1].changed_flag[1 + filevec[1].realindexes[yoff++]] = true; else if (yoff == ylim) while (xoff < xlim) filevec[0].changed_flag[1 + filevec[0].realindexes[xoff++]] = true; else { /* Find a point of correspondence in the middle of the files. */ int d = diag(xoff, xlim, yoff, ylim); int c = cost; int f = fdiag[fdiagoff + d]; int b = bdiag[bdiagoff + d]; if (c == 1) { /* This should be impossible, because it implies that one of the two subsequences is empty, and that case was handled above without calling `diag'. Let's verify that this is true. */ throw new IllegalArgumentException("Empty subsequence"); } else { /* Use that point to split this problem into two subproblems. */ compareseq(xoff, b, yoff, b - d); /* This used to use f instead of b, but that is incorrect! It is not necessarily the case that diagonal d has a snake from b to f. */ compareseq(b, xlim, b - d, ylim); } } } /** Discard lines from one file that have no matches in the other file. */ private void discard_confusing_lines() { filevec[0].discard_confusing_lines(filevec[1]); filevec[1].discard_confusing_lines(filevec[0]); } private boolean inhibit = false; /** Adjust inserts/deletes of blank lines to join changes as much as possible. */ private void shift_boundaries() { if (inhibit) return; filevec[0].shift_boundaries(filevec[1]); filevec[1].shift_boundaries(filevec[0]); } public interface ScriptBuilder { /** Scan the tables of which lines are inserted and deleted, producing an edit script. @param changed0 true for lines in first file which do not match 2nd @param len0 number of lines in first file @param changed1 true for lines in 2nd file which do not match 1st @param len1 number of lines in 2nd file @return a linked list of changes - or null */ public change build_script( boolean[] changed0, int len0, boolean[] changed1, int len1 ); } /** Scan the tables of which lines are inserted and deleted, producing an edit script in reverse order. */ static class ReverseScript implements ScriptBuilder { public change build_script( final boolean[] changed0, int len0, final boolean[] changed1, int len1) { change script = null; int i0 = 0, i1 = 0; while (i0 < len0 || i1 < len1) { if (changed0[1 + i0] || changed1[1 + i1]) { int line0 = i0, line1 = i1; /* Find # lines changed here in each file. */ while (changed0[1 + i0]) ++i0; while (changed1[1 + i1]) ++i1; /* Record this change. */ script = new change(line0, line1, i0 - line0, i1 - line1, script); } /* We have reached lines in the two files that match each other. */ i0++; i1++; } return script; } } static class ForwardScript implements ScriptBuilder { /** Scan the tables of which lines are inserted and deleted, producing an edit script in forward order. */ public change build_script( final boolean[] changed0, int len0, final boolean[] changed1, int len1) { change script = null; int i0 = len0, i1 = len1; while (i0 >= 0 || i1 >= 0) { if (changed0[i0] || changed1[i1]) { int line0 = i0, line1 = i1; /* Find # lines changed here in each file. */ while (changed0[i0]) --i0; while (changed1[i1]) --i1; /* Record this change. */ script = new change(i0, i1, line0 - i0, line1 - i1, script); } /* We have reached lines in the two files that match each other. */ i0--; i1--; } return script; } } /** Standard ScriptBuilders. */ public final static ScriptBuilder forwardScript = new ForwardScript(), reverseScript = new ReverseScript(); /* Report the differences of two files. DEPTH is the current directory depth. */ public final change diff_2(final boolean reverse) { return diff(reverse ? reverseScript : forwardScript); } /** Get the results of comparison as an edit script. The script is described by a list of changes. The standard ScriptBuilder implementations provide for forward and reverse edit scripts. Alternate implementations could, for instance, list common elements instead of differences. @param bld an object to build the script from change flags @return the head of a list of changes */ public change diff(final ScriptBuilder bld) { /* Some lines are obviously insertions or deletions because they don't match anything. Detect them now, and avoid even thinking about them in the main comparison algorithm. */ discard_confusing_lines(); /* Now do the main comparison algorithm, considering just the undiscarded lines. */ xvec = filevec[0].undiscarded; yvec = filevec[1].undiscarded; int diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3; fdiag = new int[diags]; fdiagoff = filevec[1].nondiscarded_lines + 1; bdiag = new int[diags]; bdiagoff = filevec[1].nondiscarded_lines + 1; compareseq(0, filevec[0].nondiscarded_lines, 0, filevec[1].nondiscarded_lines); fdiag = null; bdiag = null; /* Modify the results slightly to make them prettier in cases where that can validly be done. */ shift_boundaries(); /* Get the results of comparison in the form of a chain of `struct change's -- an edit script. */ return bld.build_script( filevec[0].changed_flag, filevec[0].buffered_lines, filevec[1].changed_flag, filevec[1].buffered_lines ); } /** The result of comparison is an "edit script": a chain of change objects. Each change represents one place where some lines are deleted and some are inserted. LINE0 and LINE1 are the first affected lines in the two files (origin 0). DELETED is the number of lines deleted here from file 0. INSERTED is the number of lines inserted here in file 1. If DELETED is 0 then LINE0 is the number of the line before which the insertion was done; vice versa for INSERTED and LINE1. */ public static class change { /** Previous or next edit command. */ public change link; /** # lines of file 1 changed here. */ public final int inserted; /** # lines of file 0 changed here. */ public final int deleted; /** Line number of 1st deleted line. */ public final int line0; /** Line number of 1st inserted line. */ public final int line1; /** Cons an additional entry onto the front of an edit script OLD. LINE0 and LINE1 are the first affected lines in the two files (origin 0). DELETED is the number of lines deleted here from file 0. INSERTED is the number of lines inserted here in file 1. If DELETED is 0 then LINE0 is the number of the line before which the insertion was done; vice versa for INSERTED and LINE1. */ public change(int line0, int line1, int deleted, int inserted, change old) { this.line0 = line0; this.line1 = line1; this.inserted = inserted; this.deleted = deleted; this.link = old; //System.err.println(line0+","+line1+","+inserted+","+deleted); } } /** Data on one input file being compared. */ class file_data { /** Allocate changed array for the results of comparison. */ void clear() { /* Allocate a flag for each line of each file, saying whether that line is an insertion or deletion. Allocate an extra element, always zero, at each end of each vector. */ changed_flag = new boolean[buffered_lines + 2]; } /** Return equiv_count[I] as the number of lines in this file that fall in equivalence class I. @return the array of equivalence class counts. */ int[] equivCount() { int[] equiv_count = new int[equiv_max]; for (int i = 0; i < buffered_lines; ++i) ++equiv_count[equivs[i]]; return equiv_count; } /** Discard lines that have no matches in another file. A line which is discarded will not be considered by the actual comparison algorithm; it will be as if that line were not in the file. The file's `realindexes' table maps virtual line numbers (which don't count the discarded lines) into real line numbers; this is how the actual comparison algorithm produces results that are comprehensible when the discarded lines are counted. <p> When we discard a line, we also mark it as a deletion or insertion so that it will be printed in the output. @param f the other file */ void discard_confusing_lines(file_data f) { clear(); /* Set up table of which lines are going to be discarded. */ final byte[] discarded = discardable(f.equivCount()); /* Don't really discard the provisional lines except when they occur in a run of discardables, with nonprovisionals at the beginning and end. */ filterDiscards(discarded); /* Actually discard the lines. */ discard(discarded); } /** Mark to be discarded each line that matches no line of another file. If a line matches many lines, mark it as provisionally discardable. @see equivCount() @param counts The count of each equivalence number for the other file. @return 0=nondiscardable, 1=discardable or 2=provisionally discardable for each line */ private byte[] discardable(final int[] counts) { final int end = buffered_lines; final byte[] discards = new byte[end]; final int[] equivs = this.equivs; int many = 5; int tem = end / 64; /* Multiply MANY by approximate square root of number of lines. That is the threshold for provisionally discardable lines. */ while ((tem = tem >> 2) > 0) many *= 2; for (int i = 0; i < end; i++) { int nmatch; if (equivs[i] == 0) continue; nmatch = counts[equivs[i]]; if (nmatch == 0) discards[i] = 1; else if (nmatch > many) discards[i] = 2; } return discards; } /** Don't really discard the provisional lines except when they occur in a run of discardables, with nonprovisionals at the beginning and end. */ private void filterDiscards(final byte[] discards) { final int end = buffered_lines; for (int i = 0; i < end; i++) { /* Cancel provisional discards not in middle of run of discards. */ if (discards[i] == 2) discards[i] = 0; else if (discards[i] != 0) { /* We have found a nonprovisional discard. */ int j; int length; int provisional = 0; /* Find end of this run of discardable lines. Count how many are provisionally discardable. */ for (j = i; j < end; j++) { if (discards[j] == 0) break; if (discards[j] == 2) ++provisional; } /* Cancel provisional discards at end, and shrink the run. */ while (j > i && discards[j - 1] == 2) { discards[--j] = 0; --provisional; } /* Now we have the length of a run of discardable lines whose first and last are not provisional. */ length = j - i; /* If 1/4 of the lines in the run are provisional, cancel discarding of all provisional lines in the run. */ if (provisional * 4 > length) { while (j > i) if (discards[--j] == 2) discards[j] = 0; } else { int consec; int minimum = 1; int tem = length / 4; /* MINIMUM is approximate square root of LENGTH/4. A subrun of two or more provisionals can stand when LENGTH is at least 16. A subrun of 4 or more can stand when LENGTH >= 64. */ while ((tem = tem >> 2) > 0) minimum *= 2; minimum++; /* Cancel any subrun of MINIMUM or more provisionals within the larger run. */ for (j = 0, consec = 0; j < length; j++) if (discards[i + j] != 2) consec = 0; else if (minimum == ++consec) /* Back up to start of subrun, to cancel it all. */ j -= consec; else if (minimum < consec) discards[i + j] = 0; /* Scan from beginning of run until we find 3 or more nonprovisionals in a row or until the first nonprovisional at least 8 lines in. Until that point, cancel any provisionals. */ for (j = 0, consec = 0; j < length; j++) { if (j >= 8 && discards[i + j] == 1) break; if (discards[i + j] == 2) { consec = 0; discards[i + j] = 0; } else if (discards[i + j] == 0) consec = 0; else consec++; if (consec == 3) break; } /* I advances to the last line of the run. */ i += length - 1; /* Same thing, from end. */ for (j = 0, consec = 0; j < length; j++) { if (j >= 8 && discards[i - j] == 1) break; if (discards[i - j] == 2) { consec = 0; discards[i - j] = 0; } else if (discards[i - j] == 0) consec = 0; else consec++; if (consec == 3) break; } } } } } /** Actually discard the lines. @param discards flags lines to be discarded */ private void discard(final byte[] discards) { final int end = buffered_lines; int j = 0; for (int i = 0; i < end; ++i) if (no_discards || discards[i] == 0) { undiscarded[j] = equivs[i]; realindexes[j++] = i; } else changed_flag[1 + i] = true; nondiscarded_lines = j; } file_data(Object[] data, Hashtable h) { buffered_lines = data.length; equivs = new int[buffered_lines]; undiscarded = new int[buffered_lines]; realindexes = new int[buffered_lines]; for (int i = 0; i < data.length; ++i) { Integer ir = (Integer) h.get(data[i]); if (ir == null) h.put(data[i], new Integer(equivs[i] = equiv_max++)); else equivs[i] = ir.intValue(); } } /** Adjust inserts/deletes of blank lines to join changes as much as possible. We do something when a run of changed lines include a blank line at one end and have an excluded blank line at the other. We are free to choose which blank line is included. `compareseq' always chooses the one at the beginning, but usually it is cleaner to consider the following blank line to be the "change". The only exception is if the preceding blank line would join this change to other changes. @param f the file being compared against */ void shift_boundaries(file_data f) { final boolean[] changed = changed_flag; final boolean[] other_changed = f.changed_flag; int i = 0; int j = 0; int i_end = buffered_lines; int preceding = -1; int other_preceding = -1; for (; ;) { int start, end, other_start; /* Scan forwards to find beginning of another run of changes. Also keep track of the corresponding point in the other file. */ while (i < i_end && !changed[1 + i]) { while (other_changed[1 + j++]) /* Non-corresponding lines in the other file will count as the preceding batch of changes. */ other_preceding = j; i++; } if (i == i_end) break; start = i; other_start = j; for (; ;) { /* Now find the end of this run of changes. */ while (i < i_end && changed[1 + i]) i++; end = i; /* If the first changed line matches the following unchanged one, and this run does not follow right after a previous run, and there are no lines deleted from the other file here, then classify the first changed line as unchanged and the following line as changed in its place. */ /* You might ask, how could this run follow right after another? Only because the previous run was shifted here. */ if (end != i_end && equivs[start] == equivs[end] && !other_changed[1 + j] && end != i_end && !((preceding >= 0 && start == preceding) || (other_preceding >= 0 && other_start == other_preceding))) { changed[1 + end++] = true; changed[1 + start++] = false; ++i; /* Since one line-that-matches is now before this run instead of after, we must advance in the other file to keep in synch. */ ++j; } else break; } preceding = i; other_preceding = j; } } /** Number of elements (lines) in this file. */ final int buffered_lines; /** Vector, indexed by line number, containing an equivalence code for each line. It is this vector that is actually compared with that of another file to generate differences. */ private final int[] equivs; /** Vector, like the previous one except that the elements for discarded lines have been squeezed out. */ final int[] undiscarded; /** Vector mapping virtual line numbers (not counting discarded lines) to real ones (counting those lines). Both are origin-0. */ final int[] realindexes; /** Total number of nondiscarded lines. */ int nondiscarded_lines; /** Array, indexed by real origin-1 line number, containing true for a line that is an insertion or a deletion. The results of comparison are stored here. */ boolean[] changed_flag; } } --- NEW FILE: DiffPrint.java --- package org.tcdi.opensource.wiki.util; /* $Log: DiffPrint.java,v $ * Revision 1.4 2003/04/22 01:50:47 stuart * add Unified format diff * * Revision 1.3 2003/04/22 01:00:32 stuart * added context diff format * * Revision 1.2 2000/03/02 16:59:54 stuart * add GPL * */ import java.io.*; import java.util.Vector; import java.util.Date; //import com.objectspace.jgl.predicates.UnaryPredicate; interface UnaryPredicate { boolean execute(Object obj); } /** A simple framework for printing change lists produced by <code>Diff</code>. @see bmsi.util.Diff @author Stuart D. Gathman Copyright (C) 2000 Business Management Systems, Inc. <p> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. <p> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <p> You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ public class DiffPrint { /** A Base class for printing edit scripts produced by Diff. This class divides the change list into "hunks", and calls <code>print_hunk</code> for each hunk. Various utility methods are provided as well. */ public static abstract class Base { protected Base(Object[] a, Object[] b) { outfile = new PrintWriter(new OutputStreamWriter(System.out)); file0 = a; file1 = b; } /** Set to ignore certain kinds of lines when printing an edit script. For example, ignoring blank lines or comments. */ protected UnaryPredicate ignore = null; /** Set to the lines of the files being compared. */ protected Object[] file0, file1; /** Divide SCRIPT into pieces by calling HUNKFUN and print each piece with PRINTFUN. Both functions take one arg, an edit script. PRINTFUN takes a subscript which belongs together (with a null link at the end) and prints it. */ public void print_script(Diff.change script) { Diff.change next = script; while (next != null) { Diff.change t, end; /* Find a set of changes that belong together. */ t = next; end = hunkfun(next); /* Disconnect them from the rest of the changes, making them a hunk, and remember the rest for next iteration. */ next = end.link; end.link = null; //if (DEBUG) // debug_script(t); /* Print this hunk. */ print_hunk(t); /* Reconnect the script so it will all be freed properly. */ end.link = next; } outfile.flush(); } /** Called with the tail of the script and returns the last link that belongs together with the start of the tail. */ protected Diff.change hunkfun(Diff.change hunk) { return hunk; } protected int first0, last0, first1, last1, deletes, inserts; protected PrintWriter outfile; /** Look at a hunk of edit script and report the range of lines in each file that it applies to. HUNK is the start of the hunk, which is a chain of `struct change'. The first and last line numbers of file 0 are stored in *FIRST0 and *LAST0, and likewise for file 1 in *FIRST1 and *LAST1. Note that these are internal line numbers that count from 0. If no lines from file 0 are deleted, then FIRST0 is LAST0+1. Also set *DELETES nonzero if any lines of file 0 are deleted and set *INSERTS nonzero if any lines of file 1 are inserted. If only ignorable lines are inserted or deleted, both are set to 0. */ protected void analyze_hunk(Diff.change hunk) { int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0; int i; Diff.change next; boolean nontrivial = (ignore == null); show_from = show_to = 0; f0 = hunk.line0; f1 = hunk.line1; for (next = hunk; next != null; next = next.link) { l0 = next.line0 + next.deleted - 1; l1 = next.line1 + next.inserted - 1; show_from += next.deleted; show_to += next.inserted; for (i = next.line0; i <= l0 && !nontrivial; i++) if (!ignore.execute(file0[i])) nontrivial = true; for (i = next.line1; i <= l1 && !nontrivial; i++) if (!ignore.execute(file1[i])) nontrivial = true; } first0 = f0; last0 = l0; first1 = f1; last1 = l1; /* If all inserted or deleted lines are ignorable, tell the caller to ignore this hunk. */ if (!nontrivial) show_from = show_to = 0; deletes = show_from; inserts = show_to; } /** Print the script header which identifies the files compared. */ protected void print_header(String filea, String fileb) { } protected abstract void print_hunk(Diff.change hunk); protected void print_1_line(String pre, Object linbuf) { outfile.println(pre + linbuf.toString()); } /** Print a pair of line numbers with SEPCHAR, translated for file FILE. If the two numbers are identical, print just one number. Args A and B are internal line numbers. We print the translated (real) line numbers. */ protected void print_number_range(char sepchar, int a, int b) { /* Note: we can have B < A in the case of a range of no lines. In this case, we should print the line number before the range, which is B. */ if (++b > ++a) outfile.print("" + a + sepchar + b); else outfile.print(b); } public static char change_letter(int inserts, int deletes) { if (inserts == 0) return 'd'; else if (deletes == 0) return 'a'; else return 'c'; } } /** Print a change list in the standard diff format. */ public static class NormalPrint extends Base { public NormalPrint(Object[] a, Object[] b) { super(a, b); } /** Print a hunk of a normal diff. This is a contiguous portion of a complete edit script, describing changes in consecutive lines. */ protected void print_hunk(Diff.change hunk) { /* Determine range of line numbers involved in each file. */ analyze_hunk(hunk); if (deletes == 0 && inserts == 0) return; /* Print out the line number header for this hunk */ print_number_range(',', first0, last0); outfile.print(change_letter(inserts, deletes)); print_number_range(',', first1, last1); outfile.println(); /* Print the lines that the first file has. */ if (deletes != 0) for (int i = first0; i <= last0; i++) print_1_line("< ", file0[i]); if (inserts != 0 && deletes != 0) outfile.println("---"); /* Print the lines that the second file has. */ if (inserts != 0) for (int i = first1; i <= last1; i++) print_1_line("> ", file1[i]); } } /** Prints an edit script in a format suitable for input to <code>ed</code>. The edit script must be generated with the reverse option to be useful as actual <code>ed</code> input. */ public static class EdPrint extends Base { public EdPrint(Object[] a, Object[] b) { super(a, b); } /** Print a hunk of an ed diff */ protected void print_hunk(Diff.change hunk) { /* Determine range of line numbers involved in each file. */ analyze_hunk(hunk); if (deletes == 0 && inserts == 0) return; /* Print out the line number header for this hunk */ print_number_range(',', first0, last0); outfile.println(change_letter(inserts, deletes)); /* Print new/changed lines from second file, if needed */ if (inserts != 0) { boolean inserting = true; for (int i = first1; i <= last1; i++) { /* Resume the insert, if we stopped. */ if (!inserting) outfile.println(i - first1 + first0 + "a"); inserting = true; /* If the file's line is just a dot, it would confuse `ed'. So output it with a double dot, and set the flag LEADING_DOT so that we will output another ed-command later to change the double dot into a single dot. */ if (".".equals(file1[i])) { outfile.println(".."); outfile.println("."); /* Now change that double dot to the desired single dot. */ outfile.println(i - first1 + first0 + 1 + "s/^\\.\\././"); inserting = false; } else /* Line is not `.', so output it unmodified. */ print_1_line("", file1[i]); } /* End insert mode, if we are still in it. */ if (inserting) outfile.println("."); } } } /** Prints an edit script in context diff format. This and its 'unified' variation is used for source code patches. */ public static class ContextPrint extends Base { protected int context = 3; public ContextPrint(Object[] a, Object[] b) { super(a, b); } protected void print_context_label(String mark, File inf, String label) { if (label != null) outfile.println(mark + ' ' + label); else if (inf.lastModified() > 0) // FIXME: use DateFormat to get precise format needed. outfile.println( mark + ' ' + inf.getPath() + '\t' + new Date(inf.lastModified()) ); else /* Don't pretend that standard input is ancient. */ outfile.println(mark + ' ' + inf.getPath()); } public void print_header(String filea, String fileb) { print_context_label("***", new File(filea), filea); print_context_label("---", new File(fileb), fileb); } /** If function_regexp defined, search for start of function. */ private String find_function(Object[] lines, int start) { return null; } protected void print_function(Object[] file, int start) { String function = find_function(file0, first0); if (function != null) { outfile.print(" "); outfile.print( (function.length() < 40) ? function : function.substring(0, 40) ); } } protected void print_hunk(Diff.change hunk) { /* Determine range of line numbers involved in each file. */ analyze_hunk(hunk); if (deletes == 0 && inserts == 0) return; /* Include a context's width before and after. */ first0 = Math.max(first0 - context, 0); first1 = Math.max(first1 - context, 0); last0 = Math.min(last0 + context, file0.length - 1); last1 = Math.min(last1 + context, file1.length - 1); outfile.print("***************"); /* If we looked for and found a function this is part of, include its name in the header of the diff section. */ print_function(file0, first0); outfile.println(); outfile.print("*** "); print_number_range(',', first0, last0); outfile.println(" ****"); if (deletes != 0) { Diff.change next = hunk; for (int i = first0; i <= last0; i++) { /* Skip past changes that apply (in file 0) only to lines before line I. */ while (next != null && next.line0 + next.deleted <= i) next = next.link; /* Compute the marking for line I. */ String prefix = " "; if (next != null && next.line0 <= i) /* The change NEXT covers this line. If lines were inserted here in file 1, this is "changed". Otherwise it is "deleted". */ prefix = (next.inserted > 0) ? "!" : "-"; print_1_line(prefix, file0[i]); } } outfile.print("--- "); print_number_range(',', first1, last1); outfile.println(" ----"); if (inserts != 0) { Diff.change next = hunk; for (int i = first1; i <= last1; i++) { /* Skip past changes that apply (in file 1) only to lines before line I. */ while (next != null && next.line1 + next.inserted <= i) next = next.link; /* Compute the marking for line I. */ String prefix = " "; if (next != null && next.line1 <= i) /* The change NEXT covers this line. If lines were deleted here in file 0, this is "changed". Otherwise it is "inserted". */ prefix = (next.deleted > 0) ? "!" : "+"; print_1_line(prefix, file1[i]); } } } } /** Prints an edit script in context diff format. This and its 'unified' variation is used for source code patches. */ public static class UnifiedPrint extends ContextPrint { public UnifiedPrint(Object[] a, Object[] b) { super(a, b); } public void print_header(String filea, String fileb) { print_context_label("---", new File(filea), filea); print_context_label("+++", new File(fileb), fileb); } private void print_number_range(int a, int b) { //translate_range (file, a, b, &trans_a, &trans_b); /* Note: we can have B < A in the case of a range of no lines. In this case, we should print the line number before the range, which is B. */ if (b < a) outfile.print(b + ",0"); else super.print_number_range(',', a, b); } protected void print_hunk(Diff.change hunk) { /* Determine range of line numbers involved in each file. */ analyze_hunk(hunk); if (deletes == 0 && inserts == 0) return; /* Include a context's width before and after. */ first0 = Math.max(first0 - context, 0); first1 = Math.max(first1 - context, 0); last0 = Math.min(last0 + context, file0.length - 1); last1 = Math.min(last1 + context, file1.length - 1); outfile.print("@@ -"); print_number_range(first0, last0); outfile.print(" +"); print_number_range(first1, last1); outfile.print(" @@"); /* If we looked for and found a function this is part of, include its name in the header of the diff section. */ print_function(file0, first0); outfile.println(); Diff.change next = hunk; int i = first0; int j = first1; while (i <= last0 || j <= last1) { /* If the line isn't a difference, output the context from file 0. */ if (next == null || i < next.line0) { outfile.print(' '); print_1_line("", file0[i++]); j++; } else { /* For each difference, first output the deleted part. */ int k = next.deleted; while (k-- > 0) { outfile.print('-'); print_1_line("", file0[i++]); } /* Then output the inserted part. */ k = next.inserted; while (k-- > 0) { outfile.print('+'); print_1_line("", file1[j++]); } /* We're done with this hunk, so on to the next! */ next = next.link; } } } } /** Read a text file into an array of String. This provides basic diff functionality. A more advanced diff utility will use specialized objects to represent the text lines, with options to, for example, convert sequences of whitespace to a single space for comparison purposes. */ static String[] slurp(String file) throws IOException { BufferedReader rdr = new BufferedReader(new FileReader(file)); Vector s = new Vector(); for (; ;) { String line = rdr.readLine(); if (line == null) break; s.addElement(line); } String[] a = new String[s.size()]; s.copyInto(a); return a; } public static void main(String[] argv) throws IOException { String filea = argv[argv.length - 2]; String fileb = argv[argv.length - 1]; String[] a = slurp(filea); String[] b = slurp(fileb); Diff d = new Diff(a, b); char style = 'n'; for (int i = 0; i < argv.length - 2; ++i) { String f = argv[i]; if (f.startsWith("-")) { for (int j = 1; j < f.length(); ++j) { switch (f.charAt(j)) { case 'e': // Ed style style = 'e'; break; case 'c': // Context diff style = 'c'; break; case 'u': style = 'u'; break; } } } } boolean reverse = style == 'e'; Diff.change script = d.diff_2(reverse); if (script == null) System.err.println("No differences"); else { Base p; switch (style) { case 'e': p = new EdPrint(a, b); break; case 'c': p = new ContextPrint(a, b); break; case 'u': p = new UnifiedPrint(a, b); break; default: p = new NormalPrint(a, b); } p.print_header(filea, fileb); p.print_script(script); } } } |
From: <dr...@us...> - 2003-07-02 06:55:17
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv5523/src/org/tcdi/opensource/wiki/servlet Modified Files: WikiServlet.java Added Files: DiffPageAction.java Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too --- NEW FILE: DiffPageAction.java --- /** * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Wiki. * * The Initial Developer of the Original Code is Technology Concepts * and Design, Inc. * Copyright (C) 2000 Technology Concepts and Design, Inc. All * Rights Reserved. * * Contributor(s): Lane Sharman (OpenDoors Software) * Justin Wells (Semiotek Inc.) * Eric B. Ridge (Technology Concepts and Design, Inc.) * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. * * * This product includes sofware developed by OpenDoors Software. * * This product includes software developed by Justin Wells and Semiotek Inc. * for use in the WebMacro ServletFramework (http://www.webmacro.org). */ package org.tcdi.opensource.wiki.servlet; import org.tcdi.opensource.wiki.*; import org.tcdi.opensource.wiki.renderer.TextPageRenderer; import org.tcdi.opensource.wiki.renderer.WikiPageRenderer; import org.tcdi.opensource.wiki.renderer.TextURLRenderer; import org.tcdi.opensource.wiki.util.Diff; import org.webmacro.servlet.WebContext; import java.util.ArrayList; import java.util.List; import java.util.Iterator; public class DiffPageAction implements PageAction { public static class DiffHelper { private List _changes; public DiffHelper (Diff.change changes) { _changes = new ArrayList(); while (changes != null) { _changes.add (changes); changes = changes.link; } } public List getChanges() { return _changes; } public boolean isModified (int line_no) { for (Iterator itr = _changes.iterator(); itr.hasNext();) { Diff.change ch = (Diff.change) itr.next(); if (line_no < ch.line0+ch.deleted && line_no <= ch.line1 + ch.inserted && line_no >= ch.line0 && line_no >=ch.line1 && ch.deleted > 0 && ch.inserted > 0) return true; } return false; } public boolean isDeleted(int line_no) { if (isModified(line_no)) return false; for (Iterator itr = _changes.iterator(); itr.hasNext();) { Diff.change ch = (Diff.change) itr.next(); if (ch.line0 + ch.deleted > line_no && ch.line0 <= line_no) return true; } return false; } public boolean isInserted(int line_no) { if (isModified(line_no)) return false; for (Iterator itr = _changes.iterator(); itr.hasNext();) { Diff.change ch = (Diff.change) itr.next(); if (line_no >= ch.line1 && line_no < ch.line1 + ch.inserted) return true; } return false; } public int getDeleteCount(int line_no) { if (isModified(line_no)) return 0; for (Iterator itr = _changes.iterator(); itr.hasNext();) { Diff.change ch = (Diff.change) itr.next(); if (line_no == ch.line1) return ch.deleted; } return 0; } public int getInsertCount(int line_no) { if (isModified(line_no)) return 0; for (Iterator itr = _changes.iterator(); itr.hasNext();) { Diff.change ch = (Diff.change) itr.next(); if (line_no == ch.line0) return ch.inserted; } return 0; } } public boolean accept(WikiSystem wiki, WebContext wc, WikiUser user) { return wc.getRequest().getRequestURI().endsWith ("DiffPage"); } public String getWikiPageName(WikiSystem wiki, WebContext wc) { return "DiffPage"; } public void perform(WikiSystem wiki, WebContext wc, WikiUser user, WikiPage page) throws PageAction.PageActionException { try { String current_version = wc.getForm("V1"); String old_version = wc.getForm("V2"); String page_name = wc.getForm("PAGE"); if (page_name == null) return; WikiPage tmp = wiki.getPage(page_name); WikiPage currentPage = wiki.getPage(current_version == null ? page_name : page_name + "." + current_version); if (currentPage == null) return; WikiPage oldPage = wiki.getPage(old_version == null ? page_name + "." + (currentPage.getVersion()-1) : page_name + "." + old_version); if (oldPage == null) oldPage = currentPage; boolean is_current = tmp.getVersion() == currentPage.getVersion(); String[] currentPageLines = WikiUtil.delimitedToArray(currentPage.getUnparsedData(), "\n"); String[] oldPageLines = WikiUtil.delimitedToArray(oldPage.getUnparsedData(), "\n"); Diff diff = new Diff(oldPageLines, currentPageLines); Diff.change changes = diff.diff(Diff.forwardScript); wc.put ("IsCurrent", is_current); wc.put ("CurrentPage", currentPage); wc.put ("OldPage", oldPage); wc.put ("CurrentPageLines", currentPageLines); wc.put ("OldPageLines", oldPageLines); wc.put ("DiffHelper", new DiffHelper (changes)); } catch (Exception e) { e.printStackTrace(); throw new PageAction.PageActionException(e.toString()); } } public String getTemplateName(WikiSystem wiki, WikiPage page) { return wiki.getProperties().getProperty("DiffPageAction.Template"); } } Index: WikiServlet.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet/WikiServlet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WikiServlet.java 2 Jul 2003 03:01:52 -0000 1.4 --- WikiServlet.java 2 Jul 2003 06:55:13 -0000 1.5 *************** *** 71,75 **** /** the PageActionManager we should use for each page request */ private PageActionManager _actionManager; ! /** * do necessary statup work like creating a Log and configuring --- 71,79 ---- /** the PageActionManager we should use for each page request */ private PageActionManager _actionManager; ! ! public WebMacro initWebMacro() throws InitException { ! return super.initWebMacro(); //To change body of overriden methods use Options | File Templates. ! } ! /** * do necessary statup work like creating a Log and configuring |
From: <dr...@us...> - 2003-07-02 06:55:16
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/htdocs In directory sc8-pr-cvs1:/tmp/cvs-serv5523/builds/www.webmacro.org/htdocs Modified Files: site-style.css Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too Index: site-style.css =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/htdocs/site-style.css,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** site-style.css 2 Jul 2003 03:01:51 -0000 1.3 --- site-style.css 2 Jul 2003 06:55:13 -0000 1.4 *************** *** 108,109 **** --- 108,124 ---- BACKGROUND-COLOR: #e5d5e5 } + + .deleted_line { + color: red; + background-color: #ffdede; + } + + .inserted_line { + color: green; + background-color: #deffde; + } + + .modified_line { + color: blue; + background-color: #dedeff; + } \ No newline at end of file |
From: <dr...@us...> - 2003-07-02 06:55:16
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org In directory sc8-pr-cvs1:/tmp/cvs-serv5523/builds/www.webmacro.org Modified Files: resources.jar Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too Index: resources.jar =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/resources.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsBGFtPF and /tmp/cvs8XbqMd differ |
From: <dr...@us...> - 2003-07-02 06:55:16
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/etc In directory sc8-pr-cvs1:/tmp/cvs-serv5523/builds/www.webmacro.org/etc Modified Files: Wiki.properties Added Files: WebMacro.properties Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too --- NEW FILE: WebMacro.properties --- Directives.wiki: org.tcdi.opensource.wiki.directive.WikiDirective Index: Wiki.properties =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/etc/Wiki.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Wiki.properties 2 Jul 2003 03:01:51 -0000 1.4 --- Wiki.properties 2 Jul 2003 06:55:13 -0000 1.5 *************** *** 14,17 **** --- 14,18 ---- org.tcdi.opensource.wiki.servlet.PageTreeAction \ org.tcdi.opensource.wiki.servlet.IndexPageAction \ + org.tcdi.opensource.wiki.servlet.DiffPageAction \ org.tcdi.opensource.wiki.servlet.admin.UpdateUserAction \ org.tcdi.opensource.wiki.servlet.admin.UserListAction \ *************** *** 30,34 **** PageTreeAction.Template: pagetree.wm IndexPageAction.Template: indexpage.wm ! # cookie options --- 31,35 ---- PageTreeAction.Template: pagetree.wm IndexPageAction.Template: indexpage.wm ! DiffPageAction.Template: diff.wm # cookie options |
From: <dr...@us...> - 2003-07-02 06:55:16
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates In directory sc8-pr-cvs1:/tmp/cvs-serv5523/builds/www.webmacro.org/templates Modified Files: footer.wm optionsbar.wm Added Files: diff.wm Log Message: - adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too --- NEW FILE: diff.wm --- #include as template "header.wm" #if (!$DiffHelper) { <form method="GET"> Page Name: <input type='text' name='PAGE'><br> <input type='submit' value='View differences'> </form> } #else { #if ($DiffHelper.Changes.size() == 1) { 1 difference } #else {$DiffHelper.Changes.size() differences } <table border=1 width="100%" cellspacing=1 cellpadding=2> <tr> <th>$OldPage.Title -- v$OldPage.Version</th> <th>$CurrentPage.Title -- v$CurrentPage.Version #if ($IsCurrent) { (Latest Version) }</th> </tr> <tr> <td>Editor: <b>$OldPage.LastEditor</b>; Date: <b>$OldPage.DateLastModified</b></td> <td>Editor: <b>$CurrentPage.LastEditor</b>; Date: <b>$CurrentPage.DateLastModified</b></td> </tr> <tr> <td colspan=2 align=center> <table border=0 width="50%"> <tr><th colspan=3>Legend</th></tr> <tr><td class='deleted_line'>Deleted</td><td class='inserted_line'>Inserted</td></tr> <tr><td class='modified_line'>Modified</td><td></td></tr> </table> </td> <tr> <td valign=top width="50%"> #foreach $line in $OldPageLines indexing $idx from 0 { #count $i from 1 to $DiffHelper.getInsertCount($idx) {<br>} #if($DiffHelper.isModified($idx)){<span class='modified_line'> #wiki{$line}</span><br>} #elseif($DiffHelper.isDeleted($idx)){<span class='deleted_line'> #wiki{$line}</span><br>} #else{<span class='unchanged_line'>#wiki{$line}</span><br>} } </td> <td valign=top width="50%"> #foreach $line in $CurrentPageLines indexing $idx from 0 { #count $i from 1 to $DiffHelper.getDeleteCount($idx) {<br>} #if($DiffHelper.isModified($idx)){<span class='modified_line'> #wiki{$line}</span><br>} #elseif($DiffHelper.isInserted($idx)){<span class='inserted_line'> #wiki{$line}</span><br>} #else{<span class='unchanged_line'>#wiki{$line}</span><br>} } </td> </tr> </table> } #include as template "footer.wm" Index: footer.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/footer.wm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** footer.wm 2 Jul 2003 03:01:52 -0000 1.2 --- footer.wm 2 Jul 2003 06:55:13 -0000 1.3 *************** *** 28,33 **** || <a href="ControllerPage?delete=$Page.Title"><span class="Options">Delete page</span></a> } - - || } } #elseif (!$User) { --- 28,31 ---- *************** *** 37,42 **** #if ($User) { ! <a href="ControllerPage?logout=true"><span class="Options">Log Out</span></a> } </td> --- 35,42 ---- #if ($User) { ! || <a href="ControllerPage?logout=true"><span class="Options">Log Out</span></a> } + + </td> Index: optionsbar.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/optionsbar.wm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** optionsbar.wm 2 Jul 2003 03:01:52 -0000 1.3 --- optionsbar.wm 2 Jul 2003 06:55:13 -0000 1.4 *************** *** 15,18 **** --- 15,20 ---- } + || <a href="DiffPage?PAGE=$Page.Title">Diff to previous version</a> + #if ($User && $Wiki.isAdministrator($User)) { #parse "adminoptionsbar.wm" |
From: <dr...@us...> - 2003-07-02 06:46:50
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/util In directory sc8-pr-cvs1:/tmp/cvs-serv4675a/src/org/tcdi/opensource/wiki/util Log Message: Directory /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/util added to the repository |
From: <dr...@us...> - 2003-07-02 03:05:27
|
Update of /cvsroot/webmacro/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv14910 Added Files: wiki.jar wiki1.iml wiki1.ipr wiki1.iws Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) --- NEW FILE: wiki.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wiki1.iml --- <?xml version="1.0" encoding="UTF-8"?> <module version="4" relativePaths="false"> <component name="LvcsConfiguration"> <option name="LOCAL_VCS_ENABLED" value="false" /> <option name="LOCAL_VCS_PURGING_PERIOD" value="259200000" /> <option name="MARK_EXTERNAL_CHANGES_AS_UP_TO_DATE" value="true" /> </component> <component name="NewModuleRootManager"> <output url="file://$MODULE_DIR$/class" /> <output-test url="file://" /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> </content> <content url="file:///tcdi/wiki/deploy/WEB-INF" /> <orderEntry type="jdk" jdkName="java version "1.3.1" (1)" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/JavaCC2_1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/jsdk23.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/lucene.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/webmacro.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jce1_2_1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jcert.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jnet.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jpda.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jsse.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/local_policy.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/sunjce_provider.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/US_export_policy.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="file:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="file:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/security" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/dt.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Classes/classes.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Classes/i18n.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Classes/sunrsasign.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Classes/ui.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/dt.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jce1_2_1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jcert.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jnet.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jpda.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/jsse.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/local_policy.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/sunjce_provider.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/US_export_policy.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> </component> <component name="ModuleRootManager" /> </module> --- NEW FILE: wiki1.ipr --- <?xml version="1.0" encoding="UTF-8"?> <project version="4" relativePaths="false"> <component name="ProjectRootManager" version="2" assert-keyword="false" /> <component name="CodeStyleManager"> <option name="USE_DEFAULT_CODE_STYLE_SCHEME" value="true" /> <option name="CODE_STYLE_SCHEME" value="" /> </component> <component name="ProjectModuleManager"> <modules> <module filepath="$PROJECT_DIR$/wiki1.iml" /> </modules> </component> <component name="libraryTable" /> <component name="ExportToHTMLSettings"> <option name="PRINT_LINE_NUMBERS" value="false" /> <option name="OPEN_IN_BROWSER" value="false" /> <option name="OUTPUT_DIRECTORY" /> </component> <component name="EntryPointsManager"> <entry_points /> </component> <component name="JavadocGenerationManager"> <option name="OUTPUT_DIRECTORY" /> <option name="OPTION_SCOPE" value="protected" /> <option name="OPTION_HIERARCHY" value="true" /> <option name="OPTION_NAVIGATOR" value="true" /> <option name="OPTION_INDEX" value="true" /> <option name="OPTION_SEPARATE_INDEX" value="true" /> <option name="OPTION_DOCUMENT_TAG_USE" value="false" /> <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" /> <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" /> <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" /> <option name="OPTION_DEPRECATED_LIST" value="true" /> <option name="OTHER_OPTIONS" value="" /> <option name="HEAP_SIZE" /> <option name="OPEN_IN_BROWSER" value="true" /> </component> <component name="AntConfiguration"> <buildFile url="file://$PROJECT_DIR$/build.xml"> <useEmacsModeOutput value="true" /> <useCustomJdk value="false" /> <treeView value="true" /> <useJavaw value="false" /> <verbose value="true" /> <includeProjectClasspath value="false" /> <includeParser value="true" /> <maximumHeapSize value="128" /> <viewClosedWhenNoErrors value="false" /> </buildFile> <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" /> <option name="FILTER_TARGETS" value="false" /> </component> <component name="CompilerConfiguration"> <option name="DEFAULT_COMPILER" value="Javac" /> <option name="SYNCHRONIZE_OUTPUT_DIRECTORY" value="false" /> <option name="myDefaultOutputPath" value="$PROJECT_DIR$/class" /> <option name="OUTPUT_MODE" value="single" /> <resourceExtensions> <entry name=".+\.(properties|xml|html)" /> <entry name=".+\.(gif|png|jpeg|jpg)" /> </resourceExtensions> </component> <component name="JavacSettings"> <option name="DEBUGGING_INFO" value="true" /> <option name="GENERATE_NO_WARNINGS" value="false" /> <option name="DEPRECATION" value="false" /> <option name="ADDITIONAL_OPTIONS_STRING" value="" /> <option name="JAVAC_CLASSES_PATH" value="" /> <option name="MAXIMUM_HEAP_SIZE" value="128" /> <option name="USE_GENERICS_COMPILER" value="false" /> </component> <component name="JikesSettings"> <option name="JIKES_PATH" value="" /> <option name="DEBUGGING_INFO" value="true" /> <option name="DEPRECATION" value="true" /> <option name="GENERATE_NO_WARNINGS" value="false" /> <option name="GENERATE_MAKE_FILE_DEPENDENCIES" value="false" /> <option name="DO_FULL_DEPENDENCE_CHECK" value="false" /> <option name="IS_EMACS_ERRORS_MODE" value="true" /> <option name="ADDITIONAL_OPTIONS_STRING" value="" /> </component> <component name="CheckinPanelState" /> <component name="WebManager"> <option enabled="false" /> </component> <component name="WebRootContainer" /> <component name="EjbManager" enabled="false" /> <component name="DataSourceManager" /> <component name="EjbActionsConfiguration"> <option name="NEW_MESSAGE_BEAN_LAST_PACKAGE" value="" /> <option name="NEW_ENTITY_BEAN_LAST_PACKAGE" value="" /> <option name="NEW_SESSION_BEAN_LAST_PACKAGE" value="" /> </component> <component name="ImportConfiguration"> <option name="VENDOR" /> <option name="RELEASE_TAG" /> <option name="LOG_MESSAGE" /> <option name="CHECKOUT_AFTER_IMPORT" value="true" /> </component> </project> --- NEW FILE: wiki1.iws --- <?xml version="1.0" encoding="UTF-8"?> <project version="4" relativePaths="false"> <component name="PropertiesComponent"> <property name="GoToClass.includeJavaFiles" value="false" /> <property name="MemberChooser.copyJavadoc" value="false" /> <property name="GoToClass.includeLibraries" value="false" /> <property name="MemberChooser.showClasses" value="true" /> <property name="MemberChooser.sorted" value="false" /> <property name="GoToFile.includeJavaFiles" value="false" /> <property name="GoToClass.toSaveIncludeLibraries" value="false" /> </component> <component name="LvcsProjectConfiguration"> <option name="ADD_LABEL_ON_PROJECT_OPEN" value="true" /> <option name="ADD_LABEL_ON_PROJECT_COMPILATION" value="true" /> <option name="ADD_LABEL_ON_FILE_PACKAGE_COMPILATION" value="true" /> <option name="ADD_LABEL_ON_PROJECT_MAKE" value="true" /> <option name="ADD_LABEL_ON_RUNNING" value="true" /> <option name="ADD_LABEL_ON_DEBUGGING" value="true" /> <option name="ADD_LABEL_ON_UNIT_TEST_PASSED" value="true" /> <option name="ADD_LABEL_ON_UNIT_TEST_FAILED" value="true" /> </component> <component name="ToolWindowManager"> <frame x="63" y="22" width="1317" height="1021" extended-state="0" /> <editor active="false" /> <layout> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.2501967" order="1" /> <window_info id="CVS" active="false" anchor="bottom" auto_hide="true" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="2" /> <window_info id="Hierarchy" active="true" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.13217938" order="2" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="sliding" type="sliding" visible="false" weight="0.4" order="0" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.26357198" order="0" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="3" /> <window_info id="App Server" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="1" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="6" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33002207" order="8" /> <window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="2" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="0" /> <window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="4" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="5" /> </layout> </component> <component name="ErrorTreeViewConfiguration"> <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" /> <option name="HIDE_WARNINGS" value="false" /> </component> <component name="StructureViewFactory"> <option name="SORT_MODE" value="0" /> <option name="GROUP_INHERITED" value="true" /> <option name="AUTOSCROLL_MODE" value="true" /> <option name="SHOW_FIELDS" value="true" /> <option name="AUTOSCROLL_FROM_SOURCE" value="false" /> <option name="GROUP_GETTERS_AND_SETTERS" value="true" /> <option name="SHOW_INHERITED" value="false" /> <option name="HIDE_NOT_PUBLIC" value="false" /> </component> <component name="ProjectViewSettings"> <navigator currentView="ProjectPane" flattenPackages="false" showMembers="true" showStructure="false" autoscrollToSource="false" splitterProportion="0.5" /> <view id="ProjectPane"> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin" /> <expanded_node type="directory" url="file://$PROJECT_DIR$" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/etc" /> <expanded_node type="class" url="org.tcdi.opensource.wiki.WikiPage" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds" /> <expanded_node type="directory" url="file:///tcdi/wiki/deploy/WEB-INF" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/templates" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/admin" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet" /> <expanded_node type="directory" url="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki" /> </view> <view id="SourcepathPane" /> <view id="ClasspathPane" /> </component> <component name="Commander"> <leftPanel view="Project" /> <rightPanel view="Project" /> <splitter proportion="0.5" /> </component> <component name="SelectInManager" /> <component name="HierarchyBrowserManager"> <option name="SHOW_PACKAGES" value="false" /> <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" /> <option name="SORT_ALPHABETICALLY" value="false" /> </component> <component name="TodoView" selected-index="0"> <todo-panel id="selected-file"> <are-packages-shown value="false" /> <flatten-packages value="false" /> <is-autoscroll-to-source value="true" /> </todo-panel> <todo-panel id="all"> <are-packages-shown value="true" /> <flatten-packages value="false" /> <is-autoscroll-to-source value="true" /> </todo-panel> </component> <component name="editorManager" selected-file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/WikiServlet.java"> <provider selected="true" editor-type-id="text-editor"> <state line="73" column="0" selection-start="2434" selection-end="2434" vertical-scroll-proportion="0.5255042" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="38" column="6" selection-start="1308" selection-end="1308" vertical-scroll-proportion="0.41162515" horizontal-scroll-proportion="0.06158358"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="12" column="14" selection-start="532" selection-end="532" vertical-scroll-proportion="0.107947804" horizontal-scroll-proportion="0.14369501"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> <state line="30" column="0" selection-start="1358" selection-end="1397" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/FindPagesAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/IndexPageAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/PageTreeAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/AdminAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="30" column="33" selection-start="1115" selection-end="1115" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.34070796"> <folding /> </state> </provider> </entry> </component> <component name="editorHistoryManager"> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UserListAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="30" column="0" selection-start="864" selection-end="999" vertical-scroll-proportion="0.4365362" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/indexpage.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="4" column="48" selection-start="114" selection-end="114" vertical-scroll-proportion="0.07591934" horizontal-scroll-proportion="0.49266863"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/admin/update_user.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="23" column="12" selection-start="1007" selection-end="1007" vertical-scroll-proportion="0.4365362" horizontal-scroll-proportion="0.12316716"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/htdocs/site-style.css"> <provider selected="true" editor-type-id="text-editor"> <state line="78" column="0" selection-start="961" selection-end="961" vertical-scroll-proportion="0.7402135" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/adminoptionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="25" selection-start="25" selection-end="25" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.2539913"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/WikiSystem.java"> <provider selected="true" editor-type-id="text-editor"> <state line="83" column="28" selection-start="2871" selection-end="2871" vertical-scroll-proportion="0.8351127" horizontal-scroll-proportion="0.29923666"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/header.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="38" column="6" selection-start="1308" selection-end="1308" vertical-scroll-proportion="0.41162515" horizontal-scroll-proportion="0.06158358"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/templates/optionsbar.wm"> <provider selected="true" editor-type-id="text-editor"> <state line="12" column="14" selection-start="532" selection-end="532" vertical-scroll-proportion="0.107947804" horizontal-scroll-proportion="0.14369501"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/builds/www.webmacro.org/etc/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file:///tcdi/wiki/deploy/WEB-INF/Wiki.properties"> <provider selected="true" editor-type-id="text-editor"> <state line="30" column="0" selection-start="1358" selection-end="1397" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/FindPagesAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/IndexPageAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/PageTreeAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="40" column="0" selection-start="1763" selection-end="1763" vertical-scroll-proportion="0.75919336" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/AdminAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0"> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/org/tcdi/opensource/wiki/servlet/admin/UpdateUserAction.java"> <provider selected="true" editor-type-id="text-editor"> <state line="30" column="33" selection-start="1115" selection-end="1115" vertical-scroll-proportion="0.569395" horizontal-scroll-proportion="0.34070796"> <folding /> </state> </provider> </entry> </component> <component name="DaemonCodeAnalyzer"> <disable_hints /> </component> <component name="InspectionManager"> <option name="AUTOSCROLL_TO_SOURCE" value="false" /> <option name="SPLITTER_PROPORTION" value="0.5" /> <inspection_tool class="Unused declaration" enabled="false"> <option name="ADD_MAINS_TO_ENTRIES" value="true" /> <option name="ADD_JUNIT_TO_ENTRIES" value="true" /> <option name="ADD_EJB_TO_ENTRIES" value="true" /> <option name="ADD_APPLET_TO_ENTRIES" value="true" /> <option name="ADD_SERVLET_TO_ENTRIES" value="true" /> <option name="ADD_NONJAVA_TO_ENTRIES" value="true" /> </inspection_tool> <inspection_tool class="Declaration access can be weaker" enabled="false"> <option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" /> <option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" /> <option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" /> </inspection_tool> <inspection_tool class="Declaration can have static modifier" enabled="false" /> <inspection_tool class="Declaration can have final modifier" enabled="false"> <option name="REPORT_CLASSES" value="true" /> <option name="REPORT_METHODS" value="true" /> <option name="REPORT_FIELDS" value="true" /> </inspection_tool> <inspection_tool class="Unused method parameters" enabled="false" /> <inspection_tool class="Actual method parameter is the same constant" enabled="false" /> <inspection_tool class="Unused method return value" enabled="false" /> <inspection_tool class="Method returns the same value" enabled="false" /> <inspection_tool class="Empty method" enabled="false" /> <inspection_tool class="Redundant throws clause" enabled="false" /> <inspection_tool class="Constant conditions & exceptions" enabled="false" /> <inspection_tool class="Unused assignment" enabled="false" /> <inspection_tool class="Redundant type cast" enabled="false" /> <inspection_tool class="Local variable or parameter can be final" enabled="false"> <option name="REPORT_VARIABLES" value="true" /> <option name="REPORT_PARAMETERS" value="true" /> </inspection_tool> <inspection_tool class="Declaration has javadoc problems" enabled="false"> <option name="TOP_LEVEL_CLASS_OPTIONS"> <value> <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="public" /> <option name="REQUIRED_TAGS" value="" /> </value> </option> <option name="INNER_CLASS_OPTIONS"> <value> <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected" /> <option name="REQUIRED_TAGS" value="" /> </value> </option> <option name="METHOD_OPTIONS"> <value> <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected" /> <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> </value> </option> <option name="FIELD_OPTIONS"> <value> <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected" /> <option name="REQUIRED_TAGS" value="" /> </value> </option> </inspection_tool> <inspection_tool class="Deprecated API usage" enabled="false" /> <inspection_tool class="equals() and hashCode() not paired" enabled="false" /> </component> <component name="BookmarkManager" /> <component name="DebuggerManager"> <line_breakpoints /> <exception_breakpoints> <breakpoint_any> <option name="NOTIFY_CAUGHT" value="true" /> <option name="NOTIFY_UNCAUGHT" value="true" /> <option name="ENABLED" value="false" /> <option name="SUSPEND_VM" value="true" /> <option name="COUNT_FILTER_ENABLED" value="false" /> <option name="COUNT_FILTER" value="0" /> <option name="CONDITION_ENABLED" value="false" /> <option name="CONDITION" /> <option name="LOG_ENABLED" value="false" /> <option name="LOG_EXPRESSION_ENABLED" value="false" /> <option name="LOG_MESSAGE" /> <option name="CLASS_FILTERS_ENABLED" value="false" /> <option name="INVERSE_CLASS_FILLTERS" value="false" /> <option name="SUSPEND_POLICY" value="SuspendAll" /> </breakpoint_any> </exception_breakpoints> <field_breakpoints /> <method_breakpoints /> </component> <component name="DebuggerSettings"> <option name="TRACING_FILTERS_ENABLED" value="true" /> <option name="TOSTRING_CLASSES_ENABLED" value="false" /> <option name="VALUE_LOOKUP_DELAY" value="700" /> <option name="DEBUGGER_TRANSPORT" value="0" /> <option name="FORCE_CLASSIC_VM" value="true" /> <option name="HIDE_DEBUGGER_ON_PROCESS_TERMINATION" value="false" /> <option name="SKIP_SYNTHETIC_METHODS" value="true" /> <option name="SKIP_CONSTRUCTORS" value="false" /> <option name="STEP_THREAD_SUSPEND_POLICY" value="SuspendThread" /> <option name="EVALUATION_TIMEOUT" value="1000" /> <default_breakpoint_settings> <option name="NOTIFY_CAUGHT" value="true" /> <option name="NOTIFY_UNCAUGHT" value="true" /> <option name="WATCH_MODIFICATION" value="true" /> <option name="WATCH_ACCESS" value="true" /> <option name="WATCH_ENTRY" value="true" /> <option name="WATCH_EXIT" value="true" /> <option name="ENABLED" value="true" /> <option name="SUSPEND_VM" value="true" /> <option name="COUNT_FILTER_ENABLED" value="false" /> <option name="COUNT_FILTER" value="0" /> <option name="CONDITION_ENABLED" value="false" /> <option name="CONDITION" /> <option name="LOG_ENABLED" value="false" /> <option name="LOG_EXPRESSION_ENABLED" value="false" /> <option name="LOG_MESSAGE" /> <option name="CLASS_FILTERS_ENABLED" value="false" /> <option name="INVERSE_CLASS_FILLTERS" value="false" /> <option name="SUSPEND_POLICY" value="SuspendAll" /> </default_breakpoint_settings> <filter> <option name="PATTERN" value="com.sun.*" /> <option name="ENABLED" value="true" /> </filter> <filter> <option name="PATTERN" value="java.*" /> <option name="ENABLED" value="true" /> </filter> <filter> <option name="PATTERN" value="javax.*" /> <option name="ENABLED" value="true" /> </filter> <filter> <option name="PATTERN" value="org.omg.*" /> <option name="ENABLED" value="true" /> </filter> <filter> <option name="PATTERN" value="sun.*" /> <option name="ENABLED" value="true" /> </filter> <filter> <option name="PATTERN" value="junit.*" /> <option name="ENABLED" value="true" /> </filter> </component> <component name="CompilerWorkspaceConfiguration"> <option name="COMPILE_IN_BACKGROUND" value="false" /> <option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true" /> </component> <component name="RunManager"> <option name="SHOW_SETTINGS_BEFORE_RUNNING" value="true" /> <option name="COMPILE_BEFORE_RUNNING" value="true" /> <activeType name="Application" /> <configuration name="<template>" type="Application" default="true" selected="false"> <option name="MAIN_CLASS_NAME" /> <option name="VM_PARAMETERS" /> <option name="PROGRAM_PARAMETERS" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> </configuration> <configuration name="<template>" type="Applet" default="true" selected="false"> <option name="MAIN_CLASS_NAME" /> <option name="HTML_FILE_NAME" /> <option name="HTML_USED" value="false" /> <option name="WIDTH" value="400" /> <option name="HEIGHT" value="300" /> <option name="POLICY_FILE" value="/Applications/IntelliJ-IDEA-3.0.1/bin/appletviewer.policy" /> <option name="VM_PARAMETERS" /> </configuration> <configuration name="<template>" type="JUnit" default="true" selected="false"> <option name="PACKAGE_NAME" /> <option name="MAIN_CLASS_NAME" /> <option name="METHOD_NAME" /> <option name="TEST_OBJECT" /> <option name="VM_PARAMETERS" /> <option name="PARAMETERS" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> <option name="ADDITIONAL_CLASS_PATH" /> </configuration> <configuration name="<template>" type="Remote" default="true" selected="false"> <option name="USE_SOCKET_TRANSPORT" value="true" /> <option name="SERVER_MODE" value="false" /> <option name="SHMEM_ADDRESS" value="javadebug" /> <option name="HOST" value="localhost" /> <option name="PORT" value="5005" /> </configuration> <configuration name="<template>" type="WebApp" default="true" selected="false"> <WebServerIntegration name="" /> <Host>localhost</Host> <Port>5050</Port> <LaunchServer>false</LaunchServer> </configuration> </component> <component name="VcsManagerConfiguration"> <option name="ACTIVE_VCS_NAME" value="CVS" /> </component> <component name="VssConfiguration"> <CheckoutOptions> <option name="COMMENT" value="" /> <option name="DO_NOT_GET_LATEST_VERSION" value="false" /> <option name="REPLACE_WRITABLE" value="false" /> <option name="RECURSIVE" value="false" /> </CheckoutOptions> <CheckinOptions> <option name="COMMENT" value="" /> <option name="KEEP_CHECKED_OUT" value="false" /> <option name="RECURSIVE" value="false" /> </CheckinOptions> <AddOptions> <option name="COMMENT" value="" /> <option name="STORE_ONLY_LATEST_VERSION" value="false" /> <option name="CHECK_OUT_IMMEDIATELY" value="false" /> <option name="FILE_TYPE" value="0" /> </AddOptions> <UndocheckoutOptions> <option name="MAKE_WRITABLE" value="false" /> <option name="REPLACE_LOCAL_COPY" value="0" /> <option name="RECURSIVE" value="false" /> </UndocheckoutOptions> <DiffOptions> <option name="IGNORE_WHITE_SPACE" value="false" /> <option name="IGNORE_CASE" value="false" /> </DiffOptions> <GetOptions> <option name="REPLACE_WRITABLE" value="0" /> <option name="MAKE_WRITABLE" value="false" /> <option name="RECURSIVE" value="false" /> </GetOptions> <option name="CLIENT_PATH" value="" /> <option name="SRCSAFEINI_PATH" value="" /> <option name="USER_NAME" value="" /> <option name="PWD" value="" /> <option name="SHOW_CHECKOUT_OPTIONS" value="true" /> <option name="SHOW_ADD_OPTIONS" value="true" /> <option name="SHOW_UNDOCHECKOUT_OPTIONS" value="true" /> <option name="SHOW_DIFF_OPTIONS" value="true" /> <option name="SHOW_GET_OPTIONS" value="true" /> <option name="USE_EXTERNAL_DIFF" value="false" /> <option name="EXTERNAL_DIFF_PATH" value="" /> <option name="REUSE_LAST_COMMENT" value="false" /> <option name="PUT_FOCUS_INTO_COMMENT" value="false" /> <option name="SHOW_CHECKIN_OPTIONS" value="true" /> <option name="LAST_COMMIT_MESSAGE" value="" /> </component> <component name="WebViewSettings"> <webview flattenPackages="false" showMembers="false" autoscrollToSource="false" /> </component> <component name="EjbViewSettings"> <EjbView showMembers="false" autoscrollToSource="false" /> </component> <component name="EAViewSettings"> <option name="AUTOSCROLL_TO_SOURCE" value="false" /> </component> <component name="AppServerRunManager" /> <component name="StarteamConfiguration"> <option name="SERVER" value="" /> <option name="PORT" value="49201" /> <option name="USER" value="" /> <option name="PASSWORD" value="" /> <option name="PROJECT" value="" /> <option name="VIEW" value="" /> <option name="ALTERNATIVE_WORKING_PATH" value="" /> <option name="PUT_FOCUS_INTO_COMMENT" value="false" /> <option name="SHOW_CHECKIN_OPTIONS" value="true" /> <option name="LAST_COMMIT_MESSAGE" value="" /> </component> </project> |
From: <dr...@us...> - 2003-07-02 03:05:27
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv14910/src/org/tcdi/opensource/wiki Modified Files: Wiki.java WikiSystem.java WikiUtil.java Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: Wiki.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/Wiki.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Wiki.java 27 Nov 2002 06:21:41 -0000 1.8 --- Wiki.java 2 Jul 2003 03:01:52 -0000 1.9 *************** *** 80,83 **** --- 80,84 ---- private volatile String[] _pageNames; private volatile Map _pageLookup; + private List _pageTree; /** the page renderer this Wiki is configured to use */ *************** *** 103,106 **** --- 104,123 ---- } + public String[] getPages(String prefix) { + String[] names = getCurrentPageNames(); + if (prefix == null || prefix.trim().length() == 0) + prefix = "*"; + + prefix = prefix.toLowerCase(); + List l = new ArrayList(); + for (int x=0; x<names.length; x++) { + if (prefix.equals("*") || names[x].toLowerCase().startsWith(prefix)) { + l.add (names[x]); + } + } + + return (String[]) l.toArray(new String[l.size()]); + } + public Enumeration getPageNames() { return _pageStore.keys(); *************** *** 138,141 **** --- 155,162 ---- e.printStackTrace(); } + + synchronized (this) { + _pageTree = null; + } } *************** *** 166,169 **** --- 187,194 ---- _pageStore.remove(title); populatePageNames(); + + synchronized (this) { + _pageTree = null; + } } *************** *** 412,416 **** this.savePage(page); } ! /** * Is the specified String a Wiki page reference? --- 437,441 ---- this.savePage(page); } ! /** * Is the specified String a Wiki page reference? *************** *** 418,423 **** public boolean isWikiTermReference(String word) { char[] chars = word.toCharArray(); ! int ucase = 0, lcase = 0; // does the word end in a backwards tick? if (chars[chars.length - 1] == '`') --- 443,450 ---- public boolean isWikiTermReference(String word) { char[] chars = word.toCharArray(); ! int ucase = 0, lcase = 0; + + // does the word end in a backwards tick? if (chars[chars.length - 1] == '`') *************** *** 453,455 **** --- 480,530 ---- return _properties.getProperty("StartPage").trim(); } + + public synchronized List getPageTree() { + if (_pageTree == null) { + _pageTree = new ArrayList(); + Map lookup = new HashMap(); + String[] pageNames = getCurrentPageNames(); + for (int x=0; x<pageNames.length; x++) { + String name = pageNames[x]; + WikiPage wiki_page = getPage(name); + if (wiki_page == null) + continue; + + if (!lookup.containsKey(name)) { + _pageTree.add (new WikiSystem.PageTreeEntry(wiki_page, 0)); + lookup.put(name, null); + addChildren (_pageTree, lookup, wiki_page, 0); + } + } + lookup.clear(); // no longer needed + } + + return _pageTree; + } + + private void addChildren(List pages, Map lookup, WikiPage root, int depth) { + WikiData[] data = root.getData(); + for (int x=0; x<data.length; x++) { + switch (data[x].getType()) { + case WikiDataTypes.PAGE_REFERENCE: + WikiPage wiki_page = getPage((String) data[x].getData()); + if (wiki_page == null) + continue; + + String name = wiki_page.getTitle(); + if (!lookup.containsKey(name)) { + pages.add (new PageTreeEntry(wiki_page, depth+1)); + lookup.put (name, null); + addChildren (pages, lookup, wiki_page, depth+1); + } + + break; + + default: + break; + } + } + } + } Index: WikiSystem.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiSystem.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WikiSystem.java 27 Nov 2002 06:22:06 -0000 1.4 --- WikiSystem.java 2 Jul 2003 03:01:52 -0000 1.5 *************** *** 52,55 **** --- 52,77 ---- */ public interface WikiSystem extends WikiTermMatcher { + + /** + * Represents a single entry in our Page Tree + */ + public static class PageTreeEntry { + private final WikiPage _page; + private final int _depth; + + public PageTreeEntry (WikiPage page, int depth) { + _page = page; + _depth = depth; + } + + public WikiPage getPage() { + return _page; + } + + public int getDepth() { + return _depth; + } + } + /** * @param title the title of the WikiPage to retrieve. This should be a propertly formed WikiTerm *************** *** 59,62 **** --- 81,92 ---- /** + * Return a list of all page names that begin with the specified string. + * The special string "*" is understood to mean <i>all pages</i>. + * So is <code>null</code> and the empty string. + */ + public String[] getPages(String prefix); + + + /** * return a list of all page names, including names of deleted pages * and old versions of pages. User should take care to filter these *************** *** 228,230 **** --- 258,265 ---- */ public void indexCurrentPages () throws Exception; + + /** + * Returns a tree-like structure ordered by page links. + */ + public List getPageTree(); } Index: WikiUtil.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WikiUtil.java 27 Nov 2002 06:21:41 -0000 1.3 --- WikiUtil.java 2 Jul 2003 03:01:52 -0000 1.4 *************** *** 92,96 **** * takes provided phrase and turns it into a WikiTerm by * .toUpperCase() first letter, and first letter of each word. ! * Strips all non-alpha characters * * @param phrase a phrase to convert to a WikiTerm --- 92,96 ---- * takes provided phrase and turns it into a WikiTerm by * .toUpperCase() first letter, and first letter of each word. ! * Strips all non-alphanumeric characters * * @param phrase a phrase to convert to a WikiTerm *************** *** 108,112 **** chars[x] = Character.toUpperCase(chars[x]); ! if (Character.isLetter(chars[x])) sb.append(chars[x]); } --- 108,112 ---- chars[x] = Character.toUpperCase(chars[x]); ! if (Character.isLetterOrDigit (chars[x])) sb.append(chars[x]); } |
From: <dr...@us...> - 2003-07-02 03:05:27
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org In directory sc8-pr-cvs1:/tmp/cvs-serv14910/builds/www.webmacro.org Added Files: resources.jar Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) --- NEW FILE: resources.jar --- (This appears to be a binary file; contents omitted.) |
From: <dr...@us...> - 2003-07-02 03:05:27
|
Update of /cvsroot/webmacro/wiki/lib In directory sc8-pr-cvs1:/tmp/cvs-serv14910/lib Modified Files: webmacro.jar Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: webmacro.jar =================================================================== RCS file: /cvsroot/webmacro/wiki/lib/webmacro.jar,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsRyNwoH and /tmp/cvsStEQci differ |
From: <dr...@us...> - 2003-07-02 03:05:26
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates In directory sc8-pr-cvs1:/tmp/cvs-serv14910/builds/www.webmacro.org/templates Modified Files: adminoptionsbar.wm delete.wm edit.wm findresults.wm footer.wm header.wm login.wm optionsbar.wm register.wm user_admin.wm view.wm Added Files: indexpage.wm pagetree.wm Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) --- NEW FILE: indexpage.wm --- #include as template "header.wm" <table border=0 width="100%"> <tr> <td class="LeftMenu" valign=top width="120"> #parse "leftmenu.wm" </td> <td width="8"> </td> <td valign=top> #set $prefix=$User.Attribute.LastIndexPageLetter #if ($Form.LETTER) { #set $prefix="$Form.LETTER" } #set $abc = "*ABCDEFGIJKLMNOPQRSTUVWXYZ" #foreach $letter in $abc.toCharArray() indexing $i from 0 { #if ($i>0) { | } #if ($prefix && ("$prefix"=="$letter" || "$prefix"=="" && "$letter"=="*")) { <b>$letter</b> } #else { <a href="$Request.RequestURI?LETTER=$letter">$letter</a> } } #set $pages = $Wiki.getPages($prefix) #set $currentLetter = "" #foreach $page in $pages { #set $firstLetter = "$page.charAt(0)" #if (!$firstLetter.equalsIgnoreCase($currentLetter)) { #set $currentLetter = $firstLetter <p> <table border=0 width="100%" cellspacing=0> <tr><th align=left>$currentLetter</th></tr> </table> } <a href="$page">$page</a><br> } </td> </tr> </table> #include as template "footer.wm" --- NEW FILE: pagetree.wm --- #include as template "header.wm" $PageTree.size() pages <table border=0 cellpadding=3 cellspacing=1 width="100%"> <tr> <th>Page</th> <th>Author</th> <th>Last Modified</th> </tr> <tr> #alternate $bgcolor through ["#efefef", "#ffffff"] #foreach $entry in $PageTree { <tr bgcolor="$bgcolor"> <td nowrap width="100%"> #count $i from 1 to $entry.Depth { } <a href="$entry.Page.Title">$entry.Page.Title</a></td> </td> <td> #set $author = $Wiki.getUser($entry.Page.Author) #if ($author) { $author.Name } </td> <td nowrap>$entry.Page.DateLastModified</td> </tr> } </table> #include as template "footer.wm" Index: adminoptionsbar.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/adminoptionsbar.wm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adminoptionsbar.wm 27 Nov 2002 06:21:41 -0000 1.2 --- adminoptionsbar.wm 2 Jul 2003 03:01:52 -0000 1.3 *************** *** 1,11 **** ! <table border=0 width="100%"> ! <td align=center> ! <a href="AdminUserList"><span class="AdminOptions">User Administration</a></span> ! </td> ! </table> ! ! <table width="100%"> ! <tr> ! <td bgcolor="#000000" height=1></td> ! </tr> ! </table> --- 1 ---- ! || <a href="AdminUserList"><span class="AdminOptions">User Administration</a></span> \ No newline at end of file Index: delete.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/delete.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** delete.wm 15 Oct 2001 06:36:20 -0000 1.1 --- delete.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,3 **** ! #parse "header.wm" <form action="$Request.RequestURI" method="POST"> --- 1,3 ---- ! #include as template "header.wm" <form action="$Request.RequestURI" method="POST"> *************** *** 17,19 **** </form> ! #parse "footer.wm" \ No newline at end of file --- 17,19 ---- </form> ! #include as template "footer.wm" \ No newline at end of file Index: edit.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/edit.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** edit.wm 15 Oct 2001 06:36:20 -0000 1.1 --- edit.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,3 **** ! #parse "header.wm" <form action="$Request.RequestURI" method=POST> --- 1,3 ---- ! #include as template "header.wm" <form action="$Request.RequestURI" method=POST> *************** *** 44,46 **** </form> ! #parse "footer.wm" --- 44,46 ---- </form> ! #include as template "footer.wm" Index: findresults.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/findresults.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** findresults.wm 15 Oct 2001 06:36:20 -0000 1.1 --- findresults.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,9 **** #set $PageName="Find Results" ! #parse "header.wm" <table border=0 width="100%"> <tr> <td class="LeftMenu" valign=top width="120"> ! #parse "leftmenu.wm" </td> --- 1,9 ---- #set $PageName="Find Results" ! #include as template "header.wm" <table border=0 width="100%"> <tr> <td class="LeftMenu" valign=top width="120"> ! #include as template "leftmenu.wm" </td> *************** *** 44,46 **** </table> ! #parse "footer.wm" --- 44,46 ---- </table> ! #include as template "footer.wm" Index: footer.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/footer.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** footer.wm 15 Oct 2001 06:36:20 -0000 1.1 --- footer.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 29,37 **** } ! || <a href="ControllerPage?logout=true"><span class="Options">Log Out</span></a> } } #elseif (!$User) { <a href="?login=true"><span class="Options">Log in</span></a> || <a href="?register=true" class="Options">Register</a> } </td> --- 29,41 ---- } ! || } } #elseif (!$User) { <a href="?login=true"><span class="Options">Log in</span></a> || <a href="?register=true" class="Options">Register</a> + } + + #if ($User) { + <a href="ControllerPage?logout=true"><span class="Options">Log Out</span></a> } </td> Index: header.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/header.wm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** header.wm 7 Feb 2003 15:24:46 -0000 1.2 --- header.wm 2 Jul 2003 03:01:52 -0000 1.3 *************** *** 62,64 **** </table> ! #parse "optionsbar.wm" --- 62,64 ---- </table> ! #include as template "optionsbar.wm" \ No newline at end of file Index: login.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/login.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** login.wm 15 Oct 2001 06:36:20 -0000 1.1 --- login.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,4 **** #set $PageName = "Log In" ! #parse "header.wm" <br> --- 1,4 ---- #set $PageName = "Log In" ! #include as template "header.wm" <br> *************** *** 35,37 **** </form> ! #parse "footer.wm" --- 35,37 ---- </form> ! #include as template "footer.wm" Index: optionsbar.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/optionsbar.wm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** optionsbar.wm 19 Oct 2002 19:56:13 -0000 1.2 --- optionsbar.wm 2 Jul 2003 03:01:52 -0000 1.3 *************** *** 14,17 **** --- 14,21 ---- || <a href="?register=true" class="Options">Register</a> } + + #if ($User && $Wiki.isAdministrator($User)) { + #parse "adminoptionsbar.wm" + } </td> *************** *** 48,53 **** <td bgcolor="#000000" height=1></td> </tr> ! </table> ! #if (($User) && ($Wiki.isAdministrator($User))) { ! #parse "adminoptionsbar.wm" ! } --- 52,54 ---- <td bgcolor="#000000" height=1></td> </tr> ! </table> \ No newline at end of file Index: register.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/register.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** register.wm 15 Oct 2001 06:36:20 -0000 1.1 --- register.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 2,6 **** ## say thank you #set $PageName = "Thank you for registering" ! #parse "header.wm" <table border=0 align=center> --- 2,6 ---- ## say thank you #set $PageName = "Thank you for registering" ! #include as template "header.wm" <table border=0 align=center> *************** *** 22,26 **** #set $PageName = "Register" ! #parse "header.wm" <form action="$Request.RequestURI" method=POST> --- 22,26 ---- #set $PageName = "Register" ! #include as template "header.wm" <form action="$Request.RequestURI" method=POST> *************** *** 84,86 **** } ! #parse "footer.wm" --- 84,86 ---- } ! #include as template "footer.wm" Index: user_admin.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/user_admin.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** user_admin.wm 15 Oct 2001 06:36:20 -0000 1.1 --- user_admin.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,3 **** ! #parse "header.wm" #if ($User) #begin --- 1,3 ---- ! #include as template "header.wm" #if ($User) #begin *************** *** 38,40 **** #end #end ! #parse "footer.wm" \ No newline at end of file --- 38,40 ---- #end #end ! #include as template "footer.wm" \ No newline at end of file Index: view.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/view.wm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** view.wm 15 Oct 2001 06:36:20 -0000 1.1 --- view.wm 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 1,8 **** ! #parse "header.wm" <table border=0 width="100%"> <tr> <td class="LeftMenu" valign=top width="120"> ! #parse "leftmenu.wm" </td> --- 1,8 ---- ! #include as template "header.wm" <table border=0 width="100%"> <tr> <td class="LeftMenu" valign=top width="120"> ! #include as template "leftmenu.wm" </td> *************** *** 22,24 **** </table> ! #parse "footer.wm" --- 22,24 ---- </table> ! #include as template "footer.wm" |
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv14910/src/org/tcdi/opensource/wiki/servlet Modified Files: RecentChangesAction.java WikiServlet.java Added Files: IndexPageAction.java PageTreeAction.java Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) --- NEW FILE: PageTreeAction.java --- /** * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Wiki. * * The Initial Developer of the Original Code is Technology Concepts * and Design, Inc. * Copyright (C) 2000 Technology Concepts and Design, Inc. All * Rights Reserved. * * Contributor(s): Lane Sharman (OpenDoors Software) * Justin Wells (Semiotek Inc.) * Eric B. Ridge (Technology Concepts and Design, Inc.) * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. * * * This product includes sofware developed by OpenDoors Software. * * This product includes software developed by Justin Wells and Semiotek Inc. * for use in the WebMacro ServletFramework (http://www.webmacro.org). */ package org.tcdi.opensource.wiki.servlet; import org.tcdi.opensource.wiki.*; import org.webmacro.servlet.WebContext; public class PageTreeAction implements PageAction { public boolean accept(WikiSystem wiki, WebContext wc, WikiUser user) { return wc.getRequest().getRequestURI().endsWith ("PageTree"); } public String getWikiPageName(WikiSystem wiki, WebContext wc) { return "PageTree"; } public void perform(WikiSystem wiki, WebContext wc, WikiUser user, WikiPage page) throws PageAction.PageActionException { wc.put ("PageTree", wiki.getPageTree()); } public String getTemplateName(WikiSystem wiki, WikiPage page) { return wiki.getProperties().getProperty("PageTreeAction.Template"); } } Index: RecentChangesAction.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet/RecentChangesAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RecentChangesAction.java 22 Nov 2002 04:48:06 -0000 1.3 --- RecentChangesAction.java 2 Jul 2003 03:01:52 -0000 1.4 *************** *** 137,141 **** */ public String getWikiPageName(WikiSystem wiki, WebContext wc) { ! return null; } } --- 137,141 ---- */ public String getWikiPageName(WikiSystem wiki, WebContext wc) { ! return "RecentChanges"; } } Index: WikiServlet.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet/WikiServlet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WikiServlet.java 27 Nov 2002 06:21:41 -0000 1.3 --- WikiServlet.java 2 Jul 2003 03:01:52 -0000 1.4 *************** *** 52,56 **** import org.tcdi.opensource.wiki.*; - import org.tcdi.opensource.util.*; /** --- 52,55 ---- *************** *** 73,77 **** private PageActionManager _actionManager; - /** * do necessary statup work like creating a Log and configuring --- 72,75 ---- *************** *** 133,136 **** --- 131,135 ---- // something bad happened while performing the action // TODO: Handle error and error template ourselves + e.printStackTrace(); throw new HandlerException (e.toString()); } finally { |
From: <dr...@us...> - 2003-07-02 03:05:16
|
Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet/admin In directory sc8-pr-cvs1:/tmp/cvs-serv14910/src/org/tcdi/opensource/wiki/servlet/admin Modified Files: UserListAction.java Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: UserListAction.java =================================================================== RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/servlet/admin/UserListAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UserListAction.java 27 Nov 2002 06:21:42 -0000 1.1 --- UserListAction.java 2 Jul 2003 03:01:52 -0000 1.2 *************** *** 26,30 **** public void perform(WikiSystem wiki, WebContext wc, WikiUser user, WikiPage page) throws PageAction.PageActionException { - // nothing to do here String prefix = wc.getForm("PREFIX"); if (prefix != null) --- 26,29 ---- |
From: <dr...@us...> - 2003-07-02 03:02:00
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/etc In directory sc8-pr-cvs1:/tmp/cvs-serv14910/builds/www.webmacro.org/etc Modified Files: Wiki.properties Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: Wiki.properties =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/etc/Wiki.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Wiki.properties 27 Nov 2002 06:21:41 -0000 1.3 --- Wiki.properties 2 Jul 2003 03:01:51 -0000 1.4 *************** *** 1,3 **** ! Version: WebMacro Wiki, Version 2.0 # whitespace delimited list of allowed actions, in the order --- 1,3 ---- ! Version: WebMacro Wiki, Version 2.1 # whitespace delimited list of allowed actions, in the order *************** *** 12,15 **** --- 12,17 ---- org.tcdi.opensource.wiki.servlet.RegisterNewUserAction \ org.tcdi.opensource.wiki.servlet.RecentChangesAction \ + org.tcdi.opensource.wiki.servlet.PageTreeAction \ + org.tcdi.opensource.wiki.servlet.IndexPageAction \ org.tcdi.opensource.wiki.servlet.admin.UpdateUserAction \ org.tcdi.opensource.wiki.servlet.admin.UserListAction \ *************** *** 26,29 **** --- 28,33 ---- RegisterUserAction.Template: register.wm RecentChangesAction.Template: recentchanges.wm + PageTreeAction.Template: pagetree.wm + IndexPageAction.Template: indexpage.wm |
From: <dr...@us...> - 2003-07-02 03:02:00
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/admin In directory sc8-pr-cvs1:/tmp/cvs-serv14910/builds/www.webmacro.org/templates/admin Modified Files: update_user.wm Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: update_user.wm =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/templates/admin/update_user.wm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** update_user.wm 7 Feb 2003 15:24:46 -0000 1.2 --- update_user.wm 2 Jul 2003 03:01:51 -0000 1.3 *************** *** 13,25 **** <form method='post' action='AdminUpdateUser'> <input type='hidden' name='user' value='$UserToUpdate.Identifier'> ! Username: <b>$UserToUpdate.Identifier</b><br> ! Name: <input type='text' name='name' value='$Text.HTMLEncode($UserToUpdate.Name)' size=45><br> ! Password: <input type='password' name='password' value=''><br> ! email: <input type='text' name='email' value='$Text.HTMLEncode($UserToUpdate.Attributes.email)' size=45><br> ! is moderator? <input type='checkbox' name='moderator' value='true' #if($UserToUpdate.IsModerator){ checked}><p> ! All Attributes:<br> #foreach $attribute in $UserToUpdate.Attributes.entrySet() { ! $attribute.Key = $attribute.Value<br> } <input type=button value='Back to User List' onClick='top.location.href="AdminUserList";'> --- 13,32 ---- <form method='post' action='AdminUpdateUser'> <input type='hidden' name='user' value='$UserToUpdate.Identifier'> ! <table border=0 cellpadding=0> ! <tr><td>Username:</td><td><b>$UserToUpdate.Identifier</b></td></tr> ! <tr><td>Name:</td><td><input type='text' name='name' value='$Text.HTMLEncode($UserToUpdate.Name)' size=45></td></tr> ! <tr><td>Password:</td><td><input type='password' name='password' value=''></td></tr> ! <tr><td>email:</td><td><input type='text' name='email' value='$Text.HTMLEncode($UserToUpdate.Attributes.email)' size=45></td></tr> ! <tr><td colspan=2>is moderator? <input type='checkbox' name='moderator' value='true' #if($UserToUpdate.IsModerator){ checked}></td></tr> ! </table> ! <p> ! ! User Attributes:<br> ! <table border=0> ! <tr><th>Key</th><th>Value</th> #foreach $attribute in $UserToUpdate.Attributes.entrySet() { ! <tr><td>$attribute.Key</td><td>$attribute.Value</td></tr> } + </table> <input type=button value='Back to User List' onClick='top.location.href="AdminUserList";'> |
From: <dr...@us...> - 2003-07-02 03:02:00
|
Update of /cvsroot/webmacro/wiki/builds/www.webmacro.org/htdocs In directory sc8-pr-cvs1:/tmp/cvs-serv14910/builds/www.webmacro.org/htdocs Modified Files: site-style.css Log Message: - fix bug where page names with numbers were not accessible (reported by Keats) - cleanup user admin screens - add a "PageTree" page that displays a tree (based on links) of all pages in the site - add a "IndexPage" page that displays a simple index of all pages, group by first letter (suggested by Christian) - update webmacro.jar to whatever we have in CVS as of today (living dangerously!) Index: site-style.css =================================================================== RCS file: /cvsroot/webmacro/wiki/builds/www.webmacro.org/htdocs/site-style.css,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** site-style.css 27 Nov 2002 06:21:41 -0000 1.2 --- site-style.css 2 Jul 2003 03:01:51 -0000 1.3 *************** *** 77,81 **** { FONT-SIZE: 8pt; - COLOR: red } .NavigationLinks --- 77,80 ---- |
From: <dr...@us...> - 2003-06-12 00:50:18
|
Update of /cvsroot/webmacro/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv8769 Added Files: WebMacro-CodeStyle-IDEA305.xml Log Message: And here it is, the WebMacro code style to be used with IDEA 3.0.5 (or better?). --- NEW FILE: WebMacro-CodeStyle-IDEA305.xml --- <?xml version="1.0" encoding="UTF-8"?> <code_scheme name="WebMacro" parent="Default"> <option name="BRACE_STYLE" value="2" /> <option name="CLASS_BRACE_STYLE" value="2" /> <option name="METHOD_BRACE_STYLE" value="2" /> <option name="ELSE_ON_NEW_LINE" value="true" /> <option name="CATCH_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="BLANK_LINES_AROUND_METHOD" value="2" /> <option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" /> <option name="FIELD_NAME_PREFIX" value="_" /> </code_scheme> |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/engine In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/engine Modified Files: Argument.java Block.java BlockBuilder.java BuildContext.java BuildException.java Builder.java ConstantPropertyVariable.java CrankyEvaluationExceptionHandler.java DebugEvaluationExceptionHandler.java DefaultEvaluationExceptionHandler.java EncodeFilter.java EscapeFilter.java EvaluationExceptionHandler.java Expression.java FileTemplate.java FilterManager.java FunctionCall.java FunctionCallBuilder.java FunctionVariable.java GlobalVariable.java IntrospectionException.java IntrospectionUtils.java ListBuilder.java MacroAdapter.java MacroBuildContext.java MacroBuilder.java MacroDefinition.java MacroPropertyVariable.java MapBuilder.java MethodWrapper.java NullBuilder.java NullParser.java ParamBuilder.java ParseException.java Parser.java ParserProvider.java PropertyMethodBuilder.java PropertyOperatorCache.java PropertyVariable.java QuotedStringBuilder.java SilenceFilter.java SimplePropertyVariable.java StaticClassWrapper.java StreamTemplate.java StringMacroAdapter.java StringTemplate.java TemplateDumper.java TestObject.java TextParser.java UndefinedMacro.java Variable.java VariableBuilder.java VoidMacro.java WMTemplate.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: Argument.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/Argument.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Argument.java 11 Jun 2002 17:43:21 -0000 1.6 --- Argument.java 12 Jun 2003 00:47:45 -0000 1.7 *************** *** 31,71 **** * term. */ ! public final class Argument { ! private String _name; ! private Object _value; ! /** ! * Create a new predicate ! */ ! public Argument(String name, Object value) { ! _name = name; ! _value = value; ! } ! /** ! * Return the action code for this predicate ! */ ! final public String getName() { ! return _name; ! } ! /** ! * Return the object on which this predicate operates ! */ ! final public Object getValue() { ! return _value; ! } ! /** ! * Make sure that _value is not a builder! Not a public method, ! * used by Directivebuilder and other things that build Argument ! * lists. ! */ ! final void build(BuildContext bc) throws BuildException { ! if (_value instanceof Builder) { ! _value = ((Builder) _value).build(bc); ! } ! } } --- 31,77 ---- * term. */ ! public final class Argument ! { ! private String _name; ! private Object _value; ! /** ! * Create a new predicate ! */ ! public Argument (String name, Object value) ! { ! _name = name; ! _value = value; ! } ! /** ! * Return the action code for this predicate ! */ ! final public String getName () ! { ! return _name; ! } ! /** ! * Return the object on which this predicate operates ! */ ! final public Object getValue () ! { ! return _value; ! } ! /** ! * Make sure that _value is not a builder! Not a public method, ! * used by Directivebuilder and other things that build Argument ! * lists. ! */ ! final void build (BuildContext bc) throws BuildException ! { ! if (_value instanceof Builder) ! { ! _value = ((Builder) _value).build(bc); ! } ! } } Index: Block.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/Block.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Block.java 18 Dec 2002 06:21:41 -0000 1.23 --- Block.java 12 Jun 2003 00:47:45 -0000 1.24 *************** *** 24,90 **** package org.webmacro.engine; - import java.io.*; - import java.util.*; - import org.webmacro.*; import org.webmacro.util.Encoder; /** * A Block is essentially a Macro[] that knows how to write itself * out as a String. */ ! final public class Block implements Macro, Visitable { ! private final String[] _strings; ! private final Macro[] _macros; ! private final int[] _lineNos, _colNos; ! private final Encoder.Block _block; ! private final int _length; ! private final int _remainder; ! private String _name; ! /** ! * A Block must be constructed from a BlockBuilder. The format ! * of a block is: String (Macro String)* ! * and the constructor expects to receive two arrays matching ! * this structure. The output of the block will be the first ! * string, followed by the first macro, followed by the second ! * string, followed by the second macro, etc., and terminated ! * by the final string. ! */ ! protected Block(String name, String[] strings, Macro[] macros, ! int lineNos[], int colNos[]) { ! _name = name; ! _strings = strings; ! _macros = macros; ! _lineNos = lineNos; ! _colNos = colNos; ! _length = _macros.length; ! _remainder = 10 - _length % 10; ! // we'll use this to encode our strings for output to the user ! _block = new Encoder.Block(_strings); ! } ! /** ! * Interpret the directive and write it out, using the values in ! * the supplied context as appropriate. ! * <p> ! * @exception PropertyException if required data was missing from context ! * @exception IOException if we could not successfully write to out ! */ ! final public void write(final FastWriter out, final Context context) ! throws PropertyException, IOException { ! final byte[][] bcontent = out.getEncoder().encode(_block); ! byte[] b; ! Context.TemplateEvaluationContext teC = context.getTemplateEvaluationContext(); ! String oldName = teC._templateName; ! teC._templateName = _name; ! int i = 0; ! switch (_remainder) { ! case 1: b = bcontent[i]; out.write(b, 0, b.length); --- 24,151 ---- package org.webmacro.engine; import org.webmacro.*; import org.webmacro.util.Encoder; + import java.io.IOException; + import java.util.List; + /** * A Block is essentially a Macro[] that knows how to write itself * out as a String. */ ! final public class Block implements Macro, Visitable ! { ! private final String[] _strings; ! private final Macro[] _macros; ! private final int[] _lineNos, _colNos; ! private final Encoder.Block _block; ! private final int _length; ! private final int _remainder; ! private String _name; ! /** ! * A Block must be constructed from a BlockBuilder. The format ! * of a block is: String (Macro String)* ! * and the constructor expects to receive two arrays matching ! * this structure. The output of the block will be the first ! * string, followed by the first macro, followed by the second ! * string, followed by the second macro, etc., and terminated ! * by the final string. ! */ ! protected Block (String name, String[] strings, Macro[] macros, ! int lineNos[], int colNos[]) ! { ! _name = name; ! _strings = strings; ! _macros = macros; ! _lineNos = lineNos; ! _colNos = colNos; ! _length = _macros.length; ! _remainder = 10 - _length % 10; ! // we'll use this to encode our strings for output to the user ! _block = new Encoder.Block(_strings); ! } ! /** ! * Interpret the directive and write it out, using the values in ! * the supplied context as appropriate. ! * <p> ! * @exception PropertyException if required data was missing from context ! * @exception IOException if we could not successfully write to out ! */ ! final public void write (final FastWriter out, final Context context) ! throws PropertyException, IOException ! { ! final byte[][] bcontent = out.getEncoder().encode(_block); ! byte[] b; ! Context.TemplateEvaluationContext teC = context.getTemplateEvaluationContext(); ! String oldName = teC._templateName; ! teC._templateName = _name; ! int i = 0; ! switch (_remainder) ! { ! case 1: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 2: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 3: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 4: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 5: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 6: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 7: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 8: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! case 9: ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! } ! ! while (i < _length) ! { b = bcontent[i]; out.write(b, 0, b.length); *************** *** 92,96 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 2: b = bcontent[i]; out.write(b, 0, b.length); --- 153,156 ---- *************** *** 98,102 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 3: b = bcontent[i]; out.write(b, 0, b.length); --- 158,161 ---- *************** *** 104,108 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 4: b = bcontent[i]; out.write(b, 0, b.length); --- 163,166 ---- *************** *** 110,114 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 5: b = bcontent[i]; out.write(b, 0, b.length); --- 168,171 ---- *************** *** 116,120 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 6: b = bcontent[i]; out.write(b, 0, b.length); --- 173,176 ---- *************** *** 122,126 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 7: b = bcontent[i]; out.write(b, 0, b.length); --- 178,181 ---- *************** *** 128,132 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 8: b = bcontent[i]; out.write(b, 0, b.length); --- 183,186 ---- *************** *** 134,138 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); - case 9: b = bcontent[i]; out.write(b, 0, b.length); --- 188,191 ---- *************** *** 140,308 **** teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); ! } ! ! while (i < _length) { ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! } ! b = bcontent[_length]; ! out.write(b, 0, b.length); ! teC._templateName = oldName; ! } ! public String getTemplateName() { ! return _name; ! } ! public void setTemplateName(String name) { ! _name = name; ! } ! public int getLineNo(int i) { ! return (_lineNos != null && i>=0 && _lineNos.length > i) ? _lineNos[i] : 0; ! } ! public int getColNo(int i) { ! return (_colNos != null && i>=0 && _colNos.length > i) ? _colNos[i] : 0; ! } ! private static class BlockIterator implements BlockBuilder.BlockIterator { ! private int i = 0; ! private boolean doneString = false, done = false; ! private String[] strings; ! private Macro[] macros; ! private Block block; ! public BlockIterator(String[] strings, Macro[] macros, Block b) { ! this.strings = strings; ! this.macros = macros; ! this.block = b; ! } ! public boolean hasNext() { ! return !done; ! } ! public String getName() { ! return block.getTemplateName(); ! } ! public int getLineNo() { ! return block.getLineNo(i - 1); ! } ! public int getColNo() { ! return block.getColNo(i - 1); ! } ! public void remove() { ! throw new UnsupportedOperationException(); ! } ! public Object next() { ! if (doneString) { ! doneString = false; ! return macros[i++]; ! } ! else { ! if (i == strings.length - 1) ! done = true; ! doneString = true; ! return strings[i]; ! } ! } ! } ! public BlockBuilder.BlockIterator getBlockIterator() { ! return new BlockIterator(_strings, _macros, this); ! } ! final void appendTo(List l) { ! final int len = _macros.length; ! for (int i = 0; i < _macros.length; i++) { ! l.add(_strings[i]); ! l.add(_macros[i]); ! } ! l.add(_strings[len]); ! } ! final public void accept(TemplateVisitor v) { ! v.beginBlock(); ! final int len = _macros.length; ! for (int i = 0; i < len; i++) { ! v.visitString(_strings[i]); ! v.visitMacro(_macros[i]); ! } ! v.visitString(_strings[len]); ! v.endBlock(); ! } ! /** ! * same as out but returns a String ! * <p> ! * @exception PropertyException if required data was missing from context ! */ ! final public Object evaluate(Context context) throws PropertyException { ! try { ! FastWriter fw = FastWriter.getInstance(context.getBroker()); ! write(fw, context); ! String ret = fw.toString(); ! fw.close(); ! return ret; ! } ! catch (IOException e) { ! context.getBroker().getLog("engine", "parsing and template execution").error("StringWriter threw an IOException!", e); ! return null; ! } ! } } --- 193,335 ---- teC._columnNo = this.getColNo(i); _macros[i++].write(out, context); ! b = bcontent[i]; ! out.write(b, 0, b.length); ! teC._lineNo = this.getLineNo(i); ! teC._columnNo = this.getColNo(i); ! _macros[i++].write(out, context); ! } ! b = bcontent[_length]; ! out.write(b, 0, b.length); ! teC._templateName = oldName; ! } ! public String getTemplateName () ! { ! return _name; ! } ! public void setTemplateName (String name) ! { ! _name = name; ! } ! public int getLineNo (int i) ! { ! return (_lineNos != null && i >= 0 && _lineNos.length > i) ? _lineNos[i] : 0; ! } ! public int getColNo (int i) ! { ! return (_colNos != null && i >= 0 && _colNos.length > i) ? _colNos[i] : 0; ! } ! private static class BlockIterator implements BlockBuilder.BlockIterator ! { ! private int i = 0; ! private boolean doneString = false, done = false; ! private String[] strings; ! private Macro[] macros; ! private Block block; ! public BlockIterator (String[] strings, Macro[] macros, Block b) ! { ! this.strings = strings; ! this.macros = macros; ! this.block = b; ! } ! public boolean hasNext () ! { ! return !done; ! } ! public String getName () ! { ! return block.getTemplateName(); ! } ! public int getLineNo () ! { ! return block.getLineNo(i - 1); ! } ! public int getColNo () ! { ! return block.getColNo(i - 1); ! } ! public void remove () ! { ! throw new UnsupportedOperationException(); ! } ! public Object next () ! { ! if (doneString) ! { ! doneString = false; ! return macros[i++]; ! } ! else ! { ! if (i == strings.length - 1) ! done = true; ! doneString = true; ! return strings[i]; ! } ! } ! } ! public BlockBuilder.BlockIterator getBlockIterator () ! { ! return new BlockIterator(_strings, _macros, this); ! } ! final void appendTo (List l) ! { ! final int len = _macros.length; ! for (int i = 0; i < _macros.length; i++) ! { ! l.add(_strings[i]); ! l.add(_macros[i]); ! } ! l.add(_strings[len]); ! } ! final public void accept (TemplateVisitor v) ! { ! v.beginBlock(); ! final int len = _macros.length; ! for (int i = 0; i < len; i++) ! { ! v.visitString(_strings[i]); ! v.visitMacro(_macros[i]); ! } ! v.visitString(_strings[len]); ! v.endBlock(); ! } ! /** ! * same as out but returns a String ! * <p> ! * @exception PropertyException if required data was missing from context ! */ ! final public Object evaluate (Context context) throws PropertyException ! { ! try ! { ! FastWriter fw = FastWriter.getInstance(context.getBroker()); ! write(fw, context); ! String ret = fw.toString(); ! fw.close(); ! return ret; ! } ! catch (IOException e) ! { ! context.getBroker().getLog("engine", "parsing and template execution").error("StringWriter threw an IOException!", e); ! return null; ! } ! } } Index: BlockBuilder.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/BlockBuilder.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** BlockBuilder.java 17 Dec 2002 06:01:28 -0000 1.18 --- BlockBuilder.java 12 Jun 2003 00:47:45 -0000 1.19 *************** *** 24,31 **** package org.webmacro.engine; - import java.util.*; - - import org.webmacro.Macro; import org.webmacro.Context; /** --- 24,33 ---- package org.webmacro.engine; import org.webmacro.Context; + import org.webmacro.Macro; + + import java.util.ArrayList; + import java.util.Iterator; + import java.util.Stack; /** *************** *** 35,218 **** * all of the other directives, strings, etc. that can be in a template. */ ! public class BlockBuilder implements Builder { ! ! private static final int INITIAL_SIZE = 64; ! private static Macro[] mArray = new Macro[0]; ! private static String[] sArray = new String[0]; ! private ArrayList elements = new ArrayList(); ! private int[] lineNos = new int[INITIAL_SIZE]; ! private int[] colNos = new int[INITIAL_SIZE]; ! private String name = "unknown"; ! public BlockBuilder() { ! } ! public BlockBuilder(String name) { ! this.name = name; ! } ! public interface BlockIterator extends Iterator { ! public String getName(); ! public int getLineNo(); ! public int getColNo(); ! } ! public class BBIterator implements BlockIterator { ! private int size, i; ! public BBIterator() { ! size = elements.size(); ! i = 0; ! } ! public String getName() { ! return name; ! } ! public boolean hasNext() { ! return (i < size); ! } ! public Object next() { ! return elements.get(i++); ! } ! public int getLineNo() { ! return lineNos[i - 1]; ! } ! public int getColNo() { ! return colNos[i - 1]; ! } ! public void remove() { ! throw new UnsupportedOperationException(); ! } ! } ! final public Object build(BuildContext bc) throws BuildException { ! ArrayList strings = new ArrayList((elements.size())); ! ArrayList macros = new ArrayList((elements.size())); ! int[] ln = new int[elements.size()]; ! int[] cn = new int[elements.size()]; ! Stack iterStack = new Stack(); ! StringBuffer s = new StringBuffer(); ! Context.TemplateEvaluationContext tec = bc.getTemplateEvaluationContext(); ! // flatten everything and view the content as being: ! // string (macro string)* string ! // store that as an array of strings and an array of ! // Macro objects and create a block. ! BlockIterator iter = new BBIterator(); ! while (iter.hasNext()) { ! Object o = iter.next(); ! if (o instanceof Builder) { ! // track line/column numbers in the build context ! // so that bc.getCurrentLocation() stays current ! tec._templateName = iter.getName(); ! tec._lineNo = iter.getLineNo(); ! tec._columnNo = iter.getColNo(); ! try { ! o = ((Builder) o).build(bc); ! } catch (BuildException be) { ! // restore line/column info to what it was before ! // we tried to build the block ! tec._templateName = iter.getName(); ! tec._lineNo = iter.getLineNo(); ! tec._columnNo = iter.getColNo(); ! // and rethrow the exception ! throw be; ! } ! } ! if (o instanceof Block) { ! iterStack.push(iter); ! iter = ((Block) o).getBlockIterator(); ! } ! else { ! if (o instanceof Macro) { ! strings.add(s.toString()); ! s = new StringBuffer(); ! // do not reuse StringBuffer, ! // otherwise all strings will contain char[] of max length!! ! macros.add(o); ! // Now deal with the line numbers ! int size = macros.size(); ! if (ln.length < size) { ! ln = resizeIntArray(ln, ln.length * 2); ! cn = resizeIntArray(cn, cn.length * 2); ! } ! ln[size - 1] = iter.getLineNo(); ! cn[size - 1] = iter.getColNo(); } ! else if (o != null) { ! s.append(o.toString()); } ! } ! while (!iter.hasNext() && !iterStack.empty()) ! iter = (BlockIterator) iterStack.pop(); ! } ! strings.add(s.toString()); ! Macro finalMacros[] = (Macro[]) macros.toArray(mArray); ! String finalStrings[] = (String[]) strings.toArray(sArray); ! int finalLines[] = resizeIntArray(ln, macros.size()); ! int finalCols[] = resizeIntArray(cn, macros.size()); ! return new Block(name, finalStrings, finalMacros, finalLines, finalCols); ! } ! private static int[] resizeIntArray(int[] ia, int size) { ! int[] temp = new int[size]; ! System.arraycopy(ia, 0, temp, 0, Math.min(ia.length, size)); ! return temp; ! } ! // Methods that look like Vector methods ! public void addElement(Object o) { ! elements.add(o); ! } ! public void addElement(Object o, int lineNo, int colNo) { ! elements.add(o); ! int size = elements.size(); ! if (lineNos.length < size) { ! lineNos = resizeIntArray(lineNos, Math.max(lineNos.length * 2, ! size + INITIAL_SIZE)); ! colNos = resizeIntArray(colNos, Math.max(colNos.length * 2, ! size + INITIAL_SIZE)); ! } ! lineNos[size - 1] = lineNo; ! colNos[size - 1] = colNo; ! } ! public int size() { ! return elements.size(); ! } ! public void remove(int i) { ! elements.remove(i); ! } ! public Object elementAt(int i) { ! return elements.get(i); ! } ! public Object setElementAt(Object o, int i) { ! return elements.set(i, o); ! } } --- 37,251 ---- * all of the other directives, strings, etc. that can be in a template. */ ! public class BlockBuilder implements Builder ! { ! private static final int INITIAL_SIZE = 64; ! private static Macro[] mArray = new Macro[0]; ! private static String[] sArray = new String[0]; ! private ArrayList elements = new ArrayList(); ! private int[] lineNos = new int[INITIAL_SIZE]; ! private int[] colNos = new int[INITIAL_SIZE]; ! private String name = "unknown"; ! public BlockBuilder () ! { ! } ! public BlockBuilder (String name) ! { ! this.name = name; ! } ! public interface BlockIterator extends Iterator ! { ! public String getName (); ! public int getLineNo (); ! public int getColNo (); ! } ! public class BBIterator implements BlockIterator ! { ! private int size, i; ! public BBIterator () ! { ! size = elements.size(); ! i = 0; ! } ! public String getName () ! { ! return name; ! } ! public boolean hasNext () ! { ! return (i < size); ! } ! public Object next () ! { ! return elements.get(i++); ! } ! public int getLineNo () ! { ! return lineNos[i - 1]; ! } ! public int getColNo () ! { ! return colNos[i - 1]; ! } ! public void remove () ! { ! throw new UnsupportedOperationException(); ! } ! } ! final public Object build (BuildContext bc) throws BuildException ! { ! ArrayList strings = new ArrayList((elements.size())); ! ArrayList macros = new ArrayList((elements.size())); ! int[] ln = new int[elements.size()]; ! int[] cn = new int[elements.size()]; ! Stack iterStack = new Stack(); ! StringBuffer s = new StringBuffer(); ! Context.TemplateEvaluationContext tec = bc.getTemplateEvaluationContext(); ! // flatten everything and view the content as being: ! // string (macro string)* string ! // store that as an array of strings and an array of ! // Macro objects and create a block. ! BlockIterator iter = new BBIterator(); ! while (iter.hasNext()) ! { ! Object o = iter.next(); ! if (o instanceof Builder) ! { ! // track line/column numbers in the build context ! // so that bc.getCurrentLocation() stays current ! tec._templateName = iter.getName(); ! tec._lineNo = iter.getLineNo(); ! tec._columnNo = iter.getColNo(); ! try ! { ! o = ((Builder) o).build(bc); ! } ! catch (BuildException be) ! { ! // restore line/column info to what it was before ! // we tried to build the block ! tec._templateName = iter.getName(); ! tec._lineNo = iter.getLineNo(); ! tec._columnNo = iter.getColNo(); ! // and rethrow the exception ! throw be; ! } ! } ! if (o instanceof Block) ! { ! iterStack.push(iter); ! iter = ((Block) o).getBlockIterator(); } ! else ! { ! if (o instanceof Macro) ! { ! strings.add(s.toString()); ! s = new StringBuffer(); ! // do not reuse StringBuffer, ! // otherwise all strings will contain char[] of max length!! ! macros.add(o); ! ! // Now deal with the line numbers ! int size = macros.size(); ! if (ln.length < size) ! { ! ln = resizeIntArray(ln, ln.length * 2); ! cn = resizeIntArray(cn, cn.length * 2); ! } ! ln[size - 1] = iter.getLineNo(); ! cn[size - 1] = iter.getColNo(); ! } ! else if (o != null) ! { ! s.append(o.toString()); ! } } ! while (!iter.hasNext() && !iterStack.empty()) ! iter = (BlockIterator) iterStack.pop(); ! } ! strings.add(s.toString()); ! Macro finalMacros[] = (Macro[]) macros.toArray(mArray); ! String finalStrings[] = (String[]) strings.toArray(sArray); ! int finalLines[] = resizeIntArray(ln, macros.size()); ! int finalCols[] = resizeIntArray(cn, macros.size()); ! return new Block(name, finalStrings, finalMacros, finalLines, finalCols); ! } ! private static int[] resizeIntArray (int[] ia, int size) ! { ! int[] temp = new int[size]; ! System.arraycopy(ia, 0, temp, 0, Math.min(ia.length, size)); ! return temp; ! } ! // Methods that look like Vector methods ! public void addElement (Object o) ! { ! elements.add(o); ! } ! public void addElement (Object o, int lineNo, int colNo) ! { ! elements.add(o); ! int size = elements.size(); ! if (lineNos.length < size) ! { ! lineNos = resizeIntArray(lineNos, Math.max(lineNos.length * 2, ! size + INITIAL_SIZE)); ! colNos = resizeIntArray(colNos, Math.max(colNos.length * 2, ! size + INITIAL_SIZE)); ! } ! lineNos[size - 1] = lineNo; ! colNos[size - 1] = colNo; ! } ! public int size () ! { ! return elements.size(); ! } ! public void remove (int i) ! { ! elements.remove(i); ! } ! public Object elementAt (int i) ! { ! return elements.get(i); ! } ! public Object setElementAt (Object o, int i) ! { ! return elements.set(i, o); ! } } Index: BuildContext.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/BuildContext.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** BuildContext.java 21 May 2003 23:01:46 -0000 1.25 --- BuildContext.java 12 Jun 2003 00:47:45 -0000 1.26 *************** *** 24,31 **** package org.webmacro.engine; - import java.util.*; - import org.webmacro.*; /** --- 24,32 ---- package org.webmacro.engine; import org.webmacro.*; + import java.util.HashMap; + import java.util.Map; + /** *************** *** 39,207 **** * your keys, to avoid conflicting with keys inserted by someone else. */ ! public class BuildContext extends Context { ! private final Map _types = new HashMap(); ! private final Map _macros = new HashMap(); ! private final FilterManager _filters = new FilterManager(); ! public BuildContext(Broker b) { ! super(b, false); ! } ! public final Parser getParser(String pname) ! throws NotFoundException { ! try { ! return (Parser) getBroker().get("parser", pname); ! } ! catch (NotFoundException e) { ! throw e; ! } ! catch (ResourceException e) { ! throw new NotFoundException(e.toString(), e); ! } ! } ! /** ! * Find out whether the named variable is a tool, local variable, ! * or property variable. ! */ ! public Object getVariableType(String name) { ! Object ret = _types.get(name); ! return (ret == null) ? Variable.PROPERTY_TYPE : ret; ! } ! /** ! * Declare whether the named variable is to be treated as a tool, ! * local variable, or property variable type. ! */ ! public void setVariableType(String name, Object type) { ! if (name == null) { ! return; ! } ! if (type == null) { ! _types.remove(name); ! } ! else { ! _types.put(name, type); ! } ! } ! /** ! * Register a new filter, adding it to the chain for the supplied name. ! * The name is either a top level property name or * to mean "all". ! * @param var the top level property name that is being filtered ! * @param ft the Filter which will handle this property ! */ ! public void addFilter(Variable var, Filter ft) { ! _filters.addFilter(var, ft); ! } ! /** ! * Clear all the filtered for the supplied name. Cleaing * clears ! * only global filters, leaving filters for specific properties. ! */ ! public void clearFilters(Variable var) { ! _filters.clearFilters(var); ! } ! /** ! * Get the filter that applies to a specific variable. Returning ! * null from this method means that the entire variable should ! * be dropped from the output since it's been filtered to null. ! * @return the Macro to be used to filter it, or null ! */ ! public Macro getFilterMacro(Variable v) { ! return _filters.getMacro(v); ! } ! /** ! * Add a MacroDefinition to the build context ! */ ! public void putMacro(String name, MacroDefinition macro) { ! _macros.put(name, macro); ! } ! /** ! * Search for a MacroDefinition in the build context ! */ ! public MacroDefinition getMacro(String name) { ! return (MacroDefinition) _macros.get(name); ! } ! /** ! * Add #macros and #params from the specified Template to ! * this bulid context ! */ ! public void mergeConstants(Template t) { ! Map macros = t.getMacros(); ! Map params = t.getParameters(); ! if (macros != null) ! _macros.putAll(macros); ! if (params != null) ! super.putAll(params); ! } ! /** ! * Return the map of MacroDefinitions ! */ ! public Map getMacros() { ! return _macros; ! } ! /** ! * Create a variable (or resolve a constant at build time) ! * Used by various build() routines ! */ ! Object resolveVariableReference(Object names[], boolean filtered) ! throws BuildException { ! Object v = null; ! if (names.length < 1) ! throw new BuildException("Variable with name of length zero!"); ! Object c[] = new Object[names.length]; ! for (int i = 0; i < c.length; i++) { ! c[i] = (names[i] instanceof Builder) ? ! ((Builder) names[i]).build(this) : names[i]; ! } ! String firstName = c[0].toString(); ! Object type = null; ! if (c[0] instanceof FunctionCall){ ! type = FunctionVariable.TYPE; ! } ! else { ! type = getVariableType(firstName); ! } ! if (type == Variable.PROPERTY_TYPE) { ! if (containsKey(firstName)) { ! Object expansion = get(firstName); ! if (expansion instanceof Macro) { ! v = (c.length == 1) ? expansion ! : new MacroPropertyVariable((Macro) expansion, c); } ! else { ! v = (c.length == 1) ? expansion ! : new ConstantPropertyVariable(expansion, c); } ! } ! else { ! v = (c.length == 1) ! ? (Object) new SimplePropertyVariable(c) ! : (Object) new PropertyVariable(c); ! } ! } ! else if (type == Variable.LOCAL_TYPE) { ! v = new GlobalVariable(c); ! } ! else if (type == FunctionVariable.TYPE) { ! v = new FunctionVariable(c); ! } ! else { ! throw new BuildException("Unrecognized Variable Type: " + type); ! } ! return (filtered && v instanceof Variable) ! ? getFilterMacro((Variable) v) : v; ! } } --- 40,238 ---- * your keys, to avoid conflicting with keys inserted by someone else. */ ! public class BuildContext extends Context ! { ! private final Map _types = new HashMap(); ! private final Map _macros = new HashMap(); ! private final FilterManager _filters = new FilterManager(); ! public BuildContext (Broker b) ! { ! super(b, false); ! } ! public final Parser getParser (String pname) ! throws NotFoundException ! { ! try ! { ! return (Parser) getBroker().get("parser", pname); ! } ! catch (NotFoundException e) ! { ! throw e; ! } ! catch (ResourceException e) ! { ! throw new NotFoundException(e.toString(), e); ! } ! } ! /** ! * Find out whether the named variable is a tool, local variable, ! * or property variable. ! */ ! public Object getVariableType (String name) ! { ! Object ret = _types.get(name); ! return (ret == null) ? Variable.PROPERTY_TYPE : ret; ! } ! /** ! * Declare whether the named variable is to be treated as a tool, ! * local variable, or property variable type. ! */ ! public void setVariableType (String name, Object type) ! { ! if (name == null) ! { ! return; ! } ! if (type == null) ! { ! _types.remove(name); ! } ! else ! { ! _types.put(name, type); ! } ! } ! /** ! * Register a new filter, adding it to the chain for the supplied name. ! * The name is either a top level property name or * to mean "all". ! * @param var the top level property name that is being filtered ! * @param ft the Filter which will handle this property ! */ ! public void addFilter (Variable var, Filter ft) ! { ! _filters.addFilter(var, ft); ! } ! /** ! * Clear all the filtered for the supplied name. Cleaing * clears ! * only global filters, leaving filters for specific properties. ! */ ! public void clearFilters (Variable var) ! { ! _filters.clearFilters(var); ! } ! /** ! * Get the filter that applies to a specific variable. Returning ! * null from this method means that the entire variable should ! * be dropped from the output since it's been filtered to null. ! * @return the Macro to be used to filter it, or null ! */ ! public Macro getFilterMacro (Variable v) ! { ! return _filters.getMacro(v); ! } ! /** ! * Add a MacroDefinition to the build context ! */ ! public void putMacro (String name, MacroDefinition macro) ! { ! _macros.put(name, macro); ! } ! /** ! * Search for a MacroDefinition in the build context ! */ ! public MacroDefinition getMacro (String name) ! { ! return (MacroDefinition) _macros.get(name); ! } ! /** ! * Add #macros and #params from the specified Template to ! * this bulid context ! */ ! public void mergeConstants (Template t) ! { ! Map macros = t.getMacros(); ! Map params = t.getParameters(); ! if (macros != null) ! _macros.putAll(macros); ! if (params != null) ! super.putAll(params); ! } ! /** ! * Return the map of MacroDefinitions ! */ ! public Map getMacros () ! { ! return _macros; ! } ! /** ! * Create a variable (or resolve a constant at build time) ! * Used by various build() routines ! */ ! Object resolveVariableReference (Object names[], boolean filtered) ! throws BuildException ! { ! Object v = null; ! if (names.length < 1) ! throw new BuildException("Variable with name of length zero!"); ! Object c[] = new Object[names.length]; ! for (int i = 0; i < c.length; i++) ! { ! c[i] = (names[i] instanceof Builder) ? ! ((Builder) names[i]).build(this) : names[i]; ! } ! String firstName = c[0].toString(); ! Object type = null; ! if (c[0] instanceof FunctionCall) ! { ! type = FunctionVariable.TYPE; ! } ! else ! { ! type = getVariableType(firstName); ! } ! if (type == Variable.PROPERTY_TYPE) ! { ! if (containsKey(firstName)) ! { ! Object expansion = get(firstName); ! if (expansion instanceof Macro) ! { ! v = (c.length == 1) ? expansion ! : new MacroPropertyVariable((Macro) expansion, c); ! } ! else ! { ! v = (c.length == 1) ? expansion ! : new ConstantPropertyVariable(expansion, c); ! } } ! else ! { ! v = (c.length == 1) ! ? (Object) new SimplePropertyVariable(c) ! : (Object) new PropertyVariable(c); } ! } ! else if (type == Variable.LOCAL_TYPE) ! { ! v = new GlobalVariable(c); ! } ! else if (type == FunctionVariable.TYPE) ! { ! v = new FunctionVariable(c); ! } ! else ! { ! throw new BuildException("Unrecognized Variable Type: " + type); ! } ! return (filtered && v instanceof Variable) ! ? getFilterMacro((Variable) v) : v; ! } } Index: BuildException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/BuildException.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BuildException.java 11 Jun 2002 17:43:21 -0000 1.5 --- BuildException.java 12 Jun 2003 00:47:45 -0000 1.6 *************** *** 26,38 **** import org.webmacro.TemplateException; ! public class BuildException extends TemplateException { ! public BuildException(String message) { ! super(message); ! } ! public BuildException(String reason, Throwable e) { ! super(reason, e); ! } } --- 26,41 ---- import org.webmacro.TemplateException; ! public class BuildException extends TemplateException ! { ! public BuildException (String message) ! { ! super(message); ! } ! public BuildException (String reason, Throwable e) ! { ! super(reason, e); ! } } Index: Builder.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/Builder.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Builder.java 11 Jun 2002 17:43:21 -0000 1.4 --- Builder.java 12 Jun 2003 00:47:45 -0000 1.5 *************** *** 25,32 **** ! public interface Builder { ! public Object build(BuildContext pc) ! throws BuildException; } --- 25,33 ---- ! public interface Builder ! { ! public Object build (BuildContext pc) ! throws BuildException; } Index: ConstantPropertyVariable.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/ConstantPropertyVariable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConstantPropertyVariable.java 11 Jun 2002 17:43:21 -0000 1.2 --- ConstantPropertyVariable.java 12 Jun 2003 00:47:45 -0000 1.3 *************** *** 33,79 **** * @since 1.1 */ ! public class ConstantPropertyVariable extends Variable { ! private Object value; ! /** ! * No special initialization ! */ ! ConstantPropertyVariable(Object value, Object names[]) { ! super(names); ! this.value = value; ! } ! /** ! * Look up my value in the corresponding Map, possibly using introspection, ! * and return it ! * @exception PropertyException If the property does not exist ! */ ! public final Object getValue(Context context) ! throws PropertyException { ! if (value == null) ! throw new PropertyException.NullValueException(_names[0].toString()); ! else ! return context.getBroker() ! ._propertyOperators.getProperty(context, value, _names, 1); ! } ! /** ! * Look up my the value of this variable in the specified Map, possibly ! * using introspection, and set it to the supplied value. ! * @exception PropertyException If the property does not exist ! */ ! public final void setValue(Context context, Object newValue) ! throws PropertyException { ! throw new PropertyException("Cannot set properties of a constant"); ! } ! /** ! * Return a string representation naming the variable for ! * debugging purposes. ! */ ! public final String toString() { ! return "constant-property:" + _vname; ! } } --- 33,84 ---- * @since 1.1 */ ! public class ConstantPropertyVariable extends Variable ! { ! private Object value; ! /** ! * No special initialization ! */ ! ConstantPropertyVariable (Object value, Object names[]) ! { ! super(names); ! this.value = value; ! } ! /** ! * Look up my value in the corresponding Map, possibly using introspection, ! * and return it ! * @exception PropertyException If the property does not exist ! */ ! public final Object getValue (Context context) ! throws PropertyException ! { ! if (value == null) ! throw new PropertyException.NullValueException(_names[0].toString()); ! else ! return context.getBroker() ! ._propertyOperators.getProperty(context, value, _names, 1); ! } ! /** ! * Look up my the value of this variable in the specified Map, possibly ! * using introspection, and set it to the supplied value. ! * @exception PropertyException If the property does not exist ! */ ! public final void setValue (Context context, Object newValue) ! throws PropertyException ! { ! throw new PropertyException("Cannot set properties of a constant"); ! } ! /** ! * Return a string representation naming the variable for ! * debugging purposes. ! */ ! public final String toString () ! { ! return "constant-property:" + _vname; ! } } Index: CrankyEvaluationExceptionHandler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/CrankyEvaluationExceptionHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CrankyEvaluationExceptionHandler.java 11 Jun 2002 17:43:21 -0000 1.7 --- CrankyEvaluationExceptionHandler.java 12 Jun 2003 00:47:45 -0000 1.8 *************** *** 41,121 **** */ ! public class CrankyEvaluationExceptionHandler implements EvaluationExceptionHandler { ! private Log _log; ! public CrankyEvaluationExceptionHandler() { ! } ! public CrankyEvaluationExceptionHandler(Broker b) { ! init(b, b.getSettings()); ! } ! public void init(Broker b, Settings config) { ! _log = b.getLog("engine"); ! } ! public void evaluate(Variable variable, Context context, Exception problem) ! throws PropertyException { ! // if it's a PropertyException set the current context location ! if (problem instanceof PropertyException) { ! ((PropertyException) problem) ! .setContextLocation(context.getCurrentLocation()); ! } ! else { ! // else, wrap it ! problem = new PropertyException("Error evaluating $" ! + variable.getVariableName(), ! problem, ! context.getCurrentLocation()); ! } ! // log it ! if (_log != null) ! _log.warning("Error evaluating $" + variable.getVariableName(), problem); ! // and rethrow it ! throw (PropertyException) problem; ! } ! public String expand(Variable variable, Context context, Exception problem) ! throws PropertyException { ! // if it's a PropertyException set the current context location ! if (problem instanceof PropertyException) { ! ((PropertyException) problem) ! .setContextLocation(context.getCurrentLocation()); ! } ! else { ! // else, wrap it ! problem = new PropertyException("Error expanding $" ! + variable.getVariableName(), ! problem, ! context.getCurrentLocation()); ! } ! // log it ! if (_log != null) ! _log.warning("Error expanding $" + variable.getVariableName(), problem); ! // and rethrow it ! throw (PropertyException) problem; ! } ! public String warningString(String warningText) throws PropertyException { ! throw new PropertyException("Evaluation warning: " + warningText); ! } ! public String errorString(String errorText) throws PropertyException { ! throw new PropertyException("Evaluation error: " + errorText); ! } } --- 41,133 ---- */ ! public class CrankyEvaluationExceptionHandler implements EvaluationExceptionHandler ! { ! private Log _log; ! public CrankyEvaluationExceptionHandler () ! { ! } ! public CrankyEvaluationExceptionHandler (Broker b) ! { ! init(b, b.getSettings()); ! } ! public void init (Broker b, Settings config) ! { ! _log = b.getLog("engine"); ! } ! public void evaluate (Variable variable, Context context, Exception problem) ! throws PropertyException ! { ! // if it's a PropertyException set the current context location ! if (problem instanceof PropertyException) ! { ! ((PropertyException) problem) ! .setContextLocation(context.getCurrentLocation()); ! } ! else ! { ! // else, wrap it ! problem = new PropertyException("Error evaluating $" ! + variable.getVariableName(), ! problem, ! context.getCurrentLocation()); ! } ! // log it ! if (_log != null) ! _log.warning("Error evaluating $" + variable.getVariableName(), problem); ! // and rethrow it ! throw (PropertyException) problem; ! } ! public String expand (Variable variable, Context context, Exception problem) ! throws PropertyException ! { ! // if it's a PropertyException set the current context location ! if (problem instanceof PropertyException) ! { ! ((PropertyException) problem) ! .setContextLocation(context.getCurrentLocation()); ! } ! else ! { ! // else, wrap it ! problem = new PropertyException("Error expanding $" ! + variable.getVariableName(), ! problem, ! context.getCurrentLocation()); ! } ! // log it ! if (_log != null) ! _log.warning("Error expanding $" + variable.getVariableName(), problem); ! // and rethrow it ! throw (PropertyException) problem; ! } ! public String warningString (String warningText) throws PropertyException ! { ! throw new PropertyException("Evaluation warning: " + warningText); ! } ! public String errorString (String errorText) throws PropertyException ! { ! throw new PropertyException("Evaluation error: " + errorText); ! } } Index: DebugEvaluationExceptionHandler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/DebugEvaluationExceptionHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DebugEvaluationExceptionHandler.java 11 Nov 2002 19:22:37 -0000 1.7 --- DebugEvaluationExceptionHandler.java 12 Jun 2003 00:47:45 -0000 1.8 *************** *** 62,67 **** package org.webmacro.engine; - import java.util.*; - import org.webmacro.Broker; import org.webmacro.Context; --- 62,65 ---- *************** *** 70,144 **** import org.webmacro.util.Settings; ! public class DebugEvaluationExceptionHandler implements EvaluationExceptionHandler { ! private Log _log; ! public DebugEvaluationExceptionHandler() { ! } ! public DebugEvaluationExceptionHandler(Broker b) { ! init(b, b.getSettings()); ! } ! public void init(Broker b, Settings config) { ! _log = b.getLog("engine"); ! } ! public void evaluate(Variable variable, Context context, Exception problem) throws PropertyException { ! handleError(variable, context, problem); ! } ! public String expand(Variable variable, Context context, Exception problem) throws PropertyException { ! return handleError(variable, context, problem); ! } - private String handleError(Variable variable, Context context, Exception problem) throws PropertyException { - String strError; ! ArrayList arlErrors = null; ! PropertyException propEx = null; ! if ( problem instanceof PropertyException ) { ! propEx = (PropertyException) problem; ! } ! else { ! propEx = new PropertyException("Error expanding $" + variable.getVariableName() ); ! } ! propEx.setContextLocation(context.getCurrentLocation()); ! strError = propEx.getMessage(); ! if ( ( context.containsKey( "WMERROR" ) ) && ( context.get( "WMERROR" ) instanceof ArrayList ) ) { ! arlErrors = (ArrayList) context.get("WMERROR"); ! } ! else { ! arlErrors = new ArrayList(); ! context.put("WMERROR", arlErrors); ! } ! if ( strError.lastIndexOf( "\r\n" ) >= 0 ) { ! strError = strError.substring( strError.lastIndexOf( "\r\n" ) ); ! strError = strError.trim(); ! } ! if ( !arlErrors.contains( strError ) ) { ! arlErrors.add(strError); ! } ! if (_log != null) { ! _log.warning(strError, propEx); ! } ! // and rethrow it ! throw propEx; ! } ! public String warningString(String strText) throws PropertyException { ! throw new PropertyException("Evaluation warning: " + strText); ! } ! public String errorString(String strText) throws PropertyException { ! throw new PropertyException("Evaluation error: " + strText); ! } } --- 68,160 ---- import org.webmacro.util.Settings; ! import java.util.ArrayList; ! public class DebugEvaluationExceptionHandler implements EvaluationExceptionHandler ! { ! private Log _log; ! public DebugEvaluationExceptionHandler () ! { ! } ! public DebugEvaluationExceptionHandler (Broker b) ! { ! init(b, b.getSettings()); ! ... [truncated message content] |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/servlet Modified Files: CGITool.java CGI_Impersonator.java ConfigException.java CookieJar.java CookieTool.java ErrorHandler.java Form.java FormList.java FormListTool.java FormTool.java Handler.java HandlerException.java ListTool.java ListUtil.java LocaleTool.java MathTool.java RequestTool.java ResponseTool.java Servlet20Broker.java Servlet22Broker.java ServletBroker.java ServletLog.java SessionTool.java TemplateTool.java TextTool.java TypeTool.java URLTool.java VariableTool.java WMServlet.java WebContext.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: CGITool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CGITool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CGITool.java 11 Jun 2002 17:43:22 -0000 1.9 --- CGITool.java 12 Jun 2003 00:47:47 -0000 1.10 *************** *** 32,51 **** * script variable names. */ ! public class CGITool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! CGI_Impersonator cgi = new CGI_Impersonator(wc); ! return cgi; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "CGITool only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 32,56 ---- * script variable names. */ ! public class CGITool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! CGI_Impersonator cgi = new CGI_Impersonator(wc); ! return cgi; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "CGITool only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: CGI_Impersonator.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CGI_Impersonator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CGI_Impersonator.java 11 Jun 2002 17:43:22 -0000 1.5 --- CGI_Impersonator.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 24,29 **** package org.webmacro.servlet; ! import javax.servlet.*; ! import javax.servlet.http.*; --- 24,29 ---- package org.webmacro.servlet; ! import javax.servlet.ServletContext; ! import javax.servlet.http.HttpServletRequest; *************** *** 38,201 **** * familiar to CGI programmers. eg: REQUEST_METHOD, PATH_INFO, etc. */ ! final public class CGI_Impersonator { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest requst_; ! final ServletContext sc_; ! /** ! * Use the supplied HttpServletRequest to produce the results ! * below. Really this class just forwards methods to this sub ! * object in order to provide a familiar interface to CGI programmers. ! */ ! CGI_Impersonator(WebContext wc) { ! requst_ = wc.getRequest(); ! // this is not very nice, but I don't see any other ! // possibility to get the servlet context. We should ! // provide a method in WebContext to hide this from our users. ! sc_ = ((ServletBroker) wc.getBroker()).getServletContext(); ! } ! /** ! * Return the name of the server ! */ ! final public String getSERVER_NAME() { ! return requst_.getServerName(); ! } ! /** ! * Return the server info ! */ ! final public String getSERVER_SOFTWARE() { ! return sc_.getServerInfo(); ! } ! /** ! * Return the server protocol ! */ ! final public String getSERVER_PROTOCOL() { ! return requst_.getProtocol(); ! } ! /** ! * Return the server port ! */ ! final public Integer getSERVER_PORT() { ! return new Integer(requst_.getServerPort()); ! } ! /** ! * Return what type of REQUEST this was: GET, POST, etc. ! */ ! final public String getREQUEST_METHOD() { ! return requst_.getMethod(); ! } ! /** ! * What portion of the URL appeared as additional path beyond ! * the SCRIPT_NAME portion? Return that as a string. ! */ ! final public String getPATH_INFO() { ! return requst_.getPathInfo(); ! } ! /** ! * Same as PATH_INFO but translated to a real path ! */ ! final public String getPATH_TRANSLATED() { ! return requst_.getPathTranslated(); ! } ! /** ! * What portion of the URL represented the servlet being run? ! * Return that as a string. ! */ ! final public String getSCRIPT_NAME() { ! return requst_.getServletPath(); ! } ! /** ! * What is the root of documents served by this servlet ! * ! * WARNING: the method called (getRealPath) is deprecated in Servlet 2.2 ! * ! */ ! final public String getDOCUMENT_ROOT() { ! return sc_.getRealPath("/"); ! } ! /** ! * In a GET request, return the query string that was submitted, if any ! */ ! final public String getQUERY_STRING() { ! return requst_.getQueryString(); ! } ! /** ! * Return the remote host connected to this request ! */ ! final public String getREMOTE_HOST() { ! return requst_.getRemoteHost(); ! } ! /** ! * Return the remove address connected to this servlet ! */ ! final public String getREMOTE_ADDR() { ! return requst_.getRemoteAddr(); ! } ! /** ! * Type of authorization for this request ! */ ! final public String getAUTH_TYPE() { ! return requst_.getAuthType(); ! } ! /** ! * Name of the remote user if it was supplied with the HTTP request ! */ ! final public String getREMOTE_USER() { ! return requst_.getRemoteUser(); ! } ! /** ! * Get the content type submitted to this request ! */ ! final public String getCONTENT_TYPE() { ! return requst_.getContentType(); ! } ! /** ! * Get the content length submitted to this request ! */ ! final public Integer getCONTENT_LENGTH() { ! return new Integer(requst_.getContentLength()); ! } ! /** ! * What type of data is accepted by the client ! */ ! final public String getHTTP_ACCEPT() { ! return requst_.getHeader("Accept"); ! } ! /** ! * Get the user agent (browser) connected to this request ! */ ! final public String getHTTP_USER_AGENT() { ! return requst_.getHeader("User-Agent"); ! } ! /** ! * Get the URL that the request claims to have visited prior to this one ! */ ! final public String getHTTP_REFERER() { ! return requst_.getHeader("Referer"); ! } } --- 38,222 ---- * familiar to CGI programmers. eg: REQUEST_METHOD, PATH_INFO, etc. */ ! final public class CGI_Impersonator ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest requst_; ! final ServletContext sc_; ! /** ! * Use the supplied HttpServletRequest to produce the results ! * below. Really this class just forwards methods to this sub ! * object in order to provide a familiar interface to CGI programmers. ! */ ! CGI_Impersonator (WebContext wc) ! { ! requst_ = wc.getRequest(); ! // this is not very nice, but I don't see any other ! // possibility to get the servlet context. We should ! // provide a method in WebContext to hide this from our users. ! sc_ = ((ServletBroker) wc.getBroker()).getServletContext(); ! } ! /** ! * Return the name of the server ! */ ! final public String getSERVER_NAME () ! { ! return requst_.getServerName(); ! } ! /** ! * Return the server info ! */ ! final public String getSERVER_SOFTWARE () ! { ! return sc_.getServerInfo(); ! } ! /** ! * Return the server protocol ! */ ! final public String getSERVER_PROTOCOL () ! { ! return requst_.getProtocol(); ! } ! /** ! * Return the server port ! */ ! final public Integer getSERVER_PORT () ! { ! return new Integer(requst_.getServerPort()); ! } ! /** ! * Return what type of REQUEST this was: GET, POST, etc. ! */ ! final public String getREQUEST_METHOD () ! { ! return requst_.getMethod(); ! } ! /** ! * What portion of the URL appeared as additional path beyond ! * the SCRIPT_NAME portion? Return that as a string. ! */ ! final public String getPATH_INFO () ! { ! return requst_.getPathInfo(); ! } ! /** ! * Same as PATH_INFO but translated to a real path ! */ ! final public String getPATH_TRANSLATED () ! { ! return requst_.getPathTranslated(); ! } ! /** ! * What portion of the URL represented the servlet being run? ! * Return that as a string. ! */ ! final public String getSCRIPT_NAME () ! { ! return requst_.getServletPath(); ! } ! /** ! * What is the root of documents served by this servlet ! * ! * WARNING: the method called (getRealPath) is deprecated in Servlet 2.2 ! * ! */ ! final public String getDOCUMENT_ROOT () ! { ! return sc_.getRealPath("/"); ! } ! /** ! * In a GET request, return the query string that was submitted, if any ! */ ! final public String getQUERY_STRING () ! { ! return requst_.getQueryString(); ! } ! /** ! * Return the remote host connected to this request ! */ ! final public String getREMOTE_HOST () ! { ! return requst_.getRemoteHost(); ! } ! /** ! * Return the remove address connected to this servlet ! */ ! final public String getREMOTE_ADDR () ! { ! return requst_.getRemoteAddr(); ! } ! /** ! * Type of authorization for this request ! */ ! final public String getAUTH_TYPE () ! { ! return requst_.getAuthType(); ! } ! /** ! * Name of the remote user if it was supplied with the HTTP request ! */ ! final public String getREMOTE_USER () ! { ! return requst_.getRemoteUser(); ! } ! /** ! * Get the content type submitted to this request ! */ ! final public String getCONTENT_TYPE () ! { ! return requst_.getContentType(); ! } ! /** ! * Get the content length submitted to this request ! */ ! final public Integer getCONTENT_LENGTH () ! { ! return new Integer(requst_.getContentLength()); ! } ! /** ! * What type of data is accepted by the client ! */ ! final public String getHTTP_ACCEPT () ! { ! return requst_.getHeader("Accept"); ! } ! /** ! * Get the user agent (browser) connected to this request ! */ ! final public String getHTTP_USER_AGENT () ! { ! return requst_.getHeader("User-Agent"); ! } ! /** ! * Get the URL that the request claims to have visited prior to this one ! */ ! final public String getHTTP_REFERER () ! { ! return requst_.getHeader("Referer"); ! } } Index: ConfigException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ConfigException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConfigException.java 11 Jun 2002 17:43:22 -0000 1.3 --- ConfigException.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 31,44 **** * the config file eg default variables cannot be located */ ! public class ConfigException extends WebMacroException { ! /** ! * Constructor only requires a reason ! * <p> ! * @param reason explains what went wrong ! */ ! public ConfigException(String reason) { ! super(reason); ! } } --- 31,46 ---- * the config file eg default variables cannot be located */ ! public class ConfigException extends WebMacroException ! { ! /** ! * Constructor only requires a reason ! * <p> ! * @param reason explains what went wrong ! */ ! public ConfigException (String reason) ! { ! super(reason); ! } } Index: CookieJar.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CookieJar.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CookieJar.java 11 Jun 2002 17:43:22 -0000 1.6 --- CookieJar.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 24,85 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; /** * Provide access to form variables */ ! final public class CookieJar { ! private Cookie[] jar; ! private HttpServletResponse res; ! /** ! * Read the form data from the supplied Request object ! */ ! CookieJar(final HttpServletRequest rq, final HttpServletResponse rs) { ! jar = rq.getCookies(); ! res = rs; ! } ! /** ! * Get a form value ! */ ! final public Object get(String cookieName) { ! if (jar == null) { ! return null; ! } ! for (int i = 0; i < jar.length; i++) { ! if ((jar[i] != null) && (jar[i].getName().equals(cookieName))) { ! return jar[i]; ! } ! } ! return null; ! } ! /** ! * Create a new cookie with the supplied name and value and set it ! * in the response header. ! */ ! public final void put(final String name, final String value) { ! Cookie c = new Cookie(name, value); ! res.addCookie(c); ! } ! /** ! * Calls put ! */ ! public final void set(final String name, final Object value) ! throws UnsettableException { ! try { ! put(name, (String) value); ! } ! catch (ClassCastException ce) { ! throw new UnsettableException("Value must be a String"); ! } ! } } --- 24,96 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; + import javax.servlet.http.Cookie; + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + /** * Provide access to form variables */ ! final public class CookieJar ! { ! private Cookie[] jar; ! private HttpServletResponse res; ! /** ! * Read the form data from the supplied Request object ! */ ! CookieJar (final HttpServletRequest rq, final HttpServletResponse rs) ! { ! jar = rq.getCookies(); ! res = rs; ! } ! /** ! * Get a form value ! */ ! final public Object get (String cookieName) ! { ! if (jar == null) ! { ! return null; ! } ! for (int i = 0; i < jar.length; i++) ! { ! if ((jar[i] != null) && (jar[i].getName().equals(cookieName))) ! { ! return jar[i]; ! } ! } ! return null; ! } ! /** ! * Create a new cookie with the supplied name and value and set it ! * in the response header. ! */ ! public final void put (final String name, final String value) ! { ! Cookie c = new Cookie(name, value); ! res.addCookie(c); ! } ! /** ! * Calls put ! */ ! public final void set (final String name, final Object value) ! throws UnsettableException ! { ! try ! { ! put(name, (String) value); ! } ! catch (ClassCastException ce) ! { ! throw new UnsettableException("Value must be a String"); ! } ! } } Index: CookieTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CookieTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CookieTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- CookieTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,54 **** * Provide Template with access to form data. */ ! public class CookieTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! CookieJar fl = new CookieJar(wc.getRequest(), wc.getResponse()); ! return fl; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,56 ---- * Provide Template with access to form data. */ ! public class CookieTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! CookieJar fl = new CookieJar(wc.getRequest(), wc.getResponse()); ! return fl; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: ErrorHandler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ErrorHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ErrorHandler.java 11 Jun 2002 17:43:22 -0000 1.8 --- ErrorHandler.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 34,95 **** * explaining what went wrong. */ ! final class ErrorHandler implements Handler { ! private static final String DEFAULT_ERROR_TEXT = ! "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n" ! + "#set $Response.ContentType = \"text/html\"\n" ! + "<BODY><H1>Error</H1>" ! + "<HR>$error</BODY></HTML>"; ! private Template _errorTemplate = null; ! /** ! * The default error handler simply returns its template ! * @see TemplateStore ! * @exception HandlerException if you don't want to handle the connect ! * @return A Template which can be used to interpret the connection ! */ ! public Template accept(WebContext c) ! throws HandlerException { ! Broker broker = c.getBroker(); ! String templateName; ! try { ! templateName = (String) broker.get("config", WMServlet.ERROR_TEMPLATE); ! } ! catch (ResourceException e) { ! templateName = WMServlet.ERROR_TEMPLATE_DEFAULT; ! } ! try { ! _errorTemplate = (Template) broker.get("template", templateName); ! } ! catch (ResourceException e) { ! _errorTemplate = new StringTemplate(broker, DEFAULT_ERROR_TEXT, ! "WebMacro default error template"); ! } ! return _errorTemplate; ! } ! /** ! * Does nothing ! */ ! public void destroy() { ! } ! /** ! * Does nothing ! */ ! public void init() { ! } ! /** ! * Return the name of this handler ! */ ! final public String toString() { ! return "WebMacro ErrorHandler"; ! } } --- 34,104 ---- * explaining what went wrong. */ ! final class ErrorHandler implements Handler ! { ! private static final String DEFAULT_ERROR_TEXT = ! "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n" ! + "#set $Response.ContentType = \"text/html\"\n" ! + "<BODY><H1>Error</H1>" ! + "<HR>$error</BODY></HTML>"; ! private Template _errorTemplate = null; ! /** ! * The default error handler simply returns its template ! * @see TemplateStore ! * @exception HandlerException if you don't want to handle the connect ! * @return A Template which can be used to interpret the connection ! */ ! public Template accept (WebContext c) ! throws HandlerException ! { ! Broker broker = c.getBroker(); ! String templateName; ! try ! { ! templateName = (String) broker.get("config", WMServlet.ERROR_TEMPLATE); ! } ! catch (ResourceException e) ! { ! templateName = WMServlet.ERROR_TEMPLATE_DEFAULT; ! } ! try ! { ! _errorTemplate = (Template) broker.get("template", templateName); ! } ! catch (ResourceException e) ! { ! _errorTemplate = new StringTemplate(broker, DEFAULT_ERROR_TEXT, ! "WebMacro default error template"); ! } ! return _errorTemplate; ! } ! /** ! * Does nothing ! */ ! public void destroy () ! { ! } ! /** ! * Does nothing ! */ ! public void init () ! { ! } ! /** ! * Return the name of this handler ! */ ! final public String toString () ! { ! return "WebMacro ErrorHandler"; ! } } Index: Form.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/Form.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Form.java 10 Nov 2002 20:51:13 -0000 1.8 --- Form.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 29,38 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; import org.webmacro.util.Bag; import java.util.Enumeration; --- 29,36 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; import org.webmacro.util.Bag; + import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; *************** *** 41,143 **** * Provide access to form variables */ ! final public class Form implements Bag { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! Form(final HttpServletRequest r) { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get(String field) { ! try { ! return _request.getParameterValues(field)[0]; ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Try to get a form value ! * ! * @param strKey = The form key that we're looking for. ! * ! * @return The value of that form key if found, else null ! * ! **/ ! final public Object getPossibleForm( String strKey ) { ! String strElement; ! Object obValue; ! Enumeration obEnumeration; ! //--- end of var's declaration ---// ! obValue = get( strKey ); ! if ( obValue == null ) { ! obEnumeration = _request.getParameterNames(); ! while ( obEnumeration.hasMoreElements() ) { ! strElement = obEnumeration.nextElement().toString(); ! if ( strElement.equalsIgnoreCase( strKey ) ) { ! obValue = get( strElement ); ! break; ! } ! } ! } ! return obValue; ! } ! /** ! * Get a form value as an array ! */ ! final public Object[] getList(String field) { ! try { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } /** * Return a String listing all the HTTP request parameter names and their values. */ ! final public String toString() { ! StringBuffer sb = new StringBuffer (); ! String eol = java.lang.System.getProperty ("line.separator"); ! for (Enumeration enum = _request.getParameterNames(); enum.hasMoreElements();) { String key = (String) enum.nextElement(); String[] value = _request.getParameterValues(key); ! for (int x=0; value != null && x<value.length; x++) { ! sb.append (key).append("=").append(value[x]).append (eol); } } --- 39,158 ---- * Provide access to form variables */ ! final public class Form implements Bag ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! Form (final HttpServletRequest r) ! { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get (String field) ! { ! try ! { ! return _request.getParameterValues(field)[0]; ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Try to get a form value ! * ! * @param strKey = The form key that we're looking for. ! * ! * @return The value of that form key if found, else null ! * ! **/ ! final public Object getPossibleForm (String strKey) ! { ! String strElement; ! Object obValue; ! Enumeration obEnumeration; ! //--- end of var's declaration ---// ! obValue = get(strKey); ! if (obValue == null) ! { ! obEnumeration = _request.getParameterNames(); ! while (obEnumeration.hasMoreElements()) ! { ! strElement = obEnumeration.nextElement().toString(); ! if (strElement.equalsIgnoreCase(strKey)) ! { ! obValue = get(strElement); ! break; ! } ! } ! } ! return obValue; ! } ! /** ! * Get a form value as an array ! */ ! final public Object[] getList (String field) ! { ! try ! { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } /** * Return a String listing all the HTTP request parameter names and their values. */ ! final public String toString () ! { ! StringBuffer sb = new StringBuffer(); ! String eol = java.lang.System.getProperty("line.separator"); ! for (Enumeration enum = _request.getParameterNames(); enum.hasMoreElements();) ! { String key = (String) enum.nextElement(); String[] value = _request.getParameterValues(key); ! for (int x = 0; value != null && x < value.length; x++) ! { ! sb.append(key).append("=").append(value[x]).append(eol); } } Index: FormList.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormList.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FormList.java 11 Jun 2002 17:43:22 -0000 1.5 --- FormList.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 24,78 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; import org.webmacro.util.Bag; /** * Provide access to form variables */ ! final public class FormList implements Bag { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! FormList(final HttpServletRequest r) { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get(String field) { ! try { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } } --- 24,84 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; import org.webmacro.util.Bag; + import javax.servlet.http.HttpServletRequest; + /** * Provide access to form variables */ ! final public class FormList implements Bag ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! FormList (final HttpServletRequest r) ! { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get (String field) ! { ! try ! { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } } Index: FormListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormListTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FormListTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- FormListTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,53 **** * Provide Template with access to form data. */ ! public class FormListTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! FormList fl = new FormList(wc.getRequest()); ! return fl; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,55 ---- * Provide Template with access to form data. */ ! public class FormListTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! FormList fl = new FormList(wc.getRequest()); ! return fl; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: FormTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FormTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- FormTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,53 **** * Provide Template with access to form data. */ ! public class FormTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! Form fr = new Form(wc.getRequest()); ! return fr; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "FormTool only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,55 ---- * Provide Template with access to form data. */ ! public class FormTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! Form fr = new Form(wc.getRequest()); ! return fr; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "FormTool only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: Handler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/Handler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Handler.java 12 Jun 2002 17:35:34 -0000 1.6 --- Handler.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 51,95 **** * <p> */ ! public interface Handler { ! /** ! * This is the primary method you override to create a new handler. ! * Incoming requests ultimately get passed to this method of your ! * handler, at which point it is up to you to decide what to do. ! * You must return a template--which will be used to format the ! * data you have inserted into the supplied WebContext. ! * <p> ! * If you throw an Exception it will be used to provide an explanation ! * to the user of why the failure occurred. The HandlerException class ! * provides you with numerous options for reporting errors. ! * <p> ! * @param contextData contains information about this connection ! * @return A Template which can be used to interpret the connection ! * @exception HandlerException if something went wrong with the handler ! */ ! public Template accept(WebContext contextData) ! throws HandlerException; ! /** ! * Use this method to run any startup initialization that you need ! * to perform. It will be called just before the first use of your ! * Handler. ! * @exception HandlerException if the handler failed to initialize ! */ ! public void init() throws HandlerException; ! /** ! * You SHOULD override this method and provide a short name by ! * which your handler is known. This will help you out in logging ! * and debugging messages if for some reason WebMacro needs to ! * identify the handler in a log message. ! */ ! public String toString(); ! /** ! * You may use this method to save persistent state on exit. ! * It will be called whenever the servlet is shut down. ! */ ! public void destroy(); } --- 51,96 ---- * <p> */ ! public interface Handler ! { ! /** ! * This is the primary method you override to create a new handler. ! * Incoming requests ultimately get passed to this method of your ! * handler, at which point it is up to you to decide what to do. ! * You must return a template--which will be used to format the ! * data you have inserted into the supplied WebContext. ! * <p> ! * If you throw an Exception it will be used to provide an explanation ! * to the user of why the failure occurred. The HandlerException class ! * provides you with numerous options for reporting errors. ! * <p> ! * @param contextData contains information about this connection ! * @return A Template which can be used to interpret the connection ! * @exception HandlerException if something went wrong with the handler ! */ ! public Template accept (WebContext contextData) ! throws HandlerException; ! /** ! * Use this method to run any startup initialization that you need ! * to perform. It will be called just before the first use of your ! * Handler. ! * @exception HandlerException if the handler failed to initialize ! */ ! public void init () throws HandlerException; ! /** ! * You SHOULD override this method and provide a short name by ! * which your handler is known. This will help you out in logging ! * and debugging messages if for some reason WebMacro needs to ! * identify the handler in a log message. ! */ ! public String toString (); ! /** ! * You may use this method to save persistent state on exit. ! * It will be called whenever the servlet is shut down. ! */ ! public void destroy (); } Index: HandlerException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/HandlerException.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HandlerException.java 11 Jun 2002 17:43:22 -0000 1.5 --- HandlerException.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 30,46 **** * not want to process a connection request. */ ! public class HandlerException extends WebMacroException { ! /** ! * Declare a handler exception with a reason ! * @param reason why the handler failed ! */ ! public HandlerException(String reason) { ! super(reason); ! } ! public HandlerException(String reason, Exception e) { ! super(reason, e); ! } } --- 30,49 ---- * not want to process a connection request. */ ! public class HandlerException extends WebMacroException ! { ! /** ! * Declare a handler exception with a reason ! * @param reason why the handler failed ! */ ! public HandlerException (String reason) ! { ! super(reason); ! } ! public HandlerException (String reason, Exception e) ! { ! super(reason, e); ! } } Index: ListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ListTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ListTool.java 11 Jun 2002 17:43:22 -0000 1.4 --- ListTool.java 12 Jun 2003 00:47:47 -0000 1.5 *************** *** 34,44 **** * @see ListUtil */ ! public class ListTool implements ContextTool { ! public Object init(Context context) { ! return ListUtil.getInstance(); ! } ! public void destroy(Object o) { ! } } --- 34,47 ---- * @see ListUtil */ ! public class ListTool implements ContextTool ! { ! public Object init (Context context) ! { ! return ListUtil.getInstance(); ! } ! public void destroy (Object o) ! { ! } } Index: ListUtil.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ListUtil.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ListUtil.java 20 Dec 2002 02:25:25 -0000 1.9 --- ListUtil.java 12 Jun 2003 00:47:47 -0000 1.10 *************** *** 36,761 **** * @see ListTool */ ! public class ListUtil { ! /** ! * Private constructor for a singleton class ! */ ! private ListUtil() { ! } [...1521 lines suppressed...] ! out.print(splitArray3[i][j] + ", "); ! } ! out.println("*"); ! } ! // test primitive arrays ! int[] emptyInts = new int[0]; ! out.println("Empty array of int: isEmpty=" + isEmpty(emptyInts)); ! char[] chars = {'A', 'B', 'C'}; ! out.println("Array of char: isEmpty=" + isEmpty(chars) + ", size=" + size(chars)); ! out.println("contains 'C'=" + contains(chars, new Character('C'))); ! out.println("contains 'Z'=" + contains(chars, new Character('Z'))); ! out.println("toList=" + toList(chars)); ! float[] f = new float[]{1.1f, 2.2f, 3.3f}; ! out.println("getItem(floats, 0)=" + getItem(f, 0)); ! List appendList = append(f, chars); ! out.println("append(f, chars)=" + appendList); ! append(appendList, "another thing"); ! out.println("append(appendList, \"another thing\")=" + appendList); ! } } Index: LocaleTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/LocaleTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LocaleTool.java 11 Nov 2002 19:22:38 -0000 1.7 --- LocaleTool.java 12 Jun 2003 00:47:47 -0000 1.8 *************** *** 24,30 **** package org.webmacro.servlet; - import java.lang.reflect.Field; - import java.util.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 33,150 **** import org.webmacro.util.Bag; /** * Provide Template with access to Locales. Also gives access to the static * fields e.g., Locale.US */ ! public class LocaleTool implements ContextTool, Bag { ! public static final String RCS = "$Id$"; ! private static HashMap cache = new HashMap(); ! public Object init(Context context) ! throws PropertyException { ! return this; ! } ! /** ! * return the default locale for this JVM ! */ ! final public Locale getDefault() { ! return Locale.getDefault(); ! } ! /** ! * wrappers around the 3 constructors for Locale ! */ ! final public Locale getLocale(String country) { ! return getLocale(country, "", ""); ! } ! final public Locale getLocale(String country, String language) { ! return getLocale(country, language, ""); ! } ! final public Locale getLocale(String country, String language, String variant) { ! String key = country + "_" + language + "_" + variant; // language.toUpperCase() ? ! Locale locale = (Locale) cache.get(key); ! if (locale == null) { ! locale = new Locale(country, language, ""); ! cache.put(key, locale); ! } ! return locale; ! } ! /** ! * access method used by $Locale.xxxxx => LocaleTool.get("xxxxx") ! */ ! final public Object get(String field) { ! return buildLocale(field); ! } ! /** ! * access to the static members such as Locale.US, etc ! * ! * If that field doesn't exist try to construct a locale ! * from a string so templates can have $Locale.en_GB. ! * ! * This may not be the right thing to do, though, in case of typos ! * ! * e.g., $Locale.ENGLISH => Locale.ENGLISH ! * but $Locale.ENGLSH => Locale("ENGLSH","","") ! * ! * Could argue that typos aren't caught in the latter anyway ! * (surprisingly?) ! */ ! final public static Locale buildLocale(String field) { ! Locale locale = (Locale) cache.get(field); ! if (locale == null) { ! try { ! Field f = Locale.class.getField(field); ! locale = (Locale) f.get(null); ! } ! catch (Exception ne) { ! StringTokenizer st = new StringTokenizer(field, "_"); ! String[] parts = new String[]{"", "", ""}; ! try { ! for (int i = 0; i < 3; i++) { ! parts[i] = st.nextToken(); ! } ! } ! catch (NoSuchElementException e) { } // System.out.println("Creating Locale: " // +parts[0]+"-"+parts[1]+"-"+parts[2]); ! locale = new Locale(parts[0], parts[1], parts[2]); ! } // System.out.println("Returning locale for "+field+" -> "+locale); ! cache.put(field, locale); ! } ! return locale; ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } ! public void destroy(Object o) { ! } } --- 30,171 ---- import org.webmacro.util.Bag; + import java.lang.reflect.Field; + import java.util.HashMap; + import java.util.Locale; + import java.util.NoSuchElementException; + import java.util.StringTokenizer; + /** * Provide Template with access to Locales. Also gives access to the static * fields e.g., Locale.US */ ! public class LocaleTool implements ContextTool, Bag ! { ! public static final String RCS = "$Id$"; ! private static HashMap cache = new HashMap(); ! public Object init (Context context) ! throws PropertyException ! { ! return this; ! } ! /** ! * return the default locale for this JVM ! */ ! final public Locale getDefault () ! { ! return Locale.getDefault(); ! } ! /** ! * wrappers around the 3 constructors for Locale ! */ ! final public Locale getLocale (String country) ! { ! return getLocale(country, "", ""); ! } ! final public Locale getLocale (String country, String language) ! { ! return getLocale(country, language, ""); ! } ! final public Locale getLocale (String country, String language, String variant) ! { ! String key = country + "_" + language + "_" + variant; // language.toUpperCase() ? ! Locale locale = (Locale) cache.get(key); ! if (locale == null) ! { ! locale = new Locale(country, language, ""); ! cache.put(key, locale); ! } ! return locale; ! } ! /** ! * access method used by $Locale.xxxxx => LocaleTool.get("xxxxx") ! */ ! final public Object get (String field) ! { ! return buildLocale(field); ! } ! /** ! * access to the static members such as Locale.US, etc ! * ! * If that field doesn't exist try to construct a locale ! * from a string so templates can have $Locale.en_GB. ! * ! * This may not be the right thing to do, though, in case of typos ! * ! * e.g., $Locale.ENGLISH => Locale.ENGLISH ! * but $Locale.ENGLSH => Locale("ENGLSH","","") ! * ! * Could argue that typos aren't caught in the latter anyway ! * (surprisingly?) ! */ ! final public static Locale buildLocale (String field) ! { ! Locale locale = (Locale) cache.get(field); ! if (locale == null) ! { ! try ! { ! Field f = Locale.class.getField(field); ! locale = (Locale) f.get(null); } + catch (Exception ne) + { + StringTokenizer st = new StringTokenizer(field, "_"); + String[] parts = new String[]{"", "", ""}; + try + { + for (int i = 0; i < 3; i++) + { + parts[i] = st.nextToken(); + } + } + catch (NoSuchElementException e) + { + } // System.out.println("Creating Locale: " // +parts[0]+"-"+parts[1]+"-"+parts[2]); ! locale = new Locale(parts[0], parts[1], parts[2]); ! } // System.out.println("Returning locale for "+field+" -> "+locale); ! cache.put(field, locale); ! } ! return locale; ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } ! public void destroy (Object o) ! { ! } } Index: MathTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/MathTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MathTool.java 28 Mar 2003 02:46:00 -0000 1.6 --- MathTool.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 34,198 **** */ ! public class MathTool implements ContextTool { ! /** our lonely singleton */ ! private static final MathTool _instance = new MathTool(); ! /** ! * @return the static instance of the MathTool ! */ ! public static final MathTool getInstance() { ! return _instance; ! } ! // ! // static MathTool methods and fields ! // ! /** the value of PI, as defined by <code>java.lang.Math.PI</code> */ ! public static final double PI = java.lang.Math.PI; ! /** ! * @return the smaller of the specified number ! */ ! public static final int min(int a, int b) { ! return (a < b)?a:b; ! } ! public static final long min(long a, long b) { ! return (a < b)?a:b; ! } ! public static final float min(float a, float b) { ! return (a < b)?a:b; ! } ! public static final double min(double a, double b) { ! return (a < b)?a:b; ! } ! /** ! * @return the larger of the specified number ! */ ! public static final int max(int a, int b) { ! return (a > b)?a:b; ! } ! public static final long max(long a, long b) { ! return (a > b)?a:b; ! } ! public static final float max(float a, float b) { ! return (a > b)?a:b; ! } ! public static final double max(double a, double b) { ! return (a > b)?a:b; ! } ! /** ! * Creates a pseudo-random Integer between <code>start</code> ! * and <code>end</code>, inclusive ! */ ! public static final int random(int start, int end) { ! return start + (int)((end - start + 1) * java.lang.Math.random()); ! } ! /** ! * @return <code>base</code> raised to the specified <code>power</code> ! */ ! public static final int pow(int base, int power) { ! return base ^ power; ! } ! public static final long pow(long base, long power) { ! return base ^ power; ! } ! /** ! * @return the absolute value of the specified number ! */ ! public static final int abs(int a) { ! return java.lang.Math.abs(a); ! } ! public static final long abs(long a) { ! return java.lang.Math.abs(a); ! } ! public static final float abs(float a) { ! return java.lang.Math.abs(a); ! } ! public static final double abs(double a) { ! return java.lang.Math.abs(a); ! } ! /** ! * @return <code>a</code> modulo <code>b</code> ! */ ! public static final int mod(int a, int b) { ! return a % b; ! } ! /** ! * Converts args to doubles and multiplies them together. ! * @return <code>a * b</code> ! */ ! public static final double multiply(Number a, Number b){ ! return a.doubleValue() * b.doubleValue(); ! } ! ! /** ! * Converts args to doubles and divides the first by the second. ! * @return <code>a / b</code> ! */ ! public static final double divide(Number a, Number b){ ! return a.doubleValue() / b.doubleValue(); ! } - // - // ContextTool implementation methods - // ! /** default contsructor. Does nothing */ ! public MathTool() { ! } ! /** ! * public constructor. Does nothing. The MathTool doesn't ! * interact with the Context, so it is ignored ! */ ! public MathTool(Context context) { ! } ! /** ! * Tool initialization method. The MathTool doesn't ! * interact with the context, so the <code>context</code> ! * parameter is ignored. ! */ ! public Object init(Context context) throws PropertyException { ! return MathTool.getInstance(); ! } ! /** ! * Perform necessary cleanup work ! */ ! public void destroy(Object o) { ! } ! ! public static void main(String[] args){ ! System.out.println("Generating 200 random ints between 10 and 99 inclusive:"); ! for (int i=0; i<200; i++){ ! System.out.print(MathTool.random(10, 99) + " "); ! if (((i + 1) % 20) == 0) System.out.println(); ! } ! System.out.println("\nDone."); ! } } --- 34,224 ---- */ ! public class MathTool implements ContextTool ! { ! /** our lonely singleton */ ! private static final MathTool _instance = new MathTool(); ! /** ! * @return the static instance of the MathTool ! */ ! public static final MathTool getInstance () ! { ! return _instance; ! } ! // ! // static MathTool methods and fields ! // ! /** the value of PI, as defined by <code>java.lang.Math.PI</code> */ ! public static final double PI = java.lang.Math.PI; ! /** ! * @return the smaller of the specified number ! */ ! public static final int min (int a, int b) ! { ! return (a < b) ? a : b; ! } ! public static final long min (long a, long b) ! { ! return (a < b) ? a : b; ! } ! public static final float min (float a, float b) ! { ! return (a < b) ? a : b; ! } ! public static final double min (double a, double b) ! { ! return (a < b) ? a : b; ! } ! /** ! * @return the larger of the specified number ! */ ! public static final int max (int a, int b) ! { ! return (a > b) ? a : b; ! } ! public static final long max (long a, long b) ! { ! return (a > b) ? a : b; ! } ! public static final float max (float a, float b) ! { ! return (a > b) ? a : b; ! } ! public static final double max (double a, double b) ! { ! return (a > b) ? a : b; ! } ! /** ! * Creates a pseudo-random Integer between <code>start</code> ! * and <code>end</code>, inclusive ! */ ! public static final int random (int start, int end) ! { ! return start + (int) ((end - start + 1) * java.lang.Math.random()); ! } ! /** ! * @return <code>base</code> raised to the specified <code>power</code> ! */ ! public static final int pow (int base, int power) ! { ! return base ^ power; ! } ! public static final long pow (long base, long power) ! { ! return base ^ power; ! } ! /** ! * @return the absolute value of the specified number ! */ ! public static final int abs (int a) ! { ! return java.lang.Math.abs(a); ! } ! public static final long abs (long a) ! { ! return java.lang.Math.abs(a); ! } ! public static final float abs (float a) ! { ! return java.lang.Math.abs(a); ! } ! public static final double abs (double a) ! { ! return java.lang.Math.abs(a); ! } ! /** ! * @return <code>a</code> modulo <code>b</code> ! */ ! public static final int mod (int a, int b) ! { ! return a % b; ! } ! /** ! * Converts args to doubles and multiplies them together. ! * @return <code>a * b</code> ! */ ! public static final double multiply (Number a, Number b) ! { ! return a.doubleValue() * b.doubleValue(); ! } + /** + * Converts args to doubles and divides the first by the second. + * @return <code>a / b</code> + */ + public static final double divide (Number a, Number b) + { + return a.doubleValue() / b.doubleValue(); + } ! // ! // ContextTool implementation methods ! // ! /** default contsructor. Does nothing */ ! public MathTool () ! { ! } ! /** ! * public constructor. Does nothing. The MathTool doesn't ! * interact with the Context, so it is ignored ! */ ! public MathTool (Context context) ! { ! } ! /** ! * Tool initialization method. The MathTool doesn't ! * interact with the context, so the <code>context</code> ! * parameter is ignored. ! */ ! public Object init (Context context) throws PropertyException ! { ! return MathTool.getInstance(); ! } ! ! /** ! * Perform necessary cleanup work ! */ ! public void destroy (Object o) ! { ! } ! ! public static void main (String[] args) ! { ! System.out.println("Generating 200 random ints between 10 and 99 inclusive:"); ! for (int i = 0; i < 200; i++) ! { ! System.out.print(MathTool.random(10, 99) + " "); ! if (((i + 1) % 20) == 0) System.out.println(); ! } ! System.out.println("\nDone."); ! } } Index: RequestTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/RequestTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RequestTool.java 11 Nov 2002 19:22:38 -0000 1.7 --- RequestTool.java 12 Jun 2003 00:47:47 -0000 1.8 *************** *** 31,49 **** * Provide Template with access to form data. */ ! public class RequestTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! return wc.getRequest(); ! } ! catch (ClassCastExceptio... [truncated message content] |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/parser In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/parser Modified Files: ASCII_CharStream.java BackupCharStream.java CharStream.java ParseException.java ParserBlockBuilder.java ParserRuntimeException.java Token.java TokenMgrError.java WMParser.java WMParser_impl.java WMParser_implConstants.java WMParser_implTokenManager.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: ASCII_CharStream.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/parser/ASCII_CharStream.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ASCII_CharStream.java 11 Jun 2002 17:43:22 -0000 1.5 --- ASCII_CharStream.java 12 Jun 2003 00:47:45 -0000 1.6 *************** *** 10,317 **** */ ! public final class ASCII_CharStream { ! private static final class Buffer { ! int size; ! int dataLen, curPos; ! char[] buffer; ! int[] bufline, bufcolumn; ! public Buffer(int n) { ! size = n; ! dataLen = 0; ! curPos = -1; ! buffer = new char[n]; ! bufline = new int[n]; ! bufcolumn = new int[n]; ! } ! public void expand(int n) { ! char[] newbuffer = new char[size + n]; ! int newbufline[] = new int[size + n]; ! int newbufcolumn[] = new int[size + n]; ! try { ! System.arraycopy(buffer, 0, newbuffer, 0, size); ! buffer = newbuffer; ! System.arraycopy(bufline, 0, newbufline, 0, size); ! bufline = newbufline; ! System.arraycopy(bufcolumn, 0, newbufcolumn, 0, size); ! bufcolumn = newbufcolumn; ! } ! catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! size += n; ! } ! } ! private Buffer bufA, bufB, curBuf, otherBuf, tokenBeginBuf; ! private int tokenBeginPos; ! private int backupChars; ! public static final boolean staticFlag = false; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private final void swapBuf() { ! Buffer tmp = curBuf; ! curBuf = otherBuf; ! otherBuf = tmp; ! } ! private final void FillBuff() throws java.io.IOException { ! // Buffer fill logic: ! // If there is at least 2K left in this buffer, just read some more ! // Otherwise, if we're processing a token and it either ! // (a) starts in the other buffer (meaning it's filled both part of ! // the other buffer and some of this one, or ! // (b) starts in the first 2K of this buffer (meaning its taken up ! // most of this buffer ! // we expand this buffer. Otherwise, we swap buffers. ! // This guarantees we will be able to back up at least 2K characters. ! if (curBuf.size - curBuf.dataLen < 2048) { ! if (tokenBeginPos >= 0 ! && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048) ! || tokenBeginBuf != curBuf)) { ! curBuf.expand(2048); ! } ! else { ! swapBuf(); ! curBuf.curPos = curBuf.dataLen = 0; ! } ! } ! try { ! int i = inputStream.read(curBuf.buffer, curBuf.dataLen, ! curBuf.size - curBuf.dataLen); ! if (i == -1) { ! inputStream.close(); ! throw new java.io.IOException(); ! } ! else ! curBuf.dataLen += i; ! return; ! } ! catch (java.io.IOException e) { ! if (curBuf.curPos > 0) ! --curBuf.curPos; ! if (tokenBeginPos == -1) { ! tokenBeginPos = curBuf.curPos; ! tokenBeginBuf = curBuf; ! } ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBeginPos = -1; ! char c = readChar(); ! tokenBeginBuf = curBuf; ! tokenBeginPos = curBuf.curPos; ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } ! else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } ! else line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! case '\t': ! column--; ! column += (8 - (column & 07)); ! break; ! default : ! break; ! } ! curBuf.bufline[curBuf.curPos] = line; ! curBuf.bufcolumn[curBuf.curPos] = column; ! } ! public final char readChar() throws java.io.IOException { ! // When we hit the end of the buffer, if we're backing up, we just ! // swap, if we're not, we fill. ! if (++curBuf.curPos >= curBuf.dataLen) { ! if (backupChars > 0) { ! --curBuf.curPos; ! swapBuf(); ! } ! else ! FillBuff(); ! } ! ; ! char c = (char) ((char) 0xff & curBuf.buffer[curBuf.curPos]); ! // No need to update line numbers if we've already processed this char ! if (backupChars > 0) ! --backupChars; ! else ! UpdateLineColumn(c); ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getEndColumn() { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! public final int getEndLine() { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getBeginColumn() { ! return tokenBeginBuf.bufcolumn[tokenBeginPos]; ! } ! public final int getBeginLine() { ! return tokenBeginBuf.bufline[tokenBeginPos]; ! } ! public final void backup(int amount) { ! backupChars += amount; ! if (curBuf.curPos - amount < 0) { ! int addlChars = amount - 1 - curBuf.curPos; ! curBuf.curPos = 0; ! swapBuf(); ! curBuf.curPos = curBuf.dataLen - addlChars - 1; ! } ! else { ! curBuf.curPos -= amount; ! } ! } ! public ASCII_CharStream(java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) { ! ReInit(dstream, startline, startcolumn, buffersize); ! } ! public ASCII_CharStream(java.io.Reader dstream, int startline, ! int startcolumn) { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit(java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) { ! inputStream = dstream; ! line = startline; ! column = startcolumn - 1; ! if (bufA == null || bufA.size != buffersize) ! bufA = new Buffer(buffersize); ! if (bufB == null || bufB.size != buffersize) ! bufB = new Buffer(buffersize); ! curBuf = bufA; ! otherBuf = bufB; ! curBuf.curPos = otherBuf.dataLen = -1; ! curBuf.dataLen = otherBuf.dataLen = 0; ! prevCharIsLF = prevCharIsCR = false; ! tokenBeginPos = -1; ! tokenBeginBuf = null; ! backupChars = 0; ! } ! public void ReInit(java.io.Reader dstream, int startline, ! int startcolumn) { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public ASCII_CharStream(java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) { ! this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); ! } ! public ASCII_CharStream(java.io.InputStream dstream, int startline, ! int startcolumn) { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit(java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) { ! ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, ! 4096); ! } ! public void ReInit(java.io.InputStream dstream, int startline, ! int startcolumn) { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public final String GetImage() { ! if (tokenBeginBuf == curBuf) ! return new String(curBuf.buffer, tokenBeginPos, ! curBuf.curPos - tokenBeginPos + 1); ! else ! return new String(otherBuf.buffer, tokenBeginPos, ! otherBuf.dataLen - tokenBeginPos) ! + new String(curBuf.buffer, 0, curBuf.curPos + 1); ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((curBuf.curPos + 1) >= len) ! System.arraycopy(curBuf.buffer, curBuf.curPos - len + 1, ret, 0, len); ! else { ! if (otherBuf.dataLen >= len - curBuf.curPos - 1) ! System.arraycopy(otherBuf.buffer, ! otherBuf.dataLen - (len - curBuf.curPos - 1), ret, 0, ! len - curBuf.curPos - 1); ! System.arraycopy(curBuf.buffer, 0, ret, len - curBuf.curPos - 1, ! curBuf.curPos + 1); ! } ! return null; ! } ! public void Done() { ! bufA = bufB = curBuf = otherBuf = null; ! } } --- 10,362 ---- */ ! public final class ASCII_CharStream ! { ! private static final class Buffer ! { ! int size; ! int dataLen, curPos; ! char[] buffer; ! int[] bufline, bufcolumn; ! public Buffer (int n) ! { ! size = n; ! dataLen = 0; ! curPos = -1; ! buffer = new char[n]; ! bufline = new int[n]; ! bufcolumn = new int[n]; ! } ! public void expand (int n) ! { ! char[] newbuffer = new char[size + n]; ! int newbufline[] = new int[size + n]; ! int newbufcolumn[] = new int[size + n]; ! try ! { ! System.arraycopy(buffer, 0, newbuffer, 0, size); ! buffer = newbuffer; ! System.arraycopy(bufline, 0, newbufline, 0, size); ! bufline = newbufline; ! System.arraycopy(bufcolumn, 0, newbufcolumn, 0, size); ! bufcolumn = newbufcolumn; ! } ! catch (Throwable t) ! { ! throw new Error(t.getMessage()); ! } ! size += n; ! } ! } ! private Buffer bufA, bufB, curBuf, otherBuf, tokenBeginBuf; ! private int tokenBeginPos; ! private int backupChars; ! public static final boolean staticFlag = false; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private final void swapBuf () ! { ! Buffer tmp = curBuf; ! curBuf = otherBuf; ! otherBuf = tmp; ! } ! private final void FillBuff () throws java.io.IOException ! { ! // Buffer fill logic: ! // If there is at least 2K left in this buffer, just read some more ! // Otherwise, if we're processing a token and it either ! // (a) starts in the other buffer (meaning it's filled both part of ! // the other buffer and some of this one, or ! // (b) starts in the first 2K of this buffer (meaning its taken up ! // most of this buffer ! // we expand this buffer. Otherwise, we swap buffers. ! // This guarantees we will be able to back up at least 2K characters. ! if (curBuf.size - curBuf.dataLen < 2048) ! { ! if (tokenBeginPos >= 0 ! && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048) ! || tokenBeginBuf != curBuf)) ! { ! curBuf.expand(2048); ! } ! else ! { ! swapBuf(); ! curBuf.curPos = curBuf.dataLen = 0; ! } ! } ! try ! { ! int i = inputStream.read(curBuf.buffer, curBuf.dataLen, ! curBuf.size - curBuf.dataLen); ! if (i == -1) ! { ! inputStream.close(); ! throw new java.io.IOException(); ! } ! else ! curBuf.dataLen += i; ! return; ! } ! catch (java.io.IOException e) ! { ! if (curBuf.curPos > 0) ! --curBuf.curPos; ! if (tokenBeginPos == -1) ! { ! tokenBeginPos = curBuf.curPos; ! tokenBeginBuf = curBuf; ! } ! throw e; ! } ! } ! public final char BeginToken () throws java.io.IOException ! { ! tokenBeginPos = -1; ! char c = readChar(); ! tokenBeginBuf = curBuf; ! tokenBeginPos = curBuf.curPos; ! return c; ! } ! private final void UpdateLineColumn (char c) ! { ! column++; ! if (prevCharIsLF) ! { ! prevCharIsLF = false; line += (column = 1); ! } ! else if (prevCharIsCR) ! { ! prevCharIsCR = false; ! if (c == '\n') ! { ! prevCharIsLF = true; ! } ! else ! line += (column = 1); ! } ! switch (c) ! { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! case '\t': ! column--; ! column += (8 - (column & 07)); ! break; ! default : ! break; ! } ! curBuf.bufline[curBuf.curPos] = line; ! curBuf.bufcolumn[curBuf.curPos] = column; ! } ! public final char readChar () throws java.io.IOException ! { ! // When we hit the end of the buffer, if we're backing up, we just ! // swap, if we're not, we fill. ! if (++curBuf.curPos >= curBuf.dataLen) ! { ! if (backupChars > 0) ! { ! --curBuf.curPos; ! swapBuf(); ! } ! else ! FillBuff(); ! } ! ; ! char c = (char) ((char) 0xff & curBuf.buffer[curBuf.curPos]); ! // No need to update line numbers if we've already processed this char ! if (backupChars > 0) ! --backupChars; ! else ! UpdateLineColumn(c); ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn () ! { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine () ! { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getEndColumn () ! { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! public final int getEndLine () ! { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getBeginColumn () ! { ! return tokenBeginBuf.bufcolumn[tokenBeginPos]; ! } ! public final int getBeginLine () ! { ! return tokenBeginBuf.bufline[tokenBeginPos]; ! } ! public final void backup (int amount) ! { ! backupChars += amount; ! if (curBuf.curPos - amount < 0) ! { ! int addlChars = amount - 1 - curBuf.curPos; ! curBuf.curPos = 0; ! swapBuf(); ! curBuf.curPos = curBuf.dataLen - addlChars - 1; ! } ! else ! { ! curBuf.curPos -= amount; ! } ! } ! public ASCII_CharStream (java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) ! { ! ReInit(dstream, startline, startcolumn, buffersize); ! } ! public ASCII_CharStream (java.io.Reader dstream, int startline, ! int startcolumn) ! { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit (java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) ! { ! inputStream = dstream; ! line = startline; ! column = startcolumn - 1; ! if (bufA == null || bufA.size != buffersize) ! bufA = new Buffer(buffersize); ! if (bufB == null || bufB.size != buffersize) ! bufB = new Buffer(buffersize); ! curBuf = bufA; ! otherBuf = bufB; ! curBuf.curPos = otherBuf.dataLen = -1; ! curBuf.dataLen = otherBuf.dataLen = 0; ! prevCharIsLF = prevCharIsCR = false; ! tokenBeginPos = -1; ! tokenBeginBuf = null; ! backupChars = 0; ! } ! public void ReInit (java.io.Reader dstream, int startline, ! int startcolumn) ! { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public ASCII_CharStream (java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) ! { ! this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); ! } ! public ASCII_CharStream (java.io.InputStream dstream, int startline, ! int startcolumn) ! { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit (java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) ! { ! ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, ! 4096); ! } ! public void ReInit (java.io.InputStream dstream, int startline, ! int startcolumn) ! { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public final String GetImage () ! { ! if (tokenBeginBuf == curBuf) ! return new String(curBuf.buffer, tokenBeginPos, ! curBuf.curPos - tokenBeginPos + 1); ! else ! return new String(otherBuf.buffer, tokenBeginPos, ! otherBuf.dataLen - tokenBeginPos) ! + new String(curBuf.buffer, 0, curBuf.curPos + 1); ! } ! public final char[] GetSuffix (int len) ! { ! char[] ret = new char[len]; ! if ((curBuf.curPos + 1) >= len) ! System.arraycopy(curBuf.buffer, curBuf.curPos - len + 1, ret, 0, len); ! else ! { ! if (otherBuf.dataLen >= len - curBuf.curPos - 1) ! System.arraycopy(otherBuf.buffer, ! otherBuf.dataLen - (len - curBuf.curPos - 1), ret, 0, ! len - curBuf.curPos - 1); ! System.arraycopy(curBuf.buffer, 0, ret, len - curBuf.curPos - 1, ! curBuf.curPos + 1); ! } ! return null; ! } ! public void Done () ! { ! bufA = bufB = curBuf = otherBuf = null; ! } } Index: BackupCharStream.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/parser/BackupCharStream.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BackupCharStream.java 11 Jun 2002 17:43:22 -0000 1.6 --- BackupCharStream.java 12 Jun 2003 00:47:46 -0000 1.7 *************** *** 11,343 **** */ ! public final class BackupCharStream implements CharStream { ! private static final class Buffer { ! int size; ! int dataLen, curPos; ! char[] buffer; ! int[] bufline, bufcolumn; ! public Buffer(int n) { ! size = n; ! dataLen = 0; ! curPos = -1; ! buffer = new char[n]; ! bufline = new int[n]; ! bufcolumn = new int[n]; ! } ! public void expand(int n) { ! char[] newbuffer = new char[size + n]; ! int newbufline[] = new int[size + n]; ! int newbufcolumn[] = new int[size + n]; ! try { ! System.arraycopy(buffer, 0, newbuffer, 0, size); ! buffer = newbuffer; ! System.arraycopy(bufline, 0, newbufline, 0, size); ! bufline = newbufline; ! System.arraycopy(bufcolumn, 0, newbufcolumn, 0, size); ! bufcolumn = newbufcolumn; ! } ! catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! size += n; ! } ! } ! private Buffer bufA, bufB, curBuf, otherBuf, tokenBeginBuf; ! private int tokenBeginPos; ! private int backupChars; ! public static final boolean staticFlag = false; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private boolean inputStreamClosed = false; ! private final void swapBuf() { ! Buffer tmp = curBuf; ! curBuf = otherBuf; ! otherBuf = tmp; ! } ! private final void FillBuff() throws java.io.IOException { ! // Buffer fill logic: ! // If there is at least 2K left in this buffer, just read some more ! // Otherwise, if we're processing a token and it either ! // (a) starts in the other buffer (meaning it's filled both part of ! // the other buffer and some of this one, or ! // (b) starts in the first 2K of this buffer (meaning its taken up ! // most of this buffer ! // we expand this buffer. Otherwise, we swap buffers. ! // This guarantees we will be able to back up at least 2K characters. ! if (curBuf.size - curBuf.dataLen < 2048) { ! if (tokenBeginPos >= 0 ! && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048) ! || tokenBeginBuf != curBuf)) { ! curBuf.expand(2048); ! } ! else { ! swapBuf(); ! curBuf.curPos = curBuf.dataLen = 0; ! } ! } ! try { ! int i = inputStream.read(curBuf.buffer, curBuf.dataLen, ! curBuf.size - curBuf.dataLen); ! if (i == -1) { ! inputStream.close(); ! inputStreamClosed = true; ! throw new java.io.IOException(); ! } ! else ! curBuf.dataLen += i; ! return; ! } ! catch (java.io.IOException e) { ! if (curBuf.curPos > 0) ! --curBuf.curPos; ! if (tokenBeginPos == -1) { ! tokenBeginPos = curBuf.curPos; ! tokenBeginBuf = curBuf; ! } ! if (e.getClass().getName().equals("sun.io.MalformedInputException")) { ! // it's an ugly hack, but we want to pass this exception ! // through the JavaCC parser, since it has a bad ! // exception handling ! throw new ParserRuntimeException("MalformedInput", e); ! } ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBeginPos = -1; ! char c = readChar(); ! tokenBeginBuf = curBuf; ! tokenBeginPos = curBuf.curPos; ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } ! else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } ! else line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! case '\t': ! column--; ! column += (8 - (column & 07)); ! break; ! default : ! break; ! } ! curBuf.bufline[curBuf.curPos] = line; ! curBuf.bufcolumn[curBuf.curPos] = column; ! } ! public final char readChar() throws java.io.IOException { ! // When we hit the end of the buffer, if we're backing up, we just ! // swap, if we're not, we fill. ! if (++curBuf.curPos >= curBuf.dataLen) { ! if (backupChars > 0) { ! --curBuf.curPos; ! swapBuf(); ! } ! else ! FillBuff(); ! } ! ; ! // Don't mask off the high byte ! char c = curBuf.buffer[curBuf.curPos]; ! // No need to update line numbers if we've already processed this char ! if (backupChars > 0) ! --backupChars; ! else ! UpdateLineColumn(c); ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getEndColumn() { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! public final int getEndLine() { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getBeginColumn() { ! return tokenBeginBuf.bufcolumn[tokenBeginPos]; ! } ! public final int getBeginLine() { ! return tokenBeginBuf.bufline[tokenBeginPos]; ! } ! public final void backup(int amount) { ! backupChars += amount; ! if (curBuf.curPos - amount < 0) { ! int addlChars = amount - (inputStreamClosed? 0 : 1) - curBuf.curPos; ! curBuf.curPos = 0; ! swapBuf(); ! curBuf.curPos = curBuf.dataLen - addlChars - 1; ! } ! else { ! curBuf.curPos -= amount; ! } ! } ! public BackupCharStream(java.io.Reader dstream) { ! this(dstream, 1, 1, 4096); ! } ! public BackupCharStream(java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) { ! ReInit(dstream, startline, startcolumn, buffersize); ! } ! public BackupCharStream(java.io.Reader dstream, int startline, ! int startcolumn) { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit(java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) { ! inputStream = dstream; ! inputStreamClosed = false; ! line = startline; ! column = startcolumn - 1; ! if (bufA == null || bufA.size != buffersize) ! bufA = new Buffer(buffersize); ! if (bufB == null || bufB.size != buffersize) ! bufB = new Buffer(buffersize); ! curBuf = bufA; ! otherBuf = bufB; ! curBuf.curPos = otherBuf.dataLen = -1; ! curBuf.dataLen = otherBuf.dataLen = 0; ! prevCharIsLF = prevCharIsCR = false; ! tokenBeginPos = -1; ! tokenBeginBuf = null; ! backupChars = 0; ! } ! public void ReInit(java.io.Reader dstream, int startline, ! int startcolumn) { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public void ReInit(java.io.Reader dstream) { ! ReInit(dstream, 1, 1, 4096); ! } ! public BackupCharStream(java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) { ! this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); ! } ! public BackupCharStream(java.io.InputStream dstream, int startline, ! int startcolumn) { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit(java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) { ! ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, ! 4096); ! } ! public void ReInit(java.io.InputStream dstream, int startline, ! int startcolumn) { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public final String GetImage() { ! String ret; ! if (tokenBeginBuf == curBuf) { ! ret = new String(curBuf.buffer, tokenBeginPos, ! curBuf.curPos - tokenBeginPos + 1); ! } ! else { ! ret = new String(otherBuf.buffer, tokenBeginPos, ! otherBuf.dataLen - tokenBeginPos); ! if (curBuf.curPos < curBuf.dataLen) ! ret += new String(curBuf.buffer, 0, curBuf.curPos + 1); ! } ! return ret; ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((curBuf.curPos + 1) >= len) ! System.arraycopy(curBuf.buffer, curBuf.curPos - len + 1, ret, 0, len); ! else { ! if (otherBuf.dataLen >= len - curBuf.curPos - 1) ! System.arraycopy(otherBuf.buffer, ! otherBuf.dataLen - (len - curBuf.curPos - 1), ret, 0, ! len - curBuf.curPos - 1); ! System.arraycopy(curBuf.buffer, 0, ret, len - curBuf.curPos - 1, ! curBuf.curPos + 1); ! } ! return null; ! } ! public void Done() { ! bufA = bufB = curBuf = otherBuf = null; ! } } --- 11,393 ---- */ ! public final class BackupCharStream implements CharStream ! { ! private static final class Buffer ! { ! int size; ! int dataLen, curPos; ! char[] buffer; ! int[] bufline, bufcolumn; ! public Buffer (int n) ! { ! size = n; ! dataLen = 0; ! curPos = -1; ! buffer = new char[n]; ! bufline = new int[n]; ! bufcolumn = new int[n]; ! } ! public void expand (int n) ! { ! char[] newbuffer = new char[size + n]; ! int newbufline[] = new int[size + n]; ! int newbufcolumn[] = new int[size + n]; ! try ! { ! System.arraycopy(buffer, 0, newbuffer, 0, size); ! buffer = newbuffer; ! System.arraycopy(bufline, 0, newbufline, 0, size); ! bufline = newbufline; ! System.arraycopy(bufcolumn, 0, newbufcolumn, 0, size); ! bufcolumn = newbufcolumn; ! } ! catch (Throwable t) ! { ! throw new Error(t.getMessage()); ! } ! size += n; ! } ! } ! private Buffer bufA, bufB, curBuf, otherBuf, tokenBeginBuf; ! private int tokenBeginPos; ! private int backupChars; ! public static final boolean staticFlag = false; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private boolean inputStreamClosed = false; ! private final void swapBuf () ! { ! Buffer tmp = curBuf; ! curBuf = otherBuf; ! otherBuf = tmp; ! } ! private final void FillBuff () throws java.io.IOException ! { ! // Buffer fill logic: ! // If there is at least 2K left in this buffer, just read some more ! // Otherwise, if we're processing a token and it either ! // (a) starts in the other buffer (meaning it's filled both part of ! // the other buffer and some of this one, or ! // (b) starts in the first 2K of this buffer (meaning its taken up ! // most of this buffer ! // we expand this buffer. Otherwise, we swap buffers. ! // This guarantees we will be able to back up at least 2K characters. ! if (curBuf.size - curBuf.dataLen < 2048) ! { ! if (tokenBeginPos >= 0 ! && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048) ! || tokenBeginBuf != curBuf)) ! { ! curBuf.expand(2048); ! } ! else ! { ! swapBuf(); ! curBuf.curPos = curBuf.dataLen = 0; ! } ! } ! try ! { ! int i = inputStream.read(curBuf.buffer, curBuf.dataLen, ! curBuf.size - curBuf.dataLen); ! if (i == -1) ! { ! inputStream.close(); ! inputStreamClosed = true; ! throw new java.io.IOException(); ! } ! else ! curBuf.dataLen += i; ! return; ! } ! catch (java.io.IOException e) ! { ! if (curBuf.curPos > 0) ! --curBuf.curPos; ! if (tokenBeginPos == -1) ! { ! tokenBeginPos = curBuf.curPos; ! tokenBeginBuf = curBuf; ! } ! if (e.getClass().getName().equals("sun.io.MalformedInputException")) ! { ! // it's an ugly hack, but we want to pass this exception ! // through the JavaCC parser, since it has a bad ! // exception handling ! throw new ParserRuntimeException("MalformedInput", e); ! } ! throw e; ! } ! } ! public final char BeginToken () throws java.io.IOException ! { ! tokenBeginPos = -1; ! char c = readChar(); ! tokenBeginBuf = curBuf; ! tokenBeginPos = curBuf.curPos; ! return c; ! } ! private final void UpdateLineColumn (char c) ! { ! column++; ! if (prevCharIsLF) ! { ! prevCharIsLF = false; line += (column = 1); ! } ! else if (prevCharIsCR) ! { ! prevCharIsCR = false; ! if (c == '\n') ! { ! prevCharIsLF = true; ! } ! else ! line += (column = 1); ! } ! switch (c) ! { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! case '\t': ! column--; ! column += (8 - (column & 07)); ! break; ! default : ! break; ! } ! curBuf.bufline[curBuf.curPos] = line; ! curBuf.bufcolumn[curBuf.curPos] = column; ! } ! public final char readChar () throws java.io.IOException ! { ! // When we hit the end of the buffer, if we're backing up, we just ! // swap, if we're not, we fill. ! if (++curBuf.curPos >= curBuf.dataLen) ! { ! if (backupChars > 0) ! { ! --curBuf.curPos; ! swapBuf(); ! } ! else ! FillBuff(); ! } ! ; ! // Don't mask off the high byte ! char c = curBuf.buffer[curBuf.curPos]; ! // No need to update line numbers if we've already processed this char ! if (backupChars > 0) ! --backupChars; ! else ! UpdateLineColumn(c); ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn () ! { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine () ! { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getEndColumn () ! { ! return curBuf.bufcolumn[curBuf.curPos]; ! } ! public final int getEndLine () ! { ! return curBuf.bufline[curBuf.curPos]; ! } ! public final int getBeginColumn () ! { ! return tokenBeginBuf.bufcolumn[tokenBeginPos]; ! } ! public final int getBeginLine () ! { ! return tokenBeginBuf.bufline[tokenBeginPos]; ! } ! public final void backup (int amount) ! { ! backupChars += amount; ! if (curBuf.curPos - amount < 0) ! { ! int addlChars = amount - (inputStreamClosed ? 0 : 1) - curBuf.curPos; ! curBuf.curPos = 0; ! swapBuf(); ! curBuf.curPos = curBuf.dataLen - addlChars - 1; ! } ! else ! { ! curBuf.curPos -= amount; ! } ! } ! public BackupCharStream (java.io.Reader dstream) ! { ! this(dstream, 1, 1, 4096); ! } ! public BackupCharStream (java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) ! { ! ReInit(dstream, startline, startcolumn, buffersize); ! } ! public BackupCharStream (java.io.Reader dstream, int startline, ! int startcolumn) ! { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit (java.io.Reader dstream, int startline, ! int startcolumn, int buffersize) ! { ! inputStream = dstream; ! inputStreamClosed = false; ! line = startline; ! column = startcolumn - 1; ! if (bufA == null || bufA.size != buffersize) ! bufA = new Buffer(buffersize); ! if (bufB == null || bufB.size != buffersize) ! bufB = new Buffer(buffersize); ! curBuf = bufA; ! otherBuf = bufB; ! curBuf.curPos = otherBuf.dataLen = -1; ! curBuf.dataLen = otherBuf.dataLen = 0; ! prevCharIsLF = prevCharIsCR = false; ! tokenBeginPos = -1; ! tokenBeginBuf = null; ! backupChars = 0; ! } ! public void ReInit (java.io.Reader dstream, int startline, ! int startcolumn) ! { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public void ReInit (java.io.Reader dstream) ! { ! ReInit(dstream, 1, 1, 4096); ! } ! public BackupCharStream (java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) ! { ! this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); ! } ! public BackupCharStream (java.io.InputStream dstream, int startline, ! int startcolumn) ! { ! this(dstream, startline, startcolumn, 4096); ! } ! public void ReInit (java.io.InputStream dstream, int startline, ! int startcolumn, int buffersize) ! { ! ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, ! 4096); ! } ! public void ReInit (java.io.InputStream dstream, int startline, ! int startcolumn) ! { ! ReInit(dstream, startline, startcolumn, 4096); ! } ! public final String GetImage () ! { ! String ret; ! if (tokenBeginBuf == curBuf) ! { ! ret = new String(curBuf.buffer, tokenBeginPos, ! curBuf.curPos - tokenBeginPos + 1); ! } ! else ! { ! ret = new String(otherBuf.buffer, tokenBeginPos, ! otherBuf.dataLen - tokenBeginPos); ! if (curBuf.curPos < curBuf.dataLen) ! ret += new String(curBuf.buffer, 0, curBuf.curPos + 1); ! } ! return ret; ! } ! public final char[] GetSuffix (int len) ! { ! char[] ret = new char[len]; ! if ((curBuf.curPos + 1) >= len) ! System.arraycopy(curBuf.buffer, curBuf.curPos - len + 1, ret, 0, len); ! else ! { ! if (otherBuf.dataLen >= len - curBuf.curPos - 1) ! System.arraycopy(otherBuf.buffer, ! otherBuf.dataLen - (len - curBuf.curPos - 1), ret, 0, ! len - curBuf.curPos - 1); ! System.arraycopy(curBuf.buffer, 0, ret, len - curBuf.curPos - 1, ! curBuf.curPos + 1); ! } ! return null; ! } ! public void Done () ! { ! bufA = bufB = curBuf = otherBuf = null; ! } } Index: CharStream.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/parser/CharStream.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CharStream.java 11 Nov 2002 04:53:11 -0000 1.4 --- CharStream.java 12 Jun 2003 00:47:46 -0000 1.5 *************** *** 17,110 **** */ ! public interface CharStream { ! /** ! * Returns the next character from the selected input. The method ! * of selecting the input is the responsibility of the class ! * implementing this interface. Can throw any java.io.IOException. ! */ ! char readChar() throws java.io.IOException; ! /** ! * Returns the column position of the character last read. ! * @deprecated ! * @see #getEndColumn ! */ ! int getColumn(); ! /** ! * Returns the line number of the character last read. ! * @deprecated ! * @see #getEndLine ! */ ! int getLine(); ! /** ! * Returns the column number of the last character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getEndColumn(); ! /** ! * Returns the line number of the last character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getEndLine(); ! /** ! * Returns the column number of the first character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getBeginColumn(); ! /** ! * Returns the line number of the first character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getBeginLine(); ! /** ! * Backs up the input stream by amount steps. Lexer calls this method if it ! * had already read some characters, but could not use them to match a ! * (longer) token. So, they will be used again as the prefix of the next ! * token and it is the implemetation's responsibility to do this right. ! */ ! void backup(int amount); ! /** ! * Returns the next character that marks the beginning of the next token. ! * All characters must remain in the buffer between two successive calls ! * to this method to implement backup correctly. ! */ ! char BeginToken() throws java.io.IOException; ! /** ! * Returns a string made up of characters from the marked token beginning ! * to the current buffer position. Implementations have the choice of returning ! * anything that they want to. For example, for efficiency, one might decide ! * to just return null, which is a valid implementation. ! */ ! String GetImage(); ! /** ! * Returns an array of characters that make up the suffix of length 'len' for ! * the currently matched token. This is used to build up the matched string ! * for use in actions in the case of MORE. A simple and inefficient ! * implementation of this is as follows : ! * ! * { ! * String t = GetImage(); ! * return t.substring(t.length() - len, t.length()).toCharArray(); ! * } ! */ ! char[] GetSuffix(int len); ! /** ! * The lexer calls this function to indicate that it is done with the stream ! * and hence implementations can free any resources held by this class. ! * Again, the body of this function can be just empty and it will not ! * affect the lexer's operation. ! */ ! void Done(); } --- 17,111 ---- */ ! public interface CharStream ! { ! /** ! * Returns the next character from the selected input. The method ! * of selecting the input is the responsibility of the class ! * implementing this interface. Can throw any java.io.IOException. ! */ ! char readChar () throws java.io.IOException; ! /** ! * Returns the column position of the character last read. ! * @deprecated ! * @see #getEndColumn ! */ ! int getColumn (); ! /** ! * Returns the line number of the character last read. ! * @deprecated ! * @see #getEndLine ! */ ! int getLine (); ! /** ! * Returns the column number of the last character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getEndColumn (); ! /** ! * Returns the line number of the last character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getEndLine (); ! /** ! * Returns the column number of the first character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getBeginColumn (); ! /** ! * Returns the line number of the first character for current token (being ! * matched after the last call to BeginTOken). ! */ ! int getBeginLine (); ! /** ! * Backs up the input stream by amount steps. Lexer calls this method if it ! * had already read some characters, but could not use them to match a ! * (longer) token. So, they will be used again as the prefix of the next ! * token and it is the implemetation's responsibility to do this right. ! */ ! void backup (int amount); ! /** ! * Returns the next character that marks the beginning of the next token. ! * All characters must remain in the buffer between two successive calls ! * to this method to implement backup correctly. ! */ ! char BeginToken () throws java.io.IOException; ! /** ! * Returns a string made up of characters from the marked token beginning ! * to the current buffer position. Implementations have the choice of returning ! * anything that they want to. For example, for efficiency, one might decide ! * to just return null, which is a valid implementation. ! */ ! String GetImage (); ! /** ! * Returns an array of characters that make up the suffix of length 'len' for ! * the currently matched token. This is used to build up the matched string ! * for use in actions in the case of MORE. A simple and inefficient ! * implementation of this is as follows : ! * ! * { ! * String t = GetImage(); ! * return t.substring(t.length() - len, t.length()).toCharArray(); ! * } ! */ ! char[] GetSuffix (int len); ! /** ! * The lexer calls this function to indicate that it is done with the stream ! * and hence implementations can free any resources held by this class. ! * Again, the body of this function can be just empty and it will not ! * affect the lexer's operation. ! */ ! void Done (); } Index: ParseException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/parser/ParseException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParseException.java 11 Jun 2002 17:43:22 -0000 1.3 --- ParseException.java 12 Jun 2003 00:47:46 -0000 1.4 *************** *** 11,196 **** * mechanisms so long as you retain the public fields. */ ! public class ParseException extends org.webmacro.RethrowableException { ! /** ! * This constructor is used by the method "generateParseException" ! * in the generated parser. Calling this constructor generates ! * a new object of this type with the fields "currentToken", ! * "expectedTokenSequences", and "tokenImage" set. The boolean ! * flag "specialConstructor" is also set to true to indicate that ! * this constructor was used to create this object. ! * This constructor calls its super class with the empty string ! * to force the "toString" method of parent class "Throwable" to ! * print the error message in the form: ! * ParseException: <result of getMessage> ! */ ! public ParseException(Token currentTokenVal, ! int[][] expectedTokenSequencesVal, ! String[] tokenImageVal ! ) { ! super(""); ! specialConstructor = true; ! currentToken = currentTokenVal; ! expectedTokenSequences = expectedTokenSequencesVal; ! tokenImage = tokenImageVal; ! } ! /** ! * The following constructors are for use by you for whatever ! * purpose you can think of. Constructing the exception in this ! * manner makes the exception behave in the normal way - i.e., as ! * documented in the class "Throwable". The fields "errorToken", ! * "expectedTokenSequences", and "tokenImage" do not contain ! * relevant information. The JavaCC generated code does not use ! * these constructors. ! */ ! public ParseException() { ! super(); ! specialConstructor = false; ! } ! public ParseException(String message) { ! super(message); ! specialConstructor = false; ! } ! public ParseException(String message, Exception e) { ! super(message, e); ! specialConstructor = false; ! } ! /** ! * This variable determines which constructor was used to create ! * this object and thereby affects the semantics of the ! * "getMessage" method (see below). ! */ ! protected boolean specialConstructor; ! /** ! * This is the last token that has been consumed successfully. If ! * this object has been created due to a parse error, the token ! * followng this token will (therefore) be the first error token. ! */ ! public Token currentToken; ! /** ! * Each entry in this array is an array of integers. Each array ! * of integers represents a sequence of tokens (by their ordinal ! * values) that is expected at this point of the parse. ! */ ! public int[][] expectedTokenSequences; ! /** ! * This is a reference to the "tokenImage" array of the generated ! * parser within which the parse error occurred. This array is ! * defined in the generated ...Constants interface. ! */ ! public String[] tokenImage; ! /** ! * This method has the standard behavior when this object has been ! * created using the standard constructors. Otherwise, it uses ! * "currentToken" and "expectedTokenSequences" to generate a parse ! * error message and returns it. If this object has been created ! * due to a parse error, and you do not catch it (it gets thrown ! * from the parser), then this method is called during the printing ! * of the final stack trace, and hence the correct error message ! * gets displayed. ! */ ! public String getMessage() { ! if (!specialConstructor) { ! return super.getMessage(); ! } ! String expected = ""; ! int maxSize = 0; ! for (int i = 0; i < expectedTokenSequences.length; i++) { ! if (maxSize < expectedTokenSequences[i].length) { ! maxSize = expectedTokenSequences[i].length; ! } ! for (int j = 0; j < expectedTokenSequences[i].length; j++) { ! expected += tokenImage[expectedTokenSequences[i][j]] + " "; ! } ! if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { ! expected += "..."; ! } ! expected += eol + " "; ! } ! String retval = "Encountered \""; ! Token tok = currentToken.next; ! for (int i = 0; i < maxSize; i++) { ! if (i != 0) retval += " "; ! if (tok.kind == 0) { ! retval += tokenImage[0]; ! break; ! } ! retval += add_escapes(tok.image); ! tok = tok.next; ! } ! retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol; ! if (expectedTokenSequences.length == 1) { ! retval += "Was expecting:" + eol + " "; ! } ! else { ! retval += "Was expecting one of:" + eol + " "; ! } ! retval += expected; ! return retval; ! } ! /** ! * The end of line string for this machine. ! */ ! protected String eol = System.getProperty("line.separator", "\n"); ! /** ! * Used to convert raw characters to their escaped version ! * when these raw version cannot be used as part of an ASCII ! * string literal. ! */ ! protected String add_escapes(String str) { ! StringBuffer retval = new StringBuffer(); ! char ch; ! for (int i = 0; i < str.length(); i++) { ! switch (str.charAt(i)) { ! case 0: ! continue; ! case '\b': ! retval.append("\\b"); ! continue; ! case '\t': ! retval.append("\\t"); ! continue; ! case '\n': ! retval.append("\\n"); ! continue; ! case '\f': ! retval.append("\\f"); ! continue; ! case '\r': ! retval.append("\\r"); ! continue; ! case '\"': ! retval.append("\\\""); ! continue; ! case '\'': ! retval.append("\\\'"); ! continue; ! case '\\': ! retval.append("\\\\"); ! continue; ! default: ! if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { ! String s = "0000" + Integer.toString(ch, 16); ! retval.append("\\u" + s.substring(s.length() - 4, s.length())); ! } ! else { ! retval.append(ch); ! } ! continue; ! } ! } ! return retval.toString(); ! } } --- 11,216 ---- * mechanisms so long as you retain the public fields. */ ! public class ParseException extends org.webmacro.RethrowableException ! { ! /** ! * This constructor is used by the method "generateParseException" ! * in the generated parser. Calling this constructor generates ! * a new object of this type with the fields "currentToken", ! * "expectedTokenSequences", and "tokenImage" set. The boolean ! * flag "specialConstructor" is also set to true to indicate that ! * this constructor was used to create this object. ! * This constructor calls its super class with the empty string ! * to force the "toString" method of parent class "Throwable" to ! * print the error message in the form: ! * ParseException: <result of getMessage> ! */ ! public ParseException (Token currentTokenVal, ! int[][] expectedTokenSequencesVal, ! String[] tokenImageVal ! ) ! { ! super(""); ! specialConstructor = true; ! currentToken = currentTokenVal; ! expectedTokenSequences = expectedTokenSequencesVal; ! tokenImage = tokenImageVal; ! } ! /** ! * The following constructors are for use by you for whatever ! * purpose you can think of. Constructing the exception in this ! * manner makes the exception behave in the normal way - i.e., as ! * documented in the class "Throwable". The fields "errorToken", ! * "expectedTokenSequences", and "tokenImage" do not contain ! * relevant information. The JavaCC generated code does not use ! * these constructors. ! */ ! public ParseException () ! { ! super(); ! specialConstructor = false; ! } ! public ParseException (String message) ! { ! super(message); ! specialConstructor = false; ! } ! public ParseException (String message, Exception e) ! { ! super(message, e); ! specialConstructor = false; ! } ! /** ! * This variable determines which constructor was used to create ! * this object and thereby affects the semantics of the ! * "getMessage" method (see below). ! */ ! protected boolean specialConstructor; ! /** ! * This is the last token that has been consumed successfully. If ! * this object has been created due to a parse error, the token ! * followng this token will (therefore) be the first error token. ! */ ! public Token currentToken; ! /** ! * Each entry in this array is an array of integers. Each array ! * of integers represents a sequence of tokens (by their ordinal ! * values) that is expected at this point of the parse. ! */ ! public int[][] expectedTokenSequences; ! /** ! * This is a reference to the "tokenImage" array of the generated ! * parser within which the parse error occurred. This array is ! * defined in the generated ...Constants interface. ! */ ! public String[] tokenImage; ! /** ! * This method has the standard behavior when this object has been ! * created using the standard constructors. Otherwise, it uses ! * "currentToken" and "expectedTokenSequences" to generate a parse ! * error message and returns it. If this object has been created ! * due to a parse error, and you do not catch it (it gets thrown ! * from the parser), then this method is called during the printing ! * of the final stack trace, and hence the correct error message ! * gets displayed. ! */ ! public String getMessage () ! { ! if (!specialConstructor) ! { ! return super.getMessage(); ! } ! String expected = ""; ! int maxSize = 0; ! for (int i = 0; i < expectedTokenSequences.length; i++) ! { ! if (maxSize < expectedTokenSequences[i].length) ! { ! maxSize = expectedTokenSequences[i].length; ! } ! for (int j = 0; j < expectedTokenSequences[i].length; j++) ! { ! expected += tokenImage[expectedTokenSequences[i][j]] + " "; ! } ! if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) ! { ! expected += "..."; ! } ! expected += eol + " "; ! } ! String retval = "Encountered \""; ! Token tok = currentToken.next; ! for (int i = 0; i < maxSize; i++) ! { ! ... [truncated message content] |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/resource In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/resource Modified Files: AbstractTemplateLoader.java BrokerTemplateLoader.java BrokerTemplateProvider.java BrokerTemplateProviderHelper.java CacheElement.java CacheManager.java CacheReloadContext.java CachingProvider.java ClassPathTemplateLoader.java ConfigProvider.java DefaultTemplateLoaderFactory.java DelegatingTemplateProvider.java FileTemplateLoader.java GenerationalCacheManager.java HMapCacheManager.java InvalidResourceException.java ReloadDelayDecorator.java ResourceLoader.java SMapCacheManager.java ServletContextTemplateLoader.java StaticIdentityCacheManager.java StaticSMapCacheManager.java TemplateLoader.java TemplateLoaderFactory.java TemplateLoaderHelper.java TemplatePathTemplateLoader.java TemplateProvider.java TimedReloadContext.java TrivialCacheManager.java URLTemplate.java URLTemplateProvider.java UrlProvider.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: AbstractTemplateLoader.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/AbstractTemplateLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractTemplateLoader.java 11 Jun 2002 17:43:22 -0000 1.3 --- AbstractTemplateLoader.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 33,57 **** * @author Sebastian Kanthak <ska...@mu...> */ ! public abstract class AbstractTemplateLoader implements TemplateLoader { ! /** Our broker */ ! protected Broker broker; ! /** Log to use */ ! protected Log log; ! /** Helper class for loading templates from files or URLs */ ! protected TemplateLoaderHelper helper; ! /** ! * Sets up broker, reloadDelayDecorator and log. ! * Don't forget to call super.init() if you override this ! * method. ! */ ! public void init(Broker b, Settings config) throws InitException { ! this.broker = b; ! log = b.getLog("resource", "Loading templates"); ! helper = new TemplateLoaderHelper(); ! helper.init(b, config); ! } } --- 33,59 ---- * @author Sebastian Kanthak <ska...@mu...> */ ! public abstract class AbstractTemplateLoader implements TemplateLoader ! { ! /** Our broker */ ! protected Broker broker; ! /** Log to use */ ! protected Log log; ! /** Helper class for loading templates from files or URLs */ ! protected TemplateLoaderHelper helper; ! /** ! * Sets up broker, reloadDelayDecorator and log. ! * Don't forget to call super.init() if you override this ! * method. ! */ ! public void init (Broker b, Settings config) throws InitException ! { ! this.broker = b; ! log = b.getLog("resource", "Loading templates"); ! helper = new TemplateLoaderHelper(); ! helper.init(b, config); ! } } Index: BrokerTemplateLoader.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/BrokerTemplateLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BrokerTemplateLoader.java 11 Nov 2002 19:22:37 -0000 1.3 --- BrokerTemplateLoader.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 22,47 **** package org.webmacro.resource; - import java.net.URL; - import org.webmacro.ResourceException; import org.webmacro.Template; ! public class BrokerTemplateLoader extends AbstractTemplateLoader { ! public void setConfig(String config) { ! // ignore config ! if (config != null && config.length() > 0) { ! if (log.loggingWarning()) { ! log.warning("BrokerTemplateProvider: Ignoring configuration options " + config); ! } ! } ! } ! public final Template load(String query, CacheElement ce) throws ResourceException { ! URL url = broker.getTemplate(query); ! if (url != null && log.loggingDebug()) { ! log.debug("BrokerTemplateLoader: Found Template " + url.toString()); ! } ! return (url != null) ? helper.load(url, ce) : null; ! } } --- 22,53 ---- package org.webmacro.resource; import org.webmacro.ResourceException; import org.webmacro.Template; ! import java.net.URL; ! public class BrokerTemplateLoader extends AbstractTemplateLoader ! { ! public void setConfig (String config) ! { ! // ignore config ! if (config != null && config.length() > 0) ! { ! if (log.loggingWarning()) ! { ! log.warning("BrokerTemplateProvider: Ignoring configuration options " + config); ! } ! } ! } ! ! public final Template load (String query, CacheElement ce) throws ResourceException ! { ! URL url = broker.getTemplate(query); ! if (url != null && log.loggingDebug()) ! { ! log.debug("BrokerTemplateLoader: Found Template " + url.toString()); ! } ! return (url != null) ? helper.load(url, ce) : null; ! } } Index: BrokerTemplateProvider.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/BrokerTemplateProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BrokerTemplateProvider.java 12 Jun 2002 17:35:34 -0000 1.4 --- BrokerTemplateProvider.java 12 Jun 2003 00:47:47 -0000 1.5 *************** *** 37,63 **** * @see BrokerTemplateProviderHelper */ ! final public class BrokerTemplateProvider extends CachingProvider { ! private BrokerTemplateProviderHelper _helper; ! private Log _log; ! public void init(Broker b, Settings config) throws InitException { ! super.init(b, config); ! _helper = new BrokerTemplateProviderHelper(); ! _helper.init(b, config); ! _helper.setReload(_cacheSupportsReload); ! _log = b.getLog("resource", "Object loading and caching"); ! } ! final public String getType() { ! return "template"; ! } ! final public Object load(String name, CacheElement ce) ! throws ResourceException { ! if (_log.loggingInfo()) ! _log.info("Loading template: " + name); ! return _helper.load(name, ce); ! } } --- 37,67 ---- * @see BrokerTemplateProviderHelper */ ! final public class BrokerTemplateProvider extends CachingProvider ! { ! private BrokerTemplateProviderHelper _helper; ! private Log _log; ! public void init (Broker b, Settings config) throws InitException ! { ! super.init(b, config); ! _helper = new BrokerTemplateProviderHelper(); ! _helper.init(b, config); ! _helper.setReload(_cacheSupportsReload); ! _log = b.getLog("resource", "Object loading and caching"); ! } ! final public String getType () ! { ! return "template"; ! } ! final public Object load (String name, CacheElement ce) ! throws ResourceException ! { ! if (_log.loggingInfo()) ! _log.info("Loading template: " + name); ! return _helper.load(name, ce); ! } } Index: BrokerTemplateProviderHelper.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/BrokerTemplateProviderHelper.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BrokerTemplateProviderHelper.java 12 Jun 2002 17:35:34 -0000 1.10 --- BrokerTemplateProviderHelper.java 12 Jun 2003 00:47:47 -0000 1.11 *************** *** 24,30 **** package org.webmacro.resource; - import java.io.*; - import java.net.URL; - import org.webmacro.*; import org.webmacro.engine.FileTemplate; --- 24,27 ---- *************** *** 33,36 **** --- 30,37 ---- import org.webmacro.util.Settings; + import java.io.File; + import java.io.IOException; + import java.net.URL; + /** * This class does the actual work of retrieving templates using the *************** *** 44,181 **** */ final public class BrokerTemplateProviderHelper ! implements ResourceLoader { ! // INITIALIZATION ! private Broker _broker; ! private int _cacheDuration; ! private Log _log; ! private boolean _cacheSupportsReload = true; ! private ReloadDelayDecorator reloadDelay; ! private static class UrlReloadContext extends CacheReloadContext { ! private long lastModified; ! private URL url; ! public UrlReloadContext(URL url, long lastModified) { ! this.url = url; ! this.lastModified = lastModified; ! } ! public boolean shouldReload() { ! return (lastModified != UrlProvider.getUrlLastModified(url)); ! } ! } ! /** ! * Create a new TemplateProvider that uses the specified directory ! * as the source for Template objects that it will return ! * @exception InitException provider failed to initialize ! */ ! public void init(Broker b, Settings config) throws InitException { ! _broker = b; ! _log = b.getLog("resource", "Object loading and caching"); ! _cacheDuration = config.getIntegerSetting("TemplateExpireTime", 0); ! reloadDelay = new ReloadDelayDecorator(); ! reloadDelay.init(b, config); ! } ! /** ! * Grab a template based on its name. ! */ ! final public Object load(String name, CacheElement ce) ! throws ResourceException { ! Template t = null; ! URL tUrl; ! Object ret = null; ! tUrl = findTemplate(name); ! try { ! String protocol = tUrl.getProtocol(); ! // Treat files as a special case ! if (protocol.equals("file")) { ! File f = new File(tUrl.getFile()); ! long lastMod = f.lastModified(); ! t = new FileTemplate(_broker, f); ! t.parse(); ! ret = t; ! if (_cacheSupportsReload) { ! CacheReloadContext reloadContext ! = new TemplateProvider.FTReloadContext(f, lastMod); ! ce.setReloadContext(reloadDelay.decorate("file", reloadContext)); } ! } ! else { ! long lastMod = UrlProvider.getUrlLastModified(tUrl); ! String encoding = tUrl.openConnection().getContentEncoding(); ! // encoding may be null. Will be handled by StreamTemplate ! t = new StreamTemplate(_broker, ! UrlProvider.getUrlInputStream(tUrl), ! encoding); ! t.setName(name); ! t.parse(); ! ret = t; ! if (_cacheSupportsReload) { ! CacheReloadContext reloadContext = new UrlReloadContext(tUrl, lastMod); ! ce.setReloadContext(reloadDelay.decorate(tUrl.getProtocol(), ! reloadContext)); } ! } ! } ! catch (NullPointerException npe) { ! _log.warning("BrokerTemplateProvider: Template not found: " + name); ! } ! catch (ParseException e) { ! _log.warning("BrokerTemplateProvider: Error occured while parsing " ! + name, e); ! throw new InvalidResourceException("Error parsing template " + name, ! e); ! } ! catch (IOException e) { ! _log.warning("BrokerTemplateProvider: IOException while parsing " ! + name, e); ! throw new InvalidResourceException("Error parsing template " + name, ! e); ! } ! catch (Exception e) { ! _log.warning("BrokerTemplateProvider: Error occured while fetching " ! + name, e); ! throw new ResourceException("Error parsing template " + name, e); ! } ! if (ret == null) ! throw new NotFoundException(this + " could not locate " + name); ! return ret; ! } ! /** We don't implement this one */ ! public Object load(Object query, CacheElement ce) ! throws ResourceException { ! throw new ResourceException("CachingProvider: load(Object) not supported, use load(String)"); ! } ! public void setReload(boolean reload) { ! _cacheSupportsReload = reload; ! } ! // IMPLEMENTATION ! /** ! * @param fileName the template filename to find ! * @return a File object that represents the specified template file. ! * @return null if template file cannot be found. */ ! final private URL findTemplate(String fileName) { ! if (_log.loggingDebug()) ! _log.debug("Looking for template in class path: " + fileName); ! URL u = _broker.getTemplate(fileName); ! if (u != null) ! if (_log.loggingDebug()) ! _log.debug("BrokerTemplateProvider: Found " + fileName ! + " at " + u.toString()); ! return u; ! } } --- 45,200 ---- */ final public class BrokerTemplateProviderHelper ! implements ResourceLoader ! { ! // INITIALIZATION ! private Broker _broker; ! private int _cacheDuration; ! private Log _log; ! private boolean _cacheSupportsReload = true; ! private ReloadDelayDecorator reloadDelay; ! private static class UrlReloadContext extends CacheReloadContext ! { ! private long lastModified; ! private URL url; ! public UrlReloadContext (URL url, long lastModified) ! { ! this.url = url; ! this.lastModified = lastModified; ! } ! public boolean shouldReload () ! { ! return (lastModified != UrlProvider.getUrlLastModified(url)); ! } ! } ! /** ! * Create a new TemplateProvider that uses the specified directory ! * as the source for Template objects that it will return ! * @exception InitException provider failed to initialize ! */ ! public void init (Broker b, Settings config) throws InitException ! { ! _broker = b; ! _log = b.getLog("resource", "Object loading and caching"); ! _cacheDuration = config.getIntegerSetting("TemplateExpireTime", 0); ! reloadDelay = new ReloadDelayDecorator(); ! reloadDelay.init(b, config); ! } ! /** ! * Grab a template based on its name. ! */ ! final public Object load (String name, CacheElement ce) ! throws ResourceException ! { ! Template t = null; ! URL tUrl; ! Object ret = null; ! tUrl = findTemplate(name); ! try ! { ! String protocol = tUrl.getProtocol(); ! // Treat files as a special case ! if (protocol.equals("file")) ! { ! File f = new File(tUrl.getFile()); ! long lastMod = f.lastModified(); ! t = new FileTemplate(_broker, f); ! t.parse(); ! ret = t; ! if (_cacheSupportsReload) ! { ! CacheReloadContext reloadContext ! = new TemplateProvider.FTReloadContext(f, lastMod); ! ce.setReloadContext(reloadDelay.decorate("file", reloadContext)); ! } } ! else ! { ! long lastMod = UrlProvider.getUrlLastModified(tUrl); ! String encoding = tUrl.openConnection().getContentEncoding(); ! // encoding may be null. Will be handled by StreamTemplate ! t = new StreamTemplate(_broker, ! UrlProvider.getUrlInputStream(tUrl), ! encoding); ! t.setName(name); ! t.parse(); ! ret = t; ! if (_cacheSupportsReload) ! { ! CacheReloadContext reloadContext = new UrlReloadContext(tUrl, lastMod); ! ce.setReloadContext(reloadDelay.decorate(tUrl.getProtocol(), ! reloadContext)); ! } } ! } ! catch (NullPointerException npe) ! { ! _log.warning("BrokerTemplateProvider: Template not found: " + name); ! } ! catch (ParseException e) ! { ! _log.warning("BrokerTemplateProvider: Error occured while parsing " ! + name, e); ! throw new InvalidResourceException("Error parsing template " + name, ! e); ! } ! catch (IOException e) ! { ! _log.warning("BrokerTemplateProvider: IOException while parsing " ! + name, e); ! throw new InvalidResourceException("Error parsing template " + name, ! e); ! } ! catch (Exception e) ! { ! _log.warning("BrokerTemplateProvider: Error occured while fetching " ! + name, e); ! throw new ResourceException("Error parsing template " + name, e); ! } ! if (ret == null) ! throw new NotFoundException(this + " could not locate " + name); ! return ret; ! } ! /** We don't implement this one */ ! public Object load (Object query, CacheElement ce) ! throws ResourceException ! { ! throw new ResourceException("CachingProvider: load(Object) not supported, use load(String)"); ! } ! public void setReload (boolean reload) ! { ! _cacheSupportsReload = reload; ! } ! // IMPLEMENTATION ! /** ! * @param fileName the template filename to find ! * @return a File object that represents the specified template file. ! * @return null if template file cannot be found. */ ! final private URL findTemplate (String fileName) ! { ! if (_log.loggingDebug()) ! _log.debug("Looking for template in class path: " + fileName); ! URL u = _broker.getTemplate(fileName); ! if (u != null) ! if (_log.loggingDebug()) ! _log.debug("BrokerTemplateProvider: Found " + fileName ! + " at " + u.toString()); ! return u; ! } } Index: CacheElement.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/CacheElement.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CacheElement.java 12 Jun 2002 17:35:34 -0000 1.4 --- CacheElement.java 12 Jun 2003 00:47:47 -0000 1.5 *************** *** 32,38 **** */ ! public abstract class CacheElement { ! public void setReloadContext(CacheReloadContext rc) { ! } } --- 32,40 ---- */ ! public abstract class CacheElement ! { ! public void setReloadContext (CacheReloadContext rc) ! { ! } } Index: CacheManager.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/CacheManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CacheManager.java 11 Jun 2002 17:43:22 -0000 1.3 --- CacheManager.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 39,90 **** */ ! public interface CacheManager { ! /** ! * Same as defined in Provider, except with an additional type ! * parameter so it knows what type of resource it is caching ! */ ! public void init(Broker b, Settings config, String resourceType) ! throws InitException; ! /** ! * Same as defined in Provider ! */ ! public void flush(); ! /** ! * Same as defined in Provider ! */ ! public void destroy(); ! /** ! * Called to get a resource from the cache. The helper object is used ! * to load the resource if the resource was not in the cache. ! */ ! public Object get(final Object query, ResourceLoader helper) ! throws ResourceException; ! /** ! * Called to get a resource from the cache. Returns null if not present. ! */ ! public Object get(final Object query); ! /** ! * Called to put a resource into the cache. ! */ ! public void put(final Object query, Object resource); ! /** ! * Invalidates an entry in the cache. Depending on the ! * the implementation, the actual removal from the cache ! * may or may not be immediate. ! */ ! public void invalidate(final Object query); ! /** ! * Does this cache manager support reloading of resources if the ! * underlying resource has changed? ! */ ! public boolean supportsReload(); } --- 39,91 ---- */ ! public interface CacheManager ! { ! /** ! * Same as defined in Provider, except with an additional type ! * parameter so it knows what type of resource it is caching ! */ ! public void init (Broker b, Settings config, String resourceType) ! throws InitException; ! /** ! * Same as defined in Provider ! */ ! public void flush (); ! /** ! * Same as defined in Provider ! */ ! public void destroy (); ! /** ! * Called to get a resource from the cache. The helper object is used ! * to load the resource if the resource was not in the cache. ! */ ! public Object get (final Object query, ResourceLoader helper) ! throws ResourceException; ! /** ! * Called to get a resource from the cache. Returns null if not present. ! */ ! public Object get (final Object query); ! /** ! * Called to put a resource into the cache. ! */ ! public void put (final Object query, Object resource); ! /** ! * Invalidates an entry in the cache. Depending on the ! * the implementation, the actual removal from the cache ! * may or may not be immediate. ! */ ! public void invalidate (final Object query); ! /** ! * Does this cache manager support reloading of resources if the ! * underlying resource has changed? ! */ ! public boolean supportsReload (); } Index: CacheReloadContext.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/CacheReloadContext.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CacheReloadContext.java 11 Jun 2002 17:43:22 -0000 1.3 --- CacheReloadContext.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 33,47 **** */ ! public abstract class CacheReloadContext { ! /** ! * The CacheManager calls shouldReload to ask the reference whether ! * it has changed since we loaded it. Subclasses should define an ! * implementation if this if it makes sense to. Otherwise, the default ! * returns false, which means the item is replaced when it expires from ! * the cache. ! */ ! public boolean shouldReload() { ! return false; ! } } --- 33,49 ---- */ ! public abstract class CacheReloadContext ! { ! /** ! * The CacheManager calls shouldReload to ask the reference whether ! * it has changed since we loaded it. Subclasses should define an ! * implementation if this if it makes sense to. Otherwise, the default ! * returns false, which means the item is replaced when it expires from ! * the cache. ! */ ! public boolean shouldReload () ! { ! return false; ! } } Index: CachingProvider.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/CachingProvider.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CachingProvider.java 11 Jun 2002 17:43:22 -0000 1.18 --- CachingProvider.java 12 Jun 2003 00:47:47 -0000 1.19 *************** *** 37,118 **** abstract public class CachingProvider implements Provider, ! ResourceLoader { ! private CacheManager _cache; ! private Log _log; ! protected boolean _cacheSupportsReload; ! public CachingProvider() { ! } ! /** ! * If you override this method be sure and call super.init(...) ! */ ! public void init(Broker b, Settings config) throws InitException { ! String cacheManager; ! _log = b.getLog("resource", "Object loading and caching"); ! cacheManager = b.getSetting("CachingProvider." + getType() ! + ".CacheManager"); ! if (cacheManager == null) ! cacheManager = b.getSetting("CachingProvider.*.CacheManager"); ! if (cacheManager == null || cacheManager.equals("")) { ! _log.info("CachingProvider: No cache manager specified for " ! + getType() + ", using TrivialCacheManager"); ! _cache = new TrivialCacheManager(); ! } ! else { ! try { ! _cache = (CacheManager) b.classForName(cacheManager).newInstance(); ! } ! catch (Exception e) { ! _log.warning("Unable to load cache manager " + cacheManager ! + " for resource type " + getType() ! + ", using TrivialCacheManager. Reason:\n" + e); _cache = new TrivialCacheManager(); ! } ! } ! _cache.init(b, config, getType()); ! _cacheSupportsReload = _cache.supportsReload(); ! } ! /** ! * Clear the cache. If you override this method be sure ! * and call super.flush(). ! */ ! public void flush() { ! _cache.flush(); ! } ! /** ! * Close down the provider. If you override this method be ! * sure and call super.destroy(). ! */ ! public void destroy() { ! _cache.destroy(); ! } ! /** ! * Get the object associated with the specific query, using the ! * specified cache manager. ! */ ! public Object get(String query) throws ResourceException { ! return _cache.get(query, this); ! } ! /* ! * Delegates to ResourceLoader implementers the load operation ! * by casting the query as a string and invoking the ! * implemented method. ! */ ! public Object load(Object query, CacheElement ce) ! throws ResourceException { ! return ((ResourceLoader) this).load((String) query, ce); ! } ! public String toString() { ! return "CachingProvider(type = " + getType() + ")"; ! } --- 37,130 ---- abstract public class CachingProvider implements Provider, ! ResourceLoader ! { ! private CacheManager _cache; ! private Log _log; ! protected boolean _cacheSupportsReload; ! public CachingProvider () ! { ! } ! /** ! * If you override this method be sure and call super.init(...) ! */ ! public void init (Broker b, Settings config) throws InitException ! { ! String cacheManager; ! _log = b.getLog("resource", "Object loading and caching"); ! cacheManager = b.getSetting("CachingProvider." + getType() ! + ".CacheManager"); ! if (cacheManager == null) ! cacheManager = b.getSetting("CachingProvider.*.CacheManager"); ! if (cacheManager == null || cacheManager.equals("")) ! { ! _log.info("CachingProvider: No cache manager specified for " ! + getType() + ", using TrivialCacheManager"); _cache = new TrivialCacheManager(); ! } ! else ! { ! try ! { ! _cache = (CacheManager) b.classForName(cacheManager).newInstance(); ! } ! catch (Exception e) ! { ! _log.warning("Unable to load cache manager " + cacheManager ! + " for resource type " + getType() ! + ", using TrivialCacheManager. Reason:\n" + e); ! _cache = new TrivialCacheManager(); ! } ! } ! _cache.init(b, config, getType()); ! _cacheSupportsReload = _cache.supportsReload(); ! } ! /** ! * Clear the cache. If you override this method be sure ! * and call super.flush(). ! */ ! public void flush () ! { ! _cache.flush(); ! } ! /** ! * Close down the provider. If you override this method be ! * sure and call super.destroy(). ! */ ! public void destroy () ! { ! _cache.destroy(); ! } ! /** ! * Get the object associated with the specific query, using the ! * specified cache manager. ! */ ! public Object get (String query) throws ResourceException ! { ! return _cache.get(query, this); ! } ! /* ! * Delegates to ResourceLoader implementers the load operation ! * by casting the query as a string and invoking the ! * implemented method. ! */ ! public Object load (Object query, CacheElement ce) ! throws ResourceException ! { ! return ((ResourceLoader) this).load((String) query, ce); ! } ! public String toString () ! { ! return "CachingProvider(type = " + getType() + ")"; ! } Index: ClassPathTemplateLoader.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/ClassPathTemplateLoader.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ClassPathTemplateLoader.java 27 Dec 2002 23:36:37 -0000 1.6 --- ClassPathTemplateLoader.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 22,27 **** package org.webmacro.resource; - import java.net.URL; - import org.webmacro.Broker; import org.webmacro.InitException; --- 22,25 ---- *************** *** 30,33 **** --- 28,33 ---- import org.webmacro.util.Settings; + import java.net.URL; + /** * Implementation of TemplateLoader that loads template from the classpath. *************** *** 40,80 **** * @author Sebastian Kanthak (seb...@mu...) */ ! public class ClassPathTemplateLoader extends AbstractTemplateLoader { ! private ClassLoader loader; ! private String path; ! public void init(Broker broker, Settings config) throws InitException { ! super.init(broker, config); ! loader = broker.getClassLoader(); ! } ! public void setConfig(String config) { ! // as we'll later use this as a prefix, it should end with a slash ! if (config.length() > 0 && !config.endsWith("/")) { ! if (log.loggingInfo()) ! log.info("ClassPathTemplateLoader: appending \"/\" to path " + config); ! config = config.concat("/"); ! } ! // It isn't clear from the javadocs, whether ClassLoader.getResource() ! // needs a starting slash, so won't add one at the moment. Even worse, ! // most class-loaders require you to _not have_ a slash, so we'll ! // remove it, if it exists ! if (config.startsWith("/")) { ! config = config.substring(1); ! } ! this.path = config; ! } ! public Template load(String query, CacheElement ce) throws ResourceException { ! if (query.startsWith("/")) { ! query = query.substring(1); ! } ! URL url = loader.getResource(path.concat(query)); ! if (url != null && log.loggingDebug()) { ! log.debug("ClassPathTemplateProvider: Found Template " + url.toString()); ! } ! return (url != null) ? helper.load(url, ce) : null; ! } } --- 40,88 ---- * @author Sebastian Kanthak (seb...@mu...) */ ! public class ClassPathTemplateLoader extends AbstractTemplateLoader ! { ! private ClassLoader loader; ! private String path; ! public void init (Broker broker, Settings config) throws InitException ! { ! super.init(broker, config); ! loader = broker.getClassLoader(); ! } ! public void setConfig (String config) ! { ! // as we'll later use this as a prefix, it should end with a slash ! if (config.length() > 0 && !config.endsWith("/")) ! { ! if (log.loggingInfo()) ! log.info("ClassPathTemplateLoader: appending \"/\" to path " + config); ! config = config.concat("/"); ! } ! // It isn't clear from the javadocs, whether ClassLoader.getResource() ! // needs a starting slash, so won't add one at the moment. Even worse, ! // most class-loaders require you to _not have_ a slash, so we'll ! // remove it, if it exists ! if (config.startsWith("/")) ! { ! config = config.substring(1); ! } ! this.path = config; ! } ! public Template load (String query, CacheElement ce) throws ResourceException ! { ! if (query.startsWith("/")) ! { ! query = query.substring(1); ! } ! URL url = loader.getResource(path.concat(query)); ! if (url != null && log.loggingDebug()) ! { ! log.debug("ClassPathTemplateProvider: Found Template " + url.toString()); ! } ! return (url != null) ? helper.load(url, ce) : null; ! } } Index: ConfigProvider.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/ConfigProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConfigProvider.java 11 Jun 2002 17:43:22 -0000 1.5 --- ConfigProvider.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 34,65 **** * passed to it by the broker and returns it. */ ! public class ConfigProvider implements Provider { ! private Settings _config; ! public String getType() { ! return "config"; ! } ! public void init(Broker b, Settings config) throws InitException { ! _config = config; ! if (_config == null) { ! throw new InitException("Attempt to init with no configuration"); ! } ! } ! public void flush() { ! } ! public void destroy() { ! _config = null; ! } ! public Object get(String key) throws NotFoundException { ! Object o = _config.getSetting(key); ! if (o == null) { ! throw new NotFoundException("No config information for: " + key); ! } ! return o; ! } } --- 34,73 ---- * passed to it by the broker and returns it. */ ! public class ConfigProvider implements Provider ! { ! private Settings _config; ! public String getType () ! { ! return "config"; ! } ! public void init (Broker b, Settings config) throws InitException ! { ! _config = config; ! if (_config == null) ! { ! throw new InitException("Attempt to init with no configuration"); ! } ! } ! public void flush () ! { ! } ! public void destroy () ! { ! _config = null; ! } ! public Object get (String key) throws NotFoundException ! { ! Object o = _config.getSetting(key); ! if (o == null) ! { ! throw new NotFoundException("No config information for: " + key); ! } ! return o; ! } } Index: DefaultTemplateLoaderFactory.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/DefaultTemplateLoaderFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DefaultTemplateLoaderFactory.java 11 Jun 2002 17:43:22 -0000 1.4 --- DefaultTemplateLoaderFactory.java 12 Jun 2003 00:47:47 -0000 1.5 *************** *** 39,85 **** * @author Sebastian Kanthak (seb...@mu...) */ ! public class DefaultTemplateLoaderFactory implements TemplateLoaderFactory { ! public TemplateLoader getTemplateLoader(Broker b, String config) throws InitException { ! String protocol; ! String options; ! int pos = config.indexOf(":"); ! if (pos == -1) { ! protocol = "default"; ! options = config; ! } ! else { ! protocol = config.substring(0, pos); ! if (pos + 1 < config.length()) { ! options = config.substring(pos + 1); ! } ! else { ! options = ""; ! } ! } ! String classname = b.getSetting("TemplateLoader.".concat(protocol)); ! if (classname == null || classname.length() == 0) ! throw new InitException("No class found for template loader protocol " + protocol); ! try { ! TemplateLoader loader = (TemplateLoader) b.classForName(classname).newInstance(); ! loader.init(b, b.getSettings()); ! loader.setConfig(options); ! return loader; ! } ! catch (ClassNotFoundException e) { ! throw new InitException("Class " + classname + " for template loader " + protocol + " not found", e); ! } ! catch (InstantiationException e) { ! throw new InitException("Could not instantiate class " + classname + " for template loader " + protocol, e); ! } ! catch (IllegalAccessException e) { ! throw new InitException("Could not instantiate class " + classname + " for template loader " + protocol, e); ! } ! catch (ClassCastException e) { ! throw new InitException("Class " + classname + " for template loader" + protocol + " does not implement " + ! "interface org.webmacro.resource.TemplateLoader", e); ! } ! } } --- 39,96 ---- * @author Sebastian Kanthak (seb...@mu...) */ ! public class DefaultTemplateLoaderFactory implements TemplateLoaderFactory ! { ! public TemplateLoader getTemplateLoader (Broker b, String config) throws InitException ! { ! String protocol; ! String options; ! int pos = config.indexOf(":"); ! if (pos == -1) ! { ! protocol = "default"; ! options = config; ! } ! else ! { ! protocol = config.substring(0, pos); ! if (pos + 1 < config.length()) ! { ! options = config.substring(pos + 1); ! } ! else ! { ! options = ""; ! } ! } ! String classname = b.getSetting("TemplateLoader.".concat(protocol)); ! if (classname == null || classname.length() == 0) ! throw new InitException("No class found for template loader protocol " + protocol); ! try ! { ! TemplateLoader loader = (TemplateLoader) b.classForName(classname).newInstance(); ! loader.init(b, b.getSettings()); ! loader.setConfig(options); ! return loader; ! } ! catch (ClassNotFoundException e) ! { ! throw new InitException("Class " + classname + " for template loader " + protocol + " not found", e); ! } ! catch (InstantiationException e) ! { ! throw new InitException("Could not instantiate class " + classname + " for template loader " + protocol, e); ! } ! catch (IllegalAccessException e) ! { ! throw new InitException("Could not instantiate class " + classname + " for template loader " + protocol, e); ! } ! catch (ClassCastException e) ! { ! throw new InitException("Class " + classname + " for template loader" + protocol + " does not implement " + ! "interface org.webmacro.resource.TemplateLoader", e); ! } ! } } Index: DelegatingTemplateProvider.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/DelegatingTemplateProvider.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DelegatingTemplateProvider.java 11 Jun 2002 17:43:22 -0000 1.7 --- DelegatingTemplateProvider.java 12 Jun 2003 00:47:47 -0000 1.8 *************** *** 24,32 **** package org.webmacro.resource; - import java.util.*; - import org.webmacro.*; import org.webmacro.util.Settings; /** * Alternative implementation of a TemplateProvider that uses TemplateLoaders to do the actual work. --- 24,35 ---- package org.webmacro.resource; import org.webmacro.*; import org.webmacro.util.Settings; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.Collections; + import java.util.List; + /** * Alternative implementation of a TemplateProvider that uses TemplateLoaders to do the actual work. *************** *** 62,151 **** * @author Sebastian Kanthak (seb...@mu...) */ ! public class DelegatingTemplateProvider extends CachingProvider { ! private Broker broker; ! private Log log; ! private TemplateLoaderFactory factory; ! private TemplateLoader[] templateLoaders; ! public void init(Broker broker, Settings config) throws InitException { ! super.init(broker, config); ! this.broker = broker; ! log = broker.getLog("resource", "DelegatingTemplateProvider"); ! String factoryClass = config.getSetting("TemplateLoaderFactory", ""); ! log.info("DelegatingTemplateProvider: Using TemplateLoaderFactory " + factoryClass); ! factory = createFactory(factoryClass); ! List loaders = new ArrayList(); ! // for compatability reasons, check old TemplatePath setting ! if (config.getBooleanSetting("DelegatingTemplateProvider.EmulateTemplatePath", false)) { ! if (config.getSetting("TemplatePath", "").length() > 0) { ! TemplateLoader loader = new TemplatePathTemplateLoader(); ! loader.init(broker, config); ! loader.setConfig(""); ! loaders.add(loader); ! } ! } ! int i = 0; ! String loader = config.getSetting("TemplateLoaderPath.".concat(String.valueOf(i + 1))); ! while (loader != null) { ! loaders.add(factory.getTemplateLoader(broker, loader)); ! i++; ! loader = config.getSetting("TemplateLoaderPath.".concat(String.valueOf(i + 1))); ! } ! templateLoaders = new TemplateLoader[loaders.size()]; ! loaders.toArray(templateLoaders); ! } ! public String getType() { ! return "template"; ! } ! /** ! * Ask all template loaders to load a template from query. ! * Returns the template from the first provider, that returns a non-null value ! * or throws a NotFoundException, if all providers return null. ! */ ! public Object load(String query, CacheElement ce) throws ResourceException { ! for (int i = 0; i < templateLoaders.length; i++) { ! Template t = templateLoaders[i].load(query, ce); ! if (t != null) { ! return t; ! } ! } ! throw new NotFoundException("Could not locate template " + query); ! } ! /** ! * Returns an unmodifieable list of this provider's template loaders. ! * The list is has the same order used for searching templates. You may ! * use this method to access template loaders and change their settings ! * at runtime if they have an appropriate method. ! * @return unmodifieable list of TemplateLoader objects ! */ ! public List getTemplateLoaders() { ! return Collections.unmodifiableList(Arrays.asList(templateLoaders)); ! } ! protected TemplateLoaderFactory createFactory(String classname) throws InitException { ! try { ! return (TemplateLoaderFactory) Class.forName(classname).newInstance(); ! } ! catch (ClassNotFoundException e) { ! throw new InitException("Class " + classname + " for template loader factory not found", e); ! } ! catch (InstantiationException e) { ! throw new InitException("Could not instantiate class " + classname + " for template loader factory", e); ! } ! catch (IllegalAccessException e) { ! throw new InitException("Could not instantiate class " + classname + " for template loader facory", e); ! } ! catch (ClassCastException e) { ! throw new InitException("Class " + classname + " for template loader factory does not implement " + ! "interface org.webmacro.resource.TemplateLoaderFactory", e); ! } ! } } --- 65,170 ---- * @author Sebastian Kanthak (seb...@mu...) */ ! public class DelegatingTemplateProvider extends CachingProvider ! { ! private Broker broker; ! private Log log; ! private TemplateLoaderFactory factory; ! private TemplateLoader[] templateLoaders; ! public void init (Broker broker, Settings config) throws InitException ! { ! super.init(broker, config); ! this.broker = broker; ! log = broker.getLog("resource", "DelegatingTemplateProvider"); ! String factoryClass = config.getSetting("TemplateLoaderFactory", ""); ! log.info("DelegatingTemplateProvider: Using TemplateLoaderFactory " + factoryClass); ! factory = createFactory(factoryClass); ! List loaders = new ArrayList(); ! // for compatability reasons, check old TemplatePath setting ! if (config.getBooleanSetting("DelegatingTemplateProvider.EmulateTemplatePath", false)) ! { ! if (config.getSetting("TemplatePath", "").length() > 0) ! { ! TemplateLoader loader = new TemplatePathTemplateLoader(); ! loader.init(broker, config); ! loader.setConfig(""); ! loaders.add(loader); ! } ! } ! int i = 0; ! String loader = config.getSetting("TemplateLoaderPath.".concat(String.valueOf(i + 1))); ! while (loader != null) ! { ! loaders.add(factory.getTemplateLoader(broker, loader)); ! i++; ! loader = config.getSetting("TemplateLoaderPath.".concat(String.valueOf(i + 1))); ! } ! templateLoaders = new TemplateLoader[loaders.size()]; ! loaders.toArray(templateLoaders); ! } ! public String getType () ! { ! return "template"; ! } ! /** ! * Ask all template loaders to load a template from query. ! * Returns the template from the first provider, that returns a non-null value ! * or throws a NotFoundException, if all providers return null. ! */ ! public Object load (String query, CacheElement ce) throws ResourceException ! { ! for (int i = 0; i < templateLoaders.length; i++) ! { ! Template t = templateLoaders[i].load(query, ce); ! if (t != null) ! { ! return t; ! } ! } ! throw new NotFoundException("Could not locate template " + query); ! } ! /** ! * Returns an unmodifieable list of this provider's template loaders. ! * The list is has the same order used for searching templates. You may ! * use this method to access template loaders and change their settings ! * at runtime if they have an appropriate method. ! * @return unmodifieable list of TemplateLoader objects ! */ ! public List getTemplateLoaders () ! { ! return Collections.unmodifiableList(Arrays.asList(templateLoaders)); ! } ! protected TemplateLoaderFactory createFactory (String classname) throws InitException ! { ! try ! { ! return (TemplateLoaderFactory) Class.forName(classname).newInstance(); ! } ! catch (ClassNotFoundException e) ! { ! throw new InitException("Class " + classname + " for template loader factory not found", e); ! } ! catch (InstantiationException e) ! { ! throw new InitException("Could not instantiate class " + classname + " for template loader factory", e); ! } ! catch (IllegalAccessException e) ! { ! throw new InitException("Could not instantiate class " + classname + " for template loader facory", e); ! } ! catch (ClassCastException e) ! { ! throw new InitException("Class " + classname + " for template loader factory does not implement " + ! "interface org.webmacro.resource.TemplateLoaderFactory", e); ! } ! } } Index: FileTemplateLoader.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/FileTemplateLoader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileTemplateLoader.java 11 Jun 2002 17:43:22 -0000 1.5 --- FileTemplateLoader.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 23,31 **** package org.webmacro.resource; - import java.io.*; - import org.webmacro.ResourceException; import org.webmacro.Template; /** * Implementation of TemplateLoader that loads templates from a given directory. --- 23,31 ---- package org.webmacro.resource; import org.webmacro.ResourceException; import org.webmacro.Template; + import java.io.File; + /** * Implementation of TemplateLoader that loads templates from a given directory. *************** *** 35,71 **** * @author Sebastian Kanthak (seb...@mu...) */ ! public class FileTemplateLoader extends AbstractTemplateLoader { ! private String path; ! public void setConfig(String config) { ! // leading slash isn't needed, because ! // we use File constructor. ! this.path = config; ! // However, we can check, if the directory exists. ! File f = new File(path); ! if (!f.exists()) { ! log.warning("FileTemplateLoader: " + f.getAbsolutePath() + " does not exist."); ! } ! else if (!f.isDirectory()) { ! log.warning("FileTemplateLoader: " + f.getAbsolutePath() + " is not a directory."); ! } ! } ! /** ! * Tries to load a template by interpreting query as ! * a path relative to the path set by setPath. ! */ ! public final Template load(String query, CacheElement ce) throws ResourceException { ! File tFile = new File(path, query); ! if (tFile.isFile() && tFile.canRead()) { ! if (log.loggingDebug()) ! log.debug("FileTemplateProvider: Found template " + tFile.getAbsolutePath()); ! return helper.load(tFile, ce); ! } ! else { ! return null; ! } ! } } --- 35,78 ---- * @author Sebastian Kanthak (seb...@mu...) */ ! public class FileTemplateLoader extends AbstractTemplateLoader ! { ! private String path; ! public void setConfig (String config) ! { ! // leading slash isn't needed, because ! // we use File constructor. ! this.path = config; ! // However, we can check, if the directory exists. ! File f = new File(path); ! if (!f.exists()) ! { ! log.warning("FileTemplateLoader: " + f.getAbsolutePath() + " does not exist."); ! } ! else if (!f.isDirectory()) ! { ! log.warning("FileTemplateLoader: " + f.getAbsolutePath() + " is not a directory."); ! } ! } ! /** ! * Tries to load a template by interpreting query as ! * a path relative to the path set by setPath. ! */ ! public final Template load (String query, CacheElement ce) throws ResourceException ! { ! File tFile = new File(path, query); ! if (tFile.isFile() && tFile.canRead()) ! { ! if (log.loggingDebug()) ! log.debug("FileTemplateProvider: Found template " + tFile.getAbsolutePath()); ! return helper.load(tFile, ce); ! } ! else ! { ! return null; ! } ! } } Index: GenerationalCacheManager.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/resource/GenerationalCacheManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenerationalCacheManager.java 11 Nov 2002 19:22:37 -0000 1.6 --- GenerationalCacheManager.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 25,29 **** import org.opendoors.cache.immutable.CacheFactory; import org.opendoors.cache.immutable.CacheImpl; - import org.webmacro.Broker; import org.webmacro.InitException; --- 25,28 ---- *************** *** 58,232 **** * @since 0.96 */ ! public class GenerationalCacheManager implements CacheManager { ! private static final String NAME = "GenerationalCacheManager"; ! private UpdateableCache cache; ! private Log log; ! private CacheFactory cacheFactory; ! private String resourceType; ! private boolean reloadOnChange = false; ! public GenerationalCacheManager() { ! } ! public void init(Broker b, Settings config, String resourceType) ! throws InitException { ! Settings s = new SubSettings(config, "GenerationalCacheManager." + resourceType); ! Settings def = new SubSettings(config, "GenerationalCacheManager.*"); ! if (s.containsKey("ReloadOnChange")) { ! reloadOnChange = s.getBooleanSetting("ReloadOnChange"); // for this resource type ! } ! else if (def.containsKey("ReloadOnChange")) { ! reloadOnChange = def.getBooleanSetting("ReloadOnChange"); // all resource types ! } ! cacheFactory = new CacheFactory(def.getAsProperties()); // uses the union ! this.cache = cacheFactory.initialize(null); ! this.log = b.getLog("resource"); ! this.resourceType = resourceType; ! log.info(NAME + "." + resourceType + ": " + "Reload=" + reloadOnChange); ! } ! public void flush() { ! cache.invalidateAll(); ! } ! public void destroy() { ! cacheFactory.destroy(cache); ! } ! /** ! * Get the cached value and load ! * it if it is not present or reloading ! * is required. ! */ ! public Object get(final Object query, ResourceLoader helper) ! throws ResourceException { ! if (reloadOnChange) ! return getReloadable(query, helper); ! else ! return getUnreloadable(query, helper); ! } ! /** ! * Get the object associated with the specific query, ! * trying to look it up in a cache. If it's not there, return null. ! */ ! public Object get(final Object query) { ! Object o = cache.get(query); ! if (o != null && reloadOnChange) ! return ((ScmCacheElement) o).value; ! else ! return o; ! } ! /** ! * Put an object in the cache ! */ ! public void put(final Object query, Object resource) { ! if (reloadOnChange) { ! ScmCacheElement r = new ScmCacheElement(); ! r.value = resource; ! cache.put(query, r); ! } ! else ! cache.put(query, resource); ! } ! private Object getUnreloadable(final Object query, ResourceLoader helper) ! throws ResourceException { ! Object o = cache.get(query); ! if (o == null) { ! o = helper.load(query, null); ! if (o != null) ! cache.put(query, o); ! } ! return o; ! } ! private Object getReloadable(final Object query, ResourceLoader helper) ! throws ResourceException { ! Object o = null; ! ScmCacheElement r = (ScmCacheElement) cache.get(query); ! if (r != null) ! o = r.value; ! boolean reload = false; ! if (o != null && r.reloadContext != null && reloadOnChange) ! reload = r.reloadContext.shouldReload(); ! if (o == null || reload) { ! if (r == null) ! r = new ScmCacheElement(); ! o = helper.load(query, r); ! if (o != null) { ! r.value = o; ! cache.put(query, r); ! } ! } ! return o; ! } ! /** Invalidate an entry in the cache. */ ! public void invalidate(final Object query) { ! cache.invalidate(query); ! } ! /** This manager supports reloading and so this returns true. */ ! public boolean supportsReload() { ! return true; ! } ! /** Returns the wm type of resource it is caching. */ ! public String getResourceType() { ! return resourceType; ! } ! /** ! * A caching element ! * smart enough to reload itself. ! * <p> ! * Note: SoftReference is a huge overhead hit so ! * it has been obsoleted in favor of straight obj refs. ! */ ! private static class ScmCacheElement extends CacheElement { ! private Object value; ! private CacheReloadContext reloadContext = null; ! public void setReloadContext(CacheReloadContext rc) { ! this.reloadContext = rc; ! } ! } ! /** ! * Returns cache instrumentation statistics. ! * <p> ! * These statistics will be zero if the cache ! * implementation is not using the instrumented get() routine. ! * <p> ! * Use of this routine is normally reserved for performance analysis ! * and depends on recompiling org.opendoors.cache.immutable.CacheImpl ! * @return an array of longs with the following def.<br> ! * <pre> ! * [0] The total number of gets, accesses. ! * [1] The number of accesses which resulted in a hit to the immutable cache. ! * [2] The number of accesses which resulted in a hit to the mutable cache. ! * [3] The number of accesses which resulted in a fault and a need to ! * regenerate the cache entry. ! * </pre> ! * @see org.opendoors.cache.impl.CacheImpl ! */ ! public long[] getMetrics() { ! long[] values = {0, 0, 0, 0}; // the default; ! if (cache instanceof CacheImpl) { ! CacheImpl impl = (CacheImpl) cache; ! values = impl.getMetrics(); ! } ! return values; ! } } --- 57,254 ---- * @since 0.96 */ ! public class GenerationalCacheManager implements CacheManager ! { ! private static final String NAME = "GenerationalCacheManager"; ! private UpdateableCache cache; ! private Log log; ! private CacheFactory cacheFactory; ! private String resourceType; ! private boolean reloadOnChange = false; ! public GenerationalCacheManager () ! { ! } ! public void init (Broker b, Settings config, String resourceType) ! throws InitException ! { ! Settings s = new SubSettings(config, "GenerationalCacheManager." + resourceType); ! Settings def = new SubSettings(config, "GenerationalCacheManager.*"); ! if (s.containsKey("ReloadOnChange")) ! { ! reloadOnChange = s.getBooleanSetting("ReloadOnChange"); // for this resource type ! } ! else if (def.containsKey("ReloadOnChange")) ! { ! reloadOnChange = def.getBooleanSetting("ReloadOnChange"); // all resource types ! } ! cacheFactory = new CacheFactory(def.getAsProperties()); // uses the union ! this.cache = cacheFactory.initialize(null); ! this.log = b.getLog("resource"); ! this.resourceType = resourceType; ! log.info(NAME + "." + resourceType + ": " + "Reload=" + reloadOnChan... [truncated message content] |