com.vladsch.flexmark.ext.gfm.tables.TableCell Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexmark-ext-gfm-tables Show documentation
Show all versions of flexmark-ext-gfm-tables Show documentation
flexmark-java extension for GFM tables using "|" pipes (GitHub Flavored Markdown)
The newest version!
package com.vladsch.flexmark.ext.gfm.tables;
import com.vladsch.flexmark.ast.DelimitedNode;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.sequence.BasedSequence;
/**
* Table cell of a {@link TableRow} containing inline nodes.
*/
public class TableCell extends Node implements DelimitedNode {
protected BasedSequence openingMarker = BasedSequence.NULL;
protected BasedSequence text = BasedSequence.NULL;
protected BasedSequence closingMarker = BasedSequence.NULL;
private boolean header;
private Alignment alignment;
@Override
public BasedSequence getOpeningMarker() {
return openingMarker;
}
@Override
public void setOpeningMarker(BasedSequence openingMarker) {
this.openingMarker = openingMarker;
}
@Override
public BasedSequence getText() {
return text;
}
@Override
public void setText(BasedSequence text) {
this.text = text;
}
@Override
public BasedSequence getClosingMarker() {
return closingMarker;
}
@Override
public void setClosingMarker(BasedSequence closingMarker) {
this.closingMarker = closingMarker;
}
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { openingMarker, text, closingMarker };
}
@Override
public void getAstExtra(StringBuilder out) {
if (alignment != null) out.append(" ").append(alignment);
if (header) out.append(" header");
delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text");
}
public TableCell() {
}
public TableCell(BasedSequence chars) {
super(chars);
}
/**
* @return whether the cell is a header or not
*/
public boolean isHeader() {
return header;
}
public void setHeader(boolean header) {
this.header = header;
}
/**
* @return the cell alignment
*/
public Alignment getAlignment() {
return alignment;
}
public void setAlignment(Alignment alignment) {
this.alignment = alignment;
}
/**
* How the cell is aligned horizontally.
*/
public enum Alignment {
LEFT, CENTER, RIGHT
}
}