239
240 /**
241 *
242 */
243 private synchronized void replaceDocument(String uri, CachedDocument doc) {
244 if (doc == null)
245 insertDocument(uri, doc);
246 else
247 _references.put(uri, doc);
248 }
249
250 /**
251 * Returns a document either by finding it in the cache or
252 * downloading it and putting it in the cache.
253 */
254 @Override
255 public DOM retrieveDocument(String baseURI, String href, Translet trs) {
256 CachedDocument doc;
257
258 String uri = href;
259 if (baseURI != null && !baseURI.equals("")) {
260 try {
261 uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
262 } catch (TransformerException te) {
263 // ignore
264 }
265 }
266
267 // Try to get the document from the cache first
268 if ((doc = lookupDocument(uri)) == null) {
269 doc = new CachedDocument(uri);
270 if (doc == null) return null; // better error handling needed!!!
271 doc.setLastModified(getLastModified(uri));
272 insertDocument(uri, doc);
273 }
274 // If the document is in the cache we must check if it is still valid
275 else {
276 long now = System.currentTimeMillis();
277 long chk = doc.getLastChecked();
278 doc.setLastChecked(now);
279 // Has the modification time for this file been checked lately?
|
239
240 /**
241 *
242 */
243 private synchronized void replaceDocument(String uri, CachedDocument doc) {
244 if (doc == null)
245 insertDocument(uri, doc);
246 else
247 _references.put(uri, doc);
248 }
249
250 /**
251 * Returns a document either by finding it in the cache or
252 * downloading it and putting it in the cache.
253 */
254 @Override
255 public DOM retrieveDocument(String baseURI, String href, Translet trs) {
256 CachedDocument doc;
257
258 String uri = href;
259 if (baseURI != null && !baseURI.isEmpty()) {
260 try {
261 uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
262 } catch (TransformerException te) {
263 // ignore
264 }
265 }
266
267 // Try to get the document from the cache first
268 if ((doc = lookupDocument(uri)) == null) {
269 doc = new CachedDocument(uri);
270 if (doc == null) return null; // better error handling needed!!!
271 doc.setLastModified(getLastModified(uri));
272 insertDocument(uri, doc);
273 }
274 // If the document is in the cache we must check if it is still valid
275 else {
276 long now = System.currentTimeMillis();
277 long chk = doc.getLastChecked();
278 doc.setLastChecked(now);
279 // Has the modification time for this file been checked lately?
|