com.github.dockerjava.api.model
Class ExposedPort

java.lang.Object
  extended by com.github.dockerjava.api.model.ExposedPort

public class ExposedPort
extends Object

Represents a container port that Docker exposes to external clients. The port is defined by its port number and an InternetProtocol. It can be published by Docker by binding it to a host port, represented by a Ports.Binding.


Nested Class Summary
static class ExposedPort.Deserializer
           
static class ExposedPort.Serializer
           
 
Constructor Summary
ExposedPort(int port)
          Creates an ExposedPort for the given port number and InternetProtocol.DEFAULT.
ExposedPort(int port, InternetProtocol protocol)
          Creates an ExposedPort for the given parameters.
ExposedPort(String scheme, int port)
          Deprecated. use ExposedPort(int, InternetProtocol)
 
Method Summary
 boolean equals(Object obj)
           
 int getPort()
           
 InternetProtocol getProtocol()
           
 String getScheme()
          Deprecated. use getProtocol()
 int hashCode()
           
static ExposedPort parse(String serialized)
          Parses a textual port specification (as used by the Docker CLI) to an ExposedPort.
static ExposedPort tcp(int port)
          Creates an ExposedPort for InternetProtocol.TCP.
 String toString()
          Returns a string representation of this ExposedPort suitable for inclusion in a JSON message.
static ExposedPort udp(int port)
          Creates an ExposedPort for InternetProtocol.UDP.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExposedPort

public ExposedPort(int port,
                   InternetProtocol protocol)
Creates an ExposedPort for the given parameters.

Parameters:
port - the port number
protocol - the InternetProtocol

ExposedPort

public ExposedPort(int port)
Creates an ExposedPort for the given port number and InternetProtocol.DEFAULT.

Parameters:
port - the port number

ExposedPort

@Deprecated
public ExposedPort(String scheme,
                              int port)
Deprecated. use ExposedPort(int, InternetProtocol)

Creates an ExposedPort for the given parameters.

Parameters:
scheme - the scheme, tcp or udp
port - the port number
Method Detail

getProtocol

public InternetProtocol getProtocol()
Returns:
the InternetProtocol of the port that the container exposes

getScheme

@Deprecated
public String getScheme()
Deprecated. use getProtocol()

Returns:
the scheme (internet protocol), tcp or udp

getPort

public int getPort()
Returns:
the port number that the container exposes

tcp

public static ExposedPort tcp(int port)
Creates an ExposedPort for InternetProtocol.TCP. This is a shortcut for new ExposedPort(port, InternetProtocol.TCP)


udp

public static ExposedPort udp(int port)
Creates an ExposedPort for InternetProtocol.UDP. This is a shortcut for new ExposedPort(port, InternetProtocol.UDP)


parse

public static ExposedPort parse(String serialized)
                         throws IllegalArgumentException
Parses a textual port specification (as used by the Docker CLI) to an ExposedPort.

Parameters:
serialized - the specification, e.g. 80/tcp
Returns:
an ExposedPort matching the specification
Throws:
IllegalArgumentException - if the specification cannot be parsed

toString

public String toString()
Returns a string representation of this ExposedPort suitable for inclusion in a JSON message. The format is port/protocol, like the argument in parse(String).

Overrides:
toString in class Object
Returns:
a string representation of this ExposedPort

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014. All rights reserved.