Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-11-11 14:59:07 +0000
committerAlexander Kurtakov2017-11-11 14:59:07 +0000
commitcacd6d9d1d85adb919af8c12beb22643e76ce17d (patch)
tree66fd1e3c4719189a547f1073cc82d083f9174c80 /bundles/org.eclipse.equinox.console
parent19752d9abc811e3593f031d2e8aa42290191909d (diff)
downloadrt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.tar.gz
rt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.tar.xz
rt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.zip
Bug 527146 - Move equinox.console to Java 8I20171111-1500
Modernize the codebase with Java 8 constructs. Update console.tests bundle too. Change-Id: Id3c9ec868e6526fc9c3298138317d578db4c834c Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.console')
-rwxr-xr-xbundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs25
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java82
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java36
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java11
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java38
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java8
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java15
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java10
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java13
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java11
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java5
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java8
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java14
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java11
27 files changed, 206 insertions, 150 deletions
diff --git a/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
index d8d8453d..0cc2336f 100755
--- a/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
@@ -2,8 +2,11 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
@@ -12,6 +15,7 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -21,7 +25,7 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@@ -34,14 +38,14 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -49,20 +53,22 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
@@ -71,19 +77,24 @@ org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
index 4be3b5de..09c7d851 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation, SAP AG.
+ * Copyright (c) 2010, 2017 IBM Corporation, SAP AG 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
@@ -49,9 +49,9 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
* The activator class controls the plug-in life cycle
*/
public class Activator implements BundleActivator {
- private ServiceTracker<StartLevel, ?> startLevelManagerTracker;
- private ServiceTracker<ConditionalPermissionAdmin, ?> condPermAdminTracker;
- private ServiceTracker<PermissionAdmin, ?> permissionAdminTracker;
+ private ServiceTracker<StartLevel, StartLevel> startLevelManagerTracker;
+ private ServiceTracker<ConditionalPermissionAdmin, ConditionalPermissionAdmin> condPermAdminTracker;
+ private ServiceTracker<PermissionAdmin, PermissionAdmin> permissionAdminTracker;
private ServiceTracker<PackageAdmin, PackageAdmin> packageAdminTracker;
private static boolean isFirstProcessor = true;
private static TelnetCommand telnetConnection = null;
@@ -71,6 +71,7 @@ public class Activator implements BundleActivator {
this.context = context;
}
+ @Override
public ServiceTracker<ConsoleSession, CommandSession> addingService(
ServiceReference<CommandProcessor> reference) {
CommandProcessor processor = context.getService(reference);
@@ -85,17 +86,19 @@ public class Activator implements BundleActivator {
telnetConnection.addCommandProcessor(processor);
}
- ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker<ConsoleSession, CommandSession>(context, ConsoleSession.class, new SessionCustomizer(context, processor));
+ ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker<>(context, ConsoleSession.class, new SessionCustomizer(context, processor));
tracker.open();
return tracker;
}
+ @Override
public void modifiedService(
ServiceReference<CommandProcessor> reference,
ServiceTracker<ConsoleSession, CommandSession> service) {
// nothing
}
+ @Override
public void removedService(
ServiceReference<CommandProcessor> reference,
ServiceTracker<ConsoleSession, CommandSession> tracker) {
@@ -116,6 +119,7 @@ public class Activator implements BundleActivator {
this.processor = processor;
}
+ @Override
public CommandSession addingService(
ServiceReference<ConsoleSession> reference) {
final ConsoleSession equinoxSession = context.getService(reference);
@@ -123,31 +127,30 @@ public class Activator implements BundleActivator {
return null;
PrintStream output = new PrintStream(equinoxSession.getOutput());
final CommandSession gogoSession = processor.createSession(equinoxSession.getInput(), output, output);
- new Thread(new Runnable(){
- public void run() {
- try {
- gogoSession.put("SCOPE", "equinox:*");
- gogoSession.put("prompt", "osgi> ");
- gogoSession.execute("gosh --login --noshutdown");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- gogoSession.close();
- equinoxSession.close();
- }
- }
-
+ new Thread((Runnable) () -> {
+ try {
+ gogoSession.put("SCOPE", "equinox:*");
+ gogoSession.put("prompt", "osgi> ");
+ gogoSession.execute("gosh --login --noshutdown");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ gogoSession.close();
+ equinoxSession.close();
+ }
}, "Equinox Console Session").start();
return null;
}
+ @Override
public void modifiedService(ServiceReference<ConsoleSession> reference,
CommandSession service) {
// nothing
}
+ @Override
public void removedService(ServiceReference<ConsoleSession> reference,
CommandSession session) {
session.close();
@@ -163,6 +166,7 @@ public class Activator implements BundleActivator {
this.context = context;
}
+ @Override
public List<ServiceRegistration<?>> addingService(ServiceReference<CommandProvider> reference) {
if (reference.getProperty("osgi.command.function") != null) {
// must be a gogo function already; don' track
@@ -173,8 +177,8 @@ public class Activator implements BundleActivator {
Method[] commandMethods = getCommandMethods(command);
if (commandMethods.length > 0) {
- List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
- registrations.add(context.registerService(Object.class, new CommandProviderAdapter((CommandProvider) command, commandMethods), getAttributes(commandMethods)));
+ List<ServiceRegistration<?>> registrations = new ArrayList<>();
+ registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), getAttributes(commandMethods)));
return registrations;
} else {
context.ungetService(reference);
@@ -187,10 +191,12 @@ public class Activator implements BundleActivator {
}
+ @Override
public void modifiedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> service) {
// Nothing to do.
}
+ @Override
public void removedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> registrations) {
for (ServiceRegistration<?> serviceRegistration : registrations) {
serviceRegistration.unregister();
@@ -199,23 +205,24 @@ public class Activator implements BundleActivator {
}
+ @Override
public void start(BundleContext context) throws Exception {
- commandProviderTracker = new ServiceTracker<CommandProvider, List<ServiceRegistration<?>>>(context, CommandProvider.class.getName(), new CommandCustomizer(context));
+ commandProviderTracker = new ServiceTracker<>(context, CommandProvider.class, new CommandCustomizer(context));
commandProviderTracker.open();
- commandProcessorTracker = new ServiceTracker<CommandProcessor, ServiceTracker<ConsoleSession,CommandSession>>(context, CommandProcessor.class, new ProcessorCustomizer(context));
+ commandProcessorTracker = new ServiceTracker<>(context, CommandProcessor.class, new ProcessorCustomizer(context));
commandProcessorTracker.open();
- condPermAdminTracker = new ServiceTracker<ConditionalPermissionAdmin, Object>(context, ConditionalPermissionAdmin.class.getName(), null);
+ condPermAdminTracker = new ServiceTracker<>(context, ConditionalPermissionAdmin.class, null);
condPermAdminTracker.open();
// grab permission admin
- permissionAdminTracker = new ServiceTracker<PermissionAdmin, Object>(context, PermissionAdmin.class.getName(), null);
+ permissionAdminTracker = new ServiceTracker<>(context, PermissionAdmin.class, null);
permissionAdminTracker.open();
- startLevelManagerTracker = new ServiceTracker<StartLevel, Object>(context, StartLevel.class.getName(), null);
+ startLevelManagerTracker = new ServiceTracker<>(context, StartLevel.class, null);
startLevelManagerTracker.open();
- packageAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(context, PackageAdmin.class, null);
+ packageAdminTracker = new ServiceTracker<>(context, PackageAdmin.class, null);
packageAdminTracker.open();
equinoxCmdProvider = new EquinoxCommandProvider(context, this);
@@ -252,32 +259,32 @@ public class Activator implements BundleActivator {
}
public StartLevel getStartLevel() {
- return (StartLevel) getServiceFromTracker(startLevelManagerTracker, StartLevel.class.getName());
+ return getServiceFromTracker(startLevelManagerTracker, StartLevel.class);
}
public PermissionAdmin getPermissionAdmin() {
- return (PermissionAdmin) getServiceFromTracker(permissionAdminTracker, PermissionAdmin.class.getName());
+ return getServiceFromTracker(permissionAdminTracker, PermissionAdmin.class);
}
public ConditionalPermissionAdmin getConditionalPermissionAdmin() {
- return (ConditionalPermissionAdmin) getServiceFromTracker(condPermAdminTracker, ConditionalPermissionAdmin.class.getName());
+ return getServiceFromTracker(condPermAdminTracker, ConditionalPermissionAdmin.class);
}
public PackageAdmin getPackageAdmin() {
- return (PackageAdmin) getServiceFromTracker(packageAdminTracker, PackageAdmin.class.getName());
+ return getServiceFromTracker(packageAdminTracker, PackageAdmin.class);
}
- private static Object getServiceFromTracker(ServiceTracker<?, ?> tracker, String serviceClass) {
+ private static <T> T getServiceFromTracker(ServiceTracker<?, T> tracker, Class<T> serviceClass) {
if (tracker == null)
throw new IllegalStateException("Missing service: " + serviceClass);
- Object result = tracker.getService();
+ T result = tracker.getService();
if (result == null)
throw new IllegalStateException("Missing service: " + serviceClass);
return result;
}
Method[] getCommandMethods(Object command) {
- ArrayList<Method> names = new ArrayList<Method>();
+ ArrayList<Method> names = new ArrayList<>();
Class<?> c = command.getClass();
Method[] methods = c.getDeclaredMethods();
for (Method method : methods) {
@@ -294,7 +301,7 @@ public class Activator implements BundleActivator {
}
Dictionary<String, Object> getAttributes(Method[] commandMethods) {
- Dictionary<String, Object> dict = new Hashtable<String, Object>();
+ Dictionary<String, Object> dict = new Hashtable<>();
dict.put("osgi.command.scope", "equinox");
String[] methodNames = new String[commandMethods.length];
for (int i = 0; i < commandMethods.length; i++) {
@@ -306,6 +313,7 @@ public class Activator implements BundleActivator {
return dict;
}
+ @Override
public void stop(BundleContext context) throws Exception {
commandProviderTracker.close();
commandProcessorTracker.close();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
index d6a7ebef..c42e12a5 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation, SAP AG.
+ * Copyright (c) 2010, 2017 IBM Corporation, SAP AG.
* 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
@@ -41,7 +41,7 @@ public class CommandProviderAdapter {
try {
// first argument is the command
Method command = findCommand("_" + args[0]);
- ArrayList<Object> argList = new ArrayList<Object>();
+ ArrayList<Object> argList = new ArrayList<>();
for (int i = 1; i < args.length; i++)
argList.add(args[i]);
return command.invoke(commandProvider, new CustomCommandInterpreter(commandSession, argList));
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
index 5feaeb43..9f86d4e9 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 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
@@ -54,7 +54,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
arguments = args.iterator();
}
- public Object execute(String cmd) {
+ @Override
+public Object execute(String cmd) {
try {
return commandSession.execute(cmd);
} catch (RuntimeException e) {
@@ -64,7 +65,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
}
}
- public String nextArgument() {
+ @Override
+public String nextArgument() {
if (arguments.hasNext()) {
Object next = arguments.next();
return next == null ? null : next.toString();
@@ -77,7 +79,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
*
* @param o the object to be printed
*/
- public void print(Object o) {
+ @Override
+public void print(Object o) {
check4More();
out.print(o);
out.flush();
@@ -86,7 +89,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
/**
* Prints a empty line to the outputstream
*/
- public void println() {
+ @Override
+public void println() {
println(""); //$NON-NLS-1$
}
@@ -94,7 +98,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* Print a stack trace including nested exceptions.
* @param t The offending exception
*/
- public void printStackTrace(Throwable t) {
+ @Override
+public void printStackTrace(Throwable t) {
t.printStackTrace(out);
Method[] methods = t.getClass().getMethods();
@@ -131,7 +136,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
*
* @param o the object to be printed
*/
- public void println(Object o) {
+ @Override
+public void println(Object o) {
if (o == null) {
return;
}
@@ -160,7 +166,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* @param dic the dictionary to print
* @param title the header to print above the key/value pairs
*/
- public void printDictionary(Dictionary<?,?> dic, String title) {
+ @Override
+public void printDictionary(Dictionary<?,?> dic, String title) {
if (dic == null)
return;
@@ -188,25 +195,18 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* @param bundle the bundle containing the resource
* @param resource the resource to print
*/
- public void printBundleResource(Bundle bundle, String resource) {
+ @Override
+public void printBundleResource(Bundle bundle, String resource) {
URL entry = null;
entry = bundle.getEntry(resource);
if (entry != null) {
try {
println(resource);
- InputStream in = entry.openStream();
byte[] buffer = new byte[1024];
int read = 0;
- try {
+ try (InputStream in = entry.openStream()) {
while ((read = in.read(buffer)) != -1)
print(new String(buffer, 0, read));
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
}
} catch (Exception e) {
System.err.println(e);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
index 2b5f68c6..4a2d4367 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 SAP AG.
+ * Copyright (c) 2013, 2017 SAP AG 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
@@ -31,7 +31,7 @@ public class CommandsTracker {
commandNames = Collections.synchronizedSet(new HashSet<String>());
try {
Filter filter = bundleContext.createFilter(String.format("(&(%s=*)(%s=*))", CommandProcessor.COMMAND_SCOPE, CommandProcessor.COMMAND_FUNCTION));
- commandsTracker = new ServiceTracker<Object, Set<String>>(bundleContext, filter, new CommandsTrackerCustomizer());
+ commandsTracker = new ServiceTracker<>(bundleContext, filter, new CommandsTrackerCustomizer());
commandsTracker.open();
} catch (InvalidSyntaxException e) {
//do nothing;
@@ -40,12 +40,13 @@ public class CommandsTracker {
public Set<String> getCommands() {
synchronized (lock) {
- return new HashSet<String>(commandNames);
+ return new HashSet<>(commandNames);
}
}
class CommandsTrackerCustomizer implements ServiceTrackerCustomizer<Object, Set<String>> {
- public Set<String> addingService(ServiceReference<Object> reference) {
+ @Override
+ public Set<String> addingService(ServiceReference<Object> reference) {
Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
@@ -64,10 +65,12 @@ public class CommandsTracker {
return null;
}
+ @Override
public void modifiedService(ServiceReference<Object> reference, Set<String> commandNames) {
// nothing to do
}
+ @Override
public void removedService(ServiceReference<Object> reference, Set<String> commandNames) {
Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
index 5b79b9ae..56f9bc7d 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -36,7 +36,7 @@ public class DisconnectCommand {
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"disconnect"});
context.registerService(DisconnectCommand.class.getName(), this, props);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
index bfb11f88..475cc067 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2014 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 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
@@ -65,6 +65,7 @@ import org.osgi.framework.wiring.BundleRevisions;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.framework.wiring.FrameworkWiring;
+import org.osgi.resource.Namespace;
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
@@ -133,7 +134,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
private final static String newline = "\r\n"; //$NON-NLS-1$
/** this list contains the bundles known to be lazily awaiting activation */
- private final List<Bundle> lazyActivation = new ArrayList<Bundle>();
+ private final List<Bundle> lazyActivation = new ArrayList<>();
private Activator activator;
@@ -168,7 +169,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
EquinoxCommandsConverter converter = new EquinoxCommandsConverter(context);
converterReg = context.registerService(Converter.class.getName(), converter, null);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, functions);
@@ -995,7 +996,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
System.out.print("unwired"); //$NON-NLS-1$
System.out.print(">"); //$NON-NLS-1$
System.out.print("<"); //$NON-NLS-1$
- System.out.print(importReq.getDirectives().get(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
+ System.out.print(importReq.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
System.out.println(">"); //$NON-NLS-1$
}
return title;
@@ -1185,7 +1186,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
*/
@Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION)
public List<Dictionary<String, String>> headers(@Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_ARGUMENT_DESCRIPTION) Bundle... bundles) throws Exception {
- ArrayList<Dictionary<String, String>> headers = new ArrayList<Dictionary<String,String>>();
+ ArrayList<Dictionary<String, String>> headers = new ArrayList<>();
if (bundles == null || bundles.length == 0) {
System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
@@ -1602,7 +1603,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
} else {
names = symbolicName;
}
- List<Bundle> bundles = new ArrayList<Bundle>();
+ List<Bundle> bundles = new ArrayList<>();
if (names == null) {
bundles.addAll(Arrays.asList(packageAdmin.getBundles(null, null)));
} else {
@@ -1706,14 +1707,14 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
}
private Map<String, List<PackageSource>> getPackagesInternal(BundleWiring wiring) {
- Map<String, List<PackageSource>> packages = new TreeMap<String, List<PackageSource>>();
+ Map<String, List<PackageSource>> packages = new TreeMap<>();
// first get the imported packages
List<BundleWire> packageWires = wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE);
- Set<String> importedPackageNames = new HashSet<String>();
+ Set<String> importedPackageNames = new HashSet<>();
for (BundleWire packageWire : packageWires) {
String packageName = (String) packageWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
importedPackageNames.add(packageName);
- List<PackageSource> packageSources = new ArrayList<PackageSource>();
+ List<PackageSource> packageSources = new ArrayList<>();
packageSources.add(new PackageSource(packageWire.getCapability(), packageWire));
packages.put(packageName, packageSources);
}
@@ -1733,7 +1734,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
if (!importedPackageNames.contains(packageName)) {
List<PackageSource> packageSources = packages.get(packageName);
if (packageSources == null) {
- packageSources = new ArrayList<PackageSource>();
+ packageSources = new ArrayList<>();
packages.put(packageName, packageSources);
}
boolean sourceFound = false;
@@ -1750,7 +1751,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
// get substituted packages
- Set<String> declaredPackageNames = new HashSet<String>();
+ Set<String> declaredPackageNames = new HashSet<>();
for (BundleCapability declaredPackage : providerWiring.getRevision().getDeclaredCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) {
declaredPackageNames.add((String) declaredPackage.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
}
@@ -1766,7 +1767,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
if (declaredPackageNames.contains(packageName)) {
List<PackageSource> packageSources = packages.get(packageName);
if (packageSources == null) {
- packageSources = new ArrayList<PackageSource>();
+ packageSources = new ArrayList<>();
packages.put(packageName, packageSources);
}
packageSources.add(new PackageSource(packageWire.getCapability(), packageWire));
@@ -1893,7 +1894,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
@Descriptor(ConsoleMsg.CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION)
public void getprop(@Descriptor(ConsoleMsg.CONSOLE_HELP_GETPROP_COMMAND_ARGUMENT_DESCRIPTION) String... propName) throws Exception {
Properties allProperties = System.getProperties();
- Iterator<?> propertyNames = new TreeSet<Object>(allProperties.keySet()).iterator();
+ Iterator<?> propertyNames = new TreeSet<>(allProperties.keySet()).iterator();
while (propertyNames.hasNext()) {
String prop = (String) propertyNames.next();
if (propName == null || propName.length == 0 || prop.startsWith(propName[0])) {
@@ -1905,7 +1906,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
@Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION)
public void diag(@Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_ARGUMENT_DESCRIPTION) Bundle[] bundles) throws Exception {
if (bundles.length == 0) {
- List<Bundle> unresolved = new ArrayList<Bundle>();
+ List<Bundle> unresolved = new ArrayList<>();
Bundle[] allBundles = context.getBundles();
for (Bundle bundle : allBundles) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
@@ -1942,7 +1943,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
private static class DiagReportListener implements ResolverHookFactory {
- private final Collection<BundleRevision> targetTriggers = new ArrayList<BundleRevision>();
+ private final Collection<BundleRevision> targetTriggers = new ArrayList<>();
public DiagReportListener(Bundle[] bundles) {
for (Bundle bundle : bundles) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
@@ -1955,29 +1956,35 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
volatile ResolutionReport report = null;
class DiagResolverHook implements ResolverHook, ResolutionReport.Listener {
+ @Override
public void handleResolutionReport(ResolutionReport report) {
DiagReportListener.this.report = report;
}
+ @Override
public void filterResolvable(Collection<BundleRevision> candidates) {
// nothing
}
+ @Override
public void filterSingletonCollisions(BundleCapability singleton,
Collection<BundleCapability> collisionCandidates) {
// nothing
}
+ @Override
public void filterMatches(BundleRequirement requirement,
Collection<BundleCapability> candidates) {
// nothing
}
+ @Override
public void end() {
// nothing
}
}
+ @Override
public ResolverHook begin(Collection<BundleRevision> triggers) {
if (triggers.containsAll(targetTriggers)) {
return new DiagResolverHook();
@@ -1992,6 +1999,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
/**
* This is used to track lazily activated bundles.
*/
+ @Override
public void bundleChanged(BundleEvent event) {
int type = event.getType();
Bundle bundle = event.getBundle();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
index d3300c44..feab5d83 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -32,17 +32,18 @@ public class EquinoxCommandsConverter implements Converter {
this.context = context;
}
+ @Override
public Object convert(Class<?> desiredType, Object in) throws Exception {
if(desiredType == Bundle[].class) {
if (in instanceof String) {
- if("*".equals((String) in)) {
+ if("*".equals(in)) {
return context.getBundles();
}
} else if (in instanceof List<?>) {
List<?> args = (List<?>) in;
if (checkStringElements(args)) {
try {
- ArrayList<Bundle> bundles = new ArrayList<Bundle>();
+ ArrayList<Bundle> bundles = new ArrayList<>();
for (Object arg : args) {
long id = Long.parseLong((String)arg);
bundles.add(context.getBundle(id));
@@ -124,6 +125,7 @@ public class EquinoxCommandsConverter implements Converter {
return true;
}
+ @Override
public CharSequence format(Object target, int level, Converter escape) throws Exception {
if (target instanceof Dictionary<?, ?>) {
Dictionary<?, ?> dic = (Dictionary<?, ?>) target;
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
index eef1fa86..61c5bd6e 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -46,6 +46,7 @@ public class HelpCommand {
this.context = context;
}
+ @Override
public Set<CommandProvider> addingService(
ServiceReference<CommandProvider> reference) {
if (reference.getProperty("osgi.command.function") != null) {
@@ -58,12 +59,14 @@ public class HelpCommand {
return legacyCommandProviders;
}
+ @Override
public void modifiedService(
ServiceReference<CommandProvider> reference,
Set<CommandProvider> service) {
// nothing to do
}
+ @Override
public void removedService(ServiceReference<CommandProvider> reference,
Set<CommandProvider> providers) {
CommandProvider provider = context.getService(reference);
@@ -74,15 +77,15 @@ public class HelpCommand {
public HelpCommand(BundleContext context) {
this.context = context;
- legacyCommandProviders = new HashSet<CommandProvider>();
- commandProvidersTracker = new ServiceTracker<CommandProvider, Set<CommandProvider>>(context, CommandProvider.class.getName(), new CommandProviderCustomizer(context));
+ legacyCommandProviders = new HashSet<>();
+ commandProvidersTracker = new ServiceTracker<>(context, CommandProvider.class, new CommandProviderCustomizer(context));
commandProvidersTracker.open();
- commandsTrackerTracker = new ServiceTracker<CommandsTracker, CommandsTracker>(context, CommandsTracker.class.getName(), null);
+ commandsTrackerTracker = new ServiceTracker<>(context, CommandsTracker.class, null);
commandsTrackerTracker.open();
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"help"});
@@ -177,7 +180,7 @@ public class HelpCommand {
if (method.getName().equals("_" + command)) {
try {
Method helpMethod = provider.getClass().getMethod("_help", CommandInterpreter.class);
- ArrayList<Object> argsList = new ArrayList<Object>();
+ ArrayList<Object> argsList = new ArrayList<>();
argsList.add(command);
retval = helpMethod.invoke(provider, new CustomCommandInterpreter(session, argsList));
} catch (Exception e) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
index f17f9827..e6d2914d 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* 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
@@ -25,7 +25,7 @@ public class ManCommand {
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"man"});
context.registerService(ManCommand.class.getName(), this, props);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
index 3ee1bfe0..6bbc934a 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -60,7 +60,8 @@ public class ConsoleInputScanner extends Scanner {
this.context = context;
}
- public void scan(int b) throws IOException {
+ @Override
+ public void scan(int b) throws IOException {
b &= 0xFF;
if (isCR) {
isCR = false;
@@ -261,7 +262,7 @@ public class ConsoleInputScanner extends Scanner {
}
protected String[] removeCommonPrefix(String [] names, String commonPrefix){
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
for (String name : names) {
String nameWithoutPrefix = name.substring(commonPrefix.length());
if (nameWithoutPrefix.length() > 0) {
@@ -333,7 +334,8 @@ public class ConsoleInputScanner extends Scanner {
history.reset();
}
- protected void scanEsc(final int b) throws IOException {
+ @Override
+ protected void scanEsc(final int b) throws IOException {
esc += (char) b;
KEYS key = checkEscape(esc);
if (key == KEYS.UNFINISHED) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
index 73ab4ec3..93f7a69d 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -19,12 +19,13 @@ import java.util.ArrayList;
*/
public class ConsoleInputStream extends InputStream {
- private final ArrayList<byte[]> buffer = new ArrayList<byte[]>();
+ private final ArrayList<byte[]> buffer = new ArrayList<>();
private byte[] current;
private int pos;
private boolean isClosed;
- public synchronized int read() {
+ @Override
+ public synchronized int read() {
while (current == null && buffer.isEmpty() && !isClosed) {
try {
wait();
@@ -108,7 +109,8 @@ public class ConsoleInputStream extends InputStream {
return readCnt;
}*/
- public synchronized int read(byte b[], int off, int len) throws IOException {
+ @Override
+ public synchronized int read(byte b[], int off, int len) throws IOException {
if (len == 0) {
return len;
}
@@ -140,7 +142,8 @@ public class ConsoleInputStream extends InputStream {
return readCnt;
}
- public synchronized void close() throws IOException {
+ @Override
+ public synchronized void close() throws IOException {
isClosed = true;
notifyAll();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
index 575342c2..13ec7cb6 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -51,7 +51,8 @@ public class ConsoleOutputStream extends OutputStream {
/**
* An implementation of the corresponding abstract method in OutputStream.
*/
- public synchronized void write(int i) throws IOException {
+ @Override
+ public synchronized void write(int i) throws IOException {
if (!queueing) {
if (isEcho) {
@@ -90,7 +91,8 @@ public class ConsoleOutputStream extends OutputStream {
*
* @throws IOException
*/
- public synchronized void flush() throws IOException {
+ @Override
+ public synchronized void flush() throws IOException {
if (pos > 0) {
try {
out.write(buffer, 0, pos);
@@ -122,7 +124,8 @@ public class ConsoleOutputStream extends OutputStream {
*
* @throws IOException
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
out.close();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
index 38451ad7..7bfe4ee9 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -36,7 +36,8 @@ public abstract class InputHandler extends Thread {
buffer = new byte[MAX_SIZE];
}
- public void run() {
+ @Override
+ public void run() {
int count;
try {
while ((count = input.read(buffer)) > -1) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
index 08e6f077..d5441209 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -51,7 +51,7 @@ public abstract class Scanner {
public Scanner(ConsoleInputStream toShell, OutputStream toTelnet) {
this.toShell = toShell;
this.toTelnet = toTelnet;
- supportedEscapeSequences = new HashMap<String, TerminalTypeMappings> ();
+ supportedEscapeSequences = new HashMap<> ();
supportedEscapeSequences.put("ANSI", new ANSITerminalTypeMappings());
supportedEscapeSequences.put("VT100", new VT100TerminalTypeMappings());
VT220TerminalTypeMappings vtMappings = new VT220TerminalTypeMappings();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
index 0396c27e..e92d805e 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -22,6 +22,7 @@ public class ANSITerminalTypeMappings extends TerminalTypeMappings {
DEL = 127;
}
+ @Override
public void setKeypadMappings() {
escapesToKey.put("[1~", KEYS.HOME); //$NON-NLS-1$
escapesToKey.put("[4~", KEYS.END); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
index 53dc2a69..f7298b26 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -27,7 +27,7 @@ public abstract class TerminalTypeMappings {
protected byte DEL;
public TerminalTypeMappings() {
- escapesToKey = new HashMap<String, KEYS>();
+ escapesToKey = new HashMap<>();
escapesToKey.put("[A", KEYS.UP); //$NON-NLS-1$
escapesToKey.put("[B", KEYS.DOWN); //$NON-NLS-1$
escapesToKey.put("[C", KEYS.RIGHT); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
index f7b496d8..07009ed3 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -34,10 +34,11 @@ public class CommandNamesCompleter implements Completer {
public CommandNamesCompleter(BundleContext context, CommandSession session) {
this.session = session;
- commandsTrackerTracker = new ServiceTracker<CommandsTracker, CommandsTracker>(context, CommandsTracker.class.getName(), null);
+ commandsTrackerTracker = new ServiceTracker<>(context, CommandsTracker.class.getName(), null);
commandsTrackerTracker.open();
}
+ @Override
@SuppressWarnings("unchecked")
public Map<String, Integer> getCandidates(String buffer, int cursor) {
CommandsTracker commandsTracker = commandsTrackerTracker.getService();
@@ -54,7 +55,7 @@ public class CommandNamesCompleter implements Completer {
// command names are stored in the session in lower case
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor).toLowerCase();
if(currentToken == null || currentToken.equals("")) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (!currentToken.contains(":")) {
@@ -66,7 +67,7 @@ public class CommandNamesCompleter implements Completer {
}
private Set<String> clearScopes(Set<String> commandNames) {
- Set<String> clearedCommandNames = new HashSet<String>();
+ Set<String> clearedCommandNames = new HashSet<>();
for(String commandName : commandNames) {
clearedCommandNames.add(commandName.substring(commandName.indexOf(":") + 1));
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
index b2f9e3b0..ea429077 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -41,14 +41,14 @@ public class CompletionHandler {
public CompletionHandler(BundleContext context, CommandSession session) {
this.context = context;
this.session = session;
- completers = new HashSet<Completer>();
+ completers = new HashSet<>();
}
public Map<String, Integer> getCandidates(byte[] buf, int cursor) {
String currentInput = new String(buf);
String currentToken = CommandLineParser.getCurrentToken(currentInput, cursor);
if (currentToken == null){
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (currentToken.contains(FILE) == true) {
completers.add(new FileNamesCompleter());
@@ -61,7 +61,7 @@ public class CompletionHandler {
}
}
lookupCustomCompleters();
- Map<String, Integer> candidates = new TreeMap<String, Integer>();
+ Map<String, Integer> candidates = new TreeMap<>();
for (Completer completer : completers) {
candidates.putAll(completer.getCandidates(currentInput, cursor));
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
index a69ab5e4..aa2c5b4e 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -27,11 +27,12 @@ import org.eclipse.equinox.console.completion.common.Completer;
public class FileNamesCompleter implements Completer {
private static final String FILE = "file:";
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor);
if(currentToken == null || currentToken.equals("")) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
// if current token contains file:, then use URL class to parse the filename
@@ -90,7 +91,7 @@ public class FileNamesCompleter implements Completer {
}
private Map<String, Integer> checkChildren(File parent, String nameToComplete, int cursor, boolean absolute) {
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
if(parent.exists()) {
File[] children = parent.listFiles();
for(File child : children) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
index 73723792..ca901535 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -31,10 +31,11 @@ public class StringsCompleter implements Completer {
this.isCaseSensitive = isCaseSensitive;
}
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor);
if (currentToken == null) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (!isCaseSensitive) {
currentToken = currentToken.toLowerCase();
@@ -47,10 +48,10 @@ public class StringsCompleter implements Completer {
// that a variable name is expected; in this case all strings will be
// returned as candidates
if(currentToken.equals("") && buffer.charAt(startIndex - 1) != '$') {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
for(String candidate : strings) {
if (isCaseSensitive) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
index e72277de..e90940ae 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG 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
@@ -29,6 +29,7 @@ public class VariableNamesCompleter implements Completer {
this.session = session;
}
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
// CommandSession.get(null) returns the names of all registered varialbes
@SuppressWarnings("unchecked")
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
index c4681181..852b3f78 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -24,6 +24,7 @@ public class NegotiationFinishedCallback implements Callback {
this.telnetConnection = telnetConnection;
}
+ @Override
public void finished() {
telnetConnection.telnetNegotiationFinished();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
index 8829242f..fbfe7894 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 SAP AG and others.
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -33,7 +33,7 @@ public class TelnetCommand {
private String defaultHost = null;
private int defaultPort;
- private List<CommandProcessor> processors = new ArrayList<CommandProcessor>();
+ private List<CommandProcessor> processors = new ArrayList<>();
private final BundleContext context;
private String host = null;
private int port;
@@ -54,7 +54,7 @@ public class TelnetCommand {
processors.add(processor);
this.context = context;
if ("true".equals(context.getProperty(USE_CONFIG_ADMIN_PROP))) {
- Dictionary<String, String> telnetProperties = new Hashtable<String, String>();
+ Dictionary<String, String> telnetProperties = new Hashtable<>();
telnetProperties.put(Constants.SERVICE_PID, TELNET_PID);
try {
synchronized (lock) {
@@ -90,7 +90,7 @@ public class TelnetCommand {
}
public synchronized void startService() {
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ Dictionary<String, Object> properties = new Hashtable<>();
properties.put("osgi.command.scope", "equinox");
properties.put("osgi.command.function", new String[] {"telnet"});
if ((port > 0 || defaultPort > 0) && isEnabled == true) {
@@ -215,6 +215,7 @@ public class TelnetCommand {
class TelnetConfigurator implements ManagedService {
private Dictionary<String, Object> properties;
+ @Override
public synchronized void updated(Dictionary<String, ?> props) throws ConfigurationException {
if (props != null) {
@SuppressWarnings("unchecked")
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
index cfdf098d..af46bd28 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -50,6 +50,7 @@ public class TelnetConnection extends Thread implements Closeable {
callback = new NegotiationFinishedCallback(this);
}
+ @Override
public void run() {
try {
ConsoleInputStream in = new ConsoleInputStream();
@@ -108,6 +109,7 @@ public class TelnetConnection extends Thread implements Closeable {
}
}
+ @Override
public void close() {
try {
this.interrupt();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
index 57f9af30..79f18980 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -39,9 +39,9 @@ public class TelnetInputScanner extends Scanner {
private boolean shouldFinish = false;
private boolean tTypeNegotiationStarted = false;
private int lastRead = -1;
- private ArrayList<Integer> currentTerminalType = new ArrayList<Integer>();
+ private ArrayList<Integer> currentTerminalType = new ArrayList<>();
private ArrayList<Integer> lastTerminalType = null;
- private Set<String> supportedTerminalTypes = new HashSet<String>();
+ private Set<String> supportedTerminalTypes = new HashSet<>();
private Callback callback;
public TelnetInputScanner(ConsoleInputStream toShell, ConsoleOutputStream toTelnet, Callback callback) {
@@ -64,7 +64,8 @@ public class TelnetInputScanner extends Scanner {
supportedTerminalTypes.add("SCO");
}
- public void scan(int b) throws IOException {
+ @Override
+ public void scan(int b) throws IOException {
b &= 0xFF;
if (isEsc) {
@@ -174,7 +175,7 @@ public class TelnetInputScanner extends Scanner {
return;
}
lastTerminalType = currentTerminalType;
- currentTerminalType = new ArrayList<Integer>();
+ currentTerminalType = new ArrayList<>();
if (isLast == true && isMatch == false) {
shouldFinish = true;
sendRequest();
@@ -263,7 +264,8 @@ public class TelnetInputScanner extends Scanner {
toShell.add(new byte[]{BS});
}
- protected void scanEsc(int b) throws IOException {
+ @Override
+ protected void scanEsc(int b) throws IOException {
esc += (char) b;
toShell.add(new byte[]{(byte) b});
KEYS key = checkEscape(esc);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
index 9b7dd14b..0a70dac2 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG 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
@@ -35,8 +35,8 @@ public class TelnetServer extends Thread {
private boolean isRunning = true;
private List<CommandProcessor> processors = null;
private BundleContext context;
- private List<Socket> sockets = new ArrayList<Socket>();
- private Map<CommandProcessor, List<TelnetConnection>> processorToConnectionsMapping = new HashMap<CommandProcessor, List<TelnetConnection>>();
+ private List<Socket> sockets = new ArrayList<>();
+ private Map<CommandProcessor, List<TelnetConnection>> processorToConnectionsMapping = new HashMap<>();
public TelnetServer(BundleContext context, List<CommandProcessor> processors, String host, int port) throws IOException {
this.context = context;
@@ -48,6 +48,7 @@ public class TelnetServer extends Thread {
}
}
+ @Override
public void run()
{
try
@@ -60,7 +61,7 @@ public class TelnetServer extends Thread {
TelnetConnection telnetConnection = new TelnetConnection(socket, processor, context);
List<TelnetConnection> telnetConnections = processorToConnectionsMapping.get(processor);
if (telnetConnections == null) {
- telnetConnections = new ArrayList<TelnetConnection>();
+ telnetConnections = new ArrayList<>();
processorToConnectionsMapping.put(processor, telnetConnections);
}
telnetConnections.add(telnetConnection);
@@ -86,7 +87,7 @@ public class TelnetServer extends Thread {
public synchronized void addCommandProcessor(CommandProcessor processor) {
processors.add(processor);
if (!sockets.isEmpty()) {
- List<TelnetConnection> telnetConnections = new ArrayList<TelnetConnection>();
+ List<TelnetConnection> telnetConnections = new ArrayList<>();
for (Socket socket : sockets) {
TelnetConnection telnetConnection = new TelnetConnection(socket, processor, context);
telnetConnections.add(telnetConnection);

Back to the top