File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes type of argument lost? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "type of argument lost?" Watch "type of argument lost?" New topic
Author

type of argument lost?

Scott Hibbard
Greenhorn

Joined: Jul 20, 2010
Posts: 9
I've created an inner class (recentPatientMatch) with one method (match). An argument is passed to the method (Patient) but inside the method the patient object doesn't seem to have access to it's own methods. As the errors show(see the bottom of the post), it's being treated as java.lang.Object.

I can't figure out why. Why doesn't the compiler see it as a Patient, and not just an Object?







C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:93: cannot find symbol
symbol : method getSocDate()
location: class java.lang.Object
return Integer.valueOf(p.getSocDate()) >= 1 &&
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:94: cannot find symbol
symbol : method getDcDate()
location: class java.lang.Object
(p.getDcDate().equals("") ||
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java:95: cannot find symbol
symbol : method getDcDate()
location: class java.lang.Object
Integer.valueOf(p.getDcDate()) >= 20100824);
Note: C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\src\ubiquityutilities\NoteUpdater.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\nbproject\build-impl.xml:528: The following error occurred while executing this line:
C:\Documents and Settings\beaconuser\My Documents\NetBeansProjects\UbiquityUtilities\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 5 seconds)
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

OK, first, it's generally a good idea to reduce the code to the smallest example that still demonstrates the problem. Often someone who might be able to answer your question will be see the wall of code, and decide it's time to finish their TPS reports instead. Fortuanately, I got my reports done early today!

Your inner class should start with a capital letter, like all Java classes. The compiler doesn't care about that, but it makes thing more readable to future generations of Java coders who may have to maintain your code.

And finally, the actual problem is that way you've defined your templates. I assume Predicate is a generic class, which you are parameterizing with <Patient>, but then you also parameterize the inner class that extends it, which doesn't make sense. Now, I'm not saying the compiler error was especially clear on that point, but if you change your class declaration to:

private class RecentPatientMatch extends Predicate<Patient> { ... }

then everything should work for you.
Scott Hibbard
Greenhorn

Joined: Jul 20, 2010
Posts: 9
Greg,

Thank you very much for your reply.

I'll try to reduce the code I post in the future. Thanks for scaling the wall of code anyways.

Ah, good catch on capitalizing the Class. I got into method writing mode. :-)

Yes! That did it! My grasp of generics is still a little fuzzy but I'm gettin' there.

Thanks again for your help and good luck on those TPS reports.

-Scott
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: type of argument lost?