1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.beans;
  17. import java.beans.PropertyEditorSupport;
  18. import java.util.Properties;
  19. import org.springframework.beans.MutablePropertyValues;
  20. import org.springframework.beans.propertyeditors.PropertiesEditor;
  21. /**
  22. * Editor for PropertyValues objects. Not
  23. * a GUI editor.
  24. * <br>NB: this editor must be registered with the JavaBeans API before it
  25. * will be available. Editors in this package are
  26. * registered by BeanWrapperImpl.
  27. * <br>The required format is defined in java.util.Properties documentation.
  28. * Each property must be on a new line.
  29. * <br>
  30. * The present implementation relies on a PropertiesEditor.
  31. * @author Rod Johnson
  32. */
  33. public class PropertyValuesEditor extends PropertyEditorSupport {
  34. /**
  35. * @see java.beans.PropertyEditor#setAsText(java.lang.String)
  36. */
  37. public void setAsText(String s) throws IllegalArgumentException {
  38. PropertiesEditor pe = new PropertiesEditor();
  39. pe.setAsText(s);
  40. Properties props = (Properties) pe.getValue();
  41. setValue(new MutablePropertyValues(props));
  42. }
  43. }