##### Coverage Report - org.melati.app.PoemApp

Classes in this File | Line Coverage | Branch Coverage | Complexity
PoemApp |
100% | 17/17
100% | 4/4
| 2.0;2

1 |  |
     /*
2 |  |
      * $Source: /usr/cvsroot/melati/melati/src/site/resources/withWebmacro/org.melati.app.PoemApp.html,v $
3 |  |
      * $Revision: 1.1 $
4 |  |
      *
5 |  |
      * Copyright (C) 2005 Tim Pizey
6 |  |
      *
7 |  |
      * Part of Melati (http://melati.org), a framework for the rapid
8 |  |
      * development of clean, maintainable web applications.
9 |  |
      *
10 |  |
      * Melati is free software; Permission is granted to copy, distribute
11 |  |
      * and/or modify this software under the terms either:
12 |  |
      *
13 |  |
      * a) the GNU General Public License as published by the Free Software
14 |  |
      *    Foundation; either version 2 of the License, or (at your option)
15 |  |
      *    any later version,
16 |  |
      *
17 |  |
      *    or
18 |  |
      *
19 |  |
      * b) any version of the Melati Software License, as published
20 |  |
      *    at http://melati.org
21 |  |
      *
22 |  |
      * You should have received a copy of the GNU General Public License and
23 |  |
      * the Melati Software License along with this program;
24 |  |
      * if not, write to the Free Software Foundation, Inc.,
25 |  |
      * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26 |  |
      * GNU General Public License and visit http://melati.org to obtain the
27 |  |
      * Melati Software License.
28 |  |
      *
29 |  |
      * Feel free to contact the Developers of Melati (http://melati.org),
30 |  |
      * if you would like to work out a different arrangement than the options
31 |  |
      * outlined here.  It is our intention to allow Melati to be used by as
32 |  |
      * wide an audience as possible.
33 |  |
      *
34 |  |
      * This program is distributed in the hope that it will be useful,
35 |  |
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 |  |
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 |  |
      * GNU General Public License for more details.
38 |  |
      *
39 |  |
      * Contact details for copyright holder:
40 |  |
      *
41 |  |
      *     Tim Pizey <timp@paneris.org>
42 |  |
      *     http://paneris.org/~timp
43 |  |
      */
44 |  |
     package org.melati.app;
45 |  |
46 |  |
     import java.util.Enumeration;
47 |  |
48 |  |
     import org.melati.Melati;
49 |  |
     import org.melati.poem.User;
50 |  |
51 |  |
     /**
52 |  |
      * An example of how to access a POEM database from the command line.
53 |  |
      *
54 |  |
      * Invoke:
55 |  |
      * <pre>
56 |  |
      * java -cp melati.jar;site\properties;lib\hsqldb.jar
57 |  |
      *     org.melati.app.PoemAppExample poemtest
58 |  |
      * </pre>
59 |  |
      * (Note: if you have configured a WebmacroServletTemplateEngine then you will
60 |  |
      * need webmacro.jar and servlet.jar in your classpath).
61 |  |
      */
62 | 32 |
     public class PoemApp extends AbstractPoemApp {
63 |  |
64 |  |
       /**
65 |  |
        * The main method to override.
66 |  |
        *
67 |  |
        * @param melati A {@link Melati} with arguments and properties set
68 |  |
        * @throws Exception if anything goes wrong
69 |  |
        * @see org.melati.app.AbstractPoemApp#doPoemRequest(org.melati.Melati)
70 |  |
        */
71 |  |
       protected void doPoemRequest(Melati melati) throws Exception {
72 | 22 |
         melati.getWriter().write("You are          : " + melati.getUser() + "\n");
73 | 22 |
         melati.getWriter().write("Your Database was: " + melati.getDatabase() + "\n");
74 | 22 |
         melati.getWriter().write("Your Table was   : " + melati.getTable() + "\n");
75 | 22 |
         if (melati.getObject() != null)
76 | 16 |
           melati.getWriter().write("Your Troid was   : " + melati.getObject().getTroid() + "\n");
77 |  |
         else
78 | 6 |
           melati.getWriter().write("Your Troid was   : null\n");
79 | 22 |
         melati.getWriter().write("Your Method was  : " + melati.getMethod() + "\n");
80 | 22 |
         melati.getWriter().write("System Users" + "\n");
81 | 22 |
         melati.getWriter().write("============" + "\n");
82 | 22 |
         Enumeration e = melati.getDatabase().getUserTable().selection();
83 | 66 |
         while(e.hasMoreElements()) {
84 | 44 |
           melati.getWriter().write("  " + ((User)e.nextElement()).getName() + "\n");
85 |  |
         }
86 | 22 |
       }
87 |  |
88 |  |
       /**
89 |  |
        * The main entry point.
90 |  |
        *
91 |  |
        * @param args in format <code>db table troid method</code>
92 |  |
        */
93 |  |
       public static void main(String[] args) throws Exception {
94 | 12 |
         PoemApp me = new PoemApp();
95 | 12 |
         me.run(args);
96 | 10 |
       }
97 |  |
     }