Example usage for com.liferay.portal.kernel.util Validator isVariableName

List of usage examples for com.liferay.portal.kernel.util Validator isVariableName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Validator isVariableName.

Prototype

public static boolean isVariableName(String variableName) 

Source Link

Document

Returns true if the string is a valid variable name in Java.

Usage

From source file:com.liferay.tools.sourceformatter.JSPSourceProcessor.java

License:Open Source License

protected String getVariableName(String line) {
    if (!line.endsWith(";") || line.startsWith("//")) {
        return null;
    }//w  w w.j av a2s  . c  o  m

    String variableName = null;

    int x = line.indexOf(" = ");

    if (x == -1) {
        int y = line.lastIndexOf(" ");

        if (y != -1) {
            variableName = line.substring(y + 1, line.length() - 1);
        }
    } else {
        line = line.substring(0, x);

        int y = line.lastIndexOf(" ");

        if (y != -1) {
            variableName = line.substring(y + 1);
        }
    }

    if (Validator.isVariableName(variableName)) {
        return variableName;
    }

    return null;
}