All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterNode Maven / Gradle / Ivy

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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy