getTokenType() public method

Get the token type of the token at the given index value. Creation date: (11/16/03 6:41:51 PM)
///
public getTokenType ( int index ) : int
index int int ///
return int
Example #1
0
        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");
        }
Example #2
0
        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");

                default: if (isBoolean_Renamed_Field)
                    {
                        if (evalBoolean(vn))
                            return 1;
                        else
                            return 0;
                    }
                    else
                    {
                        try
                        {
                            double dval = System.Double.Parse(evalString(vn));
                            return dval;
                        }
                        catch (System.FormatException e)
                        {
                            return System.Double.NaN;
                        }
                        //return System.Double.Parse(evalString(vn));
                    }
                //break;

            }
        }
Example #3
0
        public override System.String evalString(VTDNav vn)
        {
            String s = "";
            int a = -1;
            vn.push2();
            int size = vn.contextStack2.size;
            try
            {
                a = evalNodeSet(vn);
                if (a != -1)
                {
                    int t = vn.getTokenType(a);
                    switch (t)
                    {
                        case VTDNav.TOKEN_STARTING_TAG:
                        case VTDNav.TOKEN_DOCUMENT:
                            s = vn.getXPathStringVal2(a,(short)0);
                            break;
                        case VTDNav.TOKEN_ATTR_NAME:
                            s = vn.toString(a + 1);
                            break;
                        case VTDNav.TOKEN_PI_NAME:
                            //if (a + 1 < vn.vtdSize
                            //		|| vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                            s = vn.toString(a + 1);
                            break;
                        default:
                            s = vn.toString(a);
                            break;
                    }
                }
            }
            catch (Exception e)
            {

            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            return s;
        }
Example #4
0
 private String getString(VTDNav vn)
 {
     if (argCount1 == 0)
         try
         {
             if (vn.atTerminal)
             {
                 if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_CDATA_VAL)
                     return vn.toRawString(vn.LN);
                 return vn.toString(vn.LN);
             }
             return vn.getXPathStringVal();
         }
         catch (NavException e)
         {
             return null; // this will almost never occur
         }
     else if (argCount1 == 1)
     {
         return argumentList.e.evalString(vn);
     }
     else
         throw new System.ArgumentException("String()'s argument count is invalid");
 }
Example #5
0
        private String getNameSpaceURI(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                try
                {
                    int i = vn.getCurrentIndex();
                    int type = vn.getTokenType(i);

                    if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
                            || type == VTDNav.TOKEN_ATTR_NAME))
                    {
                        int a = vn.lookupNS();
                        if (a == 0)
                            return "";
                        else
                            return vn.toString(a);
                    }
                    return "";
                }
                catch (Exception e)
                {
                    return "";
                }
            }
            else if (argCount1 == 1 && argumentList.e.NodeSet)
            {
                vn.push2();
                int size = vn.contextStack2.size;
                int a = -1;
                try
                {
                    a = argumentList.e.evalNodeSet(vn);
                }
                catch (Exception e)
                {
                }
                String s = "";
                // return a;
                try
                {
                    if (a == -1 || vn.ns == false)
                    { }
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME)
                            s = vn.toString(vn.lookupNS());

                    }
                }
                catch (Exception e) { };
                vn.contextStack2.size = size;
                argumentList.e.reset(vn);
                vn.pop2();
                return s;

            }
            else
                throw new System.ArgumentException
                ("namespace-uri()'s argument count is invalid");
        }
Example #6
0
 private String lowerCase(VTDNav vn)
 {
     if (argCount1 == 1)
     {
         if (argumentList.e.NodeSet)
         {
             int a = evalFirstArgumentListNodeSet(vn);
             if (a == -1)
                 return "";
             else
             {
                 try
                 {
                     int t = vn.getTokenType(a);
                     if (t != VTDNav.TOKEN_STARTING_TAG && t != VTDNav.TOKEN_DOCUMENT)
                         return vn.toStringLowerCase(a);
                     return vn.getXPathStringVal2(a, (short)2);
                 }
                 catch (Exception e)
                 {
                 }
                 return "";
             }
         }
         else
         {
             return (argumentList.e.evalString(vn)).ToLower();
         }
     }
     else
         throw new System.ArgumentException
         ("lowerCase()'s argument count is invalid");
 }
Example #7
0
        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;
        }
Example #8
0
        /// <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;
        }
