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

org.leibnizcenter.uk.legislation.FindDocWithX Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package org.leibnizcenter.uk.legislation;

import org.w3._2005.atom.Entry;
import org.w3._2005.atom.Feed;
import org.xml.sax.SAXException;
import uk.gov.legislation.namespaces.legislation.Legislation;

import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

/**
 * Created by maarten on 7-10-15.
 */
public class FindDocWithX {
    private static final String[] SEARCH_FOR_ME = {
//            "Primary",
            "Secondary",
            "secondary",
            "footnote",
            "Footnote",
            "marginNote",
            "MarginNote",
//            "versions",
//            "Versions",
//            "resources",
//            "Resources",
//            "commentaries",
//            "Commentaries",
            "citation",
            "CitationList"
    };

    public static void main(String[] args) throws ParserConfigurationException, JAXBException, ApiInterface.FeedException, SAXException, IOException {
        int i = 5;
        boolean found = false;
        do {
            Feed f = ApiInterface.getFeed(new FeedRequestBuilder().setPage(i).build());
            System.out.println(i);//Checking " + url);
            for (Entry e : f.getEntries()) {
                if (e.getAlternateXmlLinks().size() > 0) {
                    String url = e.getAlternateXmlLinks().iterator().next().getHref();
                    Legislation leg = ApiInterface.parseLegislationDoc(url);
//                    String str = ApiInterface.getString(url);
//                    for (String s : SEARCH_FOR_ME) {
                    found =
                            leg.getCitationLists() != null && leg.getCitationLists().getCitationLists().size() > 0
                                    || leg.getMarginNotes() != null && leg.getMarginNotes().getMarginNotes().size() > 0
                                    || leg.getSecondary() != null
                                    || leg.getFootnotes() != null && leg.getFootnotes().getFootnotes().size() != 0
                    ;
                    if (found) {
                        System.out.println("==============================");
                        System.out.println("String xmlUrl = \"" + url + "\";");
                        break;
//                        }
                    }
                    if (found) {
                        break;
                    }
                }
            }
            i++;
        } while (!found);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy