CORE API / CATATAN</>↗Core API06 Jul 2009
To obtains all annotations for classes, methods, constructors, or fields we use the getAnnotations()method. This method returns an array of Annotation In the following example we tried to read all annotations from the sayHi() method. First we need to obtain the method object itself. Because the sayHi() method has parameters, we need to pass not […]
CORE API / CATATAN</>↗Core API05 Jul 2009
This example demonstrate how to obtain annotations of a class and methods. We use the reflection API to get class and method information from where we can read information about annotation attached to the class or the method. package org.kodejava.lang.annotation; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @HelloAnnotation(value = "Hello", greetTo = "Universe") public class GettingAnnotation { public […]
CORE API / CATATAN</>↗Core API30 Jun 2009
This example show you how to use the HelloAnnotation annotation on the previous example code, How do I create a simple annotation?. We add the HelloAnnotation annotation to our class and its methods. package org.kodejava.lang.annotation; @HelloAnnotation(value = "Good Morning", greetTo = "Universe") public class HelloAnnotationExample { public static void main(String[] args) { HelloAnnotationExample hello = […]
CORE API / CATATAN</>↗Core API27 Jun 2009
Metadata is a way to add some supplement information to the source code. This information is called annotation will not change how the program runs. This metadata can be used by other tools such as source code generator for instance to generate additional code at the runtime. Or it will be used by a dependency […]
APACHE COMMONS / CATATAN</>↗Apache Commons23 Jun 2009
This example demonstrate how to use PropertyUtils.setMappedProperty() method to modify a Map typed property value of a bean. To set the property we need to pass bean instance, property name, map key and map value to PropertyUtils.setMappedProperty() method. package org.kodejava.commons.beanutils; import org.apache.commons.beanutils.PropertyUtils; import org.kodejava.commons.beanutils.support.Track; import org.kodejava.commons.beanutils.support.Record; import java.util.HashMap...
APACHE COMMONS / CATATAN</>↗Apache Commons20 Jun 2009
In this example we show how to set the value of an indexed property. In the code below we modified the value of an array type. We’ll change the second colors of MyBean‘s colors property. We do it in the same way as we are using the PropertyUtils.setSimpleProperty method. For indexed property we use the […]