Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

[CheckStyle] forbidding a particular method

Thread view: 
oliviergir@gmail.com - 30 Mar 2006 16:08 GMT
Hello,
How can I implement a rule with checkstyle that would warn when the
code would call the method "receive()" on an instance of the class
"MessageConsumer" ?

I know that checkstyle might not be the appropriate tool for that, but
could I chek that the method "receive" is not called with a long
parameter superior with 5000 ?

thanks
Carl - 30 Mar 2006 20:42 GMT
> Hello,
> How can I implement a rule with checkstyle that would warn when the
[quoted text clipped - 6 lines]
>
> thanks

Hello,

I Have no experience with checkstyle, but based on my understanding of
your question I think that java assertions may fit your requirements.

See
http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html
for more details.

Alternatively, you could just have your method throw an
IllegalArgumentException if the argument was out of range.

Hope this helps,
Carl.
Oliver Wong - 30 Mar 2006 20:50 GMT
>> Hello,
>> How can I implement a rule with checkstyle that would warn when the
[quoted text clipped - 18 lines]
> Alternatively, you could just have your method throw an
> IllegalArgumentException if the argument was out of range.

   Presumably the OP wishes to check for these violations at compile time
(because they've got an ant script to automatically run checkstyle right
after compilation, for example), rather than runtime. I'm not familiar with
checkstyle, so I don't know how to solve this using CheckStyle either, but
it can be solved using AspectJ.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.