Class BaseJdmpviewCommand

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.
  • Field Details

  • Constructor Details

    • BaseJdmpviewCommand

      public BaseJdmpviewCommand()
  • Method Details

    • 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 executed
      args - the supplied arguments
      context - the context within which it is operating
      out - 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