Documentation generator has been moved in a dedicated component
This commit is contained in:
parent
b5e7f8e685
commit
86b4e14de4
|
@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for Information System Model
|
||||
|
||||
## [v5.0.1-SNAPSHOT]
|
||||
|
||||
- Added class Discovery to make new model discovery easier
|
||||
|
||||
|
||||
## [v5.0.0]
|
||||
|
||||
- Added the possibility to get AccessType from Type definition [#20695]
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>information-system-model</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
<name>Information System Model</name>
|
||||
<description>Information System Model is the reference model of the gCube Information System</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=PropagationConstraintImpl.class)
|
||||
@TypeMetadata(name = PropagationConstraint.NAME, description = "This class provides propation constraint for Relation", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = PropagationConstraint.NAME, description = "This class provides propagation constraint for Relation", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface PropagationConstraint extends Property {
|
||||
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.utils.discovery.Discovery;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.Section;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.Section.SectionType;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Cell;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Row;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.RowType;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class DocumentationGenerator {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
|
||||
|
||||
protected File baseDirectory;
|
||||
|
||||
public DocumentationGenerator(File baseDirectory) {
|
||||
this.baseDirectory = baseDirectory;
|
||||
}
|
||||
|
||||
/*
|
||||
* E.g. GCubeProperty extends Property
|
||||
*/
|
||||
protected Row getTypeDeclaration(Type type) {
|
||||
Row row = new Row(RowType.NORMAL);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("**");
|
||||
stringBuffer.append(type.getName());
|
||||
stringBuffer.append("**");
|
||||
stringBuffer.append(" *extends* ");
|
||||
boolean first = true;
|
||||
for(String superClass : type.getSuperClasses()) {
|
||||
if(!first) {
|
||||
stringBuffer.append(", ");
|
||||
}else {
|
||||
first = false;
|
||||
}
|
||||
stringBuffer.append("**");
|
||||
stringBuffer.append(superClass);
|
||||
stringBuffer.append("**");
|
||||
}
|
||||
Cell cell = new Cell();
|
||||
cell.setText(stringBuffer.toString());
|
||||
row.appendCell(cell);
|
||||
row.appendCell(cell);
|
||||
row.appendCell(cell);
|
||||
row.appendCell(cell);
|
||||
return row;
|
||||
}
|
||||
|
||||
public Row getPropertyHeadingRow() {
|
||||
Row row = new Row(RowType.HEADING);
|
||||
Cell name = new Cell();
|
||||
name.setText("Name");
|
||||
row.appendCell(name);
|
||||
Cell type = new Cell();
|
||||
type.setText("Type");
|
||||
row.appendCell(type);
|
||||
Cell attributes = new Cell();
|
||||
attributes.setText("Attributes");
|
||||
row.appendCell(attributes);
|
||||
Cell description = new Cell();
|
||||
description.setText("Description");
|
||||
row.appendCell(description);
|
||||
return row;
|
||||
}
|
||||
|
||||
public StringBuffer generatePropertySection(Type type) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("\n");
|
||||
String name = type.getName();
|
||||
Section section = new Section();
|
||||
stringBuffer.append(section.generateSection(SectionType.HEADING_3, name));
|
||||
stringBuffer.append(type.getDescription());
|
||||
stringBuffer.append("\n");
|
||||
|
||||
Table table = new Table();
|
||||
table.appendRow(getTypeDeclaration(type));
|
||||
table.appendRow(getPropertyHeadingRow());
|
||||
stringBuffer.append(table.generateTable());
|
||||
|
||||
|
||||
logger.info(stringBuffer.toString());
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public void generate() throws Exception {
|
||||
|
||||
DocumentationSchemaAction schemaAction = new DocumentationSchemaAction();
|
||||
Discovery.discover(schemaAction);
|
||||
|
||||
Map<String, Type> propertyElements = schemaAction.getPropertyElement();
|
||||
Set<String> propertyNames = propertyElements.keySet();
|
||||
for(String name : propertyNames) {
|
||||
Type type = propertyElements.get(name);
|
||||
|
||||
}
|
||||
|
||||
Map<String, Type> relationElements = schemaAction.getRelationElements();
|
||||
Set<String> relationNames = relationElements.keySet();
|
||||
for(String name : relationNames) {
|
||||
Type type = propertyElements.get(name);
|
||||
|
||||
}
|
||||
|
||||
Map<String, Type> entityElements = schemaAction.getEntityElement();
|
||||
Set<String> entityNames = entityElements.keySet();
|
||||
for(String name : entityNames) {
|
||||
Type type = propertyElements.get(name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.utils.discovery.SchemaAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class DocumentationSchemaAction implements SchemaAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocumentationSchemaAction.class);
|
||||
|
||||
protected Package packageToInclude;
|
||||
|
||||
protected Map<String, Type> relationElements;
|
||||
protected Map<String, Type> propertyElements;
|
||||
protected Map<String, Type> entityElements;
|
||||
|
||||
public DocumentationSchemaAction() {
|
||||
this.relationElements = new HashMap<>();
|
||||
this.propertyElements = new HashMap<>();
|
||||
this.entityElements = new HashMap<>();
|
||||
}
|
||||
|
||||
public DocumentationSchemaAction(Package pkg) {
|
||||
this();
|
||||
this.packageToInclude = pkg;
|
||||
}
|
||||
|
||||
public Map<String, Type> getRelationElements() {
|
||||
return relationElements;
|
||||
}
|
||||
|
||||
public Map<String, Type> getPropertyElement() {
|
||||
return propertyElements;
|
||||
}
|
||||
|
||||
public Map<String, Type> getEntityElement() {
|
||||
return entityElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(
|
||||
Class<R> r) throws Exception {
|
||||
if(r.isAssignableFrom(Type.class)) {
|
||||
return;
|
||||
}
|
||||
if(packageToInclude!=null && !r.getPackage().getName().startsWith(packageToInclude.getName())) {
|
||||
return;
|
||||
}
|
||||
Type type = TypeMapper.createTypeDefinition(r);
|
||||
String name = type.getName();
|
||||
logger.debug("Found {} {}", RelationElement.NAME, name);
|
||||
relationElements.put(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <P extends PropertyElement> void managePropertyClass(Class<P> p) throws Exception {
|
||||
if(p.isAssignableFrom(Type.class)) {
|
||||
return;
|
||||
}
|
||||
if(packageToInclude!=null && !p.getPackage().getName().startsWith(packageToInclude.getName())) {
|
||||
return;
|
||||
}
|
||||
Type type = TypeMapper.createTypeDefinition(p);
|
||||
String name = type.getName();
|
||||
logger.debug("Found {} {}", PropertyElement.NAME, name);
|
||||
propertyElements.put(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends EntityElement> void manageEntityClass(Class<E> e) throws Exception {
|
||||
if(e.isAssignableFrom(Type.class)) {
|
||||
return;
|
||||
}
|
||||
if(packageToInclude!=null && !e.getPackage().getName().startsWith(packageToInclude.getName())) {
|
||||
return;
|
||||
}
|
||||
Type type = TypeMapper.createTypeDefinition(e);
|
||||
String name = type.getName();
|
||||
logger.debug("Found {} {}", EntityElement.NAME, name);
|
||||
entityElements.put(name,type);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation.rst;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Section {
|
||||
|
||||
public enum SectionType {
|
||||
HEADING_1(true, "*"),
|
||||
HEADING_2(false, "="),
|
||||
HEADING_3(false, "-"),
|
||||
HEADING_4(false, "^");
|
||||
|
||||
boolean both;
|
||||
String separator;
|
||||
|
||||
private SectionType(boolean both, String separator) {
|
||||
this.both = both;
|
||||
this.separator = separator;
|
||||
}
|
||||
}
|
||||
|
||||
protected StringBuffer getSectionSeparation(String separator, int lenght) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for(int i=0; i<lenght; i++) {
|
||||
stringBuffer.append(separator);
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public StringBuffer generateSection(SectionType sectionType, String sectionTitle) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int lenght = sectionTitle.length();
|
||||
if(sectionType.both) {
|
||||
stringBuffer.append(getSectionSeparation(sectionType.separator, lenght));
|
||||
stringBuffer.append("\n");
|
||||
}
|
||||
stringBuffer.append(sectionTitle);
|
||||
stringBuffer.append("\n");
|
||||
stringBuffer.append(getSectionSeparation(sectionType.separator, lenght));
|
||||
stringBuffer.append("\n\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation.rst.table;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Cell {
|
||||
|
||||
private Row row;
|
||||
|
||||
private int size;
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* Cell Position in the row
|
||||
*/
|
||||
private Integer cellPosition;
|
||||
|
||||
public Cell() {
|
||||
this.size = 0;
|
||||
this.text = "";
|
||||
this.row = null;
|
||||
this.cellPosition = null;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
this.size = text.length();
|
||||
if(row!=null) {
|
||||
this.row.update(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRow(Row row) {
|
||||
if(this.row==null) {
|
||||
this.row = row;
|
||||
}
|
||||
}
|
||||
|
||||
protected Integer getCellPosition() {
|
||||
return cellPosition;
|
||||
}
|
||||
|
||||
protected void setPosition(Integer cellPosition) {
|
||||
if(this.cellPosition==null) {
|
||||
this.cellPosition = cellPosition;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation.rst.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Row {
|
||||
|
||||
private RowType rowType;
|
||||
|
||||
private Table table;
|
||||
/**
|
||||
* Row Position in the table
|
||||
*/
|
||||
private Integer rowPosition;
|
||||
|
||||
private List<Cell> cells;
|
||||
private List<Integer> cellSizes;
|
||||
|
||||
public Row() {
|
||||
this.rowType = RowType.NORMAL;
|
||||
this.cells = new ArrayList<>();
|
||||
this.cellSizes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Row(RowType rowType) {
|
||||
this.rowType = rowType;
|
||||
this.cells = new ArrayList<>();
|
||||
this.cellSizes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setRowType(RowType rowType) {
|
||||
this.rowType = rowType;
|
||||
}
|
||||
|
||||
public RowType getRowType() {
|
||||
return rowType;
|
||||
}
|
||||
|
||||
// public void update() {
|
||||
// for(int position=0; position<cells.size(); position++) {
|
||||
// Integer size = cells.get(position).getSize();
|
||||
// if(position>0 && cells.get(position)==cells.get(position-1)) {
|
||||
// size=null;
|
||||
// }
|
||||
// cellSizes.add(position, size);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void update(Cell cell) {
|
||||
Integer size = cell.getSize();
|
||||
int cellPosition = cell.getCellPosition();
|
||||
if(cellSizes.size()-1<cellPosition) {
|
||||
cellSizes.add(cellPosition, size);
|
||||
}else {
|
||||
cellSizes.set(cellPosition, size);
|
||||
}
|
||||
if(table!=null) {
|
||||
table.updateMaxSizePerCell(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void appendCell(Cell cell) {
|
||||
int position = cells.size();
|
||||
setCell(position, cell);
|
||||
}
|
||||
|
||||
protected void setCell(int position, Cell cell) {
|
||||
if(position>cells.size()) {
|
||||
throw new RuntimeException("You can't add the cell in position " + position);
|
||||
}
|
||||
cells.add(position, cell);
|
||||
if(position==0 || cell!=cells.get(position-1)) {
|
||||
cell.setRow(this);
|
||||
cell.setPosition(position);
|
||||
update(cell);
|
||||
}else {
|
||||
cellSizes.add(position, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Cell> getCells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
public Cell getCell(int position) {
|
||||
try {
|
||||
return cells.get(position);
|
||||
}catch (IndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getCellSizes() {
|
||||
return cellSizes;
|
||||
}
|
||||
|
||||
public Integer getCellSize(int position) {
|
||||
try {
|
||||
return cellSizes.get(position);
|
||||
}catch (IndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTable(Table table) {
|
||||
if(this.table==null) {
|
||||
this.table = table;
|
||||
}
|
||||
}
|
||||
|
||||
protected Integer getRowPosition() {
|
||||
return rowPosition;
|
||||
}
|
||||
|
||||
protected void setRowPosition(Integer rowPosition) {
|
||||
this.rowPosition = rowPosition;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation.rst.table;
|
||||
|
||||
public enum RowType {
|
||||
HEADING(Table.ROW_SEPARATOR_HEADING),
|
||||
NORMAL(Table.ROW_SEPARATOR);
|
||||
|
||||
protected String rowSeparator;
|
||||
|
||||
private RowType(String rowSeparator) {
|
||||
this.rowSeparator = rowSeparator;
|
||||
}
|
||||
|
||||
public String getRowSeparator() {
|
||||
return rowSeparator;
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.documentation.rst.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Table {
|
||||
|
||||
public static final String COLUMN_SEPARATOR = "+";
|
||||
public static final String ROW_SEPARATOR = "-";
|
||||
public static final String ROW_SEPARATOR_HEADING = "=";
|
||||
|
||||
private List<Row> rows;
|
||||
private List<Integer> maxSizePerCell;
|
||||
|
||||
public Table() {
|
||||
rows = new ArrayList<>();
|
||||
maxSizePerCell = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected void updateMaxSizePerCell(Row row) {
|
||||
List<Integer> cellSizes = row.getCellSizes();
|
||||
for(int i=0; i<cellSizes.size(); i++) {
|
||||
Integer cellSize = cellSizes.get(i);
|
||||
cellSize = cellSize!=null ? cellSize : 0;
|
||||
cellSize += 2; // We need to consider one space before and one after to calculate total column size
|
||||
Integer maxSize = 0;
|
||||
try {
|
||||
maxSize = maxSizePerCell.get(i);
|
||||
if(cellSize>=maxSize) {
|
||||
maxSizePerCell.set(i, cellSize);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
maxSizePerCell.add(i, cellSize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void appendRow(Row row) {
|
||||
rows.add(row);
|
||||
row.setRowPosition(rows.size()-1);
|
||||
row.setTable(this);
|
||||
updateMaxSizePerCell(row);
|
||||
}
|
||||
|
||||
private StringBuffer addRowSeparator(String separator) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("\t");
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
for(int i=0; i<maxSizePerCell.size(); i++) {
|
||||
for(int j=0; j<maxSizePerCell.get(i); j++) {
|
||||
stringBuffer.append(separator);
|
||||
}
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
}
|
||||
stringBuffer.append("\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
private StringBuffer addRowSeparator(Row row, String separator) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("\t");
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
for(int i=0; i<maxSizePerCell.size(); i++) {
|
||||
for(int j=0; j<maxSizePerCell.get(i); j++) {
|
||||
stringBuffer.append(separator);
|
||||
}
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
}
|
||||
stringBuffer.append("\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
private StringBuffer addRow(Row row) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("\t");
|
||||
for(int i=0; i<maxSizePerCell.size(); i++) {
|
||||
Cell cell = row.getCell(i);
|
||||
int sizeTosatisfy = maxSizePerCell.get(i);
|
||||
if(i>0 && cell==row.getCell(i-1)) {
|
||||
for(int j=0; j<sizeTosatisfy+1; j++) {
|
||||
stringBuffer.append(" ");
|
||||
}
|
||||
}else {
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
int remaining = sizeTosatisfy - cell.getSize();
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(cell.getText());
|
||||
for(int j=0; j<remaining-1; j++) {
|
||||
stringBuffer.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuffer.append(COLUMN_SEPARATOR);
|
||||
stringBuffer.append("\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public StringBuffer generateTable() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("\n\n");
|
||||
stringBuffer.append(".. table::");
|
||||
stringBuffer.append("\n\n");
|
||||
stringBuffer.append(addRowSeparator(RowType.NORMAL.getRowSeparator()));
|
||||
for(Row row : rows) {
|
||||
stringBuffer.append(addRow(row));
|
||||
stringBuffer.append(addRowSeparator(row, row.getRowType().getRowSeparator()));
|
||||
}
|
||||
stringBuffer.append("\n\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
package org.gcube.informationsystem.utils.discovery.documentation.table;
|
||||
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Cell;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Row;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.RowType;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class TableTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TableTest.class);
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Table table = new Table();
|
||||
|
||||
Row row1 = new Row(RowType.HEADING);
|
||||
table.appendRow(row1);
|
||||
|
||||
Cell cell11 = new Cell();
|
||||
cell11.setText("Column 1");
|
||||
row1.appendCell(cell11);
|
||||
|
||||
Cell cell12 = new Cell();
|
||||
cell12.setText("Column 2");
|
||||
row1.appendCell(cell12);
|
||||
|
||||
Cell cell13 = new Cell();
|
||||
cell13.setText("Column 3");
|
||||
row1.appendCell(cell13);
|
||||
|
||||
Row row2 = new Row();
|
||||
table.appendRow(row2);
|
||||
|
||||
Cell cell21 = new Cell();
|
||||
cell21.setText("Row 2 Content 1");
|
||||
row2.appendCell(cell21);
|
||||
|
||||
Cell cell22 = new Cell();
|
||||
cell22.setText("Row 2 Content 2");
|
||||
row2.appendCell(cell22);
|
||||
|
||||
Cell cell23 = new Cell();
|
||||
cell23.setText("Row 2 Content 3");
|
||||
row2.appendCell(cell23);
|
||||
|
||||
|
||||
Row row3 = new Row();
|
||||
table.appendRow(row3);
|
||||
|
||||
Cell cell31 = new Cell();
|
||||
cell31.setText("Row 3 Content 31");
|
||||
row3.appendCell(cell31);
|
||||
|
||||
Cell cell32 = new Cell();
|
||||
cell32.setText("Row 3 Content 32");
|
||||
row3.appendCell(cell32);
|
||||
|
||||
Cell cell33 = new Cell();
|
||||
cell33.setText("Row 3 Content 33");
|
||||
row3.appendCell(cell33);
|
||||
|
||||
StringBuffer stringBuffer = table.generateTable();
|
||||
logger.info(stringBuffer.toString());
|
||||
|
||||
cell11.setText("Longer Longer Column 1");
|
||||
cell33.setText("Longer Longer Row 3 Content 33");
|
||||
|
||||
stringBuffer = table.generateTable();
|
||||
logger.info(stringBuffer.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue