库软件包和关键类
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需了解最常用的类,请参阅键类。
如需查看数据源 Java 库软件包的介绍,请访问以下链接:
关键类
关键类包括 DataSourceServlet
、DataTable
、Query
和 DataSourceHelper
。
该库最简单的实现涉及从 DataSourceServlet
继承,编写您自己的 generateDataTable()
实现,然后在 WebView 中运行该实现。使用入门部分介绍了此类实现。
DataTable
类定义了数据表的列、列类型、标签、ID 和自定义属性。
Query
类是数据查询的基类,可处理可视化生成的查询。
对于更复杂的用例,辅助类 DataSourceHelper
提供了一组辅助函数。定义功能和事件流中介绍了这种实现方式。
datasource
这是顶级软件包,其中包含大多数数据源开发者与之交互的 API 类。
此顶层还有 Capabilities
,用于定义数据源的查询功能。capabilities
base
此软件包包含由多个软件包使用的所有类,以防止软件包之间的循环依赖关系。其中最显著的是采用默认语言区域(美国英语)的错误消息。如需国际化您的实现,您需要转换这些消息。
datatable
此软件包包含用于处理数据表结构(列、行、单元格)和功能(插入、添加)的类。
此软件包还包含用于处理库支持的值和值类型的 value
软件包。可用的值类型在 ValueType
枚举中定义,包括:布尔值、日期、时间、日期和时间、null、数字和文本。
query
此软件包包含处理查询的类,基类为 Query
。此软件包还包含以下软件包:
parser
- 处理查询解析的类。
engine
- 处理查询执行的类。
scalarfunction
- 用于处理查询中使用的标量函数的类。
render
此软件包包含设置响应格式的类。例如:
CsvRenderer
将数据表呈现为 CSV。
HtmlRenderer
会将数据表格呈现为 HTML。
JsonRenderer
将数据表呈现为 JSON。
EscapeUtil
提供了一个用于转义字符串的实用程序。
util
此软件包提供了两组辅助函数:
CsvDataSourceHelper
和 CsvDataSourceException
提供将 CSV 文件用作数据存储区的辅助函数,但它们不提供数据源的完整实现。如需查看示例实现,请参阅使用外部数据存储区。
SqlDataSourceHelper
和 SqlDatabaseDescription
提供了将 mySQL 数据库用作数据存储区的辅助函数,但它们不提供数据源的完整实现。如需查看示例实现,请参阅 examples
软件包中的 SqlDataSourceServlet
。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-07-10。
[null,null,["最后更新时间 (UTC):2024-07-10。"],[[["\u003cp\u003eThis library enables developers to connect their data to Google Visualization charts using Java.\u003c/p\u003e\n"],["\u003cp\u003eKey classes include \u003ccode\u003eDataSourceServlet\u003c/code\u003e, \u003ccode\u003eDataTable\u003c/code\u003e, \u003ccode\u003eQuery\u003c/code\u003e, and \u003ccode\u003eDataSourceHelper\u003c/code\u003e for building data source implementations.\u003c/p\u003e\n"],["\u003cp\u003eThe library provides packages for data source management (\u003ccode\u003edatasource\u003c/code\u003e), base functionalities (\u003ccode\u003ebase\u003c/code\u003e), data table structure (\u003ccode\u003edatatable\u003c/code\u003e), query handling (\u003ccode\u003equery\u003c/code\u003e), response formatting (\u003ccode\u003erender\u003c/code\u003e), and utility functions (\u003ccode\u003eutil\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage helper functions for CSV and SQL data stores through \u003ccode\u003eCsvDataSourceHelper\u003c/code\u003e and \u003ccode\u003eSqlDataSourceHelper\u003c/code\u003e, respectively.\u003c/p\u003e\n"],["\u003cp\u003eFor simple implementations, inherit from \u003ccode\u003eDataSourceServlet\u003c/code\u003e and implement \u003ccode\u003egenerateDataTable()\u003c/code\u003e; for complex cases, use \u003ccode\u003eDataSourceHelper\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Library Packages and Key Classes\n\nFor an introduction to the most commonly used classes, see [key\nclasses](#keyclasses).\n\nFor an introduction to the data source Java library packages follow\nthe links below:\n\n- [datasource](#datasource \"datasource\")\n- [datasource.base](#base)\n- [datasource.datatable](#datatable)\n- [datasource.query](#query)\n- [datasource.render](#render)\n- [datasource.util](#util)\n\nKey Classes\n-----------\n\nThe key classes are [DataSourceServlet](https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/DataSourceServlet.java), [DataTable](https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/datatable/DataTable.java),\n[Query](https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/query/Query.java) and [DataSourceHelper](https://code.google.com/p/google-visualization-java/source/browse/trunk/src/main/java/com/google/visualization/datasource/DataSourceHelper.java).\n\nThe simplest implementation of the library involves inheriting from `DataSourceServlet`,\nwriting your own implementation of `generateDataTable()` and\nthen running the implementation within a servlet. This type of implementation\nis described in the [Getting\nStarted](/chart/interactive/docs/dev/dsl_get_started) section.\n\nThe `DataTable` class defines the columns, column types,\nlabels, ids, and custom properties for a data table.\n\nThe `Query` class is the base class for data queries, it\nhandles a visualization-generated query.\n\nFor more complex\nuse cases, the helper class `DataSourceHelper` provides\na set of helper functions. This type of implementation\nis described in [Defining Capabilities and the Flow of Events](/chart/interactive/docs/dev/dsl_httpservlet).\n\n`datasource`\n------------\n\nThis is the [top\nlevel 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\nmost data source developers interact.\n\nAlso at this top level is `Capabilities`, which is\nused to define the data source's query [capabilities](/chart/interactive/docs/dev/dsl_key_concepts#capabilities).\n\n\n`base`\n------\n\n[This\npackage](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\nto prevent circular dependencies between the packages. The most notable\nitems are error messages in the default locale of US English. To internationalize\nyour implementation, you will need to translate these messages.\n\n`datatable`\n-----------\n\n[This\npackage](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,\nrows, cells) and functionality (insert, add).\n\nThis package also contains the `value` package that handles\nvalues and value types supported by the library. Available value types\nare defined in the `ValueType` enumeration and include: boolean,\ndate, time of day, date and time, null, number, and text.\n\n`query`\n-------\n\n[This\npackage](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`.\nThis package also contains the following packages:\n\n- `parser` - classes that handle query parsing. \n- `engine` - classes that handle query execution.\n- `scalarfunction` - classes that handle scalar functions used in a query.\n\n`render`\n--------\n\n[This\npackage](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:\n\n- `CsvRenderer` renders a data table as CSV.\n- `HtmlRenderer` renders a data table as HTML.\n- `JsonRenderer` renders a data table as JSON.\n- `EscapeUtil` provides a utility to escape strings.\n\n`util`\n------\n\n[This\npackage](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:\n\n- `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](/chart/interactive/docs/dev/dsl_csv).\n- `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."]]