Example #9
0
    protected internal int getNextChar(VTDNav vn,helper h){
		long l;
		int result;		
		if (h.type==0){// single token
			if (h.offset == h.endOffset)
				return -1;
			if (h.tokenType == VTDNav.TOKEN_CHARACTER_DATA &&
					h.tokenType !=VTDNav.TOKEN_ATTR_VAL){ 
				l = vn.getCharResolved(h.offset);
			}else {
				l = vn.getChar(h.offset);
			}
			h.offset += (int)(l>>32);
			result = (int)l;
			return result;
			
		}else {// text value
			if (h.offset < h.endOffset){
				//return result;
				if (h.tokenType != VTDNav.TOKEN_PI_VAL &&
					h.tokenType !=VTDNav.TOKEN_CHARACTER_DATA){ 
					l = vn.getChar(h.offset);
				}else {
					l = vn.getChar(h.offset);
				}
				h.offset += (int)(l>>32);
				result = (int)l;	
				return result;
			}else{
				h.index++;
				while (h.index < vtdSize) {
				    int tokenType = vn.getTokenType(h.index);
				    int depth = vn.getTokenDepth(h.index);
				    //t=t+getTokenLength2(index);
				    if (depth<h.depth || 
				    		(depth==h.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);
				    	h.offset = vn.getTokenOffset(h.index);
				    	h.endOffset = vn.getTokenOffset(h.index)+vn.getTokenLength2(h.index);
				    	h.tokenType = tokenType;
				    	//h2.index++;
				    	return getNextChar(vn,h);
				    	//
				    } else if (tokenType==VTDNav.TOKEN_ATTR_NAME
					        || tokenType == VTDNav.TOKEN_ATTR_NS
					        || tokenType == VTDNav.TOKEN_PI_NAME){			  
					    h.index = h.index+2;
					    continue;
					}			
					h.index++;
				}
				return -1;
			}
		}
		//return -1;
	}
Example #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="vn"></param>
        /// <returns></returns>
        protected int getStringIndex(VTDNav vn)
        {
            int a = -1;
            vn.push2();
            int size = vn.contextStack2.size;
            try
            {
                a = evalNodeSet(vn);
                if (a != -1)
                {
                    int t = vn.getTokenType(a);
                    if (t == VTDNav.TOKEN_ATTR_NAME)
                    {
                        a++;
                    }
                    else if (vn.getTokenType(a) == VTDNav.TOKEN_STARTING_TAG)
                    {
                        a = vn.getText();
                    }
                    else if (t == VTDNav.TOKEN_PI_NAME)
                    {
                        a++;
                    }
                }
            }
            catch (Exception e)
            {

            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            return a;
        }
Example #11
0
        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");
            }
        }
Example #12
0
 private System.String normalizeSpace(VTDNav vn)
 {
     if (argCount() == 0)
     {
         String s = null;
         try
         {
             if (vn.atTerminal)
             {
                 int ttype = vn.getTokenType(vn.LN);
                 if (ttype == VTDNav.TOKEN_CDATA_VAL)
                     s = vn.toRawString(vn.LN);
                 else if (ttype == VTDNav.TOKEN_ATTR_NAME ||
                      ttype == VTDNav.TOKEN_ATTR_NS)
                 {
                     s = vn.toString(vn.LN + 1);
                 }
                 else
                     s = vn.toString(vn.LN);
             }else
                 s = vn.toString(vn.getCurrentIndex());
             return normalize(s);
         }
         catch (NavException e)
         {
             return ""; // this will almost never occur
         }
     }
     else if (argCount() == 1)
     {
         String s = argumentList.e.evalString(vn);
         return normalize(s);
     }
     throw new System.ArgumentException("normalize-space()'s argument count is invalid");
     //return null;
 }
Example #13
0
		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;
				
			}
		}
Example #14
0
        private String getName(VTDNav vn)
        {
            int a;
            if (argCount() == 0)
            {
                a = vn.getCurrentIndex();
                int type = vn.getTokenType(a);

                if ((type == VTDNav.TOKEN_STARTING_TAG
                        || type == VTDNav.TOKEN_ATTR_NAME))
                {
                    try
                    {
                        return vn.toString(a);
                    }
                    catch (Exception e)
                    {
                        return "";
                    }
                }
                else
                    return "";
            }
            else if (argCount() == 1)
            {
                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();
                }
                try
                {
                    if (a == -1 || vn.ns == false)
                        return "";
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME)
                            return vn.toString(a);
                        return "";
                    }
                }
                catch (Exception e)
                {
                }
                return "";
            }
            else
                throw new System.ArgumentException
                ("name()'s argument count is invalid");

        }
