com.thomsonreuters.ema.access.Map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ema Show documentation
Show all versions of ema Show documentation
Enterprise Message API (EMA) Java Edition
The newest version!
///*|-----------------------------------------------------------------------------
// *| This source code is provided under the Apache 2.0 license --
// *| and is provided AS IS with no warranty or guarantee of fit for purpose. --
// *| See the project's LICENSE.md for details. --
// *| Copyright (C) 2019 Refinitiv. All rights reserved. --
///*|-----------------------------------------------------------------------------
package com.thomsonreuters.ema.access;
import java.util.Collection;
/**
* Map is a homogeneous container of complex data type entries.
*
* Map is a collection which provides iterator over the elements in this
* collection.
*
* Map entries are identified by a map key.
All entries must have key of the
* same primitive data type.
All entries must have same complex data type
* (except for delete action).
*
* The following code snippet shows addition of containers to Map.
*
* Map map = EmaFactory.createMap();
* FieldList fl = EmaFactory.createFieldList();
* fl.add(EmaFactory.createFieldEntry().real(22, 34, OmmReal.MagnitudeType.EXPONENT_POS_1));
* map.summaryData(fl);
* ByteBuffer permission = (ByteBuffer)ByteBuffer.wrap("PERMISSION DATA".getBytes());
* ByteBuffer orderBuf =(ByteBuffer)ByteBuffer.wrap("ABCD".getBytes());
* map.add(EmaFactory.createMapEntry().keyBuffer(orderBuf, MapEntry.MapAction.ADD, fl, permission));
*
*
* The following code snippet shows extracting data from Map.
*
* void decode(Map map)
* {
* switch(map.summaryData().dataType())
* {
* case DataTypes.FIELD_LIST :
* decode(map.summaryData().fieldList());
* break;
* case DataTypes.MAP :
* decode(map.summaryData().map());
* break;
* case DataTypes.REFRESH_MSG :
* decode(map.summaryData().refreshMsg());
* break;
* case DataTypes.UPDATE_MSG :
* decode(map.summaryData().updateMsg());
* break;
* }
*
* for(MapEntry mapEntry : map)
* {
* switch(mapEntry.key().dataType())
* {
* case DataTypes.ASCII :
* System.out.println("Action = " + mapEntry.mapActionAsString() + ", key = " + mapEntry.key().ascii());
* break;
* case DataTypes.BUFFER :
* System.out.println("Action = " + mapEntry.mapActionAsString() + ", key = " + mapEntry.key().buffer());
* break;
* }
*
* switch(mapEntry.loadType())
* {
* case DataTypes.FIELD_LIST :
* decode(mapEntry.fieldList());
* break;
* case DataTypes.MAP :
* decode(mapEntry.map());
* break;
* case DataTypes.REFRESH_MSG :
* decode(mapEntry.refreshMsg());
* break;
* case DataTypes.UPDATE_MSG :
* decode(mapEntry.updateMsg());
* break;
* }
* }
* }
*
*
* Objects of this class are intended to be short lived or rather transitional.
* This class is designed to efficiently perform setting and extracting of Map and its content.
* Objects of this class are not cache-able.
*
* @see Data
* @see ComplexType
* @see ReqMsg
* @see RefreshMsg
* @see UpdateMsg
* @see StatusMsg
* @see GenericMsg
* @see PostMsg
* @see AckMsg
* @see FieldList
* @see ElementList
* @see Map
* @see Vector
* @see Series
* @see FilterList
* @see OmmOpaque
* @see OmmXml
* @see OmmAnsiPage
* @see OmmError
*/
public interface Map extends ComplexType, Collection
{
/**
* Indicates presence of KeyFieldId.
*
* @return true if key field id is set; false otherwise
*/
public boolean hasKeyFieldId();
/**
* Indicates presence of TotalCountHint.
*
* @return true if total count hint is set; false otherwise
*/
public boolean hasTotalCountHint();
/**
* Returns KeyFieldId.
*
* @throws OmmInvalidUsageException
* if hasKeyFieldId() returns false
*
* @return key field id
*/
public int keyFieldId();
/**
* Returns TotalCountHint.
*
* @throws OmmInvalidUsageException
* if hasTotalCountHint() returns false
*
* @return total count hint
*/
public int totalCountHint();
/**
* Returns the contained summaryData Data based on the summaryData DataType.
* SummaryData contains no data if
* {@link com.thomsonreuters.ema.access.SummaryData#dataType()} returns
* {@link com.thomsonreuters.ema.access.DataType.DataTypes#NO_DATA}
*
* @return {@link com.thomsonreuters.ema.access.SummaryData}
*/
public SummaryData summaryData();
/**
* Clears the Map. Invoking clear() method clears all the values and resets
* all the defaults
*/
public void clear();
/**
* Specifies KeyFieldId.
*
* @param fieldId
* specifies key field id
* @return reference to this object
*/
public Map keyFieldId(int fieldId);
/**
* Specifies TotalCountHint.
*
* @param totalCountHint
* specifies total count hint
* @return reference to this object
*/
public Map totalCountHint(int totalCountHint);
/**
* Specifies the SummaryData OMM Data. Call to summaryData() must happen
* prior to calling any add***() method
*
* @throws OmmInvalidUsageException
* if an error is detected (exception will specify the cause of
* the error)
*
* @param summaryData
* specifies complex type as summaryData
* @return reference to this object
*/
public Map summaryData(ComplexType summaryData);
/**
* Specifies a primitive type for Map Entry key. This is used to override the
* default {@link com.thomsonreuters.ema.access.DataType.DataTypes#BUFFER} type.
* Call this method or any add**() method can override the default key type.
*
* @throws OmmInvalidUsageException
* if an error is detected (exception will specify the cause of
* the error)
*
* @param keyPrimitiveType specifies a key primitive type defined in
* {@link com.thomsonreuters.ema.access.DataType.DataTypes}
*
* @return reference to this object
*/
public Map keyType(int keyPrimitiveType);
}