1 24 package org.riotfamily.components.property; 25 26 import java.util.Map ; 27 28 import org.riotfamily.components.PropertyProcessor; 29 import org.springframework.beans.factory.InitializingBean; 30 import org.springframework.util.Assert; 31 32 35 public abstract class AbstractSinglePropertyProcessor 36 implements PropertyProcessor, InitializingBean { 37 38 private String property; 39 40 public AbstractSinglePropertyProcessor() { 41 } 42 43 public final void afterPropertiesSet() throws Exception { 44 Assert.notNull(property, "The name of the property must be set."); 45 initialize(); 46 } 47 48 protected void initialize() { 49 } 50 51 public void setProperty(String property) { 52 this.property = property; 53 } 54 55 public void resolveStrings(Map map) { 56 Object value = map.get(property); 57 if (value instanceof String || value == null) { 58 map.put(property, resolveString((String ) value)); 59 } 60 } 61 62 protected abstract Object resolveString(String s); 63 64 public void convertToStrings(Map map) { 65 Object object = map.get(property); 66 if (!(object instanceof String )) { 67 map.put(property, convertToString(object)); 68 } 69 } 70 71 protected abstract String convertToString(Object object); 72 73 public void copy(Map source, Map dest) { 74 String s = (String ) source.get(property); 75 dest.put(property, copy(s)); 76 } 77 78 protected String copy(String s) { 79 return s; 80 } 81 82 public void delete(Map map) { 83 String s = (String ) map.get(property); 84 delete(s); 85 } 86 87 protected void delete(String s) { 88 } 89 90 public String [] getCacheTags(Map map) { 91 String s = (String ) map.get(property); 92 String tag = getCacheTag(s); 93 return tag != null ? new String [] {tag} : null; 94 } 95 96 protected String getCacheTag(String s) { 97 return null; 98 } 99 100 } 101 | Popular Tags |