@Test public void testFormatElementName() { List < String > nonUniqueCobolNames = new ArrayList < String >(); assertEquals("", XsdDataItem.formatElementName(new CobolDataItem(""), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("a", XsdDataItem.formatElementName(new CobolDataItem("A"), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("ab", XsdDataItem.formatElementName( new CobolDataItem("AB"), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("ab9C", XsdDataItem.formatElementName(new CobolDataItem( "AB9C"), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("ab9Cd", XsdDataItem.formatElementName(new CobolDataItem( "AB9CD"), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("ab9CdE", XsdDataItem.formatElementName(new CobolDataItem( "AB9CD-E"), nonUniqueCobolNames, defaultConfig, null, 0)); assertEquals("ab9CdEf", XsdDataItem.formatElementName( new CobolDataItem("AB9CD-EF"), nonUniqueCobolNames, defaultConfig, null, 0)); configProps.put(Cob2XsdConfig.ELEMENT_NAMES_START_WITH_UPPERCASE, Boolean.toString(true)); Cob2XsdConfig config = new Cob2XsdConfig(configProps); assertEquals("Ab9CdEf", XsdDataItem.formatElementName( new CobolDataItem("AB9CD-EF"), nonUniqueCobolNames, config, null, 0)); }
public static String formatElementName(final CobolDataItem cobolDataItem, final List < String > nonUniqueCobolNames, final Cob2XsdConfig config, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem .getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (config.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (config.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; }
XsdDataItem { public static String formatElementName(final CobolDataItem cobolDataItem, final List < String > nonUniqueCobolNames, final Cob2XsdConfig config, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem .getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (config.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (config.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; } }
XsdDataItem { public static String formatElementName(final CobolDataItem cobolDataItem, final List < String > nonUniqueCobolNames, final Cob2XsdConfig config, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem .getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (config.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (config.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; } XsdDataItem(final CobolDataItem cobolDataItem,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order, final List < String > nonUniqueCobolNames,
            final RecognizerErrorHandler errorHandler); }
XsdDataItem { public static String formatElementName(final CobolDataItem cobolDataItem, final List < String > nonUniqueCobolNames, final Cob2XsdConfig config, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem .getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (config.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (config.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; } XsdDataItem(final CobolDataItem cobolDataItem,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order, final List < String > nonUniqueCobolNames,
            final RecognizerErrorHandler errorHandler); boolean markODOObjectInAncestor(final String odoObjectCobolName); boolean markODOObjectInChildren(final String odoObjectCobolName,
            final String stopChildCobolName); void updateRedefinition(final String cobolName); static String formatElementName(final CobolDataItem cobolDataItem,
            final List < String > nonUniqueCobolNames,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order); static String formatTypeName(final String elementName,
            final CobolDataItem cobolDataItem,
            final List < String > nonUniqueCobolNames,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order); static String getXmlCompatibleCobolName(final String cobolName); XsdType getXsdType(); CobolTypes getCobolType(); int getLength(); String getPattern(); int getTotalDigits(); int getFractionDigits(); String getXsdElementName(); String getXsdTypeName(); List < XsdDataItem > getChildren(); int getMinOccurs(); int getCobolMinOccurs(); int getMaxOccurs(); int getCobolMaxOccurs(); int getLevelNumber(); String getCobolName(); String getPicture(); Usage getUsage(); String getUsageForCobol(); boolean isJustifiedRight(); boolean isSign(); boolean isSignLeading(); boolean isSignSeparate(); String getDependingOn(); boolean isSigned(); String getRedefines(); String getValue(); int getSrceLine(); DataEntryType getDataEntryType(); List < String > getConditionLiterals(); List < Range > getConditionRanges(); boolean isBlankWhenZero(); XsdDataItem getParent(); boolean isODOObject(); boolean isRedefined(); void setIsODOObject(final boolean isODOObject); void setIsRedefined(final boolean isRedefined); int getMinStorageLength(); int getMaxStorageLength(); boolean isNumeric(); List < CobolDataItem > getCobolChildren(); String toString(); }
XsdDataItem { public static String formatElementName(final CobolDataItem cobolDataItem, final List < String > nonUniqueCobolNames, final Cob2XsdConfig config, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem .getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (config.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (config.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; } XsdDataItem(final CobolDataItem cobolDataItem,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order, final List < String > nonUniqueCobolNames,
            final RecognizerErrorHandler errorHandler); boolean markODOObjectInAncestor(final String odoObjectCobolName); boolean markODOObjectInChildren(final String odoObjectCobolName,
            final String stopChildCobolName); void updateRedefinition(final String cobolName); static String formatElementName(final CobolDataItem cobolDataItem,
            final List < String > nonUniqueCobolNames,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order); static String formatTypeName(final String elementName,
            final CobolDataItem cobolDataItem,
            final List < String > nonUniqueCobolNames,
            final Cob2XsdConfig config, final XsdDataItem parent,
            final int order); static String getXmlCompatibleCobolName(final String cobolName); XsdType getXsdType(); CobolTypes getCobolType(); int getLength(); String getPattern(); int getTotalDigits(); int getFractionDigits(); String getXsdElementName(); String getXsdTypeName(); List < XsdDataItem > getChildren(); int getMinOccurs(); int getCobolMinOccurs(); int getMaxOccurs(); int getCobolMaxOccurs(); int getLevelNumber(); String getCobolName(); String getPicture(); Usage getUsage(); String getUsageForCobol(); boolean isJustifiedRight(); boolean isSign(); boolean isSignLeading(); boolean isSignSeparate(); String getDependingOn(); boolean isSigned(); String getRedefines(); String getValue(); int getSrceLine(); DataEntryType getDataEntryType(); List < String > getConditionLiterals(); List < Range > getConditionRanges(); boolean isBlankWhenZero(); XsdDataItem getParent(); boolean isODOObject(); boolean isRedefined(); void setIsODOObject(final boolean isODOObject); void setIsRedefined(final boolean isRedefined); int getMinStorageLength(); int getMaxStorageLength(); boolean isNumeric(); List < CobolDataItem > getCobolChildren(); String toString(); static final String SAFE_NAME_PREFIX; }