Class Utilfns

java.lang.Object
  extended by Utilfns

public final class Utilfns
extends java.lang.Object


Method Summary
static void appendStringToFile(java.lang.String filename, java.lang.String instr)
           
static boolean arrayOfNulls(ByteArray in)
           
static java.lang.String asciiByteArrayToString(ByteArray in)
           
static ByteArray bigIntToByteArray(java.math.BigInteger in, int len)
           
static ByteArray booltobytearr(boolean in)
           
static java.math.BigInteger byteArrayToBigInteger(ByteArray in)
           
static ByteArray byteArrayToByteHexStr(ByteArray barray)
           
static java.lang.String byteArrayToHexStr(ByteArray barray)
           
static boolean bytearrtobool(ByteArray in)
           
static int bytearrtoint(ByteArray in)
           
static long bytearrtolong(ByteArray in)
           
static ByteArray byteHexStrToByteArray(ByteArray s)
           
static ByteArray chartobytearray(char inchar)
           
static java.lang.String chartohexstring(char inchar)
           
static java.lang.String containsproblematiccharacter(java.lang.String inputstr)
          Returns the empty string if inputstr contains a problematic character.
static java.lang.String formatwithleadingzeros(int x)
           
static java.net.InetAddress getAddressByAddress(ByteArray addr)
           
static java.net.InetAddress getAddressByName(java.lang.String host)
           
static java.lang.String getnamerunningprog()
          Works when called from the main thread
static ByteArray hexStrToByteArray(java.lang.String s)
           
static ByteArray incrementByteArray(ByteArray in)
           
static ByteArray int2bytearr(int in)
           
static boolean isFunkyString(java.lang.String in)
           
static boolean isPrintableASCII(byte b)
           
static boolean isPrintableASCIIByteArray(ByteArray in)
           
static boolean isProblematicCharacter(char c)
          Returns true if and only if c is a problematic character.
static boolean isValid2DigitHex(java.lang.String s)
           
static boolean isValid4DigitHex(java.lang.String s)
           
static boolean isValid8DigitHex(java.lang.String s)
           
static boolean isValidAddress(java.lang.String s)
           
static boolean isvalidfilename(java.lang.String filename)
           
static boolean isValidIPv4String(java.lang.String s)
           
static boolean isvalidprocidstring(java.lang.String s)
           
static ByteArray longtobytearr(long in)
           
static void main()
           
static java.lang.String normalizeString(java.lang.String in)
           
static java.lang.String outputErrorForFunkyString()
           
static Readbinfl readBinaryFile(java.lang.String filename)
           
static java.lang.String stdinReadLine()
           
static ByteArray string2ASCIIByteArray(java.lang.String in)
           
static Stou16 stringToU16(java.lang.String s)
           
static void systemoutprint(java.lang.String s)
           
static void systemoutprintln(java.lang.String s)
           
static void verifyJavaVersion()
           
static void writeBinaryFile(java.lang.String filename, ByteArray data)
           
static java.net.InetAddress yygetbyaddress(ByteArray addr)
           
static java.net.InetAddress yygetbyname(java.lang.String host)
           
static java.net.InetAddress yygetlocalhost()
          Makes 4 attempts at getting the localhost InetAddress.
