本文整理汇总了C#中com.ximpleware.VTDNav.getStringLength方法的典型用法代码示例。如果您正苦于以下问题:C# VTDNav.getStringLength方法的具体用法?C# VTDNav.getStringLength怎么用?C# VTDNav.getStringLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ximpleware.VTDNav
的用法示例。
在下文中一共展示了VTDNav.getStringLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getStringLen
private int getStringLen(VTDNav vn)
{
if (argCount1 == 0)
{
try
{
if (vn.atTerminal == true)
{
int type = vn.getTokenType(vn.LN);
if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
{
return vn.getStringLength(vn.LN + 1);
}
else
{
return vn.getStringLength(vn.LN);
}
}
else
{
int k = vn.getCurrentIndex2();
// int type = vn.getTokenType(k);
return vn.XPathStringLength(k);
}
}
catch (NavException e)
{
return 0;
}
}
else if (argCount1 == 1)
{
int result = 0;
if (argumentList.e.NodeSet)
{
int a = 0x7fffffff, k = -1;
vn.push2();
int size = vn.contextStack2.size;
try
{
if (argumentList.e.needReordering)
{
argumentList.e.adjust(vn.getTokenCount());
while ((k = argumentList.e.evalNodeSet(vn)) != -1)
{
if (k < a)
a = k; // a is always smaller
}
if (a == 0x7fffffff)
{
a = -1;
}
}
else
{
a = argumentList.e.evalNodeSet(vn);
}
if (a == -1)
result = 0;
else
{
int type = vn.getTokenType(a);
if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS || type == VTDNav.TOKEN_PI_NAME)
{
result = vn.getStringLength(a + 1);
}
else if (type == VTDNav.TOKEN_STARTING_TAG || type == VTDNav.TOKEN_DOCUMENT)
{
result = vn.XPathStringLength(a);
}
else
{
result = vn.getStringLength(a);
}
}
}
catch (VTDException e)
{
}
argumentList.e.reset(vn);
vn.contextStack2.size = size;
vn.pop2();
return result;
}
else
return argumentList.e.evalString(vn).Length;
}
else
{
throw new System.ArgumentException("string-length()'s argument count is invalid");
}
}
示例2: evalNumber
public override double evalNumber(VTDNav vn)
{
int ac = 0;
switch (opCode)
{
case FuncName.LAST: /*if (argCount() != 0)
throw new System.ArgumentException("floor()'s argument count is invalid");*/
return contextSize;
case FuncName.POSITION: /*if (argCount() != 0)
throw new System.ArgumentException("position()'s argument count is invalid");*/
return position;
case FuncName.COUNT: return count(vn);
case FuncName.NUMBER: /*if (argCount() != 1)
throw new System.ArgumentException("number()'s argument count is invalid");*/
return argumentList.e.evalNumber(vn);
case FuncName.SUM: return sum(vn);
case FuncName.FLOOR: /*if (argCount() != 1)
throw new System.ArgumentException("floor()'s argument count is invalid");*/
return System.Math.Floor(argumentList.e.evalNumber(vn));
case FuncName.CEILING: /*if (argCount() != 1)
throw new System.ArgumentException("ceiling()'s argument count is invalid");*/
return System.Math.Ceiling(argumentList.e.evalNumber(vn));
case FuncName.STRING_LENGTH:
//return stringLen
ac = argCount();
if (ac == 0)
{
try
{
if (vn.atTerminal == true)
{
int type = vn.getTokenType(vn.LN);
if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
{
return vn.getStringLength(vn.LN + 1);
}
else
{
return vn.getStringLength(vn.LN);
}
}
else
{
int i = vn.getText();
if (i == -1)
return 0;
else
return vn.getStringLength(i);
}
}
catch (NavException e)
{
return 0;
}
}
else if (ac == 1)
{
return argumentList.e.evalString(vn).Length;
}
else
{
throw new System.ArgumentException("string-length()'s argument count is invalid");
}
//goto case FuncName.ROUND;
case FuncName.ROUND:/* if (argCount() != 1)
throw new System.ArgumentException("round()'s argument count is invalid");*/
//UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangMathround_double'"
return (long)System.Math.Round(argumentList.e.evalNumber(vn));
case FuncName.ABS: /*if (argCount() != 1)
throw new System.ArgumentException("abs()'s argument count is invalid");*/
//UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangMathround_double'"
return (long)System.Math.Abs(argumentList.e.evalNumber(vn));
case FuncName.ROUND_HALF_TO_EVEN:
return roundHalfToEven(vn);
/*int numArg = argCount();
if (numArg < 1 || numArg > 2)
{
throw new System.ArgumentException("Argument count for roundHalfToEven() is invalid. Expected: 1 or 2; Actual: " + numArg);
}
double value = argumentList.e.evalNumber(vn);
int precision = (numArg == 2) ? (int)Math.Floor(argumentList.next.e.evalNumber(vn) + 0.5d) : 0;
return (long)System.Math.Round(value, precision, MidpointRounding.ToEven);*/
case FuncName.ROUND_HALF_TO_ODD:
throw new com.ximpleware.xpath.UnsupportedException("not yet implemented");
//.........这里部分代码省略.........
示例3: evalNumber
public override double evalNumber(VTDNav vn)
{
int ac = 0;
switch (opCode)
{
case FuncName.LAST: if (argCount() != 0)
throw new System.ArgumentException("floor()'s argument count is invalid");
return contextSize;
case FuncName.POSITION: if (argCount() != 0)
throw new System.ArgumentException("position()'s argument count is invalid");
return position;
case FuncName.COUNT: return count(vn);
case FuncName.NUMBER: if (argCount() != 1)
throw new System.ArgumentException("number()'s argument count is invalid");
return argumentList.e.evalNumber(vn);
case FuncName.SUM: return sum(vn);
case FuncName.FLOOR: if (argCount() != 1)
throw new System.ArgumentException("floor()'s argument count is invalid");
return System.Math.Floor(argumentList.e.evalNumber(vn));
case FuncName.CEILING: if (argCount() != 1)
throw new System.ArgumentException("ceiling()'s argument count is invalid");
return System.Math.Ceiling(argumentList.e.evalNumber(vn));
case FuncName.STRING_LENGTH:
ac = argCount();
if (ac == 0)
{
try
{
if (vn.atTerminal == true)
{
int type = vn.getTokenType(vn.LN);
if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
{
return vn.getStringLength(vn.LN + 1);
}
else
{
return vn.getStringLength(vn.LN);
}
}
else
{
int i = vn.getText();
if (i == - 1)
return 0;
else
return vn.getStringLength(i);
}
}
catch (NavException e)
{
return 0;
}
}
else if (ac == 1)
{
return argumentList.e.evalString(vn).Length;
}
else
{
throw new System.ArgumentException("string-length()'s argument count is invalid");
}
//goto case FuncName.ROUND;
case FuncName.ROUND: if (argCount() != 1)
throw new System.ArgumentException("round()'s argument count is invalid");
//UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangMathround_double'"
return (long) System.Math.Round(argumentList.e.evalNumber(vn));
default: if (isBoolean_Renamed_Field)
{
if (evalBoolean(vn))
return 1;
else
return 0;
}
else
{
return System.Double.Parse(evalString(vn));
}
//break;
}
}