Example usage for com.google.gson GsonBuilder setPrettyPrinting

List of usage examples for com.google.gson GsonBuilder setPrettyPrinting

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder setPrettyPrinting.

Prototype

public GsonBuilder setPrettyPrinting() 

Source Link

Document

Configures Gson to output Json that fits in a page for pretty printing.

Usage

From source file:org.mobicents.servlet.restcomm.http.UsageEndpoint.java

License:Open Source License

@PostConstruct
public void init() {
    final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName());
    configuration = (Configuration) context.getAttribute(Configuration.class.getName());
    configuration = configuration.subset("runtime-settings");
    super.init(configuration);
    dao = storage.getUsageDao();/*from  ww w  .j  av a2s . co  m*/
    accountsDao = storage.getAccountsDao();
    final UsageConverter converter = new UsageConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Usage.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new UsageListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.restcomm.http.VersionEndpoint.java

License:Open Source License

@PostConstruct
public void init() {
    final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName());
    configuration = (Configuration) context.getAttribute(Configuration.class.getName());
    configuration = configuration.subset("runtime-settings");
    super.init(configuration);
    dao = storage.getUsageDao();// w w  w.j ava  2s. c  o  m
    accountsDao = storage.getAccountsDao();
    final VersionConverter converter = new VersionConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(VersionEntity.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.AccountsEndpoint.java

License:Open Source License

public AccountsEndpoint() {
    super();// w  w w  . j  av a2  s.c o  m
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getAccountsDao();
    final AccountConverter converter = new AccountConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Account.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new AccountListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.CallsEndpoint.java

License:Open Source License

public CallsEndpoint() {
    super();/*from  w w w  . ja va2  s  .c o  m*/
    final ServiceLocator services = ServiceLocator.getInstance();
    callManager = services.get(CallManager.class);
    daos = services.get(DaoManager.class);
    interpreters = services.get(InterpreterFactory.class);
    CallDetailRecordConverter converter = new CallDetailRecordConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(CallDetailRecord.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new CallDetailRecordListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.ClientsEndpoint.java

License:Open Source License

public ClientsEndpoint() {
    super();/*from  w  w w  .ja v  a  2 s  .co m*/
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getClientsDao();
    final ClientConverter converter = new ClientConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Client.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new ClientListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.IncomingPhoneNumbersEndpoint.java

License:Open Source License

public IncomingPhoneNumbersEndpoint() {
    super();// www.  j a va2s .  c o  m
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getIncomingPhoneNumbersDao();
    final IncomingPhoneNumberConverter converter = new IncomingPhoneNumberConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(IncomingPhoneNumber.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new IncomingPhoneNumberListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.NotificationsEndpoint.java

License:Open Source License

public NotificationsEndpoint() {
    super();//  w w w  .ja  v a2s. c o  m
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getNotificationsDao();
    final NotificationConverter converter = new NotificationConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Notification.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new NotificationListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.OutgoingCallerIdsEndpoint.java

License:Open Source License

public OutgoingCallerIdsEndpoint() {
    super();//from  ww w .j a v  a  2s.  c om
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getOutgoingCallerIdsDao();
    final OutgoingCallerIdConverter converter = new OutgoingCallerIdConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(OutgoingCallerId.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new OutgoingCallerIdListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.RecordingsEndpoint.java

License:Open Source License

public RecordingsEndpoint() {
    super();/*from w  w  w  .  j a  v a 2 s .com*/
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getRecordingsDao();
    final RecordingConverter converter = new RecordingConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Recording.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new RecordingListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}

From source file:org.mobicents.servlet.sip.restcomm.http.SmsMessagesEndpoint.java

License:Open Source License

public SmsMessagesEndpoint() {
    super();//  ww  w  . j a  v a2 s.  co  m
    final ServiceLocator services = ServiceLocator.getInstance();
    dao = services.get(DaoManager.class).getSmsMessagesDao();
    aggregator = services.get(SmsAggregator.class);
    final SmsMessageConverter converter = new SmsMessageConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(SmsMessage.class, converter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new SmsMessageListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
}