com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexmark-ext-yaml-front-matter Show documentation
Show all versions of flexmark-ext-yaml-front-matter Show documentation
flexmark-java extension for YAML front matter
The newest version!
package com.vladsch.flexmark.ext.yaml.front.matter;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.sequence.BasedSequence;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
public class YamlFrontMatterNode extends Node {
private BasedSequence key;
// private List values;
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] {key};
}
public YamlFrontMatterNode(BasedSequence key, List values) {
this.key = key;
// this.values = values;
for (BasedSequence value : values) {
appendChild(new YamlFrontMatterValue(value));
}
}
public String getKey() {
return key.toString();
}
public BasedSequence getKeySequence() {
return key;
}
public void setKey(BasedSequence key) {
this.key = key;
}
public List getValues() {
List list = new ArrayList<>();
Node child = getFirstChild();
while (child != null) {
list.add(child.getChars().toString());
child = child.getNext();
}
return list;
}
public List getValuesSequences() {
List list = new ArrayList<>();
Node child = getFirstChild();
while (child != null) {
list.add(child.getChars());
child = child.getNext();
}
return list;
}
}