本文整理汇总了Java中com.igormaznitsa.jbbp.io.JBBPBitInputStream.getCounter方法的典型用法代码示例。如果您正苦于以下问题:Java JBBPBitInputStream.getCounter方法的具体用法?Java JBBPBitInputStream.getCounter怎么用?Java JBBPBitInputStream.getCounter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.igormaznitsa.jbbp.io.JBBPBitInputStream
的用法示例。
在下文中一共展示了JBBPBitInputStream.getCounter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.igormaznitsa.jbbp.io.JBBPBitInputStream; //导入方法依赖的package包/类
/**
* Parse am input stream with defined external value provider.
*
* @param in an input stream which content will be parsed, it must not be null
* @param varFieldProcessor a var field processor, it may be null if there is
* not any var field in a script, otherwise NPE will be thrown during parsing
* @param externalValueProvider an external value provider, it can be null but
* only if the script doesn't have fields desired the provider
* @return the parsed content as the root structure
* @throws IOException it will be thrown for transport errors
*/
public JBBPFieldStruct parse(final InputStream in, final JBBPVarFieldProcessor varFieldProcessor, final JBBPExternalValueProvider externalValueProvider) throws IOException {
final JBBPBitInputStream bitInStream = in instanceof JBBPBitInputStream ? (JBBPBitInputStream) in : new JBBPBitInputStream(in, bitOrder);
this.finalStreamByteCounter = bitInStream.getCounter();
final JBBPNamedNumericFieldMap fieldMap;
if (this.compiledBlock.hasEvaluatedSizeArrays() || this.compiledBlock.hasVarFields()) {
fieldMap = new JBBPNamedNumericFieldMap(externalValueProvider);
} else {
fieldMap = null;
}
if (this.compiledBlock.hasVarFields()) {
JBBPUtils.assertNotNull(varFieldProcessor, "The Script contains VAR fields, a var field processor must be provided");
}
try {
return new JBBPFieldStruct(new JBBPNamedFieldInfo("", "", -1), parseStruct(bitInStream, new JBBPIntCounter(), varFieldProcessor, fieldMap, new JBBPIntCounter(), new JBBPIntCounter(), false));
} finally {
this.finalStreamByteCounter = bitInStream.getCounter();
}
}
示例2: eval
import com.igormaznitsa.jbbp.io.JBBPBitInputStream; //导入方法依赖的package包/类
@Override
public int eval(final JBBPBitInputStream inStream, final int currentCompiledBlockOffset, final JBBPCompiledBlock block, final JBBPNamedNumericFieldMap fieldMap) {
return externalFieldName == null
? fieldMap.get(block.getNamedFields()[this.namedFieldIndex]).getAsInt()
: this.externalFieldName.equals("$")
? (int) inStream.getCounter()
: fieldMap.getExternalFieldValue(this.externalFieldName, block, this);
}