File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeClob.java | File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeTimestamp.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 | " chars from a total file size of " + fileSize +↵ | 8 | " chars from a total file size of " + fileSize +↵ | |
9 | ". Import failed.");↵ | 9 | ". Import failed.");↵ | |
10 | // convert file text into a string↵ | 10 | // convert file text into a string↵ | |
11 | // Special case: some systems tack a newline at the end of↵ | 11 | // Special case: some systems tack a newline at the end of↵ | |
12 | // 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↵ | |
13 | // we want everything else in the line.↵ | 13 | // we want everything else in the line.↵ | |
14 | String fileText;↵ | 14 | String fileText;↵ | |
15 | if (charBuf[count-1] == KeyEvent.VK_ENTER)↵ | 15 | if (charBuf[count-1] == KeyEvent.VK_ENTER)↵ | |
16 | fileText = new String(charBuf, 0, count-1);↵ | 16 | fileText = new String(charBuf, 0, count-1);↵ | |
17 | else fileText = new String(charBuf);↵ | 17 | else fileText = new String(charBuf);↵ | |
18 | // test that the string is valid by converting it into an↵ | 18 | // test that the string is valid by converting it into an↵ | |
19 | // object of this data type↵ | 19 | // object of this data type↵ | |
20 | StringBuffer messageBuffer = new StringBuffer();↵ | 20 | StringBuffer messageBuffer = new StringBuffer();↵ | |
21 | validateAndConvertInPopup(fileText, null, messageBuffer);↵ | 21 | validateAndConvertInPopup(fileText, null, messageBuffer);↵ | |
22 | if (messageBuffer.length() > 0) {↵ | 22 | if (messageBuffer.length() > 0) {↵ | |
23 | // convert number conversion issue into IO issue for consistancy↵ | 23 | // convert number conversion issue into IO issue for consistancy↵ | |
24 | throw new IOException(↵ | 24 | throw new IOException(↵ | |
25 | "Text does not represent data of type "+getClassName()+↵ | 25 | "Text does not represent data of type "+getClassName()+↵ | |
26 | ". Text was:\n"+fileText);↵ | 26 | ". Text was:\n"+fileText);↵ | |
27 | }↵ | |||
28 | ↵ | 27 | }↵ | |
29 | // return the text from the file since it does↵ | 28 | // return the text from the file since it does↵ | |
30 | // represent a valid data value↵ | 29 | // represent a valid data value↵ | |
31 | return fileText; | 30 | return fileText; | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.9 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 62 |
Number of mapped statements | 15 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 4.4 |
Clone type | Type 1 |
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; |
Row | Violation |
---|