Browse Source

polish

conversation
Keith Donald 16 years ago
parent
commit
ab7e985d72
  1. 94
      org.springframework.context/src/main/java/org/springframework/ui/binding/Binding.java
  2. 33
      org.springframework.context/src/main/java/org/springframework/ui/binding/BindingStatus.java
  3. 23
      org.springframework.context/src/main/java/org/springframework/ui/binding/ValidationStatus.java
  4. 2
      org.springframework.context/src/main/java/org/springframework/ui/binding/binder/BindingResult.java
  5. 2
      org.springframework.context/src/main/java/org/springframework/ui/binding/binder/GenericBinder.java
  6. 3
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinding.java
  7. 2
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBindingFactory.java
  8. 2
      org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java

94
org.springframework.context/src/main/java/org/springframework/ui/binding/Binding.java

@ -61,24 +61,7 @@ public interface Binding { @@ -61,24 +61,7 @@ public interface Binding {
* Used to determine if the user can see the field.
*/
boolean isVisible();
/**
* Apply the source value to this binding.
* The source value is parsed and stored in the binding's value buffer.
* Sets to {@link BindingStatus#DIRTY} if succeeds.
* Sets to {@link BindingStatus#INVALID_SOURCE_VALUE} if fails.
* @param sourceValue
* @throws IllegalStateException if not editable or not enabled
*/
void applySourceValue(Object sourceValue);
/**
* If {@link BindingStatus#INVALID_SOURCE_VALUE}, returns the invalid source value.
* Returns null otherwise.
* @return the invalid source value
*/
Object getInvalidSourceValue();
/**
* The current binding status.
* Initially {@link BindingStatus#CLEAN clean}.
@ -88,7 +71,7 @@ public interface Binding { @@ -88,7 +71,7 @@ public interface Binding {
* Is {@link BindingStatus#COMMIT_FAILURE} if a buffered value could not be committed.
*/
BindingStatus getStatus();
/**
* An alert that communicates current status to the user.
* Returns <code>null</code> if {@link BindingStatus#CLEAN} and {@link ValidationStatus#NOT_VALIDATED}.
@ -99,6 +82,23 @@ public interface Binding { @@ -99,6 +82,23 @@ public interface Binding {
*/
Alert getStatusAlert();
/**
* Apply the source value to this binding.
* The source value is parsed and stored in the binding's value buffer.
* Sets to {@link BindingStatus#DIRTY} if succeeds.
* Sets to {@link BindingStatus#INVALID_SOURCE_VALUE} if fails.
* @param sourceValue
* @throws IllegalStateException if not editable or not enabled
*/
void applySourceValue(Object sourceValue);
/**
* If {@link BindingStatus#INVALID_SOURCE_VALUE}, returns the invalid source value.
* Returns null otherwise.
* @return the invalid source value
*/
Object getInvalidSourceValue();
/**
* Commit the buffered value to the model.
* Sets to {@link BindingStatus#COMMITTED} if succeeds.
@ -119,7 +119,7 @@ public interface Binding { @@ -119,7 +119,7 @@ public interface Binding {
* @return the binding to the nested property
* @throws IllegalStateException if not a bean
*/
Binding getBinding(String property);
Binding getNestedBinding(String property);
/**
* If bound to an indexable Collection, either a {@link java.util.List} or an array.
@ -155,58 +155,4 @@ public interface Binding { @@ -155,58 +155,4 @@ public interface Binding {
* @return the formatted string
*/
String formatValue(Object potentialModelValue);
/**
* Binding states.
* @author Keith Donald
*/
public enum BindingStatus {
/**
* Initial state: No value is buffered, and there is a direct channel to the model value.
*/
CLEAN,
/**
* An invalid source value is applied.
*/
INVALID_SOURCE_VALUE,
/**
* The binding buffer contains a valid value that has not been committed.
*/
DIRTY,
/**
* The buffered value has been committed.
*/
COMMITTED,
/**
* The buffered value failed to commit.
*/
COMMIT_FAILURE
}
/**
* Validation states.
* @author Keith Donald
*/
public enum ValidationStatus {
/**
* Initial state: No validation has run.
*/
NOT_VALIDATED,
/**
* Validation has succeeded.
*/
VALID,
/**
* Validation has failed.
*/
INVALID
}
}

33
org.springframework.context/src/main/java/org/springframework/ui/binding/BindingStatus.java

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
package org.springframework.ui.binding;
/**
* Binding states.
* @author Keith Donald
*/
public enum BindingStatus {
/**
* Initial state: No value is buffered, and there is a direct channel to the model value.
*/
CLEAN,
/**
* An invalid source value is applied.
*/
INVALID_SOURCE_VALUE,
/**
* The binding buffer contains a valid value that has not been committed.
*/
DIRTY,
/**
* The buffered value has been committed.
*/
COMMITTED,
/**
* The buffered value failed to commit.
*/
COMMIT_FAILURE
}

23
org.springframework.context/src/main/java/org/springframework/ui/binding/ValidationStatus.java

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
package org.springframework.ui.binding;
/**
* Validation states.
* @author Keith Donald
*/
public enum ValidationStatus {
/**
* Initial state: No validation has run.
*/
NOT_VALIDATED,
/**
* Validation has succeeded.
*/
VALID,
/**
* Validation has failed.
*/
INVALID
}

2
org.springframework.context/src/main/java/org/springframework/ui/binding/binder/BindingResult.java

@ -29,7 +29,7 @@ public interface BindingResult { @@ -29,7 +29,7 @@ public interface BindingResult {
/**
* The model property this binding result is for.
* @see Binder#getBinding(String)
* @see Binder#getNestedBinding(String)
*/
String getProperty();

2
org.springframework.context/src/main/java/org/springframework/ui/binding/binder/GenericBinder.java

@ -23,7 +23,7 @@ import org.springframework.context.MessageSource; @@ -23,7 +23,7 @@ import org.springframework.context.MessageSource;
import org.springframework.core.convert.TypeConverter;
import org.springframework.ui.binding.Binding;
import org.springframework.ui.binding.BindingFactory;
import org.springframework.ui.binding.Binding.BindingStatus;
import org.springframework.ui.binding.BindingStatus;
import org.springframework.ui.binding.support.PropertyNotFoundException;
import org.springframework.util.Assert;

3
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinding.java

@ -35,6 +35,7 @@ import org.springframework.core.style.StylerUtils; @@ -35,6 +35,7 @@ import org.springframework.core.style.StylerUtils;
import org.springframework.ui.alert.Alert;
import org.springframework.ui.alert.Severity;
import org.springframework.ui.binding.Binding;
import org.springframework.ui.binding.BindingStatus;
import org.springframework.ui.format.Formatter;
import org.springframework.ui.message.MessageBuilder;
import org.springframework.ui.message.ResolvableArgument;
@ -278,7 +279,7 @@ public class GenericBinding implements Binding { @@ -278,7 +279,7 @@ public class GenericBinding implements Binding {
}
}
public Binding getBinding(String property) {
public Binding getNestedBinding(String property) {
return bindingContext.getBinding(property);
}

2
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBindingFactory.java

@ -134,7 +134,7 @@ public class GenericBindingFactory implements BindingFactory { @@ -134,7 +134,7 @@ public class GenericBindingFactory implements BindingFactory {
throw new IllegalArgumentException("Attempted to index a property that is not a List or Map");
}
} else {
binding = binding.getBinding(element.getValue());
binding = binding.getNestedBinding(element.getValue());
}
}
return binding;

2
org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java

@ -23,7 +23,7 @@ import org.junit.Test; @@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.style.ToStringCreator;
import org.springframework.ui.binding.Binding;
import org.springframework.ui.binding.Binding.BindingStatus;
import org.springframework.ui.binding.BindingStatus;
import org.springframework.ui.binding.binder.BindingResults;
import org.springframework.ui.binding.binder.GenericBinder;
import org.springframework.ui.binding.binder.MissingSourceValuesException;

Loading…
Cancel
Save