Revision: 1475
          http://svn.sourceforge.net/spring-rich-c/?rev=1475&view=rev
Author:   jhoskens
Date:     2006-10-02 06:38:28 -0700 (Mon, 02 Oct 2006)

Log Message:
-----------
Moved implementations to support subpackage

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/RulesValidator.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationMessage.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResults.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResultsModel.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/EmptyValidationResults.java

Removed Paths:
-------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationMessage.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResults.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResultsModel.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/EmptyValidationResults.java

Deleted: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationMessage.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationMessage.java
  2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationMessage.java
  2006-10-02 13:38:28 UTC (rev 1475)
@@ -1,83 +0,0 @@
-/*
- * Copyright 2002-2005 the original author or authors.
- * 
- * 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 org.springframework.binding.validation;
-
-import java.io.Serializable;
-
-import org.springframework.core.style.ToStringCreator;
-import org.springframework.richclient.util.Assert;
-import org.springframework.util.ObjectUtils;
-
-/**
- * Default implementation of ValidationMessage
- * 
- * @author  Oliver Hutchison
- */
-public class DefaultValidationMessage implements ValidationMessage, 
Serializable {
-    private final long timeStamp;
-
-    private final String property;
-
-    private final Severity severity;
-
-    private final String message;
-
-    public DefaultValidationMessage(String property, Severity severity, String 
message) {
-        Assert.required(severity, "severity");
-        Assert.required(message, "message");
-        this.timeStamp = System.currentTimeMillis();
-        this.property = property;
-        this.severity = severity;
-        this.message = message;
-    }
-
-    public long getTimeStamp() {
-        return timeStamp;
-    }
-
-    public String getProperty() {
-        return property;
-    }
-
-    public Severity getSeverity() {
-        return severity;
-    }
-
-    public String getMessage() {
-        return message;
-    }
-
-    public int hashCode() {
-        return (getProperty() != null ? (getProperty().hashCode() * 27) : 0) + 
(getSeverity().getShortCode() * 9)
-                + getMessage().hashCode();
-    }
-
-    public boolean equals(Object o) {
-        if (o == null || o.getClass() != this.getClass()) {
-            return false;
-        }
-        DefaultValidationMessage m2 = (DefaultValidationMessage)o;
-        return ObjectUtils.nullSafeEquals(getProperty(), m2.getProperty()) && 
getSeverity().equals(m2.getSeverity())
-                && getMessage().equals(m2.getMessage());
-    }
-
-    public String toString() {
-        return new ToStringCreator(this).append("property", getProperty())
-                .append("severity", getSeverity().getLabel())
-                .append("message", getMessage())
-                .toString();
-    }
-}
\ No newline at end of file

Deleted: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResults.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResults.java
  2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResults.java
  2006-10-02 13:38:28 UTC (rev 1475)
