当前位置: 首页>>代码示例>>Java>>正文


Java ObjectNode.toString方法代码示例

本文整理汇总了Java中org.codehaus.jackson.node.ObjectNode.toString方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectNode.toString方法的具体用法?Java ObjectNode.toString怎么用?Java ObjectNode.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.node.ObjectNode的用法示例。


在下文中一共展示了ObjectNode.toString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
@Override
public Directive deserialize(JsonParser jp, DeserializationContext ctx)
        throws IOException {
    ObjectReader reader = ObjectMapperUtil.instance().getObjectReader();
    ObjectNode obj = (ObjectNode) reader.readTree(jp);
    Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields();

    String rawMessage = obj.toString();
    DialogRequestIdHeader header = null;
    JsonNode payloadNode = null;
    ObjectReader headerReader =
            ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class);
    while (elementsIterator.hasNext()) {
        Map.Entry<String, JsonNode> element = elementsIterator.next();
        if (element.getKey().equals("header")) {
            header = headerReader.readValue(element.getValue());
        }
        if (element.getKey().equals("payload")) {
            payloadNode = element.getValue();
        }
    }
    if (header == null) {
        throw ctx.mappingException("Missing header");
    }
    if (payloadNode == null) {
        throw ctx.mappingException("Missing payload");
    }

    return createDirective(header, payloadNode, rawMessage);
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:31,代码来源:Directive.java

示例2: createAuthLinkResponse

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static String createAuthLinkResponse(){

        JsonNodeFactory f = JsonNodeFactory.instance ;
        ObjectNode loginResponse = f.objectNode();
        loginResponse.put("text","Authorization for SkyGiraffe to use Slack details is required.");
        ArrayNode attachments = loginResponse.putArray("attachments");
        ObjectNode att = f.objectNode();
        att.put("fallback", "Please authorize SkyGiraffe to access to your Slack details ...");
        att.put("pretext", "");
        att.put("title", "Please authorize..");
        att.put("title_link", Config.getPropertyValue("SLACK_AUTH_URL_DEV"));
        att.put("text","Once authorized and logged into SkyGiraffe try '/sg help' to see all commands");
        att.put("color", "#7CD197");

        attachments.add(att);
        return loginResponse.toString();

    }
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:19,代码来源:JsonUtil.java

示例3: createLoginLinkResponse

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
/**
 * {
 "attachments": [
 {
 "fallback": "Please login into SkyGiraffe to continue ...",
 "pretext": "SkyGiraffe Login",
 "title": "Please login into SkyGiraffe to continue ...",
 "title_link": "https://sgbot-mobilityai.rhcloud.com/SGbot-1.0/skyg/login?key=",
 "text": "Once logged in try '/sg help' to see all commands",
 "color": "#7CD197"
 }
 ]
 }
 * @return
 */
public static String createLoginLinkResponse(String slackUserId, String email, String teamId){

    JsonNodeFactory f = JsonNodeFactory.instance ;
    ObjectNode loginResponse = f.objectNode();
    loginResponse.put("text","Login to SkyGiraffe is required.");
    ArrayNode attachments = loginResponse.putArray("attachments");
    ObjectNode att = f.objectNode();
    att.put("fallback", "Please login into SkyGiraffe to continue ...");
    att.put("pretext", "");
    att.put("title", "Please login..");
    att.put("title_link", Config.getPropertyValue("SGDS_LOGIN_URL_DEV")+slackUserId+"&EMAIL="+email+"&TEAMID="+teamId);
    att.put("text","Once logged in try '/sg help' to see all commands");
    att.put("color", "#7CD197");

    attachments.add(att);

    return loginResponse.toString();

}
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:35,代码来源:JsonUtil.java

示例4: authenticate

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static String authenticate(String userName, String password) throws IOException {
    if (userName == null || userName.isEmpty())
        userName = SGSlackConstants.DEFAULT_USER;
    if (password == null || password.isEmpty())
        password = SGSlackConstants.PASSWORD;

    ObjectMapper m = new ObjectMapper();
    ObjectNode o = m.createObjectNode();
    o.put("UserName",userName);
    o.put("Password",password);
    o.put("OS","webapp");
    o.put("Version","4006000");

    StringEntity input = new StringEntity(o.toString());

    SGDSAuthRes ss = new SGDSAuthRes();
    ss = m.readValue(postSGDS("Authenticate",input), ss.getClass());

    logger.debug("Session id on authentication="+ss.getSessionID());
    return ss.getSessionID();
}
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:22,代码来源:SGDSClient.java

