All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.barchart.feed.ddf.message.provider.DF_3R_CmdySpreadEOD Maven / Gradle / Ivy
/**
* Copyright (C) 2011-2012 Barchart, Inc.
*
* All rights reserved. Licensed under the OSI BSD License.
*
* http://www.opensource.org/licenses/bsd-license.php
*/
/**
*
*/
package com.barchart.feed.ddf.message.provider;
import static com.barchart.util.common.ascii.ASCII.COMMA;
import static com.barchart.util.common.ascii.ASCII.NUL;
import java.nio.ByteBuffer;
import com.barchart.feed.base.values.api.PriceValue;
import com.barchart.feed.base.values.api.SizeValue;
import com.barchart.feed.ddf.message.api.DDF_EOD_CommoditySpread;
import com.barchart.feed.ddf.message.api.DDF_MessageVisitor;
import com.barchart.feed.ddf.message.enums.DDF_MessageType;
import com.barchart.feed.ddf.util.HelperDDF;
import com.barchart.feed.ddf.util.enums.DDF_Fraction;
/**
* @author g-litchfield
*
*/
class DF_3R_CmdySpreadEOD extends BaseEOD implements DDF_EOD_CommoditySpread {
DF_3R_CmdySpreadEOD() {
super(DDF_MessageType.EOD_CMDY);
}
DF_3R_CmdySpreadEOD(final DDF_MessageType messageType) {
super(messageType);
}
// //////////////////////////////////////
protected long priceOpen = HelperDDF.DDF_EMPTY;
protected long priceHigh = HelperDDF.DDF_EMPTY;
protected long priceLow = HelperDDF.DDF_EMPTY;
protected long priceLast = HelperDDF.DDF_EMPTY;
protected long sizeVolume = HelperDDF.DDF_EMPTY;
// //////////////////////////////////////
/*
* 3,C,
* ,,,,
*/
@Override
public Result accept(
final DDF_MessageVisitor visitor, final Param param) {
return visitor.visit(this, param);
}
@Override
protected void encodeHead(final ByteBuffer buffer) {
super.encodeHead(buffer);
encodeDay(buffer);
}
@Override
protected void decodeHead(final ByteBuffer buffer) {
super.decodeHead(buffer);
final byte[][] symbolLegs = decodeSpread(buffer);
setSymbol(getSymbolMain(), symbolLegs);
decodeDay(buffer);
}
@Override
protected final void encodeBody(final ByteBuffer buffer) {
final DDF_Fraction frac = getFraction();
//
HelperDDF.decimalEncode(priceOpen, frac, buffer, COMMA); // ,
HelperDDF.decimalEncode(priceHigh, frac, buffer, COMMA); // ,
HelperDDF.decimalEncode(priceLow, frac, buffer, COMMA); // ,
HelperDDF.decimalEncode(priceLast, frac, buffer, COMMA); // ,
HelperDDF.longEncode(sizeVolume, buffer, NUL); // ,
}
@Override
protected final void decodeBody(final ByteBuffer buffer) {
final DDF_Fraction frac = getFraction();
//
priceOpen = HelperDDF.decimalDecode(frac, buffer, COMMA); //
priceHigh = HelperDDF.decimalDecode(frac, buffer, COMMA); //
priceLow = HelperDDF.decimalDecode(frac, buffer, COMMA); //
priceLast = HelperDDF.decimalDecode(frac, buffer, COMMA); //
sizeVolume = HelperDDF.longDecode(buffer, NUL);
}
@Override
protected void appedFields(final StringBuilder text) {
super.appedFields(text);
text.append("priceOpen : ");
text.append(getPriceOpen());
text.append("\n");
text.append("priceHigh : ");
text.append(getPriceHigh());
text.append("\n");
text.append("priceLow : ");
text.append(getPriceLow());
text.append("\n");
text.append("priceLast : ");
text.append(getPriceLast());
text.append("\n");
text.append("sizeVolume : ");
text.append(getSizeVolume());
text.append("\n");
}
@Override
public PriceValue getPriceOpen() {
return HelperDDF.newPriceDDF(priceOpen, getFraction());
}
@Override
public PriceValue getPriceHigh() {
return HelperDDF.newPriceDDF(priceHigh, getFraction());
}
@Override
public PriceValue getPriceLow() {
return HelperDDF.newPriceDDF(priceLow, getFraction());
}
@Override
public PriceValue getPriceLast() {
return HelperDDF.newPriceDDF(priceLast, getFraction());
}
@Override
public SizeValue getSizeVolume() {
return HelperDDF.newSizeDDF(sizeVolume);
}
}