1 package org.apache.commons.digester3.annotations.handlers;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.lang.reflect.Field;
23
24 import org.apache.commons.digester3.annotations.AnnotationHandler;
25 import org.apache.commons.digester3.annotations.rules.SetProperty;
26 import org.apache.commons.digester3.binder.RulesBinder;
27 import org.apache.commons.digester3.binder.SetPropertiesBuilder;
28
29
30
31
32
33
34 public final class SetPropertiesHandler
35 implements AnnotationHandler<SetProperty, Field>
36 {
37
38
39
40
41 public void handle( SetProperty annotation, Field element, RulesBinder rulesBinder )
42 {
43 SetPropertiesBuilder builder = rulesBinder
44 .forPattern( annotation.pattern() )
45 .withNamespaceURI( annotation.namespaceURI() )
46 .setProperties();
47
48 if ( annotation.attributeName() != null && annotation.attributeName().length() > 0
49 && !element.getName().equals( annotation.attributeName() ) )
50 {
51 builder.addAlias( annotation.attributeName() ).forProperty( element.getName() );
52 }
53 }
54
55 }