com.lyncode.xoai.model.oaipmh.Header Maven / Gradle / Ivy
package com.lyncode.xoai.model.oaipmh;
import com.lyncode.xml.exceptions.XmlWriteException;
import com.lyncode.xoai.xml.XmlWriter;
import com.lyncode.xoai.xml.XmlWritable;
import javax.xml.stream.XMLStreamException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Header implements XmlWritable {
protected String identifier;
protected Date datestamp;
protected List setSpec = new ArrayList();
protected Status status;
public String getIdentifier() {
return identifier;
}
public Header withIdentifier(String value) {
this.identifier = value;
return this;
}
public Date getDatestamp() {
return datestamp;
}
public Header withDatestamp(Date value) {
this.datestamp = value;
return this;
}
public List getSetSpecs() {
return this.setSpec;
}
public Status getStatus() {
return status;
}
public Header withStatus(Status value) {
this.status = value;
return this;
}
public Header withSetSpec(String setSpec) {
this.setSpec.add(setSpec);
return this;
}
public boolean isDeleted () {
return this.status != null;
}
@Override
public void write(XmlWriter writer) throws XmlWriteException {
try {
if (this.status != null)
writer.writeAttribute("status", this.status.value());
writer.writeElement("identifier", identifier);
writer.writeElement("datestamp", datestamp);
for (String setSpec : this.getSetSpecs())
writer.writeElement("setSpec", setSpec);
} catch (XMLStreamException e) {
throw new XmlWriteException(e);
}
}
public enum Status {
DELETED("deleted");
private final String representation;
Status(String representation) {
this.representation = representation;
}
public String value() {
return representation;
}
public static Status fromRepresentation(String representation) {
for (Status status : Status.values()) {
if (status.representation.equals(representation)) {
return status;
}
}
throw new IllegalArgumentException(representation);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy