Java Bit Shift shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd)

Here you can find the source of shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd)

Description

Reads eventually the following identifier in the text.

License

Open Source License

Parameter

Parameter Description
buffer is the buffer to parse
posBegin is the beginning index
posEnd is the ending index

Return

the ending index of the identifier, or 'posBegin' if the following text isn't an identifier

Declaration

public static int shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd) 

Method Source Code

//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;
    }
}

Related

  1. shiftBits(byte b)
  2. shiftByte(byte n, short shift)
  3. shiftCharacter(char c, int offset)
  4. shiftDouble(Object o, double shift, String suffix)
  5. shiftHorizontally(int inkX, int inkXWidth, int textWidth)
  6. shiftKeyword(StringBuffer buffer, int posBegin, int posEnd, String keyword, boolean ignoreCase, boolean wholeWord)
  7. shiftLastAlphabets(String id)
  8. shiftLeft(char ch)
  9. shiftLeft(final Character orig, final int shiftDistance)