I'm working on a design for a RowSet based DTO and I was wanting to group constants up in a named inner class that the main class could expose. Something like the code below. This works fine within the package, but when I try to reference any of the constants outside the package, I get a compile time error "Field is not visible". Is it possible to do this (without making all the constant classes full blown public classes)?
A reference like below works within the UserRowSet package, but not outside it:
UserRowset.RESULT_COLUMNS.USERID;
public class UserRowSet extends CachedRowSet{
public static final RESULT_COLUMNS = new UserRowSet().new QueryColumns();
// class impl
class ResultColumns{
public static final String USERID = "USERID";
public static final String FIRSTNAME = "FIRSTNAME";
}
}
-
Visibility of named inner classes (7 messages)
- Posted by: John Pletka
- Posted on: December 17 2002 10:13 EST
Threaded Messages (7)
- Visibility of named inner classes by Dmitriy Kopylenko on December 17 2002 10:31 EST
- Visibility of named inner classes by Dmitriy Kopylenko on December 17 2002 10:33 EST
-
Visibility of named inner classes by John Pletka on December 17 2002 01:14 EST
-
Visibility of named inner classes by Dmitriy Kopylenko on December 17 2002 01:42 EST
-
Visibility of named inner classes by Sri K on December 17 2002 11:39 EST
-
Visibility of named inner classes by Dmitriy Kopylenko on December 18 2002 07:42 EST
- Visibility of named inner classes by Sri K on December 20 2002 05:46 EST
-
Visibility of named inner classes by Dmitriy Kopylenko on December 18 2002 07:42 EST
-
Visibility of named inner classes by Sri K on December 17 2002 11:39 EST
-
Visibility of named inner classes by Dmitriy Kopylenko on December 17 2002 01:42 EST
-
Visibility of named inner classes by John Pletka on December 17 2002 01:14 EST
- Visibility of named inner classes by Dmitriy Kopylenko on December 17 2002 10:33 EST
-
Visibility of named inner classes[ Go to top ]
- Posted by: Dmitriy Kopylenko
- Posted on: December 17 2002 10:31 EST
- in response to John Pletka
Make the innner class public i.e.
public class ResultColumns {...}
Dmitriy. -
Visibility of named inner classes[ Go to top ]
- Posted by: Dmitriy Kopylenko
- Posted on: December 17 2002 10:33 EST
- in response to Dmitriy Kopylenko
I mean it still should be inner class. -
Visibility of named inner classes[ Go to top ]
- Posted by: John Pletka
- Posted on: December 17 2002 13:14 EST
- in response to Dmitriy Kopylenko
That works. For some reason, I thought you could not declare public inner classes. Thanks. -
Visibility of named inner classes[ Go to top ]
- Posted by: Dmitriy Kopylenko
- Posted on: December 17 2002 13:42 EST
- in response to John Pletka
You are welcome.
Dmitriy. -
Visibility of named inner classes[ Go to top ]
- Posted by: Sri K
- Posted on: December 17 2002 23:39 EST
- in response to Dmitriy Kopylenko
Dmitriy,John
Is there any vantage , when we put all the constants into a public inner class ? instead of using an interface or a static class??? -
Visibility of named inner classes[ Go to top ]
- Posted by: Dmitriy Kopylenko
- Posted on: December 18 2002 07:42 EST
- in response to Sri K
I would personally use standalone pubplic class.
D. -
Visibility of named inner classes[ Go to top ]
- Posted by: Sri K
- Posted on: December 20 2002 05:46 EST
- in response to Dmitriy Kopylenko
any specific reason ? instead of an interface ?
Sri