Package org.apache.any23.source

Examples of org.apache.any23.source.HTTPDocumentSource


        }
    }

    protected DocumentSource createHTTPDocumentSource(HTTPClient httpClient, String uri)
            throws IOException, URISyntaxException {
        return new HTTPDocumentSource(httpClient, uri);
    }
View Full Code Here


        if(documentURI == null) throw new NullPointerException("documentURI cannot be null.");
        if (documentURI.toLowerCase().startsWith("file:")) {
            return new FileDocumentSource( new File(new URI(documentURI)) );
        }
        if (documentURI.toLowerCase().startsWith("http:") || documentURI.toLowerCase().startsWith("https:")) {
            return new HTTPDocumentSource(getHTTPClient(), documentURI);
        }
        throw new IllegalArgumentException(
                String.format("Unsupported protocol for document URI: '%s' .", documentURI)
        );
    }
View Full Code Here

        assumeOnlineAllowed();

        /*1*/ Any23 runner = new Any23();
        /*2*/ runner.setHTTPUserAgent("test-user-agent");
        /*3*/ HTTPClient httpClient = runner.getHTTPClient();
        /*4*/ DocumentSource source = new HTTPDocumentSource(
                 httpClient,
                 "http://dbpedia.org/resource/Trento"
              );
        /*5*/ ByteArrayOutputStream out = new ByteArrayOutputStream();
        /*6*/ TripleHandler handler = new NTriplesWriter(out);
View Full Code Here

        assumeOnlineAllowed();

        Any23 runner = new Any23();
        runner.setHTTPUserAgent("test-user-agent");
        HTTPClient httpClient = runner.getHTTPClient();
        DocumentSource source = new HTTPDocumentSource(
                httpClient,
                "http://products.semweb.bestbuy.com/y/products/7590289/"
        );
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TripleHandler handler = new NTriplesWriter(out);
View Full Code Here

        @Override
        public DocumentSource convert( String value ) {
            final Matcher httpMatcher = HTTP_DOCUMENT_PATTERN.matcher(value);
            if (httpMatcher.find()) {
                try {
                    return new HTTPDocumentSource(DefaultHTTPClient.createInitializedHTTPClient(), value);
                } catch ( URISyntaxException e ) {
                    throw new ParameterException("Invalid source URI: '" + value + "'");
                }
            }
            final Matcher fileMatcher = FILE_DOCUMENT_PATTERN.matcher(value);
View Full Code Here

        if(documentURI == null) throw new NullPointerException("documentURI cannot be null.");
        if (documentURI.toLowerCase().startsWith("file:")) {
            return new FileDocumentSource( new File(new URI(documentURI)) );
        }
        if (documentURI.toLowerCase().startsWith("http:") || documentURI.toLowerCase().startsWith("https:")) {
            return new HTTPDocumentSource(getHTTPClient(), documentURI);
        }
        throw new IllegalArgumentException(
                String.format("Unsupported protocol for document URI: '%s' . "
                    + "Check that document URI contains a protocol.", documentURI)
        );
View Full Code Here

        assumeOnlineAllowed();

        /* 1 */Any23 runner = new Any23();
        /* 2 */runner.setHTTPUserAgent("test-user-agent");
        /* 3 */HTTPClient httpClient = runner.getHTTPClient();
        /* 4 */DocumentSource source = new HTTPDocumentSource(httpClient,
                "http://dbpedia.org/resource/Trento");
        /* 5 */ByteArrayOutputStream out = new ByteArrayOutputStream();
        /* 6 */TripleHandler handler = new NTriplesWriter(out);
        try {
            /* 7 */runner.extract(source, handler);
View Full Code Here

        assumeOnlineAllowed();

        Any23 runner = new Any23();
        runner.setHTTPUserAgent("test-user-agent");
        HTTPClient httpClient = runner.getHTTPClient();
        DocumentSource source = new HTTPDocumentSource(httpClient,
                "http://products.semweb.bestbuy.com/y/products/7590289/");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TripleHandler handler = new NTriplesWriter(out);
        runner.extract(source, handler);
        String n3 = out.toString("UTF-8");
View Full Code Here

        @Override
        public DocumentSource convert( String value ) {
            final Matcher httpMatcher = HTTP_DOCUMENT_PATTERN.matcher(value);
            if (httpMatcher.find()) {
                try {
                    return new HTTPDocumentSource(DefaultHTTPClient.createInitializedHTTPClient(), value);
                } catch ( URISyntaxException e ) {
                    throw new ParameterException("Invalid source URI: '" + value + "'");
                }
            }
            final Matcher fileMatcher = FILE_DOCUMENT_PATTERN.matcher(value);
View Full Code Here

        if(documentURI == null) throw new NullPointerException("documentURI cannot be null.");
        if (documentURI.toLowerCase().startsWith("file:")) {
            return new FileDocumentSource( new File(new URI(documentURI)) );
        }
        if (documentURI.toLowerCase().startsWith("http:") || documentURI.toLowerCase().startsWith("https:")) {
            return new HTTPDocumentSource(getHTTPClient(), documentURI);
        }
        throw new IllegalArgumentException(
                String.format("Unsupported protocol for document URI: '%s' .", documentURI)
        );
    }
View Full Code Here

TOP

Related Classes of org.apache.any23.source.HTTPDocumentSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.