javax.swing.text.ChangedCharSetException#getCharSetSpec ( )源码实例Demo

下面列出了javax.swing.text.ChangedCharSetException#getCharSetSpec ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: HTMLJavadocParser.java
private static String getCharSet(ChangedCharSetException e) {
    String spec = e.getCharSetSpec();
    if (e.keyEqualsCharSet()) {
        //charsetspec contains only charset
        return spec;
    }
    
    //charsetspec is in form "text/html; charset=UTF-8"
            
    int index = spec.indexOf(";"); // NOI18N
    if (index != -1) {
        spec = spec.substring(index + 1);
    }
    
    spec = spec.toLowerCase();
    
    StringTokenizer st = new StringTokenizer(spec, " \t=", true); //NOI18N
    boolean foundCharSet = false;
    boolean foundEquals = false;
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.equals(" ") || token.equals("\t")) { //NOI18N
            continue;
        }
        if (foundCharSet == false && foundEquals == false
                && token.equals("charset")) { //NOI18N
            foundCharSet = true;
            continue;
        } else if (foundEquals == false && token.equals("=")) {//NOI18N
            foundEquals = true;
            continue;
        } else if (foundEquals == true && foundCharSet == true) {
            return token;
        }
        
        foundCharSet = false;
        foundEquals = false;
    }
    
    return null;
}
 
源代码2 项目: netbeans   文件: JavadocHelper.java
/**
 * Returns the charset from given {@link ChangedCharSetException}
 * @param e the {@link ChangedCharSetException}
 * @return the charset or null
 */
@CheckForNull
public static String getCharSet(ChangedCharSetException e) {
    String spec = e.getCharSetSpec();
    if (e.keyEqualsCharSet()) {
        //charsetspec contains only charset
        return spec;
    }

    //charsetspec is in form "text/html; charset=UTF-8"

    int index = spec.indexOf(";"); // NOI18N
    if (index != -1) {
        spec = spec.substring(index + 1);
    }

    spec = spec.toLowerCase();

    StringTokenizer st = new StringTokenizer(spec, " \t=", true); //NOI18N
    boolean foundCharSet = false;
    boolean foundEquals = false;
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.equals(" ") || token.equals("\t")) { //NOI18N
            continue;
        }
        if (foundCharSet == false && foundEquals == false
                && token.equals("charset")) { //NOI18N
            foundCharSet = true;
            continue;
        } else if (foundEquals == false && token.equals("=")) {//NOI18N
            foundEquals = true;
            continue;
        } else if (foundEquals == true && foundCharSet == true) {
            return token;
        }

        foundCharSet = false;
        foundEquals = false;
    }

    return null;
}
 
源代码3 项目: netbeans   文件: HTMLJavadocParser.java
private static String getCharSet(ChangedCharSetException e) {
    String spec = e.getCharSetSpec();
    if (e.keyEqualsCharSet()) {
        //charsetspec contains only charset
        return spec;
    }
    
    //charsetspec is in form "text/html; charset=UTF-8"
            
    int index = spec.indexOf(";"); // NOI18N
    if (index != -1) {
        spec = spec.substring(index + 1);
    }
    
    spec = spec.toLowerCase(Locale.ENGLISH);
    
    StringTokenizer st = new StringTokenizer(spec, " \t=", true); //NOI18N
    boolean foundCharSet = false;
    boolean foundEquals = false;
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.equals(" ") || token.equals("\t")) { //NOI18N
            continue;
        }
        if (foundCharSet == false && foundEquals == false
                && token.equals("charset")) { //NOI18N
            foundCharSet = true;
            continue;
        } else if (foundEquals == false && token.equals("=")) {//NOI18N
            foundEquals = true;
            continue;
        } else if (foundEquals == true && foundCharSet == true) {
            return token;
        }
        
        foundCharSet = false;
        foundEquals = false;
    }
    
    return null;
}