Package org.fudgemsg

Examples of org.fudgemsg.FudgeContext


   * Creates an instance.
   *
   * @param byteArrayRequestSender the sender
   */
  public RemoteBloombergSecuritySource(ByteArrayRequestSender byteArrayRequestSender) {
    this(byteArrayRequestSender, new FudgeContext());
  }
View Full Code Here


   *
   * @param object  the object to encode, not null
   * @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

      } catch (IllegalAccessException ex) {
        throw new RuntimeException(ex);
      }
    }
    byte[] msg = Base64.decodeBase64(msgBase64);
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    FudgeMsg message = context.createMessageReader(new ByteArrayInputStream(msg)).nextMessage();
    if (message == null) {
      return null;
    }
    FudgeDeserializer deser = new FudgeDeserializer(context);
    return deser.fudgeMsgToObject(type, message);
View Full Code Here

   *
   * @param bld  the URI builder, not null
   * @param object  the object to encode, not null
   */
  public static void encodeQueryParams(UriBuilder bld, Object object) {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    FudgeMsg msg = context.toFudgeMsg(object).getMessage();
    encode(bld, msg, "");
  }
View Full Code Here

   * @param uriInfo  the uri information, not null
   * @param type  the bean type to build, not null
   * @return the bean, not null
   */
  public static <T> T decodeQueryParams(UriInfo uriInfo, Class<T> type) {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    MutableFudgeMsg msg = context.newMessage();
    for (Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
      String key = entry.getKey();
      List<String> values = entry.getValue();
      for (String value : values) {
        decode(msg, key, value);
View Full Code Here

   * @return the equivalent tutorial security, not null
   * @throws IllegalArgumentException if the raw security is not an encoding of a {@code Tutorial1Security}
   */
  public static Tutorial1Security fromRawSecurity(final RawSecurity raw) {
    ArgumentChecker.isTrue(isInstance(raw), "raw");
    final FudgeContext context = OpenGammaFudgeContext.getInstance();
    final FudgeMsg fudgeMsg = context.deserialize(raw.getRawData()).getMessage();
    final FudgeDeserializer deserializer = new FudgeDeserializer(context);
    return new Tutorial1Security(raw, deserializer, fudgeMsg);
  }
View Full Code Here

   * A sub-class should not need to overload this method, overloading {@link #populateFudgeMsg} will correctly populate the {@code RawSecurity}.
   *
   * @return the raw security instance, not null
   */
  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;
  }
View Full Code Here

  /**
   * Writes a {@link CurrencyPair} to a Fudge message and reads it back.
   */
  @Test
  public void roundTrip() {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    CurrencyPair eurUsd = CurrencyPair.parse("EUR/USD");
    MutableFudgeMsg msg = context.newMessage();
    msg.add(CURRENCY_PAIR, eurUsd);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FudgeMsgWriter writer = context.createMessageWriter(baos);
    writer.writeMessage(msg);
    writer.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    FudgeMsgReader reader = context.createMessageReader(bais);
    FudgeMsg rebuiltMsg = reader.nextMessage();
    AssertJUnit.assertNotNull(rebuiltMsg);
    FudgeField currencyPairField = rebuiltMsg.getByName(CURRENCY_PAIR);
    AssertJUnit.assertNotNull(currencyPairField);
    AssertJUnit.assertEquals(String.class, currencyPairField.getType().getJavaType());
View Full Code Here

   * Constructor.
   *
   * @param secSource the source of securities, not null
   */
  public SecurityMasterRequestReceiver(SecuritySource secSource) {
    this(secSource, new FudgeContext());
  }
View Full Code Here

public class OpenGammaFudgeContextTest {

  @Test
  public void test_context() {
    // simple basic test
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    assertNotNull(context);
    assertNotNull(context.getObjectDictionary());
    assertTrue(context.getObjectDictionary().getObjectBuilder(Paging.class) instanceof PagingFudgeBuilder);
    assertTrue(context.getObjectDictionary().getMessageBuilder(Paging.class) instanceof PagingFudgeBuilder);
  }
View Full Code Here

TOP

Related Classes of org.fudgemsg.FudgeContext

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.