if (atTerminal) return false;
	public boolean toElement(int direction) throws NavException {		int size;		switch (direction) {			case ROOT : // to document element!				if (context[0] != 0) {					/*for (int i = 1; i <= context[0]; i++) {						context[i] = 0xffffffff;					}*/					context[0] = 0;				}				l1index = l2index = l3index = -1;				return true;			case PARENT :				if (context[0] > 0) {					//context[context[0]] = context[context[0] + 1] = 0xffffffff;					context[context[0]] = -1;					context[0]--;					return true;				}else if (context[0]==0){					context[0]=-1; //to be compatible with XPath Data model					return true; 				}				else {					return false;				}			case FIRST_CHILD :			case LAST_CHILD :				switch (context[0]) {				    case -1:				    	context[0] = 0;				    	return true;					case 0 :						if (l1Buffer.size() > 0) {							context[0] = 1;							l1index =								(direction == FIRST_CHILD)									? 0									: (l1Buffer.size() - 1);							context[1] = l1Buffer.upper32At(l1index);							//(int) (vtdToken >> 32);							return true;						} else							return false;					case 1 :						l2lower = l1Buffer.lower32At(l1index);						if (l2lower == -1) {							return false;						}						context[0] = 2;						l2upper = l2Buffer.size() - 1;						size = l1Buffer.size();						for (int i = l1index + 1; i < size; i++) {							int temp = l1Buffer.lower32At(i);							if (temp != 0xffffffff) {								l2upper = temp - 1;								break;							}						}						//System.out.println(" l2 upper: " + l2upper + " l2 lower : " + l2lower);						l2index =							(direction == FIRST_CHILD) ? l2lower : l2upper;						context[2] = l2Buffer.upper32At(l2index);						return true;					case 2 :						l3lower = l2Buffer.lower32At(l2index);						if (l3lower == -1) {							return false;						}						context[0] = 3;						l3upper = l3Buffer.size() - 1;						size = l2Buffer.size();						for (int i = l2index + 1; i < size; i++) {							int temp = l2Buffer.lower32At(i);							if (temp != 0xffffffff) {								l3upper = temp - 1;								break;							}						}						//System.out.println(" l3 upper : " + l3upper + " l3 lower : " + l3lower);						l3index =							(direction == FIRST_CHILD) ? l3lower : l3upper;						context[3] = l3Buffer.intAt(l3index);						return true;					default :						if (direction == FIRST_CHILD) {							size = vtdBuffer.size();							int index = context[context[0]] + 1;							while (index < size) {								long temp = vtdBuffer.longAt(index);								int token_type =									(int) ((MASK_TOKEN_TYPE & temp) >> 60)										& 0xf;								if (token_type == TOKEN_STARTING_TAG) {									int depth =										(int) ((MASK_TOKEN_DEPTH & temp) >> 52);									if (depth <= context[0]) {										return false;									} else if (depth == (context[0] + 1)) {										context[0] += 1;										context[context[0]] = index;										return true;									}								}								index++;							} // what condition  							return false;						} else {							int index = context[context[0]] + 1;							int last_index = -1;							size = vtdBuffer.size();							while (index < size) {								long temp = vtdBuffer.longAt(index);								int depth =									(int) ((MASK_TOKEN_DEPTH & temp) >> 52);								int token_type =									(int) ((MASK_TOKEN_TYPE & temp) >> 60)										& 0xf;								if (token_type == TOKEN_STARTING_TAG) {									if (depth <= context[0]) {										break;									} else if (depth == (context[0] + 1)) {										last_index = index;									}								}								index++;							}							if (last_index == -1) {								return false;							} else {								context[0] += 1;								context[context[0]] = last_index;								return true;							}						}				}			case NEXT_SIBLING :			case PREV_SIBLING :				switch (context[0]) {					case -1:					case 0 :						return false;					case 1 :						if (direction == NEXT_SIBLING) {							if (l1index + 1 >= l1Buffer.size()) {								return false;							}							l1index++; // global incremental						} else {							if (l1index - 1 < 0) {								return false;							}							l1index--; // global incremental						}						context[1] = l1Buffer.upper32At(l1index);						return true;					case 2 :						if (direction == NEXT_SIBLING) {							if (l2index + 1 > l2upper) {								return false;							}							l2index++;						} else {							if (l2index - 1 < l2lower) {								return false;							}							l2index--;						}						context[2] = l2Buffer.upper32At(l2index);						return true;					case 3 :						if (direction == NEXT_SIBLING) {							if (l3index + 1 > l3upper) {								return false;							}							l3index++;						} else {							if (l3index - 1 < l3lower) {								return false;							}							l3index--;						}						context[3] = l3Buffer.intAt(l3index);						return true;					default :						//int index = context[context[0]] + 1;						if (direction == NEXT_SIBLING) {							int index = context[context[0]] + 1;							while (index < vtdBuffer.size()) {								long temp = vtdBuffer.longAt(index);								int token_type =									(int) ((MASK_TOKEN_TYPE & temp) >> 60)										& 0xf;								if (token_type == TOKEN_STARTING_TAG) {									int depth =										(int) ((MASK_TOKEN_DEPTH & temp) >> 52);									if (depth < context[0]) {										return false;									} else if (depth == (context[0])) {										context[context[0]] = index;										return true;									}								}								index++;							}							return false;						} else {							int index = context[context[0]] - 1;							while (index > context[context[0] - 1]) {								// scan backforward								long temp = vtdBuffer.longAt(index);								int token_type =									(int) ((MASK_TOKEN_TYPE & temp) >> 60)										& 0xf;								if (token_type == TOKEN_STARTING_TAG) {									int depth =										(int) ((MASK_TOKEN_DEPTH & temp) >> 52);									/*if (depth < context[0]) {									    return false;									} else */									if (depth == (context[0])) {										context[context[0]] = index;										return true;									}								}								index--;							} // what condition          	    							return false;						}				}			default :				throw new NavException("illegal navigation options");		}	}