Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper


    for (int i = 0; i < passedEvents.size(); ++i)
    {
      assertEquals("Failed Element " + i, expFailedEvents.get(i), failedEvents.get(i));
    }

    ObjectMapper objMapper = new ObjectMapper();
    String objStr = objMapper.writeValueAsString(filter);

    System.out.println("KeyModFilter :" + objStr);

    DbusKeyFilter filter2 = KeyFilterConfigJSONFactory.parseDbusKeyFilter(objStr);
    String objStr2 = objMapper.writeValueAsString(filter2);

    System.out.println("KeyModFilter2 :" + objStr2);
    assertEquals("KeyModFilter JSON Serialization Test", objStr, objStr2);
  }
View Full Code Here


   * @return        the JSON string
   */
  public static <T>String toJsonString(T bean, boolean pretty)
         throws JsonGenerationException, JsonMappingException, IOException
  {
    JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());

    StringWriter out = new StringWriter(1000);
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(out);
    if (pretty) jsonGenerator.useDefaultPrettyPrinter();
    jsonGenerator.writeObject(bean);
View Full Code Here

    for (int i = 0; i < passedEvents.size(); ++i)
    {
      assertEquals("Failed Element " + i, expFailedEvents.get(i), failedEvents.get(i));
    }

    ObjectMapper objMapper = new ObjectMapper();
    String objStr = objMapper.writeValueAsString(filter);

    System.out.println("KeyModFilter :" + objStr);

    DbusKeyFilter filter2 = KeyFilterConfigJSONFactory.parseDbusKeyFilter(objStr);
    String objStr2 = objMapper.writeValueAsString(filter2);

    System.out.println("KeyModFilter2 :" + objStr2);
    assertEquals("KeyModFilter JSON Serialization Test", objStr, objStr2);
  }
View Full Code Here

    for (int i = 0; i < passedEvents.size(); ++i)
    {
      assertEquals("Failed Element " + i, expFailedEvents.get(i), failedEvents.get(i));
    }

    ObjectMapper objMapper = new ObjectMapper();
    String objStr = objMapper.writeValueAsString(filter);

    System.out.println("KeyRangeFilter :" + objStr);

    DbusKeyFilter filter2 = KeyFilterConfigJSONFactory.parseDbusKeyFilter(objStr);
    String objStr2 = objMapper.writeValueAsString(filter2);

    System.out.println("KeyRangeFilter2 :" + objStr2);
    assertEquals("KeyRangeFilter JSON Serialization Test", objStr, objStr2);

  }
View Full Code Here

        _stateReuse.switchToTargetScnResponseError();
      }
      else
      {
        InputStream bodyStream = Channels.newInputStream(_decorated);
        ObjectMapper mapper = new ObjectMapper();
        String scnString = mapper.readValue(bodyStream, String.class);
        LOG.info("targetScn:" + scnString);

        long targetScn = Long.parseLong(scnString);

        _stateReuse.switchToTargetScnSuccess();
View Full Code Here

          LOG.info("initiated bootstrap sesssion to host " + hostHdr + " service " + svcHdr);
        }

        InputStream bodyStream = Channels.newInputStream(_decorated);

        ObjectMapper mapper = new ObjectMapper();
        String scnString = mapper.readValue(bodyStream, String.class);

        ServerInfo serverInfo  = null;
        String serverHostPort = _decorated.getMetadata(DbusConstants.SERVER_INFO_HOSTPORT_HEADER_PARAM);
        try
        {
View Full Code Here

    sendRequest(request, new StreamRequestResultListener(), streamResponseProcessor);
  }

  private boolean populateStreamRequestUrl(StringBuilder uriString)
  {
    ObjectMapper objMapper = new ObjectMapper();
    Formatter uriFmt = new Formatter(uriString);
    String filtersStr = null;
    boolean error = false;
    if (null != _filter)
    {
      try
      {
        Map<Long, DbusKeyFilter> fMap = _filter.getFilterMap();
        if (null != fMap && fMap.size() > 0)
          filtersStr = objMapper.writeValueAsString(fMap);
      }
      catch (IOException ex)
      {
        LOG.error("Got exception while serializing Filters. Filter Map was : " + _filter, ex);
        error = true;
View Full Code Here

          svcHdr = getParent().getRemoteService();
          LOG.info("initiated sesssion to host " + hostHdr + " service " + svcHdr);
        }

        InputStream bodyStream = Channels.newInputStream(_decorated);
        ObjectMapper mapper = new ObjectMapper();

        List<IdNamePair> sources =
            mapper.readValue(bodyStream,
                             new TypeReference<List<IdNamePair>>()
                                 {});
       _stateReuse.switchToSourcesSuccess(sources, hostHdr, svcHdr);
      }
    }
