Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2009 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.beans;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
Default implementation of the PropertyValues interface. Allows simple manipulation of properties, and provides constructors to support deep copy and construction from a Map.

Author(s):
Rod Johnson
Juergen Hoeller
Rob Harrop
Since:
13 May 2001
 
 public class MutablePropertyValues implements PropertyValuesSerializable {
 
 	private final List<PropertyValuepropertyValueList;
 
 
 	private volatile boolean converted = false;


Creates a new empty MutablePropertyValues object.

Property values can be added with the add method.

 
 	public MutablePropertyValues() {
 	}

Deep copy constructor. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.

Parameters:
original the PropertyValues to copy
See also:
addPropertyValues(org.springframework.beans.PropertyValues)
 
 	public MutablePropertyValues(PropertyValues original) {
 		// We can optimize this because it's all new:
 		// There is no replacement of existing property values.
 		if (original != null) {
 			PropertyValue[] pvs = original.getPropertyValues();
 			this. = new ArrayList<PropertyValue>(pvs.length);
 			for (PropertyValue pv : pvs) {
 			}
 		}
 		else {
 		}
 	}

Construct a new MutablePropertyValues object from a Map.

Parameters:
original Map with property values keyed by property name Strings
See also:
addPropertyValues(java.util.Map)
 
 	public MutablePropertyValues(Map<?, ?> original) {
 		// We can optimize this because it's all new:
 		// There is no replacement of existing property values.
 		if (original != null) {
 			this. = new ArrayList<PropertyValue>(original.size());
 			for (Map.Entry entry : original.entrySet()) {
 				this..add(new PropertyValue(entry.getKey().toString(), entry.getValue()));
 			}
 		}
 		else {
 		}
 	}

Construct a new MutablePropertyValues object using the given List of PropertyValue objects as-is.

This is a constructor for advanced usage scenarios. It is not intended for typical programmatic use.

Parameters:
propertyValueList List of PropertyValue objects
	public MutablePropertyValues(List<PropertyValuepropertyValueList) {
				(propertyValueList != null ? propertyValueList : new ArrayList<PropertyValue>());
	}


Return the underlying List of PropertyValue objects in its raw form. The returned List can be modified directly, although this is not recommended.

This is an accessor for optimized access to all PropertyValue objects. It is not intended for typical programmatic use.

		return this.;
	}

Return the number of PropertyValue entries in the list.
	public int size() {
		return this..size();
	}

Copy all given PropertyValues into this object. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.

Parameters:
other the PropertyValues to copy
Returns:
this in order to allow for adding multiple property values in a chain
		if (other != null) {
			PropertyValue[] pvs = other.getPropertyValues();
			for (PropertyValue pv : pvs) {
			}
		}
		return this;
	}

Add all property values from the given Map.

Parameters:
other Map with property values keyed by property name, which must be a String
Returns:
this in order to allow for adding multiple property values in a chain
	public MutablePropertyValues addPropertyValues(Map<?, ?> other) {
		if (other != null) {
			for (Map.Entry<?, ?> entry : other.entrySet()) {
			}
		}
		return this;
	}

Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).

Parameters:
pv PropertyValue object to add
Returns:
this in order to allow for adding multiple property values in a chain
		for (int i = 0; i < this..size(); i++) {
			PropertyValue currentPv = this..get(i);
			if (currentPv.getName().equals(pv.getName())) {
				pv = mergeIfRequired(pvcurrentPv);
				return this;
			}
		}
		return this;
	}

Overloaded version of addPropertyValue that takes a property name and a property value.

Note: As of Spring 3.0, we recommend using the more concise and chaining-capable variant add(java.lang.String,java.lang.Object).

Parameters:
propertyName name of the property
propertyValue value of the property
See also:
addPropertyValue(org.springframework.beans.PropertyValue)
	public void addPropertyValue(String propertyNameObject propertyValue) {
		addPropertyValue(new PropertyValue(propertyNamepropertyValue));
	}

Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).

Parameters:
propertyName name of the property
propertyValue value of the property
Returns:
this in order to allow for adding multiple property values in a chain
	public MutablePropertyValues add(String propertyNameObject propertyValue) {
		addPropertyValue(new PropertyValue(propertyNamepropertyValue));
		return this;
	}

Modify a PropertyValue object held in this object. Indexed from 0.
	public void setPropertyValueAt(PropertyValue pvint i) {
		this..set(ipv);
	}

Merges the value of the supplied 'new' PropertyValue with that of the current PropertyValue if merging is supported and enabled.

See also:
Mergeable
	private PropertyValue mergeIfRequired(PropertyValue newPvPropertyValue currentPv) {
		Object value = newPv.getValue();
		if (value instanceof Mergeable) {
			Mergeable mergeable = (Mergeablevalue;
			if (mergeable.isMergeEnabled()) {
				Object merged = mergeable.merge(currentPv.getValue());
				return new PropertyValue(newPv.getName(), merged);
			}
		}
		return newPv;
	}

Remove the given PropertyValue, if contained.

Parameters:
pv the PropertyValue to remove
	public void removePropertyValue(PropertyValue pv) {
	}

Overloaded version of removePropertyValue that takes a property name.

Parameters:
propertyName name of the property
See also:
removePropertyValue(org.springframework.beans.PropertyValue)
	public void removePropertyValue(String propertyName) {
	}
	}
	public PropertyValue getPropertyValue(String propertyName) {
		for (PropertyValue pv : this.) {
			if (pv.getName().equals(propertyName)) {
				return pv;
			}
		}
		return null;
	}
		if (old == this) {
			return changes;
		}
		// for each property value in the new set
		for (PropertyValue newPv : this.) {
			// if there wasn't an old one, add it
			PropertyValue pvOld = old.getPropertyValue(newPv.getName());
			if (pvOld == null) {
				changes.addPropertyValue(newPv);
			}
			else if (!pvOld.equals(newPv)) {
				// it's changed
				changes.addPropertyValue(newPv);
			}
		}
		return changes;
	}
	public boolean contains(String propertyName) {
		return (getPropertyValue(propertyName) != null ||
				(this. != null && this..contains(propertyName)));
	}
	public boolean isEmpty() {
		return this..isEmpty();
	}


Register the specified property as "processed" in the sense of some processor calling the corresponding setter method outside of the PropertyValue(s) mechanism.

This will lead to true being returned from a contains(java.lang.String) call for the specified property.

Parameters:
propertyName the name of the property.
	public void registerProcessedProperty(String propertyName) {
		if (this. == null) {
		}
		this..add(propertyName);
	}

Mark this holder as containing converted values only (i.e. no runtime resolution needed anymore).
	public void setConverted() {
		this. = true;
	}

Return whether this holder contains converted values only (true), or whether the values still need to be converted (false).
	public boolean isConverted() {
		return this.;
	}
	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof MutablePropertyValues)) {
			return false;
		}
		return this..equals(that.propertyValueList);
	}
	public int hashCode() {
	}
	public String toString() {
		StringBuilder sb = new StringBuilder("PropertyValues: length=" + pvs.length + "; ");
		sb.append(StringUtils.arrayToDelimitedString(pvs"; "));
		return sb.toString();
	}
New to GrepCode? Check out our FAQ X