01: package com.xoetrope.carousel.generation.attributes;
02:
03: import java.util.Hashtable;
04:
05: /**
06: * A class for storing the attributes needed to automatically generate user
07: * interfaces for structures such as forms and data files of various formats.
08: *
09: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
10: * the GNU Public License (GPL), please see license.txt for more details. If
11: * you make commercial use of this software you must purchase a commercial
12: * license from Xoetrope.</p>
13: * <p> $Revision: 1.2 $</p>
14: */
15: public class GenerationAttributes implements Cloneable {
16: public static final String NAME_ATTR = "name";
17: public static final String IMPLEMENTATION_CLASS_ATTR = "implemetationClass";
18: public static final String CAPTION_KEY_ATTR = "caption";
19: public static final String CAPTION_STYLE_ATTR = "captionStyle";
20: public static final String PARENT_REF_ATTR = "parentReference";
21: public static final String VALIDATION_ATTR = "validationRule";
22: public static final String INPUT_PATH_ATTR = "inputPath";
23: public static final String OUTPUT_PATH_ATTR = "outputPath";
24: public static final String MASK_ATTR = "inputMask";
25: public static final String FORMAT_ATTR = "outputFormat";
26: public static final String LAYOUT_ATTR = "layout";
27: public static final String ALIGNMENT_ATTR = "alignment";
28: public static final String STYLE_ATTR = "style";
29: public static final String INIT_ATTR = "initCommand";
30: public static final String ACTION_ATTR = "actionCommand";
31:
32: private static int nextId;
33: protected int id;
34: protected Hashtable attributes;
35:
36: public GenerationAttributes() {
37: attributes = new Hashtable();
38: id = nextId++;
39: }
40:
41: /**
42: * Get the id of this attribute.
43: * @return the id
44: */
45: public int getId() {
46: return id;
47: }
48:
49: /**
50: * Get an attribute value
51: * @param key teh value to lookup
52: * @param defaultValue the default value in case nothing is found
53: * @return the value or the default if nothing is found
54: */
55: public Object getAttribute(String key, String defaultValue) {
56: Object value = attributes.get(key);
57: if (value == null)
58: return defaultValue;
59:
60: return value;
61: }
62:
63: /**
64: * Get an attribute value
65: * @param key the value to lookup
66: * @return the value or null if nothing is found
67: */
68: public Object getAttribute(String key) {
69: return getAttribute(key, null);
70: }
71: }
|