Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1556 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
1 changed files with 63 additions and 0 deletions
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
/** |
||||
* |
||||
*/ |
||||
package org.springframework.ui.binding.support; |
||||
|
||||
import org.springframework.ui.binding.Binding.Model; |
||||
|
||||
class ValueBuffer { |
||||
|
||||
private Object value; |
||||
|
||||
private boolean hasValue; |
||||
|
||||
private Model model; |
||||
|
||||
private boolean flushFailed; |
||||
|
||||
private Exception flushException; |
||||
|
||||
public ValueBuffer(Model model) { |
||||
this.model = model; |
||||
} |
||||
|
||||
public boolean hasValue() { |
||||
return hasValue; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
if (!hasValue()) { |
||||
throw new IllegalStateException("No value in buffer"); |
||||
} |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(Object value) { |
||||
this.value = value; |
||||
hasValue = true; |
||||
} |
||||
|
||||
public void flush() { |
||||
try { |
||||
model.setValue(value); |
||||
clear(); |
||||
} catch (Exception e) { |
||||
flushFailed = true; |
||||
flushException = e; |
||||
} |
||||
} |
||||
|
||||
public void clear() { |
||||
value = null; |
||||
hasValue = false; |
||||
flushFailed = false; |
||||
} |
||||
|
||||
public boolean flushFailed() { |
||||
return flushFailed; |
||||
} |
||||
|
||||
public Exception getFlushException() { |
||||
return flushException; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue