[
https://issues.apache.org/jira/browse/DERBY-6169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-6169:
--------------------------------------
Attachment: derby-6169-03-a.diff
Attaching derby-6169-03-a.diff which improves the encapsulation of the
targetColumns and updateColumns fields in the CursorInfo and
GenericPreparedStatement classes.
The targetColumns field was never actually used for anything, so the
patch removes it and a lot of code that was used for building up the
data structure.
The updateColumns field was only used to check whether there were any
update columns and to check if a specific column could be updated. To
prevent exposing the internal, mutable array through the public
getUpdateColumns() method, the patch replaces that method with two
more specific methods that hide the internal data structure:
hasUpdateColumns() and isUpdateColumn(String)
The patch also changes the type of CursorInfo.updateColumns from
String[] to List, which has the following advantages:
- CursorNode already has this field as a List, so we can remove some
code for converting it to String[]
- Code that manually searches the array can be replaced with a call to
List.contains()
- Debug code in CursorInfo.toString() can be simplified by using
List.toString() instead of manually converting the array to a
readable string
Other changes:
- ArrayUtil.readStringArray(), which the patch started using in
CursorInfo.readExternal(), was changed so that it didn't have to
create an intermediate Object array
- QueryTreeNode.getCursorInfo() was moved to StatementNode, since it's
only ever called on nodes whose type is a child of Statement node
(at least after DERBY-2096, and I believe that it was just an
oversight that this method was left in QueryTreeNode)
The patch removes more code than it adds. According to diffstat:
11 files changed, 66 insertions(+), 263 deletions(-)
All regression tests ran cleanly with the patch.
> Reduce visibility of classes and methods under impl/sql
> -------------------------------------------------------
>
> Key: DERBY-6169
> URL: https://issues.apache.org/jira/browse/DERBY-6169
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 10.11.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Priority: Minor
> Attachments: derby-6169-01-a.diff, derby-6169-02-a.diff,
> derby-6169-03-a.diff
>
>
> My IDE shows many warnings in the classes under impl/sql because they are
> public and may make parts of the internal state more visible than necessary.
> I'd like to reduce the visibility of classes and methods, if possible, to
> make it clearer to IDEs and tools that perform static analysis that the code
> is only accessed from the same package, and reduce some of the noise from the
> tools.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira