List of usage examples for org.json JSONObject optBoolean
public boolean optBoolean(String key, boolean defaultValue)
From source file:com.extjs.JSBuilder2.java
private static void createTargetsWithDeps() { try {//from w ww .ja va 2 s .c o m int len = pkgs.length(); for (int i = 0; i < len; i++) { /* Build pkg and include file deps */ JSONObject pkg = pkgs.getJSONObject(i); /* if we need to includeDeps, they shoudl already be built. */ if (pkg.optBoolean("includeDeps", false)) { String targFileName = pkg.getString("file"); if (targFileName.contains(".js")) { targFileName = FileHelper.insertFileSuffix(pkg.getString("file"), debugSuffix); } if (verbose) { System.out.format("Building the '%s' package as '%s'%n", pkg.getString("name"), targFileName); System.out.println("This package is built by included dependencies."); } /* create file and write out header */ File targetFile = new File(deployDir.getCanonicalPath() + File.separatorChar + targFileName); outputFiles.add(targetFile); targetFile.getParentFile().mkdirs(); FileHelper.writeStringToFile("", targetFile, false); /* get necessary pkg includes for this specific package */ JSONArray pkgDeps = pkg.getJSONArray("pkgDeps"); int pkgDepsLen = pkgDeps.length(); if (verbose) { System.out.format("- There are %d package include(s).%n", pkgDepsLen); } /* loop over file includes */ for (int j = 0; j < pkgDepsLen; j++) { /* open each file, read into string and append to target */ String pkgDep = pkgDeps.getString(j); if (verbose) { System.out.format("- - %s%n", pkgDep); } String nameWithorWithoutSuffix = pkgDep; if (pkgDep.contains(".js")) { nameWithorWithoutSuffix = FileHelper.insertFileSuffix(pkgDep, debugSuffix); } String subFileName = deployDir.getCanonicalPath() + File.separatorChar + nameWithorWithoutSuffix; File subFile = new File(subFileName); String tempString = FileHelper.readFileToString(subFile); FileHelper.writeStringToFile(tempString, targetFile, true); } } } } catch (Exception e) { e.printStackTrace(); System.err.println("Failed to create target with package dependencies."); } }
From source file:com.facebook.internal.Utility.java
private static FetchedAppSettings parseAppSettingsFromJSON(String applicationId, JSONObject settingsJSON) { FetchedAppSettings result = new FetchedAppSettings( settingsJSON.optBoolean(APP_SETTING_SUPPORTS_IMPLICIT_SDK_LOGGING, false), settingsJSON.optString(APP_SETTING_NUX_CONTENT, ""), settingsJSON.optBoolean(APP_SETTING_NUX_ENABLED, false), parseDialogConfigurations(settingsJSON.optJSONObject(APP_SETTING_DIALOG_CONFIGS))); fetchedAppSettings.put(applicationId, result); return result; }
From source file:ru.orangesoftware.financisto2.rates.OpenExchangeRatesDownloader.java
private boolean hasError(JSONObject json) throws JSONException { return json.optBoolean("error", false); }
From source file:com.jsonstore.api.JSONStoreAddOptions.java
public JSONStoreAddOptions(JSONObject json) { this();//from w ww . j a v a2s . c om if (json != null) { additionalSearchFields = json.optJSONObject(OPTION_ADDITIONAL_SEARCH_FIELDS); markDirty = json.optBoolean(OPTION_IS_ADD, false); } }
From source file:com.dattasmoon.pebble.plugin.IgnorePreference.java
@Override protected void onBindDialogView(View view) { btnAdd = (Button) view.findViewById(R.id.btnAdd); etMatch = (EditText) view.findViewById(R.id.etMatch); chkRawRegex = (CheckBox) view.findViewById(R.id.chkRawRegex); chkCaseInsensitive = (CheckBox) view.findViewById(R.id.chkCaseInsensitive); actvApplications = (AutoCompleteTextView) view.findViewById(R.id.actvApplications); spnApplications = (Spinner) view.findViewById(R.id.spnApplications); spnMode = (Spinner) view.findViewById(R.id.spnMode); lvIgnore = (ListView) view.findViewById(R.id.lvIgnore); lvIgnore.setAdapter(arrayAdapter);//from w w w. j av a 2s . c o m lvIgnore.setEmptyView(view.findViewById(android.R.id.empty)); new LoadAppsTask().execute(); lvIgnore.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) final View v = contextInfo.targetView; MenuInflater inflater = new MenuInflater(getContext()); inflater.inflate(R.menu.preference_ignore_context, menu); //we have to do this mess because DialogPreference doesn't allow for onMenuItemSelected or onOptionsItemSelected. Bleh menu.findItem(R.id.btnEdit).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { try { JSONObject ignore = arrayAdapter.getJSONArray().getJSONObject(i); if (i == arrayPosition) { etMatch.setText(ignore.getString("match")); chkRawRegex.setChecked(ignore.getBoolean("raw")); chkCaseInsensitive.setChecked(ignore.optBoolean("insensitive", true)); String app = ignore.getString("app"); if (app == "-1") { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(app); } boolean exclude = ignore.optBoolean("exclude", true); if (exclude) { spnMode.setSelection(Constants.IgnoreMode.EXCLUDE.ordinal()); } else { spnMode.setSelection(Constants.IgnoreMode.INCLUDE.ordinal()); } continue; } temp.put(ignore); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); return true; } }); menu.findItem(R.id.btnDelete).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); builder.setMessage(getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?") .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { if (i == arrayPosition) { continue; } try { temp.put(arrayAdapter.getJSONArray().getJSONObject(i)); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); builder.create().show(); return true; } }); } }); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONObject item = new JSONObject(); try { item.put("match", etMatch.getText().toString()); item.put("raw", chkRawRegex.isChecked()); item.put("insensitive", chkCaseInsensitive.isChecked()); if (actvApplications.getText().toString() .equalsIgnoreCase(getContext().getString(R.string.ignore_any))) { item.put("app", "-1"); } else { item.put("app", actvApplications.getText().toString()); } if (spnMode.getSelectedItemPosition() == Constants.IgnoreMode.INCLUDE.ordinal()) { item.put("exclude", false); } else { item.put("exclude", true); } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Item is: " + item.toString()); } arrayAdapter.getJSONArray().put(item); etMatch.setText(""); arrayAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } } }); actvApplications.setText(getContext().getString(R.string.ignore_any)); actvApplications.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actvApplications.showDropDown(); } }); actvApplications.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ApplicationInfo pkg = (ApplicationInfo) parent.getItemAtPosition(position); if (pkg == null) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(pkg.packageName); } } }); actvApplications.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { actvApplications.showDropDown(); } else { if (actvApplications.getText().length() == 0) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } } } }); super.onBindDialogView(view); }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { // handle the prefs changing, because of how accessibility services // work, sharedprefsonchange listeners don't work if (watchFile.lastModified() > lastChange) { loadPrefs();/*from ww w. j ava 2s . c o m*/ } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Service: Mode is: " + String.valueOf(mode.ordinal())); } // if we are off, don't do anything. if (mode == Mode.OFF) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Service: Mode is off, not sending any notifications"); } return; } //handle quiet hours if (quiet_hours) { Calendar c = Calendar.getInstance(); Date now = new Date(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); } if (quiet_hours_before.after(quiet_hours_after)) { if (now.after(quiet_hours_after) && now.before(quiet_hours_before)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Time is during quiet time. Returning."); } return; } } else if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Time is before or after the quiet hours time. Returning."); } return; } } // handle if they only want notifications if (notifications_only) { if (event != null) { Parcelable parcelable = event.getParcelableData(); if (!(parcelable instanceof Notification)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Event is not a notification and notifications only is enabled. Returning."); } return; } } } if (no_ongoing_notifs) { Parcelable parcelable = event.getParcelableData(); if (parcelable instanceof Notification) { Notification notif = (Notification) parcelable; if ((notif.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Event is a notification, notification flag contains ongoing, and no ongoing notification is true. Returning."); } return; } } else { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Event is not a notification."); } } } // Handle the do not disturb screen on settings PowerManager powMan = (PowerManager) this.getSystemService(Context.POWER_SERVICE); if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "NotificationService.onAccessibilityEvent: notifScreenOn=" + notifScreenOn + " screen=" + powMan.isScreenOn()); } if (!notifScreenOn && powMan.isScreenOn()) { return; } if (event == null) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Event is null. Returning."); } return; } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Event: " + event.toString()); } // main logic PackageManager pm = getPackageManager(); String eventPackageName; if (event.getPackageName() != null) { eventPackageName = event.getPackageName().toString(); } else { eventPackageName = ""; } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Service package list is: "); for (String strPackage : packages) { Log.i(Constants.LOG_TAG, strPackage); } Log.i(Constants.LOG_TAG, "End Service package list"); } switch (mode) { case EXCLUDE: // exclude functionality if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Mode is set to exclude"); } for (String packageName : packages) { if (packageName.equalsIgnoreCase(eventPackageName)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, packageName + " == " + eventPackageName + " which is on the exclude list. Returning."); } return; } } break; case INCLUDE: // include only functionality if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Mode is set to include only"); } boolean found = false; for (String packageName : packages) { if (packageName.equalsIgnoreCase(eventPackageName)) { found = true; break; } } if (!found) { Log.i(Constants.LOG_TAG, eventPackageName + " was not found in the include list. Returning."); return; } break; } // get the title String title = ""; try { boolean renamed = false; for (int i = 0; i < pkg_renames.length(); i++) { if (pkg_renames.getJSONObject(i).getString("pkg").equalsIgnoreCase(eventPackageName)) { renamed = true; title = pkg_renames.getJSONObject(i).getString("to"); } } if (!renamed) { title = pm.getApplicationLabel(pm.getApplicationInfo(eventPackageName, 0)).toString(); } } catch (NameNotFoundException e) { title = eventPackageName; } catch (JSONException e) { title = eventPackageName; } // get the notification text String notificationText = event.getText().toString(); // strip the first and last characters which are [ and ] notificationText = notificationText.substring(1, notificationText.length() - 1); if (notification_extras) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Fetching extras from notification"); } Parcelable parcelable = event.getParcelableData(); if (parcelable instanceof Notification) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { notificationText += "\n" + getExtraBigData((Notification) parcelable, notificationText.trim()); } else { notificationText += "\n" + getExtraData((Notification) parcelable, notificationText.trim()); } } } // Check ignore lists for (int i = 0; i < ignores.length(); i++) { try { JSONObject ignore = ignores.getJSONObject(i); String app = ignore.getString("app"); boolean exclude = ignore.optBoolean("exclude", true); boolean case_insensitive = ignore.optBoolean("insensitive", true); if ((!app.equals("-1")) && (!eventPackageName.equalsIgnoreCase(app))) { //this rule doesn't apply to all apps and this isn't the app we're looking for. continue; } String regex = ""; if (case_insensitive) { regex += "(?i)"; } if (!ignore.getBoolean("raw")) { regex += Pattern.quote(ignore.getString("match")); } else { regex += ignore.getString("match"); } Pattern p = Pattern.compile(regex); Matcher m = p.matcher(notificationText); if (m.find()) { if (exclude) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Notification text of '" + notificationText + "' matches: '" + regex + "' and exclude is on. Returning"); } return; } } else { if (!exclude) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Notification text of '" + notificationText + "' does not match: '" + regex + "' and include is on. Returning"); } return; } } } catch (JSONException e) { continue; } } // Send the alert to Pebble sendToPebble(title, notificationText); if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, event.toString()); Log.i(Constants.LOG_TAG, event.getPackageName().toString()); } }
From source file:at.alladin.rmbt.android.util.GetMapOptionsInfoTask.java
/** * /* ww w .j a v a 2s . c om*/ */ @Override protected void onPostExecute(final JSONObject result) { if (serverConn.hasError()) hasError = true; else if (result != null) { try { final JSONObject mapSettingsObject = result.getJSONObject("mapfilter"); // / // //////////////////////////////////////////////////// // MAP / CHOOSE final JSONArray mapTypeArray = mapSettingsObject.getJSONArray("mapTypes"); // Log.d(DEBUG_TAG, mapTypeArray.toString(4)); // / final ArrayList<MapListSection> mapListSectionList = new ArrayList<MapListSection>(); for (int cnt = 0; cnt < mapTypeArray.length(); cnt++) { final JSONObject t = mapTypeArray.getJSONObject(cnt); final String sectionTitle = t.getString("title"); final JSONArray objectOptionsArray = t.getJSONArray("options"); // / final List<MapListEntry> mapListEntryList = new ArrayList<MapListEntry>(); for (int cnt2 = 0; cnt2 < objectOptionsArray.length(); cnt2++) { final JSONObject s = objectOptionsArray.getJSONObject(cnt2); final String entryTitle = s.getString("title"); final String entrySummary = s.getString("summary"); final String value = s.getString("map_options"); final String overlayType = s.getString("overlay_type"); final MapListEntry mapListEntry = new MapListEntry(entryTitle, entrySummary); mapListEntry.setKey("map_options"); mapListEntry.setValue(value); mapListEntry.setOverlayType(overlayType); mapListEntryList.add(mapListEntry); } final MapListSection mapListSection = new MapListSection(sectionTitle, mapListEntryList); mapListSectionList.add(mapListSection); } // //////////////////////////////////////////////////// // MAP / FILTER final JSONObject mapFiltersObject = mapSettingsObject.getJSONObject("mapFilters"); final HashMap<String, List<MapListSection>> mapFilterListSectionListHash = new HashMap<String, List<MapListSection>>(); // Log.d(DEBUG_TAG, mapFilterArray.toString(4)); for (final String typeKey : new String[] { "mobile", "wifi", "browser" }) { final JSONArray mapFilterArray = mapFiltersObject.getJSONArray(typeKey); final List<MapListSection> mapFilterListSectionList = new ArrayList<MapListSection>(); mapFilterListSectionListHash.put(typeKey, mapFilterListSectionList); // add map appearance option (satellite, no satellite) final MapListSection appearanceSection = new MapListSection( activity.getString(R.string.map_appearance_header), Arrays.asList( new MapListEntry(activity.getString(R.string.map_appearance_nosat_title), activity.getString(R.string.map_appearance_nosat_summary), true, MapProperties.MAP_SAT_KEY, MapProperties.MAP_NOSAT_VALUE, true), new MapListEntry(activity.getString(R.string.map_appearance_sat_title), activity.getString(R.string.map_appearance_sat_summary), MapProperties.MAP_SAT_KEY, MapProperties.MAP_SAT_VALUE))); mapFilterListSectionList.add(appearanceSection); // add overlay option (heatmap, points) final MapListSection overlaySection = new MapListSection( activity.getString(R.string.map_overlay_header), Arrays.asList( new MapListEntry( activity.getString(R.string.map_overlay_auto_title), activity.getString(R.string.map_overlay_auto_summary), true, MapProperties.MAP_OVERLAY_KEY, MapOverlay.AUTO.name(), true), new MapListEntry(activity.getString(R.string.map_overlay_heatmap_title), activity.getString(R.string.map_overlay_heatmap_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.HEATMAP.name()), new MapListEntry(activity.getString(R.string.map_overlay_points_title), activity.getString(R.string.map_overlay_points_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.POINTS.name()), new MapListEntry(activity.getString(R.string.map_overlay_regions_title), activity.getString(R.string.map_overlay_regions_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.REGIONS.name()), new MapListEntry(activity.getString(R.string.map_overlay_municipality_title), activity.getString(R.string.map_overlay_municipality_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.MUNICIPALITY.name()), new MapListEntry(activity.getString(R.string.map_overlay_settlements_title), activity.getString(R.string.map_overlay_settlements_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.SETTLEMENTS.name()), new MapListEntry(activity.getString(R.string.map_overlay_whitespots_title), activity.getString(R.string.map_overlay_whitespots_summary), MapProperties.MAP_OVERLAY_KEY, MapOverlay.WHITESPOTS.name()))); mapFilterListSectionList.add(overlaySection); // add other filter options for (int cnt = 0; cnt < mapFilterArray.length(); cnt++) { final JSONObject t = mapFilterArray.getJSONObject(cnt); final String sectionTitle = t.getString("title"); final JSONArray objectOptionsArray = t.getJSONArray("options"); // / final List<MapListEntry> mapListEntryList = new ArrayList<MapListEntry>(); boolean haveDefault = false; for (int cnt2 = 0; cnt2 < objectOptionsArray.length(); cnt2++) { final JSONObject s = objectOptionsArray.getJSONObject(cnt2); final String entryTitle = s.getString("title"); final String entrySummary = s.getString("summary"); final boolean entryDefault = s.optBoolean("default", false); s.remove("title"); s.remove("summary"); s.remove("default"); // final MapListEntry mapListEntry = new MapListEntry(entryTitle, entrySummary); // final JSONArray sArray = s.names(); if (sArray != null && sArray.length() > 0) { final String key = sArray.getString(0); mapListEntry.setKey(key); mapListEntry.setValue(s.getString(key)); } mapListEntry.setChecked(entryDefault && !haveDefault); mapListEntry.setDefault(entryDefault); if (entryDefault) haveDefault = true; // / mapListEntryList.add(mapListEntry); } if (!haveDefault && mapListEntryList.size() > 0) { final MapListEntry first = mapListEntryList.get(0); first.setChecked(true); // set first if we had no default first.setDefault(true); } final MapListSection mapListSection = new MapListSection(sectionTitle, mapListEntryList); mapFilterListSectionList.add(mapListSection); } } // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // map type final MapListEntry entry = mapListSectionList.get(0).getMapListEntryList().get(0); activity.setCurrentMapType(entry); activity.setMapTypeListSectionList(mapListSectionList); activity.setMapFilterListSectionListMap(mapFilterListSectionListHash); } catch (final JSONException e) { e.printStackTrace(); } } else Log.i(DEBUG_TAG, "LEERE LISTE"); if (endTaskListener != null) { final JSONArray array = new JSONArray(); array.put(result); endTaskListener.taskEnded(array); } }
From source file:org.steveleach.scoresheet.support.JsonCodec.java
private void loadTeamPlayers(JSONArray jsonPlayers, Team team) throws JSONException { for (int n = 0; n < jsonPlayers.length(); n++) { JSONObject jsonPlayer = (JSONObject) jsonPlayers.get(n); Player player = new Player(); player.setNumber(jsonPlayer.getInt("number")); player.setName(jsonPlayer.optString("name", "")); player.setPlaying(jsonPlayer.optBoolean("active", true)); team.getPlayers().put(player.getNumber(), player); }/*from w w w . j av a 2 s . c om*/ }
From source file:org.chromium.ChromeUsb.java
private void getDevices(CordovaArgs args, JSONObject params, final CallbackContext callbackContext) throws JSONException, UsbError { HashMap<String, UsbDevice> devices = mUsbManager.getDeviceList(); JSONArray result = new JSONArray(); for (UsbDevice device : devices.values()) { addDeviceToArray(result, device.getDeviceId(), device.getVendorId(), device.getProductId()); }//from w w w . ja v a2 s. c o m if (params.optBoolean("appendFakeDevice", false)) { addDeviceToArray(result, FakeDevice.ID, FakeDevice.VID, FakeDevice.PID); } callbackContext.success(result); }
From source file:ded.model.Relation.java
public Relation(JSONObject o, ArrayList<Entity> integerToEntity, ArrayList<Inheritance> integerToInheritance, int version) throws JSONException { this.start = new RelationEndpoint(o.getJSONObject("start"), integerToEntity, integerToInheritance, ArrowStyle.AS_NONE, version); this.end = new RelationEndpoint(o.getJSONObject("end"), integerToEntity, integerToInheritance, ArrowStyle.AS_FILLED_TRIANGLE, version); JSONArray pts = o.optJSONArray("controlPts"); if (pts != null) { for (int i = 0; i < pts.length(); i++) { this.controlPts.add(AWTJSONUtil.pointFromJSON(pts.getJSONObject(i))); }//from www . ja v a 2 s .c o m } if (o.has("routingAlg")) { this.routingAlg = RoutingAlgorithm.valueOf(RoutingAlgorithm.class, o.getString("routingAlg")); } this.label = o.optString("label", ""); if (version < 9) { // The end arrowhead style was associated with the relation itself. this.setLegacyOwning(o.optBoolean("owning", false)); } if (o.has("lineWidth")) { this.lineWidth = Integer.valueOf(o.getInt("lineWidth")); } }