Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 796:a5526908f92f
Added javadoc in state package.
gnv-artifacts/trunk@878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 01 Apr 2010 09:15:36 +0000 |
parents | c4156275c1e1 |
children | feae2f9d6c6f |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Thu Apr 01 09:15:36 2010 +0000 @@ -55,6 +55,9 @@ import org.w3c.dom.NodeList; /** + * This is the major implementation of <code>State</code>. Nearly every other + * state is derived by this class. + * * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> @@ -71,17 +74,38 @@ */ private static Logger log = Logger.getLogger(StateBase.class); + /** + * + */ protected final static String MINVALUEFIELDNAME = "minvalue"; + /** + * + */ protected final static String MAXVALUEFIELDNAME = "maxvalue"; private final static String NODATASELECTIONKEY = "n/n"; + /** + * + */ public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; + /** + * + */ public final static String XPATH_STATIC_UI = "art:static"; + /** + * + */ public final static String XPATH_DYNAMIC_UI = "art:dynamic"; + /** + * + */ public static final String EXCEPTION_NO_INPUT = "no.input.data"; + /** + * + */ public static final String EXCEPTION_INVALID_INPUT = "input.is.not.valid"; @@ -90,28 +114,61 @@ private String id = null; + /** + * + */ protected String hash; private String description = null; + /** + * + */ protected String dataName = null; + /** + * + */ protected String preSettingsName = null; + /** + * + */ protected boolean dataMultiSelect = false; + /** + * + */ protected boolean dataNoSelect = false; + /** + * + */ protected String queryID = null; + /** + * + */ protected Collection<String> inputValueNames = null; + /** + * + */ protected Map<String, InputValue> inputValues = null; + /** + * + */ protected State parent = null; + /** + * + */ protected Map<String, InputData> inputData = null; + /** + * + */ protected Map<String, InputData> preSettings = null; /** @@ -122,14 +179,14 @@ } /** - * @see de.intevation.gnv.state.State#getID() + * @return */ public String getID() { return this.id; } /** - * @see de.intevation.gnv.state.State#getDescription() + * @return */ public String getDescription() { return this.description; @@ -138,19 +195,24 @@ /** - * @see de.intevation.gnv.state.State#getRequiredInputValues() + * @return */ public Collection<InputValue> getRequiredInputValues() { return this.inputValues.values(); } + /** + * + * @param uuid + */ public void reset(String uuid) { inputData.remove(dataName); } /** + * @param configuration * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node) */ public void setup(Node configuration) { @@ -207,6 +269,7 @@ } /** + * @return * @see de.intevation.gnv.state.State#getParent() */ public State getParent() { @@ -214,6 +277,7 @@ } /** + * @param state * @see de.intevation.gnv.state.State#setParent(de.intevation.gnv.state.State) */ public void setParent(State state) { @@ -221,6 +285,14 @@ } + /** + * + * @param context + * @param inputData + * @param uuid + * @return + * @throws StateException + */ public Document feed( CallContext context, Collection<InputData> inputData, @@ -244,7 +316,8 @@ inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { @@ -285,18 +358,33 @@ } + /** + * + * @return + */ protected Document feedSuccess() { return ArtifactXMLUtilities.createSuccessReport( "Initialize success", XMLUtils.newDocument()); } + /** + * + * @param msg + * @return + */ protected Document feedFailure(String msg) { return ArtifactXMLUtilities.createInputExceptionReport( msg, XMLUtils.newDocument()); } + /** + * + * @param data + * @param uuid + * @return + */ protected String[] getDescriptionForInputData(InputData data, String uuid) { // there is only one element in the list, so take the first Object obj = getDescibeData(uuid).get(0); @@ -336,8 +424,12 @@ /** + * @param inputData + * @param uuid + * @throws StateException * @see de.intevation.gnv.state.State#putInputData(java.util.Collection) */ + @SuppressWarnings({"static-access", "static-access", "static-access", "static-access"}) public void putInputData(Collection<InputData> inputData, String uuid) throws StateException { if (inputData != null) { @@ -352,13 +444,14 @@ inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { if (tmpItem.getName().equals(MINVALUEFIELDNAME)){ String minValue = tmpItem.getValue(); String maxValue = this.getInputValue4ID(inputData, MAXVALUEFIELDNAME); - valid = iv.isInputValid(maxValue,inputValue.getType()); + valid = InputValidator.isInputValid(maxValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -367,7 +460,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -378,7 +471,7 @@ }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){ String minValue = this.getInputValue4ID(inputData, MINVALUEFIELDNAME); String maxValue = tmpItem.getValue(); - valid = iv.isInputValid(minValue,inputValue.getType()); + valid = InputValidator.isInputValid(minValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -387,7 +480,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -422,6 +515,7 @@ /** * + * @param preSettings * @see de.intevation.gnv.state.State#setPreSettings(java.util.Map) */ public void setPreSettings(Map<String, InputData> preSettings) { @@ -430,10 +524,20 @@ + /** + * + * @return + */ public Map<String, InputData> getPreSettings() { return this.preSettings; } + /** + * + * @param inputData + * @param inputName + * @return + */ protected String getInputValue4ID(Collection<InputData> inputData, String inputName){ Iterator<InputData> it = inputData.iterator(); while (it.hasNext()) { @@ -447,6 +551,9 @@ /** + * @param uuid + * @param context + * @throws StateException * @see de.intevation.gnv.state.State#advance(java.lang.String, * de.intevation.artifacts.CallMeta) */ @@ -455,6 +562,12 @@ { } + /** + * + * @param uuid + * @param context + * @throws StateException + */ public void initialize(String uuid, CallContext context) throws StateException { @@ -495,6 +608,11 @@ return filterValues; } + /** + * + * @param value + * @return + */ protected String prepareInputData4RegionDBQuery(String value){ return value; } @@ -536,6 +654,8 @@ /** * @param result + * @param uuid + * @return */ protected List<Object> purifyResult(Collection<Result> result, String uuid) { List<Object> describeData = new ArrayList<Object>(); @@ -550,6 +670,8 @@ /** * @param result + * @param keyid + * @param valueid * @return */ protected NamedCollection<KeyValueDescibeData> extractKVP(Collection<Result> result, @@ -614,6 +736,11 @@ } + /** + * + * @param key + * @return + */ public static boolean inBlackList(String key) { int length = BLACKLIST.length; for (int i = 0; i < length; i++) { @@ -626,6 +753,10 @@ } /** + * @param document + * @param rootNode + * @param context + * @param uuid * @see de.intevation.gnv.state.State#describe(org.w3c.dom.Document, * org.w3c.dom.Node, de.intevation.artifacts.CallMeta, * java.lang.String) @@ -675,6 +806,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param dynamic + * @param context + * @param uuid + */ protected void describeDynamic( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -703,6 +843,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param staticNode + * @param context + * @param uuid + */ protected void describeStatic( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -722,6 +871,14 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param staticNode + * @param callMeta + */ protected void appendToStaticNode( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -775,6 +932,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param dynamicNode + * @param callMeta + * @param o + */ protected void appendToDynamicNode( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -848,6 +1014,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param node + * @param callMeta + * @param o + */ protected void appendMinMaxDescribeData( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -914,6 +1089,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param node + * @param callMeta + * @param o + */ protected void appendSingleValueDescribeData( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -953,17 +1137,27 @@ } + /** + * + * @param uuid + */ protected void setHash(String uuid) { this.hash = uuid + id + inputData.hashCode(); } + /** + * + * @return + */ protected String getHash() { return this.hash; } /** + * @param uuid + * @return * @see de.intevation.gnv.state.State#getDescibeData() */ public List<Object> getDescibeData(String uuid) { @@ -1016,6 +1210,13 @@ return null; } + /** + * + * @param filterValues + * @param uuid + * @return + * @throws QueryException + */ protected List<Object> queryDatabase(String[] filterValues, String uuid) throws QueryException { Collection<Result> result = null; @@ -1030,17 +1231,28 @@ } + /** + * + * @return + */ public Map<String, InputData> inputData() { return inputData; } /** + * @return + * @throws StateException * @see de.intevation.gnv.state.State#getInputData() */ public Collection<InputData> getInputData() throws StateException { return this.inputData != null ? this.inputData.values() : null; } + /** + * + * @param name + * @return + */ public InputData getInputDataByName(String name) { State state = this; @@ -1056,11 +1268,19 @@ return null; } + /** + * + * @param globalContext + */ public void endOfLife(Object globalContext) { } + /** + * + * @param context + */ public void cleanup(Object context) { } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file