程式庫套件和金鑰類別
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如需最常用的類別簡介,請參閱金鑰類別。
如需資料來源 Java 程式庫套件的簡介,請點選下方連結:
重要類別
主要類別為 DataSourceServlet
、DataTable
、Query
和 DataSourceHelper
。
如要實作程式庫,最簡單的實作方法就是沿用 DataSourceServlet
,編寫自己的 generateDataTable()
實作內容,然後在 ++ 中執行實作。如需這類實作的說明,請參閱入門指南。
DataTable
類別會定義資料表的資料欄、資料欄類型、標籤、ID 和自訂屬性。
Query
類別是資料查詢的基礎類別,可處理視覺化產生的查詢。
如果是較複雜的用途,輔助類別 DataSourceHelper
會提供一組輔助函式。有關這類實作的說明,請參閱「定義功能與事件流」。
datasource
這是頂層套件,內含大部分資料來源開發人員互動的 API 類別。
此外,這個頂層也是 Capabilities
,用於定義資料來源的查詢capabilities。
base
這個套件包含由多個套件使用的所有類別,以避免套件之間的循環依附元件。其中最值得注意的項目是預設語言代碼 (美國英文) 的錯誤訊息。如要將實作項目國際化,您需要翻譯這些訊息。
datatable
這個套件包含處理資料表結構 (資料欄、資料列、儲存格) 和功能 (insert、add) 的類別。
這個套件也包含 value
套件,用於處理程式庫支援的值和值類型。可用值類型是在 ValueType
列舉中定義,包括:布林值、日期、時間、日期和時間、空值、數字和文字。
query
這個套件包含處理查詢的類別,基本類別為 Query
。這個套件也包含以下套件:
parser
:處理查詢剖析的類別。
engine
- 處理查詢執行作業的類別。
scalarfunction
- 處理查詢中使用的純量函式的類別。
render
這個套件包含用於設定回應格式的類別。例如:
CsvRenderer
會將資料表轉譯為 CSV。
HtmlRenderer
會將資料表轉譯為 HTML。
JsonRenderer
會將資料表轉譯為 JSON。
EscapeUtil
提供逸出字串的公用程式。
util
這個套件提供兩組輔助函式:
CsvDataSourceHelper
和 CsvDataSourceException
提供使用 CSV 檔案做為資料儲存庫的輔助函式,因此無法提供資料來源的完整實作。如需實作範例,請參閱「使用外部資料儲存庫」。
SqlDataSourceHelper
和 SqlDatabaseDescription
會提供使用 mySQL 資料庫做為資料儲存庫的輔助函式,但這些函式並未提供資料來源的完整實作。如需實作範例,請參閱 examples
套件中的 SqlDataSourceServlet
。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-07-10 (世界標準時間)。
[null,null,["上次更新時間: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."]]