public void expect() throws IOException { throw new EmitterException("expecting nothing, but got " + event); } }
private void emit(ThreadContext context, Event event) { try { if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter"); emitter.emit(event); } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (EmitterException ee) { throw context.runtime.newRuntimeError(ee.toString()); } }
private void emit(ThreadContext context, Event event) { try { if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter"); emitter.emit(event); } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (EmitterException ee) { throw context.runtime.newRuntimeError(ee.toString()); } }
static String prepareAnchor(String anchor) { if (anchor.length() == 0) { throw new EmitterException("anchor must not be empty"); } if (!ANCHOR_FORMAT.matcher(anchor).matches()) { throw new EmitterException("invalid character in the anchor: " + anchor); } return anchor; }
private String prepareTagHandle(String handle) { if (handle.length() == 0) { throw new EmitterException("tag handle must not be empty"); } else if (handle.charAt(0) != '!' || handle.charAt(handle.length() - 1) != '!') { throw new EmitterException("tag handle must start and end with '!': " + handle); } else if (!"!".equals(handle) && !HANDLE_FORMAT.matcher(handle).matches()) { throw new EmitterException("invalid character in the tag handle: " + handle); } return handle; }
private String prepareTagPrefix(String prefix) { if (prefix.length() == 0) { throw new EmitterException("tag prefix must not be empty"); } StringBuilder chunks = new StringBuilder(); int start = 0; int end = 0; if (prefix.charAt(0) == '!') { end = 1; } while (end < prefix.length()) { end++; } if (start < end) { chunks.append(prefix.substring(start, end)); } return chunks.toString(); }
private String prepareTag(String tag) { if (tag.length() == 0) { throw new EmitterException("tag must not be empty"); } if ("!".equals(tag)) { return tag; } String handle = null; String suffix = tag; // shall the tag prefixes be sorted as in PyYAML? for (String prefix : tagPrefixes.keySet()) { if (tag.startsWith(prefix) && ("!".equals(prefix) || prefix.length() < tag.length())) { handle = prefix; } } if (handle != null) { suffix = tag.substring(handle.length()); handle = tagPrefixes.get(handle); } int end = suffix.length(); String suffixText = end > 0 ? suffix.substring(0, end) : ""; if (handle != null) { return handle + suffixText; } return "!<" + suffixText + ">"; }
public void expect() throws IOException { if (event instanceof StreamStartEvent) { writeStreamStart(); state = new ExpectFirstDocumentStart(); } else { throw new EmitterException("expected StreamStartEvent, but got " + event); } } }
private String prepareVersion(Version version) { if (version.major() != 1) { throw new EmitterException("unsupported YAML version: " + version); } return version.getRepresentation(); }
private void expectAlias() throws IOException { if (((NodeEvent) event).getAnchor() == null) { throw new EmitterException("anchor is not specified for alias"); } processAnchor("*"); state = states.pop(); }
public void expect() throws IOException { if (event instanceof DocumentEndEvent) { writeIndent(); if (((DocumentEndEvent) event).getExplicit()) { writeIndicator("...", true, false, false); writeIndent(); } flushStream(); state = new ExpectDocumentStart(false); } else { throw new EmitterException("expected DocumentEndEvent, but got " + event); } } }
state = new ExpectNothing(); } else { throw new EmitterException("expected DocumentStartEvent, but got " + event);
private void expectNode(boolean root, boolean mapping, boolean simpleKey) throws IOException { rootContext = root; mappingContext = mapping; simpleKeyContext = simpleKey; if (event instanceof AliasEvent) { expectAlias(); } else if (event instanceof ScalarEvent || event instanceof CollectionStartEvent) { processAnchor("&"); processTag(); if (event instanceof ScalarEvent) { expectScalar(); } else if (event instanceof SequenceStartEvent) { if (flowLevel != 0 || canonical || ((SequenceStartEvent) event).isFlow() || checkEmptySequence()) { expectFlowSequence(); } else { expectBlockSequence(); } } else {// MappingStartEvent if (flowLevel != 0 || canonical || ((MappingStartEvent) event).isFlow() || checkEmptyMapping()) { expectFlowMapping(); } else { expectBlockMapping(); } } } else { throw new EmitterException("expected NodeEvent, but got " + event); } }
throw new EmitterException("tag is not specified");
public void expect() throws IOException { throw new EmitterException("expecting nothing, but got " + event); } }
public void expect() throws IOException { throw new EmitterException("expecting nothing, but got " + event); } }
public void expect() throws IOException { throw new EmitterException("expecting nothing, but got " + event); } }
static String prepareAnchor(String anchor) { if (anchor.length() == 0) { throw new EmitterException("anchor must not be empty"); } if (!ANCHOR_FORMAT.matcher(anchor).matches()) { throw new EmitterException("invalid character in the anchor: " + anchor); } return anchor; }
static String prepareAnchor(String anchor) { if (anchor.length() == 0) { throw new EmitterException("anchor must not be empty"); } if (!ANCHOR_FORMAT.matcher(anchor).matches()) { throw new EmitterException("invalid character in the anchor: " + anchor); } return anchor; }
static String prepareAnchor(String anchor) { if (anchor.length() == 0) { throw new EmitterException("anchor must not be empty"); } if (!ANCHOR_FORMAT.matcher(anchor).matches()) { throw new EmitterException("invalid character in the anchor: " + anchor); } return anchor; }