Package org.jitterbit.integration.data.structure.text

Examples of org.jitterbit.integration.data.structure.text.Field


        Segment root = Segment.newRootSegment();
        s.addSegment(root);
        Segment order = new Segment("Order");
        order.setOccurrence(SegmentOccurrence.ZeroOrMore);
        order.setParentName(root.getName());
        Field id = Field.newDelimitedIdentifier("O");
        order.fieldList.add(id);
        Field date = new Field(1, "Date", FieldDataType.Date.name(), "", "", 0, 0, 0, id);
        order.fieldList.add(date);
        Field anotherDate = new Field(2, "Date", FieldDataType.Date.name(), "", "", 0, 0, 0, date);
        order.fieldList.add(anotherDate);
        s.addSegment(order);
        return s;
    }
View Full Code Here


    }

    private Segment createSegment(DatabaseObject table, String id) {
        Segment segment = new Segment("");
        if (id != null) {
            Field idField = Field.newDelimitedIdentifier(id);
            segment.fieldList.add(idField);
        }
        for (DatabaseColumn column : table.getAllColumns()) {
            Field field = columnToField(column);
            segment.fieldList.add(field);
        }
        return segment;
    }
View Full Code Here

        String name = column.getName();
        // TODO: In theory the replacement of illegal characters could result in two
        // fields ending up with the same name. Check for that.
        // TODO: Check the column's data type.
        String safeName = TextStructureNameUtils.replaceIllegalCharacters(name);
        Field field = new Field(-1, safeName, FieldDataType.String.name(), null, null, 1, false);
        return field;
    }
View Full Code Here

        }
    }

  private void defineFieldList(List<String> lines){
        for(String line:lines){
            Field field=new Field(line, this.isFixField());
            segment.insertField(field);
        }
  }
View Full Code Here

    String[]columns;
    for(String line : lines){
      // shall skip the first line if it is a list of column name
      columns=KongaStringUtils.split(line);
      Segment tmpSegment;
      Field tmpField;
      String fieldName=columns[3],defaultValue=columns[9],format=columns[10];
      int fieldId=Integer.parseInt(columns[1]),
        parentId=Integer.parseInt(columns[2]),
        sequence=KongaStringUtils.parseInt(columns[4], 0),
        varTypeId=KongaStringUtils.parseInt(columns[5], 0),
        startPos=KongaStringUtils.parseInt(columns[6], 0),
        endPos=KongaStringUtils.parseInt(columns[7], 0),
        required=KongaStringUtils.parseInt(columns[8], 0);
      String dataType=Field.Variable_TypeTab[varTypeId];

      if(dataType.equals("Segment")){ // define a Segment in the ComplexTextStructure
        tmpSegment=new Segment(fieldName);
        tmpSegment.setId(fieldId);
        if(parentId>0){
          Segment parent=getSegment(parentId);
          if(parent!=null){
            tmpSegment.setParentName(parent.getName());
          } else {
            tmpSegment.setParentName(c_rootName);
            parentId=1;
          }
        }
        if(required>1&&required<=4){
          tmpSegment.setOccurrence(Segment.oTypes.get(required-1));
        }
        addSegment(tmpSegment);
        if(tmpSegment.getName().equals(c_rootName)){
          if(!tmpSegment.getOccurrence().equals(Segment.oTypes.get(0))){
            tmpSegment.setOccurrence(Segment.oTypes.get(0));
          }
        }
        if(sequence!=0){ // Sequence!=0 for the case of alias segment
          tmpSegment.alias=getSegment(sequence);
          tmpSegment.fieldList=null;
        }
      } else { // define Field in a Segment
        tmpSegment=getSegment(parentId);
        if ( tmpSegment == null )
          throw new IllegalStateException("Failed to parse document definition line \""
              + line + "\" for text document \"" + getName() + "\". Parent_ID = "
              + Long.toString(parentId) + " was not found.");
        int length=endPos-startPos+1;
        tmpField=new Field(fieldId,fieldName,dataType,defaultValue,format,required,startPos,length,null, this.isFixField());
        tmpSegment.insertField(tmpField);
      }
    }
  }
View Full Code Here

        int id = 0;
            int idBeginPos = -1;
            int idEndPos = -1;
            for (Segment segment : segmentList) {
                Field idField = segment.findIdentField();
                if (idField != null) {
                    idBeginPos = idField.getBeginPosition();
                    idEndPos = idField.getEndPosition();
                    break;
                }
            }
        for (Segment segment : segmentList) {
          // Seems like segment ids are not updated correctly. We have to do it here.
View Full Code Here

TOP

Related Classes of org.jitterbit.integration.data.structure.text.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.