APACHE COMMONS / CATATAN</>↗Apache Commons08 Nov 2007
Using the PropertyUtils.getPropertyType() we can determine the bean property type. This method return a Class object of bean’s property type. package org.kodejava.commons.beanutils; import org.apache.commons.beanutils.PropertyUtils; import org.kodejava.commons.beanutils.support.Record; public class PropertyType { public static void main(String[] args) { Record record = new Record(); record.setTitle("Magical Mystery Tour"); try { /* * Using PropertyUtils.getPropertyType() to d...
APACHE COMMONS / CATATAN</>↗Apache Commons03 Nov 2007
In this example you’ll see how to read mapped property value of a bean. We use PropertyUtils.getMappedProperty() method the read the mapped property of the Record object that consist of Track objects. 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; import java.util.Map; public class ReadMapProperty { pu...
APACHE COMMONS / CATATAN</>↗Apache Commons31 Okt 2007
In this example you’ll see how to read an indexed property of an object such as List or array. Using the PropertyUtils.getIndexedProperty() method we can do it easily. This method take the bean and the name of indexed property including the element to be read. Let’s see the example below for more details. package org.kodejava.commons.beanutils; […]
APACHE COMMONS / CATATAN</>↗Apache Commons27 Okt 2007
In this example you’ll see how to read bean’s nested property, we’ll use PropertyUtils.getNestedProperty() method. To test we will create three classes, Track and Artist for our beans and ReadNestedProperty as a main program to run. The Track class will contain a property of an Artist object. Using the PropertyUtils.getNestedProperty() method we want to get […]
APACHE COMMONS / CATATAN</>↗Apache Commons27 Okt 2007
In this example we will learn how to use PropertyUtils.getSimpleProperty() method to read bean’s property value. To test this method we will create a simple class called Track for our bean. The Track class have some properties such as id, title and duration. The PropertyUtils.getSimpleProperty() reads our bean property by accessing the bean’s getter method. […]
APACHE COMMONS / CATATAN</>↗Apache Commons24 Okt 2007
In this example we’ll use the StringUtils.substringBetween() method. Here we’ll extract the title and body of our HTML document. Let’s see the code. package org.kodejava.commons.lang; import java.util.Date; import org.apache.commons.lang3.StringUtils; public class NestedString { public static void main(String[] args) { String helloHtml = "<html>" + "<head>" + " <title>Hello World from Java</title>" + "<body>" + "Hello, […]