* SCJA and SCJP
Posted on November 6th, 2008 by admin. Filed under Java.
I’m planning to pass SCJA and SCJP at the end of this year. I will post all the mocks and materials which I find helpful. Here is the first list:
SCJA
Tutorials/Books
- Certified-Associate-Study-Guide
- http://www.amazon.com/gp/product/1598729039/ref=cm_cr_asin_lnk
- j2ee 1.4 tutorial
Mocks:
- http://www.scja.de/
- http://www.ejavaguru.com/scjafreemockexam.php
- http://www.cafe4java.com/mockexams/scja/mock1/q1.php
- http://studyguides.scja.com/ExamScam/get.jsp?link=mockexams
- sun sample questions
UML
SCJP
Tutorials/Books
* Peppy fast css3 selector engine
Posted on October 28th, 2008 by admin. Filed under Javascript.
Peppy is a small and very fast css3 selector written by James Donaghue. How to use it:
var selector = "div"; var context = "#elementId"; var q = peppy.query(selector, context);
* Define your own Annotation Type
Posted on October 24th, 2008 by admin. Filed under Java.
I’ve been using build-in Java annotation types (like @Overrides or @Deprecated) and those created by different vendors/services for a while now but I’ve never built my own. Here is an example of how you can define very simple annotation type and use it:
import java.lang.annotation.Retention; public @interface SimpleMessageAnnotation { public String message(); }
As you can see a declaration of the new annotation type is very similar to the Java interface declaration (add ‘@’ symbol in front of the interface) There are some additional rules you have to follow:
- Method declarations should not have any parameters
- Method declarations should not have any throws clauses
- Return types of the method should be one of the following:
primitives, String, Class, enum, array of the above types
In order to annotate a class with the new type you can write:
@SimpleMessageAnnotation(message = "hello world!!!") public class TestAnnotation { }
Now in order to access the message value during the runtime we can use reflection API. Before we can do that we need to change the RetentionPolicy of our new annotation type to RUNTIME. We can do it by adding Retention annotation to our SimpleMessageAnnotation:
import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.RUNTIME; @Retention(RUNTIME) public @interface SimpleMessageAnnotation { public String message(); }
This will inform the compiler about the new policy. There are 3 policies which can be used by the compiler (default is CLASS):
- SOURCE—Annotations are to be discarded by the compiler.
- CLASS—Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at runtime. This is the default behavior.
- RUNTIME—Annotations are to be recorded in the class file by the compiler and retained by the VM at runtime, so they may be read reflectively.
Now by using reflection API we can access our message value like this:
public class Run { public static void main(String[] args) { Class<TestAnnotation> clazz = TestAnnotation.class; System.out.println(clazz.getAnnotation(SimpleMessageAnnotation.class).message()); } }
What can be annotated?
- package
- class ( including interface, enum)
- method
- field
- local variable, formal parameter (compile time only)
* Properties pattern
Posted on October 23rd, 2008 by admin. Filed under Uncategorized.
* how to remove .svn from all folders - command line
Posted on October 15th, 2008 by admin. Filed under PHP, Uncategorized.
* JavaScript closures
Posted on September 16th, 2008 by admin. Filed under Javascript.
* google protobuf
Posted on September 2nd, 2008 by admin. Filed under google.
* google chrome
Posted on September 2nd, 2008 by admin. Filed under google.
* guice
Posted on May 5th, 2008 by admin. Filed under google.
* flex 3 component explorer
Posted on March 27th, 2008 by admin. Filed under Uncategorized.
Archives
- November 2008
- October 2008
- September 2008
- May 2008
- March 2008
- February 2008
- December 2007
- July 2007
- June 2007
- May 2007
- February 2007
- January 2007
- October 2006
- August 2006
- July 2006
- May 2006
- April 2006
- March 2006