本文整理了Java中com.thomsonreuters.upa.codec.Vector
类的一些代码示例,展示了Vector
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector
类的具体详情如下:
包路径:com.thomsonreuters.upa.codec.Vector
类名称:Vector
[英]The Vector is a uniform container type of index-value pair entries. Each entry, known as a VectorEntry, contains an index, correlating to the entry's position in the information stream and value. A Vector can contain zero to N entries (zero entries indicates an empty Vector).
Vector Encoding Example
The following sample demonstrates how to encode a Vector containing Series values. The example encodes three VectorEntry values as well as summary data:
The first entry is encoded from an unencoded series
The second entry is encoded from a buffer containing a pre-encoded series and has perm data
The third is a clear action type with no payload.
This example demonstrates error handling for the initial encode method. To simplify the example, additional error handling is omitted (though it should be performed).
// populate vector structure prior to call to vector.encodeInit()
// indicate that summary data and a total count hint will be encoded
vector.flags(VectorFlags.HAS_SUMMRAY_DATA | VectorFlags.HAS_TOTAL_COUNT | VectorFlags.HAS_PER_ENTRY_PERM_DATA);
// populate containerType and total count hint
vector.containerType(DataTypes.SERIES);
vector.totalCountHint(3);
// begin encoding of vector - assumes that encIter is already populated with
// buffer and version information, store return value to determine success or
// failure
if ((retVal = vector.encodeInit(encIter, 50, 0)) < CodecReturnCodes.SUCCESS)
{
// error condition - switch our success value to false so we can roll back
success = false;
}
else
{
// vector init encoding was successful
// create a single VectorEntry and Series and reuse for each entry
VectorEntry vectorEntry = CodecFactory.createVectorEntry();
Series series = CodecFactory.createSeries();
// encode expected summary data, init for this was done by
// vector.encodeInit - this type should match vector.containerType
{
// now encode nested container using its own specific encode methods
// begin encoding of series - using same encIterator as vector
retVal = series.encodeInit(encIter, 0, 0);
{
// ----- Continue encoding series entries, see Series encoding
// example -----
// Complete nested container encoding
retVal = series.encodeComplete(encIter, success);
}
// complete encoding of summary data. If any series entry encoding
// failed, success is false
retVal = vector.encodeSummaryComplete(encIter, success);
// FIRST Vector Entry: encode entry from unencoded data. Approx. encoded
// length 90 bytes
//populate index and action, no perm data on this entry
vectorEntry.index(1);
vectorEntry.flags(VectorEntryFlags.NONE);
vectorEntry.action(VectorEntryActions.UPDATE);
retVal = vectorEntry.encodeInit(encIter, 90);
//encode contained series - this type should match vector.containerType
{
//now encode nested container using its own specific encode methods
//clear, then begin encoding of series - using same encIterator as vector
series.clear();
retVal = series.encodeInit(encIter, 0, 0);
//-----Continue encoding series entries. See example in Series ---
retVal = series.encodeComplete(encIter, success);
}
//SECOND Vector Entry: encode entry from pre-encoded buffer containing an encoded Series
//assuming pEncSeries Buffer contains the pre-encoded payload with data and length populated
//and pPermData contains permission data information
vectorEntry.index(2);
//by passing permData on an entry, the map encoding functionality will implicitly set the
//Vector.HAS_PER_ENTRY_PERM flag
vectorEntry.flags(VectorEntryFlags.HAS_PERM_DATA);
vectorEntry.action(VectorEntryActions.SET);
vectorEntry.permData(permData);
vectorEntry.encodedData(encSeries);
retVal = vectorEntry.encode(encIter);
//THIRD Vector Entry: encode entry with clear action, no payload on clear
//Should clear entry for safety, this will set flags to NONE
vectorEntry.clear();
vectorEntry.index(3);
vectorEntry.action(VectorEntryFlags.CLEAR);
retVal = vectorEntry.encode(encIter);
}
//complete vector encoding. If success parameter is true, this will finalize encoding.
//If success parameter is false, this will roll back encoding prior to vector.encodeInit();
retVal = vector.encodeComplete(encIter, success);
Vector decoding example
The following sample illustrates how to decode a Vector and is structured to decode each entry to the contained value. This sample code assumes the housed container type is a Series. Typically an application would invoke the specific container type decoder for the housed type or use a switch statement to allow a more generic series entry decoder. This example uses the same DecodeIterator when calling the content's decoder method. Optionally, an application could use a new DecodeIterator by setting the encData on a new iterator. To simplify the sample, some error handling is omitted.
//decode contents into the vector//decode each vector entry until there are no more left
while((retVal = vectorEntry.decode(decIter)) != CodecReturnCodes.END_OF_CONTAINER)
if(retVal < CodecReturnCodes.SUCCESS)
//decoding failure tends to be unrecoverable
}
else
Series series = CodecFactory.createSeries();
retVal = series.decode(decIter);
//Continue decoding series entries, see Series decoding example
}
}
}
else
//decoding failure tends to be unrecoverable
}
}
[中]向量是索引值对条目的统一容器类型。每个条目(称为VectorEntry)都包含一个索引,与该条目在信息流中的位置和值相关。一个向量可以包含0到N个条目(零个条目表示一个空向量)。
矢量编码示例
下面的示例演示如何对包含系列值的向量进行编码。该示例对三个矢量输入值以及摘要数据进行编码:
*第一个条目是从未编码的序列中编码的
*第二个条目从包含预编码序列的缓冲区编码,并具有perm数据
*第三种是无有效载荷的清晰动作类型。
这个例子演示了初始编码方法的错误处理。为了简化示例,省略了额外的错误处理(尽管应该执行)。
*
// populate vector structure prior to call to vector.encodeInit()
// indicate that summary data and a total count hint will be encoded
vector.flags(VectorFlags.HAS_SUMMRAY_DATA | VectorFlags.HAS_TOTAL_COUNT | VectorFlags.HAS_PER_ENTRY_PERM_DATA);
// populate containerType and total count hint
vector.containerType(DataTypes.SERIES);
vector.totalCountHint(3);
// begin encoding of vector - assumes that encIter is already populated with
// buffer and version information, store return value to determine success or
// failure
if ((retVal = vector.encodeInit(encIter, 50, 0)) < CodecReturnCodes.SUCCESS)
{
// error condition - switch our success value to false so we can roll back
success = false;
}
else
{
// vector init encoding was successful
// create a single VectorEntry and Series and reuse for each entry
VectorEntry vectorEntry = CodecFactory.createVectorEntry();
Series series = CodecFactory.createSeries();
// encode expected summary data, init for this was done by
// vector.encodeInit - this type should match vector.containerType
{
// now encode nested container using its own specific encode methods
// begin encoding of series - using same encIterator as vector
retVal = series.encodeInit(encIter, 0, 0);
{
// ----- Continue encoding series entries, see Series encoding
// example -----
// Complete nested container encoding
retVal = series.encodeComplete(encIter, success);
}
// complete encoding of summary data. If any series entry encoding
// failed, success is false
retVal = vector.encodeSummaryComplete(encIter, success);
// FIRST Vector Entry: encode entry from unencoded data. Approx. encoded
// length 90 bytes
//populate index and action, no perm data on this entry
vectorEntry.index(1);
vectorEntry.flags(VectorEntryFlags.NONE);
vectorEntry.action(VectorEntryActions.UPDATE);
retVal = vectorEntry.encodeInit(encIter, 90);
//encode contained series - this type should match vector.containerType
{
//now encode nested container using its own specific encode methods
//clear, then begin encoding of series - using same encIterator as vector
series.clear();
retVal = series.encodeInit(encIter, 0, 0);
//-----Continue encoding series entries. See example in Series ---
retVal = series.encodeComplete(encIter, success);
}
//SECOND Vector Entry: encode entry from pre-encoded buffer containing an encoded Series
//assuming pEncSeries Buffer contains the pre-encoded payload with data and length populated
//and pPermData contains permission data information
vectorEntry.index(2);
//by passing permData on an entry, the map encoding functionality will implicitly set the
//Vector.HAS_PER_ENTRY_PERM flag
vectorEntry.flags(VectorEntryFlags.HAS_PERM_DATA);
vectorEntry.action(VectorEntryActions.SET);
vectorEntry.permData(permData);
vectorEntry.encodedData(encSeries);
retVal = vectorEntry.encode(encIter);
//THIRD Vector Entry: encode entry with clear action, no payload on clear
//Should clear entry for safety, this will set flags to NONE
vectorEntry.clear();
vectorEntry.index(3);
vectorEntry.action(VectorEntryFlags.CLEAR);
retVal = vectorEntry.encode(encIter);
}
//complete vector encoding. If success parameter is true, this will finalize encoding.
//If success parameter is false, this will roll back encoding prior to vector.encodeInit();
retVal = vector.encodeComplete(encIter, success);
矢量解码示例
下面的示例演示了如何对向量进行解码,并将每个条目解码为包含的值。此示例代码假定封装的容器类型是一个系列。通常,应用程序会为封装的类型调用特定的容器类型解码器,或者使用switch语句来允许更通用的序列条目解码器。本例在调用内容的解码器方法时使用相同的DecodeIterator。或者,应用程序可以通过在新迭代器上设置encData来使用新的DecodeIterator。为了简化示例,省略了一些错误处理。
*
//decode contents into the vector//decode each vector entry until there are no more left
while((retVal = vectorEntry.decode(decIter)) != CodecReturnCodes.END_OF_CONTAINER)
if(retVal < CodecReturnCodes.SUCCESS)
//decoding failure tends to be unrecoverable
}
else
Series series = CodecFactory.createSeries();
retVal = series.decode(decIter);
//Continue decoding series entries, see Series decoding example
}
}
}
else
//decoding failure tends to be unrecoverable
}
}
代码示例来源:origin: Refinitiv/Elektron-SDK
retCode = _rsslVector.decode(_rsslDecodeIter);
switch (retCode)
_rsslVector.flags(0);
_fillCollection = false;
clearCollection();
if (_rsslVector.checkHasSetDefs())
switch (_rsslVector.containerType())
_rsslLocalSetDefDb = null;
int rsslContainerType = _rsslVector.checkHasSummaryData() ? _rsslVector.containerType() : com.thomsonreuters.upa.codec.DataTypes.NO_DATA;
int dType = dataType(rsslContainerType, _rsslMajVer, _rsslMinVer, _rsslVector.encodedSummaryData());
_summaryDecoded = dataInstance(_summaryDecoded, dType);
_summaryDecoded.decode(_rsslVector.encodedSummaryData(), _rsslMajVer, _rsslMinVer, _rsslDictionary, _rsslLocalSetDefDb);
代码示例来源:origin: Refinitiv/Elektron-SDK
vector.flags(VectorFlags.HAS_TOTAL_COUNT_HINT | VectorFlags.HAS_SUMMARY_DATA);
vector.containerType(DataTypes.ELEMENT_LIST);
vector.totalCountHint(1);
if ((retVal = vector.encodeInit(encIter, 128, 0)) < CodecReturnCodes.SUCCESS)
if ((retVal = vector.encodeSummaryDataComplete(encIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = vector.encodeComplete(encIter, true)) < CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
@Override
public void clear()
{
_summaryDataTypeSet = false;
_summaryDataType = com.thomsonreuters.upa.codec.DataTypes.NO_DATA;
if (_rsslEncodeIter != null)
{
super.clear();
_rsslVector.clear();
_vectorCollection.clear();
}
else
clearCollection();
}
代码示例来源:origin: Refinitiv/Elektron-SDK
@Override
public Vector totalCountHint(int totalCountHint)
{
if (totalCountHint < 0 || totalCountHint > 1073741823)
throw ommOORExcept().message("totalCountHint is out of range [0 - 1073741823].");
_rsslVector.applyHasTotalCountHint();
_rsslVector.totalCountHint(totalCountHint);
return this;
}
代码示例来源:origin: Refinitiv/Elektron-SDK
xmlString.append("<vector flags=\"0x" + String.format("%02X", vec.flags()));
if (vec.flags() != 0)
xmlString.append(" (");
if (vec.checkHasSetDefs())
if (vec.checkHasSummaryData())
xmlString.append("HAS_SUMMARY_DATA");
if (vec.checkHasPerEntryPermData())
xmlString.append("HAS_PER_ENTRY_PERM_DATA");
if (vec.checkHasTotalCountHint())
xmlString.append("HAS_TOTAL_COUNT_HINT");
if (vec.checkSupportsSorting())
if (vec.flags() != 0)
xmlString.append(")");
xmlString.append("\"");
xmlString.append(" countHint=\"" + vec.totalCountHint() + "\" containerType=\"");
xmlString.append(xmlDumpDataType(vec.containerType()));
xmlString.append("\">\n");
代码示例来源:origin: Refinitiv/Elektron-SDK
@Override
public Vector summaryData(ComplexType summaryData)
{
if (summaryData == null)
throw ommIUExcept().message("Passed in summaryData is null");
_summaryDataType = summaryData.dataType();
_summaryDataTypeSet = true;
_rsslVector.applyHasSummaryData();
Utilities.copy(((DataImpl) summaryData).encodedData(), _rsslVector.encodedSummaryData());
return this;
}
代码示例来源:origin: Refinitiv/Elektron-SDK
vector.applyHasPerEntryPermData();
vector.applyHasTotalCountHint();
vector.applySupportsSorting();
vector.applyHasSummaryData();
vector.applyHasSetDefs();
vector.totalCountHint(5);
((VectorImpl)vector).encodedEntries(txt);
vector.encodedSetDefs(txt);
vector.encodedSummaryData(txt);
vector.containerType(DataTypes.FIELD_LIST);
assertTrue(vector.encodeInit(iter, 0, 0) == CodecReturnCodes.SUCCESS);
assertTrue(vector.encodeComplete(iter, true) == CodecReturnCodes.SUCCESS);
assertTrue(vector.encodeInit(iter, 0, 0) == CodecReturnCodes.SUCCESS);
assertTrue(vector.encodeComplete(iter, false) == CodecReturnCodes.SUCCESS);
assertEquals(0, buf.data().position());
代码示例来源:origin: Refinitiv/Elektron-SDK
vector.clear();
vector.applyHasSetDefs();
vector.applyHasSummaryData();
vector.applyHasTotalCountHint();
vector.totalCountHint(3);
bufferSizeNeeded += 4;
vector.containerType(innerContainerType);
preEncodeIter.setBufferAndRWFVersion(preEncodeBuffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.SUCCESS, containerOverrunTest_encodeFieldSetDb(preEncodeIter, setDb));
vector.encodedSetDefs(preEncodeBuffer);
break;
assertEquals(CodecReturnCodes.SUCCESS, containerOverrunTest_writeOpaqueByteBuffer(payloadEncodedSize, expectedOpaqueData, preEncSetDefByteBuf));
preEncSetDefByteBuf.flip();
vector.encodedSetDefs().data(preEncSetDefByteBuf);
break;
preEncodeIter.setBufferAndRWFVersion(preEncodeBuffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.SUCCESS, containerOverrunTest_encodeFieldList(preEncodeIter, sizeIndex, (setDefsEncodeMethod != ContainerOverrunTest_EncodeMethod.NONE) ? setDb : null));
vector.encodedSummaryData(preEncodeBuffer);
break;
assertEquals(CodecReturnCodes.SUCCESS, containerOverrunTest_writeOpaqueByteBuffer(payloadEncodedSize, expectedOpaqueData, preEncSummaryDataByteBuf));
preEncSummaryDataByteBuf.flip();
代码示例来源:origin: Refinitiv/Elektron-SDK
encVector.clear();
encVector.applyHasSetDefs();
encVector.applyHasSummaryData();
encVector.containerType(DataTypes.ELEMENT_LIST);
if ((ret = encVector.encodeInit(iter, 0, 0)) < CodecReturnCodes.SUCCESS)
if ((ret = encVector.encodeSetDefsComplete(iter, true)) < CodecReturnCodes.SUCCESS)
if ((ret = encVector.encodeSummaryDataComplete(iter, true)) < CodecReturnCodes.SUCCESS)
if ((ret = encVector.encodeComplete(iter, true)) < CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
assertEquals(CodecReturnCodes.SUCCESS, vector.decode(dIter));
assertEquals(true, vector.checkHasPerEntryPermData());
assertEquals(true, vector.checkHasSetDefs());
assertEquals(true, vector.checkHasSummaryData());
assertEquals(true, vector.checkHasTotalCountHint());
assertEquals(true, vector.checkSupportsSorting());
assertEquals(DataTypes.FIELD_LIST, vector.containerType());
assertEquals(2, vector.totalCountHint());
assertEquals("000000001111111122222222", vector.encodedSetDefs().toString());
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", vector.encodedSummaryData().toString());
bb.limit(bb.capacity());
buffer.data(bb, 0 , 77);
vector.clear();
vectorEntry.clear();
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(),
Codec.minorVersion()));
assertEquals(CodecReturnCodes.SUCCESS, vector.decode(dIter));
assertEquals(CodecReturnCodes.INCOMPLETE_DATA, vectorEntry.decode(dIter));
bb.limit(77);
buffer.data(bb, 0 , 77);
vector.clear();
vectorEntry.clear();
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(),
代码示例来源:origin: Refinitiv/Elektron-SDK
upaVector.containerType(containerType);
upaVector.applyHasTotalCountHint();
upaVector.totalCountHint(totalCountHint);
upaVector.applyHasSummaryData();
if ((retVal = upaVector.encodeInit(encodeIter, 0, 0) ) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeSummaryDataComplete(encodeIter, success)) < CodecReturnCodes.SUCCESS)
if ((retVal = upaVector.encodeComplete(encodeIter, true) ) < CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
vector.clear();
vector.containerType(DataTypes.ELEMENT_LIST);
vector.flags(VectorFlags.HAS_SUMMARY_DATA);
ret = vector.encodeInit(encodeIter, 0, 0);
if (ret != CodecReturnCodes.SUCCESS)
ret = vector.encodeSummaryDataComplete(encodeIter, true);
if (ret != CodecReturnCodes.SUCCESS)
ret = vector.encodeComplete(encodeIter, true);
if (ret != CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.NO_DATA, vector.decode(dIter));
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.INCOMPLETE_DATA, vector.decode(dIter));
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.SUCCESS, vector.decode(dIter));
assertEquals(false, vector.checkHasSetDefs());
assertEquals(false, vector.checkHasSummaryData());
assertEquals(false, vector.checkHasTotalCountHint());
assertEquals(DataTypes.FIELD_LIST, vector.containerType());
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.INCOMPLETE_DATA, vector.decode(dIter));
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.INCOMPLETE_DATA, vector.decode(dIter));
assertEquals(true, vector.checkHasSummaryData());
dIter.clear();
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.INCOMPLETE_DATA, vector.decode(dIter));
代码示例来源:origin: Refinitiv/Elektron-SDK
eIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
vec.containerType(DataTypes.OPAQUE);
assertEquals(CodecReturnCodes.SUCCESS, vec.encodeInit(eIter, 0, 0));
assertEquals(CodecReturnCodes.SUCCESS, vec.encodeComplete(eIter, true));
dIter.setBufferAndRWFVersion(buffer, Codec.majorVersion(), Codec.minorVersion());
assertEquals(CodecReturnCodes.SUCCESS, vec.decode(dIter));
assertEquals(DataTypes.OPAQUE, vec.containerType());
代码示例来源:origin: Refinitiv/Elektron-SDK
_rsslVector.containerType(entryType);
_rsslVector.containerType(entryType);
_rsslVector.containerType(Utilities.toRsslDataType(firstEntry.loadType()));
while ((ret = _rsslVector.encodeInit(_rsslEncodeIter, 0, 0)) == CodecReturnCodes.BUFFER_TOO_SMALL)
ret = _rsslVector.encodeComplete(_rsslEncodeIter, true);
if (ret != CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
if ((retVal = vector.decode(decIter)) < CodecReturnCodes.SUCCESS)
return retVal;
System.out.printf("\tVector Header Decoded: TotalCountHint: %d\n", vector.totalCountHint());
if(vector.checkHasSummaryData()) {
代码示例来源:origin: Refinitiv/Elektron-SDK
vector.clear();
ret = vector.decode(dIter);
if (ret != CodecReturnCodes.SUCCESS
&& ret != CodecReturnCodes.BLANK_DATA)
if (vector.checkHasSetDefs())
vector.clear();
ret = vector.decode(dIter);
if (ret != CodecReturnCodes.SUCCESS
&& ret != CodecReturnCodes.BLANK_DATA)
if (vector.checkHasSetDefs())
代码示例来源:origin: Refinitiv/Elektron-SDK
&& (vector.containerType() != DataTypes.NO_DATA))
代码示例来源:origin: Refinitiv/Elektron-SDK
if (finishedSet == true)
if ((ret = encVector.encodeComplete(iter, true)) < CodecReturnCodes.SUCCESS)
代码示例来源:origin: Refinitiv/Elektron-SDK
if ((vector.checkHasPerEntryPermData()) && (vectorEntry.checkHasPermData()))
&& (vector.containerType() != DataTypes.NO_DATA))
内容来源于网络,如有侵权,请联系作者删除!