View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.annotation.impl;
23  
24  import org.opencastproject.annotation.api.Annotation;
25  import org.opencastproject.annotation.api.AnnotationList;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  import javax.xml.bind.annotation.XmlAccessType;
31  import javax.xml.bind.annotation.XmlAccessorType;
32  import javax.xml.bind.annotation.XmlAttribute;
33  import javax.xml.bind.annotation.XmlElement;
34  import javax.xml.bind.annotation.XmlRootElement;
35  import javax.xml.bind.annotation.XmlType;
36  
37  /**
38   * A {@link List} of {@link AnnotationList}s
39   */
40  @XmlType(name = "annotations", namespace = "http://annotation.opencastproject.org")
41  @XmlRootElement(name = "annotations", namespace = "http://annotation.opencastproject.org")
42  @XmlAccessorType(XmlAccessType.FIELD)
43  public class AnnotationListImpl implements AnnotationList {
44  
45    @XmlAttribute(name = "total")
46    protected int total;
47  
48    @XmlAttribute(name = "offset")
49    protected int offset;
50  
51    @XmlAttribute(name = "limit")
52    protected int limit;
53  
54    @XmlElement(name = "annotation")
55    protected List<AnnotationImpl> annotations;
56  
57    public void add(Annotation annotation) {
58      annotations.add((AnnotationImpl) annotation);
59    }
60  
61    /**
62     * A no-arg constructor needed by JAXB
63     */
64    public AnnotationListImpl() {
65      this.annotations = new ArrayList<AnnotationImpl>();
66    }
67  
68    public void setTotal(int total) {
69      this.total = total;
70    }
71  
72    public void setLimit(int limit) {
73      this.limit = limit;
74    }
75  
76    public void setOffset(int offset) {
77      this.offset = offset;
78    }
79  
80    @Override
81    public int getTotal() {
82      return total;
83    }
84  
85    @Override
86    public int getLimit() {
87      return limit;
88    }
89  
90    @Override
91    public int getOffset() {
92      return offset;
93    }
94  
95    @Override
96    public List<Annotation> getAnnotations() {
97      return new ArrayList<Annotation>(annotations);
98    }
99  }