switch (firstToken.getType()) {
case Token.TYPE_START_NODE:
depthState.setName(idRegistry.get(firstToken.getId()));
break;
default:
throw new StreamException("Expected StartNode");
}
while (true) {
final Token nextToken = readToken();
switch (nextToken.getType()) {
case Token.TYPE_ATTRIBUTE:
depthState.addAttribute(idRegistry.get(nextToken.getId()), nextToken.getValue());
break;
case Token.TYPE_VALUE:
depthState.setValue(nextToken.getValue());
break;
case Token.TYPE_END_NODE:
depthState.setHasMoreChildren(false);
pushBack(nextToken);
return;
case Token.TYPE_START_NODE:
depthState.setHasMoreChildren(true);
pushBack(nextToken);
return;
default:
throw new StreamException("Unexpected token " + nextToken);
}
}
}