Package com.dalsemi.onewire.debug
Class Debug
java.lang.Object
com.dalsemi.onewire.debug.Debug
This class is intended to help both developers of the 1-Wire API for Java and
developers using the 1-Wire API for Java to have a standard method for
printing debug messages. Applications that want to see debug messages should
call the setDebugMode(boolean)
method. Classes that want to
print information under debugging circumstances should call the
debug(String)
method.
Debug printing is turned off by default.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final void
Prints the specifiedjava.lang.String
object if debug mode is enabled.static final void
Prints the specified array of bytes with a given label if debug mode is enabled.static final void
Prints the specified array of bytes with a given label if debug mode is enabled.static final void
Prints the specified exception with a given label if debug mode is enabled.static final boolean
Gets the debug printing mode for this application.static final void
setDebugMode
(boolean onoff) Sets the debug printing mode for this application.static final void
setPrintStream
(PrintStream outStream) Sets the output stream for printing the debug info.static final void
Prints out an exception stack trace for debugging purposes.
-
Constructor Details
-
Debug
public Debug()
-
-
Method Details
-
setDebugMode
public static final void setDebugMode(boolean onoff) Sets the debug printing mode for this application.- Parameters:
onoff
-true
to see debug messages,false
to suppress them
-
getDebugMode
public static final boolean getDebugMode()Gets the debug printing mode for this application.- Returns:
true
indicates debug messages are on,false
suppresses them.
-
setPrintStream
Sets the output stream for printing the debug info.- Parameters:
outStream
- the output stream for printing the debug info.
-
debug
Prints the specifiedjava.lang.String
object if debug mode is enabled. This method callsPrintStream.println(String)
, and pre-pends theString
">> " to the message, so that if a program were to call (when debug mode was enabled):com.dalsemi.onewire.debug.Debug.debug("Some notification...");
the resulting output would look like:>> Some notification...
- Parameters:
x
- the message to print out if in debug mode
-
debug
Prints the specified array of bytes with a given label if debug mode is enabled. This method callsPrintStream.println(String)
, and pre-pends theString
">> " to the message, so that if a program were to call (when debug mode was enabled):com.dalsemi.onewire.debug.Debug.debug("Some notification...", myBytes);
the resulting output would look like:>> my label >> FF F1 F2 F3 F4 F5 F6 FF
- Parameters:
lbl
- the message to print out above the arraybytes
- the byte array to print out
-
debug
Prints the specified array of bytes with a given label if debug mode is enabled. This method callsPrintStream.println(String)
, and pre-pends theString
">> " to the message, so that if a program were to call (when debug mode was enabled):com.dalsemi.onewire.debug.Debug.debug("Some notification...", myBytes, 0, 8);
the resulting output would look like:>> my label >> FF F1 F2 F3 F4 F5 F6 FF
- Parameters:
lbl
- the message to print out above the arraybytes
- the byte array to print outoffset
- the offset to start printing from the arraylength
- the number of bytes to print from the array
-
debug
Prints the specified exception with a given label if debug mode is enabled. This method callsPrintStream.println(String)
, and pre-pends theString
">>" to the message, so that if a program were to call (when debug mode was enabled):
the resulting output would look like:com.dalsemi.onewire.debug.Debug.debug("Some notification...", exception);
>> my label >> OneWireIOException: Device Not Present
- Parameters:
lbl
- the message to print out above the arrayt
-
-
stackTrace
public static final void stackTrace()Prints out an exception stack trace for debugging purposes. This is useful to figure out which functions are calling a particular function at runtime.
-