mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[releng][cleanup] Fix @since tags according to API Tooling
This commit is contained in:
parent
e13dc52133
commit
8c6050dbe2
7 changed files with 200 additions and 183 deletions
|
@ -7,10 +7,10 @@
|
||||||
*
|
*
|
||||||
* Initial Contributors:
|
* Initial Contributors:
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
* The following IBM employees contributed to the Remote System Explorer
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David McKnight (IBM) [215847]SystemEncodingUtil needs to convert to unsigned when checking xml file
|
* 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
|
* 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.
|
* A singleton class that contains useful methods related to encodings.
|
||||||
*/
|
*/
|
||||||
public class SystemEncodingUtil {
|
public class SystemEncodingUtil {
|
||||||
|
|
||||||
private static SystemEncodingUtil instance;
|
private static SystemEncodingUtil instance;
|
||||||
public static String ENCODING_UTF_8 = "UTF-8"; //$NON-NLS-1$
|
public static String ENCODING_UTF_8 = "UTF-8"; //$NON-NLS-1$
|
||||||
|
|
||||||
private DefaultEncodingProvider _defaultEncodingProvider = new DefaultEncodingProvider();
|
private DefaultEncodingProvider _defaultEncodingProvider = new DefaultEncodingProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,20 +40,20 @@ public class SystemEncodingUtil {
|
||||||
private SystemEncodingUtil() {
|
private SystemEncodingUtil() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the singleton instance of the utility class.
|
* Returns the singleton instance of the utility class.
|
||||||
* @return the singleton instance.
|
* @return the singleton instance.
|
||||||
*/
|
*/
|
||||||
public static SystemEncodingUtil getInstance() {
|
public static SystemEncodingUtil getInstance() {
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new SystemEncodingUtil();
|
instance = new SystemEncodingUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,32 +73,33 @@ public class SystemEncodingUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the default encoding provider.
|
* Change the default encoding provider.
|
||||||
*
|
*
|
||||||
* This is a system-wide change, and clients will not be notified
|
* This is a system-wide change, and clients will not be notified of changed
|
||||||
* of changed default encodings due to changing the provider. Therefore,
|
* default encodings due to changing the provider. Therefore, changing the
|
||||||
* changing the provider should be done only once during early system
|
* provider should be done only once during early system startup.
|
||||||
* startup.
|
*
|
||||||
*
|
* @param p the new encoding provider.
|
||||||
* @param p the new encoding provider.
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public void setDefaultEncodingProvider(DefaultEncodingProvider p) {
|
public void setDefaultEncodingProvider(DefaultEncodingProvider p) {
|
||||||
_defaultEncodingProvider = p;
|
_defaultEncodingProvider = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the local default encoding as provided by the default encoding
|
* Returns the local default encoding as provided by the default encoding
|
||||||
* provider. This method should be called after RSE startup is complete
|
* provider. This method should be called after RSE startup is complete in
|
||||||
* in order to get the proper default workspace encoding.
|
* order to get the proper default workspace encoding.
|
||||||
*
|
*
|
||||||
* @return the local default encoding
|
* @return the local default encoding
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public String getLocalDefaultEncoding() {
|
public String getLocalDefaultEncoding() {
|
||||||
return _defaultEncodingProvider.getLocalDefaultEncoding();
|
return _defaultEncodingProvider.getLocalDefaultEncoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the encoding of the environment. This is the encoding being used by the JVM,
|
* 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.
|
* which by default is the machine encoding, unless changed explicitly.
|
||||||
|
@ -107,29 +108,29 @@ public class SystemEncodingUtil {
|
||||||
public String getEnvironmentEncoding() {
|
public String getEnvironmentEncoding() {
|
||||||
return System.getProperty("file.encoding"); //$NON-NLS-1$
|
return System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the file is an XML file.
|
* Returns whether the file is an XML file.
|
||||||
* @param filePath the file path.
|
* @param filePath the file path.
|
||||||
* @return <code>true</code> if the file is an XML file, <code>false</code> otherwise.
|
* @return <code>true</code> if the file is an XML file, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean isXML(String filePath) {
|
public boolean isXML(String filePath) {
|
||||||
|
|
||||||
int index = filePath.lastIndexOf("."); //$NON-NLS-1$
|
int index = filePath.lastIndexOf("."); //$NON-NLS-1$
|
||||||
|
|
||||||
// check if there is a "."
|
// check if there is a "."
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// check if the name ends with "."
|
// check if the name ends with "."
|
||||||
if (index == filePath.length() - 1) {
|
if (index == filePath.length() - 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String extension = filePath.substring(index+1);
|
String extension = filePath.substring(index+1);
|
||||||
|
|
||||||
if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
|
if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -139,46 +140,46 @@ public class SystemEncodingUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the encoding of an XML file.
|
* Gets the encoding of an XML file.
|
||||||
* @param filePath the file path.
|
* @param filePath the file path.
|
||||||
* @return the encoding, or <code>null</code> if the encoding could not be determined.
|
* @return the encoding, or <code>null</code> if the encoding could not be determined.
|
||||||
*/
|
*/
|
||||||
public String getXMLFileEncoding(String filePath) throws IOException {
|
public String getXMLFileEncoding(String filePath) throws IOException {
|
||||||
|
|
||||||
String encoding = null;
|
String encoding = null;
|
||||||
|
|
||||||
// this is an implementation of the encoding detection algorithm
|
// this is an implementation of the encoding detection algorithm
|
||||||
// as specified in Appendix F of the XML specification
|
// as specified in Appendix F of the XML specification
|
||||||
|
|
||||||
FileInputStream stream = new FileInputStream(filePath);
|
FileInputStream stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
// try to get the encoding if the file starts with a BOM
|
// try to get the encoding if the file starts with a BOM
|
||||||
String encodingGuess = getEncodingFromBOM(stream);
|
String encodingGuess = getEncodingFromBOM(stream);
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
// if no BOM, read in bytes corresponding to the first four chars in the header, i.e. "<?xm"
|
// 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
|
// and try to determine the encoding from that
|
||||||
if (encodingGuess == null) {
|
if (encodingGuess == null) {
|
||||||
|
|
||||||
stream = new FileInputStream(filePath);
|
stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
byte[] tempSigned = new byte[4];
|
byte[] tempSigned = new byte[4];
|
||||||
|
|
||||||
stream.read(tempSigned);
|
stream.read(tempSigned);
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
|
|
||||||
// convert to unsigned
|
// convert to unsigned
|
||||||
int[] temp = new int[4];
|
int[] temp = new int[4];
|
||||||
for (int i = 0; i < 4; i++){
|
for (int i = 0; i < 4; i++){
|
||||||
temp[i] = 0xFF & tempSigned[i];
|
temp[i] = 0xFF & tempSigned[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other 7-bit,
|
// 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
|
// 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
|
// 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) {
|
if (temp[0] == 0x3C && temp[1] == 0x3F && temp[2] == 0x78 && temp[3] == 0x6D) {
|
||||||
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
|
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UCS-4 or other encoding with a 32-bit code unit and ASCII characters encoded as
|
// 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
|
// 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
|
// 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)
|
// UCS-4, big-endian order (1234 order)
|
||||||
/* DKM - encodingGuess can only be null
|
/* DKM - encodingGuess can only be null
|
||||||
|
@ -211,35 +212,35 @@ public class SystemEncodingUtil {
|
||||||
encodingGuess = null;
|
encodingGuess = null;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// UTF-16BE or big-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
|
// 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
|
// in big-endian order and ASCII characters encoded as ASCII values (the encoding
|
||||||
// declaration must be read to determine which)
|
// declaration must be read to determine which)
|
||||||
else if (temp[0] == 0x00 && temp[1] == 0x3C && temp[2] == 0x00 && temp[3] == 0x3F) {
|
else if (temp[0] == 0x00 && temp[1] == 0x3C && temp[2] == 0x00 && temp[3] == 0x3F) {
|
||||||
encodingGuess = "UnicodeBigUnmarked"; //$NON-NLS-1$
|
encodingGuess = "UnicodeBigUnmarked"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UTF-16LE or little-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
|
// 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
|
// in little-endian order and ASCII characters encoded as ASCII values (the encoding
|
||||||
// declaration must be read to determine which)
|
// declaration must be read to determine which)
|
||||||
else if (temp[0] == 0x3C && temp[1] == 0x00 && temp[2] == 0x3F && temp[3] == 0x00) {
|
else if (temp[0] == 0x3C && temp[1] == 0x00 && temp[2] == 0x3F && temp[3] == 0x00) {
|
||||||
encodingGuess = "UnicodeLittleUnmarked"; //$NON-NLS-1$
|
encodingGuess = "UnicodeLittleUnmarked"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// EBCDIC (in some flavor; the full encoding declaration must be read to tell which
|
// EBCDIC (in some flavor; the full encoding declaration must be read to tell which
|
||||||
// code page is in use)
|
// code page is in use)
|
||||||
else if (temp[0] == 0x4C && temp[1] == 0x6F && temp[2] == 0xA7 && temp[3] == 0x94) {
|
else if (temp[0] == 0x4C && temp[1] == 0x6F && temp[2] == 0xA7 && temp[3] == 0x94) {
|
||||||
encodingGuess = "Cp037"; //$NON-NLS-1$
|
encodingGuess = "Cp037"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UTF-8 without an encoding declaration, or else the data stream is mislabeled
|
// UTF-8 without an encoding declaration, or else the data stream is mislabeled
|
||||||
// (lacking a required encoding declaration), corrupt, fragmentary, or enclosed in a
|
// (lacking a required encoding declaration), corrupt, fragmentary, or enclosed in a
|
||||||
// wrapper of some kind
|
// wrapper of some kind
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// From section 4.3.3 of the XML specification:
|
// From section 4.3.3 of the XML specification:
|
||||||
// In the absence of information provided by an external transport protocol
|
// 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
|
// (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
|
// 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
|
// 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.
|
// 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.
|
// 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
|
// 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
|
// 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:
|
// 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),
|
// 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
|
// 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;
|
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have a guess, we need to read in the encoding declaration to get the actual encoding
|
// 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
|
// the guess tells us the encoding of the family
|
||||||
if (encodingGuess != null) {
|
if (encodingGuess != null) {
|
||||||
|
|
||||||
boolean encodingFound = false;
|
boolean encodingFound = false;
|
||||||
|
|
||||||
FileInputStream inputStream = new FileInputStream(filePath);
|
FileInputStream inputStream = new FileInputStream(filePath);
|
||||||
InputStreamReader reader = new InputStreamReader(inputStream, encodingGuess);
|
InputStreamReader reader = new InputStreamReader(inputStream, encodingGuess);
|
||||||
|
|
||||||
// note that buffer capacity must be 1, otherwise we run into a problem
|
// 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
|
// if the XML file has a non UTF-8 encoding and accented characters in the file
|
||||||
BufferedReader bufReader = new BufferedReader(reader, 1);
|
BufferedReader bufReader = new BufferedReader(reader, 1);
|
||||||
|
|
||||||
String line = bufReader.readLine();
|
String line = bufReader.readLine();
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
|
|
||||||
int encodingIndex = line.indexOf("encoding"); //$NON-NLS-1$
|
int encodingIndex = line.indexOf("encoding"); //$NON-NLS-1$
|
||||||
|
|
||||||
// look for the encoding attribute
|
// look for the encoding attribute
|
||||||
if (encodingIndex != -1) {
|
if (encodingIndex != -1) {
|
||||||
|
|
||||||
// we look in the same line first
|
// we look in the same line first
|
||||||
boolean sameLine = true;
|
boolean sameLine = true;
|
||||||
|
|
||||||
boolean doubleQuoteFound = false;
|
boolean doubleQuoteFound = false;
|
||||||
boolean singleQuoteFound = false;
|
boolean singleQuoteFound = false;
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
|
|
||||||
// now look for the begin quote, which does not have to be
|
// now look for the begin quote, which does not have to be
|
||||||
// on the same line as the encoding attribute declaration
|
// on the same line as the encoding attribute declaration
|
||||||
int beginQuote = -1;
|
int beginQuote = -1;
|
||||||
|
|
||||||
// search in same line first
|
// search in same line first
|
||||||
if (sameLine) {
|
if (sameLine) {
|
||||||
|
|
||||||
// look for double quote
|
// look for double quote
|
||||||
beginQuote = line.indexOf('\"', encodingIndex+9);
|
beginQuote = line.indexOf('\"', encodingIndex+9);
|
||||||
|
|
||||||
// if double quote not found, then try single quote
|
// if double quote not found, then try single quote
|
||||||
if (beginQuote == -1) {
|
if (beginQuote == -1) {
|
||||||
beginQuote = line.indexOf('\'', encodingIndex+9);
|
beginQuote = line.indexOf('\'', encodingIndex+9);
|
||||||
|
|
||||||
// single quote found, so flag it
|
// single quote found, so flag it
|
||||||
if (beginQuote != -1) {
|
if (beginQuote != -1) {
|
||||||
singleQuoteFound = true;
|
singleQuoteFound = true;
|
||||||
|
@ -315,14 +316,14 @@ public class SystemEncodingUtil {
|
||||||
}
|
}
|
||||||
// search in another line now
|
// search in another line now
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// look for double quote
|
// look for double quote
|
||||||
beginQuote = line.indexOf('\"');
|
beginQuote = line.indexOf('\"');
|
||||||
|
|
||||||
// if single quote not found, then try single quote
|
// if single quote not found, then try single quote
|
||||||
if (beginQuote == -1) {
|
if (beginQuote == -1) {
|
||||||
beginQuote = line.indexOf('\'');
|
beginQuote = line.indexOf('\'');
|
||||||
|
|
||||||
// single quote found, so flag it
|
// single quote found, so flag it
|
||||||
if (beginQuote != -1) {
|
if (beginQuote != -1) {
|
||||||
singleQuoteFound = true;
|
singleQuoteFound = true;
|
||||||
|
@ -333,47 +334,47 @@ public class SystemEncodingUtil {
|
||||||
doubleQuoteFound = true;
|
doubleQuoteFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if begin quote found, look for endquote which should be on the same line
|
// if begin quote found, look for endquote which should be on the same line
|
||||||
if (beginQuote != -1) {
|
if (beginQuote != -1) {
|
||||||
int endQuote = -1;
|
int endQuote = -1;
|
||||||
|
|
||||||
if (doubleQuoteFound) {
|
if (doubleQuoteFound) {
|
||||||
endQuote = line.indexOf('\"', beginQuote+1);
|
endQuote = line.indexOf('\"', beginQuote+1);
|
||||||
}
|
}
|
||||||
else if (singleQuoteFound){
|
else if (singleQuoteFound){
|
||||||
endQuote = line.indexOf('\'', beginQuote+1);
|
endQuote = line.indexOf('\'', beginQuote+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if end quote found, encoding is in between begin quote and end quote
|
// if end quote found, encoding is in between begin quote and end quote
|
||||||
if (endQuote != -1) {
|
if (endQuote != -1) {
|
||||||
encoding = line.substring(beginQuote+1, endQuote);
|
encoding = line.substring(beginQuote+1, endQuote);
|
||||||
encodingFound = true;
|
encodingFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sameLine) {
|
if (sameLine) {
|
||||||
sameLine = false;
|
sameLine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = bufReader.readLine();
|
line = bufReader.readLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encodingFound) {
|
if (encodingFound) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = bufReader.readLine();
|
line = bufReader.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bufReader.close();
|
bufReader.close();
|
||||||
|
|
||||||
// if the encoding declaration was not found
|
// if the encoding declaration was not found
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
|
|
||||||
// check if our initial guess was UTF-8 or UTF-16
|
// check if our initial guess was UTF-8 or UTF-16
|
||||||
// those do not have to have an encoding declaration
|
// those do not have to have an encoding declaration
|
||||||
if (encodingGuess.equals(SystemEncodingUtil.ENCODING_UTF_8) || encodingGuess.startsWith("UnicodeBig") || //$NON-NLS-1$
|
if (encodingGuess.equals(SystemEncodingUtil.ENCODING_UTF_8) || encodingGuess.startsWith("UnicodeBig") || //$NON-NLS-1$
|
||||||
|
@ -382,10 +383,10 @@ public class SystemEncodingUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the encoding from the Byte Order Mark (BOM).
|
* Gets the encoding from the Byte Order Mark (BOM).
|
||||||
* @param filePath the file path.
|
* @param filePath the file path.
|
||||||
|
@ -393,36 +394,36 @@ public class SystemEncodingUtil {
|
||||||
*/
|
*/
|
||||||
public String getEncodingFromBOM(String filePath) throws IOException {
|
public String getEncodingFromBOM(String filePath) throws IOException {
|
||||||
FileInputStream stream = new FileInputStream(filePath);
|
FileInputStream stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
String encoding = getEncodingFromBOM(stream);
|
String encoding = getEncodingFromBOM(stream);
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the encoding from the Byte Order Mark (BOM).
|
* Gets the encoding from the Byte Order Mark (BOM).
|
||||||
* @param filePath the file path.
|
* @param filePath the file path.
|
||||||
* @return the encoding, or <code>null</code> if there is no BOM.
|
* @return the encoding, or <code>null</code> if there is no BOM.
|
||||||
*/
|
*/
|
||||||
private String getEncodingFromBOM(InputStream stream) throws IOException {
|
private String getEncodingFromBOM(InputStream stream) throws IOException {
|
||||||
|
|
||||||
byte[] bomBytes = new byte[4];
|
byte[] bomBytes = new byte[4];
|
||||||
|
|
||||||
// read the first three bytes
|
// read the first three bytes
|
||||||
stream.read(bomBytes, 0, 3);
|
stream.read(bomBytes, 0, 3);
|
||||||
|
|
||||||
// check if UTF-8 BOM
|
// check if UTF-8 BOM
|
||||||
if (bomBytes[0] == 0xEF && bomBytes[1] == 0xBB && bomBytes[2] == 0xBF) {
|
if (bomBytes[0] == 0xEF && bomBytes[1] == 0xBB && bomBytes[2] == 0xBF) {
|
||||||
return SystemEncodingUtil.ENCODING_UTF_8;
|
return SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now read the fourth byte
|
// now read the fourth byte
|
||||||
stream.read(bomBytes, 3, 1);
|
stream.read(bomBytes, 3, 1);
|
||||||
|
|
||||||
// check if it matches some other encoding BOM
|
// check if it matches some other encoding BOM
|
||||||
|
|
||||||
// UCS-4, big-endian order (1234 order)
|
// UCS-4, big-endian order (1234 order)
|
||||||
if (bomBytes[0] == 0x00 && bomBytes[1] == 0x00 && bomBytes[2] == 0xFE && bomBytes[3] == 0xFF) {
|
if (bomBytes[0] == 0x00 && bomBytes[1] == 0x00 && bomBytes[2] == 0xFE && bomBytes[3] == 0xFF) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,36 +6,42 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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
|
* Martin Oberhuber (Wind River) - [216252] canceled --> cancelled in comments and locals
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.rse.services.clientserver;
|
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 cancelled = false;
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
|
|
||||||
public boolean isDone()
|
public boolean isDone()
|
||||||
{
|
{
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDone(boolean value)
|
public void setDone(boolean value)
|
||||||
{
|
{
|
||||||
done = value;
|
done = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancelled()
|
public boolean isCancelled()
|
||||||
{
|
{
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setCancelled(boolean value)
|
public void setCancelled(boolean value)
|
||||||
{
|
{
|
||||||
cancelled = value;
|
cancelled = value;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||||
* Xuan Chen (IBM) - [160775] Derive from org.eclipse.rse.services.Mutex
|
* Xuan Chen (IBM) - [160775] Derive from org.eclipse.rse.services.Mutex
|
||||||
* Xuan Chen (IBM) - [209825] add some info of printing the lock status
|
* Xuan Chen (IBM) - [209825] add some info of printing the lock status
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -18,36 +18,36 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SystemMutex Exclusion Lock for Threads that need to access a resource
|
* A reentrant Exclusion Lock for Threads that need to access a resource in a
|
||||||
* in a serialized manner.
|
* serialized manner. If the request for the lock is running on the same thread
|
||||||
* If the request for the lock is running on the same thread who is currently holding the lock,
|
* who is currently holding the lock, it will "borrow" the lock, and the call to
|
||||||
* it will "borrow" the lock, and the call to waitForLock() will go through.
|
* waitForLock() will go through. A SystemOperationMonitor is accepted in order
|
||||||
* An SystemOperationMonitor is accepted
|
* to support cancellation when waiting for the Mutex. This is a clone of
|
||||||
* in order to support cancellation when waiting for the SystemMutex.
|
* {@link org.eclipse.rse.services.Mutex} with some modification to make sure the
|
||||||
* 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
|
||||||
* sequential calls to waitForLock() method in the same thread will not be blocked.
|
* blocked.
|
||||||
*
|
*
|
||||||
* Usage Example:
|
* Usage Example: <code>
|
||||||
* <code>
|
* private SystemReentrantMutex fooMutex = new SystemReentrantMutex();
|
||||||
* private SystemMutex fooMutex = new SystemMutex();
|
|
||||||
* boolean doFooSerialized()(ISystemOperationMonitor monitor) {
|
* boolean doFooSerialized()(ISystemOperationMonitor monitor) {
|
||||||
* int mutexLockStatus = SystemMutex.LOCK_STATUS_NOLOCK;
|
* int mutexLockStatus = SystemReentrantMutex.LOCK_STATUS_NOLOCK;
|
||||||
* mutexLockStatus = fooMutex.waitForLock(monitor, 1000);
|
* mutexLockStatus = fooMutex.waitForLock(monitor, 1000);
|
||||||
* if (SystemMutex.LOCK_STATUS_NOLOCK != mutexLockStatus) {
|
* if (mutexLockStatus != SystemReentrantMutex.LOCK_STATUS_NOLOCK) {
|
||||||
* try {
|
* try {
|
||||||
* return doFoo();
|
* return doFoo();
|
||||||
* } finally {
|
* } finally {
|
||||||
* //We only release the mutex if we acquire it, not borrowed it.
|
* //We only release the mutex if we acquire it, not borrowed it.
|
||||||
* if (SystemMutex.LOCK_STATUS_AQUIRED == mutexLockStatus)
|
* if (mutexLockStatus == SystemReentrantMutex.LOCK_STATUS_AQUIRED)
|
||||||
* {
|
* {
|
||||||
* fooMutex.release();
|
* fooMutex.release();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* return false;
|
* return false;
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class SystemReentrantMutex {
|
public class SystemReentrantMutex {
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Johnson Ma (Wind River) - initial API and implementation
|
* Johnson Ma (Wind River) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.rse.services.clientserver.archiveutils;
|
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;
|
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 {
|
public class SystemTgzHandler extends SystemTarHandler {
|
||||||
|
|
||||||
|
@ -30,25 +32,25 @@ public class SystemTgzHandler extends SystemTarHandler {
|
||||||
public SystemTgzHandler(File file) throws IOException {
|
public SystemTgzHandler(File file) throws IOException {
|
||||||
super(file);
|
super(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a tar.gz file from the underlying 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.
|
* @return the tar file, or <code>null</code> if the tar file does not exist.
|
||||||
*/
|
*/
|
||||||
protected TarFile getTarFile() {
|
protected TarFile getTarFile() {
|
||||||
|
|
||||||
TarFile tarFile = null;
|
TarFile tarFile = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tarFile = new TgzFile(file);
|
tarFile = new TgzFile(file);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
// TODO: log error
|
// TODO: log error
|
||||||
}
|
}
|
||||||
|
|
||||||
return tarFile;
|
return tarFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException {
|
protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException {
|
||||||
GZIPOutputStream zipOutputStream = null;
|
GZIPOutputStream zipOutputStream = null;
|
||||||
try{
|
try{
|
||||||
|
|
|
@ -17,7 +17,10 @@ package org.eclipse.rse.services.clientserver.messages;
|
||||||
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Externalized Strings for common messages that all clients can use.
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
public class CommonMessages extends NLS {
|
public class CommonMessages extends NLS {
|
||||||
private static String BUNDLE_NAME = "org.eclipse.rse.services.clientserver.messages.CommonMessages";//$NON-NLS-1$
|
private static String BUNDLE_NAME = "org.eclipse.rse.services.clientserver.messages.CommonMessages";//$NON-NLS-1$
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,11 @@ import java.io.StringWriter;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
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 {
|
public class SimpleSystemMessage extends SystemMessage {
|
||||||
|
|
||||||
private String _pluginId;
|
private String _pluginId;
|
||||||
|
@ -47,13 +51,13 @@ public class SimpleSystemMessage extends SystemMessage {
|
||||||
/**
|
/**
|
||||||
* Creates a String based System Message with severity, ID and String
|
* Creates a String based System Message with severity, ID and String
|
||||||
* message details.
|
* message details.
|
||||||
*
|
*
|
||||||
* This allows using the RSE Messaging Framework based on simple String
|
* This allows using the RSE Messaging Framework based on simple String
|
||||||
* messages and IDs, rather than using XML Message files from
|
* messages and IDs, rather than using XML Message files from
|
||||||
* {@link SystemMessageFile} along with the
|
* {@link SystemMessageFile} along with the
|
||||||
* <code>org.eclipse.rse.ui.SystemBasePlugin#loadMessageFile()</code> and
|
* <code>org.eclipse.rse.ui.SystemBasePlugin#loadMessageFile()</code> and
|
||||||
* <code>org.eclipse.rse.ui.SystemBasePlugin#getMessage()</code> methods.
|
* <code>org.eclipse.rse.ui.SystemBasePlugin#getMessage()</code> methods.
|
||||||
*
|
*
|
||||||
* Clients can use either globally unique RSE message IDs or plugin-specific
|
* Clients can use either globally unique RSE message IDs or plugin-specific
|
||||||
* local IDs. <b>RSE-global message IDs</b> are of the form:
|
* local IDs. <b>RSE-global message IDs</b> are of the form:
|
||||||
* RSE<subcomponent><number>, where the subcomponent is a single
|
* RSE<subcomponent><number>, where the subcomponent is a single
|
||||||
|
@ -65,17 +69,17 @@ public class SimpleSystemMessage extends SystemMessage {
|
||||||
* <li>"C" for Communications</li>
|
* <li>"C" for Communications</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* and the number is a four digit number.
|
* and the number is a four digit number.
|
||||||
*
|
*
|
||||||
* Some RSE-global message IDs are predefined in {@link ICommonMessageIds}.
|
* Some RSE-global message IDs are predefined in {@link ICommonMessageIds}.
|
||||||
* When used in a SimpleSystemMessage, these common message IDs must be used
|
* When used in a SimpleSystemMessage, these common message IDs must be used
|
||||||
* along with the matching message Strings from {@link CommonMessages}, in
|
* along with the matching message Strings from {@link CommonMessages}, in
|
||||||
* order to be consistent to the user. For example:
|
* order to be consistent to the user. For example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_COMM_AUTH_FAILED, IStatus.ERROR, CommonMessages.MSG_COMM_AUTH_FAILED, NLS.bind(
|
* 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()));
|
* CommonMessages.MSG_COMM_AUTH_FAILED_DETAILS, getHost().getAliasName()));
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <b>Plugin-specific local IDs</b> are totally free to be defined by the
|
* <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
|
* 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
|
* 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
|
* 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
|
* ID: relative IDs are qualified by the specified plugin ID, so they live
|
||||||
* in the plugin ID namespace.
|
* in the plugin ID namespace.
|
||||||
*
|
*
|
||||||
* @param pluginId the id of the originating plugin
|
* @param pluginId the id of the originating plugin
|
||||||
* @param messageId the RSE-global unique ID or plugin-specific local ID of
|
* @param messageId the RSE-global unique ID or plugin-specific local ID of
|
||||||
* the message
|
* the message
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
*
|
*
|
||||||
* Initial Contributors:
|
* Initial Contributors:
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
* The following IBM employees contributed to the Remote System Explorer
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - [197848] Fix shell terminated state when remote dies
|
* Martin Oberhuber (Wind River) - [197848] Fix shell terminated state when remote dies
|
||||||
* Martin Oberhuber (Wind River) - [217429] Make registering multiple output listeners thread-safe
|
* 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 List _listeners;
|
||||||
protected int _waitIncrement = 2;
|
protected int _waitIncrement = 2;
|
||||||
protected boolean _keepRunning = true;
|
protected boolean _keepRunning = true;
|
||||||
|
|
||||||
protected List _linesOfOutput;
|
protected List _linesOfOutput;
|
||||||
protected int _consumerOffset;
|
protected int _consumerOffset;
|
||||||
protected IHostShell _hostShell;
|
protected IHostShell _hostShell;
|
||||||
protected boolean _isErrorReader = false;
|
protected boolean _isErrorReader = false;
|
||||||
|
|
||||||
|
|
||||||
protected long _timeOfLastEvent = 0;
|
protected long _timeOfLastEvent = 0;
|
||||||
protected int _sizeAtLastEvent = 0;
|
protected int _sizeAtLastEvent = 0;
|
||||||
|
|
||||||
public AbstractHostShellOutputReader(IHostShell hostShell, boolean isErrorReader)
|
public AbstractHostShellOutputReader(IHostShell hostShell, boolean isErrorReader)
|
||||||
{
|
{
|
||||||
_hostShell = hostShell;
|
_hostShell = hostShell;
|
||||||
|
@ -46,17 +46,17 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
_isErrorReader = isErrorReader;
|
_isErrorReader = isErrorReader;
|
||||||
_timeOfLastEvent = System.currentTimeMillis();
|
_timeOfLastEvent = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isErrorReader()
|
public boolean isErrorReader()
|
||||||
{
|
{
|
||||||
return _isErrorReader;
|
return _isErrorReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostShell getHostShell()
|
public IHostShell getHostShell()
|
||||||
{
|
{
|
||||||
return _hostShell;
|
return _hostShell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWaitTime(int value)
|
public void setWaitTime(int value)
|
||||||
{
|
{
|
||||||
_waitIncrement = value;
|
_waitIncrement = value;
|
||||||
|
@ -82,20 +82,20 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
finish();
|
finish();
|
||||||
_keepRunning = false;
|
_keepRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addLine(IHostOutput line)
|
protected void addLine(IHostOutput line)
|
||||||
{
|
{
|
||||||
_linesOfOutput.add(line);
|
_linesOfOutput.add(line);
|
||||||
int sizenow = _linesOfOutput.size();
|
int sizenow = _linesOfOutput.size();
|
||||||
int deltaSize = sizenow - _sizeAtLastEvent;
|
int deltaSize = sizenow - _sizeAtLastEvent;
|
||||||
|
|
||||||
long timenow = System.currentTimeMillis();
|
long timenow = System.currentTimeMillis();
|
||||||
//if ((timenow - _timeOfLastEvent) > 10 || deltaSize > 2)
|
//if ((timenow - _timeOfLastEvent) > 10 || deltaSize > 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// notify listeners
|
// notify listeners
|
||||||
HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, _sizeAtLastEvent, deltaSize);
|
HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, _sizeAtLastEvent, deltaSize);
|
||||||
fireOutputChanged(event);
|
fireOutputChanged(event);
|
||||||
|
@ -103,30 +103,31 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
_sizeAtLastEvent = sizenow;
|
_sizeAtLastEvent = sizenow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @since 3.0 */
|
||||||
protected final synchronized void startIfNotAlive() {
|
protected final synchronized void startIfNotAlive() {
|
||||||
if (!isAlive()) {
|
if (!isAlive()) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostOutput readLine()
|
public IHostOutput readLine()
|
||||||
{
|
{
|
||||||
if (!isAlive())
|
if (!isAlive())
|
||||||
{
|
{
|
||||||
internalReadLine();
|
internalReadLine();
|
||||||
startIfNotAlive();
|
startIfNotAlive();
|
||||||
}
|
}
|
||||||
return (IHostOutput)_linesOfOutput.get(_consumerOffset++);
|
return (IHostOutput)_linesOfOutput.get(_consumerOffset++);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostOutput readLine(int lineNumber)
|
public IHostOutput readLine(int lineNumber)
|
||||||
{
|
{
|
||||||
return (IHostOutput)_linesOfOutput.get(lineNumber);
|
return (IHostOutput)_linesOfOutput.get(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setLineOffset(int lineNumber)
|
public void setLineOffset(int lineNumber)
|
||||||
{
|
{
|
||||||
_consumerOffset = lineNumber;
|
_consumerOffset = lineNumber;
|
||||||
|
@ -147,12 +148,12 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
if (!_keepRunning)
|
if (!_keepRunning)
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
_listeners.clear();
|
_listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFinished()
|
public boolean isFinished()
|
||||||
{
|
{
|
||||||
return !_keepRunning;
|
return !_keepRunning;
|
||||||
|
@ -166,7 +167,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
//dispose();
|
//dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
while (_keepRunning)
|
while (_keepRunning)
|
||||||
|
@ -189,7 +190,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
|
||||||
fireOutputChanged(event);
|
fireOutputChanged(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IHostOutput internalReadLine();
|
protected abstract IHostOutput internalReadLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue