You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by BMS TechSupport JP <te...@bluemartini.com> on 2004/08/23 11:11:34 UTC

[BeanUtils] Where is BeanComparator?

Hi,

BeanUtils javadoc said

http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api
/org/apache/commons/beanutils/package-summary.html#collections
Comparing Beans
org.apache.commons.beanutils.BeanComparator is a Comparator implementation
that compares beans based on a shared property value.

But I cannot find the Comparator implementation class in the package..??

regards,

Koji



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [BeanUtils] Where is BeanComparator?

Posted by José Antonio Pérez Testa <ja...@indra.es>.
That's all!

import java.util.Comparator;
....
public class BeanComparator implements Comparator, Serializable {
......

    /**
     * Compare two JavaBeans by their shared property.
     *
     * @param  o1 Object The first bean to get data from to compare against
     * @param  o2 Object The second bean to get data from to compare
     * @return int negative or positive based on order
     */
    public int compare( Object o1, Object o2 ) {
        try {
            Object value1 = PropertyUtils.getProperty( o1, property );
            Object value2 = PropertyUtils.getProperty( o2, property );
            return comparator.compare( value1, value2 );
        }
        catch ( Exception e ) {
            throw new ClassCastException( e.toString() );
        }
    }
....

BMS TechSupport JP wrote:

>Hi,
>
>BeanUtils javadoc said
>
>http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api
>/org/apache/commons/beanutils/package-summary.html#collections
>Comparing Beans
>org.apache.commons.beanutils.BeanComparator is a Comparator implementation
>that compares beans based on a shared property value.
>
>But I cannot find the Comparator implementation class in the package..??
>
>regards,
>
>Koji
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>
-------------------------------------------------------------------------------------------------------------------
Este correo electr�nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci�n de car�cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgaci�n, copia o distribuci�n a terceros sin la previa autorizaci�n escrita de Indra. En el caso de haber recibido este correo electr�nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv�o a la direcci�n electr�nica del remitente.

The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [BeanUtils] Where is BeanComparator?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi

the bean comparator class is in the beanutils-bean-collections jar  
(rather than the code).

- robert

On 23 Aug 2004, at 10:11, BMS TechSupport JP wrote:

> Hi,
>
> BeanUtils javadoc said
>
> http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/ 
> docs/api
> /org/apache/commons/beanutils/package-summary.html#collections
> Comparing Beans
> org.apache.commons.beanutils.BeanComparator is a Comparator  
> implementation
> that compares beans based on a shared property value.
>
> But I cannot find the Comparator implementation class in the  
> package..??
>
> regards,
>
> Koji
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org