This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status": "OK", | |
"results": [ | |
{ | |
"place_id": "ChIJJ5T9-iFawokRTPGaOginEO4", | |
"formatted_address": "280 Broadway, New York, NY 10007, USA", | |
"address_components": [ | |
{ | |
"short_name": "280", | |
"types": ["street_number"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Location", new BoxLayout(BoxLayout.Y_AXIS)); | |
hi.add("Pinpointing Location"); | |
Display.getInstance().callSerially(() -> { | |
Location l = Display.getInstance().getLocationManager().getCurrentLocationSync(); | |
ConnectionRequest request = new ConnectionRequest("http://maps.googleapis.com/maps/api/geocode/json", false) { | |
private String country; | |
private String region; | |
private String city; | |
private String json; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Result result = Result.fromContent(input, Result.XML); | |
String country = result.getAsString("/result/address_component[type='country']/long_name"); | |
String region = result.getAsString("/result/address_component[type='administrative_area_level_1']/long_name"); | |
String city = result.getAsString("/result/address_component[type='locality']/long_name"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<GeocodeResponse> | |
<status>OK</status> | |
<result> <!-- (irrelevant content removed) --> | |
<address_component> | |
<long_name>London</long_name> | |
<short_name>London</short_name> | |
<type>locality</type> | |
<type>political</type> | |
</address_component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("JSON Parsing", new BoxLayout(BoxLayout.Y_AXIS)); | |
JSONParser json = new JSONParser(); | |
try(Reader r = new InputStreamReader(Display.getInstance().getResourceAsStream(getClass(), "/anapioficeandfire.json"), "UTF-8")) { | |
Map<String, Object> data = json.parseJSON(r); | |
java.util.List<Map<String, Object>> content = (java.util.List<Map<String, Object>>)data.get("root"); | |
for(Map<String, Object> obj : content) { | |
String url = (String)obj.get("url"); | |
String name = (String)obj.get("name"); | |
java.util.List<String> titles = (java.util.List<String>)obj.get("titles"); | |
if(name == null || name.length() == 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Toolbar.setGlobalToolbar(true); | |
Style s = UIManager.getInstance().getComponentStyle("TitleCommand"); | |
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_QUERY_BUILDER, s); | |
Form hi = new Form("SQL Explorer", new BorderLayout()); | |
hi.getToolbar().addCommandToRightBar("", icon, (e) -> { | |
TextArea query = new TextArea(3, 80); | |
Command ok = new Command("Execute"); | |
Command cancel = new Command("Cancel"); | |
if(Dialog.show("Query", query, ok, cancel) == ok) { | |
Database db = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database db = Display.getInstance().openOrCreate(“databaseName”); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String path = Display.getInstance().getDatabasePath(“databaseName”); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass implements Externalizable { | |
private static final int VERSION = 2; | |
private String name; | |
private String value; | |
private String domain; | |
private Date date; | |
private long expires; | |
public MyClass() {} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void externalize(DataOutputStream out) throws IOException { | |
Util.writeUTF(name, out); | |
Util.writeUTF(value, out); | |
Util.writeUTF(domain, out); | |
out.writeLong(expires); | |
} | |
public void internalize(int version, DataInputStream in) throws IOException { | |
name = Util.readUTF(in); | |
value = Util.readUTF(in); |