Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sourceforge.jsdialect.util;

Extract query string parameters from an attribute values list. Given an attribute usage like this one: js:attribute="req_1, req_2, opt_1, opt_2" where req_x are the required parameters and opt_x are the optional ones, this class returns the optional parameters as a string array: [opt_1, opt_2]
public class ScriptParametersExtractor {
    private static final String[] NONE_OPTIONAL_PARAMETER = new String[0];
    private ScriptParametersExtractor(){
    public static String[] optionalParameters(String[] attributeValuesint requiredAttributeValues) {
        if (emptyOptionalParameters(attributeValuesrequiredAttributeValues)) {
            return ;
        } else {
            int parametersLength = attributeValues.length - requiredAttributeValues;
            String[] parameters = new String[parametersLength];
            int i = 0;
            while (i < parametersLength) {
                parameters[i] = attributeValues[i + requiredAttributeValues].trim();
            return parameters;
    private static boolean emptyOptionalParameters(String[] attributeValuesint requiredAttributeValues) {
        return attributeValues == null || attributeValues.length == requiredAttributeValues;
New to GrepCode? Check out our FAQ X