Package org.codehaus.janino

# Class Java.SimpleConstant

java.lang.Object
org.codehaus.janino.Java.Located
org.codehaus.janino.Java.Atom
org.codehaus.janino.Java.Rvalue
org.codehaus.janino.Java.SimpleConstant

All Implemented Interfaces:
  `Java.ArrayInitializerOrRvalue`, `Java.ElementValue`, `Java.Locatable`

Enclosing class:
  `Java`

public static final class Java.SimpleConstant extends Java.Rvalue
This class is not used when code is parsed; it is intended for "programmatic" literals.

## Field Summary

### Fields inherited from class org.codehaus.janino.Java.Located

`NOWHERE`

## Constructor Summary

Constructors
Constructor
Description
`SimpleConstant(Location location)`
Equivalent of the `null` literal.
`SimpleConstant(Location location, boolean value)`
Equivalent of a `Java.BooleanLiteral`.
`SimpleConstant(Location location, byte value)`
Equivalent of an literal, cast to `byte`.
`SimpleConstant(Location location, char value)`
Equivalent of a `Java.CharacterLiteral`.
`SimpleConstant(Location location, double value)`
Equivalent of a `Java.FloatingPointLiteral` with type `double`.
`SimpleConstant(Location location, float value)`
Equivalent of a `Java.FloatingPointLiteral` with type `float`.
`SimpleConstant(Location location, int value)`
Equivalent of an `Java.IntegerLiteral` with type `int`.
`SimpleConstant(Location location, long value)`
Equivalent of an `Java.IntegerLiteral` with type `long`.
`SimpleConstant(Location location, short value)`
Equivalent of an literal, cast to `short`.
`SimpleConstant(Location location, String value)`
Equivalent of a `Java.StringLiteral`, or, if `value` is null, the equivalent of a `Java.NullLiteral`.

## Method Summary

Modifier and Type
Method
Description
`<R, EX extends Throwable>
R`
`accept(Visitor.RvalueVisitor<R,EX> visitor)`
Invokes the "`visit...()`" method of `Visitor.RvalueVisitor` for the concrete `Java.Rvalue` type.
`String`
`toString()`

### Methods inherited from class org.codehaus.janino.Java.Rvalue

`accept, accept, accept, getEnclosingScope, getEnclosingScopeOrNull, setEnclosingScope, toRvalue`

### Methods inherited from class org.codehaus.janino.Java.Atom

`toLvalue, toLvalueOrCompileException, toRvalueOrCompileException, toType, toTypeOrCompileException`

### Methods inherited from class org.codehaus.janino.Java.Located

`getLocation, throwCompileException`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.codehaus.janino.Java.Locatable

`getLocation, throwCompileException`

## Constructor Details

### SimpleConstant

public SimpleConstant(Location location)
Equivalent of the `null` literal.

### SimpleConstant

public SimpleConstant(Location location, byte value)
Equivalent of an literal, cast to `byte`.

### SimpleConstant

public SimpleConstant(Location location, short value)
Equivalent of an literal, cast to `short`.

### SimpleConstant

public SimpleConstant(Location location, int value)
Equivalent of an `Java.IntegerLiteral` with type `int`.

### SimpleConstant

public SimpleConstant(Location location, long value)
Equivalent of an `Java.IntegerLiteral` with type `long`.

### SimpleConstant

public SimpleConstant(Location location, float value)
Equivalent of a `Java.FloatingPointLiteral` with type `float`.

Notice that this class supports the special values `Float.NaN`, `Float.NEGATIVE_INFINITY` and `Float.POSITIVE_INFINITY`, which can not be represented with a `Java.FloatingPointLiteral`.

### SimpleConstant

public SimpleConstant(Location location, double value)
Equivalent of a `Java.FloatingPointLiteral` with type `double`.

Notice that this class supports the special values `Double.NaN`, `Double.NEGATIVE_INFINITY` and `Double.POSITIVE_INFINITY`, which can not be represented with a `Java.FloatingPointLiteral`.

### SimpleConstant

public SimpleConstant(Location location, char value)
Equivalent of a `Java.CharacterLiteral`.

### SimpleConstant

public SimpleConstant(Location location, boolean value)
Equivalent of a `Java.BooleanLiteral`.

### SimpleConstant

public SimpleConstant(Location location, String value)
Equivalent of a `Java.StringLiteral`, or, if `value` is null, the equivalent of a `Java.NullLiteral`.

## Method Details

### accept

@Nullable public <R, EX extends Throwable> R accept(Visitor.RvalueVisitor<R,EX> visitor) throws EX
Description copied from class: `Java.Rvalue`
Invokes the "`visit...()`" method of `Visitor.RvalueVisitor` for the concrete `Java.Rvalue` type.

Specified by:
  `accept` in class `Java.Rvalue`
Throws:
  `EX`

### toString

public String toString()

Specified by:
  `toString` in class `Java.Atom`