Package mgui.numbers
Class MguiLong
java.lang.Object
mgui.numbers.MguiLong
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<MguiNumber>
,XMLObject
,MguiNumber
public class MguiLong extends java.lang.Object implements MguiNumber
Implementation of
MguiNumber
for values of type long
.- 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 long
value
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description MguiNumber
add(double n)
Update the value of this number by addingn
.MguiNumber
add(MguiNumber number)
Update the value of this number by addingn
.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 byn
.MguiNumber
divide(MguiNumber number)
Update the value of this number by dividing byn
.boolean
equals(java.lang.Object obj)
int
getByteSize()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.String
getLocalName()
Returns the local name associated with this XML object.long
getLong()
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 numberstatic long
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 representationvoid
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 byn
.MguiNumber
multiply(MguiNumber number)
Update the value of this number by multiplying byn
.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 subtractingn
.MguiNumber
subtract(MguiNumber number)
Update the value of this number by subtractingn
.java.lang.String
toString()
java.lang.String
toString(java.lang.String pattern)
Returns the value of this number as aString
, formatted withpattern
.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, asXMLType.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 long value
-
-
Constructor Details
-
MguiLong
public MguiLong() -
MguiLong
public MguiLong(int thisValue) -
MguiLong
public MguiLong(java.lang.String thisValue) -
MguiLong
public MguiLong(double value)
-
-
Method Details
-
getValue
public double getValue()Description copied from interface:MguiNumber
Returns the value of this number- Specified by:
getValue
in interfaceMguiNumber
- Returns:
-
compareTo
public int compareTo(double value, int precision)- Specified by:
compareTo
in interfaceMguiNumber
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
getLong
public long getLong() -
getValue
public static long getValue(java.lang.String s) -
setValue
- Specified by:
setValue
in interfaceMguiNumber
-
setValue
public void setValue(double thisValue)- Specified by:
setValue
in interfaceMguiNumber
-
add
Description copied from interface:MguiNumber
Update the value of this number by addingn
.- Specified by:
add
in interfaceMguiNumber
- Returns:
- this number
-
divide
Description copied from interface:MguiNumber
Update the value of this number by dividing byn
.- Specified by:
divide
in interfaceMguiNumber
- Returns:
- this number
-
subtract
Description copied from interface:MguiNumber
Update the value of this number by subtractingn
.- Specified by:
subtract
in interfaceMguiNumber
- Returns:
- this number
-
multiply
Description copied from interface:MguiNumber
Update the value of this number by multiplying byn
.- Specified by:
multiply
in interfaceMguiNumber
- Returns:
- this number
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(java.lang.String pattern)Description copied from interface:MguiNumber
Returns the value of this number as aString
, formatted withpattern
.- Specified by:
toString
in interfaceMguiNumber
- Returns:
-
setValue
public boolean setValue(java.lang.String val)- Specified by:
setValue
in interfaceMguiNumber
-
getString
public static java.lang.String getString(int thisVal, java.lang.String pattern) -
clone
public java.lang.Object clone()- Specified by:
clone
in interfaceMguiNumber
- Overrides:
clone
in classjava.lang.Object
-
compareTo
- Specified by:
compareTo
in interfacejava.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 interfaceMguiNumber
-
getByteSize
public int getByteSize()- Specified by:
getByteSize
in interfaceMguiNumber
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
add
Description copied from interface:MguiNumber
Update the value of this number by addingn
.- Specified by:
add
in interfaceMguiNumber
- Returns:
- this number
-
divide
Divides this number byn
. Treats the values as doubles for the operation.- Specified by:
divide
in interfaceMguiNumber
- Returns:
- this number
-
multiply
Multiplies this number byn
. Treats the values as doubles for the operation.- Specified by:
multiply
in interfaceMguiNumber
- Returns:
- this number
-
subtract
Description copied from interface:MguiNumber
Update the value of this number by subtractingn
.- Specified by:
subtract
in interfaceMguiNumber
- 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 representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObject
Returns the local name associated with this XML object.- Specified by:
getLocalName
in interfaceXMLObject
- 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 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: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 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:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- 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 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:XMLObject
Handles the start of an XML element.- Specified by:
handleXMLElementStart
in interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
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 interfaceXMLObject
- Parameters:
s
- String to handle
-
getXMLInstance
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription 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 ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will 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: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 ofXMLFormat.Ascii
will be used. -
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 interfaceXMLObject
- Returns:
-