Java tutorial
//package com.java2s; //License from project: Open Source License import android.util.Pair; public class Main { private static Pair<Boolean, String> evaluateAsConstantExpression(String parameter) { // String constant? // TODO: Error, this matches something like "hello" + "how are you?" which is not a constant // (but can't be evaluated by getValueFromEntities() anyway). String[] quoteSet = new String[] { "\"", "'" }; //$NON-NLS-1$ //$NON-NLS-2$ for (String quote : quoteSet) if (parameter.startsWith(quote) && parameter.endsWith(quote)) return new Pair<Boolean, String>(true, parameter.substring(1, parameter.length() - 1)); // Numeric constant? if (parameter.matches("^(-)?[0-9.]+$")) //$NON-NLS-1$ return new Pair<Boolean, String>(true, parameter); // Boolean constant? if (parameter.equalsIgnoreCase("true") || parameter.equalsIgnoreCase("false")) //$NON-NLS-1$ //$NON-NLS-2$ return new Pair<Boolean, String>(true, parameter); // Special constants? if (parameter.equalsIgnoreCase("nowait") || parameter.equalsIgnoreCase("status") //$NON-NLS-1$//$NON-NLS-2$ || parameter.equalsIgnoreCase("keep")) return new Pair<Boolean, String>(true, parameter); // Not a constant value, apparently. return new Pair<Boolean, String>(false, parameter); } }