Class InetAddressStringParser

java.lang.Object
com.martiansoftware.jsap.StringParser
com.martiansoftware.jsap.stringparsers.InetAddressStringParser

public class InetAddressStringParser
extends StringParser
A StringParser for parsing java.net.InetAddress objects. The parse() method delegates the actual parsing to InetAddress.getByName(String). If InetAddress.getByName() throws an UnknownHostException, it is encapsulated in a ParseException and re-thrown.
Author:
Marty Lamb
See Also:
StringParser, InetAddress
  • Constructor Details

  • Method Details

    • getParser

      public static InetAddressStringParser getParser()
      Returns a InetAddressStringParser.

      Convenient access to the only instance returned by this method is available through JSAP.INETADDRESS_PARSER.

      Returns:
      a InetAddressStringParser.
    • parse

      public java.lang.Object parse​(java.lang.String arg) throws ParseException
      Parses the specified argument into an InetAddress. This method delegates the actual parsing to InetAddress.getByName(arg). If InetAddress.getByName(arg) throws an UnknownHostException, it is encapsulated in a ParseException and re-thrown.
      Specified by:
      parse in class StringParser
      Parameters:
      arg - the argument to parse
      Returns:
      an InetAddress object representing the specified address.
      Throws:
      ParseException - if InetAddress.getByName(arg) throws an UnknownHostException.
      See Also:
      InetAddress, StringParser.parse(String)