Example #15
0
 private bool contains(VTDNav vn)
 {
     String s2 = argumentList.next.e.evalString(vn);
     if (argumentList.e.NodeSet)
     {
         int a = evalFirstArgumentListNodeSet(vn);
         if (a == -1)
             return false;
         try
         {
             int t = vn.getTokenType(a);
             if (t != VTDNav.TOKEN_STARTING_TAG && t != VTDNav.TOKEN_DOCUMENT)
                 return vn.contains(a, s2);
             else
                 return vn.XPathStringVal_Contains(a, s2);
         }
         catch (Exception e)
         {
             return false;
         }
     }
     String s1 = argumentList.e.evalString(vn);
     //return s1.contains(s2);
     return s1.IndexOf(s2) != -1;
     //return (s1.i))
 }
Example #16
0
        /// <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{ 
			h2.index = -1;
			h2.type= 0;
			h2.offset = vn2.getTokenOffset(k);
			h2.endOffset= vn2.getTokenOffset(k)+vn2.getTokenLength(k);
			h2.tokenType = vn2.getTokenType(k);
		}
		
		// set the offset
		int c1=-1, c2=-1;
		do{
			c1=getNextChar(this, h1); 
			c2=getNextChar(vn2,h2);		
			if (c1!=c2){
				if (c1>c2)
					return 1;
				else 
					return -1;
				//return false;
			}
		} while(c1!=-1 && c2!=-1);
		
		if (c1==c2){
			return 0;
		}
		else {
			if (c1!=-1)
				return 1;
			else 
				return -1;
		}
			//return false;
	}
Example #17
0
 private bool startsWith(VTDNav vn)
 {
     String s2 = argumentList.next.e.evalString(vn);
     if (argumentList.e.NodeSet)
     {
         //boolean b = false;
         int a = evalFirstArgumentListNodeSet(vn);
         if (a == -1)
             return "".StartsWith(s2);
         else
         {
             try
             {
                 int t = vn.getTokenType(a);
                 if (t != VTDNav.TOKEN_STARTING_TAG && t != VTDNav.TOKEN_DOCUMENT)
                     return vn.startsWith(a, s2);
                 else
                     return vn.XPathStringVal_StartsWith(a, s2);
             }
             catch (Exception e)
             {
             }
             return false;
         }
     }
     String s1 = argumentList.e.evalString(vn);
     return s1.StartsWith(s2);
 }
