All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.barchart.feed.ddf.message.provider.DF_20_Param 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.*;

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_MarketParameter;
import com.barchart.feed.ddf.message.api.DDF_MessageVisitor;
import com.barchart.feed.ddf.message.enums.DDF_MessageType;
import com.barchart.feed.ddf.message.enums.DDF_ParamType;
import com.barchart.feed.ddf.util.HelperDDF;

// TODO: Auto-generated Javadoc
class DF_20_Param extends BaseMarket implements DDF_MarketParameter {

	/* (non-Javadoc)
	 * @see com.barchart.feed.ddf.message.provider.Base#accept(com.barchart.feed.ddf.message.api.DDF_MessageVisitor, java.lang.Object)
	 */
	@Override
	public  Result accept(
			DDF_MessageVisitor visitor, Param param) {
		return visitor.visit(this, param);
	}

	DF_20_Param() {
		super(DDF_MessageType.PARAM);
	}

	DF_20_Param(final DDF_MessageType messageType) {
		super(messageType);
	}

	// //////////////////////////////////////

	private byte ordParam = DDF_ParamType.UNKNOWN.ord;

	/**
	 * can represent:
	 * 
	 * 1) price (with exponent from fraction);
	 * 
	 * 2) size (regardless of the exponent in fraction):
	 */
	protected long value = HelperDDF.DDF_EMPTY;

	// //////////////////////////////////////

	/* (non-Javadoc)
	 * @see com.barchart.feed.ddf.message.api.DDF_MarketParameter#getParamType()
	 */
	@Override
	public final DDF_ParamType getParamType() {
		return DDF_ParamType.fromOrd(ordParam);
	}

	/**
	 * Sets the param type.
	 *
	 * @param type the new param type
	 */
	public final void setParamType(final DDF_ParamType type) {
		ordParam = type.ord;
	}

	/* (non-Javadoc)
	 * @see com.barchart.feed.ddf.message.api.DDF_MarketParameter#getAsPrice()
	 */
	@Override
	public final PriceValue getAsPrice() {
		return HelperDDF.newPriceDDF(value, getFraction());
	}

	/* (non-Javadoc)
	 * @see com.barchart.feed.ddf.message.api.DDF_MarketParameter#getAsSize()
	 */
	@Override
	public final SizeValue getAsSize() {
		return HelperDDF.newSizeDDF(value);
	}

	/*
	 * ,()(,)()||
	 * 
	 * ,
	 * 
	 * ||||




© 2015 - 2024 Weber Informatics LLC | Privacy Policy