public final class PictureUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
calcLengthFromPicture(Map<Character,Integer> charNum,
boolean isSignSeparate,
String currencySign,
char currencySymbol,
boolean calcStorageLength)
The COBOL picture clause determines the length, in number of characters,
for all alphanumeric and numeric-edited data items.
|
static Map<Character,Integer> |
getPictureCharOccurences(String picture,
char currencySymbol)
Determines how many times a given character occurs in a picture string.
|
static String |
getRegexFromPicture(String picture,
String currencySign,
char currencySymbol)
Try to infer a regular expression to match a COBOL picture clause.
|
static List<PictureSymbol> |
parsePicture(String picture,
char currencySymbol)
Parse a COBOL picture clause.
|
public static Map<Character,Integer> getPictureCharOccurences(String picture, char currencySymbol)
picture - the picture stringcurrencySymbol - the currency symbolpublic static int calcLengthFromPicture(Map<Character,Integer> charNum, boolean isSignSeparate, String currencySign, char currencySymbol, boolean calcStorageLength)
The length evaluated here is either the number of character positions (which corresponds to the size constraint on the client side) or the byte size of the storage needed on z/OS for the data item. You select between one or the other with the calcStorageLength parameter.
When the currency sign is more than a single character, then the first occurrence of the currency symbol counts for more than one byte of storage.
charNum - map of all characters in the picture stringisSignSeparate - if sign occupies a separated position (no
overpunch)currencySign - the currency signcurrencySymbol - the currency symbolcalcStorageLength - when true the length returned is the z/OS
storage lengthpublic static String getRegexFromPicture(String picture, String currencySign, char currencySymbol)
The objective is to build a string that would fit the internal representation of a picture edited COBOL field.
If a picture is not restrictive, for instance PIC X does not impose any restriction, then we return null (no pattern).
Regular expressions in XML Schema are more like PERL than Java regex.
picture - the picture clausecurrencySign - the currency signcurrencySymbol - the currency symbolpublic static List<PictureSymbol> parsePicture(String picture, char currencySymbol)
For instance: 9(3)V99XX becomes 4 entries in the list for characters 9, V, 9 and X. First 9 occurs 3 times, V occurs 1 time, 9 occurs 2 and X occurs 2.
currencySymbol - the currency symbolpicture - the COBOL picture clauseCopyright © 2021 LegSem. All rights reserved.