public Field addComponent(Component component) { getComponents().add(component); return this; }
/** * Digests attributes and child elements of Field element. * @param node the Field element. * @param field the {@link org.dhatim.edisax.model.internal.Field} to populate * @param namespacePrefix the prefix used to name elements in xml. * @throws org.dhatim.edisax.EDIConfigurationException is thrown when values are badly formatted. */ private void digestField(Node node, Field field, String namespacePrefix, MappingNode parent) throws EDIConfigurationException { setValuesForField(field, node, namespacePrefix, parent); NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node currentNode = nodes.item(i); if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "component")) { Component component = new Component(); field.getComponents().add(component); digestComponent(currentNode, component, namespacePrefix, field); } } }
private void addFields(List<Field> fields, Element segmentEl) { for(Field field : fields) { Element fieldEl = newElement("field", segmentEl, field); mapBeanProperties(field, fieldEl, "name", "xmltag", "nodeTypeRef", "truncatable", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); addComponents(field.getComponents(), fieldEl); } }
Set<String> names = new HashSet<String>(); for (Field field : fields) { if (field.getComponents().isEmpty()) {
newClass = classes.get(newClass.getName()); for (Component component : field.getComponents()) { EStructuralFeature attribute = componentToEAttribute(component); if (newClass.getEStructuralFeature(attribute.getName()) == null) {
component.setRequired(linePart.isMandatory()); populateComponent(component, components.get(linePart.getId())); field.getComponents().add(component);
if (field.getComponents().size() == 0 && (!currentSegmentFields[i].equals(""))) { validateValueNode(field, currentSegmentFields[i]);
private static Field copyField(Field oldField, boolean isMandatory) { Field field = new Field(); field.setName(oldField.getName()); field.setXmltag(XmlTagEncoder.encode(oldField.getXmltag())); field.setNodeTypeRef(oldField.getNodeTypeRef()); field.setDocumentation(oldField.getDocumentation()); field.setMaxLength(oldField.getMaxLength()); field.setMinLength(oldField.getMinLength()); field.setRequired(isMandatory); field.setTruncatable(true); field.setDataType(oldField.getDataType()); field.setDataTypeParameters(oldField.getTypeParameters()); field.getComponents().addAll(oldField.getComponents()); return field; }
/** * Converting a {@link Field} to {@link EAttribute} Works only for * {@link Field} where {@link Field#getComponents()} is empty * * @param field * @return */ public static EAttribute fieldToEAttribute(Field field) { if (!field.getComponents().isEmpty()) { throw new IllegalArgumentException( "Can't convert field with components to " + "EAttribute, use fieldToEReference"); } EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute(); attr.setName(toJavaName(field.getXmltag(), false)); attr.setLowerBound(field.isRequired() ? 1 : 0); attr.setUpperBound(1); if (field.getTypeClass() != null) { attr.setEType(toEType(field.getTypeClass())); } else { log.warn("Field " + field.getXmltag() + " has no type! Setting it's type to String"); attr.setEType(XMLTypePackage.Literals.STRING); } addMappingInformation(attr, field); annotateField(field, attr); return attr; }
field.setTruncatable(isTruncatable(truncatableFields, field.isTruncatable())); if (truncatableComponents != null) { for (Component component : field.getComponents()) { component.setTruncatable(isTruncatable(truncatableComponents, component.isTruncatable()));
List<Component> expectedComponents = expectedField.getComponents();