Package org.fudgemsg

Examples of org.fudgemsg.FudgeContext.toByteArray()


    ManageableExchange exchange = new ManageableExchange();
    exchange.setUniqueId(UniqueId.of("DbExg", "101", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange101");
    exchange.setTimeZone(ZoneId.of("Europe/London"));
    byte[] bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange101", "Europe/London", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "102", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("G", "H")));
View Full Code Here


        "TestExchange101", "Europe/London", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "102", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("G", "H")));
    exchange.setName("TestExchange102");
    exchange.setTimeZone(ZoneId.of("Europe/Paris"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        102, 102, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange102", "Europe/Paris", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
View Full Code Here

        "TestExchange102", "Europe/Paris", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange201");
    exchange.setTimeZone(ZoneId.of("Asia/Tokyo"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        201, 201, toSqlTimestamp(_version1Instant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange201", "Asia/Tokyo", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "1"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
View Full Code Here

        "TestExchange201", "Asia/Tokyo", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "1"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange202");
    exchange.setTimeZone(ZoneId.of("Asia/Tokyo"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        202, 201, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP,
        "TestExchange202", "Asia/Tokyo", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    _totalExchanges = 3;
//  id bigint not null,
View Full Code Here

   * @return  the encoded version of the object, not null
   */
  public static String encodeBase64(final Object object) {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    FudgeMsg msg = context.toFudgeMsg(object).getMessage();
    byte[] byteArray = context.toByteArray(msg);
    return Base64.encodeBase64URLSafeString(byteArray);
  }

  //-------------------------------------------------------------------------
  /**
 
View Full Code Here

  public RawSecurity toRawSecurity() {
    final FudgeContext context = OpenGammaFudgeContext.getInstance();
    final MutableFudgeMsg fudgeMsg = context.newMessage();
    final FudgeSerializer serializer = new FudgeSerializer(context);
    populateFudgeMsg(serializer, fudgeMsg);
    final RawSecurity security = new RawSecurity(getUniqueId(), getName(), getSecurityType(), getExternalIdBundle(), context.toByteArray(fudgeMsg));
    security.setAttributes(getAttributes());
    return security;
  }

  //------------------------- AUTOGENERATED START -------------------------
View Full Code Here

    FudgeDeserializer deserializationContext = new FudgeDeserializer(context);
    ValueRequirement test = new ValueRequirement("DATA", ComputationTargetType.PRIMITIVE, USD);
    MutableFudgeMsg inMsg = serializationContext.objectToFudgeMsg(test);
    assertNotNull(inMsg);
    assertEquals(3, inMsg.getNumFields());
    FudgeMsg outMsg = context.deserialize(context.toByteArray(inMsg)).getMessage();
    ValueRequirement decoded = deserializationContext.fudgeMsgToObject(ValueRequirement.class, outMsg);
    assertEquals(test, decoded);
    test = new ValueRequirement("DATA", ComputationTargetType.PRIMITIVE, USD, ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get());
    inMsg = serializationContext.objectToFudgeMsg(test);
    assertNotNull(inMsg);
View Full Code Here

    assertEquals(test, decoded);
    test = new ValueRequirement("DATA", ComputationTargetType.PRIMITIVE, USD, ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get());
    inMsg = serializationContext.objectToFudgeMsg(test);
    assertNotNull(inMsg);
    assertEquals(4, inMsg.getNumFields());
    outMsg = context.deserialize(context.toByteArray(inMsg)).getMessage();
    decoded = deserializationContext.fudgeMsgToObject(ValueRequirement.class, outMsg);
    assertEquals(test, decoded);
  }

}
View Full Code Here

  public void fudgeEncoding() {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    CalculationJobSpecification spec1 = new CalculationJobSpecification(UniqueId.of("Test", "ViewCycle"), "config", Instant.now(), 1L);
    FudgeSerializer serializationContext = new FudgeSerializer(context);
    MutableFudgeMsg inMsg = serializationContext.objectToFudgeMsg(spec1);
    FudgeMsg outMsg = context.deserialize(context.toByteArray(inMsg)).getMessage();
    FudgeDeserializer deserializationContext = new FudgeDeserializer(context);
    CalculationJobSpecification spec2 = deserializationContext.fudgeMsgToObject(CalculationJobSpecification.class, outMsg);
    assertEquals(spec1, spec2);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.