public void serialize(Node node) throws IOException { if (closed == null) { throw new SerializerException("serializer is not opened"); } else if (closed) { throw new SerializerException("serializer is closed"); } this.emitter.emit(new DocumentStartEvent(null, null, this.explicitStart, this.useVersion, useTags)); anchorNode(node); if (explicitRoot != null) { node.setTag(explicitRoot); } serializeNode(node, null); this.emitter.emit(new DocumentEndEvent(null, null, this.explicitEnd)); this.serializedNodes.clear(); this.anchors.clear(); }
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); 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); boolean implicit = first && !ev.getExplicit() && !canonical && ev.getVersion() == null && (ev.getTags() == null || ev.getTags().isEmpty()) && !checkEmptyDocument(); if (!implicit) {
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); 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); boolean implicit = first && !ev.getExplicit() && !canonical && ev.getVersion() == null && (ev.getTags() == null || ev.getTags().isEmpty()) && !checkEmptyDocument(); if (!implicit) {
public YAMLGenerator(IOContext ctxt, int jsonFeatures, int yamlFeatures, ObjectCodec codec, Writer out, org.yaml.snakeyaml.DumperOptions.Version version) throws IOException { super(jsonFeatures, codec); _ioContext = ctxt; _formatFeatures = yamlFeatures; _writer = out; _outputOptions = buildDumperOptions(jsonFeatures, yamlFeatures, version); _emitter = new Emitter(_writer, _outputOptions); // should we start output now, or try to defer? _emitter.emit(new StreamStartEvent(null, null)); Map<String,String> noTags = Collections.emptyMap(); boolean startMarker = Feature.WRITE_DOC_START_MARKER.enabledIn(yamlFeatures); _emitter.emit(new DocumentStartEvent(null, null, startMarker, version, // for 1.10 was: ((version == null) ? null : version.getArray()), noTags)); }
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); 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); boolean implicit = first && !ev.getExplicit() && !canonical && ev.getVersion() == null && (ev.getTags() == null || ev.getTags().isEmpty()) && !checkEmptyDocument(); if (!implicit) {
public YAMLGenerator(IOContext ctxt, int jsonFeatures, int yamlFeatures, ObjectCodec codec, Writer out, org.yaml.snakeyaml.DumperOptions.Version version) throws IOException { super(jsonFeatures, codec); _ioContext = ctxt; _formatFeatures = yamlFeatures; _writer = out; _outputOptions = buildDumperOptions(jsonFeatures, yamlFeatures, version); _emitter = new Emitter(_writer, _outputOptions); // should we start output now, or try to defer? _emitter.emit(new StreamStartEvent(null, null)); Map<String,String> noTags = Collections.emptyMap(); boolean startMarker = Feature.WRITE_DOC_START_MARKER.enabledIn(yamlFeatures); _emitter.emit(new DocumentStartEvent(null, null, startMarker, version, // for 1.10 was: ((version == null) ? null : version.getArray()), noTags)); }
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); 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); boolean implicit = first && !ev.getExplicit() && !canonical && ev.getVersion() == null && (ev.getTags() == null || ev.getTags().isEmpty()) && !checkEmptyDocument(); if (!implicit) {
public Event produce() { // Parse an implicit document. if (!scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart, Token.ID.StreamEnd)) { directives = new VersionTagsTuple(null, DEFAULT_TAGS); Token token = scanner.peekToken(); Mark startMark = token.getStartMark(); Mark endMark = startMark; Event event = new DocumentStartEvent(startMark, endMark, false, null, null); // Prepare the next state. states.push(new ParseDocumentEnd()); state = new ParseBlockNode(); return event; } else { Production p = new ParseDocumentStart(); return p.produce(); } } }
private void handleDocumentStart(ThreadContext context, DocumentStartEvent dse, boolean tainted, IRubyObject handler) { Ruby runtime = context.runtime; DumperOptions.Version _version = dse.getVersion(); Integer[] versionInts = _version == null ? null : _version.getArray(); IRubyObject version = versionInts == null ? RubyArray.newArray(runtime) : RubyArray.newArray(runtime, runtime.newFixnum(versionInts[0]), runtime.newFixnum(versionInts[1])); Map<String, String> tagsMap = dse.getTags(); RubyArray tags = RubyArray.newArray(runtime); if (tagsMap != null && tagsMap.size() > 0) { for (Map.Entry<String, String> tag : tagsMap.entrySet()) { IRubyObject key = stringFor(runtime, tag.getKey(), tainted); IRubyObject value = stringFor(runtime, tag.getValue(), tainted); tags.append(RubyArray.newArray(runtime, key, value)); } } IRubyObject notExplicit = runtime.newBoolean(!dse.getExplicit()); invoke(context, handler, "start_document", version, tags, notExplicit); }
public SldTransformContext document() throws IOException { yaml.emit(new DocumentStartEvent(null, null, false, null, null)); return this; }
private void handleDocumentStart(ThreadContext context, DocumentStartEvent dse, boolean tainted, IRubyObject handler) { Ruby runtime = context.runtime; DumperOptions.Version _version = dse.getVersion(); Integer[] versionInts = _version == null ? null : _version.getArray(); IRubyObject version = versionInts == null ? RubyArray.newArray(runtime) : RubyArray.newArray(runtime, runtime.newFixnum(versionInts[0]), runtime.newFixnum(versionInts[1])); Map<String, String> tagsMap = dse.getTags(); RubyArray tags = RubyArray.newArray(runtime); if (tagsMap != null && tagsMap.size() > 0) { for (Map.Entry<String, String> tag : tagsMap.entrySet()) { IRubyObject key = stringFor(runtime, tag.getKey(), tainted); IRubyObject value = stringFor(runtime, tag.getValue(), tainted); tags.append(RubyArray.newArray(runtime, key, value)); } } IRubyObject notExplicit = runtime.newBoolean(!dse.getExplicit()); invoke(context, handler, "start_document", version, tags, notExplicit); }
event = new DocumentStartEvent(startMark, endMark, true, tuple.getVersion(), tuple.getTags()); states.push(new ParseDocumentEnd());
public SldTransformContext document() throws IOException { yaml.emit(new DocumentStartEvent(null, null, false, null, null)); return this; }
public void newDocument() throws IOException { _emitter.emit(new DocumentEndEvent(null, null, false)); _emitter.emit(new DocumentStartEvent(null, null, true, version, Collections.emptyMap())); }
public void serialize(Node node) throws IOException { if (closed == null) { throw new SerializerException("serializer is not opened"); } else if (closed) { throw new SerializerException("serializer is closed"); } this.emitter.emit(new DocumentStartEvent(null, null, this.explicitStart, this.useVersion, useTags)); anchorNode(node); if (explicitRoot != null) { node.setTag(explicitRoot); } serializeNode(node, null); this.emitter.emit(new DocumentEndEvent(null, null, this.explicitEnd)); this.serializedNodes.clear(); this.anchors.clear(); }
public void serialize(Node node) throws IOException { if (closed == null) { throw new SerializerException("serializer is not opened"); } else if (closed) { throw new SerializerException("serializer is closed"); } this.emitter.emit(new DocumentStartEvent(null, null, this.explicitStart, this.useVersion, useTags)); anchorNode(node); if (explicitRoot != null) { node.setTag(explicitRoot); } serializeNode(node, null); this.emitter.emit(new DocumentEndEvent(null, null, this.explicitEnd)); this.serializedNodes.clear(); this.anchors.clear(); }
public YAMLGenerator(IOContext ctxt, int jsonFeatures, int yamlFeatures, ObjectCodec codec, Writer out, org.yaml.snakeyaml.DumperOptions.Version version) throws IOException { super(jsonFeatures, codec); _ioContext = ctxt; _formatFeatures = yamlFeatures; _writer = out; _outputOptions = buildDumperOptions(jsonFeatures, yamlFeatures, version); _emitter = new Emitter(_writer, _outputOptions); // should we start output now, or try to defer? _emitter.emit(new StreamStartEvent(null, null)); Map<String,String> noTags = Collections.emptyMap(); boolean startMarker = Feature.WRITE_DOC_START_MARKER.enabledIn(yamlFeatures); _emitter.emit(new DocumentStartEvent(null, null, startMarker, version, // for 1.10 was: ((version == null) ? null : version.getArray()), noTags)); }
public YAMLGenerator(ObjectWriteContext writeContext, IOContext ioCtxt, int streamWriteFeatures, int yamlFeatures, Writer out, org.yaml.snakeyaml.DumperOptions.Version version) throws IOException { super(writeContext, streamWriteFeatures); _ioContext = ioCtxt; _formatWriteFeatures = yamlFeatures; _writer = out; _outputOptions = buildDumperOptions(streamWriteFeatures, yamlFeatures, version); _emitter = new Emitter(_writer, _outputOptions); // should we start output now, or try to defer? _emitter.emit(new StreamStartEvent(null, null)); Map<String,String> noTags = Collections.emptyMap(); boolean startMarker = Feature.WRITE_DOC_START_MARKER.enabledIn(yamlFeatures); _emitter.emit(new DocumentStartEvent(null, null, startMarker, version, // for 1.10 was: ((version == null) ? null : version.getArray()), noTags)); }
public void serialize(Node node) throws IOException { if (closed == null) { throw new SerializerException("serializer is not opened"); } else if (closed) { throw new SerializerException("serializer is closed"); } this.emitter.emit(new DocumentStartEvent(null, null, this.explicitStart, this.useVersion, useTags)); anchorNode(node); if (explicitRoot != null) { node.setTag(explicitRoot); } serializeNode(node, null); this.emitter.emit(new DocumentEndEvent(null, null, this.explicitEnd)); this.serializedNodes.clear(); this.anchors.clear(); this.lastAnchorId = 0; }
public Event produce() { // Parse an implicit document. if (!scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart, Token.ID.StreamEnd)) { directives = new VersionTagsTuple(null, DEFAULT_TAGS); Token token = scanner.peekToken(); Mark startMark = token.getStartMark(); Mark endMark = startMark; Event event = new DocumentStartEvent(startMark, endMark, false, null, null); // Prepare the next state. states.push(new ParseDocumentEnd()); state = new ParseBlockNode(); return event; } else { Production p = new ParseDocumentStart(); return p.produce(); } } }