public final class Picture
extends java.lang.Number
implements java.lang.Comparable<java.lang.Object>
DCL P PICTURE '99.99';
or DCL Q PICTURE 'X(3)';
.
Pictures have numeric qualities when used in arithmetic expressions and character
qualities when used in input / output statements, so they share both
attributes of a PL/I CODEDARITHMETIC and STRING variable type. When
declared with character attributes (X, A) the Picture data type
operates as STRING, when declared with numeric attributes (9, ., V, CR)
it takes on the role of a CODEDARITHMETIC. This data type covers
both for simplicity even though, for example, CONVERSION CONDITIONs will
be unconditionally raised if an arithmetic operation involves a
STRING Picture.
Picture also supports PL/I commoning attributes such as DATE which performs correct comparisons when two variables with like attributes are compared.
See IBM Enterprise PL/I Language Reference 5.1, PICTURE data element, pg. 66 and Picture specification characters, ch 14, pg 355 for more information. Picture specifications may include the following:
Character Specification Characters
stored as Unicode String Java type
A ASCII character constant
E EBCDIC character constant
X Hex character constant
B4 B3 GX M WX Bit and graphic constant not supported
Numeric Specification Characters
stored as packed decimal java.math.BigDecimal Java type
9 decimal digit
Z leading zero-suppressed decimal digit, displayed as blank
V assumed decimal point
. , / ' insertion characters
B blank character
S optional sign location
+ force positive or negative sign character
- force negative, blank positive sign character
$ default currency character
<char> alternative currency specification, <$>, <yen>
CR credit symbol
DB debit symbol
T I R Overpunch characters { through G
Y all zero-suppression, displayed as blank
Commoning Companion Attributes
stored as Date Java type
YYYY four-digit year
YY two-digit year
MM two-digit month
DD two-digit day-of-month
DDD three-digit day-of-year
Several methods are available to discover the formatting criteria
in a Java-centric way using String.format(), java.text.DecimalFormat or java.text.DateFormat
formatting classes (getStringFormat(), getDateFormat(),
getDecimalFormat()
and a way to determine beforehand whether
they are likely to work on the PICTURE value (isString(), isDate(),
isDecimal()
Methods are available for native Java programming to retrieve the base types used to store Picture data.
Internally hold Picture values in "object" field as either java.math.BigDecimal (numeric Pictures) or String (non-numeric Pictures
Constructor and Description |
---|
Picture(java.math.BigDecimal value)
Constructor - construct a arithmetic Picture from a java.math.BigDecimal
and a @PIC annotation
|
Picture(java.lang.Object value)
Constructor - construct a Picture from an @PIC annotation and data
|
Picture(Picture picture,
java.math.BigDecimal value)
Constructor - construct a arithmetic Picture
|
Picture(Picture picture,
java.lang.Object value)
Constructor - construct a arithmetic Picture
|
Picture(java.lang.String data)
Constructor - construct a Picture variable with specification only
Note: can only be used to communicate the picture specification
to other constructors and valueOf() of pictures
|
Picture(java.lang.String pictureString,
java.math.BigDecimal value)
Constructor - construct a arithmetic Picture from a java.math.BigDecimal
without checking for validity
|
Picture(java.lang.String pictureString,
java.util.Date date)
Constructor - construct a arithmetic Picture
|
Picture(java.lang.String pictureString,
java.lang.Object data)
Constructor - construct a Picture from a pic spec and data
when no annotation (@PIC) is available
|
Picture(java.lang.String pictureString,
java.lang.String data)
Constructor - construct a arithmetic Picture
|
Modifier and Type | Method and Description |
---|---|
Picture |
abs()
abs() - return abs/modulus/magnitude
|
Picture |
add(Picture b)
add(b) - return a new Picture object whose value is (this + b)
|
java.math.BigDecimal |
bigDecimalValue()
bigDecimalValue() - return BigDecimal from a (numeric) Picture number
|
java.math.BigInteger |
bigIntegerValue()
bigIntegerValue() - return a big integer from a Picture number
|
boolean |
booleanValue()
booleanValue() - return a (truncated) boolean from a Picture number or string
|
byte |
byteValue()
byteValue() - return a (truncated) byte from a Picture number
|
int |
charsConsumed()
return the number of chars consumed during conversion
|
int |
compareTo(java.lang.Object x)
compareTo - compare a Picture with a non-Picture
|
Picture |
divide(Picture b)
divide(b) - return a / b
|
double |
doubleValue()
doubleValue() - return a (truncated) double from a Picture number
|
boolean |
equals(java.lang.Object x)
equals - compare two Picture numbers for equality
|
FixedBin |
fixedBinValue()
fixedBinValue() - return a (truncated) FixedBin from a Picture number
|
float |
floatValue()
floatValue() - return a (truncated) float from a Picture number
|
static Picture |
fromBytes(byte[] bytes)
fromBytes() - create a Picture from a byte array
(one that had been generated from toBytes())
|
java.text.DateFormat |
getDateFormat()
getDateFormat() - return the Java java.text.DateFormat object
suitable for formatting this PIC.
|
java.text.DecimalFormat |
getDecimalFormat()
getDecimalFormat() - return the Java java.text.DecimalFormat object
suitable for formatting this PIC.
|
java.lang.Object |
getObject()
getObject() - return the underlying Object this picture is
based upon, either a String for character picture specifications,
java.math.BigDecimal for numeric picture specifications or Date for
picture specifications with the commonly date attribute.
|
java.lang.String |
getPicture()
getPicture() - return the original picture specification
|
com.heirloomcomputing.epli.runtime.Picture.PictureSpec |
getPictureSpec()
get internal PictureSpec of this Picture
|
int |
getSize()
to determine the "size in bytes if converted to a byte array"
convert it to a byte array
|
java.lang.String |
getStringFormat()
getStringFormat() - return the Java Formatter specification
suitable for use in Java String.format() or Formatter class
methods to translate values into Strings following the PIC spec.
|
int |
hashCode()
hashcode of a pic is that of the underlying object
|
int |
intValue()
intValue() - return a (truncated) integer from a Picture number
|
boolean |
isDate()
isDate() - return true if this is a PICTURE specification
with the DATE formatting attribute.
|
boolean |
isDecimal()
isDecimal() - return true if this is a PICTURE specification
usable in numeric calculations (does not have A or X PIC chars).
|
boolean |
isString()
isString() - return true if this is a PICTURE specification
usable containing A or X PIC chars.
|
long |
longValue()
longValue() - return a (truncated) long from a Picture number
|
static void |
main(java.lang.String[] args)
main - unit test for Picture
|
Picture |
multiply(Picture b)
multiply(b) - return a new Picture object whose value is (this * b)
|
Picture |
negate()
negate() - return a new Picture object whose value is (-this)
|
static void |
Reset()
reset the internationalization symbols used for format
invoke after changing the LOCALE settings (e.g., EPLI.RuntimeOption("LOCALE=es_ES")
|
short |
shortValue()
shortValue() - return a (truncated) short from a Picture number
|
int |
size()
return the size in bytes if this Picture were
to be converted with toBytes()
|
Picture |
subtract(Picture b)
subtract(b) - return a new Picture object whose value is (this - b)
|
byte[] |
toByteArray()
toByteArray - synonym for toBytes()
|
byte[] |
toBytes()
toBytes() - return a byte array representation of this picture
|
java.lang.String |
toRawString()
toRawString() - return a String representation the data only, without formating,
of the Picture object
|
java.lang.String |
toString()
toString() - return a String representation of the invoking Picture object
|
java.lang.String |
toString(java.lang.String picSpec)
toString - return a String representation of the invoking Picture object
|
static Picture |
valueOf(java.math.BigDecimal b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(java.math.BigInteger b)
valueOf() - construct a Picture number from a java.math.BigInteger
|
Picture |
valueOf(BitN bs)
valueOf() - construct a Picture number from a BitN
|
Picture |
valueOf(java.lang.Boolean b)
valueOf() - construct a Picture number from a Boolean
|
Picture |
valueOf(byte i)
valueOf() - construct a Picture number from a byte
|
static Picture |
valueOf(java.lang.Byte b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(double d)
valueOf() - construct a Picture number from a double or float
|
static Picture |
valueOf(java.lang.Double b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(FixedBin f)
valueOf() - construct a Picture number from a FixedBin
|
Picture |
valueOf(float f)
valueOf() - construct a Picture number from a double or float
|
static Picture |
valueOf(java.lang.Float b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(int i)
valueOf() - construct a Picture number from an int
|
static Picture |
valueOf(java.lang.Integer b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(long i)
valueOf() - construct a Picture number from a long
|
static Picture |
valueOf(java.lang.Long b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(Picture pval)
valueOf() - construct a Picture number from another Picture
|
Picture |
valueOf(short i)
valueOf() - construct a Picture number from a short
|
static Picture |
valueOf(java.lang.Short b)
valueOf() - construct a Picture number from a java.math.BigDecimal
|
Picture |
valueOf(java.lang.String str)
valueOf() - duplicate a Picture but with a different value
|
static Picture |
valueOf(java.lang.String pic,
java.math.BigInteger b)
valueOf() - construct a Picture number from a java.math.BigInteger
|
static Picture |
valueOf(java.lang.String pic,
BitN bs)
valueOf() - construct a Picture number from a BitN
|
static Picture |
valueOf(java.lang.String pic,
java.lang.Boolean b)
valueOf() - construct a Picture number from a Boolean
|
static Picture |
valueOf(java.lang.String pic,
byte i)
valueOf() - construct a Picture number from a byte
|
static Picture |
valueOf(java.lang.String pic,
java.util.Date value)
valueOf() - construct a Picture number from another Picture
|
static Picture |
valueOf(java.lang.String pic,
double d)
valueOf() - construct a Picture number from a double or float
|
static Picture |
valueOf(java.lang.String pic,
FixedBin f)
valueOf() - construct a Picture number from a FixedBin
|
static Picture |
valueOf(java.lang.String pic,
float f)
valueOf() - construct a Picture number from a double or float
|
static Picture |
valueOf(java.lang.String pic,
int i)
valueOf() - construct a Picture number from an int
|
static Picture |
valueOf(java.lang.String pic,
long i)
valueOf() - construct a Picture number from a long
|
static Picture |
valueOf(java.lang.String pic,
Picture pval)
valueOf() - construct a Picture number from another Picture
|
static Picture |
valueOf(java.lang.String pic,
short i)
valueOf() - construct a Picture number from a short
|
static Picture |
valueOf(java.lang.String pictureString,
java.lang.String str)
valueOf() - construct a Picture number from a string
|
public static final Picture ZERO
public Picture(java.lang.String data)
public Picture(java.lang.String pictureString, java.math.BigDecimal value)
packed
- - set a numeric PICTURE specification and value
Note: use static valueOf() to construct other numeric PICTUREspublic Picture(java.math.BigDecimal value)
packed
- - set a numeric PICTURE specification and value
Note: use static valueOf() to construct other numeric PICTUREspublic Picture(Picture picture, java.math.BigDecimal value)
packed
- - set a numeric PICTURE specification and valuepublic Picture(Picture picture, java.lang.Object value)
picture
- - set a string PICTURE specificationvalue
- - and its value conforming to the pic specCONVERSION
- condition if the data does not conform with
the specificationpublic Picture(java.lang.Object value)
value
- - the picture value whose contents infer the PICTURE specificationCONVERSION
- condition if the data does not conform with
the specificationpublic Picture(java.lang.String pictureString, java.lang.String data)
picture
- - a string PICTURE specificationdata
- - the value conforming to the PIC specCONVERSION
- condition if the data does not conform with
the specificationpublic Picture(java.lang.String pictureString, java.lang.Object data)
picture
- - a string PICTURE specificationdata
- - PICTURE valueCONVERSION
- condition if the data does not conform with
the specificationpublic Picture(java.lang.String pictureString, java.util.Date date)
date
- - set a commonly date PICTURE specification and valuepublic static Picture valueOf(java.lang.String pictureString, java.lang.String str)
pic
- - a String of the picture specification is used to construct
(may be null meaning infer the pic spec from the str)str
- - a String value in the same format as returned by toString()public Picture valueOf(java.lang.String str)
str
- - a value value in the form of a String
to be applied to this Picturepublic static Picture valueOf(java.lang.String pic, long i)
pic
- - the String format of the new Picturei
- - a long valuepublic Picture valueOf(long i)
i
- - a long valuepublic static Picture valueOf(java.lang.String pic, int i)
pic
- - the String format of the new Picturei
- - an int valuepublic Picture valueOf(int i)
i
- - an int valuepublic static Picture valueOf(java.lang.String pic, short i)
pic
- - the String format of the new Picturei
- - a short valuepublic Picture valueOf(short i)
i
- - a short valuepublic static Picture valueOf(java.lang.String pic, byte i)
pic
- - the String format of the new Picturei
- - a byte valuepublic Picture valueOf(byte i)
i
- - a byte valuepublic static Picture valueOf(java.lang.String pic, double d)
pic
- - the String format of the new Pictured
- - a double valuepublic Picture valueOf(double d)
d
- - a double valuepublic static Picture valueOf(java.lang.String pic, float f)
pic
- - the String format of the new Picturef
- - a float valuepublic Picture valueOf(float f)
f
- - a float valuepublic static Picture valueOf(java.lang.String pic, FixedBin f)
pic
- - the String format of the new Picturef
- - a FixedBin valuepublic Picture valueOf(FixedBin f)
f
- - a FixedBin valuepublic static Picture valueOf(java.lang.String pic, java.math.BigInteger b)
pic
- - the String format of the new Pictureb
- - a java.math.BigInteger valuepublic static Picture valueOf(java.math.BigDecimal b)
b
- - a java.math.BigDecimal valuepublic static Picture valueOf(java.lang.Byte b)
b
- - a Bytepublic static Picture valueOf(java.lang.Integer b)
b
- - a Integerpublic static Picture valueOf(java.lang.Short b)
b
- - a Shortpublic static Picture valueOf(java.lang.Long b)
b
- - a Longpublic static Picture valueOf(java.lang.Double b)
b
- - a Doublepublic static Picture valueOf(java.lang.Float b)
b
- - a Floatpublic Picture valueOf(java.math.BigInteger b)
b
- - a java.math.BigInteger valuepublic static Picture valueOf(java.lang.String pic, java.lang.Boolean b)
pic
- - the String format of the new Pictureb
- - a Boolean valuepublic Picture valueOf(java.lang.Boolean b)
b
- - a Boolean valuepublic static Picture valueOf(java.lang.String pic, BitN bs)
pic
- - the String format of the new Picturebs
- - a BitN valuepublic Picture valueOf(BitN bs)
bs
- - a BitN valuepublic static Picture valueOf(java.lang.String pic, Picture pval)
pic
- - the String format of the new Picturepval
- - a Picture valuepublic static Picture valueOf(java.lang.String pic, java.util.Date value)
pic
- - the String format of the new Picturepval
- - a Picture valuepublic Picture valueOf(Picture pval)
pval
- - the other Picturepublic static Picture fromBytes(byte[] bytes)
bytes
- - the byte arraypublic int size()
public int charsConsumed()
public boolean isDate()
public boolean isDecimal()
public boolean isString()
public java.lang.String getPicture()
public com.heirloomcomputing.epli.runtime.Picture.PictureSpec getPictureSpec()
public java.lang.String getStringFormat()
toString()
for non-numeric PicturesgetDecimalFormat()
public java.text.DecimalFormat getDecimalFormat()
toString()
for numeric PicturesgetStringFormat()
public java.text.DateFormat getDateFormat()
toString()
for date PicturesgetStringFormat()
,
getDecimalFormat()
public java.lang.Object getObject()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toRawString()
public java.lang.String toString(java.lang.String picSpec)
picSpec
- - use this to format the Picture instead of the one definedpublic byte[] toBytes()
public byte[] toByteArray()
public int getSize()
public java.math.BigDecimal bigDecimalValue()
CONVERSION
- Condition if PICTURE is not numericpublic int intValue()
intValue
in class java.lang.Number
CONVERSION
- Condition if PICTURE is not numericpublic short shortValue()
shortValue
in class java.lang.Number
public byte byteValue()
byteValue
in class java.lang.Number
public long longValue()
longValue
in class java.lang.Number
public java.math.BigInteger bigIntegerValue()
CONVERSION
- Condition if PICTURE is not numericpublic double doubleValue()
doubleValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public FixedBin fixedBinValue()
public boolean booleanValue()
public Picture abs()
public Picture negate()
public Picture add(Picture b)
b
- public Picture subtract(Picture b)
b
- public Picture multiply(Picture b)
b
- public Picture divide(Picture b)
b
- Picture number as the divisorpublic boolean equals(java.lang.Object x)
equals
in class java.lang.Object
x
- - a Picture number to compareCONVERSION
- condition if x is not Picturepublic int compareTo(java.lang.Object x)
compareTo
in interface java.lang.Comparable<java.lang.Object>
x
- - a Picture number to compareCONVERSION
- condition if x is not Picturepublic int hashCode()
hashCode
in class java.lang.Object
public static void Reset()
public static void main(java.lang.String[] args)
args
- - the real & imaginary part of operand "a" and "b", respectively