Skip to content
/ grid Public

Grid structure in Java with rendering to JSON, XML and CSV

License

Notifications You must be signed in to change notification settings

dhis2/grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Grid

Grid is a Java library which provides a two-dimensional grid structure. A grid has a set of rows and columns. Each column can have a corresponding header. The grid implementation is annotated with Jackson annotations and can be rendered to JSON and XML using a Jackson renderer. A grid can be rendered to CSV using the GridUtils utility class.

Maven

You can use Grid with Maven:

<dependency>
  <groupId>org.hisp</groupId>
  <artifactId>grid</artifactId>
  <version>1.0.0</version>
</dependency>

Sample Usage

To create a grid and add a few headers and rows:

Grid grid = new ListGrid()
    .setTitle( "Clients" )
    .addHeader( new GridHeader( "Name", "name" ) )
    .addHeader( new GridHeader( "Email", "email" ) )
    .addHeader( new GridHeader( "Phone", "phone" ) );

for ( Person person : people )
{
    grid.addRow()
        .addValue( person.getName() )
        .addValue( person.getEmail() )
        .addValue( person.getPhone() );
}

Render to CSV (Writer retrieved e.g. from HttpServletResponse):

Writer writer = response.getWriter();
GridUtils.toCsv( grid, writer );

Javadoc

You can find Javadoc here.

About

Grid structure in Java with rendering to JSON, XML and CSV

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages