From 8c6050dbe2b6c4af2df39133998bd803272efe6e Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Wed, 4 Jun 2008 08:48:58 +0000 Subject: [PATCH] [releng][cleanup] Fix @since tags according to API Tooling --- .../clientserver/SystemEncodingUtil.java | 199 +++++++++--------- .../clientserver/SystemOperationMonitor.java | 24 ++- .../clientserver/SystemReentrantMutex.java | 52 ++--- .../archiveutils/SystemTgzHandler.java | 26 +-- .../clientserver/messages/CommonMessages.java | 5 +- .../messages/SimpleSystemMessage.java | 18 +- .../shells/AbstractHostShellOutputReader.java | 59 +++--- 7 files changed, 200 insertions(+), 183 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java index 6eee5da076d..caac7a08021 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java @@ -7,10 +7,10 @@ * * Initial Contributors: * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * + * * Contributors: * David McKnight (IBM) [215847]SystemEncodingUtil needs to convert to unsigned when checking xml file * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding @@ -28,10 +28,10 @@ import java.io.InputStreamReader; * A singleton class that contains useful methods related to encodings. */ public class SystemEncodingUtil { - + private static SystemEncodingUtil instance; public static String ENCODING_UTF_8 = "UTF-8"; //$NON-NLS-1$ - + private DefaultEncodingProvider _defaultEncodingProvider = new DefaultEncodingProvider(); /** @@ -40,20 +40,20 @@ public class SystemEncodingUtil { private SystemEncodingUtil() { super(); } - + /** * Returns the singleton instance of the utility class. * @return the singleton instance. */ public static SystemEncodingUtil getInstance() { - + if (instance == null) { instance = new SystemEncodingUtil(); } - + return instance; } - + /** @@ -73,32 +73,33 @@ public class SystemEncodingUtil { } } - /** - * Change the default encoding provider. - * - * This is a system-wide change, and clients will not be notified - * of changed default encodings due to changing the provider. Therefore, - * changing the provider should be done only once during early system - * startup. - * - * @param p the new encoding provider. - */ + /** + * Change the default encoding provider. + * + * This is a system-wide change, and clients will not be notified of changed + * default encodings due to changing the provider. Therefore, changing the + * provider should be done only once during early system startup. + * + * @param p the new encoding provider. + * @since 3.0 + */ public void setDefaultEncodingProvider(DefaultEncodingProvider p) { _defaultEncodingProvider = p; } /** - * Returns the local default encoding as provided by the default encoding - * provider. This method should be called after RSE startup is complete - * in order to get the proper default workspace encoding. - * + * Returns the local default encoding as provided by the default encoding + * provider. This method should be called after RSE startup is complete in + * order to get the proper default workspace encoding. + * * @return the local default encoding + * @since 3.0 */ public String getLocalDefaultEncoding() { return _defaultEncodingProvider.getLocalDefaultEncoding(); } - + /** * Gets the encoding of the environment. This is the encoding being used by the JVM, * which by default is the machine encoding, unless changed explicitly. @@ -107,29 +108,29 @@ public class SystemEncodingUtil { public String getEnvironmentEncoding() { return System.getProperty("file.encoding"); //$NON-NLS-1$ } - + /** * Returns whether the file is an XML file. * @param filePath the file path. * @return true if the file is an XML file, false otherwise. */ public boolean isXML(String filePath) { - + int index = filePath.lastIndexOf("."); //$NON-NLS-1$ - + // check if there is a "." if (index == -1) { return false; } else { - + // check if the name ends with "." if (index == filePath.length() - 1) { return false; } else { String extension = filePath.substring(index+1); - + if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) { //$NON-NLS-1$ //$NON-NLS-2$ return true; } @@ -139,46 +140,46 @@ public class SystemEncodingUtil { } } } - + /** * Gets the encoding of an XML file. * @param filePath the file path. * @return the encoding, or null if the encoding could not be determined. */ public String getXMLFileEncoding(String filePath) throws IOException { - + String encoding = null; - + // this is an implementation of the encoding detection algorithm // as specified in Appendix F of the XML specification - + FileInputStream stream = new FileInputStream(filePath); - + // try to get the encoding if the file starts with a BOM String encodingGuess = getEncodingFromBOM(stream); - + stream.close(); - + // if no BOM, read in bytes corresponding to the first four chars in the header, i.e. "null if there is no BOM. */ private String getEncodingFromBOM(InputStream stream) throws IOException { - + byte[] bomBytes = new byte[4]; - + // read the first three bytes stream.read(bomBytes, 0, 3); - + // check if UTF-8 BOM if (bomBytes[0] == 0xEF && bomBytes[1] == 0xBB && bomBytes[2] == 0xBF) { return SystemEncodingUtil.ENCODING_UTF_8; } - + // now read the fourth byte stream.read(bomBytes, 3, 1); - + // check if it matches some other encoding BOM - + // UCS-4, big-endian order (1234 order) if (bomBytes[0] == 0x00 && bomBytes[1] == 0x00 && bomBytes[2] == 0xFE && bomBytes[3] == 0xFF) { return null; diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemOperationMonitor.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemOperationMonitor.java index bafec85394d..03bfa2602b0 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemOperationMonitor.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemOperationMonitor.java @@ -6,36 +6,42 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Xuan Chen (IBM) - initial API and implementation + * Xuan Chen (IBM) - initial API and implementation * Martin Oberhuber (Wind River) - [216252] canceled --> cancelled in comments and locals *******************************************************************************/ package org.eclipse.rse.services.clientserver; -public class SystemOperationMonitor implements ISystemOperationMonitor +/** + * A monitor to support cancellation of operations in an environment + * where Eclipse IProgressMonitor is not available. + * + * @since 3.0 + */ +public class SystemOperationMonitor implements ISystemOperationMonitor { private boolean cancelled = false; private boolean done = false; - - + + public boolean isDone() { return done; } - + public void setDone(boolean value) { done = value; } - + public boolean isCancelled() { return cancelled; } - - - + + + public void setCancelled(boolean value) { cancelled = value; diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemReentrantMutex.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemReentrantMutex.java index dcaf881eea6..b3b60c8bbaa 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemReentrantMutex.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemReentrantMutex.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation * Xuan Chen (IBM) - [160775] Derive from org.eclipse.rse.services.Mutex * Xuan Chen (IBM) - [209825] add some info of printing the lock status *******************************************************************************/ @@ -18,36 +18,36 @@ import java.util.LinkedList; import java.util.List; /** - * A SystemMutex Exclusion Lock for Threads that need to access a resource - * in a serialized manner. - * If the request for the lock is running on the same thread who is currently holding the lock, - * it will "borrow" the lock, and the call to waitForLock() will go through. - * An SystemOperationMonitor is accepted - * in order to support cancellation when waiting for the SystemMutex. - * This is a clone for org.eclipse.rse.services.Mutex with some modification to make sure the - * sequential calls to waitForLock() method in the same thread will not be blocked. - * - * Usage Example: - * - * private SystemMutex fooMutex = new SystemMutex(); + * A reentrant Exclusion Lock for Threads that need to access a resource in a + * serialized manner. If the request for the lock is running on the same thread + * who is currently holding the lock, it will "borrow" the lock, and the call to + * waitForLock() will go through. A SystemOperationMonitor is accepted in order + * to support cancellation when waiting for the Mutex. This is a clone of + * {@link org.eclipse.rse.services.Mutex} with some modification to make sure the + * sequential calls to waitForLock() method in the same thread will not be + * blocked. + * + * Usage Example: + * private SystemReentrantMutex fooMutex = new SystemReentrantMutex(); * boolean doFooSerialized()(ISystemOperationMonitor monitor) { - * int mutexLockStatus = SystemMutex.LOCK_STATUS_NOLOCK; + * int mutexLockStatus = SystemReentrantMutex.LOCK_STATUS_NOLOCK; * mutexLockStatus = fooMutex.waitForLock(monitor, 1000); - * if (SystemMutex.LOCK_STATUS_NOLOCK != mutexLockStatus) { + * if (mutexLockStatus != SystemReentrantMutex.LOCK_STATUS_NOLOCK) { * try { * return doFoo(); * } finally { * //We only release the mutex if we acquire it, not borrowed it. - * if (SystemMutex.LOCK_STATUS_AQUIRED == mutexLockStatus) - * { - * fooMutex.release(); - * } + * if (mutexLockStatus == SystemReentrantMutex.LOCK_STATUS_AQUIRED) + * { + * fooMutex.release(); + * } * } * } * return false; * } * - * + * + * @since 3.0 */ public class SystemReentrantMutex { diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java index 318edf4bb43..6cce710c07f 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2008 Wind River Systems, Inc. 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: * Johnson Ma (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -19,7 +19,9 @@ import java.util.zip.GZIPOutputStream; import org.eclipse.rse.internal.services.clientserver.archiveutils.TgzFile; /** - * handler class for .tar.gz and .tgz files + * Handler class for .tar.gz and .tgz files. + * + * @since 3.0 */ public class SystemTgzHandler extends SystemTarHandler { @@ -30,25 +32,25 @@ public class SystemTgzHandler extends SystemTarHandler { public SystemTgzHandler(File file) throws IOException { super(file); } - + /** * Gets a tar.gz file from the underlying file. * @return the tar file, or null if the tar file does not exist. */ protected TarFile getTarFile() { - + TarFile tarFile = null; - + try { tarFile = new TgzFile(file); } catch (IOException e) { // TODO: log error } - + return tarFile; } - + protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException { GZIPOutputStream zipOutputStream = null; try{ diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java index 807a94aacdc..cc89d0e304c 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java @@ -17,7 +17,10 @@ package org.eclipse.rse.services.clientserver.messages; import org.eclipse.osgi.util.NLS; - +/** + * Externalized Strings for common messages that all clients can use. + * @since 3.0 + */ public class CommonMessages extends NLS { private static String BUNDLE_NAME = "org.eclipse.rse.services.clientserver.messages.CommonMessages";//$NON-NLS-1$ diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java index 84a2a44b3cd..0e309513e48 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java @@ -21,7 +21,11 @@ import java.io.StringWriter; import org.eclipse.core.runtime.IStatus; - +/** + * An RSE SystemMessage that can be created from Strings (without XML parsing). + * + * @since 3.0 + */ public class SimpleSystemMessage extends SystemMessage { private String _pluginId; @@ -47,13 +51,13 @@ public class SimpleSystemMessage extends SystemMessage { /** * Creates a String based System Message with severity, ID and String * message details. - * + * * This allows using the RSE Messaging Framework based on simple String * messages and IDs, rather than using XML Message files from * {@link SystemMessageFile} along with the * org.eclipse.rse.ui.SystemBasePlugin#loadMessageFile() and * org.eclipse.rse.ui.SystemBasePlugin#getMessage() methods. - * + * * Clients can use either globally unique RSE message IDs or plugin-specific * local IDs. RSE-global message IDs are of the form: * RSE<subcomponent><number>, where the subcomponent is a single @@ -65,17 +69,17 @@ public class SimpleSystemMessage extends SystemMessage { *
  • "C" for Communications
  • * * and the number is a four digit number. - * + * * Some RSE-global message IDs are predefined in {@link ICommonMessageIds}. * When used in a SimpleSystemMessage, these common message IDs must be used * along with the matching message Strings from {@link CommonMessages}, in * order to be consistent to the user. For example: - * + * *
     	 * msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_COMM_AUTH_FAILED, IStatus.ERROR, CommonMessages.MSG_COMM_AUTH_FAILED, NLS.bind(
     	 * 		CommonMessages.MSG_COMM_AUTH_FAILED_DETAILS, getHost().getAliasName()));
     	 * 
    - * + * * Plugin-specific local IDs are totally free to be defined by the * plugin that creates a specific message, as long as they are not prefixed * by "RSE". It is recommended that plugins define unique IDs for various @@ -83,7 +87,7 @@ public class SimpleSystemMessage extends SystemMessage { * users; but it is not a requirement. Local ID's are specific to the plugin * ID: relative IDs are qualified by the specified plugin ID, so they live * in the plugin ID namespace. - * + * * @param pluginId the id of the originating plugin * @param messageId the RSE-global unique ID or plugin-specific local ID of * the message diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java index 949ce1f6c45..9cb68ec59cc 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java @@ -7,10 +7,10 @@ * * Initial Contributors: * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * + * * Contributors: * Martin Oberhuber (Wind River) - [197848] Fix shell terminated state when remote dies * Martin Oberhuber (Wind River) - [217429] Make registering multiple output listeners thread-safe @@ -27,16 +27,16 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I protected List _listeners; protected int _waitIncrement = 2; protected boolean _keepRunning = true; - + protected List _linesOfOutput; protected int _consumerOffset; protected IHostShell _hostShell; protected boolean _isErrorReader = false; - - + + protected long _timeOfLastEvent = 0; protected int _sizeAtLastEvent = 0; - + public AbstractHostShellOutputReader(IHostShell hostShell, boolean isErrorReader) { _hostShell = hostShell; @@ -46,17 +46,17 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I _isErrorReader = isErrorReader; _timeOfLastEvent = System.currentTimeMillis(); } - + public boolean isErrorReader() { return _isErrorReader; } - + public IHostShell getHostShell() { return _hostShell; } - + public void setWaitTime(int value) { _waitIncrement = value; @@ -82,20 +82,20 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I finish(); _keepRunning = false; } - + } - + protected void addLine(IHostOutput line) - { + { _linesOfOutput.add(line); int sizenow = _linesOfOutput.size(); int deltaSize = sizenow - _sizeAtLastEvent; - + long timenow = System.currentTimeMillis(); //if ((timenow - _timeOfLastEvent) > 10 || deltaSize > 2) { - - + + // notify listeners HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, _sizeAtLastEvent, deltaSize); fireOutputChanged(event); @@ -103,30 +103,31 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I _sizeAtLastEvent = sizenow; } } - + + /** @since 3.0 */ protected final synchronized void startIfNotAlive() { if (!isAlive()) { start(); } } - + public IHostOutput readLine() { if (!isAlive()) { internalReadLine(); - startIfNotAlive(); + startIfNotAlive(); } - return (IHostOutput)_linesOfOutput.get(_consumerOffset++); + return (IHostOutput)_linesOfOutput.get(_consumerOffset++); } - + public IHostOutput readLine(int lineNumber) { - return (IHostOutput)_linesOfOutput.get(lineNumber); + return (IHostOutput)_linesOfOutput.get(lineNumber); } - - - + + + public void setLineOffset(int lineNumber) { _consumerOffset = lineNumber; @@ -147,12 +148,12 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I if (!_keepRunning) dispose(); } - + public void dispose() { _listeners.clear(); } - + public boolean isFinished() { return !_keepRunning; @@ -166,7 +167,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I //dispose(); } } - + public void run() { while (_keepRunning) @@ -189,7 +190,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I fireOutputChanged(event); } } - + protected abstract IHostOutput internalReadLine(); }