View Full Code Here

        _stateReuse.switchToRegisterResponseError();
      }
      else
      {
        InputStream bodyStream = Channels.newInputStream(_decorated);
        ObjectMapper mapper = new ObjectMapper();
        int registerResponseVersion = 3// either 2 or 3 would suffice here; we care only about 4

        if (_registerResponseVersionHdr != null)
        {
          try
          {
            registerResponseVersion = Integer.parseInt(_registerResponseVersionHdr);
          }
          catch (NumberFormatException e)
          {
            throw new RuntimeException("Could not parse /register response protocol version: " +
                                       _registerResponseVersionHdr);
          }
          if (registerResponseVersion < 2 || registerResponseVersion > 4)
          {
            throw new RuntimeException("Out-of-range /register response protocol version: " +
                                       _registerResponseVersionHdr);
          }
        }

        if (registerResponseVersion == 4// DDSDBUS-2009
        {
          HashMap<String, List<Object>> responseMap =
              mapper.readValue(bodyStream, new TypeReference<HashMap<String, List<Object>>>() {});

          // Look for mandatory SOURCE_SCHEMAS_KEY.
          Map<Long, List<RegisterResponseEntry>> sourcesSchemasMap = RegisterResponseEntry.createFromResponse(responseMap,
                                                                                                              RegisterResponseEntry.SOURCE_SCHEMAS_KEY,
                                                                                                              false);
          // Look for optional KEY_SCHEMAS_KEY
          // Key schemas, if they exist, should correspond to source schemas, but it's not
          // a one-to-one mapping.  The same version of a key schema may be used for several
          // versions of a source schema, or vice versa.  (The IDs must correspond.)
          //
          // TODO (DDSDBUS-xxx):  support key schemas on the relay side, too
          Map<Long, List<RegisterResponseEntry>> keysSchemasMap = RegisterResponseEntry.createFromResponse(responseMap,
                                                                                                           RegisterResponseEntry.KEY_SCHEMAS_KEY,
                                                                                                           true);

          // Look for optional METADATA_SCHEMAS_KEY
          List<RegisterResponseMetadataEntry> metadataSchemasList = RegisterResponseMetadataEntry.createFromResponse(responseMap,
                                                                                                                     RegisterResponseMetadataEntry.METADATA_SCHEMAS_KEY,
                                                                                                                     true);

          _stateReuse.switchToRegisterSuccess(sourcesSchemasMap, keysSchemasMap, metadataSchemasList);
        }
        else // version 2 or 3
        {
          List<RegisterResponseEntry> schemasList =
              mapper.readValue(bodyStream, new TypeReference<List<RegisterResponseEntry>>() {});

          Map<Long, List<RegisterResponseEntry>> sourcesSchemasMap = RegisterResponseEntry.convertSchemaListToMap(schemasList);

          _stateReuse.switchToRegisterSuccess(sourcesSchemasMap, null, null);
        }
View Full Code Here

    KeyFilterConfigHolder holder = new KeyFilterConfigHolder(staticConfig);

    System.out.println("Holder is :" + holder.toString());
   
    ObjectMapper mapper = new ObjectMapper();
    String s = mapper.writeValueAsString(holder);
   
    System.out.println("Config Holder JSON:" + s);
       
    JSONObject obj = new JSONObject(s);
    String type = obj.getString("partitionType");
    String configStr = obj.getString("filterConfig");
   
    KeyFilterConfigHolder configHolder = new KeyFilterConfigHolder();
        configHolder.setPartitionType(PartitionType.valueOf(type));
        KeyFilterConfig conf = null;
    if (PartitionType.MOD == configHolder.getPartitionType())
    {
       conf = mapper.readValue(configStr,KeyModFilterConfig.class);
    } else if (PartitionType.RANGE == configHolder.getPartitionType()) {
       conf = mapper.readValue(configStr,KeyRangeFilterConfig.class);
    }
    configHolder.setFilterConfig(conf);
   
    System.out.println("Holder2 is :" + configHolder.toString());
     
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.ObjectMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.