static void yysleep(long millisec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getnamerunningprog

public static java.lang.String getnamerunningprog()
Works when called from the main thread


systemoutprintln

public static void systemoutprintln(java.lang.String s)

systemoutprint

public static void systemoutprint(java.lang.String s)

isProblematicCharacter

public static boolean isProblematicCharacter(char c)
Returns true if and only if c is a problematic character. A problematic character is a character that causes issues when it is passed at the command line to a Java program in bash when it is intended to be a symbol in a string argument to the Java program.


containsproblematiccharacter

public static java.lang.String containsproblematiccharacter(java.lang.String inputstr)
Returns the empty string if inputstr contains a problematic character. It returns a non-empty string describing the problematic character otherwise.


formatwithleadingzeros

public static java.lang.String formatwithleadingzeros(int x)
                                               throws FeralcoreException
Throws:
FeralcoreException

incrementByteArray

public static ByteArray incrementByteArray(ByteArray in)

longtobytearr

public static ByteArray longtobytearr(long in)

chartobytearray

public static ByteArray chartobytearray(char inchar)

chartohexstring

public static java.lang.String chartohexstring(char inchar)

bytearrtolong

public static long bytearrtolong(ByteArray in)

int2bytearr

public static ByteArray int2bytearr(int in)

bytearrtoint

public static int bytearrtoint(ByteArray in)

booltobytearr

public static ByteArray booltobytearr(boolean in)

bytearrtobool

public static boolean bytearrtobool(ByteArray in)

isValid2DigitHex

public static boolean isValid2DigitHex(java.lang.String s)

isValid4DigitHex

public static boolean isValid4DigitHex(java.lang.String s)

isValid8DigitHex

public static boolean isValid8DigitHex(java.lang.String s)

isValidAddress

public static boolean isValidAddress(java.lang.String s)

yygetbyaddress

public static java.net.InetAddress yygetbyaddress(ByteArray addr)
                                           throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

yygetbyname

public static java.net.InetAddress yygetbyname(java.lang.String host)
                                        throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

yygetlocalhost

public static java.net.InetAddress yygetlocalhost()
                                           throws java.net.UnknownHostException,
                                                  java.lang.InterruptedException
Makes 4 attempts at getting the localhost InetAddress. A feralcore node in the Linode.com cloud once threw the UnknownHostException when calling InetAddress.getLocalHost(). It was wierd because another feralcore node running on the same machine did not throw at that time. As a result of that event, the iterative approach with sleep and try-catch was implemented.

Throws:
java.net.UnknownHostException
java.lang.InterruptedException

yysleep

public static void yysleep(long millisec)
                    throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

string2ASCIIByteArray

public static ByteArray string2ASCIIByteArray(java.lang.String in)

isPrintableASCII

public static boolean isPrintableASCII(byte b)

isPrintableASCIIByteArray

public static boolean isPrintableASCIIByteArray(ByteArray in)

asciiByteArrayToString

public static java.lang.String asciiByteArrayToString(ByteArray in)
                                               throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

arrayOfNulls

public static boolean arrayOfNulls(ByteArray in)
                            throws FeralcoreException
Throws:
FeralcoreException

byteArrayToBigInteger

public static java.math.BigInteger byteArrayToBigInteger(ByteArray in)

bigIntToByteArray

public static ByteArray bigIntToByteArray(java.math.BigInteger in,
                                          int len)

byteArrayToHexStr

public static java.lang.String byteArrayToHexStr(ByteArray barray)

hexStrToByteArray

public static ByteArray hexStrToByteArray(java.lang.String s)

byteArrayToByteHexStr

public static ByteArray byteArrayToByteHexStr(ByteArray barray)

byteHexStrToByteArray

public static ByteArray byteHexStrToByteArray(ByteArray s)

writeBinaryFile

public static void writeBinaryFile(java.lang.String filename,
                                   ByteArray data)
                            throws java.io.IOException
Throws:
java.io.IOException

appendStringToFile

public static void appendStringToFile(java.lang.String filename,
                                      java.lang.String instr)
                               throws java.io.IOException
Throws:
java.io.IOException

isvalidfilename

public static boolean isvalidfilename(java.lang.String filename)
                               throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

readBinaryFile

public static Readbinfl readBinaryFile(java.lang.String filename)
                                throws java.io.IOException,
                                       java.io.UnsupportedEncodingException
Throws:
java.io.IOException
java.io.UnsupportedEncodingException

normalizeString

public static java.lang.String normalizeString(java.lang.String in)

isFunkyString

public static boolean isFunkyString(java.lang.String in)

outputErrorForFunkyString

public static java.lang.String outputErrorForFunkyString()

verifyJavaVersion

public static void verifyJavaVersion()
                              throws FeralcoreException
Throws:
FeralcoreException

getAddressByName

public static java.net.InetAddress getAddressByName(java.lang.String host)
                                             throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getAddressByAddress

public static java.net.InetAddress getAddressByAddress(ByteArray addr)
                                                throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

stdinReadLine

public static java.lang.String stdinReadLine()
                                      throws java.io.IOException
Throws:
java.io.IOException

isvalidprocidstring

public static boolean isvalidprocidstring(java.lang.String s)
                                   throws FeralcoreException,
                                          java.io.UnsupportedEncodingException
Throws:
FeralcoreException
java.io.UnsupportedEncodingException

stringToU16

public static Stou16 stringToU16(java.lang.String s)

isValidIPv4String

public static boolean isValidIPv4String(java.lang.String s)
                                 throws FeralcoreException,
                                        java.net.UnknownHostException
Throws:
FeralcoreException
java.net.UnknownHostException

main

public static void main()
                 throws FeralcoreException,
                        java.security.NoSuchAlgorithmException,
                        java.io.FileNotFoundException,
                        java.io.IOException,
                        java.lang.InterruptedException
Throws:
FeralcoreException
java.security.NoSuchAlgorithmException
java.io.FileNotFoundException
java.io.IOException
java.lang.InterruptedException