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