diff options
author | Alexander Kurtakov | 2016-07-08 09:01:43 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2016-07-08 09:01:43 +0000 |
commit | dfbf925d5d364bcd5f5a7d841b44fe0860bef3db (patch) | |
tree | 0dd3cf2d276285606e3449272d27db319183ed3f /org.eclipse.help.webapp | |
parent | 2ef1e5d654acfaf55187ee45921a2270695b6142 (diff) | |
download | eclipse.platform.ua-dfbf925d5d364bcd5f5a7d841b44fe0860bef3db.tar.gz eclipse.platform.ua-dfbf925d5d364bcd5f5a7d841b44fe0860bef3db.tar.xz eclipse.platform.ua-dfbf925d5d364bcd5f5a7d841b44fe0860bef3db.zip |
Bug 497548 - Make use of StandardCharsetsI20160708-1700
All the various places defining and using different UTF-8 charset name
constants is too error prone. Let's stick to StandardCharsets.UTF-8
which even saves the string lookup too.
Change-Id: Idcb356d0293cd2d0d0148de4e1f2e131584d09c4
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.help.webapp')
4 files changed, 14 insertions, 12 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java index 68799368f..aa50e958e 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation and others. + * Copyright (c) 2009, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ package org.eclipse.help.internal.webapp.servlet; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; @@ -29,7 +30,6 @@ import org.eclipse.help.internal.webapp.data.UrlUtil; public class ChildLinkInserter { - private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ private HttpServletRequest req; private OutputStream out; private static final String NO_CHILDREN = "no_child_topics"; //$NON-NLS-1$ @@ -77,7 +77,7 @@ public class ChildLinkInserter { if (encoding != null) { out.write(linkString.getBytes(encoding)); } else { - out.write(linkString.getBytes("UTF8")); //$NON-NLS-1$ + out.write(linkString.getBytes(StandardCharsets.UTF_8)); } } catch (UnsupportedEncodingException e) { out.write(linkString.getBytes()); @@ -114,16 +114,16 @@ public class ChildLinkInserter { return buf.toString(); } - public void addStyle() throws UnsupportedEncodingException, IOException { + public void addStyle() throws IOException { ITopic[] subtopics = getSubtopics(); for (ITopic subtopic : subtopics) { if (ScopeUtils.showInTree(subtopic, scope)) { - out.write(HAS_CHILDREN.getBytes(UTF_8)); + out.write(HAS_CHILDREN.getBytes(StandardCharsets.UTF_8)); return; } } - out.write(NO_CHILDREN.getBytes(UTF_8)); + out.write(NO_CHILDREN.getBytes(StandardCharsets.UTF_8)); } } diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java index 049718fc8..cf59bb0b5 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java @@ -21,6 +21,7 @@ import java.io.Writer; import java.lang.reflect.UndeclaredThrowableException; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Locale; import javax.servlet.ServletContext; @@ -180,7 +181,7 @@ public class EclipseConnector { message.append("</pre>"); //$NON-NLS-1$ message.append(errorPageEnd); - is = new ByteArrayInputStream(message.toString().getBytes("UTF8")); //$NON-NLS-1$ + is = new ByteArrayInputStream(message.toString().getBytes(StandardCharsets.UTF_8)); } OutputStream out = resp.getOutputStream(); diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java index 7bababdaf..7a3fb3cc5 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java @@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; @@ -38,7 +39,6 @@ public class PluginsRootResolvingStream extends OutputStream { private static final int MAY_BE_INCLUDE = 4; private static final int IN_METATAG = 5; private static final String PLUGINS_ROOT = "PLUGINS_ROOT/"; //$NON-NLS-1$ - private static final String UTF8 = "UTF8"; //$NON-NLS-1$ private static final String INSERT_CHILD_LINKS = "<!--INSERT_CHILD_LINKS-->"; //$NON-NLS-1$ private static final String INSERT_CHILD_LINK_STYLE = "<!--INSERT_CHILD_LINK_STYLE-->"; //$NON-NLS-1$ private final String[] keywords = { INSERT_CHILD_LINKS, INSERT_CHILD_LINK_STYLE }; @@ -200,12 +200,12 @@ public class PluginsRootResolvingStream extends OutputStream { } private void flushPluginsRootCharacters() throws IOException { - out.write(PLUGINS_ROOT.substring(0, charsMatched).getBytes(UTF8)); + out.write(PLUGINS_ROOT.substring(0, charsMatched).getBytes(StandardCharsets.UTF_8)); } private void flushKeywordCharacters() throws IOException { String matchingCharacters = keywords[lastKeywordMatch].substring(0, charsMatched); - out.write(matchingCharacters.getBytes(UTF8)); + out.write(matchingCharacters.getBytes(StandardCharsets.UTF_8)); } diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/XMLGenerator.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/XMLGenerator.java index 5c1cb2169..5bb599d5a 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/XMLGenerator.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/XMLGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ package org.eclipse.help.internal.webapp.servlet; import java.io.*; +import java.nio.charset.StandardCharsets; import org.eclipse.help.internal.base.util.*; import org.eclipse.help.internal.webapp.*; @@ -49,7 +50,7 @@ public class XMLGenerator { this.outFile = outFile; try { out = new PrintWriter(new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(outFile), "UTF8")), //$NON-NLS-1$ + new FileOutputStream(outFile), StandardCharsets.UTF_8)), false /* no aotoFlush */ ); println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ |