BEANS / NOTES</>↗Beans24 Jun 2008
package org.kodejava.bean; import java.io.Serializable; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.beans.IntrospectionException; public class Fruit implements Serializable { private Long id; private String name; private String latinName; private double price; public Fruit() { } public static void main(String[] args) { try { BeanInfo bi = Introspector.getBeanInfo(Fruit.class); PropertyDescriptor[] pds = bi.getP...
BEANS / NOTES</>↗Beans20 Jun 2008
package org.kodejava.bean; import java.io.Serializable; import java.io.IOException; import java.beans.Beans; public class TheBean implements Serializable { private Long id; private String name; public TheBean() { } public static void main(String[] args) { try { TheBean bean = (TheBean) Beans.instantiate( ClassLoader.getSystemClassLoader(), "org.kodejava.bean.TheBean"); bean.setId(1L); bean.setName("John"); System.out.println("The Bean = " + bean); } catch (IOException | Class...
BEANS / NOTES</>↗Beans16 Jun 2008
The constrained property change is fired when a bean’s value is about to change. When a VetoableChangeListener veto the value change the bean’s value will be rolled-back to the previous value. In this example we have a constrained property called interest. package org.kodejava.bean; import java.beans.VetoableChangeSupport; import java.beans.PropertyVetoException; public class VetoBean { private double interest; private […]
BEANS / NOTES</>↗Beans12 Jun 2008
In this example we’ll listen to bean’s property change event. We create a small bean named MyBean, adds attributes and getter/setter. We want to know or to get notified when the bean property name is changed. First we need the add a PropertyChangeSupport field to the bean, with this object we will fire the property […]
CORE API / NOTES</>↗Core API09 Jun 2008
In this example we demonstrate how to use the java.text.Collator class to sort strings in language-specific order. Using the java.text.Collator class makes the string not just sorted by the ASCII code of their characters, but it will follow the language natural order of the characters. package org.kodejava.text; import java.util.List; import java.util.ArrayList; import java.util.Locale; import java.text.Collator; […]
CORE API / NOTES</>↗Core API06 Jun 2008
package org.kodejava.util; import java.util.*; public class ResourceBundleToProperties { public static void main(String[] args) { // Load resource bundle Messages_en_GB.properties from the classpath. ResourceBundle resource = ResourceBundle.getBundle("Messages", Locale.UK); // Call the convertResourceBundleToProperties method to convert the resource // bundle into a Properties object. Properties properties = convertResourceBundleToProperties(resource); // Print the entire con...