Example #18
0
        public override System.String evalString(VTDNav vn)
        {
            String s = "";
            int a = 0x7fffffff, k = -1;
            vn.push2();
            int size = vn.contextStack2.size;
            try
            {
                //a = evalNodeSet(vn);
                if (needReordering)
                {
                    while ((k = evalNodeSet(vn)) != -1)
                    {
                        // a = evalNodeSet(vn);
                        if (k < a)
                            a = k;
                    }
                    if (a == 0x7fffffff)
                        a = -1;
                }
                else
                {
                    a = evalNodeSet(vn);
                }
                if (a != -1)
                {
                    int t = vn.getTokenType(a);
                    switch (t)
                    {
                        case VTDNav.TOKEN_STARTING_TAG:
                        case VTDNav.TOKEN_DOCUMENT:
                            s = vn.getXPathStringVal();
                            break;
                        case VTDNav.TOKEN_ATTR_NAME:
                            s = vn.toString(a + 1);
                            break;
                        case VTDNav.TOKEN_PI_NAME:
                            //if (a + 1 < vn.vtdSize
                            //		|| vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                            s = vn.toString(a + 1);
                            break;
                        default:
                            s = vn.toString(a);
                            break;
                    }
                }
            }
            catch (Exception e)
            {

            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            return s;
        }
Example #19
0
 private bool matchName(VTDNav vn)
 {
     int a;
     if (argCount1 == 1)
     {
         a = vn.getCurrentIndex();
         int type = vn.getTokenType(a);
         String s1 = argumentList.e.evalString(vn);
         if (type == VTDNav.TOKEN_STARTING_TAG
                 || type == VTDNav.TOKEN_ATTR_NAME
                 || type == VTDNav.TOKEN_PI_NAME)
         {
             try
             {
                 return vn.matchRawTokenString(a, s1);
             }
             catch (Exception e)
             {
                 return false;
             }
         }
         else
             return false;
     }
     else if (argCount1 == 2)
     {
         a = evalFirstArgumentListNodeSet2(vn);
         String s1 = argumentList.next.e.evalString(vn);
         try
         {
             if (a == -1 || vn.ns == false)
                 return s1.CompareTo("")==0;
             else
             {
                 int type = vn.getTokenType(a);
                 if (type == VTDNav.TOKEN_STARTING_TAG
                         || type == VTDNav.TOKEN_ATTR_NAME
                         || type == VTDNav.TOKEN_PI_NAME)
                     return vn.matchRawTokenString(a, s1);
                 return false;
             }
         }
         catch (Exception e)
         {
         }
         return false;
     }
     else
         throw new System.ArgumentException(
                 "matchName()'s argument count is invalid");
 }
Example #20
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="vn"></param>
		/// <returns></returns>
		public override double evalNumber(VTDNav vn)
		{
            double d = Double.NaN;
            int a = 0x7fffffff, k = -1;
            vn.push2();
            int size = vn.contextStack2.size;
            try
            {
                while ((k = evalNodeSet(vn)) != -1)
                {
                    //a = evalNodeSet(vn);
                    if (k < a)
                        a = k;
                }
                if (a == 0x7fffffff)
                    a = -1;
                if (a != -1)
                {
                    int t = vn.getTokenType(a);
                    if (t == VTDNav.TOKEN_ATTR_NAME)
                    {
                        d = vn.parseDouble(a + 1);
                    }
                    else if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                    {
                        d = vn.XPathStringVal2Double(a);//Double.parseDouble(s);
                    }
                    else if (t == VTDNav.TOKEN_PI_NAME)
                    {
                        if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                            //s = vn.toString(a+1); 	
                            d = vn.parseDouble(a + 1);
                        else
                            d = Double.NaN;
                    }
                    else
                        d = vn.parseDouble(a);
                }
            }
            catch (Exception e)
            {

            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            //return s;
            return d;
		}
Example #21
0
 private int getStringVal(VTDNav vn, int i)
 {
     int i1, t = vn.getTokenType(i);
     if (t == VTDNav.TOKEN_STARTING_TAG)
     {
         i1 = vn.getText();
         return i1;
     }
     else if (t == VTDNav.TOKEN_ATTR_NAME
             || t == VTDNav.TOKEN_ATTR_NS || t == VTDNav.TOKEN_PI_NAME)
         return i + 1;
     else
         return i;
 }
Example #22
0
        /*
        * (non-Javadoc)
        *
        * @see com.ximpleware.xpath.Expr#evalString(com.ximpleware.VTDNav)
        */
        public override System.String evalString(VTDNav vn)
        {
            if (e.NodeSet == false)
                return e.evalString(vn);
            else
            {
                String s = "";
                int a = -1;
                vn.push2();
                int size = vn.contextStack2.size;
                try
                {
                    a = evalNodeSet(vn);
                    if (a != -1)
                    {
                        int t = vn.getTokenType(a);
                        switch (t)
                        {
                            case VTDNav.TOKEN_STARTING_TAG:
                            case VTDNav.TOKEN_DOCUMENT:
                                s = vn.getXPathStringVal();
                                break;
                            case VTDNav.TOKEN_ATTR_NAME:
                                s = vn.toString(a + 1);
                                break;
                            case VTDNav.TOKEN_PI_NAME:
                                //if (a + 1 < vn.vtdSize
                                //        || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                                s = vn.toString(a + 1);
                                break;
                            default:
                                s = vn.toString(a);
                                break;
                        }
                        /*if (t == VTDNav.TOKEN_ATTR_NAME) {
                            s = vn.toString(a + 1);
                        } else if (t == VTDNav.TOKEN_STARTING_TAG
                                || t == VTDNav.TOKEN_DOCUMENT) {
                            s = vn.getXPathStringVal();
                        } else if (t == VTDNav.TOKEN_PI_NAME) {
                            if (a + 1 < vn.vtdSize
                                    || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                                s = vn.toString(a + 1);
                            // s = vn.toString(a+1);
                        } else
                            s = vn.toString(a);*/
                    }
                }
                catch (Exception ee)
                {

                }
                vn.contextStack2.size = size;
                reset(vn);
                vn.pop2();
                return s;
            }
        }
Example #23
0
        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 "";
                    }
                }
                else
                    return "";
            }
            else
                throw new System.ArgumentException
                ("local-name()'s argument count is invalid");
        }
