File: Encoding.java

package info (click to toggle)
flutejava 1.3-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,316 kB
  • ctags: 1,070
  • sloc: java: 8,251; makefile: 51
file content (49 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright (c) 1999 World Wide Web Consortium
 * (Massachusetts Institute of Technology, Institut National de Recherche
 *  en Informatique et en Automatique, Keio University).
 * All Rights Reserved. http://www.w3.org/Consortium/Legal/
 *
 * $Id: Encoding.java,v 1.1 1999/04/02 13:23:32 plehegar Exp $
 */
package org.w3c.flute.util;

import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

/**
 * @version $Revision: 1.1 $
 * @author  Philippe Le Hegaret
 */
public class Encoding {
    private Encoding() {}

    /**
     * Converts the format encoding information into Java encoding information.
     */
    public static String getJavaEncoding(String encoding) {
	String _result = encodings.getProperty(encoding);
	if (_result == null) {
	    return encoding;
	}
	return _result;
    }

    static Properties encodings;

    static {
	encodings = new Properties();
	
	try {
            URL url = Encoding.class.getResource("encoding.properties");
            InputStream f = url.openStream();
            encodings.load(f);
            f.close();
        } catch (Exception e) {
            System.err.println(Encoding.class
                               + ": couldn't load encoding properties ");
            e.printStackTrace();
	}
    }
}