Example usage for com.google.gson JsonPrimitive JsonPrimitive

List of usage examples for com.google.gson JsonPrimitive JsonPrimitive

Introduction

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

Prototype

public JsonPrimitive(Character c) 

Source Link

Document

Create a primitive containing a character.

Usage

From source file:arces.unibo.SEPA.commons.SPARQL.RDFTerm.java

License:Open Source License

public RDFTerm(String value) {
    json = new JsonObject();
    json.add("value", new JsonPrimitive(value));
}

From source file:arces.unibo.SEPA.commons.SPARQL.RDFTermBNode.java

License:Open Source License

public RDFTermBNode(String value) {
    super(value);

    json.add("type", new JsonPrimitive("bnode"));
}

From source file:arces.unibo.SEPA.commons.SPARQL.RDFTermLiteral.java

License:Open Source License

public RDFTermLiteral(String value) {
    super(value);

    json.add("type", new JsonPrimitive("literal"));
}

From source file:arces.unibo.SEPA.commons.SPARQL.RDFTermLiteral.java

License:Open Source License

public RDFTermLiteral(String value, String lanOrDT, boolean lan) {
    super(value);

    json.add("type", new JsonPrimitive("literal"));

    if (lan)//  www.j av a 2  s  .  c o  m
        json.add("xml:lang", new JsonPrimitive(lanOrDT));
    else
        json.add("datatype", new JsonPrimitive(lanOrDT));
}

From source file:arces.unibo.SEPA.commons.SPARQL.RDFTermURI.java

License:Open Source License

public RDFTermURI(String value) {
    super(value);
    json.add("type", new JsonPrimitive("uri"));
}

From source file:arces.unibo.SEPA.server.core.EngineProperties.java

License:Open Source License

protected void defaults() {
    JsonObject properties = new JsonObject();

    // Engine timeouts
    JsonObject timeouts = new JsonObject();
    timeouts.add("scheduling", new JsonPrimitive(0));
    timeouts.add("queuesize", new JsonPrimitive(1000));
    timeouts.add("keepalive", new JsonPrimitive(5000));
    timeouts.add("http", new JsonPrimitive(5000));
    properties.add("timeouts", timeouts);

    // Default path, scheme and port
    properties.add("path", new JsonPrimitive("/sparql"));
    properties.add("scheme", new JsonPrimitive("http"));
    properties.add("port", new JsonPrimitive(8000));

    // Secure query
    JsonObject secureQuery = new JsonObject();
    secureQuery.add("port", new JsonPrimitive(8443));
    secureQuery.add("scheme", new JsonPrimitive("https"));
    properties.add("securequery", secureQuery);

    // Secure update
    JsonObject secureUpdate = new JsonObject();
    secureUpdate.add("port", new JsonPrimitive(8443));
    secureUpdate.add("scheme", new JsonPrimitive("https"));
    properties.add("secureupdate", secureUpdate);

    // Subscribe//from www  .j  a  v  a  2  s  .c o m
    JsonObject subscribe = new JsonObject();
    subscribe.add("scheme", new JsonPrimitive("ws"));
    subscribe.add("port", new JsonPrimitive(9000));
    properties.add("subscribe", subscribe);

    // Secure subscribe
    JsonObject secureSubscribe = new JsonObject();
    secureSubscribe.add("scheme", new JsonPrimitive("wss"));
    secureSubscribe.add("port", new JsonPrimitive(9443));
    secureSubscribe.add("path", new JsonPrimitive("/secure/sparql"));
    properties.add("securesubscribe", secureSubscribe);

    // Authorization server
    JsonObject authServer = new JsonObject();
    authServer.add("port", new JsonPrimitive(8443));
    authServer.add("scheme", new JsonPrimitive("https"));
    authServer.add("register", new JsonPrimitive("/oauth/register"));
    authServer.add("tokenrequest", new JsonPrimitive("/oauth/token"));
    properties.add("authorizationserver", authServer);

    parameters.add("parameters", properties);
}

From source file:arces.unibo.SEPA.server.protocol.HTTPGate.java

License:Open Source License

/**
 * Builds the echo response./*from w ww . j a  va  2 s  .  co  m*/
 *
 * @param exchange
 *            the exchange
 * @return the json object
 */
private JsonObject buildEchoResponse(HttpExchange exchange) {
    JsonObject json = new JsonObject();

    json.add("method", new JsonPrimitive(exchange.getRequestMethod().toUpperCase()));
    json.add("protocol", new JsonPrimitive(exchange.getProtocol()));

    JsonObject headers = new JsonObject();
    for (String header : exchange.getRequestHeaders().keySet()) {
        headers.add(header, new JsonPrimitive(exchange.getRequestHeaders().get(header).toString()));
    }
    json.add("headers", headers);

    String body = "";
    try {
        body = IOUtils.toString(exchange.getRequestBody(), "UTF-8");
    } catch (IOException e) {
        logger.error(e.getMessage());
        body = e.getMessage();
    }
    json.add("body", new JsonPrimitive(body));

    json.add("contextPath", new JsonPrimitive(exchange.getHttpContext().getPath()));
    if (exchange.getRequestURI().getQuery() != null)
        json.add("query", new JsonPrimitive(exchange.getRequestURI().getQuery()));

    return json;
}

From source file:arces.unibo.SEPA.server.protocol.HTTPGate.java

License:Open Source License

/**
 * Failure response.//from w  w  w . j  a  va2 s  .c  o m
 *
 * @param exchange
 *            the exchange
 * @param httpResponseCode
 *            the http response code
 * @param responseBody
 *            the response body
 */
protected void failureResponse(HttpExchange exchange, int httpResponseCode, String responseBody) {
    JsonObject json = buildEchoResponse(exchange);

    json.add("body", new JsonPrimitive(responseBody));
    json.add("code", new JsonPrimitive(httpResponseCode));

    sendResponse(exchange, httpResponseCode, json.toString());
}

From source file:at.ac.tuwien.infosys.jcloudscale.datastore.mapping.type.json.JsonBooleanTypeAdapter.java

License:Apache License

@Override
public JsonElement serialize(Boolean object, TypeMetadata<JsonElement> typeMetadata) {
    return new JsonPrimitive(object);
}

From source file:at.ac.tuwien.infosys.jcloudscale.datastore.mapping.type.json.JsonByteTypeAdapter.java

License:Apache License

@Override
public JsonElement serialize(Byte object, TypeMetadata<JsonElement> typeMetadata) {
    return new JsonPrimitive(object);
}