Package mgui.numbers
Class MguiDouble
java.lang.Object
mgui.numbers.MguiDouble
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<MguiNumber>,XMLObject,MguiNumber
public class MguiDouble extends java.lang.Object implements MguiNumber
Implementation of
MguiNumber for values of type double.- 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 doublevalue -
Constructor Summary
Constructors Constructor Description MguiDouble()MguiDouble(double thisValue)MguiDouble(java.lang.String val)MguiDouble(MguiNumber thisValue) -
Method Summary
Modifier and Type Method Description MguiNumberadd(double n)Update the value of this number by addingn.MguiNumberadd(MguiNumber number)Update the value of this number by addingn.java.lang.Objectclone()intcompareTo(double d)intcompareTo(double value, int precision)intcompareTo(MguiNumber n)MguiNumberdivide(double n)Update the value of this number by dividing byn.MguiNumberdivide(MguiNumber number)Update the value of this number by dividing byn.booleanequals(java.lang.Object obj)intgetByteSize()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.StringgetLocalName()Returns the local name associated with this XML object.java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.static java.lang.StringgetString(double thisVal, int precision)static java.lang.StringgetString(double thisVal, int precision, boolean no_commas)static java.lang.StringgetString(double thisVal, java.lang.String pattern)doublegetValue()Returns the value of this numberstatic doublegetValue(java.lang.String s)java.lang.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.static XMLObjectgetXMLInstance(org.xml.sax.Attributes attributes)java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationstatic java.util.ArrayList<MguiNumber>getZeros(int size)voidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.MguiNumbermultiply(double n)Update the value of this number by multiplying byn.MguiNumbermultiply(MguiNumber number)Update the value of this number by multiplying byn.voidsetValue(double thisValue)booleansetValue(java.lang.String val)voidsetValue(MguiNumber val)MguiNumbersubtract(double n)Update the value of this number by subtractingn.MguiNumbersubtract(MguiNumber number)Update the value of this number by subtractingn.java.lang.StringtoString()java.lang.StringtoString(java.lang.String pattern)Returns the value of this number as aString, formatted withpattern.voidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(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 double value
-
-
Constructor Details
-
MguiDouble
public MguiDouble() -
MguiDouble
public MguiDouble(double thisValue) -
MguiDouble
public MguiDouble(java.lang.String val) -
MguiDouble
-
-
Method Details
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
add
Description copied from interface:MguiNumberUpdate the value of this number by addingn.- Specified by:
addin interfaceMguiNumber- Returns:
- this number
-
divide
Description copied from interface:MguiNumberUpdate the value of this number by dividing byn.- Specified by:
dividein interfaceMguiNumber- Returns:
- this number
-
subtract
Description copied from interface:MguiNumberUpdate the value of this number by subtractingn.- Specified by:
subtractin interfaceMguiNumber- Returns:
- this number
-
multiply
Description copied from interface:MguiNumberUpdate the value of this number by multiplying byn.- Specified by:
multiplyin interfaceMguiNumber- Returns:
- this number
-
setValue
- Specified by:
setValuein interfaceMguiNumber
-
setValue
public void setValue(double thisValue)- Specified by:
setValuein interfaceMguiNumber
-
getValue
public double getValue()Description copied from interface:MguiNumberReturns the value of this number- Specified by:
getValuein interfaceMguiNumber- Returns:
-
getValue
public static double getValue(java.lang.String s) -
compareTo
public int compareTo(double d)- Specified by:
compareToin interfaceMguiNumber
-
getZeros
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(java.lang.String pattern)Description copied from interface:MguiNumberReturns the value of this number as aString, formatted withpattern.- Specified by:
toStringin interfaceMguiNumber- Returns:
-
getString
public static java.lang.String getString(double thisVal, java.lang.String pattern) -
getString
public static java.lang.String getString(double thisVal, int precision) -
getString
public static java.lang.String getString(double thisVal, int precision, boolean no_commas) -
setValue
public boolean setValue(java.lang.String val)- Specified by:
setValuein interfaceMguiNumber
-
clone
public java.lang.Object clone()- Specified by:
clonein interfaceMguiNumber- Overrides:
clonein classjava.lang.Object
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<MguiNumber>- Throws:
java.lang.ClassCastException
-
compareTo
public int compareTo(double value, int precision)- Specified by:
compareToin interfaceMguiNumber
-
getByteSize
public int getByteSize()- Specified by:
getByteSizein interfaceMguiNumber
-
add
Description copied from interface:MguiNumberUpdate the value of this number by addingn.- Specified by:
addin interfaceMguiNumber- Returns:
- this number
-
divide
Description copied from interface:MguiNumberUpdate the value of this number by dividing byn.- Specified by:
dividein interfaceMguiNumber- Returns:
- this number
-
multiply
Description copied from interface:MguiNumberUpdate the value of this number by multiplying byn.- Specified by:
multiplyin interfaceMguiNumber- Returns:
- this number
-
subtract
Description copied from interface:MguiNumberUpdate the value of this number by subtractingn.- Specified by:
subtractin interfaceMguiNumber- Returns:
- this number
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Specified by:
getLocalNamein interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns 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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file. -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObjectReturns 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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file. -
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObjectReturns the XML schema for this object's XML representation- Specified by:
getXMLSchemain interfaceXMLObject- Returns:
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin interfaceXMLObject- 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:XMLObjectHandles the start of an XML element.- Specified by:
handleXMLElementStartin interfaceXMLObject- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element
-
handleXMLString
public void handleXMLString(java.lang.String s)Description copied from interface:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin interfaceXMLObject- Parameters:
s- String to handle
-
getXMLInstance
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites 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 ofXMLFormat.Asciiwill be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites 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 ofXMLFormat.Asciiwill be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObjectReturns a short XML representation of this object.- Specified by:
getShortXMLin interfaceXMLObject- Returns:
-