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

com.cemiltokatli.jurl.Protocol Maven / Gradle / Ivy

Go to download

JURL is a Java URL builder library that allows you to create URLs with different schemes without dealing with string building or concatenation.

The newest version!
package com.cemiltokatli.jurl;

/**
 * An object of this class represents a file protocol.
 * This class also has static fields that are used by the build method of the JURL class for creating
 * a new URL object.
 *
 * @param  the type
 */
public class Protocol {
    /**
     * Used for creating a URL with "http" scheme.
     */
    public static final Protocol HTTP = new Protocol<>(HttpURL.class, "http://");
    /**
     * Used for creating a URL with "https" scheme.
     */
    public static final Protocol HTTPS = new Protocol<>(HttpURL.class, "https://");
    /**
     * Used for creating a URL with "file" scheme.
     */
    public static final Protocol FILE = new Protocol<>(FileURL.class, "file://");
    /**
     * Used for creating a URL with "ftp" scheme.
     */
    public static final Protocol FTP = new Protocol<>(FileURL.class, "ftp://");
    /**
     * Used for creating a URL with "ftps" scheme.
     */
    public static final Protocol FTPS = new Protocol<>(FileURL.class, "ftps://");
    /**
     * Used for creating a URL with "sftp" scheme.
     */
    public static final Protocol SFTP = new Protocol<>(FileURL.class, "sftp://");
    /**
     * Used for creating a URL with "data" scheme.
     */
    public static final Protocol DATA = new Protocol<>(DataURL.class, "data:");
    /**
     * Used for creating a URL with "telnet" scheme.
     */
    public static final Protocol TELNET = new Protocol<>(TelnetURL.class, "telnet://");
    /**
     * Used for creating a URL with "mailto" scheme.
     */
    public static final Protocol MAILTO = new Protocol<>(MailtoURL.class, "mailto:");

    private Class type;
    private String protocol;

    /**
     * Creates a new protocol object with the given type and protocol.
     *
     * @param type the class type
     * @param protocol the protocol
     */
    Protocol(Class type, String protocol){
        this.type = type;
        this.protocol = protocol;
    }

    /**
     * Returns the protocol.
     *
     * @return the protocol.
     */
    String getProtocol(){
        return protocol;
    }

    /**
     * Returns the class type.
     *
     * @return the class type.
     */
    Class getType(){
        return type;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy