1 package com.terradue.jcatalogue.client.internal.digester;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import static com.terradue.jcatalogue.client.internal.digester.Namespaces.ATOM;
20 import static com.terradue.jcatalogue.client.internal.digester.Namespaces.OPEN_SEARCH;
21
22 import org.apache.commons.digester3.binder.AbstractNamespaceURIBasedRulesModule;
23
24 public final class AtomRulesModule
25 extends AbstractNamespaceURIBasedRulesModule
26 {
27
28 private final Class<?> mappedEntity;
29
30 public AtomRulesModule( Class<?> mappedEntity )
31 {
32 super( ATOM );
33 this.mappedEntity = mappedEntity;
34 }
35
36 @Override
37 protected void configure()
38 {
39 forPattern( "feed" ).createObject().ofType( mappedEntity );
40 forPattern( "feed/title" ).setBeanProperty();
41 forPattern( "feed/subtitle" ).setBeanProperty();
42 forPattern( "feed/updated" ).setBeanProperty();
43 forPattern( "feed/id" ).setBeanProperty();
44 forPattern( "feed/totalResults" ).withNamespaceURI( OPEN_SEARCH ).setBeanProperty().withName( "totalResults" );
45 forPattern( "feed/startIndex" ).withNamespaceURI( OPEN_SEARCH ).setBeanProperty().withName( "startIndex" );
46 forPattern( "feed/itemsPerPage" ).withNamespaceURI( OPEN_SEARCH ).setBeanProperty().withName( "itemsPerPage" );
47
48 forPattern( "feed/link" ).callMethod( "addLink" )
49 .withParamTypes( String.class, String.class, String.class, Integer.class )
50 .then()
51 .callParam()
52 .fromAttribute( "rel" )
53 .ofIndex( 0 )
54 .then()
55 .callParam()
56 .fromAttribute( "type" )
57 .ofIndex( 1 )
58 .then()
59 .callParam()
60 .fromAttribute( "href" )
61 .ofIndex( 2 )
62 .then()
63 .addRuleCreatedBy( new PriorityParamRule.PriorityParamRuleProvider( 3 ) );
64 }
65
66 }