Package io.mola.galimatias

Examples of io.mola.galimatias.URL


            }
        }
        if ("".equals(trimHtmlSpaces(literal.toString()))) {
            throw newDatatypeException("Must be non-empty.");
        }
        URL url = null;
        URLParsingSettings settings = URLParsingSettings.create().withErrorHandler(
                StrictErrorHandler.getInstance());
        boolean data = false;
        try {
            CharSequencePair pair = splitScheme(literal);
View Full Code Here


    private static ErrorHandler errorHandler = new PrintErrorHandler();

    public static void main(String[] args) {

        URLParsingSettings settings = URLParsingSettings.create().withErrorHandler(errorHandler);
        URL url = null;
        String whatwgUrlSerialized = "";
        String rfc3986UrlSerialized = "";
        String rfc2396UrlSerialized = "";

        boolean parseErrors;

        URL base = null;
        String input = "";
        if (args.length < 1) {
            System.err.println("Need a URL as input");
            System.exit(1);
        } else if (args.length == 1) {
            input = args[0];
        } else if (args.length == 2) {
            try {
                base = URL.parse(args[0]);
            } catch (GalimatiasParseException ex) {
                assert false; // shouldn't get in here unless serious bug
            }
            input = args[1];
        } else {
            System.err.println("Too many args");
            System.exit(1);
        }

        if (base == null) {
            try {
                base = URL.parse("http://example.org/foo/bar");
            } catch (GalimatiasParseException ex) {
                assert false; // shouldn't get in here unless serious bug
            }
        }

        System.out.println("Base: " + base.toString());
        System.out.println("Analyzing URL: " + input);

        try {
            System.out.println("Parsing...");
            url = URL.parse(settings, base, input);
View Full Code Here

    @Override
    public URL canonicalize(final URL input) throws GalimatiasParseException {
        if (input == null) {
            return input;
        }
        URL output = input;
        if (output.isHierarchical()) {
            output = output
                    .withUsername(decodeUnreserved(output.username()))
                    .withPassword(decodeUnreserved(output.password()))
                    .withPath(decodeUnreserved(output.path()));
        }
        return output
                .withQuery(decodeUnreserved(output.query()))
                .withFragment(decodeUnreserved(output.fragment()));
    }
View Full Code Here

import static io.mola.galimatias.URLUtils.*;

public class RFC3986Canonicalizer implements URLCanonicalizer {

    public URL canonicalize(final URL input) throws GalimatiasParseException {
        URL result = input;

        // User
        String user = input.username();
        if (user != null && !user.isEmpty()) {
            StringBuilder newUser = new StringBuilder();
View Full Code Here

import static io.mola.galimatias.URLUtils.*;

public class RFC2396Canonicalizer implements URLCanonicalizer {

    public URL canonicalize(final URL input) throws GalimatiasParseException {
        URL result = input;

        // User
        String user = input.username();
        if (user != null && !user.isEmpty()) {
            StringBuilder newUser = new StringBuilder();
View Full Code Here

        }
    }

    @Override
    public URL canonicalize(final URL input) throws GalimatiasParseException {
        URL result = input;
        for (final URLCanonicalizer canon : canonicalizers) {
            result = canon.canonicalize(result);
        }
        return result;
    }
View Full Code Here

    @Theory
    public void idempotence(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG) TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        final URLCanonicalizer canon = new DecodeUnreservedCanonicalizer();
        final URL roundOne = canon.canonicalize(testURL.parsedURL);
        final URL roundTwo = canon.canonicalize(roundOne);
        assertThat(roundOne).isEqualTo(roundTwo);
        final URL reparse = URL.parse(roundTwo.toString());
        assertThat(reparse).isEqualTo(roundTwo);
    }
View Full Code Here

    @Theory
    public void idempotence(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG) TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        final URLCanonicalizer canon = new RFC2396Canonicalizer();
        final URL roundOne = canon.canonicalize(testURL.parsedURL);
        final URL roundTwo = canon.canonicalize(roundOne);
        assertThat(roundOne).isEqualTo(roundTwo);
        final URL reparse = URL.parse(roundTwo.toString());
        assertThat(reparse).isEqualTo(roundTwo);
    }
View Full Code Here

    @Theory
    public void idempotence(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG) TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        final URLCanonicalizer canon = new RFC2396Canonicalizer();
        final URL roundOne = canon.canonicalize(testURL.parsedURL);
        final URL roundTwo = canon.canonicalize(roundOne);
        assertThat(roundOne).isEqualTo(roundTwo);
        final URL reparse = URL.parse(roundTwo.toString());
        assertThat(reparse).isEqualTo(roundTwo);
    }
View Full Code Here

TOP

Related Classes of io.mola.galimatias.URL

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.