Java Code Examples for java.nio.charset.Charset.aliases()

The following are Jave code examples for showing how to use aliases() of the java.nio.charset.Charset class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: the-vigilantes   File: CharsetMapping.java   View Source Code Vote up 5 votes
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
Example 2
Project: OpenVertretung   File: CharsetMapping.java   View Source Code Vote up 5 votes
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
Example 3
Project: lams   File: CharsetMapping.java   View Source Code Vote up 5 votes
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
Example 4
Project: ProyectoPacientes   File: CharsetMapping.java   View Source Code Vote up 5 votes
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
Example 5
Project: BibliotecaPS   File: CharsetMapping.java   View Source Code Vote up 5 votes
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}