java.lang.Object
com.ibm.java.diagnostics.utils.commands.BaseCommand
com.ibm.jvm.dtfjview.commands.BaseJdmpviewCommand
- All Implemented Interfaces:
ICommand
- Direct Known Subclasses:
CdCommand
,CloseCommand
,DeadlockCommand
,FindCommand
,FindNextCommand
,FindPtrCommand
,HeapdumpCommand
,HelpCommand
,HexdumpCommand
,InfoClassCommand
,InfoHeapCommand
,InfoJitmCommand
,InfoLockCommand
,InfoMemoryCommand
,InfoMmapCommand
,InfoProcCommand
,InfoSymCommand
,InfoSystemCommand
,InfoThreadCommand
,LogCommand
,OpenCommand
,PwdCommand
,ScrollCommand
,SetHeapdumpCommand
,SetLoggingCommand
,ShowHeapdumpCommand
,ShowLoggingCommand
,SimpleRedirectorCommand
,WhatisCommand
,XCommand
This the base command for all jdmpview commands. It ensures consistent
behaviour with the legacy commands without breaking the generic command
encapsulation.
There are a number of methods which allow DTFJ objects to be consistently
displayed across different plugins e.g. getClassInfo(). Where the method
name starts with getXYZ the output will be returned for further processing,
however where the method starts with writeXYZ then the output is written
immediately to the command's print stream.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
Enum for identifying the type of artifact that is currently being analyzed. -
Field Summary
Modifier and TypeFieldDescriptionprotected IDTFJContext
protected String
protected Logger
protected PrintStream
Fields declared in class com.ibm.java.diagnostics.utils.commands.BaseCommand
COMMAND_FORMAT, config, nl, SUBCOMMAND_FORMAT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecodeThreadState
(int state) Textual description of a thread state.protected BaseJdmpviewCommand.ArtifactType
Determine the type of artifact currently being operated on.handleException
(Throwable cause) Lots of DTFJ methods will throw a standard set of exceptions such as corrupt data or data unavailable.final boolean
initCommand
(String command, String[] args, IContext context, PrintStream out) Common processing to initialize the command and make the porting of existing jdmpview commands easier.abstract void
Print detailed help for a given commandtoHexString
(byte num) Format a number with the correct number of zeros as padding according to the data type passed in.toHexString
(int num) Format a number with the correct number of zeros as padding according to the data type passed in.toHexString
(long num) Format a number with the correct number of zeros as padding according to the data type passed in.toHexString
(short num) Format a number with the correct number of zeros as padding according to the data type passed in.toHexStringAddr
(long num) Format an address as hex padded with zeros according to the size of the process.long
Typically used when an extension takes a numeric argument, and wants to accept a variety of formats.toString
(double num) Convenience method to convert a number into a String to display.toString
(float num) Convenience method to convert a number into a String to display.Methods declared in class com.ibm.java.diagnostics.utils.commands.BaseCommand
addCommand, addSubCommand, getCommandDescriptions, getCommandNames, getConfig, recognises, setConfig
-
Field Details
-
out
-
ctx
-
logger
-
hexfmt
-
-
Constructor Details
-
BaseJdmpviewCommand
public BaseJdmpviewCommand()
-
-
Method Details
-
printDetailedHelp
Print detailed help for a given command- Parameters:
out
- stream to write the output to
-
initCommand
public final boolean initCommand(String command, String[] args, IContext context, PrintStream out) throws CommandException Common processing to initialize the command and make the porting of existing jdmpview commands easier.- Parameters:
command
- the command being executedargs
- the supplied argumentscontext
- the context within which it is operatingout
- where to write the output- Returns:
- returns true if this method has handled the output and the subclass should exit
- Throws:
CommandException
-
toLong
Typically used when an extension takes a numeric argument, and wants to accept a variety of formats. Currently it will support decimal or hexadecimal formats.- Parameters:
number
- String representation of the number to parse- Returns:
- the numeric value
-
getArtifactType
Determine the type of artifact currently being operated on.- Returns:
- artifact type
-
toHexStringAddr
Format an address as hex padded with zeros according to the size of the process. e.g. 17 would be formatted as 0x00000011 for 32 bit and 0x0000000000000011 for 64 bit- Parameters:
num
- the number to format- Returns:
- formatted number
-
handleException
Lots of DTFJ methods will throw a standard set of exceptions such as corrupt data or data unavailable. This method provides a central point for handling these exceptions and attempts to provide more context as to whether or not this is an expected occurrence for the artifact type under analysis.- Parameters:
cause
- the exception returned from a call to the DTFJ API- Returns:
- formatted string for displaying to the user
-
decodeThreadState
Textual description of a thread state.- Parameters:
state
- state to convert- Returns:
- cumulative description of the states
-
toHexString
Format a number with the correct number of zeros as padding according to the data type passed in.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toHexString
Format a number with the correct number of zeros as padding according to the data type passed in.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toHexString
Format a number with the correct number of zeros as padding according to the data type passed in.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toHexString
Format a number with the correct number of zeros as padding according to the data type passed in.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toString
Convenience method to convert a number into a String to display.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toString
Convenience method to convert a number into a String to display.- Parameters:
num
- the number to format- Returns:
- formatted number
-