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/DataTypeDate.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
		 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(
6
         throw new IOException(
7
				 "Could read only "+ count +
7
"Could read only " + count
8
				
9
 " chars from a total file size of " + fileSize +
8
               + " chars from a total file size of " + fileSize
10
				
11
 ". Import failed.");
9
               + ". Import failed.");
12
		 // convert file text into a string
10
      // convert file text into a string
13
		 // Special case: some systems tack a newline at the end of
11
      // Special case: some systems tack a newline at the end of
14
		 // 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
15
		 // we want everything else in the line.
13
      // we want everything else in the line.
16
		 String fileText;
14
      String fileText;
17
		 if (charBuf[count-1] == KeyEvent.VK_ENTER)
15
      if (charBuf[count - 1] == KeyEvent.VK_ENTER)
18
			 fileText = new String(charBuf, 0, count-1);
16
         fileText = new String(charBuf, 0, count - 1);
19
		 else
17
      else
20
 fileText = new String(charBuf);
18
         fileText = new String(charBuf);
21
		 // test that the string is valid by converting it into an
19
      // test that the string is valid by converting it into an
22
		 // object of this data type
20
      // object of this data type
23
		 StringBuffer messageBuffer = new StringBuffer();
21
      StringBuffer messageBuffer = new StringBuffer();
24
		 validateAndConvertInPopup(fileText, null, messageBuffer);
22
      validateAndConvertInPopup(fileText, null, messageBuffer);
25
		 if (messageBuffer.length() > 0) {
23
      if (messageBuffer.length() > 0) {
26
			 // convert number conversion issue into IO issue for consistancy
24
         // convert number conversion issue into IO issue for consistancy
27
			 throw new IOException(
25
         throw new IOException(
28
				 "Text does not represent data of type "+
26
"Text does not represent data of type "
29
getClassName()+
27
               + getClassName() +
30
				 ".  Text was:\n"+fileText);
28
 ".  Text was:\n" + fileText);
31
		 }
32
		
29
      }
33
 // return the text from the file since it does
30
      // return the text from the file since it does
34
		 // represent a valid data value
31
      // represent a valid data value
35
		 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.0
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.2
    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