1 12 13 package com.openedit.users.filesystem; 14 15 import java.io.Serializable ; 16 import java.util.Date ; 17 import java.util.Map ; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 import com.openedit.users.InvalidPropertyNameException; 23 import com.openedit.users.PropertyContainer; 24 import com.openedit.users.UnsupportedPropertyTypeException; 25 import com.openedit.users.UserManagerException; 26 27 28 34 public abstract class FileSystemObject implements PropertyContainer, Serializable 35 { 36 private transient static Log log = null; 37 private Log getLog() 38 { 39 if( log == null) 40 { 41 log = LogFactory.getLog(FileSystemObject.class); 42 } 43 return log; 44 } 45 46 protected PropertyContainer fieldPropertyContainer; 47 protected Date fieldCreationDate; 50 51 52 public FileSystemObject() 53 { 54 } 55 56 public PropertyContainer getPropertyContainer() 57 { 58 if( fieldPropertyContainer == null) 59 { 60 fieldPropertyContainer = new MapPropertyContainer(); 61 } 62 return fieldPropertyContainer; 63 } 64 public void setPropertyContainer(PropertyContainer inData ) 65 { 66 fieldPropertyContainer = inData; 67 } 68 73 public Map getProperties() 74 { 75 return getPropertyContainer().getProperties(); 76 } 77 78 86 public Object get( String inPropertyName ) 87 { 88 return getPropertyContainer().get( inPropertyName ); 89 } 90 91 public Date getCreationDate() 92 { 93 return fieldCreationDate; 94 } 95 protected void setCreationDate(Date inDate) 96 { 97 fieldCreationDate = inDate; 98 } 99 134 public void put( String inPropertyName, Object inPropertyValue ) 135 throws UserManagerException 136 { 137 getPropertyContainer().put( inPropertyName, inPropertyValue ); 138 } 139 140 151 public void putAll( Map inProperties ) throws UserManagerException 152 { 153 getPropertyContainer().putAll( inProperties ); 154 } 155 156 164 public void remove( String inPropertyName ) throws UserManagerException 165 { 166 getPropertyContainer().remove( inPropertyName ); 167 } 168 169 177 public void removeAll( String [] inProperties ) throws UserManagerException 178 { 179 getPropertyContainer().removeAll( inProperties ); 180 } 181 182 public boolean getBoolean( String inPropertyName ) 183 { 184 return Boolean.valueOf( getString( inPropertyName ) ).booleanValue(); 185 } 186 187 public String getString( String inPropertyName ) 188 { 189 return (String ) get( inPropertyName ); 190 } 191 192 public void safePut( String inKey, Object inValue ) 193 { 194 try 195 { 196 if ( inValue == null) 197 { 198 getPropertyContainer().remove( inKey ); 199 } 200 else 201 { 202 Object value = inValue; 203 if ( inValue instanceof String ) 204 { 205 value = ( (String ) inValue ).trim(); 206 } 207 getPropertyContainer().put( inKey, value ); 208 } 209 } 210 catch ( UserManagerException ex) 211 { 212 getLog().error( ex ); 213 } 214 } 215 216 } 217 | Popular Tags |