package jgrasp_viewers;


import java.math.BigDecimal;
import jgrasp.BigDec;
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.BigDecimal detail viewer. **/
public class java__math__BigDecimal_NumericView extends TextAreaView {

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


   /** {@inheritDoc} **/
   @Override
   public String getDisplayText(final Value value, final DebugContext context) throws ViewerException {
      BigDec bd = value.toBigDec(context);
      BigDecimal val = bd.getBDValue();
      if (val == null) {
         return bd.toShortString();
      }
      return "Value: " + val + "\nUnscaled Value: " + val.unscaledValue() + "\nScale: " + val.scale();
   }


   /** {@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";
   }
}
