# Library Packages and Key Classes

For an introduction to the most commonly used classes, see [key
classes](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#keyclasses).

For an introduction to the data source Java library packages follow
the links below:

- [datasource](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#datasource "datasource")
- [datasource.base](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#base)
- [datasource.datatable](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#datatable)
- [datasource.query](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#query)
- [datasource.render](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#render)
- [datasource.util](https://developers.google.com/chart/interactive/docs/dev/dsl_packages#util)

## Key Classes

The key classes are `https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/DataSourceServlet.java`, `https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/datatable/DataTable.java`,
`https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/query/Query.java` and `https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/DataSourceHelper.java`.

The simplest implementation of the library involves inheriting from `DataSourceServlet`,
writing your own implementation of `generateDataTable()` and
then running the implementation within a servlet. This type of implementation
is described in the [Getting
Started](https://developers.google.com/chart/interactive/docs/dev/dsl_get_started) section.

The `DataTable` class defines the columns, column types,
labels, ids, and custom properties for a data table.

The `Query` class is the base class for data queries, it
handles a visualization-generated query.

For more complex
use cases, the helper class `DataSourceHelper` provides
a set of helper functions. This type of implementation
is described in [Defining Capabilities and the Flow of Events](https://developers.google.com/chart/interactive/docs/dev/dsl_httpservlet).

## `datasource`

This is the [top
level package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource%3Fstate%3Dclosed) and contains the API classes with which
most data source developers interact.

Also at this top level is `Capabilities`, which is
used to define the data source's query [capabilities](https://developers.google.com/chart/interactive/docs/dev/dsl_key_concepts#capabilities).


## `base`

[This
package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource/base) contains all classes that are used by more than one package
to prevent circular dependencies between the packages. The most notable
items are error messages in the default locale of US English. To internationalize
your implementation, you will need to translate these messages.

## `datatable`

[This
package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource/datatable) contains classes that handle data table structure (columns,
rows, cells) and functionality (insert, add).

This package also contains the `value` package that handles
values and value types supported by the library. Available value types
are defined in the `ValueType` enumeration and include: boolean,
date, time of day, date and time, null, number, and text.

## `query`

[This
package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource/query) contains classes that handle queries, the base class is `Query`.
This package also contains the following packages:

- `parser` - classes that handle query parsing.   
- `engine` - classes that handle query execution.
- `scalarfunction` - classes that handle scalar functions used in a query.

## `render`

[This
package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource/render) contains the classes that format a response. For example:

- `CsvRenderer` renders a data table as CSV.
- `HtmlRenderer` renders a data table as HTML.
- `JsonRenderer` renders a data table as JSON.
- `EscapeUtil` provides a utility to escape strings.

## `util`

[This
package](http://code.google.com/p/google-visualization-java/source/browse/#svn/trunk/src/java/com/google/chart/interactive/datasource/util) provides two sets of helper functions:

- `CsvDataSourceHelper` and `CsvDataSourceException` provide helper functions for using a CSV file as a data store, they do not provide a complete implementation of a data source. For an example implementation, see [Using an External Data Store](https://developers.google.com/chart/interactive/docs/dev/dsl_csv).
- `SqlDataSourceHelper` and `SqlDatabaseDescription` provide helper functions for using a mySQL database as a data store, they do not provide a complete implementation of a data source. For an example implementation, see `SqlDataSourceServlet` in the `examples` package.