View Javadoc

1   package org.apache.commons.digester3.annotations.atom;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.net.URL;
23  import java.util.ArrayList;
24  import java.util.Date;
25  import java.util.List;
26  
27  import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
28  import org.apache.commons.digester3.annotations.rules.CallMethod;
29  import org.apache.commons.digester3.annotations.rules.ObjectCreate;
30  import org.apache.commons.digester3.annotations.rules.SetNext;
31  import org.apache.commons.digester3.annotations.rules.SetProperty;
32  
33  @ObjectCreate( pattern = "feed" )
34  public final class Feed
35  {
36  
37      @BeanPropertySetter( pattern = "feed/title" )
38      private String title;
39  
40      @SetProperty( pattern = "feed/link", attributeName = "href" )
41      private URL link;
42  
43      @BeanPropertySetter( pattern = "feed/updated" )
44      private Date updated;
45  
46      private final List<String> authors = new ArrayList<String>();
47  
48      @BeanPropertySetter( pattern = "feed/id" )
49      private String id;
50  
51      private final List<Entry> entries = new ArrayList<Entry>();
52  
53      public String getTitle()
54      {
55          return title;
56      }
57  
58      public void setTitle( String title )
59      {
60          this.title = title;
61      }
62  
63      public URL getLink()
64      {
65          return link;
66      }
67  
68      public void setLink( URL link )
69      {
70          this.link = link;
71      }
72  
73      public Date getUpdated()
74      {
75          return updated;
76      }
77  
78      public void setUpdated( Date updated )
79      {
80          this.updated = updated;
81      }
82  
83      public String getId()
84      {
85          return id;
86      }
87  
88      public void setId( String id )
89      {
90          this.id = id;
91      }
92  
93      public List<String> getAuthors()
94      {
95          return authors;
96      }
97  
98      @CallMethod( pattern = "feed/author/name", usingElementBodyAsArgument = true )
99      public void addAuthor( String author )
100     {
101         authors.add( author );
102     }
103 
104     public List<Entry> getEntries()
105     {
106         return entries;
107     }
108 
109     @SetNext
110     public void addEntry( Entry entry )
111     {
112         entries.add( entry );
113     }
114 
115     @Override
116     public String toString()
117     {
118         return "Feed [title=" + title + ", link=" + link + ", updated=" + updated + ", authors=" + authors + ", id="
119             + id + ", entries=" + entries + "]";
120     }
121 
122 }