diff --git a/src/main/java/se/kb/oai/pmh/ListBase.java b/src/main/java/se/kb/oai/pmh/ListBase.java new file mode 100644 index 0000000..46aafcd --- /dev/null +++ b/src/main/java/se/kb/oai/pmh/ListBase.java @@ -0,0 +1,47 @@ +package se.kb.oai.pmh; + +import java.util.List; + +import org.dom4j.Document; + +public class ListBase extends ResponseBase { + + protected List list; + + public ListBase(Document document) throws ErrorResponseException { + super(document); + } + + /** + * Get the size of the list. + * + * @return the size + */ + public int size() { + return list.size(); + } + + /** + * Get a the content of the response as a list of type T. + * + * @return a list with objects of type T + */ + public List asList() { + return list; + } + + /** + * Get the ResumptionToken, if any, for this response. + * + * @return the ResumptionToken, or null + * if none available + */ + public ResumptionToken getResumptionToken() { + if (super.resumptionToken == null + || super.resumptionToken.getId() == null + || super.resumptionToken.getId().length() == 0) + return null; + + return super.resumptionToken; + } +}