001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010:
011: package de.uka.ilkd.key.java.expression.literal;
012:
013: import de.uka.ilkd.key.java.NameAbstractionTable;
014: import de.uka.ilkd.key.java.PrettyPrinter;
015: import de.uka.ilkd.key.java.Services;
016: import de.uka.ilkd.key.java.SourceElement;
017: import de.uka.ilkd.key.java.abstraction.KeYJavaType;
018: import de.uka.ilkd.key.java.abstraction.PrimitiveType;
019: import de.uka.ilkd.key.java.expression.Literal;
020: import de.uka.ilkd.key.java.visitor.Visitor;
021: import de.uka.ilkd.key.util.ExtList;
022:
023: /**
024: * Double literal.
025: * @author <TT>AutoDoc</TT>
026: */
027:
028: public class DoubleLiteral extends Literal {
029:
030: /**
031: * Textual representation of the value.
032: */
033:
034: protected final String value;
035:
036: /**
037: * Double literal.
038: */
039:
040: public DoubleLiteral() {
041: this .value = "0.0";
042: }
043:
044: /**
045: * Double literal.
046: * @param value a double value.
047: */
048:
049: public DoubleLiteral(double value) {
050: this .value = "" + value;
051: }
052:
053: /**
054: * Double literal.
055: * @param children list with all children(here:comments)
056: * May contain: Comments
057: * @param value a string.
058: */
059:
060: public DoubleLiteral(ExtList children, String value) {
061: super (children);
062: this .value = value;
063: }
064:
065: /**
066: * Double literal.
067: * @param value a string.
068: */
069:
070: public DoubleLiteral(String value) {
071: this .value = value;
072: }
073:
074: /** tests if equals
075: */
076: public boolean equalsModRenaming(SourceElement o,
077: NameAbstractionTable nat) {
078: if (!(o instanceof DoubleLiteral)) {
079: return false;
080: }
081: return ((DoubleLiteral) o).getValue().equals(getValue());
082: }
083:
084: public int hashCode() {
085: int result = 17;
086: result = 37 * result + getValue().hashCode();
087: return result;
088: }
089:
090: public boolean equals(Object o) {
091: return super .equals(o);
092: }
093:
094: /**
095: * Get value.
096: * @return the string.
097: */
098:
099: public String getValue() {
100: return value;
101: }
102:
103: /** calls the corresponding method of a visitor in order to
104: * perform some action/transformation on this element
105: * @param v the Visitor
106: */
107: public void visit(Visitor v) {
108: v.performActionOnDoubleLiteral(this );
109: }
110:
111: public void prettyPrint(PrettyPrinter p) throws java.io.IOException {
112: p.printDoubleLiteral(this );
113: }
114:
115: public KeYJavaType getKeYJavaType(Services javaServ) {
116: return javaServ.getJavaInfo().getKeYJavaType(
117: PrimitiveType.JAVA_DOUBLE);
118: }
119:
120: }
|