Example #24
0
        private System.String normalizeSpace(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                String s = null;
                try
                {
                    if (vn.atTerminal)
                    {
                        int ttype = vn.getTokenType(vn.LN);
                        if (ttype == VTDNav.TOKEN_CDATA_VAL)
                            s = vn.toRawString(vn.LN);
                        else if (ttype == VTDNav.TOKEN_ATTR_NAME ||
                             ttype == VTDNav.TOKEN_ATTR_NS)
                        {
                            s = vn.toString(vn.LN + 1);
                        }
                        else
                            s = vn.toString(vn.LN);
                    }
                    else
                    {
                        int i = vn.getCurrentIndex();
                        int t = vn.getTokenType(i);
                        if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                        {
                            s = vn.toNormalizedXPathString(i);
                        }
                        else
                            s = vn.toNormalizedString(i);
                    }
                    return normalize(s);
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }
            }
            else if (argCount1 == 1)
            {
                String s = "";
                if (argumentList.e.NodeSet)
                {
                    //boolean b = false;
                    int a = evalFirstArgumentListNodeSet(vn);
                    if (a == -1)
                        return "";
                    else
                    {
                        try
                        {
                            int t = vn.getTokenType(a);
                            if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                            {
                                s = vn.toNormalizedXPathString(a);
                            }
                            else
                                s = vn.toNormalizedString(a);
                        }
                        catch (Exception e)
                        {
                        }
                        return s;
                    }
                }
                else
                {
                    s = argumentList.e.evalString(vn);
                    return normalize(s);
                }
	        
            }
            throw new System.ArgumentException("normalize-space()'s argument count is invalid");
            //return null;
        }
Example #25
0
        private String getName(VTDNav vn)
        {
            int a;
            if (argCount1 == 0)
            {
                a = vn.getCurrentIndex();
                int type = vn.getTokenType(a);

                if ((type == VTDNav.TOKEN_STARTING_TAG
                        || type == VTDNav.TOKEN_ATTR_NAME
                        || type == VTDNav.TOKEN_PI_NAME))
                {
                    try
                    {
                        if (vn.nameIndex != a)
                        {
                            vn.name = vn.toRawString(a);
                            vn.nameIndex = a;
                        }
                        return vn.name;
                    }
                    catch (Exception e)
                    {
                        return "";
                    }
                }
                else
                    return "";
            }
            else if (argCount1 == 1)
            {
                a = evalFirstArgumentListNodeSet2(vn);
                try
                {
                    if (a == -1 || vn.ns == false)
                        return "";
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME
                                || type == VTDNav.TOKEN_PI_NAME)
                            return vn.toRawString(a);
                        return "";
                    }
                }
                catch (Exception e)
                {
                }
                return "";
            }
            else
                throw new System.ArgumentException
                ("name()'s argument count is invalid");

        }