@@ -1,138 +0,0 @@
-/*
- * Copyright 2002-2005 the original author or authors.
- * 
- * 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 org.springframework.binding.validation;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.springframework.binding.validation.support.RulesValidator;
-import org.springframework.core.style.ToStringCreator;
-import org.springframework.util.CachingMapDecorator;
-import org.springframework.util.ObjectUtils;
-
-public class DefaultValidationResults implements ValidationResults {
-
-    private final Set messages = new HashSet();
-
-    private CachingMapDecorator messagesSubSets = new CachingMapDecorator() {
-
-        protected Object create(Object key) {
-            Set messagesSubSet = new HashSet();
-            for (Iterator i = messages.iterator(); i.hasNext();) {
-                ValidationMessage message = (ValidationMessage)i.next();
-                if (key instanceof Severity && 
message.getSeverity().equals(key)) {
-                    messagesSubSet.add(message);
-                }
-                else if (ObjectUtils.nullSafeEquals(message.getProperty(), 
key)) {
-                    messagesSubSet.add(message);
-                }
-            }
-            return Collections.unmodifiableSet(messagesSubSet);
-        }
-
-    };
-
-    public DefaultValidationResults() {
-    }
-
-    public DefaultValidationResults(ValidationResults validationResults) {
-        addAllMessages(validationResults);
-    }
-
-    public DefaultValidationResults(Collection validationMessages) {
-        addAllMessages(validationMessages);
-    }
-
-    public void addAllMessages(ValidationResults validationResults) {
-        addAllMessages(validationResults.getMessages());
-    }
-
-    public void addAllMessages(Collection validationMessages) {        
-        if (messages.addAll(validationMessages)) {
-            messagesSubSets.clear();
-        }
-    }
-
-    public void addMessage(ValidationMessage validationMessage) {
-        if (messages.add(validationMessage)) {            
-            messagesSubSets.clear();
-        }
-    }
-
-    public void addMessage(String field, Severity severity, String message) {
-        addMessage(new DefaultValidationMessage(field, severity, message));
-    }
-
-    public void removeMessage(ValidationMessage message) {
-        messages.remove(message);
-        messagesSubSets.clear();
-    }
-
-    public boolean getHasErrors() {
-        return getMessageCount(Severity.ERROR) > 0;
-    }
-
-    public boolean getHasWarnings() {
-        return getMessageCount(Severity.WARNING) > 0;
-    }
-
-    public boolean getHasInfo() {
-        return getMessageCount(Severity.INFO) > 0;
-    }
-
-    public int getMessageCount() {
-        return messages.size();
-    }
-
-    public int getMessageCount(Severity severity) {
-        return getMessages(severity).size();
-    }
-
-    public int getMessageCount(String fieldName) {
-        return getMessages(fieldName).size();
-    }
-
-    public Set getMessages() {
-        return Collections.unmodifiableSet(messages);
-    }
-
-    public Set getMessages(Severity severity) {
-        return (Set)messagesSubSets.get(severity);
-    }
-
-    public Set getMessages(String fieldName) {
-        return (Set)messagesSubSets.get(fieldName);
-    }
-
-    public String toString() {
-        return new ToStringCreator(this).append("messages", 
getMessages()).toString();
-    }
-    
-    /**
-     * Clear all messages.
-     * 
-     * @see RulesValidator#clearMessages()
-     */
-    public void clearMessages()
-    {
-        messages.clear();
-        messagesSubSets.clear();
-    }
-
-}
\ No newline at end of file

Deleted: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResultsModel.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResultsModel.java
     2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResultsModel.java
     2006-10-02 13:38:28 UTC (rev 1475)
@@ -1,235 +0,0 @@
-/*
- * Copyright 2002-2005 the original author or authors.
- * 
- * 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 org.springframework.binding.validation;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.springframework.core.style.ToStringCreator;
-import org.springframework.richclient.util.Assert;
-import org.springframework.richclient.util.EventListenerListHelper;
-import org.springframework.util.CachingMapDecorator;
-import org.springframework.util.ObjectUtils;
-
-/**
- * Default implementation of ValidationResultsModel
- * 
- * @author  Oliver Hutchison
- */
-public class DefaultValidationResultsModel implements ValidationResultsModel {
-
-    private final EventListenerListHelper validationListeners = new 
EventListenerListHelper(ValidationListener.class);
-
-    private final CachingMapDecorator propertyValidationListeners = new 
CachingMapDecorator() {
-
-        protected Object create(Object propertyName) {
-            return new EventListenerListHelper(ValidationListener.class);
-        }
-    };
-
-    private final CachingMapDecorator propertyChangeListeners = new 
CachingMapDecorator() {
-
-        protected Object create(Object propertyName) {
-            return new EventListenerListHelper(PropertyChangeListener.class);
-        }
-    };
-
-    private final ValidationResultsModel delegateFor;
-
-    private ValidationResults validationResults = 
EmptyValidationResults.INSTANCE;
-
-    public DefaultValidationResultsModel() {
-        delegateFor = this;
-    }
-
-    public DefaultValidationResultsModel(ValidationResultsModel delegateFor) {
-        this.delegateFor = delegateFor;
-    }
-
-    public void updateValidationResults(ValidationResults 
newValidationResults) {
-        Assert.required(newValidationResults, "newValidationResults");
-        ValidationResults oldValidationResults = validationResults;
-        validationResults = newValidationResults;
-        if (oldValidationResults.getMessageCount() == 0 && 
validationResults.getMessageCount() == 0) {
-            return;
-        }
-        for (Iterator i = propertyValidationListeners.keySet().iterator(); 
i.hasNext();) {
-            String propertyName = (String)i.next();
-            if (oldValidationResults.getMessageCount(propertyName) > 0
-                    || validationResults.getMessageCount(propertyName) > 0) {
-                fireValidationResultsChanged(propertyName);
-            }
-        }
-        fireChangedEvents(oldValidationResults);
-    }
-    
-    // TODO: test
-    public void addMessage(ValidationMessage validationMessage) {
-        if (!validationResults.getMessages().contains(validationMessage)) {
-            ValidationResults oldValidationResults = validationResults;
-            List newMessages = new 
ArrayList(oldValidationResults.getMessages());
-            newMessages.add(validationMessage);
-            validationResults = new DefaultValidationResults(newMessages);
-            fireValidationResultsChanged(validationMessage.getProperty());
-            fireChangedEvents(oldValidationResults);
-        }
-    }
-
-    // TODO: test
-    public void removeMessage(ValidationMessage validationMessage) {
-        if (validationResults.getMessages().contains(validationMessage)) {
-            ValidationResults oldValidationResults = validationResults;
-            List newMessages = new 
ArrayList(oldValidationResults.getMessages());
-            newMessages.remove(validationMessage);
-            validationResults = new DefaultValidationResults(newMessages);
-            fireValidationResultsChanged(validationMessage.getProperty());
-            fireChangedEvents(oldValidationResults);
-        }
-    }
-
-    // TODO: test
-    public void replaceMessage(ValidationMessage messageToReplace, 
ValidationMessage replacementMessage) {        
-        ValidationResults oldValidationResults = validationResults;
-        List newMessages = new ArrayList(oldValidationResults.getMessages());
-        final boolean containsMessageToReplace = 
validationResults.getMessages().contains(messageToReplace);
-        if (containsMessageToReplace) {
-            newMessages.remove(messageToReplace);
-        }
-        newMessages.add(replacementMessage);
-        validationResults = new DefaultValidationResults(newMessages);
-        if (containsMessageToReplace && 
!ObjectUtils.nullSafeEquals(messageToReplace.getProperty(), 
replacementMessage.getProperty())) {
-            fireValidationResultsChanged(messageToReplace.getProperty());
-        }
-        fireValidationResultsChanged(replacementMessage.getProperty());
-        fireChangedEvents(oldValidationResults);
-    }
-
-    public void clearAllValidationResults() {
-        updateValidationResults(EmptyValidationResults.INSTANCE);
-    }
-
-    public boolean getHasErrors() {
-        return validationResults.getHasErrors();
-    }
-
-    public boolean getHasInfo() {
-        return validationResults.getHasInfo();
-    }
-
-    public boolean getHasWarnings() {
-        return validationResults.getHasWarnings();
-    }
-
-    public int getMessageCount() {
-        return validationResults.getMessageCount();
-    }
-
-    public int getMessageCount(Severity severity) {
-        return validationResults.getMessageCount(severity);
-    }
-
-    public int getMessageCount(String propertyName) {
-        return validationResults.getMessageCount(propertyName);
-    }
-
-    public Set getMessages() {
-        return validationResults.getMessages();
-    }
-
-    public Set getMessages(Severity severity) {
-        return validationResults.getMessages(severity);
-    }
-
-    public Set getMessages(String propertyName) {
-        return validationResults.getMessages(propertyName);
-    }
-
-    public void addValidationListener(ValidationListener listener) {
-        validationListeners.add(listener);
-    }
-
-    public void removeValidationListener(ValidationListener listener) {
-        validationListeners.remove(listener);
-    }
-
-    public void addValidationListener(String propertyName, ValidationListener 
listener) {
-        getValidationListeners(propertyName).add(listener);
-    }
-
-    public void removeValidationListener(String propertyName, 
ValidationListener listener) {
-        getValidationListeners(propertyName).remove(listener);
-    }
-
-    public void addPropertyChangeListener(PropertyChangeListener listener) {
-        throw new UnsupportedOperationException("This method is not 
implemented");
-    }
-
-    public void removePropertyChangeListener(PropertyChangeListener listener) {
-        throw new UnsupportedOperationException("This method is not 
implemented");
-    }
-
-    public void addPropertyChangeListener(String propertyName, 
PropertyChangeListener listener) {
-        getPropertyChangeListeners(propertyName).add(listener);
-    }
-
-    public void removePropertyChangeListener(String propertyName, 
PropertyChangeListener listener) {
-        getPropertyChangeListeners(propertyName).remove(listener);
-    }
-
-    protected void fireChangedEvents(ValidationResults oldValidationResults) {
-        fireValidationResultsChanged();
-        firePropertyChange(HAS_ERRORS_PROPERTY, 
oldValidationResults.getHasErrors(), getHasErrors());
-        firePropertyChange(HAS_WARNINGS_PROPERTY, 
oldValidationResults.getHasWarnings(), getHasWarnings());
-        firePropertyChange(HAS_INFO_PROPERTY, 
oldValidationResults.getHasInfo(), getHasInfo());
-    }
-
-    protected void fireValidationResultsChanged() {
-        validationListeners.fire("validationResultsChanged", delegateFor);
-    }
-
-    protected void fireValidationResultsChanged(String propertyName) {
-        for (Iterator i = getValidationListeners(propertyName).iterator(); 
i.hasNext();) {
-            
((ValidationListener)i.next()).validationResultsChanged(delegateFor);           
 
-        }
-    }
-
-    protected EventListenerListHelper getValidationListeners(String 
propertyName) {
-        return 
((EventListenerListHelper)propertyValidationListeners.get(propertyName));
-    }
-
-    protected void firePropertyChange(String propertyName, boolean oldValue, 
boolean newValue) {
-        if (oldValue != newValue) {
-            EventListenerListHelper propertyChangeListeners = 
getPropertyChangeListeners(propertyName);
-            if (propertyChangeListeners.hasListeners()) {
-                PropertyChangeEvent event = new 
PropertyChangeEvent(delegateFor, propertyName,
-                        Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
-                propertyChangeListeners.fire("propertyChange", event);
-            }
-        }
-    }
-
-    protected EventListenerListHelper getPropertyChangeListeners(String 
propertyName) {
-        return 
((EventListenerListHelper)propertyChangeListeners.get(propertyName));
-    }
-    
-    public String toString() {
-        return new ToStringCreator(this).append("messages", 
getMessages()).toString();
-    }
-}
\ No newline at end of file

Deleted: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/EmptyValidationResults.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/EmptyValidationResults.java
    2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/EmptyValidationResults.java
    2006-10-02 13:38:28 UTC (rev 1475)
@@ -1,104 +0,0 @@
-/*
- * Copyright 2002-2005 the original author or authors.
- * 
- * 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 org.springframework.binding.validation;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.springframework.core.style.ToStringCreator;
-
-/**
- * An implementation of ValidationResults that contains no results. 
- * 
- * @author Oliver Hutchison
- */
-public class EmptyValidationResults implements ValidationResults {
-
-    /**
-     * The singleton instance of this class.
-     */
-    public static final ValidationResults INSTANCE = new 
EmptyValidationResults();
-
-    protected EmptyValidationResults() {
-    }
-
-    /**
-     * Always returns <code>false</code>
-     */
-    public boolean getHasErrors() {
-        return false;
-    }
-
-    /**
-     * Always returns <code>false</code>
-     */
-    public boolean getHasWarnings() {
-        return false;
-    }
-
-    /**
-     * Always returns <code>false</code>
-     */
-    public boolean getHasInfo() {
-        return false;
-    }
-
-    /**
-     * Always returns 0
-     */
-    public int getMessageCount() {
-        return 0;
-    }
-
-    /**
-     * Always returns 0
-     */
-    public int getMessageCount(Severity severity) {
-        return 0;
-    }
-
-    /**
-     * Always returns 0
-     */
-    public int getMessageCount(String propertyName) {
-        return 0;
-    }
-
-    /**
-     * Always returns an empty list.
-     */
-    public Set getMessages() {
-        return Collections.EMPTY_SET;
-    }
-
-    /**
-     * Always returns an empty list.
-     */
-    public Set getMessages(Severity severity) {
-        return Collections.EMPTY_SET;
-    }
-
-    /**
-     * Always returns an empty list.
-     */
-    public Set getMessages(String propertyName) {
-        return Collections.EMPTY_SET;
-    }
-    
-    public String toString() {
-        return new ToStringCreator(this).toString();
-    }
-}

Copied: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationMessage.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationMessage.java)
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationMessage.java
                          (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationMessage.java
  2006-10-02 13:38:28 UTC (rev 1475)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * 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 org.springframework.binding.validation.support;
+
+import java.io.Serializable;
+
+import org.springframework.binding.validation.Severity;
+import org.springframework.binding.validation.ValidationMessage;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.richclient.util.Assert;
+import org.springframework.util.ObjectUtils;
+
+/**
+ * Default implementation of ValidationMessage
+ * 
+ * @author  Oliver Hutchison
+ */
+public class DefaultValidationMessage implements ValidationMessage, 
Serializable {
+    private final long timeStamp;
+
+    private final String property;
+
+    private final Severity severity;
+
+    private final String message;
+
+    public DefaultValidationMessage(String property, Severity severity, String 
message) {
+        Assert.required(severity, "severity");
+        Assert.required(message, "message");
+        this.timeStamp = System.currentTimeMillis();
+        this.property = property;
+        this.severity = severity;
+        this.message = message;
+    }
+
+    public long getTimeStamp() {
+        return timeStamp;
+    }
+
+    public String getProperty() {
+        return property;
+    }
+
+    public Severity getSeverity() {
+        return severity;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public int hashCode() {
+        return (getProperty() != null ? (getProperty().hashCode() * 27) : 0) + 
(getSeverity().getShortCode() * 9)
+                + getMessage().hashCode();
+    }
+
+    public boolean equals(Object o) {
+        if (o == null || o.getClass() != this.getClass()) {
+            return false;
+        }
+        DefaultValidationMessage m2 = (DefaultValidationMessage)o;
+        return ObjectUtils.nullSafeEquals(getProperty(), m2.getProperty()) && 
getSeverity().equals(m2.getSeverity())
+                && getMessage().equals(m2.getMessage());
+    }
+
+    public String toString() {
+        return new ToStringCreator(this).append("property", getProperty())
+                .append("severity", getSeverity().getLabel())
+                .append("message", getMessage())
+                .toString();
+    }
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResults.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResults.java)
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResults.java
                          (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResults.java
  2006-10-02 13:38:28 UTC (rev 1475)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * 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 org.springframework.binding.validation.support;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.springframework.binding.validation.Severity;
+import org.springframework.binding.validation.ValidationMessage;
+import org.springframework.binding.validation.ValidationResults;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.util.CachingMapDecorator;
+import org.springframework.util.ObjectUtils;
+
+public class DefaultValidationResults implements ValidationResults {
+
+    private final Set messages = new HashSet();
+
+    private CachingMapDecorator messagesSubSets = new CachingMapDecorator() {
+
+        protected Object create(Object key) {
+            Set messagesSubSet = new HashSet();
+            for (Iterator i = messages.iterator(); i.hasNext();) {
+                ValidationMessage message = (ValidationMessage)i.next();
+                if (key instanceof Severity && 
message.getSeverity().equals(key)) {
+                    messagesSubSet.add(message);
+                }
+                else if (ObjectUtils.nullSafeEquals(message.getProperty(), 
key)) {
+                    messagesSubSet.add(message);
+                }
+            }
+            return Collections.unmodifiableSet(messagesSubSet);
+        }
+
+    };
+
+    public DefaultValidationResults() {
+    }
+
+    public DefaultValidationResults(ValidationResults validationResults) {
+        addAllMessages(validationResults);
+    }
+
+    public DefaultValidationResults(Collection validationMessages) {
+        addAllMessages(validationMessages);
+    }
+
+    public void addAllMessages(ValidationResults validationResults) {
+        addAllMessages(validationResults.getMessages());
+    }
+
+    public void addAllMessages(Collection validationMessages) {        
+        if (messages.addAll(validationMessages)) {
+            messagesSubSets.clear();
+        }
+    }
+
+    public void addMessage(ValidationMessage validationMessage) {
+        if (messages.add(validationMessage)) {            
+            messagesSubSets.clear();
+        }
+    }
+
+    public void addMessage(String field, Severity severity, String message) {
+        addMessage(new DefaultValidationMessage(field, severity, message));
+    }
+
+    public void removeMessage(ValidationMessage message) {
+        messages.remove(message);
+        messagesSubSets.clear();
+    }
+
+    public boolean getHasErrors() {
+        return getMessageCount(Severity.ERROR) > 0;
+    }
+
+    public boolean getHasWarnings() {
+        return getMessageCount(Severity.WARNING) > 0;
+    }
+
+    public boolean getHasInfo() {
+        return getMessageCount(Severity.INFO) > 0;
+    }
+
+    public int getMessageCount() {
+        return messages.size();
+    }
+
+    public int getMessageCount(Severity severity) {
+        return getMessages(severity).size();
+    }
+
+    public int getMessageCount(String fieldName) {
+        return getMessages(fieldName).size();
+    }
+
+    public Set getMessages() {
+        return Collections.unmodifiableSet(messages);
+    }
+
+    public Set getMessages(Severity severity) {
+        return (Set)messagesSubSets.get(severity);
+    }
+
+    public Set getMessages(String fieldName) {
+        return (Set)messagesSubSets.get(fieldName);
+    }
+
+    public String toString() {
+        return new ToStringCreator(this).append("messages", 
getMessages()).toString();
+    }
+    
+    /**
+     * Clear all messages.
+     * 
+     * @see RulesValidator#clearMessages()
+     */
+    public void clearMessages()
+    {
+        messages.clear();
+        messagesSubSets.clear();
+    }
+
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResults.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResultsModel.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/DefaultValidationResultsModel.java)
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResultsModel.java
                             (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResultsModel.java
     2006-10-02 13:38:28 UTC (rev 1475)
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * 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 org.springframework.binding.validation.support;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.binding.validation.Severity;
+import org.springframework.binding.validation.ValidationListener;
+import org.springframework.binding.validation.ValidationMessage;
+import org.springframework.binding.validation.ValidationResults;
+import org.springframework.binding.validation.ValidationResultsModel;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.richclient.util.Assert;
+import org.springframework.richclient.util.EventListenerListHelper;
+import org.springframework.util.CachingMapDecorator;
+import org.springframework.util.ObjectUtils;
+
+/**
+ * Default implementation of ValidationResultsModel
+ * 
+ * @author  Oliver Hutchison
+ */
+public class DefaultValidationResultsModel implements ValidationResultsModel {
+
+    private final EventListenerListHelper validationListeners = new 
EventListenerListHelper(ValidationListener.class);
+
+    private final CachingMapDecorator propertyValidationListeners = new 
CachingMapDecorator() {
+
+        protected Object create(Object propertyName) {
+            return new EventListenerListHelper(ValidationListener.class);
+        }
+    };
+
+    private final CachingMapDecorator propertyChangeListeners = new 
CachingMapDecorator() {
+
+        protected Object create(Object propertyName) {
+            return new EventListenerListHelper(PropertyChangeListener.class);
+        }
+    };
+
+    private final ValidationResultsModel delegateFor;
+
+    private ValidationResults validationResults = 
EmptyValidationResults.INSTANCE;
+
+    public DefaultValidationResultsModel() {
+        delegateFor = this;
+    }
+
+    public DefaultValidationResultsModel(ValidationResultsModel delegateFor) {
+        this.delegateFor = delegateFor;
+    }
+
+    public void updateValidationResults(ValidationResults 
newValidationResults) {
+        Assert.required(newValidationResults, "newValidationResults");
+        ValidationResults oldValidationResults = validationResults;
+        validationResults = newValidationResults;
+        if (oldValidationResults.getMessageCount() == 0 && 
validationResults.getMessageCount() == 0) {
+            return;
+        }
+        for (Iterator i = propertyValidationListeners.keySet().iterator(); 
i.hasNext();) {
+            String propertyName = (String)i.next();
+            if (oldValidationResults.getMessageCount(propertyName) > 0
+                    || validationResults.getMessageCount(propertyName) > 0) {
+                fireValidationResultsChanged(propertyName);
+            }
+        }
+        fireChangedEvents(oldValidationResults);
+    }
+    
+    // TODO: test
+    public void addMessage(ValidationMessage validationMessage) {
+        if (!validationResults.getMessages().contains(validationMessage)) {
+            ValidationResults oldValidationResults = validationResults;
+            List newMessages = new 
ArrayList(oldValidationResults.getMessages());
+            newMessages.add(validationMessage);
+            validationResults = new DefaultValidationResults(newMessages);
+            fireValidationResultsChanged(validationMessage.getProperty());
+            fireChangedEvents(oldValidationResults);
+        }
+    }
+
+    // TODO: test
+    public void removeMessage(ValidationMessage validationMessage) {
+        if (validationResults.getMessages().contains(validationMessage)) {
+            ValidationResults oldValidationResults = validationResults;
+            List newMessages = new 
ArrayList(oldValidationResults.getMessages());
+            newMessages.remove(validationMessage);
+            validationResults = new DefaultValidationResults(newMessages);
+            fireValidationResultsChanged(validationMessage.getProperty());
+            fireChangedEvents(oldValidationResults);
+        }
+    }
+
+    // TODO: test
+    public void replaceMessage(ValidationMessage messageToReplace, 
ValidationMessage replacementMessage) {        
+        ValidationResults oldValidationResults = validationResults;
+        List newMessages = new ArrayList(oldValidationResults.getMessages());
+        final boolean containsMessageToReplace = 
validationResults.getMessages().contains(messageToReplace);
+        if (containsMessageToReplace) {
+            newMessages.remove(messageToReplace);
+        }
+        newMessages.add(replacementMessage);
+        validationResults = new DefaultValidationResults(newMessages);
+        if (containsMessageToReplace && 
!ObjectUtils.nullSafeEquals(messageToReplace.getProperty(), 
replacementMessage.getProperty())) {
+            fireValidationResultsChanged(messageToReplace.getProperty());
+        }
+        fireValidationResultsChanged(replacementMessage.getProperty());
+        fireChangedEvents(oldValidationResults);
+    }
+
+    public void clearAllValidationResults() {
+        updateValidationResults(EmptyValidationResults.INSTANCE);
+    }
+
+    public boolean getHasErrors() {
+        return validationResults.getHasErrors();
+    }
+
+    public boolean getHasInfo() {
+        return validationResults.getHasInfo();
+    }
+
+    public boolean getHasWarnings() {
+        return validationResults.getHasWarnings();
+    }
+
+    public int getMessageCount() {
+        return validationResults.getMessageCount();
+    }
+
+    public int getMessageCount(Severity severity) {
+        return validationResults.getMessageCount(severity);
+    }
+
+    public int getMessageCount(String propertyName) {
+        return validationResults.getMessageCount(propertyName);
+    }
+
+    public Set getMessages() {
+        return validationResults.getMessages();
+    }
+
+    public Set getMessages(Severity severity) {
+        return validationResults.getMessages(severity);
+    }
+
+    public Set getMessages(String propertyName) {
+        return validationResults.getMessages(propertyName);
+    }
+
+    public void addValidationListener(ValidationListener listener) {
+        validationListeners.add(listener);
+    }
+
+    public void removeValidationListener(ValidationListener listener) {
+        validationListeners.remove(listener);
+    }
+
+    public void addValidationListener(String propertyName, ValidationListener 
listener) {
+        getValidationListeners(propertyName).add(listener);
+    }
+
+    public void removeValidationListener(String propertyName, 
ValidationListener listener) {
+        getValidationListeners(propertyName).remove(listener);
+    }
+
+    public void addPropertyChangeListener(PropertyChangeListener listener) {
+        throw new UnsupportedOperationException("This method is not 
implemented");
+    }
+
+    public void removePropertyChangeListener(PropertyChangeListener listener) {
+        throw new UnsupportedOperationException("This method is not 
implemented");
+    }
+
+    public void addPropertyChangeListener(String propertyName, 
PropertyChangeListener listener) {
+        getPropertyChangeListeners(propertyName).add(listener);
+    }
+
+    public void removePropertyChangeListener(String propertyName, 
PropertyChangeListener listener) {
+        getPropertyChangeListeners(propertyName).remove(listener);
+    }
+
+    protected void fireChangedEvents(ValidationResults oldValidationResults) {
+        fireValidationResultsChanged();
+        firePropertyChange(HAS_ERRORS_PROPERTY, 
oldValidationResults.getHasErrors(), getHasErrors());
+        firePropertyChange(HAS_WARNINGS_PROPERTY, 
oldValidationResults.getHasWarnings(), getHasWarnings());
+        firePropertyChange(HAS_INFO_PROPERTY, 
oldValidationResults.getHasInfo(), getHasInfo());
+    }
+
+    protected void fireValidationResultsChanged() {
+        validationListeners.fire("validationResultsChanged", delegateFor);
+    }
+
+    protected void fireValidationResultsChanged(String propertyName) {
+        for (Iterator i = getValidationListeners(propertyName).iterator(); 
i.hasNext();) {
+            
((ValidationListener)i.next()).validationResultsChanged(delegateFor);           
 
+        }
+    }
+
+    protected EventListenerListHelper getValidationListeners(String 
propertyName) {
+        return 
((EventListenerListHelper)propertyValidationListeners.get(propertyName));
+    }
+
+    protected void firePropertyChange(String propertyName, boolean oldValue, 
boolean newValue) {
+        if (oldValue != newValue) {
+            EventListenerListHelper propertyChangeListeners = 
getPropertyChangeListeners(propertyName);
+            if (propertyChangeListeners.hasListeners()) {
+                PropertyChangeEvent event = new 
PropertyChangeEvent(delegateFor, propertyName,
+                        Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
+                propertyChangeListeners.fire("propertyChange", event);
+            }
+        }
+    }
+
+    protected EventListenerListHelper getPropertyChangeListeners(String 
propertyName) {
+        return 
((EventListenerListHelper)propertyChangeListeners.get(propertyName));
+    }
+    
+    public String toString() {
+        return new ToStringCreator(this).append("messages", 
getMessages()).toString();
+    }
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/DefaultValidationResultsModel.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/EmptyValidationResults.java
 (from rev 1404, 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/EmptyValidationResults.java)
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/EmptyValidationResults.java
                            (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/EmptyValidationResults.java
    2006-10-02 13:38:28 UTC (rev 1475)
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ * 
+ * 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 org.springframework.binding.validation.support;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.springframework.binding.validation.Severity;
+import org.springframework.binding.validation.ValidationResults;
+import org.springframework.core.style.ToStringCreator;
+
+/**
+ * An implementation of ValidationResults that contains no results. 
+ * 
+ * @author Oliver Hutchison
+ */
+public class EmptyValidationResults implements ValidationResults {
+
+    /**
+     * The singleton instance of this class.
+     */
+    public static final ValidationResults INSTANCE = new 
EmptyValidationResults();
+
+    protected EmptyValidationResults() {
+    }
+
+    /**
+     * Always returns <code>false</code>
+     */
+    public boolean getHasErrors() {
+        return false;
+    }
+
+    /**
+     * Always returns <code>false</code>
+     */
+    public boolean getHasWarnings() {
+        return false;
+    }
+
+    /**
+     * Always returns <code>false</code>
+     */
+    public boolean getHasInfo() {
+        return false;
+    }
+
+    /**
+     * Always returns 0
+     */
+    public int getMessageCount() {
+        return 0;
+    }
+
+    /**
+     * Always returns 0
+     */
+    public int getMessageCount(Severity severity) {
+        return 0;
+    }
+
+    /**
+     * Always returns 0
+     */
+    public int getMessageCount(String propertyName) {
+        return 0;
+    }
+
+    /**
+     * Always returns an empty list.
+     */
+    public Set getMessages() {
+        return Collections.EMPTY_SET;
+    }
+
+    /**
+     * Always returns an empty list.
+     */
+    public Set getMessages(Severity severity) {
+        return Collections.EMPTY_SET;
+    }
+
+    /**
+     * Always returns an empty list.
+     */
+    public Set getMessages(String propertyName) {
+        return Collections.EMPTY_SET;
+    }
+    
+    public String toString() {
+        return new ToStringCreator(this).toString();
+    }
+}


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/EmptyValidationResults.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/RulesValidator.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/RulesValidator.java
    2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/RulesValidator.java
    2006-10-02 13:38:28 UTC (rev 1475)
@@ -23,8 +23,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.springframework.binding.form.FormModel;
 import 
org.springframework.binding.form.support.FormModelPropertyAccessStrategy;
-import org.springframework.binding.validation.DefaultValidationMessage;
-import org.springframework.binding.validation.DefaultValidationResults;
 import org.springframework.binding.validation.RichValidator;
 import org.springframework.binding.validation.Severity;
 import org.springframework.binding.validation.ValidationMessage;

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
       2006-10-02 13:13:23 UTC (rev 1474)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
       2006-10-02 13:38:28 UTC (rev 1475)
@@ -34,8 +34,6 @@
 import org.springframework.beans.PropertyValue;
 import org.springframework.beans.PropertyValues;
 import org.springframework.binding.form.FormModel;
-import org.springframework.binding.validation.DefaultValidationMessage;
-import org.springframework.binding.validation.DefaultValidationResults;
 import org.springframework.binding.validation.RichValidator;
 import org.springframework.binding.validation.Severity;
 import org.springframework.binding.validation.ValidationMessage;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to