1
2
3
4
5
6
7
8 package de.keepondreaming.xml;
9
10
11 /***
12 * Strategy pattern to create instances needed by {@link de.keepondreaming.xml.XmlConverter}
13 *
14 * $Author: wintermond $
15 * $Date: 2005/07/10 18:40:13 $
16 * $Log: ObjectStrategy.java,v $
17 * Revision 1.3 2005/07/10 18:40:13 wintermond
18 * javadoc
19 * init()
20 *
21 * Revision 1.2 2005/07/09 09:56:51 wintermond
22 * javadoc
23 *
24 */
25 public interface ObjectStrategy
26 {
27 /***
28 * Creates an instance of the type <code>clazz</code>.
29 * <p>
30 * <code>clazz</code> is never null
31 *
32 * @param clazz
33 *
34 * @return An instance of the type <code>clazz</code>.
35 */
36 public Object createInstance(Class clazz);
37
38 /***
39 * Sets the attribute on an instance returned via {@link #createInstance(Class)}
40 * <p>
41 * <code>target</code> and <code>attribute</code> are guaranteed to be not null.
42 * <p>
43 * <code>value</code> is guaranteed to be not null if called by the parser
44 *
45 * @param target Object to set the attribute to
46 * @param attribute Attribute name
47 * @param value value to set
48 */
49 public void setAttribute(Object target, String attribute, Object value);
50
51 /***
52 * Restore initial state
53 */
54 public void init();
55
56 /***
57 * Determines the interfaces this object was created upon.
58 *
59 * @param object Object created by {@link #createInstance(Class)} of this object
60 *
61 * @return Target The interfaces this object was created upon.
62 */
63 public Class resolveInterface(Object object);
64
65 /***
66 * Returns the get/set method name for an attribute read by the parser
67 *
68 * @param clazz
69 * @param attribute
70 * @param set true if set method is requested, false if get
71 *
72 * @return Null if attribute can not be handled or strategy does not support the operation, name of method otherwise
73 */
74 public String getMethodName(Class clazz, String attribute, boolean set);
75
76
77 }