Package org.fudgemsg

Examples of org.fudgemsg.FudgeFieldType


  protected void writeLabels(final FudgeSerializer serializer, final MutableFudgeMsg message, final Object[] labels, final String valueKey, final String typeKey) {
    final MutableFudgeMsg valueMsg = serializer.newMessage();
    final MutableFudgeMsg typeMsg = serializer.newMessage();
    boolean needsTypeInfo = false;
    for (Object label : labels) {
      final FudgeFieldType type = serializer.getFudgeContext().getTypeDictionary().getByJavaType(label.getClass());
      if (type == null) {
        serializer.addToMessage(valueMsg, null, null, label);
        valueMsg.add(null, null, FudgeWireType.SUB_MESSAGE, serializer.objectToFudgeMsg(label));
        typeMsg.add(null, null, label.getClass().getName());
        needsTypeInfo = true;
      } else {
        valueMsg.add(null, null, type, label);
        if (type instanceof SecondaryFieldType<?, ?>) {
          typeMsg.add(null, null, type.getJavaType().getName());
          needsTypeInfo = true;
        } else {
          typeMsg.add(null, null, type.getTypeId());
        }
      }
    }
    if (!needsTypeInfo) {
      // Message contains only primitive types; only put the type info in if there have been type reductions
View Full Code Here


      } else if (dataValue instanceof JSONArray) {
        final JSONArray dataArray = (JSONArray) dataValue;
        if (dataArray.length() > 0) {
          if (isPrimitiveArray(metaValue)) {
            try {
              final FudgeFieldType fieldType = getFieldType((String) metaValue);
              if (fieldType == null) {
                throw new OpenGammaRuntimeException("Unknown field type " + metaValue + " for " + fieldName + ":" + dataValue);
              }
              final Object primitiveArray = jsonArrayToPrimitiveArray(dataArray, fieldType);
              addField(fudgeMsg, fieldName, getFieldType((String) metaValue), primitiveArray);
            } catch (final JSONException e) {
              wrapException("converting json array to primitive array", e);
            }
          } else {
            //treat as repeated fields
            addRepeatedFields(fudgeMsg, fieldName, dataArray, (JSONArray) metaValue);
          }
        }
      } else {
        final FudgeFieldType fieldType = getFieldType((String) metaValue);
        if (fieldType == null) {
          throw new OpenGammaRuntimeException("Unknown field type " + metaValue + " for " + fieldName + ":" + dataValue);
        }
        addField(fudgeMsg, fieldName, fieldType, dataValue);
      }
View Full Code Here

        final Object metaValue = metaArray.get(i);
        if (arrValue instanceof JSONObject) {
          final MutableFudgeMsg subMsg = processFields((JSONObject) arrValue, (JSONObject) metaValue);
          addField(fudgeMsg, fieldName, FudgeWireType.SUB_MESSAGE, subMsg);
        } else {
          final FudgeFieldType fieldType = getFieldType((String) metaValue);
          if (fieldType == null) {
            throw new OpenGammaRuntimeException("Unknown field type " + metaValue + " for " + fieldName + ":" + arrValue);
          }
          addField(fudgeMsg, fieldName, fieldType, arrValue);
        }
View Full Code Here

  protected static FudgeMsg serializeValue(final FudgeSerializer serializer, final Object value) {
    if (value instanceof Double) {
      //Make sure fudge doesn't faff around with reflection
      final MutableFudgeMsg newMessage = serializer.newMessage();
      final FudgeFieldType doubleFieldType = FudgeWireType.DOUBLE;
      newMessage.add(null, NATIVE_FIELD_INDEX, doubleFieldType, value);
      return newMessage;
    } else if (value instanceof FudgeMsg) {
      final MutableFudgeMsg newMessage = serializer.newMessage();
      final FudgeFieldType messageFieldType = FudgeWireType.SUB_MESSAGE;
      newMessage.add(null, NATIVE_FIELD_INDEX, messageFieldType, value);
      return newMessage;
    }
    serializer.reset();
    final MutableFudgeMsg message = serializer.newMessage();
View Full Code Here

TOP

Related Classes of org.fudgemsg.FudgeFieldType

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.