}
public static Struct getStruct(TreeGrid treeGrid, TreeNode rootNode,
Struct parent) {
Struct current = null;
if (Main.Sequence.equals(rootNode.getAttribute(Type))) {
current = new StructSequenceImpl(rootNode.getAttribute(Name));
((StructSequenceImpl) current).setDelimiter(handleEscape(rootNode
.getAttribute(Delimiter)));
((StructSequenceImpl) current).setLookahead(handleEscape(rootNode
.getAttribute(Lookahead)));
((StructSequenceImpl) current).setNegative(rootNode
.getAttributeAsBoolean(Not));
} else if (Main.Choice.equals(rootNode.getAttribute(Type))) {
current = new StructChoiceImpl(rootNode.getAttribute(Name));
} else {
current = new StructSimpleImpl(rootNode.getAttribute(Name));
((StructSimpleImpl) current).setSimplePattern(handleEscape(rootNode
.getAttribute(Regex)));
((StructSimpleImpl) current).setAllowedChars(handleEscape(rootNode
.getAttribute(AllowedChars)));
((StructSimpleImpl) current).setAllowedValues(handleEscape(rootNode
.getAttribute(AllowedValues)));
if (rootNode.getAttribute(minLength) != null)
((StructSimpleImpl) current).setMinLength(Integer
.parseInt(rootNode.getAttribute(minLength)));
if (rootNode.getAttribute(maxLength) != null)
((StructSimpleImpl) current).setMaxLength(Integer
.parseInt(rootNode.getAttribute(maxLength)));
}
if (parent != null) {
parent.addChild(current);
}
if (rootNode.getAttributeAsDouble(Min) != null)
current.setMinOccurrences(rootNode.getAttributeAsDouble(Min)
.intValue());
if (rootNode.getAttributeAsDouble(Max) != null)
current.setMaxOccurrences(rootNode.getAttributeAsDouble(Max)
.intValue());
current.setPrefix(handleEscape(rootNode.getAttribute(Prefix)));
current.setSuffix(handleEscape(rootNode.getAttribute(Suffix)));
for (TreeNode node : treeGrid.getTree().getChildren(rootNode)) {
getStruct(treeGrid, node, current);
}