Example #26
0
 private double sum(VTDNav vn)
 {
     double d = 0;
     /*if (argCount() != 1 || argumentList.e.NodeSet == false)
         throw new System.ArgumentException("sum()'s argument count is invalid");*/
     vn.push2();
     try
     {
         a = 0;
         int i1;
         while ((a = argumentList.e.evalNodeSet(vn)) != -1)
         {
             int t = vn.getTokenType(a);
             if (t == VTDNav.TOKEN_STARTING_TAG)
             {
                 i1 = vn.getText();
                 if (i1 != -1)
                     d = d + vn.parseDouble(i1);
                 if (System.Double.IsNaN(d))
                     break;
             }
             else if (t == VTDNav.TOKEN_ATTR_NAME || t == VTDNav.TOKEN_ATTR_NS)
             {
                 d = d + vn.parseDouble(a + 1);
                 if (System.Double.IsNaN(d))
                     break;
             }
             else if (t == VTDNav.TOKEN_CHARACTER_DATA
                 || t == VTDNav.TOKEN_CDATA_VAL
                 || t == VTDNav.TOKEN_COMMENT)
             {
                 d = d + vn.parseDouble(a);
                 if (System.Double.IsNaN(d))
                     break;
             }
             else if (t == VTDNav.TOKEN_PI_NAME)
             {
                 if (a + 1 < vn.vtdSize && vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                 {
                     d += vn.parseDouble(a + 1);
                 }
                 else
                 {
                     d = Double.NaN;
                     break;
                 }
             }
             //    fib1.append(i);
         }
         argumentList.e.reset(vn);
         vn.pop2();
         return d;
     }
     catch (System.Exception e)
     {
         argumentList.e.reset(vn);
         vn.pop2();
         return System.Double.NaN;
     }
 }
Example #27
0
        public override double evalNumber(VTDNav vn)
        {
            double d = Double.NaN;
            int a = -1;
            vn.push2();
            int size = vn.contextStack2.size;
            try
            {
                a = evalNodeSet(vn);
                if (a != -1)
                {
                    int t = vn.getTokenType(a);
                    if (t == VTDNav.TOKEN_ATTR_NAME)
                    {
                        d = vn.parseDouble(a + 1);
                    }
                    else if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                    {
                        String s = vn.getXPathStringVal();
                        d = Double.Parse(s);
                    }
                    else if (t == VTDNav.TOKEN_PI_NAME)
                    {
                        if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                            d = vn.parseDouble(a + 1);
                    }
                    else
                        d = vn.parseDouble(a);
                }
            }
            catch (Exception e)
            {

            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            //return s;
            return d;
        }
Example #28
0
 private int evalFirstArgumentListNodeSet(VTDNav vn)
 {
     vn.push2();
     int size = vn.contextStack2.size;
     int a = 0x7fffffff, k = -1;
     try
     {
         if (argumentList.e.needReordering)
         {
             while ((k = argumentList.e.evalNodeSet(vn)) != -1)
             {
                 //a = evalNodeSet(vn);
                 if (k < a)
                     a = k;
             }
             if (a == 0x7fffffff)
                 a = -1;
         }
         else
             a = argumentList.e.evalNodeSet(vn);
         if (a != -1)
         {
             int t = vn.getTokenType(a);
             if (t == VTDNav.TOKEN_ATTR_NAME)
             {
                 a++;
             }
             /*else if (t == VTDNav.TOKEN_STARTING_TAG)
             {
                 a = vn.getText();
             }*/
             else if (t == VTDNav.TOKEN_PI_NAME)
             {
                 //if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                     a++;
                 //else
                 //    a = -1;
             }
         }
     }
     catch (Exception e)
     {
     }
     vn.contextStack2.size = size;
     argumentList.e.reset(vn);
     vn.pop2();
     return a;
 }
Example #29
0
        public bool eval2(VTDNav vn)
        {
            switch (testType)
            {
                case NAMETEST:
                    if (vn.atTerminal)
                        return false;
                    switch (type)
                    {
                        case 0: return true;
                        case 1: return vn.matchElement(nodeName);
                        case 2: return vn.matchElementNS(URL, localName);
                    }
                    return false;
                case NODE:
                    return true;
                case TEXT:
                    if (!vn.atTerminal)
                        return false;
                    int t = vn.getTokenType(vn.LN);
                    if (t == VTDNav.TOKEN_CHARACTER_DATA
                            || t == VTDNav.TOKEN_CDATA_VAL)
                    {
                        return true;
                    }
                    return false;

                case PI0:
                    if (!vn.atTerminal)
                        return false;
                    if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_PI_NAME)
                    {
                        return true;
                    }
                    return false;
                case PI1:
                    if (!vn.atTerminal)
                        return false;
                    if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_PI_NAME)
                    {
                        return vn.matchTokenString(vn.LN, nodeName);
                    }
                    return false;

                default: // comment
                    if (!vn.atTerminal)
                        return false;
                    if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_COMMENT)
                    {
                        return true;
                    }
                    return false;
            }
        }
Example #30
0
    private bool compStringNodeSet(Expr left, Expr right, VTDNav vn, int op)
    {
        int i, i1 = 0, stackSize;
        String s;
        try
        {
            s = left.evalString(vn);
            vn.push2();
            stackSize = vn.contextStack2.size;
            while ((i = right.evalNodeSet(vn)) != -1)
            {
                    int t = vn.getTokenType(i);
                    if (t != VTDNav.TOKEN_STARTING_TAG
                            && t != VTDNav.TOKEN_DOCUMENT)
                    {

                        i1 = getStringVal(vn, i);
                        if (i1 != -1)
                        {
                            bool b = compareVString2(i1, vn, s, op);
                            if (b)
                            {
                                right.reset(vn);
                                vn.contextStack2.size = stackSize;
                                vn.pop2();
                                return b;
                            }
                        }
                    }
                    else
                    {
                        bool b = vn.XPathStringVal_Matches(i, s);
                        if (b)
                        {
                            right.reset(vn);
                            vn.contextStack2.size = stackSize;
                            vn.pop2();
                            return b;
                        }
                    }
                }
            vn.contextStack2.size = stackSize;
            vn.pop2();
            right.reset(vn);
            return false;// compareEmptyNodeSet(op, s);
        }
        catch (Exception e)
        {
            throw new System.SystemException("Undefined behavior");
        }
    }