Changed scm params to fit for xetorthio's jedis repository, formated SortingParams with java coding style.

This commit is contained in:
m-heuser
2010-10-02 08:46:08 +02:00
parent 45bb728425
commit da876fe7d2
2 changed files with 99 additions and 99 deletions

View File

@@ -32,8 +32,8 @@
<scm> <scm>
<url>http://github.com/xetorthio/jedis</url> <url>http://github.com/xetorthio/jedis</url>
<connection>scm:git:http://github.com/xetorthio/jedis.git</connection> <connection>scm:git:git@github.com:xetorthio/jedis.git</connection>
<developerConnection>scm:git:http://github.com/xetorthio/jedis.git</developerConnection> <developerConnection>scm:git:git@github.com:xetorthio/jedis.git</developerConnection>
</scm> </scm>
<properties> <properties>

View File

@@ -10,110 +10,110 @@ import java.util.List;
* *
*/ */
public class SortingParams { public class SortingParams {
private List<String> params = new ArrayList<String>(); private List<String> params = new ArrayList<String>();
/** /**
* Sort by weight in keys. * Sort by weight in keys.
* <p> * <p>
* Takes a pattern that is used in order to generate the key names of the * Takes a pattern that is used in order to generate the key names of the
* weights used for sorting. Weight key names are obtained substituting the * weights used for sorting. Weight key names are obtained substituting the
* first occurrence of * with the actual value of the elements on the list. * first occurrence of * with the actual value of the elements on the list.
* <p> * <p>
* The pattern for a normal key/value pair is "keyname*" and for a value in * The pattern for a normal key/value pair is "keyname*" and for a value in
* a hash "keyname*->fieldname". * a hash "keyname*->fieldname".
* *
* @param pattern * @param pattern
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams by(String pattern) { public SortingParams by(String pattern) {
params.add("BY"); params.add("BY");
params.add(pattern); params.add(pattern);
return this; return this;
} }
/** /**
* No sorting. * No sorting.
* <p> * <p>
* This is useful if you want to retrieve a external key (using * This is useful if you want to retrieve a external key (using
* {@link #get(String...) GET}) but you don't want the sorting overhead. * {@link #get(String...) GET}) but you don't want the sorting overhead.
* *
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams nosort() { public SortingParams nosort() {
params.add("BY nosort"); params.add("BY nosort");
return this; return this;
} }
public Collection<String> getParams() { public Collection<String> getParams() {
return Collections.unmodifiableCollection(params); return Collections.unmodifiableCollection(params);
} }
/** /**
* Get the Sorting in Descending Order. * Get the Sorting in Descending Order.
* *
* @return the sortingParams Object * @return the sortingParams Object
*/ */
public SortingParams desc() { public SortingParams desc() {
params.add("DESC"); params.add("DESC");
return this; return this;
} }
/** /**
* Get the Sorting in Ascending Order. This is the default order. * Get the Sorting in Ascending Order. This is the default order.
* *
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams asc() { public SortingParams asc() {
params.add("ASC"); params.add("ASC");
return this; return this;
} }
/** /**
* Limit the Numbers of returned Elements. * Limit the Numbers of returned Elements.
* *
* @param start * @param start
* is zero based * is zero based
* @param count * @param count
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams limit(int start, int count) { public SortingParams limit(int start, int count) {
params.add("LIMIT"); params.add("LIMIT");
params.add(String.valueOf(start)); params.add(String.valueOf(start));
params.add(String.valueOf(count)); params.add(String.valueOf(count));
return this; return this;
} }
/** /**
* Sort lexicographicaly. Note that Redis is utf-8 aware assuming you set * Sort lexicographicaly. Note that Redis is utf-8 aware assuming you set
* the right value for the LC_COLLATE environment variable. * the right value for the LC_COLLATE environment variable.
* *
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams alpha() { public SortingParams alpha() {
params.add("ALPHA"); params.add("ALPHA");
return this; return this;
} }
/** /**
* Retrieving external keys from the result of the search. * Retrieving external keys from the result of the search.
* <p> * <p>
* Takes a pattern that is used in order to generate the key names of the * Takes a pattern that is used in order to generate the key names of the
* result of sorting. The key names are obtained substituting the * result of sorting. The key names are obtained substituting the first
* first occurrence of * with the actual value of the elements on the list. * occurrence of * with the actual value of the elements on the list.
* <p> * <p>
* The pattern for a normal key/value pair is "keyname*" and for a value in * The pattern for a normal key/value pair is "keyname*" and for a value in
* a hash "keyname*->fieldname". * a hash "keyname*->fieldname".
* <p> * <p>
* To get the list itself use the char # as pattern. * To get the list itself use the char # as pattern.
* *
* @param patterns * @param patterns
* @return the SortingParams Object * @return the SortingParams Object
*/ */
public SortingParams get(String... patterns) { public SortingParams get(String... patterns) {
for (String pattern : patterns) { for (String pattern : patterns) {
params.add("GET"); params.add("GET");
params.add(pattern); params.add(pattern);
}
return this;
} }
return this;
}
} }