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