public class XsdDataItem extends Object
Acts as a facade to the CobolDataItem type. This class is constructed
from a CobolDataItem. All XML Schema attributes are derived at construction
time.
The isODOObject and isRedefined properties are the only ones that are not set at construction time (And therefore have setters). This is because these members can be set only when some data item downstream happens to reference this one.
| Modifier and Type | Class and Description |
|---|---|
static class |
XsdDataItem.XsdType
XSD simple built-in types.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
SAFE_NAME_PREFIX
A prefix to use when a COBOL name starts with an illegal XML character.
|
| Constructor and Description |
|---|
XsdDataItem(CobolDataItem cobolDataItem,
Cob2XsdConfig config,
XsdDataItem parent,
int order,
List<String> nonUniqueCobolNames,
RecognizerErrorHandler errorHandler)
COBOL data item is analyzed at construction time and all XSD attributes
are derived from the COBOL attributes.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
formatElementName(CobolDataItem cobolDataItem,
List<String> nonUniqueCobolNames,
Cob2XsdConfig config,
XsdDataItem parent,
int order)
Turn a COBOL name to an XSD element name.
|
static String |
formatTypeName(String elementName,
CobolDataItem cobolDataItem,
List<String> nonUniqueCobolNames,
Cob2XsdConfig config,
XsdDataItem parent,
int order)
Turn a COBOL name to a unique XSD type name.
|
List<XsdDataItem> |
getChildren() |
List<CobolDataItem> |
getCobolChildren() |
int |
getCobolMaxOccurs() |
int |
getCobolMinOccurs() |
String |
getCobolName() |
CobolTypes |
getCobolType() |
List<String> |
getConditionLiterals() |
List<CobolDataItem.Range> |
getConditionRanges() |
CobolDataItem.DataEntryType |
getDataEntryType() |
String |
getDependingOn() |
int |
getFractionDigits() |
int |
getLength() |
int |
getLevelNumber() |
protected int |
getMaxDigits(Map<Character,Integer> intCharNum,
char currencySymbol)
The maximum number of digits supported by a numeric is given by its
picture clause.
|
int |
getMaxOccurs() |
int |
getMaxStorageLength() |
int |
getMinOccurs() |
int |
getMinStorageLength() |
XsdDataItem |
getParent() |
String |
getPattern() |
String |
getPicture() |
String |
getRedefines() |
int |
getSrceLine() |
int |
getTotalDigits() |
CobolUsage.Usage |
getUsage() |
String |
getUsageForCobol() |
String |
getValue() |
static String |
getXmlCompatibleCobolName(String cobolName)
Transform the COBOL name to a valid XML Name.
|
String |
getXsdElementName() |
XsdDataItem.XsdType |
getXsdType() |
String |
getXsdTypeName() |
boolean |
isBlankWhenZero() |
protected boolean |
isGroup(CobolDataItem cobolDataItem)
Items are identified as group items if they has at least one child that
is not a condition.
|
boolean |
isJustifiedRight() |
boolean |
isNumeric() |
boolean |
isODOObject() |
boolean |
isRedefined() |
boolean |
isSign() |
boolean |
isSigned() |
boolean |
isSignLeading() |
boolean |
isSignSeparate() |
boolean |
markODOObjectInAncestor(String odoObjectCobolName)
Lookup our ancestors for the ODO object of an array.
|
boolean |
markODOObjectInChildren(String odoObjectCobolName,
String stopChildCobolName)
Lookup an ODO object in this item's children.
|
protected void |
setDataDescription(CobolDataItem cobolDataItem,
Cob2XsdConfig config,
List<String> nonUniqueCobolNames)
Setup a regular data description entry, elementary data items and groups.
|
protected void |
setDigitsAndSign(String picture,
char currencySymbol,
boolean decimalPointIsComma)
Extracts total number of digits, fraction digits and sign from a picture
clause.
|
void |
setIsODOObject(boolean isODOObject) |
void |
setIsRedefined(boolean isRedefined) |
String |
toString() |
String |
updateRedefinition(String cobolName)
Called when some child (or child of a child) has a REDEFINES clause.
|
public static final String SAFE_NAME_PREFIX
public XsdDataItem(CobolDataItem cobolDataItem, Cob2XsdConfig config, XsdDataItem parent, int order, List<String> nonUniqueCobolNames, RecognizerErrorHandler errorHandler)
cobolDataItem - the COBOL elementary data itemconfig - the translator options in effectparent - the parent data item or null if rootorder - order within parent to disambiguate siblingsnonUniqueCobolNames - a list of non unique COBOL names used to
detect name collisionserrorHandler - collects translation errorsprotected void setDataDescription(CobolDataItem cobolDataItem, Cob2XsdConfig config, List<String> nonUniqueCobolNames)
cobolDataItem - the COBOL elementary data itemconfig - the translator options in effectnonUniqueCobolNames - a list of non unique COBOL names used to
detect name collisionsprotected boolean isGroup(CobolDataItem cobolDataItem)
If a group item has a picture clause assume a COBOL syntax error issue a warning and ignore children.
cobolDataItem - the COBOL data item to check for groupnesspublic boolean markODOObjectInAncestor(String odoObjectCobolName)
First we ask our direct parent to lookup in his children (stopping when he reaches us).
If we can't find in the immediate parent, then we move up to the grand parent.
odoObjectCobolName - the depending on object name.public boolean markODOObjectInChildren(String odoObjectCobolName, String stopChildCobolName)
Recurses through the grand children until found or no more children to lookup.
odoObjectCobolName - the ODO Object we are looking forstopChildCobolName - a child name past which it is not useful to
continue the lookuppublic String updateRedefinition(String cobolName)
In case the redefined parent is itself redefining a grand parent (transitive redefines), we don't update the isRedefined property and send back the grand parent name (to be used as the true redefines).
cobolName - the redefines object.protected void setDigitsAndSign(String picture, char currencySymbol, boolean decimalPointIsComma)
Works for zoned decimals, binary and packed decimal.
picture - a purely numeric picture clausecurrencySymbol - the currency symboldecimalPointIsComma - true if decimal point is commaprotected int getMaxDigits(Map<Character,Integer> intCharNum, char currencySymbol)
Currency symbol, + and - can be used for floating insertion editing in which case they are repeated more than once.
intCharNum - the picture symbols mapcurrencySymbol - the currency symbol in usepublic static String formatElementName(CobolDataItem cobolDataItem, List<String> nonUniqueCobolNames, Cob2XsdConfig config, XsdDataItem parent, int order)
COBOL names look ugly in XML schema. They are often uppercased and use hyphens extensively. XML schema names they will have to be transformed later to java identifiers so we try to get as close as possible to a naming convention that suits XML Schema as well as Java.
So we remove hyphens. We lower case all characters which are not word breakers. Word breakers are hyphens and numerics. This creates Camel style names. Element names customarily start with a lowercase character.
COBOL FILLERs are a particular case because there might be more than one in the same parent group. So what we do is systematically append the COBOL source line number so that these become unique names.
COBOL names can start with a digit which is illegal for XML element names. In this case we prepend a "C" character.
Since Enterprise COBOL V4R1, underscores can be used (apart from first character). We treat them as hyphens here, they are not propagated to the XSD name but are used as word breakers.
Once an element name is identified, we make sure it is unique among siblings within the same parent.
cobolDataItem - the original COBOL data itemnonUniqueCobolNames - a list of non unique COBOL names used to
detect name collisionsconfig - the translator optionsparent - used to resolve potential name conflictorder - order within parent to disambiguate siblingspublic static String formatTypeName(String elementName, CobolDataItem cobolDataItem, List<String> nonUniqueCobolNames, Cob2XsdConfig config, XsdDataItem parent, int order)
Complex type names customarily start with an uppercase character.
The proposed name might be conflicting with another so we disambiguate xsd type names with one of 2 options:
cobolDataItem - the COBOL data itemelementName - the element name built from the COBOL namenonUniqueCobolNames - a list of non unique COBOL namesconfig - the translator optionsparent - used to resolve potential name conflictorder - order within parent to disambiguate siblingspublic static String getXmlCompatibleCobolName(String cobolName)
cobolName - the original COBOL data item namepublic XsdDataItem.XsdType getXsdType()
public CobolTypes getCobolType()
public int getLength()
public String getPattern()
public int getTotalDigits()
public int getFractionDigits()
public String getXsdElementName()
public String getXsdTypeName()
public List<XsdDataItem> getChildren()
public int getMinOccurs()
public int getCobolMinOccurs()
public int getMaxOccurs()
public int getCobolMaxOccurs()
public int getLevelNumber()
public String getCobolName()
public String getPicture()
public CobolUsage.Usage getUsage()
public String getUsageForCobol()
public boolean isJustifiedRight()
public boolean isSign()
public boolean isSignLeading()
public boolean isSignSeparate()
public String getDependingOn()
public boolean isSigned()
public String getRedefines()
public String getValue()
public int getSrceLine()
public CobolDataItem.DataEntryType getDataEntryType()
public List<String> getConditionLiterals()
public List<CobolDataItem.Range> getConditionRanges()
public boolean isBlankWhenZero()
public XsdDataItem getParent()
public boolean isODOObject()
public boolean isRedefined()
public void setIsODOObject(boolean isODOObject)
isODOObject - true if some array size downstream depends on this
data item valuepublic void setIsRedefined(boolean isRedefined)
isRedefined - true if some item downstream redefines this data itempublic int getMinStorageLength()
public int getMaxStorageLength()
public boolean isNumeric()
public List<CobolDataItem> getCobolChildren()
Copyright © 2021 LegSem. All rights reserved.