package jgrasp_viewers;


import java.math.BigInteger;
import java.util.Locale;
import jgrasp.viewer.ViewerCreateData;
import jgrasp.viewer.ViewerException;
import jgrasp.viewer.ViewerInfo;
import jgrasp.viewer.ViewerPriorityData;
import jgrasp.viewer.jgrdi.DebugContext;
import jgrasp.viewer.jgrdi.Value;
import jgrasp.viewer.text.TextAreaView;


/** java.math.BigInteger detail viewer. **/
public class java__math__BigInteger_NumericView extends TextAreaView {

   /** Creates a new BigInteger viewer.
    *
    * @param vcd creation data. **/
   public java__math__BigInteger_NumericView(final ViewerCreateData vcd) {
   }


   /** {@inheritDoc} **/
   @Override
   public String getDisplayText(final Value value, final DebugContext context) throws ViewerException {
      BigInteger val = value.toBigInt(context);
      return "Decimal: " + val.toString() + "\nHex: 0x" + val.toString(16).toUpperCase(Locale.ENGLISH) + "\nOctal: 0"
            + val.toString(8) + "\nBinary: " + val.toString(2);
   }


   /** {@inheritDoc} **/
   @Override
   public void getInfo(final ViewerInfo vi) {
      vi.setShortDescription("Detail viewer for BigInteger");
      vi.setLongDescription("This viewer displays a BigInteger in decimal, hex, octal, and binary forms.");
   }


   /** {@inheritDoc} **/
   @Override
   public int getPriority(final ViewerPriorityData vpd) {
      return -1;
   }


   /** {@inheritDoc} **/
   @Override
   public String getViewName() {
      return "Numeric";
   }
}
