Nested classes and separate files in Javadoc...
Hello. I am writing an application, and it has several .java files, and some of the classes contained therein contain nested classes, for example
ClassOne.java
class ClassOne
// stuff
class innerClassOne
//more stuff
}ClassTwo.java
class ClassTwo
// stuff
class innerClassTwo
//more stuff
}What I want to do is generate documentation like the online java documentation for my app, that is, documentation that will contain ALL the classes and nested classes involved, and link everything that comes in java already to the sun online java docs.
I've figured out the -link command for javadoc, and I can make that work, but I've run into some other snags.
1.) Javadoc isn't finding or documenting my nested classes, despite them being marked up. Google does not wish to help.
2.) Some classes reference other classes of mine that aren't conatined in the same .java file, but do exist in their own .java files in the dame local directory. Javadoc does not like this, and gives errors.
3.) Running javadoc on one file at a time overwrites the old file's documentation, thus I cannot seem to get an index.html javadoc file that links to all my classes, nor can I get the classes to link to each other.
What do I need to do to fix these?
So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
int i;
static class Bar {
int j = i; // WRONG! Bar class is static context
}~
Similar Messages
-
Creating Private Inner Classes in Separate Files
I sometimes find myself wanting to use private inner classes to do things, but then moving the classes to separate files and giving them package access just because I don't like having single large files.
Is there a way to create private inner classes on a class but just save them in another file?
Thanks,
JohnFor me, short file sizes usually make design structure
more clear. This can make maintenance easier. It can
also make browsing the code easier, even if you have a
good editor or IDE. It is also less intimadating
psychologically (for me, anyway) to work with a number
of small files, each one with a distinct purpose, than
it is to open up a monster, even if the monster does
represent a coherent design unit in some sense. I
think this psychological impact may be more important
than most people give it credit for.The psychological impact is lessened if you use an IDE like VisualAge (where only one method at a time is generally displayed) or use the "Show Source Of Selected Element Only" option in Eclipse.
It's one thing to say a method should be short and a class should have as few methods as possible. Those forces reduce complexity and ease maintenance. It's another to say a source file should be short. A source file is just a storage artifact; source code could be stored in a database without changing how the programmer interacts with it. The fact that the standard java compiler requires the implementation of nested classes to be stored inside the source file of their containing class is a minor inconvenience. Don't let it discourage you from using inner classes when they make sense. The design should not be driven by source file size considerations.
>
But you have added code only with the sole intent of
making a source file smaller. If Java had amechanism
for storing nested classes in other files youwouldn't
do this. My point below was that you shouldn't let
source file size override the decision to use anested
class.Why shouldn't I let it? There are plenty of
non-trivial benefits (the ones I gave above, for
starters) to working with smaller files.Because all of those benefits can be gained from using a decent IDE. Eclipse is free. It can show only the current method and it can collapse nested classes.
You say "If
Java had a mechanism...." Well, I could answer: It
does have such a mechanism, and that mechanism is
packages.Packages are not a mechanism for creating private inner classes in separate files. Eclipse has a mechanism for making the fact that they reside in the same source file a non-issue.
>>
I am not being cavalier. I have no argument, onlyan
opinion.Again, you are perfectly entitled to your opinion.
But if it is truly an opinion, and nothing more, why
bother telling me about it. You might as well post
your favorite color. It is the reasons for your
opinion that interest me, and you still have not
really given any.I have had lengthy arguments about the issue of method and class size. Like I said before, I prefer very small classes and methods. I also think the number of nested classes should be as small as possible. But I have no problem with large files. Files are just one way to organize source code. The size of the things in the files matters, not the files themselves. -
Compiling Nested Classes and Interfaces
I am looking for documentation about compiling nested classes and interfaces. I have found something in the JVM Specification, but there does not explain how a nested class is compiled and what is included in the top level class to mark a "place holder" to the nested class. The JVM Specification in this topic cite the web page http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html that does not exists any more.
My root problem is that: I am compiling a class with a private nested class, but in the class file generated TopLevelClass$NestedClass.class the class does not have the private modifier. So I am not understanding why the "private" modifier was removed during compilation.
I performed the same test with a protected nested class and the result was the nested class with the public modifier. So I am not understanding why the "protected" modifier was changed to "public".
Thanks in advance,
Mardoqueu.This should not be happening. What compiler are you using? If it's a reasonably recent Sun compiler, could you post a minimal example?
-
Nested Classes and Static Methods
I was perusing the Java Tutorials on Nested Classes and I came across this...
[http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html|http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]
I was reading the documentation and I read a slightly confusing statement. I was hoping some further discussion could clarify the matter. The documentation on "Nested Classes" says (I highlighted the two statements, in bold, I am having trouble piecing together.)
Static Nested Classes
As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class ? it can use them only through an object reference.
Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
int i;
static class Bar {
int j = i; // WRONG! Bar class is static context
}~ -
Revision: 16580
Revision: 16580
Author: [email protected]
Date: 2010-06-16 17:08:07 -0700 (Wed, 16 Jun 2010)
Log Message:
Converted classes and project files to work in flex 3.5
Modified Paths:
osmf/branches/zeri-certification/Test_Apps/FlexUnit4/.actionScriptProperties
osmf/branches/zeri-certification/Test_Apps/MediaTests/.actionScriptProperties
osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/history/history.js
osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/index.template.html
osmf/branches/zeri-certification/Test_Apps/MediaTests/src/InstructionsForm.mxml
osmf/branches/zeri-certification/Test_Apps/MediaTests/src/MediaTests.mxml
osmf/branches/zeri-certification/Test_Apps/MediaTests/src/ZeriTests.mxml
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/.actionScriptProperties
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/history/histo ry.js
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/index.templat e.html
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/src/Zeri_Custom_Player.mxml
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/src/comps/LogBuffer.mxml
Added Paths:
osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/AC_OETags.js
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/AC_OETags.js
Removed Paths:
osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/swfobject.js
osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/swfobject.jsHi for anyone getting similar issues,
the solution is described in http://forums.adobe.com/message/3302944#3302944
This is not a bug.
Arnoud -
Where to put common classes and jar files
hi,
i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being accessed easily ,but i am having problems with sun one .
Regards
Ameem SamiDid you find a solution for this? I'm having the same problem.
Thanks,
Tony -
Hello,
There is a way to distribute the Mysql db files with yout java application without need to install Mysql in the computer, like in access, you just copy the .mdb file with your java class and create a conection to it.
Thank YouNo. If you want to do that you should just use Access. mySQL files will not work without the mySQL server.
-
Weblogic startup class and EAR file
Hi,
I am using WL 8.1.5.
I have a weblogic starup class MyStartup that implements T3StartupDef. (it does not specify package).
I jar-ed it. And I placed MyStartup.jar file into the MyEA.ear file. And I placed that into applications dir.
With WL Console I defined the startup class and for the ClassName specified MyStartup.
Yet I get the java.lang.ClassNotFoundException.
I also have a Manifest.mf file with
Class-Path: MyStartup.jar
Please help me solve this problem, I literally don't know what to do next.
MBHi,
thanks.
This seems like a completely opposite method of the depplying startup class with weblogic console.
Does my class still need to implement T3StartupDef?
I get this exception. And my classnotfound is still there.
Exception:weblogic.management.ApplicationException: startup.MyStartup
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2484)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2396)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:883)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:591)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:500)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Regards,
MB -
Nested classes and GUI integration
I have a GUI class called ArenaHelperGUI and an ArenaHelperRunner that's supposed to store the data taken from the text fields in the GUI and later do some calculations on it. The GUI is nested within the runner, but it can't do anything to the runner's variables, or call its functions.
Here's the runner:
package arenahelper;
* @author Greg
public class ArenaHelperRunner {
ArenaHelperGUI gui;
String args[];
String[] oneTwo;
String[] fourFive;
String[] sixSeven;
String[] nineTen;
String[] elevenTwelve;
String[] fourteenFifteen;
String[] sixteenSeventeen;
String[] nineteenTwenty;
ArenaHelperRunner()
gui = new ArenaHelperGUI();
gui.main(args);
oneTwo = new String[4];
fourFive = new String[4];
sixSeven = new String[4];
nineTen = new String[4];
elevenTwelve = new String[4];
fourteenFifteen = new String[4];
sixteenSeventeen = new String[4];
nineteenTwenty = new String[4];
public void test()
System.out.println("TEST");
} The GUI was generated by Netbeans, and it's supposed to interact with the variables in the runner when one of the buttons is pressed:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test();
System.out.println(oneTwo[0]);
} The call to test and println both give "cannot find symbol".
If anyone knows how to fix this or can suggest a better way to implement it, I'll be very grateful =)farshmak wrote:
I have a GUI class called ArenaHelperGUI and an ArenaHelperRunner that's supposed to store the data taken from the text fields in the GUI and later do some calculations on it. The GUI is nested within the runner, but it can't do anything to the runner's variables, or call its functions.
ArenaHelperRunner()
gui = new ArenaHelperGUI();
gui.main(args);
oneTwo = new String[4];
fourFive = new String[4];
sixSeven = new String[4];
nineTen = new String[4];
elevenTwelve = new String[4];
fourteenFifteen = new String[4];
sixteenSeventeen = new String[4];
nineteenTwenty = new String[4];
}Spot the magic number. I suggest setting a variable size = 4 and initializing each array to size. It will make your code more elegant and easier to maintain.
The call to test and println both give "cannot find symbol".Its good to separate the GUI and logic however you can't call a non static method from Class A within Class B without instantiating an instance of Class A first.
e.g. within Class B
ArenaHelperRunner runner = new ArenaHelperRunner();
runner.test();Mel -
Hi everyone,
I build a class in java, and now i wanna use this class in my jsp file.
I put that class into web-inf/classes in Apache Tomcat, but don't work.... Anyone can help me?
Greetings!Put the class with its package such as com.sun.ejb.MyClass
-- > /WEB-INF/classes/com/sun/ejb/MyClass.class
then use it
http://www.skillipedia.com -
Where do i place my html files,classes and Java files
Can any one plz help me out here. I'm using Tomcat3.2.1 to
run my servlets, I have written the servlets and gotten
tomcat to run as well. What confuses me now is where my
files should be placed.
- Do i have to create a special directory to contain my html
files ?
- another directory for my servlet classes ?
- how about my .java files ?
- and how should i call my servlet from the html code ?
HEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLPPPPPPPPPPPP!!!!!!!!!!!!!!!hi,
you can my post here http://forum.java.sun.com/thread.jsp?forum=33&thread=302433 -
Extending a nested class and parent access
I want the child of the abstract inner class to have access to the inner classes parent's variables. I know that an inner class can access it's parent's variables and methods with the "[ParentClass].this.[var/method]" syntax. What's the appropriate syntax for the situation I'm describing?
My setup is like this:
class Canister {
int a = 0;
public abstract class Behavior
class Lonely Behavior extends Behavior
public int getParentVariable() {
return Canister.this.a;
}Thanks!
-stephenThe correction to my code is:
class Canister
int a = 0;
public abstract class Behavior
class LonelyBehavior extends Canister.Behavior
public int getParentVariable() {
return Canister.this.a;
}The compiler doesn't have a problem with me extending Canister.Behavior because it's public inside of Canister. But as I explained, the "[ParentClass].this.[var/method]" syntax doesn't work.
This is inconsistent with inheritance: you'd think that if you extend an inner class, you would inherit the abilities and characteristics of that inner class, just as you would in other cases of inheritance. It's also inconvenient: if the inner class is abstract because you want programmers to extend and upgrade it, those programmers have to change the source code of the enclosing class to include the new classes.
Anyway, thanks for the info. -
URGENT controller class and XML file
Hi there,
I understand that oapagecontext.getParameter("FieldID") returns the field of XML. So for example in my xml i had this:
<oa:messageTextInput id="AActiveTo" dataType="DATE" viewName="RoleAdminVO" prompt="Active To" viewAttr="ActiveTo" readOnly="${oa.RoleAdminVO.SecuredFlag}" columns="15"/>
And on the front end I typed in "25-Aug-2006". My oapagecontext.getParameter("AActiveTo") should return "25-Aug-2005".
However is this only true if I put oapagecontext.getParameter within my processFormRequest of the controller class which the XML is pointing to?
CheersOr you can apply a XSLT transform as per http://blogs.msdn.com/b/mattm/archive/2007/12/15/xml-source-making-things-easier-with-xslt.aspx
Arthur My Blog -
Scene Detect and Separate Files on OSX
I am trying to find a way to save my scene detected clips as individual files instead of subclips. I'm obviously using OSX. Is there a way to accomplish this in the capture settings or once the master clip has been made? If neither of these are possible is their an easy way to import or pull a subclip into After Effects?
I ask because I am used to the PC way and have gotten used to it and found it very simple to remove junk clips.
Adobe, why is this different on each platform?
Thanks for the help!I wonder if this isn't another QuickTime "feature". Avid (which is more-or-less a QuickTime app, even on Windows) and I believe FCP act the same way when it comes to capturing DV media from tape. Scene detection is performed, but in the case of either, a captured clip is not broken up into individual files. Instead, subclips are created and/or markers are placed in the captured clip to delineate scene changes.
I've never seen such behavior with an app that is more AVI-centric, like PPro (on Windows, anyway) and Edius.
Not the answer you're necessarily looking for, I realize... -
Propblem with Properties class and .ini file !
Hello I have to read and write in a .ini file. I've got no problem, using a bit of code like this
Properties iniFile = new Properties();
String result="exception";
try{
iniFile.load(new FileInputStream(path));
result = iniFile.getProperty("SrcPath","not found");
catch(IOException e){}
finally{return result;}
it works correctly, but my problem is that my .ini file contain path like "SrcPath = e:\directory1\directory2"
And then in my result variable I get : "e:directory1directory2" all the slash are cutted by iniFile.load !!
And the problem is that I can not put "\\" in my ini file because it is used by other programs that need just one slash !!!!
Is anybody got an idea to get the right path "e:\directory1\directory2"
Thanks by advance Eric1st question.
Properties props = new Properties();
try{
String uploadprop = "c:/yourinifile.ini";
File file = new File(uploadprop);
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int character;
while((character=fis.read()) != -1){
baos.write(character);
if((char)character == '\\')
//write one more '\'
baos.write(character);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
baos.close();
//load bais
props.load(bais);
bais.close();
fis.close();
System.out.println(props.getProperty("dirname"));
}catch(Exception e){
hope this helps
rishi
Maybe you are looking for
-
Help! I would like to update to the highest version I can with my older system - Mac OS 10.4.11. Can you help me?
-
Hi All, I want to select the data of a standard table directly into an internal table but I am not able to get that. Note : I am working 4.6C version of SAP Please see the below code : REPORT zdwnld_tabl_data . PARAMETERS : p_tabl1 TYPE dd02v-tabname
-
Photos (thumbnails) in iPod Classic got "corrupted"
I have no idea of how to describe with words, this is a shot of what's going on with my iPod. http://bdweb.no-ip.com/Images/iPodClassicPhotos.jpg It happens on some photos in my iPod, they can be viewed as normal pictures by clicking the centre butto
-
Cannot open iphoto library 5 with iphoto 8
My old mac (ibook G4) still has iphoto 5 and this new one has iphoto 8. I cannot open my old library with this new version, and I have most of my photos in the old library! How do I open my copy of iphoto 5 with iphoto 8?
-
I am looking for a download to add the Japanese language pack, all I seem to be able to find is the how to and not where I go to get this application. Can someone give me a site where I can get such an app.