TTTO.MasterServer
Class HelpMethods

java.lang.Object
  extended by TTTO.MasterServer.HelpMethods

public class HelpMethods
extends java.lang.Object

Various common methods

Author:
emi-lind

Constructor Summary
private HelpMethods()
           
 
Method Summary
static java.lang.String limitString(java.lang.String aString, int aLimitSize)
          Checks if a strings length is bigger then aSize.
static java.lang.String socketAsString(java.net.Socket aSocket)
          Creates a string representation of a socket.
static boolean validateIPv4(java.lang.String aIp)
          Validates an dot-decimal notated IPv4
static boolean validatePort(java.lang.String aPort)
          Validates a port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelpMethods

private HelpMethods()
Method Detail

validateIPv4

public static boolean validateIPv4(java.lang.String aIp)
Validates an dot-decimal notated IPv4

Parameters:
aIp - The ip to validate
Returns:
true if it got validated

validatePort

public static boolean validatePort(java.lang.String aPort)
Validates a port. Checks for digits and if the port is between 0 and 65535

Parameters:
aPort - the port to check
Returns:
true if 0 - 65535

socketAsString

public static java.lang.String socketAsString(java.net.Socket aSocket)
Creates a string representation of a socket. Format: ip:port

Parameters:
aSocket - The socket to get the representation from
Returns:
the representation

limitString

public static java.lang.String limitString(java.lang.String aString,
                                           int aLimitSize)
Checks if a strings length is bigger then aSize. If it is, the string will get shrinked. Else it won't do anything.

Parameters:
aString - The string to check
aSize - Max length you want on the string
Returns:
the new checked string.