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

com.fitbur.github.dockerjava.api.model.Repository Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.github.dockerjava.api.model;

import java.net.MalformedURLException;
import java.net.URL;

import com.fitbur.google.com.fitburmon.base.Objects;

/**
 * A repository or image name.
 */
public class Repository {
    public final String name;

    /**
     * Name may be eg. 'busybox' or '10.0.0.1:5000/fred'
     * 
     * @param name
     *            Repository name
     */
    public Repository(String name) {
        this.name = name;
    }

    /**
     * Return the URL portion (repository). Note that this might not actually BE a repository location.
     * 
     * @return
     * @throws java.net.MalformedURLException
     */
    public URL getURL() throws MalformedURLException {
        return new URL("http://" + name);
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this).add("name", name).toString();
    }

    public String getPath() {
        if (!name.contains("/"))
            return name;

        return name.substring(name.indexOf("/") + 1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy