- Timestamp:
- 2009-05-23T11:53:37+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r1605 r1610 261 261 } 262 262 263 synchronized public boolean putLong(final String key, final Long value) { 264 return put(key, Long.toString(value)); 265 } 266 263 267 private final void firePreferenceChanged(final String key, final String value) { 264 268 for (final PreferenceChangedListener l : listener) -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r1450 r1610 11 11 import org.openstreetmap.josm.Main; 12 12 13 /** 14 * Use this class if you want to cache and store a single file that gets updated regularly. 15 * Unless you flush() it will be kept in memory. If you want to cache a lot of data and/or files, 16 * use CacheFiles 17 * @author xeen 18 * 19 */ 13 20 public abstract class CacheCustomContent { 14 21 /** … … 21 28 final static public int INTERVAL_MONTHLY = INTERVAL_WEEKLY * 4; 22 29 final static public int INTERVAL_NEVER = Integer.MAX_VALUE; 23 30 24 31 /** 25 * Where the data will be stored 32 * Where the data will be stored 26 33 */ 27 34 private byte[] data = null; 28 35 29 36 /** 30 37 * The ident that identifies the stored file. Includes file-ending. 31 38 */ 32 39 final private String ident; 33 40 34 41 /** 35 42 * The (file-)path where the data will be stored 36 43 */ 37 44 final private File path; 38 45 39 46 /** 40 47 * How often to update the cached version 41 48 */ 42 49 final private int updateInterval; 43 50 44 51 /** 45 52 * This function will be executed when an update is required. It has to be implemented by the … … 49 56 */ 50 57 protected abstract byte[] updateData(); 51 58 52 59 /** 53 60 * This function serves as a comfort hook to perform additional checks if the cache is valid … … 56 63 protected boolean isCacheValid() { 57 64 return true; 58 } 59 65 } 66 60 67 /** 61 68 * Initializes the class. Note that all read data will be stored in memory until it is flushed 62 * by flushData(). 69 * by flushData(). 63 70 * @param ident 64 71 * @param updateInterval … … 69 76 this.path = new File(Main.pref.getPreferencesDir(), ident); 70 77 } 71 78 72 79 /** 73 80 * Updates data if required … … 80 87 return getData(); 81 88 } 82 89 83 90 /** 84 91 * Updates data if required … … 91 98 return getDataString(); 92 99 } 93 100 94 101 /** 95 102 * Executes an update regardless of updateInterval … … 102 109 return data; 103 110 } 104 111 105 112 /** 106 113 * Executes an update regardless of updateInterval … … 121 128 return data; 122 129 } 123 130 124 131 /** 125 132 * Returns the data without performing any updates … … 131 138 132 139 /** 133 * Tries to load the data using the given ident from disk. If this fails, data will be updated 140 * Tries to load the data using the given ident from disk. If this fails, data will be updated 134 141 */ 135 142 private void loadFromDisk() { … … 143 150 } 144 151 } 145 152 146 153 /** 147 154 * Stores the data to disk … … 154 161 output.close(); 155 162 } catch(Exception e) {} 156 } 157 163 } 164 158 165 /** 159 166 * Flushes the data from memory. Class automatically reloads it from disk or updateData() if
Note:
See TracChangeset
for help on using the changeset viewer.