[java-opensaml COMMIT] /trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java

noreply at shibboleth.net noreply at shibboleth.net
Fri Jan 15 14:33:02 EST 2016


Author: putmanb
Date: Fri Jan 15 14:33:02 2016
New Revision: 4422

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4422&view=rev
Log:
OSJ-153: AbstractXMLObject prepareForAssignment(String, String) should have variant that doesn't normalize input

Modified:
    trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java

Modified: trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java?rev=4422&r1=4421&r2=4422&view=diff
==============================================================================
--- trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java	(original)
+++ trunk/opensaml-core/src/main/java/org/opensaml/core/xml/AbstractXMLObject.java	Fri Jan 15 14:33:02 2016
@@ -258,7 +258,26 @@
      * @return the value that should be assigned
      */
     @Nullable protected String prepareForAssignment(@Nullable final String oldValue, @Nullable final String newValue) {
-        String newString = StringSupport.trimOrNull(newValue);
+        return prepareForAssignment(oldValue, newValue, true);
+    }
+    
+    /**
+     * A helper function for derived classes. This 'normalizes' newString if <code>normalize=true</code>,
+     * and then if it is different from oldString invalidates the DOM. It returns the new effective value so 
+     * subclasses just have to go. this.foo = prepareForAssignment(this.foo, foo);
+     * 
+     * @param oldValue - the current value
+     * @param newValue - the new value
+     * @param normalize - whether the newValue should be normalized
+     * 
+     * @return the value that should be assigned
+     */
+    @Nullable protected String prepareForAssignment(@Nullable final String oldValue, @Nullable final String newValue, 
+            boolean normalize) {
+        String newString = newValue;
+        if (normalize) {
+            newString = StringSupport.trimOrNull(newString);
+        }
 
         if (!Objects.equals(oldValue, newString)) {
             releaseThisandParentDOM();



More information about the commits mailing list