public class Literals
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
toBigDecimalLiteral(java.math.BigDecimal bigDecimal,
GenModel genModel)
Returns a literal expression for the given
BigDecimal value. |
static java.lang.String |
toBigIntegerLiteral(java.math.BigInteger bigInteger,
GenModel genModel)
Returns a literal expression for the given
BigInteger value. |
static java.lang.String |
toBooleanLiteral(boolean b,
GenModel genModel)
Returns the literal expression for the given
boolean value. |
static java.lang.String |
toByteArrayLiteral(byte[] bytes,
GenModel genModel)
Returns a literal expression for the given
byte[] value. |
static java.lang.String |
toByteLiteral(byte b,
GenModel genModel)
Returns the hexadecimal literal expression for the given
byte
value. |
static java.lang.String |
toCharLiteral(char c,
GenModel genModel)
Returns a literal expression for the given
char value. |
static java.lang.String |
toClassLiteral(java.lang.Class<?> c,
GenModel genModel)
Returns a literal expression for the given
Class value. |
static java.lang.String |
toDateLiteral(java.util.Date date,
GenModel genModel)
Returns a literal expression for the given
Date value. |
static java.lang.String |
toDoubleLiteral(double d,
GenModel genModel)
Returns a literal expression for the given
double value. |
static java.lang.String |
toFloatLiteral(float f,
GenModel genModel)
Returns a literal expression for the given
float value. |
static java.lang.String |
toIntLiteral(int i,
GenModel genModel)
Returns the decimal literal expression for the given
int
value. |
static java.lang.String |
toLiteral(java.lang.Object o)
Convenience dispatch method.
|
static java.lang.String |
toLiteral(java.lang.Object o,
boolean boxPrimitive,
GenModel genModel)
Convenience dispatch method.
|
static java.lang.String |
toLiteral(java.lang.Object o,
GenModel genModel)
Convenience dispatch method.
|
static java.lang.String |
toLongLiteral(long l,
GenModel genModel)
Returns the decimal literal expression for the given
long
value. |
static java.lang.String |
toShortLiteral(short s,
GenModel genModel)
Returns the decimal literal expression for the given
short
value. |
static java.lang.String |
toStringLiteral(java.lang.String s,
GenModel genModel)
Returns a literal expression for the given
String . |
static java.lang.String |
toUnsafeCharLiteral(char c,
GenModel genModel)
Returns a literal expression for the given
char value. |
static java.lang.String |
toUnsafeStringLiteral(java.lang.String s,
GenModel genModel)
Returns a literal expression for the given
String . |
public static java.lang.String toLiteral(java.lang.Object o)
object
is an instance
of Boolean
, Byte
, Short
,
Integer
, Long
, Float
,
Double
, Character
, String
,
BigDecimal
, BigInteger
, Date
,
Class
, or byte[]
, the appropriate conversion
method is called, with the unboxed primitive, or the typed object as an
argument. Class names are never imported; the qualified name is used.public static java.lang.String toLiteral(java.lang.Object o, GenModel genModel)
object
is an instance
of Boolean
, Byte
, Short
,
Integer
, Long
, Float
,
Double
, Character
, String
,
BigDecimal
, BigInteger
, Date
,
Class
, or byte[]
, the appropriate conversion
method is called, with the unboxed primitive, or the typed object as an
argument.
The specified GenModel
,
if non-null, is used when necessary to import class names.
public static java.lang.String toLiteral(java.lang.Object o, boolean boxPrimitive, GenModel genModel)
object
is an instance
of Boolean
, Byte
, Short
,
Integer
, Long
, Float
,
Double
, Character
, String
,
BigDecimal
, BigInteger
, Date
,
Class
, or byte[]
, the appropriate conversion
method is called, with the unwrapped primitive, or the typed object as an
argument.
The specified GenModel
,
if non-null, is used when necessary to import class names.
If the object is a primitive type,
public static java.lang.String toBooleanLiteral(boolean b, GenModel genModel)
boolean
value.public static java.lang.String toByteLiteral(byte b, GenModel genModel)
byte
value.public static java.lang.String toShortLiteral(short s, GenModel genModel)
short
value.public static java.lang.String toIntLiteral(int i, GenModel genModel)
int
value.public static java.lang.String toLongLiteral(long l, GenModel genModel)
long
value.public static java.lang.String toFloatLiteral(float f, GenModel genModel)
float
value.
This literal may be in simple form or exponential notation, or it may
be one of the special values java.lang.Float.NaN
,
java.lang.Float.POSITIVE_INFINITY
, or
java.lang.Float.NEGATIVE_INFINITY
.public static java.lang.String toDoubleLiteral(double d, GenModel genModel)
double
value.
This literal may be in simple form or exponential notation, or it may
be one of the special values java.lang.Double.NaN
,
java.lang.Double.POSITIVE_INFINITY
, or
java.lang.Double.NEGATIVE_INFINITY
.public static java.lang.String toCharLiteral(char c, GenModel genModel)
char
value.
This literal will be in its escaped form if it is backspace,
horizontal tab, newline, form feed, carriage return, double quote,
single quote, or backslash. If it is within the common printable
range of space (32) to ~
(126), it will simply be the
character literal. Otherwise, it will be in the escaped Unicode
encoding form.public static java.lang.String toUnsafeCharLiteral(char c, GenModel genModel)
char
value.
This literal will be in its escaped form if it is backspace,
horizontal tab, newline, form feed, carriage return, double quote,
single quote, or backslash. Otherwise, it will simply be the character
literal. This result may not fall within the common printable range.public static java.lang.String toStringLiteral(java.lang.String s, GenModel genModel)
String
. Each
of its characters will appear in the same form as if it was the
argument to toCharLiteral(char, org.eclipse.emf.codegen.ecore.genmodel.GenModel)
.public static java.lang.String toUnsafeStringLiteral(java.lang.String s, GenModel genModel)
String
. Each
of its characters will appear in the same form as if it was the
argument to toUnsafeCharLiteral(char, org.eclipse.emf.codegen.ecore.genmodel.GenModel)
.public static java.lang.String toBigDecimalLiteral(java.math.BigDecimal bigDecimal, GenModel genModel)
BigDecimal
value.public static java.lang.String toBigIntegerLiteral(java.math.BigInteger bigInteger, GenModel genModel)
BigInteger
value.public static java.lang.String toDateLiteral(java.util.Date date, GenModel genModel)
Date
value.public static java.lang.String toClassLiteral(java.lang.Class<?> c, GenModel genModel)
Class
value.public static java.lang.String toByteArrayLiteral(byte[] bytes, GenModel genModel)
byte[]
value.