01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19: package de.schlund.pfixcore.generator;
20:
21: import java.io.IOException;
22:
23: import de.schlund.pfixxml.resources.FileResource;
24: import de.schlund.util.statuscodes.StatusCode;
25:
26: /**
27: * IWrappers are objects which aggregate part of the submitted data
28: * of a HTTP post or get event in a typesafe way and present getter
29: * and setter methods to manipulate that data.</br>
30: * Classes which implement the IWrapper interface are not written by
31: * hand, but are autogenerated from a describtion written in a
32: * special xml format.</br>
33: * From the application programmers point of view IWrappers
34: * are never instanciated directly. Following snipplet
35: * shows the use of an <code>IWrapper</code> in the handleSubmittedData method
36: * of an {@link IHandler}.
37: * <pre>
38: * public void handleSubmittedData(Context context, IWrapper wrapper) throws Exception {
39: * AdultInfo info = (AdultInfo) wrapper;
40: * }
41: * </pre>
42: * <br/>
43: * For more information see the 'IWrapper_XML_Description_Language.txt' in the docs
44: * directory of the Pfixcore package.
45: */
46:
47: public interface IWrapper extends Comparable<IWrapper> {
48: void init(String prefix) throws Exception;
49:
50: void initLogging(FileResource logdir, String pagename,
51: String visitid);
52:
53: void tryParamLogging() throws IOException;
54:
55: void tryErrorLogging() throws IOException;
56:
57: void load(RequestData req) throws Exception;
58:
59: /**
60: * Load the IWrapper's typed data from the String representations set via the
61: * setStringValXXX methods, i.e. the string values are processed (checked and casted)
62: * just like values provided by a RequestData object.
63: * This method requires that the IWrapper is already initialized (that the init
64: * method has been called). Amongst others it can be used to manually instantiate
65: * and populate IWrapper objects within unit tests.
66: * @throws Exception
67: */
68: void loadFromStringValues() throws Exception;
69:
70: boolean errorHappened();
71:
72: void defineOrder(int order);
73:
74: // The reason for these to not being called get* is to avoid nameclashes with
75: // descendents who may want to use a Parameter called e.g. "Prefix" (which would
76: // result in a method getPrefix be generated)
77: Integer gimmeOrder();
78:
79: String gimmePrefix();
80:
81: IHandler gimmeIHandler();
82:
83: IWrapperParam[] gimmeAllParams();
84:
85: IWrapperParam[] gimmeAllParamsWithErrors();
86:
87: IWrapperParamDefinition[] gimmeAllParamDefinitions();
88:
89: void addSCode(IWrapperParam param, StatusCode scode, String[] args,
90: String level);
91: }
|