Compact Class For Java – CCMessage


Compact Class is a collection of common functions and classes that can make your code more concise, fast, and precise.

utility

Class CCMessage

java.lang.Object

extended by

utility.CCMessage

public class CCMessageextends java.lang.Object

CCMessage is a collection method is used to simplify the standard input,
output, logger, and JOptionPane.

Since:
10.03.17
Version:
12.03.17
Author:
Yosua Onesimus


Field Detail

CC4J_VERSION

public static final java.lang.String CC4J_VERSION
CC4J_VERSION = “Compact Class For Java 12.05.22”
See Also:
Constant Field Values

RETURN_NULL_COZ

public static final java.lang.String RETURN_NULL_COZ
RETURN_NULL_COZ = “return null; coz “
See Also:
Constant Field Values

RETURN_BLANK_COZ

public static final java.lang.String RETURN_BLANK_COZ
RETURN_BLANK_COZ = “return blank; coz “
See Also:
Constant Field Values

RETURN_0D_COZ

public static final java.lang.String RETURN_0D_COZ
RETURN_0D_COZ = “return 0d; coz “
See Also:
Constant Field Values

RETURN_0_COZ

public static final java.lang.String RETURN_0_COZ
RETURN_0_COZ = “return 0; coz “
See Also:
Constant Field Values

RETURN_0F_COZ

public static final java.lang.String RETURN_0F_COZ
RETURN_0F_COZ = “return 0f; coz “
See Also:
Constant Field Values

RETURN_0L_COZ

public static final java.lang.String RETURN_0L_COZ
RETURN_0L_COZ = “return 0l; coz “
See Also:
Constant Field Values

SHOW_PRINTLN

public static boolean SHOW_PRINTLN
SHOW_PRINTLN = true

SHOW_LOG_INFO

public static boolean SHOW_LOG_INFO
SHOW_LOG_INFO = false

SHOW_LOG_SEVERE

public static boolean SHOW_LOG_SEVERE
SHOW_LOG_SEVERE = false


Constructor Detail

CCMessage

public CCMessage()


Method Detail

checkpoint

public static void checkpoint()
Show class name, method name, and line number.

println

public static void println(java.lang.Object message,
                           boolean isError)
Prints an object. The string produced by the String.valueOf(Object)
method is translated into bytes according to the platform’s default
character encoding, and these bytes are written in exactly the manner of
the PrintStream.write(int) method.

 

Parameters:
message– The Object to be printed
isError – true = err, false = out

 


println

public static void println(java.lang.Object message)
Prints an object. The string produced by the String.valueOf(Object)
method is translated into bytes according to the platform’s default
character encoding, and these bytes are written in exactly the manner of
the PrintStream.write(int) method.
Same as :
 println(message, false);

 

Parameters:
message – The Object to be printed

 


readln

public static java.lang.String readln()
Reads a line of text. A line is considered to be terminated by any one of
a line feed (‘\n’), a carriage return (‘\r’), or a carriage return
followed immediately by a linefeed.

 

Returns:
A String containing the contents of the line, not including any
line-termination characters, or null if the end of the stream has been
reached

 


logp

