Java Code Examples for javax.swing.text.ChangedCharSetException#getCharSetSpec()
The following examples show how to use
javax.swing.text.ChangedCharSetException#getCharSetSpec() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HTMLJavadocParser.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 2
Source File: JavadocHelper.java From netbeans with Apache License 2.0 | 4 votes |
/** * 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; }
Example 3
Source File: HTMLJavadocParser.java From netbeans with Apache License 2.0 | 4 votes |
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; }