示例5: postRealTimeData

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static boolean postRealTimeData(HttpClient client, String url, String deviceToken) throws ParseException, IOException {
  HttpPost post = new HttpPost(url);
  post.addHeader("Cookie", Constants.X_SMS_AUTH_TOKEN + "=" + deviceToken);

  long MINS_AHEAD = 1000 * 60 * 30;   // Pretend we have 30 minutes of print time left
  int jobsInQueue = 6;                // and 6 jobs left in the queue
  String status = "DS_PRINTING";      // and we're currently printing

  Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  Timestamp printCompleteTime = new Timestamp(cal.getTime().getTime() + MINS_AHEAD);
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  String date = format.format(printCompleteTime.getTime());

  ObjectMapper mapper = new org.codehaus.jackson.map.ObjectMapper();
  ObjectNode jsonNode = mapper.createObjectNode();

  jsonNode.put("deviceStatus", status);
  jsonNode.put("totalJobs", jobsInQueue);
  jsonNode.put("printTimeComplete", date);

  StringEntity entity = new StringEntity(jsonNode.toString());
  post.setEntity(entity);

  HttpResponse response = HttpClientWrapper.executeHttpCommand(client, post);
  if (response != null) {
    if (response.getStatusLine().getStatusCode() != 204) {
      HttpClientWrapper.logErrorResponse(response, "Failed To post data");
      return false;
    } else {
      EntityUtils.consumeQuietly(response.getEntity());
      log.info("Sucessfully posted data");
      System.out.println("Successfully posted data.");
      return false;
    }
  } else {
    log.error("No response returned from post data");
    return false;
  }
}
 
开发者ID:HPInc,项目名称:printos-device-api-example-java,代码行数:40,代码来源:Device.java

示例6: loginAndGetToken

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static String loginAndGetToken(HttpClient client, String url, String login, String password)
  throws ParseException, IOException
{
  String token = null;
  HttpPost loginPost = new HttpPost(url);

  ObjectMapper mapper = new ObjectMapper();
  ObjectNode jsonNode = mapper.createObjectNode();

  jsonNode.put("login", login);
  jsonNode.put("password", password);

  StringEntity entity = new StringEntity(jsonNode.toString());
  loginPost.setEntity(entity);

  HttpResponse response = HttpClientWrapper.executeHttpCommand(client, loginPost);
  if (response != null)
  {
    if(response.getStatusLine().getStatusCode() == 200)
    {
      token = HttpClientWrapper.getTokenFromResponse(response);
      EntityUtils.consumeQuietly(response.getEntity());
    }
    else {
      HttpClientWrapper.logErrorResponse(response, "Failed To login");
    }
  }else {
    log.error("No response returned from login call");
  }

  return token;
}
 
开发者ID:HPInc,项目名称:printos-device-api-example-java,代码行数:33,代码来源:User.java

示例7: getAppList

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static String getAppList(String sessionId) throws IOException {

        if (sessionId == null || sessionId.isEmpty())
            throw new IllegalArgumentException("Session Id is empty. Please login.");

        ObjectMapper m = new ObjectMapper();
        ObjectNode o = m.createObjectNode();
        o.put("SessionID",sessionId);
        StringEntity inputApps = new StringEntity(o.toString());
        return postSGDS("GetAppsList", inputApps);
    }
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:12,代码来源:SGDSClient.java

示例8: getLogSearch

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
@Path("dataTable/{index-name}/{search-handle}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getDataTableData
    (
        @PathParam("index-name") String indexName,
        @PathParam("search-handle") String searchHandle,
        @QueryParam("iDisplayStart") int iDisplayStart,
        @QueryParam("iDisplayLength") int iDisplayLength,
        @QueryParam("sEcho") String sEcho
    ) throws Exception
{
    LogSearch logSearch = getLogSearch(indexName);
    if ( logSearch == null )
    {
        return "{}";
    }
    ObjectNode          node;
    try
    {
        CachedSearch        cachedSearch = logSearch.getCachedSearch(searchHandle);
        DateFormat          dateFormatter = new SimpleDateFormat(DATE_FORMAT_STR);
        ArrayNode           dataTab = JsonNodeFactory.instance.arrayNode();
        for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i )
        {
            if ( i < cachedSearch.getTotalHits() )
            {
                ObjectNode      data = JsonNodeFactory.instance.objectNode();
                int             docId = cachedSearch.getNthDocId(i);
                SearchItem      item = logSearch.toResult(docId);
                
                data.put("DT_RowId", "index-query-result-" + docId);
                data.put("0", getTypeName(EntryTypes.getFromId(item.getType())));
                data.put("1", dateFormatter.format(item.getDate()));
                data.put("2", trimPath(item.getPath()));

                dataTab.add(data);
            }
        }

        node = JsonNodeFactory.instance.objectNode();
        node.put("sEcho", sEcho);
        node.put("iTotalRecords", logSearch.getDocQty());
        node.put("iTotalDisplayRecords", cachedSearch.getTotalHits());
        node.put("aaData", dataTab);
    }
    finally
    {
        context.getExhibitor().getIndexCache().releaseLogSearch(logSearch.getFile());
    }

    return node.toString();
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:54,代码来源:IndexResource.java

示例9: getNodeData

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
@GET
@Path("node-data")
@Produces("application/json")
public String   getNodeData(@QueryParam("key") String key) throws Exception
{
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    try
    {
        Stat stat = context.getExhibitor().getLocalConnection().checkExists().forPath(key);
        byte[]          bytes = context.getExhibitor().getLocalConnection().getData().storingStatIn(stat).forPath(key);

        if (bytes != null) {
            node.put("bytes", bytesToString(bytes));
            node.put("str", new String(bytes, "UTF-8"));
        } else {
            node.put("bytes", "");
            node.put("str", "");
        }
        node.put("stat", reflectToString(stat));
    }
    catch ( KeeperException.NoNodeException dummy )
    {
        node.put("bytes", "");
        node.put("str", "");
        node.put("stat", "* not found * ");
    }
    catch ( Throwable e )
    {
        node.put("bytes", "");
        node.put("str", "Exception");
        node.put("stat", e.getMessage());
    }
    return node.toString();
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:35,代码来源:ExplorerResource.java

示例10: create

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static DeviceInfo create(String aaaPrefix, HttpClient client, String userToken,
                              Properties settings, Properties credentials) throws ParseException, IOException {
  String url = aaaPrefix + "/organizations/devices";
  String pspPassword = credentials.getProperty("psp_password");
  HttpPost post = new HttpPost(url);
  post.addHeader("Cookie", Constants.X_SMS_AUTH_TOKEN + "=" + userToken);

  // Device model and type must match correctly; see etc/devicelist.csv for a list of currently supported
  // combinations.  Note that serial number must be unique, or the same device will get replaced.

  ObjectMapper mapper = new ObjectMapper();
  ObjectNode jsonNode = mapper.createObjectNode();

  String serialNumber = getSerialNumber(settings.getProperty("serial_number"));
  jsonNode.put("name", settings.getProperty("device_name"));
  jsonNode.put("description", settings.getProperty("device_description"));
  jsonNode.put("serialNumber", serialNumber);
  jsonNode.put("model", settings.getProperty("device_model"));
  jsonNode.put("type", settings.getProperty("device_type"));
  jsonNode.put("securityPassword", pspPassword);

  StringEntity entity = new StringEntity(jsonNode.toString());
  post.setEntity(entity);

  HttpResponse response = HttpClientWrapper.executeHttpCommand(client, post);
  if (response != null) {
    String resp = EntityUtils.toString(response.getEntity());

    if (response.getStatusLine().getStatusCode() == 200) {
      JsonParser jp = mapper.getJsonFactory().createJsonParser(resp);
      JsonNode rootNode = mapper.readTree(jp);
      JsonNode node = rootNode.findValue("credentials");
      JsonNode node2 = rootNode.findValue("device");
      String deviceId = node2.findValue("deviceId").getTextValue();

      String deviceLogin = null;
      String devicePassword = null;
      if (node == null || node.findValue("login") == null) {
        System.out.println("Device is marked as non-provisionable, no login/password will be returned.");
      } else {
        deviceLogin = node.findValue("login").getTextValue();
        devicePassword = node.findValue("password").getTextValue();
        System.out.println("device_login=" + deviceLogin);
        System.out.println("device_password=" + devicePassword);
      }

      System.out.println("device_id=" + deviceId);
      System.out.println("Device created successfully.  Remember these values, this is the only time they'll be shown.");
      EntityUtils.consumeQuietly(response.getEntity());
      return new DeviceInfo(deviceLogin, devicePassword, deviceId, serialNumber);

    } else {
      System.out.println("Error executing command.  Does that device already exist?");
      EntityUtils.consumeQuietly(response.getEntity());
      return null;
    }

  } else {
    System.out.println("No response returned from create device");
    return null;
  }
}
 
开发者ID:HPInc,项目名称:printos-device-api-example-java,代码行数:63,代码来源:Device.java

示例11: getParameterList

import org.codehaus.jackson.node.ObjectNode; //导入方法依赖的package包/类
public static String getParameterList(String sessionId, String appId, String repId, String repUpId) throws IOException {

        //
        if (sessionId == null || sessionId.isEmpty())
            throw new IllegalArgumentException("Session Id is empty. Please login.");

        HttpPost postRequest = new HttpPost("https://wspublisherv2https.skygiraffe.com/WSPublisherV2.svc/GetReport_ParametersMainScreen4");

        // add header
        postRequest.setHeader("Content-Type", "application/json");

        JsonNodeFactory f = JsonNodeFactory.instance;

        ObjectNode o = f.objectNode();

        o.put("ApplicationID", appId);
        o.put("ReportID", repId);
        o.put("TabID","");

        ArrayNode diuId = f.arrayNode();
        diuId = o.putArray("DataItemUpdateIDs");
        o.put("ReportUpdateID",repUpId);
        o.put("RequestID",sessionId);

        o.put("SessionID",sessionId);

        StringEntity inputApps = new StringEntity(o.toString());

        inputApps.setContentType("application/json");
        postRequest.setEntity(inputApps);

        CloseableHttpResponse responseParams = getHttpClient().execute(postRequest);
        String paramStr = "";
        try {
            HttpEntity entityApps = responseParams.getEntity();
            paramStr = EntityUtils.toString(entityApps, "UTF-8");
            EntityUtils.consume(entityApps);
        }finally{
            responseParams.close();
        }
        logger.debug("Params = "+paramStr);
        return paramStr;
    }
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:44,代码来源:SGDSClient.java


注:本文中的org.codehaus.jackson.node.ObjectNode.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。