@SuppressWarnings("unchecked")
private VersionTagsTuple processDirectives() {
Version yamlVersion = null;
HashMap<String, String> tagHandles = new HashMap<String, String>();
while (scanner.checkToken(Token.ID.Directive)) {
@SuppressWarnings("rawtypes")
DirectiveToken token = (DirectiveToken) scanner.getToken();
if (token.getName().equals("YAML")) {
if (yamlVersion != null) {
throw new ParserException(null, null, "found duplicate YAML directive",
token.getStartMark());
}
List<Integer> value = (List<Integer>) token.getValue();
Integer major = value.get(0);
if (major != 1) {
throw new ParserException(null, null,
"found incompatible YAML document (version 1.* is required)",
token.getStartMark());
}
Integer minor = value.get(1);
switch (minor) {
case 0:
yamlVersion = Version.V1_0;
break;
default:
yamlVersion = Version.V1_1;
break;
}
} else if (token.getName().equals("TAG")) {
List<String> value = (List<String>) token.getValue();
String handle = value.get(0);
String prefix = value.get(1);
if (tagHandles.containsKey(handle)) {
throw new ParserException(null, null, "duplicate tag handle " + handle,
token.getStartMark());
}
tagHandles.put(handle, prefix);
}
}
if (yamlVersion != null || !tagHandles.isEmpty()) {