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