|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +title: "Java" |
| 4 | +description: "Java is a programming language with collection and object models that can represent tabular data as maps, arrays, lists, and class instances. You can export grid data as Java-ready source in AnyWayData.com." |
| 5 | +--- |
| 6 | + |
| 7 | +Java is a programming language and the AnyWayData Java option is most useful when you want copy/paste-ready data for tests, fixtures, demos, and prototypes. |
| 8 | + |
| 9 | +## What is Java Data Output? |
| 10 | + |
| 11 | +Java can represent table-like data using collections of maps or collections of objects. |
| 12 | + |
| 13 | +For example, a list of maps: |
| 14 | + |
| 15 | +```java |
| 16 | +import java.util.Map; |
| 17 | +import java.util.List; |
| 18 | +import java.util.ArrayList; |
| 19 | + |
| 20 | +List<Map<String, Object>> data = new ArrayList<>(List.of( |
| 21 | + Map.of("user", "Jesse.Bradtke97", "name", "Corine"), |
| 22 | + Map.of("user", "Cielo.Little", "name", "Zander") |
| 23 | +)); |
| 24 | +``` |
| 25 | + |
| 26 | +In the example above: |
| 27 | + |
| 28 | +- each row is represented as a map using key/value pairs |
| 29 | +- map keys come from the column headers |
| 30 | +- row maps are collected in a Java list |
| 31 | + |
| 32 | +AnyWayData can also generate class-instance output where each row is represented as a named Java object. |
| 33 | + |
| 34 | +## How is Java Output different from JSON and Javascript? |
| 35 | + |
| 36 | +JSON is a language-independent data format and JavaScript object arrays are JavaScript syntax. |
| 37 | + |
| 38 | +Java output uses Java syntax and Java concepts: |
| 39 | + |
| 40 | +- rows can be emitted as `Map<String, Object>` values or named class instances |
| 41 | +- output can be generated as `List` or array collections |
| 42 | +- values can be emitted as quoted strings or numeric literals |
| 43 | +- output can be assigned to a named Java variable |
| 44 | + |
| 45 | +Unlike JSON, Java output is designed to be used directly in Java source code. |
| 46 | + |
| 47 | +## AnyWayData Support for Java |
| 48 | + |
| 49 | +AnyWayData currently supports **exporting** data to Java format. |
| 50 | + |
| 51 | +You can configure output options such as: |
| 52 | + |
| 53 | +- collection type (`List` or array) |
| 54 | +- variable assignment and naming |
| 55 | +- number conversion (quoted vs unquoted) |
| 56 | +- map vs class-instance output |
| 57 | +- pretty print indentation and custom delimiter |
| 58 | +- import inclusion |
| 59 | + |
| 60 | +Java output can be generated from the same grid data used for the other supported export formats. |
0 commit comments