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);
}
}
}