1 package org.apache.commons.digester3.binder;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.apache.commons.digester3.SetPropertiesRule;
26
27
28
29
30 public final class SetPropertiesBuilder
31 extends AbstractBackToLinkedRuleBuilder<SetPropertiesRule>
32 {
33
34 private final Map<String, String> aliases = new HashMap<String, String>();
35
36 private boolean ignoreMissingProperty = true;
37
38 SetPropertiesBuilder( String keyPattern, String namespaceURI, RulesBinder mainBinder,
39 LinkedRuleBuilder mainBuilder )
40 {
41 super( keyPattern, namespaceURI, mainBinder, mainBuilder );
42 }
43
44
45
46
47
48
49
50
51
52 @Deprecated
53 public SetPropertiesBuilder addAlias( String attributeName, String propertyName )
54 {
55 return addAlias( attributeName ).forProperty( propertyName );
56 }
57
58
59
60
61
62
63
64
65 public AddAliasBuilder<SetPropertiesBuilder> addAlias( String attributeName )
66 {
67 if ( attributeName == null )
68 {
69 reportError( "setProperties().addAlias( String )", "empty 'attributeName' not allowed" );
70 }
71 return new AddAliasBuilder<SetPropertiesBuilder>( this, aliases, attributeName );
72 }
73
74
75
76
77
78
79
80 public SetPropertiesBuilder ignoreAttribute( String attributeName )
81 {
82 if ( attributeName == null )
83 {
84 reportError( "setProperties().ignoreAttribute( String )", "empty 'attributeName' not allowed" );
85 }
86 return addAlias( attributeName ).forProperty( null );
87 }
88
89
90
91
92
93
94
95
96
97
98
99 public SetPropertiesBuilder ignoreMissingProperty( boolean ignoreMissingProperty )
100 {
101 this.ignoreMissingProperty = ignoreMissingProperty;
102 return this;
103 }
104
105
106
107
108 @Override
109 protected SetPropertiesRule createRule()
110 {
111 SetPropertiesRule rule = new SetPropertiesRule( aliases );
112 rule.setIgnoreMissingProperty( ignoreMissingProperty );
113 return rule;
114 }
115
116 }