Package org.fudgemsg

Examples of org.fudgemsg.FudgeMsg


    _delegate = delegate;
  }
 
  @Override
  public FudgeMsg requestReceived(FudgeDeserializer deserializer, FudgeMsgEnvelope requestEnvelope) {
    FudgeMsg requestFudgeMsg = requestEnvelope.getMessage();
    ResolveRequest resolveRequest = ResolveRequest.fromFudgeMsg(deserializer, requestFudgeMsg);
    s_logger.debug("Received resolve request for {}", resolveRequest.getRequestedSpecification());
   
    LiveDataSpecification requestedSpec = resolveRequest.getRequestedSpecification();
    ExternalId resolvedId = _delegate.resolve(requestedSpec.getIdentifiers());
    LiveDataSpecification resolvedSpec = new LiveDataSpecification(
        requestedSpec.getNormalizationRuleSetId(),
        resolvedId);
   
    ResolveResponse response = new ResolveResponse(resolvedSpec);
    FudgeMsg responseFudgeMsg = response.toFudgeMsg(new FudgeSerializer(deserializer.getFudgeContext()));
    return responseFudgeMsg;
  }
View Full Code Here


    msg.add("Foo", "1");
    msg.add("Bar", 2.0);
    msg.add("Baz", 500);
   
    FieldHistoryStore store = new FieldHistoryStore();
    FudgeMsg normalizedMsg = ruleSet.getNormalizedMessage(msg, "123", store);
    assertEquals(msg, normalizedMsg);
  }
View Full Code Here

    provider.setWriteThrough(true);
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
   
    LastKnownValueStore store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    FudgeMsg currFields = store.getFields();
    assertTrue(currFields.isEmpty());
   
    msg.add("bid", 1.0d);
    msg.add("ask", 2.0d);
   
    store.updateFields(msg);
   
    currFields = store.getFields();
    assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Reset the store.
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Write through another value and confirm it works.
    msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("bid", 5.0d);
    store.updateFields(msg);
   
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Reset the store. This time don't write through.
    provider.setWriteThrough(false);
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("bid", 3.0d);
    msg.add("ask", 4.0d);
    store.updateFields(msg);
    currFields = store.getFields();
    assertEquals(3.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(4.0d, currFields.getDouble("ask"), 0.0005d);

    // Reset the store.
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
  }
View Full Code Here

    if (xs.size() > 0) {
      final Class<?> xClazz = xs.get(0).getClass();
      final Map<Object, Double> values = new HashMap<Object, Double>();
      final List<FudgeField> valuesFields = message.getAllByName("values");
      for (final FudgeField valueField : valuesFields) {
        final FudgeMsg subMessage = (FudgeMsg) valueField.getValue();
        final Object x = deserializer.fieldValueToObject(xClazz, subMessage.getByName("x"));
        final Double value = subMessage.getDouble("value");
        values.put(x, value);
      }
      return new FuturePriceCurveData<Object>(definitionName, specificationName, target, xs.toArray(xsArray), values);
    }
    return new FuturePriceCurveData<Object>(definitionName, specificationName, target, xs.toArray(), Collections.<Object, Double>emptyMap());
View Full Code Here

    object.setClassifier(msg.getString(CLASSIFIER_FIELD_NAME));
    String uriStr = msg.getString(URI_FIELD_NAME);
    if (uriStr != null) {
      object.setUri(URI.create(uriStr));
    }
    FudgeMsg attributes = msg.getMessage(ATTRIBUTES_FIELD_NAME);
    for (FudgeField field : attributes) {
      object.addAttribute(field.getName(), field.getValue().toString());
    }
  }
View Full Code Here

   
    List<FudgeMsgEnvelope> receivedMessages = collectingReceiver.getMessages();
    assertEquals(1, receivedMessages.size());
    FudgeMsgEnvelope receivedEnvelope = receivedMessages.get(0);
    assertNotNull(receivedEnvelope.getMessage());
    FudgeMsg receivedMsg = receivedEnvelope.getMessage();
    assertEquals(2, receivedMsg.getNumFields());
    assertEquals("Bar", receivedMsg.getString("Foo"));
    assertEquals(new Integer(99), receivedMsg.getInt("Number Problems"));
  }
View Full Code Here

    List<FudgeMsgEnvelope> receivedMessages = responseReceiver.getMessages();
    assertEquals(1, receivedMessages.size());
   
    FudgeMsgEnvelope receivedEnvelope = receivedMessages.get(0);
    assertNotNull(receivedEnvelope.getMessage());
    FudgeMsg receivedMsg = receivedEnvelope.getMessage();
    assertEquals(1, receivedMsg.getNumFields());
    assertEquals("In The Name Of", receivedMsg.getString("Killing"));
  }
View Full Code Here

  public static ExternalIdSearch fromFudgeMsg(final FudgeDeserializer deserializer, final FudgeMsg msg) {
    if (msg == null) {
      return null;
    }
    final FudgeMsg idMsg = msg.getMessage(IDENTIFIERS_FIELD_NAME);
    final String searchType = msg.getString(SEARCH_TYPE_FIELD_NAME);
    Set<ExternalId> ids = new HashSet<ExternalId>();
    for (FudgeField field : idMsg) {
      ids.add(ExternalIdFudgeBuilder.fromFudgeMsg((FudgeMsg) field.getValue()));
    }
View Full Code Here

    if (predictedSize != -1) {
      assertEquals(predictedSize, data.length);
    }
    assertTrue(consumer.isReadable(FudgeMsgEnvelope.class, null, null, null));
    final ByteArrayInputStream bis = new ByteArrayInputStream(data);
    final FudgeMsg msgOut;
    try {
      final FudgeMsgEnvelope env = (FudgeMsgEnvelope) consumer.readFrom(FudgeMsgEnvelope.class, null, null, null, null, bis);
      assertNotNull(env);
      msgOut = env.getMessage();
    } catch (IOException e) {
      throw new OpenGammaRuntimeException("ioexception", e);
    }
    assertNotNull(msgOut);
    assertEquals("bar", msgOut.getFieldValue(String.class, msgOut.getByName("foo")));
    assertEquals((Integer) 42, msgOut.getFieldValue(Integer.class, msgOut.getByName("number")));
  }
View Full Code Here

      final Class<?> xClazz = xs.get(0).getClass();
      final Class<?> yClazz = ys.get(0).getClass();
      final Map<Pair<Object, Object>, Double> values = new HashMap<Pair<Object, Object>, Double>();
      final List<FudgeField> valuesFields = message.getAllByName(VALUES_FIELD);
      for (final FudgeField valueField : valuesFields) {
        final FudgeMsg subMessage = (FudgeMsg) valueField.getValue();
        final Object x = deserializer.fieldValueToObject(xClazz, subMessage.getByName(X_FIELD));
        final Object y = deserializer.fieldValueToObject(yClazz, subMessage.getByName(Y_FIELD));
        final Double value = subMessage.getDouble(VALUE_FIELD);
        values.put(Pair.of(x, y), value);
      }
      return new VolatilitySurfaceData<Object, Object>(definitionName, specificationName, target, xs.toArray(xsArray), xLabel, ys.toArray(ysArray), yLabel, values);
    }
    return new VolatilitySurfaceData<Object, Object>(definitionName, specificationName, target, xs.toArray(), xLabel, ys.toArray(), yLabel, Collections.<Pair<Object, Object>, Double>emptyMap());
View Full Code Here

TOP

Related Classes of org.fudgemsg.FudgeMsg

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.