1 /***
2 *
3 */
4 package ar.com.epere4.java2excel.parser.impl;
5
6 import org.apache.commons.lang.Validate;
7 import org.apache.commons.lang.builder.ToStringBuilder;
8
9 import ar.com.epere4.java2excel.parser.PropertyDtd;
10
11 /***
12 * Abstract implementation of
13 * {@link ar.com.epere4.java2excel.parser.PropertyDtd}.
14 *
15 * @author epere4
16 * @since 09/03/2006
17 */
18 public abstract class AbstractPropertyDtd implements PropertyDtd {
19 /*** This is the property expression. */
20 private boolean protectNullPointer = true;
21
22 /*** This is the property expression. */
23 private String expression;
24
25 /*** This is the title property. */
26 private String title;
27
28 /*** This is the property description. */
29 private String description;
30
31 /***
32 * Default Constructor.
33 *
34 * @since 09/03/2006
35 */
36 public AbstractPropertyDtd() {
37 }
38
39 /***
40 * @param expression
41 * the default value for {@link #getExpression()}.
42 * @param title
43 * the default value for {@link #getTitle()}.
44 * @since 09/03/2006
45 */
46 public AbstractPropertyDtd(final String expression, final String title) {
47 setExpression(expression);
48 setTitle(title);
49 }
50
51 /***
52 * {@inheritDoc}
53 *
54 * @see PropertyDtd#getExpression()
55 */
56 public String getExpression() {
57 return expression;
58 }
59
60 /***
61 * @param expression
62 * The expression to set.
63 */
64 public void setExpression(final String expression) {
65 Validate.notNull(expression, "expression cannot be null");
66 this.expression = expression;
67 }
68
69 /***
70 * {@inheritDoc}
71 *
72 * @see ar.com.epere4.java2excel.parser.PropertyDtd#getTitle()
73 * @since 18/02/2006
74 */
75 public String getTitle() {
76 if (title == null) {
77 setTitle(getExpression());
78 }
79 return title;
80 }
81
82 /***
83 * @param title
84 * The title to set.
85 * @since 18/02/2006
86 */
87 public void setTitle(final String title) {
88 this.title = title;
89 }
90
91 /***
92 * {@inheritDoc}
93 *
94 * @see PropertyDtd#getDescription()
95 */
96 public String getDescription() {
97 return description;
98 }
99
100 /***
101 * @param description
102 * The description to set.
103 */
104 public void setDescription(final String description) {
105 this.description = description;
106 }
107
108 /***
109 * {@inheritDoc}
110 *
111 * @see PropertyDtd#isProtectNullPointer()
112 */
113 public boolean isProtectNullPointer() {
114 return protectNullPointer;
115 }
116
117 /***
118 * @param protectNullPointer
119 * setea la propiedad {@link PropertyDtd#isProtectNullPointer()}.
120 * @since 18/02/2006
121 */
122 public void setProtectNullPointer(final boolean protectNullPointer) {
123 this.protectNullPointer = protectNullPointer;
124 }
125
126 /***
127 * {@inheritDoc}
128 *
129 * @see java.lang.Object#toString()
130 */
131 public String toString() {
132 return ToStringBuilder.reflectionToString(this);
133 }
134
135 }