public void close() throws IOException { if (closed == null) { throw new SerializerException("serializer is not opened"); } else if (!Boolean.TRUE.equals(closed)) { this.emitter.emit(new StreamEndEvent(null, null)); this.closed = Boolean.TRUE; } }
public void open() throws IOException { if (closed == null) { this.emitter.emit(new StreamStartEvent(null, null)); this.closed = Boolean.FALSE; } else if (Boolean.TRUE.equals(closed)) { throw new SerializerException("serializer is closed"); } else { throw new SerializerException("serializer is already opened"); } }
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.emitter.emit(new AliasEvent(tAlias, null, null)); } else { this.serializedNodes.add(node); ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple, scalarNode.getValue(), null, null, scalarNode.getStyle()); this.emitter.emit(event); break; case sequence: boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence, null, true)); this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(), implicitS, null, null, seqNode.getFlowStyle())); List<Node> list = seqNode.getValue(); serializeNode(item, node); this.emitter.emit(new SequenceEndEvent(null, null)); break; default:// instance of MappingNode Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true); boolean implicitM = node.getTag().equals(implicitTag); this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(), implicitM, null, null, ((CollectionNode) node).getFlowStyle())); MappingNode mnode = (MappingNode) node; this.emitter.emit(new MappingEndEvent(null, null));
public SldTransformContext mapping() throws IOException { yaml.emit( new MappingStartEvent(null, null, true, null, null, DumperOptions.FlowStyle.BLOCK)); return this; }
public SldTransformContext sequence() throws IOException { yaml.emit( new SequenceStartEvent( null, null, true, null, null, DumperOptions.FlowStyle.BLOCK)); return this; }
public SldTransformContext endStream() throws IOException { yaml.emit(new StreamEndEvent(null, null)); output.flush(); return this; }
public SldTransformContext endDocument() throws IOException { yaml.emit(new DocumentEndEvent(null, null, true)); return this; }
public SldTransformContext endSequence() throws IOException { yaml.emit(new SequenceEndEvent(null, null)); return this; }
public SldTransformContext stream() throws IOException { yaml.emit(new StreamStartEvent(null, null)); return this; }
public SldTransformContext endMapping() throws IOException { yaml.emit(new MappingEndEvent(null, null)); return this; }
public SldTransformContext document() throws IOException { yaml.emit(new DocumentStartEvent(null, null, false, null, null)); return this; }
public SldTransformContext scalar(String value) throws IOException { yaml.emit( new ScalarEvent( null, null, new ImplicitTuple(true, false), value, null, null, DumperOptions.ScalarStyle.PLAIN)); return this; }
@Override public void emit(Event event) throws IOException { if (event instanceof StreamStartEvent) { events.add(new Pair(event, stack++)); } else if (event instanceof StreamEndEvent) { events.add(new Pair(event, --stack)); } else if (event instanceof DocumentStartEvent) { events.add(new Pair(event, stack++)); } else if (event instanceof DocumentEndEvent) { events.add(new Pair(event, --stack)); } else if (event instanceof ScalarEvent) { events.add(new Pair(event, stack)); } else if (event instanceof MappingStartEvent) { events.add(new Pair(event, stack++)); } else if (event instanceof MappingEndEvent) { events.add(new Pair(event, --stack)); } else if (event instanceof SequenceStartEvent) { events.add(new Pair(event, stack++)); } else if (event instanceof SequenceEndEvent) { events.add(new Pair(event, --stack)); } delegate.emit(event); }
public SldTransformContext endStream() throws IOException { yaml.emit(new StreamEndEvent(null, null)); output.flush(); return this; }
public SldTransformContext document() throws IOException { yaml.emit(new DocumentStartEvent(null, null, false, null, null)); return this; }
public SldTransformContext endDocument() throws IOException { yaml.emit(new DocumentEndEvent(null, null, true)); return this; }
public SldTransformContext stream() throws IOException { yaml.emit(new StreamStartEvent(null, null)); return this; }
public SldTransformContext sequence() throws IOException { yaml.emit(new SequenceStartEvent(null, null, true, null, null, false)); return this; }
public SldTransformContext endMapping() throws IOException { yaml.emit(new MappingEndEvent(null, null)); return this; }