Package mgui.numbers

Class MguiBoolean

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

public class MguiBoolean
extends java.lang.Object
implements MguiNumber
Implementation of MguiNumber for values of type boolean. As a number, this treats a value as 0 == false and any other value is considered true.
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 boolean value  
  • Constructor Summary

    Constructors
    Constructor Description
    MguiBoolean()  
    MguiBoolean​(boolean thisValue)  
    MguiBoolean​(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)
    Update the value of this number by dividing 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
    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.
    boolean getTrue()  
    double getValue()
    Returns the value of this number
    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.
    MguiNumber multiply​(double n)
    Update the value of this number by multiplying by n.
    MguiNumber multiply​(MguiNumber number)
    Update the value of this number by multiplying by n.
    void setTrue​(boolean b)  
    void setValue​(boolean thisValue)  
    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()  
    static java.lang.String toString​(boolean b)  
    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, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      protected boolean value
  • Constructor Details

    • MguiBoolean

      public MguiBoolean()
    • MguiBoolean

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

      public MguiBoolean​(boolean thisValue)
  • Method Details

    • setValue

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

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

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

      public void setValue​(boolean thisValue)
    • toString

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

      public boolean getTrue()
    • setTrue

      public void setTrue​(boolean b)
    • getValue

      public double getValue()
      Description copied from interface: MguiNumber
      Returns the value of this number
      Specified by:
      getValue in interface MguiNumber
      Returns:
    • 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
    • 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
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • 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
    • 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)
      Description copied from interface: MguiNumber
      Update the value of this number by dividing by n.
      Specified by:
      divide in interface MguiNumber
      Returns:
      this number
    • multiply

      public MguiNumber multiply​(double n)
      Description copied from interface: MguiNumber
      Update the value of this number by multiplying by n.
      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
    • getByteSize

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

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

      public static java.lang.String toString​(boolean b)
    • 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: