InputStreamReader inReader = new InputStreamReader(inStream); int fileSize = inStream.available(); char charBuf[] = new char[fileSize]; int count = inReader.read(charBuf, 0, fileSize); if (count != fileSize) throw new IOException( "Could read only "+ count + " chars from a total file size of " + fileSize + ". Import failed."); // convert file text into a string // Special case: some systems tack a newline at the end of // the text read. Assume that if last char is a newline that // we want everything else in the line. String fileText; if (charBuf[count-1] == KeyEvent.VK_ENTER) fileText = new String(charBuf, 0, count-1); else fileText = new String(charBuf); // test that the string is valid by converting it into an // object of this data type StringBuffer messageBuffer = new StringBuffer(); validateAndConvertInPopup(fileText, null, messageBuffer); if (messageBuffer.length() > 0) { // convert number conversion issue into IO issue for consistancy throw new IOException( "Text does not represent data of type "+getClassName()+ ". Text was:\n"+fileText); } // return the text from the file since it does // represent a valid data value return fileText;
InputStreamReader inReader = new InputStreamReader(inStream); int fileSize = inStream.available(); char charBuf[] = new char[fileSize]; int count = inReader.read(charBuf, 0, fileSize); if (count != fileSize) throw new IOException("Could read only " + count + " chars from a total file size of " + fileSize + ". Import failed."); // convert file text into a string // Special case: some systems tack a newline at the end of // the text read. Assume that if last char is a newline that // we want everything else in the line. String fileText; if (charBuf[count - 1] == KeyEvent.VK_ENTER) fileText = new String(charBuf, 0, count - 1); else fileText = new String(charBuf); // test that the string is valid by converting it into an // object of this data type StringBuffer messageBuffer = new StringBuffer(); validateAndConvertInPopup(fileText, null, messageBuffer); if (messageBuffer.length() > 0) { // convert number conversion issue into IO issue for consistancy throw new IOException("Text does not represent data of type " + getClassName() + ". Text was:\n" + fileText); } // return the text from the file since it does // represent a valid data value return fileText;
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeByte.java File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java
Method name: String importObject(FileInputStream) Method name: String importObject(FileInputStream)
Number of AST nodes: 15 Number of AST nodes: 15
1
InputStreamReader inReader = new InputStreamReader(inStream);
1
InputStreamReader inReader = new InputStreamReader(inStream);
2
	 	
3
	 	
4
int fileSize = inStream.available();
2
      int fileSize = inStream.available();
5
	 	
6
	 	
7
char charBuf[] = new char[fileSize];
3
      char charBuf[] = new char[fileSize];
8
	 	
9
	 	
10
int count = inReader.read(charBuf, 0, fileSize);
4
      int count = inReader.read(charBuf, 0, fileSize);
11
	 	
12
	 	
13
if (count != fileSize)
5
      if (count != fileSize)
14
	 		throw new IOException(
6
         throw new IOException(
15
	 			"Could read only "+ count +
7
"Could read only " + count
16
	 			
17
" chars from a total file size of " + fileSize +
8
               + " chars from a total file size of " + fileSize
18
	 			
19
". Import failed.");
9
               + ". Import failed.");
20
	 	
21
	 	
22
// convert file text into a string
10
      // convert file text into a string
23
	 	// Special case: some systems tack a newline at the end of
11
      // Special case: some systems tack a newline at the end of
24
	 	// the text read.  Assume that if last char is a newline that
12
      // the text read. Assume that if last char is a newline that
25
	 	// we want everything else in the line.
13
      // we want everything else in the line.
26
	 	String fileText;
14
      String fileText;
27
	 	if (charBuf[count-1] == KeyEvent.VK_ENTER)
15
      if (charBuf[count - 1] == KeyEvent.VK_ENTER)
28
	 		fileText = new String(charBuf, 0, count-1);
16
         fileText = new String(charBuf, 0, count - 1);
29
	 	else
17
      else
30
 fileText = new String(charBuf);
18
         fileText = new String(charBuf);
31
	 	
32
	 	
33
// test that the string is valid by converting it into an
19
      // test that the string is valid by converting it into an
34
	 	// object of this data type
20
      // object of this data type
35
	 	StringBuffer messageBuffer = new StringBuffer();
21
      StringBuffer messageBuffer = new StringBuffer();
36
	 	validateAndConvertInPopup(fileText, null, messageBuffer);
22
      validateAndConvertInPopup(fileText, null, messageBuffer);
37
	 	if (messageBuffer.length() > 0) {
23
      if (messageBuffer.length() > 0) {
38
	 		// convert number conversion issue into IO issue for consistancy
24
         // convert number conversion issue into IO issue for consistancy
39
	 		throw new IOException(
25
         throw new IOException(
40
	 			"Text does not represent data of type "+
26
"Text does not represent data of type "
41
getClassName()+
27
               + getClassName()
42
	 			".  Text was:\n"+fileText);
28
 + ".  Text was:\n" + fileText);
43
	 	}
44
	 	
45
	 	
29
      }
46
// return the text from the file since it does
30
      // return the text from the file since it does
47
	 	// represent a valid data value
31
      // represent a valid data value
48
	 	return fileText;
32
      return fileText;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.3
Clones locationClones are in different classes having the same super class
Number of node comparisons62
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.1
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    InputStreamReader inReader = new InputStreamReader(inStream);
    1
    InputStreamReader inReader = new InputStreamReader(inStream);
    2
    int fileSize = inStream.available();
    2
    int fileSize = inStream.available();
    3
    char charBuf [] = new char[fileSize];
    3
    char charBuf [] = new char[fileSize];
    4
    int count = inReader.read(charBuf, 0, fileSize);
    4
    int count = inReader.read(charBuf, 0, fileSize);
    5
    if (count != fileSize)
    5
    if (count != fileSize)
    6
    throw new IOException("Could read only " + count + " chars from a total file size of " + fileSize + ". Import failed.");
    6
    throw new IOException("Could read only " + count + " chars from a total file size of " + fileSize + ". Import failed.");
    7
    String fileText;
    7
    String fileText;
    8
    if (charBuf[count - 1] == KeyEvent.VK_ENTER)
    8
    if (charBuf[count - 1] == KeyEvent.VK_ENTER)
    9
    fileText = new String(charBuf, 0, count - 1);
    9
    fileText = new String(charBuf, 0, count - 1);
    else
    else
    10
    fileText = new String(charBuf);
    10
    fileText = new String(charBuf);
    11
    StringBuffer messageBuffer = new StringBuffer();
    11
    StringBuffer messageBuffer = new StringBuffer();
    12
    validateAndConvertInPopup(fileText, null, messageBuffer);
    12
    validateAndConvertInPopup(fileText, null, messageBuffer);
    13
    if (messageBuffer.length() > 0)
    13
    if (messageBuffer.length() > 0)
    14
    throw new IOException("Text does not represent data of type " + getClassName() + ".  Text was:\n" + fileText);
    14
    throw new IOException("Text does not represent data of type " + getClassName() + ".  Text was:\n" + fileText);
    15
    return fileText;
    15
    return fileText;
    Precondition Violations (0)
    Row Violation