Package jnr.netdb

Class Protocol


  • public final class Protocol
    extends java.lang.Object
    An entry in the system protocol database
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  Protocol.ProtocolDBSingletonHolder
      Holds the global lazily-loaded instance of the ProtocolDB
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Collection<java.lang.String> aliases
      All the aliases for this protocol
      private int proto  
      private java.lang.String protocolName
      Official protocol name
    • Constructor Summary

      Constructors 
      Constructor Description
      Protocol​(java.lang.String name, int proto, java.util.Collection<java.lang.String> aliases)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<java.lang.String> getAliases()
      Returns a list of aliases this Protocol is also known by.
      java.lang.String getName()
      Returns the official IANA name of this Protocol
      int getProto()
      Returns the official IANA protocol number for this Protocol
      static Protocol getProtocolByName​(java.lang.String name)
      Locates a protocol by name.
      static Protocol getProtocolByNumber​(int proto)
      Locates a protocol by number.
      private static ProtocolsDB getProtocolDB()
      Returns the currently loaded ProtocolDB
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • protocolName

        private final java.lang.String protocolName
        Official protocol name
      • proto

        private final int proto
      • aliases

        private final java.util.Collection<java.lang.String> aliases
        All the aliases for this protocol
    • Constructor Detail

      • Protocol

        Protocol​(java.lang.String name,
                 int proto,
                 java.util.Collection<java.lang.String> aliases)
    • Method Detail

      • getProtocolByName

        public static final Protocol getProtocolByName​(java.lang.String name)
        Locates a protocol by name.
        Parameters:
        name - the official IANA name for the protocol, or an alias.
        Returns:
        a Protocol instance, or null if the protocol could not be found.
      • getProtocolByNumber

        public static final Protocol getProtocolByNumber​(int proto)
        Locates a protocol by number.
        Parameters:
        proto - the internet protocol number of the protocol.
        Returns:
        a Protocol instance, or null if the protocol could not be found.
      • getName

        public final java.lang.String getName()
        Returns the official IANA name of this Protocol
        Returns:
        The name of this Protocol as a String
      • getProto

        public final int getProto()
        Returns the official IANA protocol number for this Protocol
        Returns:
        The protocol number for this Protocol as an int
      • getAliases

        public final java.util.Collection<java.lang.String> getAliases()
        Returns a list of aliases this Protocol is also known by.
        Returns:
        A Collection of Strings for aliases this Protocol
      • getProtocolDB

        private static final ProtocolsDB getProtocolDB()
        Returns the currently loaded ProtocolDB
        Returns:
        an instance of ProtocolDB
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object