Merge branch 'release/5.45.0'
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / dto / oaipmh / ResumptionToken.java
1 //
2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b02-fcs
3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 // Any modifications to this file will be lost upon recompilation of the source schema.
5 // Generated on: 2009.11.02 at 12:58:05 PM GMT
6 //
7 package eu.etaxonomy.cdm.remote.dto.oaipmh;
8
9 import java.io.Serializable;
10 import java.math.BigInteger;
11 import java.util.UUID;
12
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlAttribute;
16 import javax.xml.bind.annotation.XmlSchemaType;
17 import javax.xml.bind.annotation.XmlTransient;
18 import javax.xml.bind.annotation.XmlType;
19 import javax.xml.bind.annotation.XmlValue;
20 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
21
22 import org.joda.time.DateTime;
23
24 import eu.etaxonomy.cdm.api.service.pager.Pager;
25 import eu.etaxonomy.cdm.jaxb.DateTimeAdapter;
26
27 /**
28 * A resumptionToken may have 3 optional attributes
29 * and can be used in ListSets, ListIdentifiers, ListRecords
30 * responses.
31 *
32 * <p>Java class for resumptionTokenType complex type.
33 *
34 * <p>The following schema fragment specifies the expected content contained within this class.
35 *
36 * <pre>
37 * &lt;complexType name="resumptionTokenType">
38 * &lt;simpleContent>
39 * &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
40 * &lt;attribute name="expirationDate" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
41 * &lt;attribute name="completeListSize" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
42 * &lt;attribute name="cursor" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
43 * &lt;/extension>
44 * &lt;/simpleContent>
45 * &lt;/complexType>
46 * </pre>
47 */
48 @XmlAccessorType(XmlAccessType.FIELD)
49 @XmlType(name = "resumptionTokenType", propOrder = {
50 "value"
51 })
52 public class ResumptionToken implements Serializable {
53
54 private static final long serialVersionUID = 6381710233899646281L;
55
56 @XmlValue
57 protected String value;
58
59 @XmlAttribute
60 @XmlJavaTypeAdapter(DateTimeAdapter.class)
61 protected DateTime expirationDate;
62
63 @XmlAttribute
64 @XmlSchemaType(name = "positiveInteger")
65 protected BigInteger completeListSize;
66
67 @XmlAttribute
68 @XmlSchemaType(name = "nonNegativeInteger")
69 protected BigInteger cursor;
70
71 @XmlTransient
72 private MetadataPrefix metadataPrefix;
73
74 @XmlTransient
75 private DateTime from;
76
77 @XmlTransient
78 private DateTime until;
79
80 @XmlTransient
81 private SetSpec set;
82
83 public ResumptionToken(Pager results, DateTime from,
84 DateTime until, MetadataPrefix metadataPrefix, SetSpec set) {
85 this.from = from;
86 this.until = until;
87 this.metadataPrefix = metadataPrefix;
88 this.set = set;
89 this.value = UUID.randomUUID().toString();
90 this.completeListSize = BigInteger.valueOf(results.getCount());
91 this.cursor = BigInteger.valueOf(results.getPageSize() * results.getCurrentIndex());
92 }
93
94 public ResumptionToken() { }
95
96 public String getValue() {
97 return value;
98 }
99
100 public void setValue(String value) {
101 this.value = value;
102 }
103
104 public DateTime getExpirationDate() {
105 return expirationDate;
106 }
107
108 public void setExpirationDate(DateTime value) {
109 this.expirationDate = value;
110 }
111
112 public BigInteger getCompleteListSize() {
113 return completeListSize;
114 }
115
116 public void setCompleteListSize(BigInteger value) {
117 this.completeListSize = value;
118 }
119
120 public BigInteger getCursor() {
121 return cursor;
122 }
123
124 public void setCursor(BigInteger value) {
125 this.cursor = value;
126 }
127
128 public MetadataPrefix getMetadataPrefix() {
129 return metadataPrefix;
130 }
131
132 public DateTime getFrom() {
133 return from;
134 }
135
136 public DateTime getUntil() {
137 return until;
138 }
139
140 public SetSpec getSet() {
141 return set;
142 }
143
144 public void updateResults(Pager results) {
145 this.completeListSize = BigInteger.valueOf(results.getCount());
146 this.cursor = BigInteger.valueOf(results.getPageSize() * results.getCurrentIndex());
147 }
148
149 public static ResumptionToken emptyResumptionToken() {
150 return new ResumptionToken();
151 }
152 }