Cisco Cisco Prime Home 6.3 Developer's Guide

Page of 78
Cisco Prime Home – Integration Guide
 
 
OL-28558-01   v5.1
 
72 
 
public Credentials getCredentials() { 
final JSONObject attributes = optJSONObject("credentials", new 
JSONObject()); 
final String login = attributes.optString("login"); 
final String password = attributes.optString("password"); 
return new Credentials(login, password); 

 
public void setCredentials(final Credentials credentials) { 
try { 
final JSONObject json = optJSONObject("credentials", new 
JSONObject()); 
json.put("login", credentials.getLogin()); 
json.put("password", credentials.getPassword()); 
put("credentials", json); 
} catch (JSONException e) { 
throw new RuntimeException(e); 

 
public String[] getLabels() { 
try { 
final JSONArray json = optJSONArray("labels"); 
if (json == null) return new String[0]; 
final String[] labels = new String[json.length()]; 
for (int i = 0; i < json.length(); i++) { 
labels[i] = json.getJSONObject(i).getString("name"); 

return labels; 
} catch (JSONException e) { 
throw new RuntimeException(e); 

 
public void setLabels(final String[] labels) { 
try { 
final JSONArray json = new JSONArray(); 
for (String labelName : labels) { 
final JSONObject label = new JSONObject(); 
label.put("name", labelName); 

put("labels", json); 
} catch (JSONException e) { 
throw new RuntimeException(e); 

 
public boolean isNotPersisted() { 
return !has("revision"); 

 
public JSONObject optJSONObject(final String key, final  
JSONObject defaultValue) { 
final JSONObject value = optJSONObject(key); 
return value != null ? value : defaultValue; 
 
com.clearaccess.subscriber.api.Address 
 
/* 
* Copyright (c) 2010 ClearAccess, Inc.