- 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
public abstract class BaseJdmpviewCommand extends BaseCommand
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
Nested Classes Modifier and Type Class Description protected static class
BaseJdmpviewCommand.ArtifactType
Enum for identifying the type of artifact that is currently being analyzed.
-
Field Summary
Fields Modifier and Type Field Description protected IDTFJContext
ctx
protected String
hexfmt
protected Logger
logger
protected PrintStream
out
-
Fields declared in class com.ibm.java.diagnostics.utils.commands.BaseCommand
COMMAND_FORMAT, config, nl, SUBCOMMAND_FORMAT
-
-
Constructor Summary
Constructors Constructor Description BaseJdmpviewCommand()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
decodeThreadState(int state)
Textual description of a thread state.protected BaseJdmpviewCommand.ArtifactType
getArtifactType()
Determine the type of artifact currently being operated on.String
handleException(Throwable cause)
Lots of DTFJ methods will throw a standard set of exceptions such as corrupt data or data unavailable.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
printDetailedHelp(PrintStream out)
Print detailed help for a given commandString
toHexString(byte num)
Format a number with the correct number of zeros as padding according to the data type passed in.String
toHexString(int num)
Format a number with the correct number of zeros as padding according to the data type passed in.String
toHexString(long num)
Format a number with the correct number of zeros as padding according to the data type passed in.String
toHexString(short num)
Format a number with the correct number of zeros as padding according to the data type passed in.String
toHexStringAddr(long num)
Format an address as hex padded with zeros according to the size of the process.long
toLong(String number)
Typically used when an extension takes a numeric argument, and wants to accept a variety of formats.String
toString(double num)
Convenience method to convert a number into a String to display.String
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, setConfig
-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods declared in interface com.ibm.java.diagnostics.utils.commands.ICommand
getCommandDescriptions, getCommandNames, getConfig, recognises, run
-
-
-
-
Field Detail
-
out
protected PrintStream out
-
ctx
protected IDTFJContext ctx
-
logger
protected Logger logger
-
hexfmt
protected String hexfmt
-
-
Method Detail
-
printDetailedHelp
public abstract void printDetailedHelp(PrintStream out)
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
public long toLong(String number)
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
protected BaseJdmpviewCommand.ArtifactType getArtifactType()
Determine the type of artifact currently being operated on.- Returns:
- artifact type
-
toHexStringAddr
public String toHexStringAddr(long num)
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
public String handleException(Throwable cause)
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
public String decodeThreadState(int state)
Textual description of a thread state.- Parameters:
state
- state to convert- Returns:
- cumulative description of the states
-
toHexString
public String toHexString(long num)
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
public String toHexString(short num)
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
public String toHexString(int num)
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
public String toHexString(byte num)
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
public String toString(float num)
Convenience method to convert a number into a String to display.- Parameters:
num
- the number to format- Returns:
- formatted number
-
toString
public String toString(double num)
Convenience method to convert a number into a String to display.- Parameters:
num
- the number to format- Returns:
- formatted number
-
-