Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Opensec UTIL - https://nakamura5akihito.github.io/ Copyright (C) 2015 Akihito Nakamura Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package io.opensec.util.repository;
 
 import java.util.Map;
 import java.util.Set;



A set of query parameters to be interpreted as a filter for collections of objects.

Author(s):
Akihito Nakamura, AIST
 
 public class QueryParams
     implements CloneableSerializable
 {
 
     public static final String  LIST_DELIMITER = ",";
 
 
     private final Map<StringString>  _params = new HashMap<StringString>();



    
Constructor.
 
     public QueryParams()
     {
     }
 
 
     public QueryParams(
                     final Map<StringStringparams
                     )
     {
         .putAllparams );
     }



    

Returns:
all the keys as a set.
 
     public Set<Stringkeys()
     {
         return .keySet();
     }



    

Returns:
true if this set is empty; no parameter.
 
     public boolean isEmpty()
     {
         return .isEmpty();
     }



    

Parameters:
key the key of the parameter.
value the value of the parameter.
Returns:
this object.
 
     public QueryParams set(
                     final String key,
                     final String value
                     )
     {
         .putkeyvalue );
 
         return this;
     }
 
 
     public QueryParams set(
                     final String key,
                     final String[] values
                     )
     {
        StringBuilder  s = new StringBuilder();
        boolean  first = true;
        for (String  v : values) {
            if (first) {
                first = false;
            } else {
                s.append"," );
            }
            s.appendv );
        }
        .putkeys.toString() );
        return this;
    }
    public QueryParams set(
                    final String key,
                    final Enum<?>[] values
                    )
    {
        StringBuilder  s = new StringBuilder();
        boolean  first = true;
        for (Enum<?>  e : values) {
            if (first) {
                first = false;
            } else {
                s.append"," );
            }
            s.appende.name() );
        }
        .putkeys.toString() );
        return this;
    }



    

Parameters:
key the key of the parameter.
Returns:
the value of the parameter, or null if there was no parameter for the key.
    public String get(
                    final String key
                    )
    {
        return .getkey );
    }
    public String get(
                    final String key,
                    final String defaultValue
                    )
    {
        String  value = getkey );
        return (value == null ? defaultValue : value);
    }
    public int getAsInt(
                    final String key
                    )
    {
        String  v = .getkey );
        if (v == null) {
            throw new IllegalArgumentException"no such key: " + key );
        }
        return Integer.valueOfv ).intValue();
    }



    

Parameters:
key the key of the parameter.
Returns:
true if a parameter associated with the specified key.
    public boolean containsKey(
                    final String key
                    )
    {
        return .containsKeykey );
    }



    

Parameters:
key the key of the parameter.
Returns:
the previous parameter value associated with key, or null if there was no parameter for key.
    public String remove(
                    final String key
                    )
    {
        return .removekey );
    }



    

Returns:
the number of the parameters.
    public int size()
    {
        return .size();
    }
    //**************************************************************
    //  java.lang.Cloneable
    //**************************************************************
    @Override
    public Object clone()
    {
        return (new QueryParams ));
    }
    //**************************************************************
    //  java.lang.Object
    //**************************************************************
    @Override
    public String toString()
    {
        return String.valueOf );
    }
//
New to GrepCode? Check out our FAQ X