Package mgui.numbers

Class MguiShort

java.lang.Object
mgui.numbers.MguiShort
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<MguiNumber>, XMLObject, MguiNumber

public class MguiShort
extends java.lang.Object
implements MguiNumber
Implementation of MguiNumber for values of type short.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Nested Class Summary

    Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject

    XMLObject.XMLEncoding, XMLObject.XMLType
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected short value  
  • Constructor Summary

    Constructors
    Constructor Description
    MguiShort()  
    MguiShort​(double value)  
    MguiShort​(short thisValue)  
    MguiShort​(java.lang.String thisValue)  
  • Method Summary

    Modifier and Type Method Description
    MguiNumber add​(double n)
    Update the value of this number by adding n.
    MguiNumber add​(MguiNumber number)
    Update the value of this number by adding n.
    java.lang.Object clone()  
    int compareTo​(double d)  
    int compareTo​(double value, int precision)  
    int compareTo​(MguiNumber n)  
    MguiNumber divide​(double n)
    Divides this number by n.
    MguiNumber divide​(MguiNumber number)
    Update the value of this number by dividing by n.
    boolean equals​(java.lang.Object obj)  
    int getByteSize()  
    java.lang.String getDTD()
    Returns the Data Type Declaration (DTD) for this object's XML representation
    int getInt()  
    java.lang.String getLocalName()
    Returns the local name associated with this XML object.
    java.lang.String getShortXML​(int tab)
    Returns a short XML representation of this object.
    static java.lang.String getString​(int thisVal, java.lang.String pattern)  
    double getValue()
    Returns the value of this number
    static int getValue​(java.lang.String s)  
    java.lang.String getXML()
    Returns this object's XML representation as a single string.
    java.lang.String getXML​(int tab)
    Returns this object's XML representation as a single string.
    static XMLObject getXMLInstance​(org.xml.sax.Attributes attributes)  
    java.lang.String getXMLSchema()
    Returns the XML schema for this object's XML representation
    void handleXMLElementEnd​(java.lang.String localName)
    Handles the end of an XML element.
    void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
    Handles the start of an XML element.
    void handleXMLString​(java.lang.String s)
    Handles a string within an XML element.
    int hashCode()  
    MguiNumber multiply​(double n)
    Multiplies this number by n.
    MguiNumber multiply​(MguiNumber number)
    Update the value of this number by multiplying by n.
    static java.lang.String removeCommas​(java.lang.String s)  
    void setValue​(double thisValue)  
    boolean setValue​(java.lang.String val)  
    void setValue​(MguiNumber val)  
    MguiNumber subtract​(double n)
    Update the value of this number by subtracting n.
    MguiNumber subtract​(MguiNumber number)
    Update the value of this number by subtracting n.
    java.lang.String toString()  
    java.lang.String toString​(java.lang.String pattern)
    Returns the value of this number as a String, formatted with pattern.
    void writeXML​(int tab, java.io.Writer writer)
    Writes the XML representation of this object to file.
    void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
    Writes the XML representation of this object to file, as XMLType.Normal.
    void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
    Writes the XML representation of this object to file.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      protected short value
  • Constructor Details

    • MguiShort

      public MguiShort()
    • MguiShort

      public MguiShort​(short thisValue)
    • MguiShort

      public MguiShort​(java.lang.String thisValue)
    • MguiShort

      public MguiShort​(double value)
  • Method Details

    • getValue

      public double getValue()
      Description copied from interface: MguiNumber
      Returns the value of this number
      Specified by:
      getValue in interface MguiNumber
      Returns:
    • compareTo

      public int compareTo​(double value, int precision)
      Specified by:
      compareTo in interface MguiNumber
    • getInt

      public int getInt()
    • getValue

      public static int getValue​(java.lang.String s)
    • setValue

      public void setValue​(MguiNumber val)
      Specified by:
      setValue in interface MguiNumber
    • setValue

      public void setValue​(double thisValue)
      Specified by:
      setValue in interface MguiNumber
    • add

      public MguiNumber add​(MguiNumber number)
      Description copied from interface: MguiNumber
      Update the value of this number by adding n.
      Specified by:
      add in interface MguiNumber
      Returns:
      this number
    • divide

      public MguiNumber divide​(MguiNumber number)
      Description copied from interface: MguiNumber
      Update the value of this number by dividing by n.
      Specified by:
      divide in interface MguiNumber
      Returns:
      this number
    • subtract

      public MguiNumber subtract​(MguiNumber number)
      Description copied from interface: MguiNumber
      Update the value of this number by subtracting n.
      Specified by:
      subtract in interface MguiNumber
      Returns:
      this number
    • multiply

      public MguiNumber multiply​(MguiNumber number)
      Description copied from interface: MguiNumber
      Update the value of this number by multiplying by n.
      Specified by:
      multiply in interface MguiNumber
      Returns:
      this number
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toString

      public java.lang.String toString​(java.lang.String pattern)
      Description copied from interface: MguiNumber
      Returns the value of this number as a String, formatted with pattern.
      Specified by:
      toString in interface MguiNumber
      Returns:
    • setValue

      public boolean setValue​(java.lang.String val)
      Specified by:
      setValue in interface MguiNumber
    • getString

      public static java.lang.String getString​(int thisVal, java.lang.String pattern)
    • clone

      public java.lang.Object clone()
      Specified by:
      clone in interface MguiNumber
      Overrides:
      clone in class java.lang.Object
    • compareTo

      public int compareTo​(MguiNumber n) throws java.lang.ClassCastException
      Specified by:
      compareTo in interface java.lang.Comparable<MguiNumber>
      Throws:
      java.lang.ClassCastException
    • removeCommas

      public static java.lang.String removeCommas​(java.lang.String s)
    • compareTo

      public int compareTo​(double d)
      Specified by:
      compareTo in interface MguiNumber
    • getByteSize

      public int getByteSize()
      Specified by:
      getByteSize in interface MguiNumber
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • add

      public MguiNumber add​(double n)
      Description copied from interface: MguiNumber
      Update the value of this number by adding n.
      Specified by:
      add in interface MguiNumber
      Returns:
      this number
    • divide

      public MguiNumber divide​(double n)
      Divides this number by n. Treats the values as doubles for the operation.
      Specified by:
      divide in interface MguiNumber
      Returns:
      this number
    • multiply

      public MguiNumber multiply​(double n)
      Multiplies this number by n. Treats the values as doubles for the operation.
      Specified by:
      multiply in interface MguiNumber
      Returns:
      this number
    • subtract

      public MguiNumber subtract​(double n)
      Description copied from interface: MguiNumber
      Update the value of this number by subtracting n.
      Specified by:
      subtract in interface MguiNumber
      Returns:
      this number
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML​(int tab)
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName)
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
    • handleXMLString

      public void handleXMLString​(java.lang.String s)
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
    • getXMLInstance

      public static XMLObject getXMLInstance​(org.xml.sax.Attributes attributes)
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns: