All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.w3._2005.atom.Entry Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 
// See http://java.sun.com/xml/jaxb 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2015.08.07 at 06:17:52 PM CEST 
//


package org.w3._2005.atom;


import org.leibnizcenter.uk.legislation.ApiInterface;
import org.leibnizcenter.uk.legislation.uri.TopLevelUri;
import org.xml.sax.SAXException;
import uk.gov.legislation.namespaces.legislation.Legislation;
import uk.gov.legislation.namespaces.metadata.*;
import uk.gov.legislation.namespaces.metadata.Number;

import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;


/**
 * 

Java class for anonymous complex type. *

*

The following schema fragment specifies the expected content contained within this class. *

*

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <choice maxOccurs="unbounded" minOccurs="0">
 *         <element ref="{http://www.w3.org/2005/Atom}author"/>
 *         <element ref="{http://www.w3.org/2005/Atom}category"/>
 *         <element ref="{http://www.w3.org/2005/Atom}content"/>
 *         <element ref="{http://www.w3.org/2005/Atom}contributor"/>
 *         <element ref="{http://www.w3.org/2005/Atom}id"/>
 *         <element ref="{http://www.w3.org/2005/Atom}link"/>
 *         <element ref="{http://www.w3.org/2005/Atom}published"/>
 *         <element ref="{http://www.w3.org/2005/Atom}rights"/>
 *         <element ref="{http://www.w3.org/2005/Atom}source"/>
 *         <element ref="{http://www.w3.org/2005/Atom}summary"/>
 *         <element ref="{http://www.w3.org/2005/Atom}title"/>
 *         <element ref="{http://www.w3.org/2005/Atom}updated"/>
 *       </choice>
 *       <attGroup ref="{http://www.w3.org/2005/Atom}atomCommonAttributes"/>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
*/ @XmlAccessorType(XmlAccessType.FIELD) //@XmlType(name = "", propOrder = { // "authorsAndCategoriesAndContents" //}) @XmlRootElement(name = "entry") public class Entry { // Ignoring this generated stuff for our homegrown solution // // @XmlElementRefs({ // @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = Source.class, required = false), // @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = Link.class, required = false), // @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = Content.class, required = false), // @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), // @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = Category.class, required = false), // @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = Id.class, required = false), // @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false) // }) // protected List authorsAndCategoriesAndContents; /** * Collection of Link types */ @XmlElement(required = true, name = "link") public final Collection links = new HashSet<>(); // Start custom definition (overriding generated codes) @XmlElement(required = true) public String id; /** * Document title */ @XmlElement(required = true) public String title; /** * DateTime on which the document was last updated (i.e., not necessarily through a formal amendment) */ @XmlElement(required = true) public String updated; @XmlElement(required = true) public String summary; @XmlElement(required = true) public String published; @XmlElement(required = true, namespace = "http://www.legislation.gov.uk/namespaces/metadata", name = "DocumentMainType") public DocumentMainType documentMainType; /** * Year as it appears in the representation URI */ @XmlElement(required = true, namespace = "http://www.legislation.gov.uk/namespaces/metadata", name = "Year") public Year year; /** * Number as it appears in the representation URI */ @XmlElement(required = true, namespace = "http://www.legislation.gov.uk/namespaces/metadata", name = "Number") public uk.gov.legislation.namespaces.metadata.Number number; /** * Date on which this law was created. Maybe always the same date as {@code published}? */ @XmlElement(required = true, namespace = "http://www.legislation.gov.uk/namespaces/metadata", name = "CreationDate") public uk.gov.legislation.namespaces.metadata.CreationDate creationDate; /** * ISBN number for this law */ @XmlElement(required = true, namespace = "http://www.legislation.gov.uk/namespaces/metadata", name = "isbn") public ISBN isbn; // End custom definition (overriding generated codes) @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") @XmlSchemaType(name = "anyURI") protected String base; @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlSchemaType(name = "language") protected String lang; // Ignore generated code: // // /** // * Gets the value of the authorsAndCategoriesAndContents property. // *

// *

// * This accessor method returns a reference to the live list, // * not a snapshot. Therefore any modification you make to the // * returned list will be present inside the JAXB object. // * This is why there is not a set method for the authorsAndCategoriesAndContents property. // *

// *

// * For example, to add a new item, do as follows: // *

//     *    getAuthorsAndCategoriesAndContents().add(newItem);
//     * 
// *

// *

// *

