/** {@inheritDoc} */ public void setPropertyValue(final int index) throws HostException { ICobolBinding child = getChildrenList().get(index); /* Children that are not bound to a value object are ignored. * This includes Choices and dynamically generated counters * for instance. */ if (!child.isBound()) { return; } /* Set the Value object property value from binding object */ Object bindingValue = null; switch (index) { case 0: bindingValue = child.getObjectValue(LsUnsignedPackedDecimal.class); mValueObject.setLsUnsignedPackedDecimal((LsUnsignedPackedDecimal) bindingValue); break; default: break; } if (_log.isDebugEnabled()) { _log.debug( "Setting value of Value object property " + child.getJaxbName() + " value=" + bindingValue); } }
/** * Recursively adds fields to the fields list. * * <p>Field names may be prefixed with the parent name to avoid name conflicts. * * <p>Arrays are split in the maximum number of items, each one being named after the array name * and suffixed with its index within the array. * * <p>Choices (redefines) result in alternatives being ignored. This is because PDI does not allow * the list of fields to be redefined dynamically based on content. So we cannot use LegStar * redefines handling strategies. * * @param fields a list of fields being populated * @param binding the current COBOL data item * @param prefix the parents names (space if root) * @param suffix the index for array items * @param redefined true if this field is in a redefined sub-structure * @throws HostException if COBOL introspection fails */ public static void toFields( final List<CobFileInputField> fields, final ICobolBinding binding, final String prefix, final String suffix, final boolean redefined) throws HostException { if (binding instanceof ICobolComplexBinding) { for (ICobolBinding child : ((ICobolComplexBinding) binding).getChildrenList()) { String newPrefix = (prefix == null) ? "" : (prefix.length() == 0 ? binding.getBindingName() : prefix + "_" + binding.getBindingName()); toFields(fields, child, newPrefix, suffix, redefined); } } else if (binding instanceof ICobolChoiceBinding) { /* * Opt to process the first alternative only and mark all * descendants as redefined. */ String newPrefix = (prefix == null) ? "" : (prefix.length() == 0 ? binding.getBindingName() : prefix + "_" + binding.getBindingName()); toFields( fields, ((ICobolChoiceBinding) binding).getAlternativesList().get(0), newPrefix, suffix, true); } else if (binding instanceof ICobolArrayBinding) { for (int i = 0; i < ((ICobolArrayBinding) binding).getMaxOccurs(); i++) { String newSuffix = ((suffix == null) ? "_" : suffix + "_") + i; if (binding instanceof ICobolArrayComplexBinding) { toFields( fields, ((ICobolArrayComplexBinding) binding).getComplexItemBinding(), prefix, newSuffix, redefined); } else { fields.add(toField(fields, binding, prefix, newSuffix, redefined)); } } } else { fields.add(toField(fields, binding, prefix, suffix, redefined)); } }
/** * For elementary COBOL data items, this translates COBOL properties to PDI field properties. * * @param binding the elementary COBOL data item * @param prefix the parents names (space if root) * @param suffix the index for array items * @param redefined true if this field is in a redefined sub-structure * @return a PDI field */ public static CobFileInputField toField( final List<CobFileInputField> fields, final ICobolBinding binding, final String prefix, final String suffix, final boolean redefined) { CobFileInputField field = new CobFileInputField(); field.setName(newName(fields, binding.getBindingName(), prefix, suffix)); if (binding instanceof ICobolNumericBinding || binding instanceof ICobolArrayNumericBinding) { field.setPrecision(binding.getFractionDigits()); } else { field.setPrecision(-1); } field.setLength(-1); field.setTrimType(ValueMetaInterface.TRIM_TYPE_NONE); if (binding instanceof ICobolStringBinding) { field.setType(ValueMetaInterface.TYPE_STRING); field.setLength((binding.getByteLength())); field.setTrimType(ValueMetaInterface.TRIM_TYPE_RIGHT); } else if (binding instanceof ICobolArrayStringBinding) { field.setType(ValueMetaInterface.TYPE_STRING); field.setLength(((ICobolArrayBinding) binding).getItemByteLength()); field.setTrimType(ValueMetaInterface.TRIM_TYPE_RIGHT); } else if (binding instanceof ICobolNumericBinding || binding instanceof ICobolArrayNumericBinding) { if (binding.getFractionDigits() > 0) { field.setType(ValueMetaInterface.TYPE_BIGNUMBER); } else { field.setType(ValueMetaInterface.TYPE_INTEGER); } } else if (binding instanceof ICobolDoubleBinding || binding instanceof ICobolArrayDoubleBinding) { field.setType(ValueMetaInterface.TYPE_NUMBER); } else if (binding instanceof ICobolFloatBinding || binding instanceof ICobolArrayFloatBinding) { field.setType(ValueMetaInterface.TYPE_NUMBER); } else if (binding instanceof ICobolDbcsBinding || binding instanceof ICobolNationalBinding) { field.setType(ValueMetaInterface.TYPE_STRING); field.setLength((binding.getByteLength() / 2)); field.setTrimType(ValueMetaInterface.TRIM_TYPE_RIGHT); } else if (binding instanceof ICobolArrayDbcsBinding || binding instanceof ICobolArrayNationalBinding) { field.setType(ValueMetaInterface.TYPE_STRING); field.setLength(((ICobolArrayBinding) binding).getItemByteLength() / 2); field.setTrimType(ValueMetaInterface.TRIM_TYPE_RIGHT); } else if (binding instanceof ICobolOctetStreamBinding) { field.setType(ValueMetaInterface.TYPE_BINARY); field.setLength((binding.getByteLength())); } else if (binding instanceof ICobolArrayOctetStreamBinding) { field.setType(ValueMetaInterface.TYPE_BINARY); field.setLength(((ICobolArrayBinding) binding).getItemByteLength()); } else { field.setType(ValueMetaInterface.TYPE_NONE); } field.setFormat(""); field.setCurrencySymbol(""); field.setDecimalSymbol(""); field.setGroupSymbol(""); field.setRedefined(redefined); return field; }