diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/AbstractFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/AbstractFilter.java index d8c3427c..889abef4 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/filter/AbstractFilter.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/AbstractFilter.java @@ -24,35 +24,28 @@ package org.springframework.ldap.filter; */ public abstract class AbstractFilter implements Filter { - protected AbstractFilter() { - super(); - } + protected AbstractFilter() { + super(); + } - /** - * Prints the query with LDAP encoding to a stringbuffer - * - * @param buff - * The stringbuffer - * @return The very same stringbuffer - */ - public abstract StringBuffer encode(StringBuffer buff); + /* + * @see org.springframework.ldap.filter.Filter#encode(java.lang.StringBuffer) + */ + public abstract StringBuffer encode(StringBuffer buff); - /** - * Encodes the filter to a string using the (@link #encode(StringBuffer) - * method. - * - * @return The encoded filter - */ - public String encode() { - StringBuffer buff = new StringBuffer(256); - buff = encode(buff); - return buff.toString(); - } + /* + * @see org.springframework.ldap.filter.Filter#encode() + */ + public String encode() { + StringBuffer buf = new StringBuffer(256); + buf = encode(buf); + return buf.toString(); + } - /** - * @see java.lang.Object#toString() - */ - public String toString() { - return encode(); - } + /* + * @see java.lang.Object#toString() + */ + public String toString() { + return encode(); + } } diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/AndFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/AndFilter.java index d1f47547..222a049e 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/filter/AndFilter.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/AndFilter.java @@ -17,7 +17,7 @@ package org.springframework.ldap.filter; /** - * A filter for a logical AND. E.g.: + * A filter for a logical AND. Example: * *
* AndFilter filter = new AndFilter();
@@ -34,26 +34,24 @@ package org.springframework.ldap.filter;
*/
public class AndFilter extends BinaryLogicalFilter {
- private static final String AMPERSAND = "&";
+ private static final String AMPERSAND = "&";
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.ldap.filter.BinaryLogicalFilter#getLogicalOperator()
- */
- protected String getLogicalOperator() {
- return AMPERSAND;
- }
+ /*
+ * @see org.springframework.ldap.filter.BinaryLogicalFilter#getLogicalOperator()
+ */
+ protected String getLogicalOperator() {
+ return AMPERSAND;
+ }
- /**
- * Add a query to the and expression
- *
- * @param query
- * The query to and with the rest of the and:ed queries.
- * @return This LdapAndQuery
- */
- public AndFilter and(Filter query) {
- queryList.add(query);
- return this;
- }
+ /**
+ * Add a query to the AND expression.
+ *
+ * @param query The expression to AND with the rest of the AND:ed
+ * expressions.
+ * @return This LdapAndQuery
+ */
+ public AndFilter and(Filter query) {
+ queryList.add(query);
+ return this;
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java
index b44ce2c6..7b10f706 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java
@@ -24,72 +24,74 @@ import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
- * Abstract superclass for binary logical operations, that is "and"
- * and "or" operations.
+ * Abstract superclass for binary logical operations, that is "AND"
+ * and "OR" operations.
*
* @author Mattias Arthursson
*/
public abstract class BinaryLogicalFilter extends AbstractFilter {
- protected List queryList = new LinkedList();
+ protected List queryList = new LinkedList();
- /**
- * @see org.springframework.ldap.filter.Filter#encode(java.lang.StringBuffer)
- */
- public StringBuffer encode(StringBuffer buff) {
- if (queryList.size() <= 0) {
+ /*
+ * @see org.springframework.ldap.filter.AbstractFilter#encode(java.lang.StringBuffer)
+ */
+ public StringBuffer encode(StringBuffer buff) {
+ if (queryList.size() <= 0) {
- // only output query if contains anything
- return buff;
+ // only output query if contains anything
+ return buff;
- } else if (queryList.size() == 1) {
+ }
+ else if (queryList.size() == 1) {
- // don't add the &
- Filter query = (Filter) queryList.get(0);
- return query.encode(buff);
+ // don't add the &
+ Filter query = (Filter) queryList.get(0);
+ return query.encode(buff);
- } else {
- buff.append("(" + getLogicalOperator());
+ }
+ else {
+ buff.append("(" + getLogicalOperator());
- for (Iterator i = queryList.iterator(); i.hasNext();) {
- Filter query = (Filter) i.next();
- buff = query.encode(buff);
- }
+ for (Iterator i = queryList.iterator(); i.hasNext();) {
+ Filter query = (Filter) i.next();
+ buff = query.encode(buff);
+ }
- buff.append(")");
+ buff.append(")");
- return buff;
- }
- }
+ return buff;
+ }
+ }
- /**
- * Implement this in subclass to return the logical operator, for example
- * &qout;&&qout;.
- *
- * @return the logical operator.
- */
- protected abstract String getLogicalOperator();
+ /**
+ * Implement this in subclass to return the logical operator, for example
+ * &qout;&&qout;.
+ *
+ * @return the logical operator.
+ */
+ protected abstract String getLogicalOperator();
- /**
- * Compares each filter in turn
- *
- * @see org.springframework.ldap.filter.Filter#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj instanceof BinaryLogicalFilter
- && this.getClass() == obj.getClass()) {
- return EqualsBuilder.reflectionEquals(this, obj);
- } else {
- return false;
- }
- }
+ /**
+ * Compares each filter in turn.
+ *
+ * @see org.springframework.ldap.filter.Filter#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof BinaryLogicalFilter && this.getClass() == obj.getClass()) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+ else {
+ return false;
+ }
+ }
- /**
- * Hashes all contained data
- *
- * @see org.springframework.ldap.filter.Filter#hashCode()
- */
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
+ /**
+ * Hashes all contained data.
+ *
+ * @see org.springframework.ldap.filter.Filter#hashCode()
+ */
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/CompareFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/CompareFilter.java
index aa0790aa..1529d4c3 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/CompareFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/CompareFilter.java
@@ -21,103 +21,103 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.ldap.core.LdapEncoder;
/**
- * Abstract superclass for filters to compare values.
+ * Abstract superclass for filters that compare values.
*
* @author Mattias Arthursson
*/
public abstract class CompareFilter extends AbstractFilter {
- private final String attribute;
+ private final String attribute;
- private final String value;
+ private final String value;
- private final String encodedValue;
+ private final String encodedValue;
- public CompareFilter(String attribute, String value) {
- this.attribute = attribute;
- this.value = value;
- this.encodedValue = encodeValue(value);
- }
+ public CompareFilter(String attribute, String value) {
+ this.attribute = attribute;
+ this.value = value;
+ this.encodedValue = encodeValue(value);
+ }
- /**
- * For testing purposes.
- *
- * @return the encoded value.
- */
- String getEncodedValue() {
- return encodedValue;
- }
+ /**
+ * For testing purposes.
+ *
+ * @return the encoded value.
+ */
+ String getEncodedValue() {
+ return encodedValue;
+ }
- /**
- * Override to perform special encoding in subclass.
- *
- * @param value
- * the value to encode.
- * @return properly escaped value.
- */
- protected String encodeValue(String value) {
- return LdapEncoder.filterEncode(value);
- }
+ /**
+ * Override to perform special encoding in subclass.
+ *
+ * @param value the value to encode.
+ * @return properly escaped value.
+ */
+ protected String encodeValue(String value) {
+ return LdapEncoder.filterEncode(value);
+ }
- /**
- * Convenience constructor for int values.
- *
- * @param attribute
- * @param value
- */
- public CompareFilter(String attribute, int value) {
- this.attribute = attribute;
- this.value = String.valueOf(value);
- this.encodedValue = LdapEncoder.filterEncode(this.value);
- }
+ /**
+ * Convenience constructor for int values.
+ *
+ * @param attribute Name of attribute in filter.
+ * @param value The value of the attribute in the filter.
+ */
+ public CompareFilter(String attribute, int value) {
+ this.attribute = attribute;
+ this.value = String.valueOf(value);
+ this.encodedValue = LdapEncoder.filterEncode(this.value);
+ }
- /*
- * @see org.springframework.ldap.filter.AbstractFilter#encode(java.lang.StringBuffer)
- */
- public StringBuffer encode(StringBuffer buff) {
- buff.append('(');
- buff.append(attribute).append(getCompareString()).append(encodedValue);
- buff.append(')');
+ /*
+ * @see org.springframework.ldap.filter.AbstractFilter#encode(java.lang.StringBuffer)
+ */
+ public StringBuffer encode(StringBuffer buff) {
+ buff.append('(');
+ buff.append(attribute).append(getCompareString()).append(encodedValue);
+ buff.append(')');
- return buff;
- }
+ return buff;
+ }
- /**
- * Compares key and value before encoding.
- *
- * @see org.springframework.ldap.filter.Filter#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o instanceof CompareFilter && o.getClass() == this.getClass()) {
- CompareFilter that = (CompareFilter) o;
- EqualsBuilder builder = new EqualsBuilder();
- builder.append(this.attribute, that.attribute);
- builder.append(this.value, that.value);
- return builder.isEquals();
- } else {
- return false;
- }
- }
+ /**
+ * Compares key and value before encoding.
+ *
+ * @see org.springframework.ldap.filter.Filter#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ if (o instanceof CompareFilter && o.getClass() == this.getClass()) {
+ CompareFilter that = (CompareFilter) o;
+ EqualsBuilder builder = new EqualsBuilder();
+ builder.append(this.attribute, that.attribute);
+ builder.append(this.value, that.value);
+ return builder.isEquals();
+ }
+ else {
+ return false;
+ }
+ }
- /**
- * Calculate the hash code for the attribute and the value.
- *
- * @see org.springframework.ldap.filter.Filter#hashCode()
- */
- public int hashCode() {
- HashCodeBuilder builder = new HashCodeBuilder();
- builder.append(attribute);
- builder.append(value);
- return builder.toHashCode();
- }
+ /**
+ * Calculate the hash code for the attribute and the value.
+ *
+ * @see org.springframework.ldap.filter.Filter#hashCode()
+ */
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+ builder.append(attribute);
+ builder.append(value);
+ return builder.toHashCode();
+ }
- /**
- * Implement this method in subclass to return a String representing the
- * operator. The {@link EqualsFilter#getCompareString()} would for example
- * return an equals sign, "=".
- *
- * @return the String to use as operator in the comparison for the specific
- * subclass.
- */
- protected abstract String getCompareString();
+ /**
+ * Implement this method in subclass to return a String representing the
+ * operator. The {@link EqualsFilter#getCompareString()} would for example
+ * return an equals sign, "=".
+ *
+ * @return the String to use as operator in the comparison for the specific
+ * subclass.
+ */
+ protected abstract String getCompareString();
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/EqualsFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/EqualsFilter.java
index 0a30ec5d..e452be35 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/EqualsFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/EqualsFilter.java
@@ -16,7 +16,6 @@
package org.springframework.ldap.filter;
-
/**
* A filter for 'equals'. The following code:
*
@@ -26,32 +25,35 @@ package org.springframework.ldap.filter;
*
*
* would result in:
- * (cn=Some CN)+ * + *
+ * (cn=Some CN) + ** * @author Adam Skogman */ public class EqualsFilter extends CompareFilter { - private static final String EQUALS_SIGN = "="; + private static final String EQUALS_SIGN = "="; - public EqualsFilter(String attribute, String value) { - super(attribute, value); - } + public EqualsFilter(String attribute, String value) { + super(attribute, value); + } - /** - * Convenience constructor for int values. - * - * @param attribute Name of attribute in filter. - * @param value The value of the attribute in the filter. - */ - public EqualsFilter(String attribute, int value) { - super(attribute, value); - } + /** + * Convenience constructor for int values. + * + * @param attribute Name of attribute in filter. + * @param value The value of the attribute in the filter. + */ + public EqualsFilter(String attribute, int value) { + super(attribute, value); + } - /* - * @see org.springframework.ldap.filter.CompareFilter#getCompareString() - */ - protected String getCompareString() { - return EQUALS_SIGN; - } + /* + * @see org.springframework.ldap.filter.CompareFilter#getCompareString() + */ + protected String getCompareString() { + return EQUALS_SIGN; + } } diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/Filter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/Filter.java index 027cdc70..112291a2 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/filter/Filter.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/Filter.java @@ -17,28 +17,28 @@ package org.springframework.ldap.filter; /** - * Common interface for filters. + * Common interface for LDAP filters. * * @author Adam Skogman + * @see http://www.ietf.org/rfc/rfc1960.txt */ public interface Filter { /** - * Encodes the filter to a string using the (@link #encode(StringBuffer) - * method. + * Encodes the filter to a String. * - * @return The encoded filter + * @return The encoded filter in the standard String format */ public String encode(); /** - * Prints the query with LDAP encoding to a stringbuffer + * Encodes the filter to a StringBuffer. * - * @param buff - * The stringbuffer - * @return The very same stringbuffer + * @param buf + * The StringBuffer to encode the filter to + * @return The same StringBuffer as was given */ - public StringBuffer encode(StringBuffer buff); + public StringBuffer encode(StringBuffer buf); /** * All filters must implement equals. @@ -49,9 +49,10 @@ public interface Filter { public boolean equals(Object o); /** - * All filters must implement hashCode() + * All filters must implement hashCode. * - * @return hascode + * @return the hash code according to the contract in + * {@link Object#hashCode()} */ public int hashCode(); diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilter.java index 63df5e2e..c46be2ac 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilter.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilter.java @@ -21,8 +21,7 @@ package org.springframework.ldap.filter; * code: * *
- * GreaterThanOrEqualsFilter filter = new GreaterThanOrEqualsFilter("cn",
- * "Some CN");
+ * GreaterThanOrEqualsFilter filter = new GreaterThanOrEqualsFilter("cn", "Some CN");
* System.out.println(filter.ecode());
*
*
@@ -36,17 +35,20 @@ package org.springframework.ldap.filter;
*/
public class GreaterThanOrEqualsFilter extends CompareFilter {
- private static final String GREATER_THAN_OR_EQUALS = ">=";
+ private static final String GREATER_THAN_OR_EQUALS = ">=";
- public GreaterThanOrEqualsFilter(String attribute, String value) {
- super(attribute, value);
- }
+ public GreaterThanOrEqualsFilter(String attribute, String value) {
+ super(attribute, value);
+ }
- public GreaterThanOrEqualsFilter(String attribute, int value) {
- super(attribute, value);
- }
+ public GreaterThanOrEqualsFilter(String attribute, int value) {
+ super(attribute, value);
+ }
- protected String getCompareString() {
- return GREATER_THAN_OR_EQUALS;
- }
+ /*
+ * @see org.springframework.ldap.filter.CompareFilter#getCompareString()
+ */
+ protected String getCompareString() {
+ return GREATER_THAN_OR_EQUALS;
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/LessThanOrEqualsFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/LessThanOrEqualsFilter.java
index 4c0a39db..389a654b 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/LessThanOrEqualsFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/LessThanOrEqualsFilter.java
@@ -35,17 +35,20 @@ package org.springframework.ldap.filter;
*/
public class LessThanOrEqualsFilter extends CompareFilter {
- private static final String LESS_THAN_OR_EQUALS = "<=";
+ private static final String LESS_THAN_OR_EQUALS = "<=";
- public LessThanOrEqualsFilter(String attribute, String value) {
- super(attribute, value);
- }
+ public LessThanOrEqualsFilter(String attribute, String value) {
+ super(attribute, value);
+ }
- public LessThanOrEqualsFilter(String attribute, int value) {
- super(attribute, value);
- }
+ public LessThanOrEqualsFilter(String attribute, int value) {
+ super(attribute, value);
+ }
- protected String getCompareString() {
- return LESS_THAN_OR_EQUALS;
- }
+ /*
+ * @see org.springframework.ldap.filter.CompareFilter#getCompareString()
+ */
+ protected String getCompareString() {
+ return LESS_THAN_OR_EQUALS;
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/LikeFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/LikeFilter.java
index 5f2e7366..5ad694e9 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/LikeFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/LikeFilter.java
@@ -38,41 +38,38 @@ import org.springframework.ldap.core.LdapEncoder;
*/
public class LikeFilter extends EqualsFilter {
- public LikeFilter(String attribute, String value) {
- super(attribute, value);
- }
+ public LikeFilter(String attribute, String value) {
+ super(attribute, value);
+ }
- /**
- * Encodes a value according to the rules for this filter.
- *
- * @param value
- * Value to encode.
- * @return Encoded value.
- */
- protected String encodeValue(String value) {
- // just return if blank string
- if (value == null) {
- return "";
- }
+ /*
+ * @see org.springframework.ldap.filter.CompareFilter#encodeValue(java.lang.String)
+ */
+ protected String encodeValue(String value) {
+ // just return if blank string
+ if (value == null) {
+ return "";
+ }
- String[] substrings = value.split("\\*", -2);
+ String[] substrings = value.split("\\*", -2);
- if (substrings.length == 1) {
- return LdapEncoder.filterEncode(substrings[0]);
- }
+ if (substrings.length == 1) {
+ return LdapEncoder.filterEncode(substrings[0]);
+ }
- StringBuffer buff = new StringBuffer();
- for (int i = 0; i < substrings.length; i++) {
- buff.append(LdapEncoder.filterEncode(substrings[i]));
- if (i < substrings.length - 1) {
- buff.append("*");
- } else {
- if (substrings[i].equals("")) {
- continue;
- }
- }
- }
+ StringBuffer buff = new StringBuffer();
+ for (int i = 0; i < substrings.length; i++) {
+ buff.append(LdapEncoder.filterEncode(substrings[i]));
+ if (i < substrings.length - 1) {
+ buff.append("*");
+ }
+ else {
+ if (substrings[i].equals("")) {
+ continue;
+ }
+ }
+ }
- return buff.toString();
- }
+ return buff.toString();
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/NotFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/NotFilter.java
index f0a9d164..8584ad00 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/NotFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/NotFilter.java
@@ -23,67 +23,62 @@ import org.apache.commons.lang.Validate;
*
*
* Filter filter = new NotFilter(new EqualsFilter("cn", "foo");
- * System.out.println(filter.ecode());
+ * System.out.println(filter.encode());
*
*
* would result in:
*
- * (!(cn=foo))+ *
+ * (!(cn = foo)) + ** * @author Adam Skogman */ public class NotFilter extends AbstractFilter { - private final Filter filter; + private final Filter filter; - static private final int HASH = "!".hashCode(); + static private final int HASH = "!".hashCode(); - /** - * Create a filter that negates the outcome of the given
filter.
- *
- * @param filter
- * The filter that should be negated.
- */
- public NotFilter(Filter filter) {
- Validate.notNull(filter);
- this.filter = filter;
- }
+ /**
+ * Create a filter that negates the outcome of the given filter.
+ *
+ * @param filter The filter that should be negated.
+ */
+ public NotFilter(Filter filter) {
+ Validate.notNull(filter);
+ this.filter = filter;
+ }
- /**
- * @see org.springframework.ldap.filter.Filter#encode(java.lang.StringBuffer)
- */
- public StringBuffer encode(StringBuffer buff) {
+ /*
+ * @see org.springframework.ldap.filter.AbstractFilter#encode(java.lang.StringBuffer)
+ */
+ public StringBuffer encode(StringBuffer buff) {
- buff.append("(!");
- filter.encode(buff);
- buff.append(')');
+ buff.append("(!");
+ filter.encode(buff);
+ buff.append(')');
- return buff;
+ return buff;
+ }
- }
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
- /**
- * Compares key and value before encoding
- *
- * @see org.springframework.ldap.filter.Filter#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
+ if (o instanceof NotFilter && o.getClass() == this.getClass()) {
+ NotFilter f = (NotFilter) o;
+ return this.filter.equals(f.filter);
+ }
- if (o instanceof NotFilter && o.getClass() == this.getClass()) {
- NotFilter f = (NotFilter) o;
- return this.filter.equals(f.filter);
- }
-
- return false;
- }
-
- /**
- * hash attribute and value
- *
- * @see org.springframework.ldap.filter.Filter#hashCode()
- */
- public int hashCode() {
- return HASH ^ filter.hashCode();
- }
+ return false;
+ }
+ /*
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return HASH ^ filter.hashCode();
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/OrFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/OrFilter.java
index cf7721a3..b0369a70 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/OrFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/OrFilter.java
@@ -34,26 +34,23 @@ package org.springframework.ldap.filter;
*/
public class OrFilter extends BinaryLogicalFilter {
- private static final String PIPE_SIGN = "|";
+ private static final String PIPE_SIGN = "|";
- /**
- * Add a query to the OR expression
- *
- * @param query
- * The query to or with the rest of the or:ed queries.
- * @return This LdapOrQuery
- */
- public OrFilter or(Filter query) {
- queryList.add(query);
- return this;
- }
+ /**
+ * Add a query to the OR expression
+ *
+ * @param query The query to or with the rest of the or:ed queries.
+ * @return This LdapOrQuery
+ */
+ public OrFilter or(Filter query) {
+ queryList.add(query);
+ return this;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.ldap.filter.BinaryLogicalFilter#getLogicalOperator()
- */
- protected String getLogicalOperator() {
- return PIPE_SIGN;
- }
+ /*
+ * @see org.springframework.ldap.filter.BinaryLogicalFilter#getLogicalOperator()
+ */
+ protected String getLogicalOperator() {
+ return PIPE_SIGN;
+ }
}
diff --git a/spring-ldap/src/main/java/org/springframework/ldap/filter/WhitespaceWildcardsFilter.java b/spring-ldap/src/main/java/org/springframework/ldap/filter/WhitespaceWildcardsFilter.java
index 6848099a..73c02f8c 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/filter/WhitespaceWildcardsFilter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/filter/WhitespaceWildcardsFilter.java
@@ -27,8 +27,7 @@ import org.springframework.ldap.core.LdapEncoder;
* following code:
*
*
- * WhitespaceWildcardsFilter filter = new WhitespaceWildcardsFilter("cn",
- * "Some CN");
+ * WhitespaceWildcardsFilter filter = new WhitespaceWildcardsFilter("cn", "Some CN");
* System.out.println(filter.ecode());
*
*
@@ -38,47 +37,43 @@ import org.springframework.ldap.core.LdapEncoder;
* @author Mattias Arthursson
*/
public class WhitespaceWildcardsFilter extends EqualsFilter {
- private static Pattern starReplacePattern = Pattern.compile("\\s+");
+ private static Pattern starReplacePattern = Pattern.compile("\\s+");
- public WhitespaceWildcardsFilter(String attribute, String value) {
- super(attribute, value);
- }
+ public WhitespaceWildcardsFilter(String attribute, String value) {
+ super(attribute, value);
+ }
- /**
- * Encodes a value according to the rules for this filter.
- *
- * @param value
- * Value to encode.
- * @return Encoded value.
- */
- protected String encodeValue(String value) {
+ /*
+ * @see org.springframework.ldap.filter.CompareFilter#encodeValue(java.lang.String)
+ */
+ protected String encodeValue(String value) {
- // blank string means just ONE star
- if (StringUtils.isBlank(value)) {
- return "*";
- }
+ // blank string means just ONE star
+ if (StringUtils.isBlank(value)) {
+ return "*";
+ }
- // trim value, we will add in stars first and last anywhay
- value = value.trim();
+ // trim value, we will add in stars first and last anywhay
+ value = value.trim();
- // filter encode so that any stars etc. are preserved
- String filterEncoded = LdapEncoder.filterEncode(value);
+ // filter encode so that any stars etc. are preserved
+ String filterEncoded = LdapEncoder.filterEncode(value);
- // Now replace all whitespace with stars
- Matcher m = starReplacePattern.matcher(filterEncoded);
+ // Now replace all whitespace with stars
+ Matcher m = starReplacePattern.matcher(filterEncoded);
- // possibly 2 longer (stars at ends)
- StringBuffer buff = new StringBuffer(value.length() + 2);
+ // possibly 2 longer (stars at ends)
+ StringBuffer buff = new StringBuffer(value.length() + 2);
- buff.append('*');
+ buff.append('*');
- while (m.find()) {
- m.appendReplacement(buff, "*");
- }
- m.appendTail(buff);
+ while (m.find()) {
+ m.appendReplacement(buff, "*");
+ }
+ m.appendTail(buff);
- buff.append('*');
+ buff.append('*');
- return buff.toString();
- }
+ return buff.toString();
+ }
}