| Thejesh GN | A Blog, A Website and A container for all my views with excerpts from technology, travel, films, india, photography, kannada, friends and other interests. I am Thejesh GN. Friends call me Thej..more. |
![]() |
You are reading ‘Technology’ ....I have seen developers writing toString method in each of their bean class. The purpose is to print the bean variables for logging or debugging purposes. I thought of reducing their effort by writing a generic toString method to have in their base bean class. It works for simple bean classes. Its no-brainer you can modify to work for others.
public String toString() {
String lineSeaparator = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer(lineSeaparator);
buffer.append("|---------");
buffer.append(this.getClass());
buffer.append("---------|");
buffer.append(lineSeaparator);
Method[] methods = this.getClass().getMethods();
if(methods != null && methods.length >0){
Method method = null;
for(int i =0; i< methods.length; i++){
method = methods[i];
if(method.getName().startsWith("get")
&& !method.getName().startsWith("getClass")){
buffer.append
(method.getName().replaceAll("get",""));
buffer.append(" = ");
Object[] params=null;
try {
buffer.append
(method.invoke(this, params));
} catch (Exception e) {
buffer.append(" ");
}
buffer.append(lineSeaparator);
}
}
}
buffer.append("|---------------------------------------------|");
buffer.append(lineSeaparator);
return buffer.toString();
}
Any suggestions to improve are welcome. Note: This was the most read blog post on TechMag. Unfortunately lost all the content there. I have reproduced the same post here for the readers benefit. Thanks. VLC is a player but also can be used to record a screen cast ( capture the screen as video).Here is the small how to do that. This works with portable VLC too. Start the VLC By going to the installation folder and running the command >> vlc screen:// It will open the VLC and shows the screen exactly. It actually is streaming the screen I just read this new article by Anand about the SMSGupsgup. Even though I don’t agree with the traffic/numbers used for comparison I was forced to re look at Gupshup. I had an account at SMS Gupshup almost an year back. My last msg there was 359 days back and I had 84 subscribers then. Year back it was simple one to many SMS application. It didn’t have other ways of interacting than sending an expensive SMS. At the same time twitter had all those things which I needed. So the obvious choice was twitter.
I still think it needs an API to get more people attracted. By looking at the way they have introduced features in last one year, they may have it very soon. Reusing the code/frameworks ( either the in public domain or FOSS licensed code) is pretty common. But searching for useful code online is not very easy.The regular search engines like Google or Yahoo are not designed for code searching. Now there are few specialized code search engines which can fetch better result. Here are the top five code search engines All the above engines allow you to search on Language (like Java, C etc) and license (like GPL, MIT etc). Except for oreilly code search, rest of them search the internet. Oreilly code search contains the code from their books.Which currently contains over 123,000 individual examples, composed of 2.6 million lines of code all edited and ready to use. CodeFetch allows you to search all source code examples included in all books on all languages. But be sure about license terms and conditions before reusing the code. On the fourth day of Developer Summit myself and Veetrag spent some time with Alessandro CTO of Lightstreamer. We talked about comet architecture and its application in various fields. Comment is sometimes referred as reverse AJAX and is a set of technologies used to push the live data from server to http clients. Lightstreamer is a scalable and reliable Server for pushing live data to Rich Internet Applications. Its based on AJAX-Comet paradigm and pushes the live data to http/flex clients. A free version of Lightstreamer is available for download and can be used evaluation. |