1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[releng][cleanup] Fix @since tags according to API Tooling

This commit is contained in:
Martin Oberhuber 2008-06-04 08:48:58 +00:00
parent e13dc52133
commit 8c6050dbe2
7 changed files with 200 additions and 183 deletions

View file

@ -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 <code>true</code> if the file is an XML file, <code>false</code> 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 <code>null</code> 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. "<?xm"
// and try to determine the encoding from that
if (encodingGuess == null) {
stream = new FileInputStream(filePath);
byte[] tempSigned = new byte[4];
stream.read(tempSigned);
stream.close();
// convert to unsigned
int[] temp = new int[4];
for (int i = 0; i < 4; i++){
temp[i] = 0xFF & tempSigned[i];
}
// UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other 7-bit,
// 8-bit, or mixed-width encoding which ensures that the characters of ASCII have their
// normal positions, width, and values; the actual encoding declaration must be read to
@ -187,11 +188,11 @@ public class SystemEncodingUtil {
if (temp[0] == 0x3C && temp[1] == 0x3F && temp[2] == 0x78 && temp[3] == 0x6D) {
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
}
// UCS-4 or other encoding with a 32-bit code unit and ASCII characters encoded as
// ASCII values, in respectively big-endian (1234), little-endian (4321) and two
// unusual byte orders (2143 and 3412). The encoding declaration must be read to
// determine which of UCS-4 or other supported 32-bit encodings applies.
// determine which of UCS-4 or other supported 32-bit encodings applies.
// UCS-4, big-endian order (1234 order)
/* DKM - encodingGuess can only be null
@ -211,35 +212,35 @@ public class SystemEncodingUtil {
encodingGuess = null;
}
*/
// UTF-16BE or big-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
// in big-endian order and ASCII characters encoded as ASCII values (the encoding
// declaration must be read to determine which)
else if (temp[0] == 0x00 && temp[1] == 0x3C && temp[2] == 0x00 && temp[3] == 0x3F) {
encodingGuess = "UnicodeBigUnmarked"; //$NON-NLS-1$
}
// UTF-16LE or little-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
// in little-endian order and ASCII characters encoded as ASCII values (the encoding
// declaration must be read to determine which)
else if (temp[0] == 0x3C && temp[1] == 0x00 && temp[2] == 0x3F && temp[3] == 0x00) {
encodingGuess = "UnicodeLittleUnmarked"; //$NON-NLS-1$
}
// EBCDIC (in some flavor; the full encoding declaration must be read to tell which
// code page is in use)
else if (temp[0] == 0x4C && temp[1] == 0x6F && temp[2] == 0xA7 && temp[3] == 0x94) {
encodingGuess = "Cp037"; //$NON-NLS-1$
}
// UTF-8 without an encoding declaration, or else the data stream is mislabeled
// (lacking a required encoding declaration), corrupt, fragmentary, or enclosed in a
// wrapper of some kind
else {
// From section 4.3.3 of the XML specification:
// In the absence of information provided by an external transport protocol
// (e.g. HTTP or MIME), it is an error for an entity including an encoding declaration
@ -247,62 +248,62 @@ public class SystemEncodingUtil {
// declaration, or for an entity which begins with neither a Byte Order Mark nor an
// encoding declaration to use an encoding other than UTF-8. Note that since ASCII is
// a subset of UTF-8, ordinary ASCII entities do not strictly need an encoding declaration.
// We'll assume that this is UTF-8 or ASCII encoding without an encoding declaration.
// Of course, it could also be another encoding that doesn't have an encoding declaration
// in which case it has violated the XML specification (any encoding beside UTF-8 or UTF-16
// must specify the character encoding). From section 4.3.3 of the XML specification:
// In the absence of external character encoding information (such as MIME headers),
// parsed entities which are stored in an encoding other than UTF-8 or UTF-16 must begin
// with a text declaration (see 4.3.1 The Text Declaration) containing an encoding declaration.
// with a text declaration (see 4.3.1 The Text Declaration) containing an encoding declaration.
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
}
}
// if we have a guess, we need to read in the encoding declaration to get the actual encoding
// the guess tells us the encoding of the family
if (encodingGuess != null) {
boolean encodingFound = false;
FileInputStream inputStream = new FileInputStream(filePath);
InputStreamReader reader = new InputStreamReader(inputStream, encodingGuess);
// note that buffer capacity must be 1, otherwise we run into a problem
// if the XML file has a non UTF-8 encoding and accented characters in the file
BufferedReader bufReader = new BufferedReader(reader, 1);
String line = bufReader.readLine();
while (line != null) {
int encodingIndex = line.indexOf("encoding"); //$NON-NLS-1$
// look for the encoding attribute
if (encodingIndex != -1) {
// we look in the same line first
boolean sameLine = true;
boolean doubleQuoteFound = false;
boolean singleQuoteFound = false;
while (line != null) {
// now look for the begin quote, which does not have to be
// on the same line as the encoding attribute declaration
int beginQuote = -1;
// search in same line first
if (sameLine) {
// look for double quote
beginQuote = line.indexOf('\"', encodingIndex+9);
// if double quote not found, then try single quote
if (beginQuote == -1) {
beginQuote = line.indexOf('\'', encodingIndex+9);
// single quote found, so flag it
if (beginQuote != -1) {
singleQuoteFound = true;
@ -315,14 +316,14 @@ public class SystemEncodingUtil {
}
// search in another line now
else {
// look for double quote
beginQuote = line.indexOf('\"');
// if single quote not found, then try single quote
// if single quote not found, then try single quote
if (beginQuote == -1) {
beginQuote = line.indexOf('\'');
// single quote found, so flag it
if (beginQuote != -1) {
singleQuoteFound = true;
@ -333,47 +334,47 @@ public class SystemEncodingUtil {
doubleQuoteFound = true;
}
}
// if begin quote found, look for endquote which should be on the same line
if (beginQuote != -1) {
int endQuote = -1;
if (doubleQuoteFound) {
endQuote = line.indexOf('\"', beginQuote+1);
}
else if (singleQuoteFound){
endQuote = line.indexOf('\'', beginQuote+1);
}
// if end quote found, encoding is in between begin quote and end quote
if (endQuote != -1) {
encoding = line.substring(beginQuote+1, endQuote);
encodingFound = true;
}
break;
}
if (sameLine) {
sameLine = false;
}
line = bufReader.readLine();
}
}
if (encodingFound) {
break;
}
line = bufReader.readLine();
}
bufReader.close();
// if the encoding declaration was not found
if (encoding == null) {
// check if our initial guess was UTF-8 or UTF-16
// those do not have to have an encoding declaration
if (encodingGuess.equals(SystemEncodingUtil.ENCODING_UTF_8) || encodingGuess.startsWith("UnicodeBig") || //$NON-NLS-1$
@ -382,10 +383,10 @@ public class SystemEncodingUtil {
}
}
}
return encoding;
}
/**
* Gets the encoding from the Byte Order Mark (BOM).
* @param filePath the file path.
@ -393,36 +394,36 @@ public class SystemEncodingUtil {
*/
public String getEncodingFromBOM(String filePath) throws IOException {
FileInputStream stream = new FileInputStream(filePath);
String encoding = getEncodingFromBOM(stream);
stream.close();
return encoding;
}
/**
* Gets the encoding from the Byte Order Mark (BOM).
* @param filePath the file path.
* @return the encoding, or <code>null</code> 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;

View file

@ -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;

View file

@ -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:
* <code>
* 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: <code>
* 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;
* }
* </code>
*
*
* @since 3.0
*/
public class SystemReentrantMutex {

View file

@ -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 <code>null</code> 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{

View file

@ -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$

View file

@ -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
* <code>org.eclipse.rse.ui.SystemBasePlugin#loadMessageFile()</code> and
* <code>org.eclipse.rse.ui.SystemBasePlugin#getMessage()</code> methods.
*
*
* Clients can use either globally unique RSE message IDs or plugin-specific
* local IDs. <b>RSE-global message IDs</b> are of the form:
* RSE&lt;subcomponent&gt;&lt;number&gt;, where the subcomponent is a single
@ -65,17 +69,17 @@ public class SimpleSystemMessage extends SystemMessage {
* <li>"C" for Communications</li>
* </ul>
* 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:
*
*
* <pre>
* 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()));
* </pre>
*
*
* <b>Plugin-specific local IDs</b> 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

View file

@ -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();
}