private void checkOrderby ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } String orderbySpec = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ORDERBY ) ; if ( ( orderbySpec == null ) || ( orderbySpec . length ( ) == 0 ) ) { return ; } ClassDescriptorDef ownerClass = ( ClassDescriptorDef ) collDef . getOwner ( ) ; String elementClassName = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF ) . replace ( ' ' , ' ' ) ; ClassDescriptorDef elementClass = ( ( ModelDef ) ownerClass . getOwner ( ) ) . getClass ( elementClassName ) ; FieldDescriptorDef fieldDef ; String token ; String fieldName ; String ordering ; int pos ; for ( CommaListIterator it = new CommaListIterator ( orderbySpec ) ; it . hasNext ( ) ; ) { token = it . getNext ( ) ; pos = token . indexOf ( ' ' ) ; if ( pos == - 1 ) { fieldName = token ; ordering = null ; } else { fieldName = token . substring ( 0 , pos ) ; ordering = token . substring ( pos + 1 ) ; } fieldDef = elementClass . getField ( fieldName ) ; if ( fieldDef == null ) { throw new ConstraintException ( "The field " + fieldName + " specified in the orderby attribute of the collection " + collDef . getName ( ) + " in class " + ownerClass . getName ( ) + " hasn't been found in the element class " + elementClass . getName ( ) ) ; } if ( ( ordering != null ) && ( ordering . length ( ) > 0 ) && ! "ASC" . equals ( ordering ) && ! "DESC" . equals ( ordering ) ) { throw new ConstraintException ( "The ordering " + ordering + " specified in the orderby attribute of the collection " + collDef . getName ( ) + " in class " + ownerClass . getName ( ) + " is invalid" ) ; } } }
Checks the orderby attribute .