Home | History | Annotate | Download | only in charset

Lines Matching defs:Charset

18 package java.nio.charset;
27 import java.nio.charset.spi.CharsetProvider;
43 import com.ibm.icu4jni.charset.CharsetProviderICU;
47 * A charset defines a mapping between a Unicode character sequence and a byte
52 * A charset has a canonical name, which is usually in uppercase. Typically it
60 * Additional charsets can be made available by configuring one or more charset
62 * as "java.nio.charset.spi.CharsetProvider" and located in the
65 * charset provider which extends
66 * <code>java.nio.charset.spi.CharsetProvider</code>. A line should end with
75 * @see java.nio.charset.spi.CharsetProvider
77 public abstract class Charset implements Comparable<Charset> {
80 * The name of configuration files where charset provider class names can be
83 private static final String PROVIDER_CONFIGURATION_FILE_NAME = "META-INF/services/java.nio.charset.spi.CharsetProvider"; //$NON-NLS-1$
103 private static TreeMap<String, Charset> _builtInCharsets = null;
110 // cached Charset table
111 private final static HashMap<String, Charset> cachedCharsetTable = new HashMap<String, Charset>();
117 * Create built-in charset provider even if no privilege to access
118 * charset provider.
129 * Constructs a <code>Charset</code> object. Duplicated aliases are
133 * the canonical name of the charset.
135 * an array containing all aliases of the charset. May be null.
141 protected Charset(String canonicalName, String[] aliases) {
160 * charset names, other than letters and digits.
183 * Checks whether a given string is a legal charset name. The argument name
187 // An empty string is illegal charset name
238 TreeMap<String, Charset> charsets) {
239 Iterator<Charset> it = cp.charsets();
241 Charset cs = it.next();
267 ClassLoader contextClassLoader, TreeMap<String, Charset> charsets) {
271 // Read each line for charset provider class names
281 // Load the charset provider
322 * instances of <code>Charset</code>. The canonical names can be considered
329 public static SortedMap<String, Charset> availableCharsets() {
332 // Charset.forName("TIS-620");
333 // Charset.forName("windows-1258");
334 // Charset.forName("cp856");
335 // Charset.forName("cp922");
340 synchronized (Charset.class) {
342 _builtInCharsets = new TreeMap<String, Charset>(
350 TreeMap<String, Charset> charsets = (TreeMap<String, Charset>) _builtInCharsets
353 // Collect all charsets provided by charset providers
377 * Read a configuration file and try to find the desired charset among those
381 private static Charset searchConfiguredCharsets(String charsetName,
386 // Read each line for charset provider class names
395 // Load the charset provider
419 // Try to get the desired charset from this provider
420 Charset
447 * Gets a <code>Charset</code> instance for the specified charset name. If
448 * the charset is not supported, returns null instead of throwing an
451 private synchronized static Charset forNameInternal(String charsetName)
453 Charset cs = cachedCharsetTable.get(charsetName);
474 // collect all charsets provided by charset providers
512 * save charset into cachedCharsetTable
514 private static void cacheCharset(Charset cs) {
531 * Gets a <code>Charset</code> instance for the specified charset name.
534 * the canonical name of the charset or an alias.
535 * @return a <code>Charset</code> instance for the specified charset name.
537 * if the specified charset name is illegal.
539 * if the desired charset is not supported by this runtime.
541 public static Charset forName(String charsetName) {
542 Charset c = forNameInternal(charsetName);
550 * Determines whether the specified charset is supported by this runtime.
553 * the name of the charset.
554 * @return true if the specified charset is supported, otherwise false.
556 * if the specified charset name is illegal.
560 Charset cs = cachedCharsetTable.get(charsetName);
583 Charset cs = forNameInternal(charsetName);
590 * Determines whether this charset is a super set of the given charset.
592 * @param charset
593 * a given charset.
594 * @return true if this charset is a super set of the given charset,
595 * false if it's unknown or this charset is not a superset of
596 * the given charset.
598 public abstract boolean contains(Charset charset);
601 * Gets a new instance of an encoder for this charset.
603 * @return a new instance of an encoder for this charset.
608 * Gets a new instance of a decoder for this charset.
610 * @return a new instance of a decoder for this charset.
615 * Gets the canonical name of this charset.
617 * @return this charset's name in canonical form.
624 * Gets the set of this charset's aliases.
626 * @return an unmodifiable set of this charset's aliases.
633 * Gets the name of this charset for the default locale.
635 * <p>The default implementation returns the canonical name of this charset.
638 * @return the name of this charset for the default locale.
645 * Gets the name of this charset for the specified locale.
647 * <p>The default implementation returns the canonical name of this charset.
652 * @return the name of this charset for the specified locale
659 * Indicates whether this charset is known to be registered in the IANA
660 * Charset Registry.
662 * @return true if the charset is known to be registered, otherwise returns
671 * Returns true if this charset supports encoding, false otherwise.
673 * @return true if this charset supports encoding, false otherwise.
747 * Compares this charset with the given charset. This comparation is
750 * @param charset
755 public final int compareTo(Charset charset) {
756 return this.canonicalName.compareToIgnoreCase(charset.canonicalName);
766 * Determines whether this charset equals to the given object. They are
775 if (obj instanceof Charset) {
776 Charset that = (Charset) obj;
783 * Gets the hash code of this charset.
785 * @return the hash code of this charset.
793 * Gets a string representation of this charset. Usually this contains the
794 * canonical name of the charset.
796 * @return a string representation of this charset.
800 return "Charset[" + this.canonicalName + "]"; //$NON-NLS-1$//$NON-NLS-2$
804 * Gets the system default charset from the virtual machine.
806 * @return the default charset.
808 public static Charset defaultCharset() {
809 Charset defaultCharset = null;
817 defaultCharset = Charset.forName(encoding);
819 defaultCharset = Charset.forName("UTF-8"); //$NON-NLS-1$