本文整理汇总了C#中com.ximpleware.VTDNav.getTokenLength方法的典型用法代码示例。如果您正苦于以下问题:C# VTDNav.getTokenLength方法的具体用法?C# VTDNav.getTokenLength怎么用?C# VTDNav.getTokenLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ximpleware.VTDNav
的用法示例。
在下文中一共展示了VTDNav.getTokenLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getLocalName
private String getLocalName(VTDNav vn)
{
if (argCount1 == 0)
{
try
{
int index = vn.getCurrentIndex();
int type = vn.getTokenType(index);
if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
|| type == VTDNav.TOKEN_ATTR_NAME))
{
int offset = vn.getTokenOffset(index);
int length = vn.getTokenLength(index);
if (length < 0x10000)
{
if (vn.localNameIndex != index)
{
vn.localNameIndex = index;
vn.localName = vn.toRawString(index);
}
return vn.localName;
}
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
{
if (vn.localNameIndex != index)
{
vn.localNameIndex = index;
vn.localName = vn.toRawString(offset + preLen + 1, QLen
- preLen - 1);
}
return vn.localName;
}
else
{
if (vn.localNameIndex != index)
{
vn.localNameIndex = index;
vn.localName = vn.toRawString(offset, QLen);
}
return vn.localName;
}
}
}
else
return "";
}
catch (NavException e)
{
return ""; // this will almost never occur
}
}
else if (argCount1 == 1)
{
int a = evalFirstArgumentListNodeSet2(vn);
if (a == -1 || vn.ns == false)
return "";
int type = vn.getTokenType(a);
if (type == VTDNav.TOKEN_STARTING_TAG || type == VTDNav.TOKEN_ATTR_NAME)
{
try
{
int offset = vn.getTokenOffset(a);
int length = vn.getTokenLength(a);
if (length < 0x10000)
return vn.toRawString(a);
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
return vn.toRawString(offset + preLen + 1,
QLen - preLen - 1);
else
{
return vn.toRawString(offset, QLen);
}
}
}
catch (NavException e)
{
return ""; // this will almost never occur
}
}
else if (type == VTDNav.TOKEN_PI_NAME)
{
try
{
return vn.toRawString(a);
}
catch (NavException e)
{
return "";
//.........这里部分代码省略.........
示例2: matchLocalName
private bool matchLocalName(VTDNav vn)
{
if (argCount1 == 1)
{
try
{
int index = vn.getCurrentIndex();
int type = vn.getTokenType(index);
String s1 = argumentList.e.evalString(vn);
if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
|| type == VTDNav.TOKEN_ATTR_NAME))
{
int offset = vn.getTokenOffset(index);
int length = vn.getTokenLength(index);
if (length < 0x10000 || (length >> 16) == 0)
{
return (vn.compareRawTokenString(index, s1) == 0);//vn.toRawString(index);
}
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
{
return (vn.compareRawTokenString(offset + preLen + 1, QLen
- preLen - 1, s1) == 0);
}
}
}
else if (type == VTDNav.TOKEN_PI_NAME)
{
return vn.compareRawTokenString(index, s1) == 0;
}
else
return "".Equals(s1);
}
catch (NavException e)
{
return false; // this will never occur
}
}
else if (argCount1 == 2)
{
int a = evalFirstArgumentListNodeSet2(vn);
String s1 = argumentList.next.e.evalString(vn);
if (a == -1 || vn.ns == false)
return "".Equals(s1);
int type = vn.getTokenType(a);
if (type == VTDNav.TOKEN_STARTING_TAG || type == VTDNav.TOKEN_ATTR_NAME)
{
//return "".equals(s1);
try
{
int offset = vn.getTokenOffset(a);
int length = vn.getTokenLength(a);
if (length < 0x10000 || (length >> 16) == 0)
return vn.compareRawTokenString(a, s1) == 0;
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
return vn.compareRawTokenString(offset + preLen + 1,
QLen - preLen - 1, s1) == 0;
/*else {
return vn.toRawString(offset, QLen);
}*/
}
}
catch (NavException e)
{
return "".Equals(s1); // this will almost never occur
}
}
else if (type == VTDNav.TOKEN_PI_NAME)
{
try
{
return vn.compareRawTokenString(a, s1) == 0;
}
catch (NavException e)
{
return "".Equals(s1);
}
}
return "".Equals(s1);
}
else
throw new ArgumentException
("match-local-name()'s argument count is invalid");
return false;
}
示例3: compareTokens
/// <summary>
/// <em>New in 2.0</em>
/// This method compares two VTD tokens of VTDNav objects
/// The behavior of this method is like compare the strings corresponds
/// to i1 and i2
/// </summary>
/// <param name="i"></param>
/// <param name="vn2"></param>
/// <param name="i2"></param>
/// <returns></returns>
public int compareTokens(int i1, VTDNav vn2, int i2)
{
int t1, t2;
int ch1, ch2;
int endOffset1, endOffset2;
long l;
if (i1 == i2 && this == vn2)
return 0;
t1 = this.getTokenType(i1);
t2 = vn2.getTokenType(i2);
int offset1 = this.getTokenOffset(i1);
int offset2 = vn2.getTokenOffset(i2);
int len1 =
(t1 == TOKEN_STARTING_TAG
|| t1 == TOKEN_ATTR_NAME
|| t1 == TOKEN_ATTR_NS)
? getTokenLength(i1) & 0xffff
: getTokenLength(i1);
int len2 =
(t2 == TOKEN_STARTING_TAG
|| t2 == TOKEN_ATTR_NAME
|| t2 == TOKEN_ATTR_NS)
? vn2.getTokenLength(i2) & 0xffff
: vn2.getTokenLength(i2);
endOffset1 = len1 + offset1;
endOffset2 = len2 + offset2;
for (; offset1 < endOffset1 && offset2 < endOffset2; )
{
if (t1 == VTDNav.TOKEN_CHARACTER_DATA
|| t1 == VTDNav.TOKEN_ATTR_VAL)
{
l = this.getCharResolved(offset1);
}
else
{
l = this.getChar(offset1);
}
ch1 = (int)l;
offset1 += (int)(l >> 32);
if (t2 == VTDNav.TOKEN_CHARACTER_DATA
|| t2 == VTDNav.TOKEN_ATTR_VAL)
{
l = vn2.getCharResolved(offset2);
}
else
{
l = vn2.getChar(offset2);
}
ch2 = (int)l;
offset2 += (int)(l >> 32);
if (ch1 > ch2)
return 1;
if (ch1 < ch2)
return -1;
}
if (offset1 == endOffset1
&& offset2 < endOffset2)
return -1;
else if (offset1 < endOffset1
&& offset2 == endOffset2)
return 1;
else
return 0;
}
示例4: XPathStringVal_Matches
/// <summary>
///
/// </summary>
/// <param name="j"></param>
/// <param name="vn2"></param>
/// <param name="k"></param>
/// <returns></returns>
protected internal int XPathStringVal_Matches(int j, VTDNav vn2, int k /*k is a token index */) {
if (h1==null){
h1 = new helper();
}
if (h2==null){
h2 = new helper();
}
int tokenType1 = getTokenType(j);
int tokenType2 = vn2.getTokenType(k);
if (tokenType1 == VTDNav.TOKEN_STARTING_TAG || tokenType1 == VTDNav.TOKEN_DOCUMENT ){
h1.index = j + 1;
h1.type = 1;
h1.depth = getTokenDepth(j);
h1.offset = -1;
while (h1.index < vtdSize) {
int tokenType = getTokenType(h1.index);
int depth = getTokenDepth(h1.index);
//t=t+getTokenLength2(index);
if (depth<h1.depth ||
(depth==h1.depth && tokenType==VTDNav.TOKEN_STARTING_TAG)){
break;
}
if (tokenType==VTDNav.TOKEN_CHARACTER_DATA
|| tokenType==VTDNav.TOKEN_CDATA_VAL){
//length = getTokenLength2(index);
//t += length;
//fib.append(index);
h1.offset = getTokenOffset(h1.index);
h1.endOffset = getTokenOffset(h1.index)+getTokenLength2(h1.index);
//h1.index++;
h1.tokenType=tokenType;
goto loop11;
//
} else if (tokenType==VTDNav.TOKEN_ATTR_NAME
|| tokenType == VTDNav.TOKEN_ATTR_NS
|| tokenType == VTDNav.TOKEN_PI_NAME){
h1.index = h1.index+2;
continue;
}
h1.index++;
}
loop11:
;
}
else{
h1.index = -1;
h1.type = 0;
h1.offset = getTokenOffset(j);
h1.endOffset = getTokenOffset(j)+getTokenLength(j);
h1.tokenType = getTokenType(j);
}
if (tokenType2 == VTDNav.TOKEN_STARTING_TAG || tokenType2 == VTDNav.TOKEN_DOCUMENT ){
h2.index = k + 1;
h2.type = 1;
h2.depth = vn2.getTokenDepth(k);
h2.offset = -1;
while (h2.index < vtdSize) {
int tokenType = vn2.getTokenType(h2.index);
int depth = vn2.getTokenDepth(h2.index);
//t=t+getTokenLength2(index);
if (depth<h2.depth ||
(depth==h2.depth && tokenType==VTDNav.TOKEN_STARTING_TAG)){
break;
}
if (tokenType==VTDNav.TOKEN_CHARACTER_DATA
|| tokenType==VTDNav.TOKEN_CDATA_VAL){
//length = getTokenLength2(index);
//t += length;
//fib.append(index);
h2.offset = vn2.getTokenOffset(h2.index);
h2.endOffset = vn2.getTokenOffset(h2.index)+vn2.getTokenLength2(h2.index);
h2.tokenType = tokenType;
//h2.index++;
goto loop22;
//
} else if (tokenType==VTDNav.TOKEN_ATTR_NAME
|| tokenType == VTDNav.TOKEN_ATTR_NS
|| tokenType == VTDNav.TOKEN_PI_NAME){
h2.index = h2.index+2;
continue;
}
h2.index++;
}
loop22:
;
}
else{
//.........这里部分代码省略.........
示例5: getLocalName
private String getLocalName(VTDNav vn)
{
if (argCount() == 0)
{
try
{
int index = vn.getCurrentIndex();
int type = vn.getTokenType(index);
if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
|| type == VTDNav.TOKEN_ATTR_NAME))
{
long offset = vn.getTokenOffset(index);
int length = vn.getTokenLength(index);
if (length < 0x10000)
return vn.toRawString(index);
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
return vn.toRawString(offset + preLen + 1, QLen
- preLen - 1);
else
{
return vn.toRawString(offset, QLen);
}
}
}
else
return "";
}
catch (NavException e)
{
return ""; // this will almost never occur
}
} else if (argCount() == 1)
{
int a = -1;
vn.push2();
try
{
a = argumentList.e.evalNodeSet(vn);
argumentList.e.reset(vn);
vn.pop2();
}
catch (Exception e)
{
argumentList.e.reset(vn);
vn.pop2();
}
if (a == -1 || vn.ns == false)
return "";
int type = vn.getTokenType(a);
if (type != VTDNav.TOKEN_STARTING_TAG && type != VTDNav.TOKEN_ATTR_NAME)
return "";
try
{
long offset = vn.getTokenOffset(a);
int length = vn.getTokenLength(a);
if (length < 0x10000)
return vn.toRawString(a);
else
{
int preLen = length >> 16;
int QLen = length & 0xffff;
if (preLen != 0)
return vn.toRawString(offset + preLen + 1,
QLen - preLen - 1);
else
{
return vn.toRawString(offset, QLen);
}
}
}
catch (NavException e)
{
return ""; // this will almost never occur
}
}
else
throw new System.ArgumentException
("local-name()'s argument count is invalid");
}