// * Objects of the following type(s) are allowed in the list // * {@link JAXBElement }{@code <}{@link AtomTextConstruct }{@code >} // * {@link JAXBElement }{@code <}{@link AtomPersonConstruct }{@code >} // * {@link Source } // * {@link JAXBElement }{@code <}{@link AtomDateConstruct }{@code >} // * {@link JAXBElement }{@code <}{@link AtomTextConstruct }{@code >} // * {@link JAXBElement }{@code <}{@link AtomPersonConstruct }{@code >} // * {@link Link } // * {@link Content } // * {@link JAXBElement }{@code <}{@link AtomTextConstruct }{@code >} // * {@link Category } // * {@link Id } // * {@link JAXBElement }{@code <}{@link AtomDateConstruct }{@code >} // */ // public List getAuthorsAndCategoriesAndContents() { // if (authorsAndCategoriesAndContents == null) { // authorsAndCategoriesAndContents = new ArrayList(); // } // return this.authorsAndCategoriesAndContents; // } /** * Gets the value of the base property. * * @return possible object is * {@link String } */ public String getBase() { return base; } /** * Sets the value of the base property. * * @param value allowed object is * {@link String } */ public void setBase(String value) { this.base = value; } /** * Gets the value of the lang property. * * @return possible object is * {@link String } */ public String getLang() { return lang; } /** * Sets the value of the lang property. * * @param value allowed object is * {@link String } */ public void setLang(String value) { this.lang = value; } public List getTableOfContentsLinks() { return getLinksForRel("http://purl.org/dc/terms/tableOfContents"); } public List getHtmlSnippets() { List links = new ArrayList<>(getLinks().size()); for (Link l : getLinks()) { if ("alternate".equals(l.getRel()) && "application/xhtml+xml".equals(l.getType())) { links.add(l); } } return links; } /** * @return Link to English HTML, null if not found */ public Link getEnglishHtmlSnippet() { for (Link l : getLinks()) { if ("alternate".equals(l.getRel()) && "application/xhtml+xml".equals(l.getType()) && ( l.getHreflang() == null || "en".equals(l.getHreflang()) || l.getHreflang().trim().length() == 0) ) { return l; } } return null; } /** * @return Link to Welsh HTML, null if not found */ public Link getWelshHtmlSnippet() { for (Link l : getLinks()) { if ("alternate".equals(l.getRel()) && "application/xhtml+xml".equals(l.getType()) && "cy".equals(l.getHreflang()) ) { return l; } } return null; } /** * @return Links with the "alternate" attribute */ public List getAlternateLinks() { return getLinksForRel("alternate"); } /** * @param rel "rel" attribute to query links for. (E.g.; @code{}) * @return List of links which have the given "rel" attribute */ public List getLinksForRel(String rel) { List links = new ArrayList<>(getLinks().size()); for (Link l : getLinks()) { if (rel.equals(l.getRel())) { links.add(l); } } return links; } /** * @return Legislation that represents the English table of contents (as opposed to Welsh) * @throws ParserConfigurationException * @throws JAXBException * @throws SAXException * @throws IOException */ public Legislation getEnglishTableOfContents() throws ParserConfigurationException, JAXBException, SAXException, IOException { for (Link link : getTableOfContentsLinks()) { String lang = link.getHreflang() == null ? "en" : link.getHreflang(); //Default language is English if ("en".equals(lang)) { return ApiInterface.parseLegislationDoc(link.getHref() + "/data.xml"); } } return null; } /** * @return Legislation that represents the Welsh table of contents (as opposed to English) * @throws ParserConfigurationException * @throws JAXBException * @throws SAXException * @throws IOException */ public Legislation getWelshTableOfContents() throws ParserConfigurationException, JAXBException, SAXException, IOException { for (Link link : getTableOfContentsLinks()) { if ("cy".equals(link.getHreflang())) { return ApiInterface.parseLegislationDoc(link.getHref() + "/data.xml"); } } return null; } public List getAllTableOfContents() throws ParserConfigurationException, JAXBException, SAXException, IOException { List contents = new ArrayList<>(getTableOfContentsLinks().size()); for (Link l : getTableOfContentsLinks()) { Legislation leg = ApiInterface.parseLegislationDoc(l.getHref() + "/data.xml"); contents.add(leg); } return contents; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public Collection getLinks() { return links; } public String getUpdated() { return updated; } public void setUpdated(String updated) { this.updated = updated; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public String getPublished() { return published; } public void setPublished(String published) { this.published = published; } public DocumentMainType getDocumentMainType() { return documentMainType; } public void setDocumentMainType(DocumentMainType documentMainType) { this.documentMainType = documentMainType; } public Year getYear() { return year; } public void setYear(Year year) { this.year = year; } public uk.gov.legislation.namespaces.metadata.Number getNumber() { return number; } public void setNumber(Number number) { this.number = number; } public CreationDate getCreationDate() { return creationDate; } public void setCreationDate(CreationDate creationDate) { this.creationDate = creationDate; } public ISBN getIsbn() { return isbn; } public void setIsbn(ISBN isbn) { this.isbn = isbn; } /** * @return Representation URI for this law */ public TopLevelUri getUriObject() { String backupLink = null; for (Link link : links) { backupLink = link.href; if ("self".equals(link.rel)) { break; } } return new TopLevelUri(backupLink, getYear().asInt(), getNumber().asInt()); } public static class TagWithValueAttribute { @XmlAttribute(name = "Value") public String value; public TagWithValueAttribute() { } public TagWithValueAttribute(String c) { value = c; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } @Override public String toString() { return value; } } }