public static void logp(java.util.logging.Level level,
                        java.lang.String sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Log a message, specifying source class and method, with no
arguments.
If the logger is currently enabled for the given message
level then the given message is forwarded to all the registered output
Handler objects.

 

Parameters:
level– One of the message level identifiers, e.g. SEVERE.
sourceClass– name of class that issued the logging request.
sourceMethod– name of method that issued the logging request.
msg – The string message (or a key in the message catalog).

 


logp

public static void logp(java.util.logging.Level level,
                        java.lang.String sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.Throwable thrown)
Log a message, specifying source class and method, with associated
Throwable information.
If the logger is currently enabled for the
given message level then the given arguments are stored in a LogRecord
which is forwarded to all registered output handlers.
Note that the
thrown argument is stored in the LogRecord thrown property, rather than
the LogRecord parameters property. Thus is it processed specially by
output Formatters and is not treated as a formatting parameter to the
LogRecord message property.

 

Parameters:
level– One of the message level identifiers, e.g. SEVERE.
sourceClass– name of class that issued the logging request.
sourceMethod– name of method that issued the logging request.
thrown – Throwable associated with log message.

 


logp

public static void logp(java.lang.Class clazz,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Same as :
 logp(Level.INFO, clazz.getName(), sourceMethod, msg);

 

Parameters:
clazz– class that issued the logging request.
sourceMethod– name of method that issued the logging request.
msg – The string message (or a key in the message catalog).

 


logp

public static void logp(java.lang.String msg)
Same as :
 logp(Level.INFO, CCClass.getCallerClassName(), CCClass.getCallerMethodName(), msg);

 

Parameters:
msg – The string message (or a key in the message catalog).

 


logp

public static void logp(java.lang.Class clazz,
                        java.lang.String sourceMethod,
                        java.lang.Throwable thrown)
Same as :
 logp(Level.SEVERE, clazz.getName(), sourceMethod, thrown);

 

Parameters:
clazz– class that issued the logging request.
sourceMethod– name of method that issued the logging request.
thrown – Throwable associated with log message.

 


logp

public static void logp(java.lang.Throwable thrown)
Same as :
 logp(Level.SEVERE, CCClass.getCallerClassName(), CCClass.getCallerMethodName(), thrown);

 

Parameters:
thrown – Throwable associated with log message.

 


addHandler

public static boolean addHandler(java.lang.String pattern,
                                 boolean append,
                                 java.util.logging.Level... levels)
Add a log Handler to receive logging messages.
By default, Loggers
also send their output to their parent logger. Typically the root Logger
is configured with a set of Handlers that essentially act as default
handlers for all loggers.

 

Parameters:
pattern– the name of the output file.
append– specifies append mode.
levels – level identifiers, e.g. SEVERE.

 

Returns:boolean


getErrorMessage

public static java.lang.String getErrorMessage()
Returns:
errorMessage

setErrorMessage

public static void setErrorMessage(java.lang.String errorMessage)
Parameters:
errorMessage

getCauseMessage

public static java.lang.String getCauseMessage()
Returns:
causeMessage

setCauseMessage

public static void setCauseMessage(java.lang.String causeMessage)
Parameters:
causeMessage

IS_EMPTY

public static java.lang.String IS_EMPTY(java.lang.String objectName)
Parameters:
objectName

Returns:(Please_enter_) + objectName + “.”


IS_USED

public static java.lang.String IS_USED(java.lang.String objectName)
Parameters:
objectName

Returns:turn(The_) + objectName + turn(_entered_is_taken) + “. ” +
turn(Please_give_a_new_) + objectName +
turn(_or_use_the_default_sequenced_) + objectName;


IS_WRONG

public static java.lang.String IS_WRONG(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_wrong) + “.”


IS_NOT_MATCH

public static java.lang.String IS_NOT_MATCH(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_match) + “.”


IS_NOT_EXISTED

public static java.lang.String IS_NOT_EXISTED(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_existed) + “.”


IS_NOT_NUMERIC

public static java.lang.String IS_NOT_NUMERIC(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_numeric) + “.”


IS_NOT_DECIMAL

public static java.lang.String IS_NOT_DECIMAL(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_decimal) + “.”


IS_NOT_VALID_DATE

public static java.lang.String IS_NOT_VALID_DATE(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_a_valid_date) + “.”


IS_NOT_EMAIL

public static java.lang.String IS_NOT_EMAIL(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_a_valid_email_address) + “.”


IS_NOT_PHONE_NUMBER

public static java.lang.String IS_NOT_PHONE_NUMBER(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_a_valid_phone_number) + “.”


IS_NOT_BARCODE

public static java.lang.String IS_NOT_BARCODE(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_barcode) + “.”


IS_NOT_IP

public static java.lang.String IS_NOT_IP(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_a_valid_ip_format) + “.”


HAS_LENGTH_BELOW_THAN_MIN_LENGTH

public static java.lang.String HAS_LENGTH_BELOW_THAN_MIN_LENGTH(java.lang.String objectName,
                                                                int minLength)
Parameters:
objectName
minLength

Returns:objectName + ” ” + turn(has_length_below_than) + ” ” + minLength
+ “.”


IS_NOT_SELECTED

public static java.lang.String IS_NOT_SELECTED(java.lang.String objectName)
Parameters:
objectName

Returns:objectName + ” ” + turn(is_not_selected) + “.”


WARNING_FILE_REPLACED

public static java.lang.String WARNING_FILE_REPLACED(java.io.File file)
Parameters:
file

Returns:file.getPath() + ” ” + turn(already_exists) + “. ” +
turn(Do_you_want_to_replace_it) + “?”;


WARNING_DATA_NOT_SAVED

public static java.lang.String WARNING_DATA_NOT_SAVED()
Returns:
turn(Are_you_sure_to_close_the_dialog_without_saving_the_changes)
+ “?”;

ASK_SAVE

public static java.lang.String ASK_SAVE()
Returns:
turn(Are_you_sure_to_save_these_changes) + “?”;

INFO_SAVE_SUCCESS

public static java.lang.String INFO_SAVE_SUCCESS()
Returns:
turn(Data_has_been_saved) + “.”;

INFO_SAVE_FAIL

public static java.lang.String INFO_SAVE_FAIL()
Returns:
turn(Data_could_not_be_saved) + “.”;

ASK_HIDE

public static java.lang.String ASK_HIDE()
Returns:
turn(Are_you_sure_to_hide_this_data) + “?”;

INFO_HIDE_SUCCESS

public static java.lang.String INFO_HIDE_SUCCESS()
Returns:
turn(Data_has_been_hidden) + “.”;

INFO_HIDE_FAIL

public static java.lang.String INFO_HIDE_FAIL()
Returns:
turn(Data_could_not_be_hidden) + “.”;

ASK_DELETE

public static java.lang.String ASK_DELETE()
Returns:
turn(Are_you_sure_to_delete_this_data) + “?”;

INFO_DELETE_SUCCESS

public static java.lang.String INFO_DELETE_SUCCESS()
Returns:
turn(Data_has_been_deleted) + “.”;

INFO_DELETE_FAIL

public static java.lang.String INFO_DELETE_FAIL()
Returns:
turn(Data_could_not_be_deleted) + “.”;

showMessageDialog

public static void showMessageDialog(java.awt.Component parentComponent,
                                     java.lang.Object message,
                                     int messageType)
Brings up a dialog displaying a message, specifying all parameters.

 

Parameters:
parentComponent – determines the Frame in which the dialog is
displayed; if null, or if the parentComponent has no Frame, a default
Frame is used.
message– the Object to display.
messageType – 0 = Error, 1 = Information, 2 = Warning, 3 = Question

 


showError

public static void showError(java.lang.Object... messages)
Same as :
 showMessageDialog(null, _getMessage(messages), 0);

 

Parameters:
messages – the Object to display.

 


showError

public static void showError()
Same as :
 showError(getErrorMessage(), getCauseMessage());

showInformation

public static void showInformation(java.lang.Object... messages)
Same as :
 showMessageDialog(null, _getMessage(messages), 1);

 

Parameters:
messages – the Object to display.

 


showSaved

public static void showSaved(boolean success)
Same as :
 showInformation(success ? INFO_SAVE_SUCCESS() : (INFO_SAVE_FAIL() + "\n" + getErrorMessage() + "\n" + CCMessage.getCauseMessage()));

 

Parameters:
success

 


showHidden

public static void showHidden(boolean success)
Same as :
 showInformation(success ? INFO_HIDE_SUCCESS() : (INFO_HIDE_FAIL() + "\n" + getErrorMessage() + "\n" + CCMessage.getCauseMessage()));

 

Parameters:
success

 


showDeleted

public static void showDeleted(boolean success)
Same as :
 showInformation(success ? INFO_DELETE_SUCCESS() : (INFO_DELETE_FAIL() + "\n" + getErrorMessage() + "\n" + turn(Cant_delete_or_update_a_parent_row)));

 

Parameters:
success

 


showOptionDialog

public static int showOptionDialog(java.awt.Component parentComponent,
                                   java.lang.Object message,
                                   int optionType,
                                   int messageType)
Brings up a dialog with a specified icon, where the initial choice is
determined by the initialValue parameter and the number of choices is
determined by the optionType parameter.
If optionType is
YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null,
then the options are supplied by the look and feel.
The messageType
parameter is primarily used to supply a default icon from the look and
feel.

 

Parameters:
parentComponent – determines the Frame in which the dialog is
displayed; if null, or if the parentComponent has no Frame, a default
Frame is used.
message– the Object to display.
optionType– 0 = Yes No, 1 = Yes No Cancel, 2 = Ok Cancel
messageType – 0 = Error, 1 = Information, 2 = Warning, 3 = Question

 

Returns:an integer indicating the option chosen by the user, or
CLOSED_OPTION if the user closed the dialog.


showYesNoWarning

public static int showYesNoWarning(java.lang.Object... messages)
Same as :
 showOptionDialog(null, _getMessage(messages), 0, 2);

 

Parameters:
messages – the Object to display.

 

Returns:an integer indicating the option chosen by the user, or
CLOSED_OPTION if the user closed the dialog.


showYesNoQuestion

public static int showYesNoQuestion(java.lang.Object... messages)
Same as :
 showOptionDialog(null, _getMessage(messages), 0, 3);

 

Parameters:
messages – the Object to display.

 

Returns:an integer indicating the option chosen by the user, or
CLOSED_OPTION if the user closed the dialog.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: