Here you can find the source of shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd)
Parameter | Description |
---|---|
buffer | is the buffer to parse |
posBegin | is the beginning index |
posEnd | is the ending index |
public static int shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008, 2012 Obeo.//from w w w .j av a2 s . c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Obeo - initial API and implementation *******************************************************************************/ public class Main { /** * Reads eventually the following identifier in the text. * * @param buffer * is the buffer to parse * @param posBegin * is the beginning index * @param posEnd * is the ending index * @return the ending index of the identifier, or 'posBegin' if the following text isn't an identifier */ public static int shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd) { int b = posBegin; while (b < posEnd && Character.isWhitespace(buffer.charAt(b))) { b++; } if (b < posEnd && Character.isJavaIdentifierStart(buffer.charAt(b))) { int e = b + 1; while (e < posEnd && Character.isJavaIdentifierPart(buffer.charAt(e))) { e++; } return e; } return posBegin; } }