/*
 * central4j - an api for accessing maven central
 * Copyright 2016 MeBigFatGuy.com
 * Copyright 2016 Dave Brosius
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations
 * under the License.
 */
package com.mebigfatguy.central4j;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class ArtifactIterator implements Iterator<Artifact> {

    private Map<String, List<String>> browseResults;

    public ArtifactIterator() {

    }

    @Override
    public boolean hasNext() {
        return false;
    }

    @Override
    public Artifact next() {
        return null;
    }

}

@@ -724,218 +724,1122 @@
 ava.
-util.Iterator;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Apublic class ArtifactIterator implements Iterator%3CArtifact%3E %7B%0A%0A    private Map%3CString, List%3CString%3E%3E browseResults;%0A%0A    public ArtifactIterator() %7B%0A
+io.BufferedInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.URL;%0Aimport java.util.ArrayDeque;%0Aimport java.util.Collections;%0Aimport java.util.Deque;%0Aimport java.util.HashSet;%0Aimport java.util.Iterator;%0Aimport java.util.Set;%0A%0Aimport org.xml.sax.Attributes;%0Aimport org.xml.sax.InputSource;%0Aimport org.xml.sax.SAXException;%0Aimport org.xml.sax.XMLReader;%0Aimport org.xml.sax.helpers.DefaultHandler;%0Aimport org.xml.sax.helpers.XMLReaderFactory;%0A%0Aimport com.mebigfatguy.central4j.internal.CentralURLs;%0A%0Apublic class ArtifactIterator implements Iterator%3CArtifact%3E %7B%0A%0A    private static final Set%3CString%3E IGNORED_EXTENSIONS;%0A%0A    static %7B%0A        Set%3CString%3E ie = new HashSet%3CString%3E();%0A        ie.add(%22%22);%0A        ie.add(%22asc%22);%0A        ie.add(%22html%22);%0A        ie.add(%22md5%22);%0A        ie.add(%22pom%22);%0A        ie.add(%22sha1%22);%0A        ie.add(%22xml%22);%0A%0A        IGNORED_EXTENSIONS = Collections.unmodifiableSet(ie);%0A    %7D%0A%0A    private Deque%3CString%3E browseResults;%0A%0A    public ArtifactIterator() %7B%0A        browseResults = new ArrayDeque%3C%3E(200);%0A        populateBrowse(CentralURLs.ITERATION_URL);
 %0A   
@@ -1906,13 +1906,32 @@
 urn 
-false
+!browseResults.isEmpty()
 ;%0A  
@@ -2006,10 +2006,1114 @@
 %0A    %7D%0A%0A
+    private void populateBrowse(URL u) %7B%0A        try (InputStream is = new BufferedInputStream(u.openStream())) %7B%0A%0A            XMLReader r = XMLReaderFactory.createXMLReader();%0A            r.setContentHandler(new BrowseHandler(%22%22));%0A            r.parse(new InputSource(is));%0A        %7D catch (IOException %7C SAXException e) %7B%0A            // we just won't return results%0A        %7D%0A    %7D%0A%0A    class BrowseHandler extends DefaultHandler %7B%0A%0A        private String root;%0A%0A        public BrowseHandler(String rootPath) %7B%0A            root = rootPath + '/';%0A        %7D%0A%0A        @Override%0A        public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException %7B%0A            if (%22a%22.equals(localName)) %7B%0A                String href = attributes.getValue(%22href%22);%0A                int dotPos = href.lastIndexOf('.');%0A%0A                String extension = dotPos %3C 0 ? %22ok%22 : href.substring(dotPos + 1);%0A%0A                if (!IGNORED_EXTENSIONS.contains(extension)) %7B%0A                    browseResults.addLast(root + href);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %7D%0A

add basic iteration page parsing