org.yaml.snakeyaml.events.CollectionStartEvent Java Examples
The following examples show how to use
org.yaml.snakeyaml.events.CollectionStartEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Emitter.java From orion.server with Eclipse Public License 1.0 | 6 votes |
private boolean needEvents(int count) { int level = 0; Iterator<Event> iter = events.iterator(); iter.next(); while (iter.hasNext()) { Event event = iter.next(); if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) { level++; } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) { level--; } else if (event instanceof StreamEndEvent) { level = -1; } if (level < 0) { return false; } } return events.size() < count + 1; }
Example #2
Source File: Emitter.java From snake-yaml with Apache License 2.0 | 6 votes |
private boolean needEvents(int count) { int level = 0; Iterator<Event> iter = events.iterator(); iter.next(); while (iter.hasNext()) { Event event = iter.next(); if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) { level++; } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) { level--; } else if (event instanceof StreamEndEvent) { level = -1; } if (level < 0) { return false; } } return events.size() < count + 1; }
Example #3
Source File: IndexYamlAbsoluteUrlRewriterSupport.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
protected void updateUrls(final InputStream is, final OutputStream os) { try (Reader reader = new InputStreamReader(is); Writer writer = new OutputStreamWriter(os)) { Yaml yaml = new Yaml(); Emitter emitter = new Emitter(writer, new DumperOptions()); boolean rewrite = false; for (Event event : yaml.parse(reader)) { if (event instanceof ScalarEvent) { ScalarEvent scalarEvent = (ScalarEvent) event; if (rewrite) { event = maybeSetAbsoluteUrlAsRelative(scalarEvent); } else if (URLS.equals(scalarEvent.getValue())) { rewrite = true; } } else if (event instanceof CollectionStartEvent) { // NOOP } else if (event instanceof CollectionEndEvent) { rewrite = false; } emitter.emit(event); } } catch (IOException ex) { log.error("Error rewriting urls in index.yaml", ex); } }
Example #4
Source File: Emitter.java From orion.server with Eclipse Public License 1.0 | 5 votes |
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).getFlowStyle() || checkEmptySequence()) { expectFlowSequence(); } else { expectBlockSequence(); } } else {// MappingStartEvent if (flowLevel != 0 || canonical || ((MappingStartEvent) event).getFlowStyle() || checkEmptyMapping()) { expectFlowMapping(); } else { expectBlockMapping(); } } } else { throw new EmitterException("expected NodeEvent, but got " + event); } }
Example #5
Source File: Emitter.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private boolean checkSimpleKey() { int length = 0; if (event instanceof NodeEvent && ((NodeEvent) event).getAnchor() != null) { if (preparedAnchor == null) { preparedAnchor = prepareAnchor(((NodeEvent) event).getAnchor()); } length += preparedAnchor.length(); } String tag = null; if (event instanceof ScalarEvent) { tag = ((ScalarEvent) event).getTag(); } else if (event instanceof CollectionStartEvent) { tag = ((CollectionStartEvent) event).getTag(); } if (tag != null) { if (preparedTag == null) { preparedTag = prepareTag(tag); } length += preparedTag.length(); } if (event instanceof ScalarEvent) { if (analysis == null) { analysis = analyzeScalar(((ScalarEvent) event).getValue()); } length += analysis.scalar.length(); } return (length < 128 && (event instanceof AliasEvent || (event instanceof ScalarEvent && !analysis.empty && !analysis.multiline) || checkEmptySequence() || checkEmptyMapping())); }
Example #6
Source File: Emitter.java From snake-yaml with Apache License 2.0 | 5 votes |
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).getFlowStyle() || checkEmptySequence()) { expectFlowSequence(); } else { expectBlockSequence(); } } else {// MappingStartEvent if (flowLevel != 0 || canonical || ((MappingStartEvent) event).getFlowStyle() || checkEmptyMapping()) { expectFlowMapping(); } else { expectBlockMapping(); } } } else { throw new EmitterException("expected NodeEvent, but got " + event); } }
Example #7
Source File: Emitter.java From snake-yaml with Apache License 2.0 | 5 votes |
private boolean checkSimpleKey() { int length = 0; if (event instanceof NodeEvent && ((NodeEvent) event).getAnchor() != null) { if (preparedAnchor == null) { preparedAnchor = prepareAnchor(((NodeEvent) event).getAnchor()); } length += preparedAnchor.length(); } String tag = null; if (event instanceof ScalarEvent) { tag = ((ScalarEvent) event).getTag(); } else if (event instanceof CollectionStartEvent) { tag = ((CollectionStartEvent) event).getTag(); } if (tag != null) { if (preparedTag == null) { preparedTag = prepareTag(tag); } length += preparedTag.length(); } if (event instanceof ScalarEvent) { if (analysis == null) { analysis = analyzeScalar(((ScalarEvent) event).getValue()); } length += analysis.scalar.length(); } return length < 128 && (event instanceof AliasEvent || (event instanceof ScalarEvent && !analysis.empty && !analysis.multiline) || checkEmptySequence() || checkEmptyMapping()); }
Example #8
Source File: PyStructureTest.java From snake-yaml with Apache License 2.0 | 5 votes |
private void compareEvents(List<Event> events1, List<Event> events2, boolean full) { assertEquals(events1.size(), events2.size()); Iterator<Event> iter1 = events1.iterator(); Iterator<Event> iter2 = events2.iterator(); while (iter1.hasNext()) { Event event1 = iter1.next(); Event event2 = iter2.next(); assertEquals(event1.getClass(), event2.getClass()); if (event1 instanceof AliasEvent && full) { assertEquals(((AliasEvent) event1).getAnchor(), ((AliasEvent) event2).getAnchor()); } if (event1 instanceof CollectionStartEvent) { String tag1 = ((CollectionStartEvent) event1).getTag(); String tag2 = ((CollectionStartEvent) event1).getTag(); if (tag1 != null && !"!".equals(tag1) && tag2 != null && !"!".equals(tag1)) { assertEquals(tag1, tag2); } } if (event1 instanceof ScalarEvent) { ScalarEvent scalar1 = (ScalarEvent) event1; ScalarEvent scalar2 = (ScalarEvent) event2; if (scalar1.getImplicit().bothFalse() && scalar2.getImplicit().bothFalse()) { assertEquals(scalar1.getTag(), scalar2.getTag()); } assertEquals(scalar1.getValue(), scalar2.getValue()); } } }
Example #9
Source File: Emitter.java From Diorite with MIT License | 5 votes |
private boolean needEvents(int count) { int level = 0; Iterator<Event> iter = this.events.iterator(); iter.next(); while (iter.hasNext()) { Event event = iter.next(); if ((event instanceof DocumentStartEvent) || (event instanceof CollectionStartEvent)) { level++; } else if ((event instanceof DocumentEndEvent) || (event instanceof CollectionEndEvent)) { level--; } else if (event instanceof StreamEndEvent) { level = - 1; } if (level < 0) { return false; } } return this.events.size() < (count + 1); }
Example #10
Source File: Emitter.java From Diorite with MIT License | 5 votes |
boolean checkSimpleKey() { int length = 0; if ((this.event instanceof NodeEvent) && (((NodeEvent) this.event).getAnchor() != null)) { if (this.preparedAnchor == null) { this.preparedAnchor = prepareAnchor(((NodeEvent) this.event).getAnchor()); } length += this.preparedAnchor.length(); } String tag = null; if (this.event instanceof ScalarEvent) { tag = ((ScalarEvent) this.event).getTag(); } else if (this.event instanceof CollectionStartEvent) { tag = ((CollectionStartEvent) this.event).getTag(); } if (tag != null) { if (this.preparedTag == null) { this.preparedTag = this.prepareTag(tag); } length += this.preparedTag.length(); } if (this.event instanceof ScalarEvent) { if (this.analysis == null) { this.analysis = this.analyzeScalar(((ScalarEvent) this.event).getValue()); } length += this.analysis.scalar.length(); } return (length < SMALL_LENGTH) && ((this.event instanceof AliasEvent) || ((this.event instanceof ScalarEvent) && ! ((this.analysis == null) || this.analysis.empty) && ! this.analysis.multiline) || this.checkEmptySequence() || this.checkEmptyMapping()); }
Example #11
Source File: Emitter.java From Diorite with MIT License | 4 votes |
void expectNode(boolean root, boolean mapping, boolean simpleKey, @Nullable Integer lastIndent) throws IOException { this.rootContext = root; this.mappingContext = mapping; this.simpleKeyContext = simpleKey; if (this.event instanceof AliasEvent) { this.expectAlias(); } else if ((this.event instanceof ScalarEvent) || (this.event instanceof CollectionStartEvent)) { this.processAnchor("&"); this.processTag(); if (this.event instanceof ScalarEvent) { this.expectScalar(lastIndent); } else if (this.event instanceof SequenceStartEvent) { if ((this.flowLevel != 0) || this.canonical || ((SequenceStartEvent) this.event).getFlowStyle() || this.checkEmptySequence()) { this.expectFlowSequence(); } else { this.expectBlockSequence(); } } else {// MappingStartEvent if ((this.flowLevel != 0) || this.canonical || ((MappingStartEvent) this.event).getFlowStyle() || this.checkEmptyMapping()) { this.expectFlowMapping(); } else { this.expectBlockMapping(); } } } else { throw new EmitterException("expected NodeEvent, but got " + this.event); } }