com.github.fedorchuck.developers_notification
Class DevelopersNotificationUtil

java.lang.Object
  extended by com.github.fedorchuck.developers_notification.DevelopersNotificationUtil

public class DevelopersNotificationUtil
extends java.lang.Object

Class contains helper methods

Author: Volodymyr Fedorchuk

Since:
0.1.0

Constructor Summary
DevelopersNotificationUtil()
           
 
Method Summary
static java.lang.String arrayToString(java.lang.StackTraceElement[] stackTrace)
          Convert array of StackTraceElement to string.
static boolean checkTheNecessaryConfigurationExists(DevelopersNotificationMessenger messenger)
          Check does the necessary messenger configuration exist
static java.lang.String getEnvironmentVariable(java.lang.String key)
          Getting environment variable value.
static byte[] getThrowableStackTraceBytes(java.lang.Throwable throwable)
          Convert Throwable stack trace to byte[] array
static boolean isBlank(java.lang.String string)
          Check is the given string is blank.
static boolean isNullOrEmpty(java.lang.String string)
          Check is the given string is null or is the empty string.
static void printToLogEnvironmentVariable(java.lang.String name)
          Prints environment variable value with.
static void setEnvironmentVariable(java.lang.String key, java.lang.String value)
          Deprecated. 
static java.lang.String urlEncode(java.lang.String param)
          Translates a string into application/x-www-form-urlencoded format using UTF-8 encoding scheme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DevelopersNotificationUtil

public DevelopersNotificationUtil()
Method Detail

setEnvironmentVariable

@Deprecated
public static void setEnvironmentVariable(java.lang.String key,
                                                     java.lang.String value)
Deprecated. 

Setting environment variables using reflection.

NOTE: System environment variables are accessible by any process. Java system properties are only accessible by the process they are added to. Probably, In your case should use Java system properties - for it you can use, for example, System.setProperty(String, String)

Method is deprecated. Will be removed at v 0.4.0

Parameters:
key - name of property
value - of property
Throws:
java.lang.IllegalStateException - if failed to set environment variable
Since:
0.1.0

getEnvironmentVariable

public static java.lang.String getEnvironmentVariable(java.lang.String key)
Getting environment variable value.

Parameters:
key - name of property
Returns:
string value of variable or null, if it is not set
Since:
0.1.0

printToLogEnvironmentVariable

public static void printToLogEnvironmentVariable(java.lang.String name)
Prints environment variable value with. DevelopersNotificationLogger.infoEnvironmentVariable(String, String).

Parameters:
name - of property
Since:
0.1.0

urlEncode

public static java.lang.String urlEncode(java.lang.String param)
                                  throws java.io.UnsupportedEncodingException
Translates a string into application/x-www-form-urlencoded format using UTF-8 encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

Parameters:
param - string to be translated
Returns:
encoded string
Throws:
java.io.UnsupportedEncodingException - - If the named encoding is not supported
Since:
0.1.0

arrayToString

public static java.lang.String arrayToString(java.lang.StackTraceElement[] stackTrace)
Convert array of StackTraceElement to string.

Parameters:
stackTrace - - array of StackTraceElement which will be converted
Returns:
convert array as string, each element of array start from new line
Since:
0.1.0

getThrowableStackTraceBytes

public static byte[] getThrowableStackTraceBytes(java.lang.Throwable throwable)
Convert Throwable stack trace to byte[] array

Parameters:
throwable - - which will be converted
Returns:
convert throwable as byte array
Since:
0.3.0

isNullOrEmpty

public static boolean isNullOrEmpty(java.lang.String string)
Check is the given string is null or is the empty string.

Parameters:
string - to check
Returns:
true if the given string is null or is the empty string.
Since:
0.1.1

isBlank

public static boolean isBlank(java.lang.String string)
Check is the given string is blank. isBlank(null): true; isBlank(""): true; isBlank(" "): true; isBlank("Hello world!"): false

Parameters:
string - to check
Returns:
true if the given string is blank.
Since:
0.3.0

checkTheNecessaryConfigurationExists

public static boolean checkTheNecessaryConfigurationExists(DevelopersNotificationMessenger messenger)
Check does the necessary messenger configuration exist

Parameters:
messenger - to check
Returns:
true if configuration exist; false otherwise.
Since:
0.3.0