001package org.apache.commons.digester3.annotations.atom;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.net.URL;
023import java.util.ArrayList;
024import java.util.Date;
025import java.util.List;
026
027import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
028import org.apache.commons.digester3.annotations.rules.CallMethod;
029import org.apache.commons.digester3.annotations.rules.ObjectCreate;
030import org.apache.commons.digester3.annotations.rules.SetNext;
031import org.apache.commons.digester3.annotations.rules.SetProperty;
032
033@ObjectCreate( pattern = "feed" )
034public final class Feed
035{
036
037    @BeanPropertySetter( pattern = "feed/title" )
038    private String title;
039
040    @SetProperty( pattern = "feed/link", attributeName = "href" )
041    private URL link;
042
043    @BeanPropertySetter( pattern = "feed/updated" )
044    private Date updated;
045
046    private final List<String> authors = new ArrayList<String>();
047
048    @BeanPropertySetter( pattern = "feed/id" )
049    private String id;
050
051    private final List<Entry> entries = new ArrayList<Entry>();
052
053    public String getTitle()
054    {
055        return title;
056    }
057
058    public void setTitle( String title )
059    {
060        this.title = title;
061    }
062
063    public URL getLink()
064    {
065        return link;
066    }
067
068    public void setLink( URL link )
069    {
070        this.link = link;
071    }
072
073    public Date getUpdated()
074    {
075        return updated;
076    }
077
078    public void setUpdated( Date updated )
079    {
080        this.updated = updated;
081    }
082
083    public String getId()
084    {
085        return id;
086    }
087
088    public void setId( String id )
089    {
090        this.id = id;
091    }
092
093    public List<String> getAuthors()
094    {
095        return authors;
096    }
097
098    @CallMethod( pattern = "feed/author/name", usingElementBodyAsArgument = true )
099    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}