this.first = first;
}
public void expect() throws IOException {
if (event instanceof DocumentStartEvent) {
DocumentStartEvent ev = (DocumentStartEvent) event;
if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
writeIndicator("...", true, false, false);
writeIndent();
}
if (ev.getVersion() != null) {
String versionText = prepareVersion(ev.getVersion());
writeVersionDirective(versionText);
}
tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
if (ev.getTags() != null) {
Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
for (String handle : handles) {
String prefix = ev.getTags().get(handle);
tagPrefixes.put(prefix, handle);
String handleText = prepareTagHandle(handle);
String prefixText = prepareTagPrefix(prefix);
writeTagDirective(handleText, prefixText);
}
}
boolean implicit = first && !ev.getExplicit() && !canonical
&& ev.getVersion() == null
&& (ev.getTags() == null || ev.getTags().isEmpty())
&& !checkEmptyDocument();
if (!implicit) {
writeIndent();
writeIndicator("---", true, false, false);
if (canonical) {