File: URLResourceFinder.java

package info (click to toggle)
liblessen-java 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: java: 2,981; xml: 31; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.metaweb.lessen;

import java.net.MalformedURLException;
import java.net.URL;

import com.metaweb.lessen.tokenizers.Tokenizer;


public class URLResourceFinder implements ResourceFinder {
    final protected URL _base;
    
    public URLResourceFinder(URL base) {
        _base = base;
    }

    @Override
    public Tokenizer open(String where) {
        try {
            URL url = new URL(_base, where);
            
            return Utilities.open(url);
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public ResourceFinder rebase(String where) {
        try {
            return new URLResourceFinder(new URL(_base, where));
        } catch (MalformedURLException e) {
            return null;
        }
    }
}