From 4101169603139867bf7003192f37dd4271c2189d Mon Sep 17 00:00:00 2001 From: Ole-Martin Mork Date: Tue, 26 Nov 2002 08:18:38 +0000 Subject: [PATCH] Forgot this one git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1266 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-netbeans/src/pmd/config/ConfigUtils.java | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pmd-netbeans/src/pmd/config/ConfigUtils.java diff --git a/pmd-netbeans/src/pmd/config/ConfigUtils.java b/pmd-netbeans/src/pmd/config/ConfigUtils.java new file mode 100644 index 0000000000..b8b174c652 --- /dev/null +++ b/pmd-netbeans/src/pmd/config/ConfigUtils.java @@ -0,0 +1,49 @@ +/* + * ConfigUtils.java + * + * Created on 25. november 2002, 23:35 + */ + +package pmd.config; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.sourceforge.pmd.Rule; +import pmd.config.ui.AvailableListModel; + +/** + * + * @author ole martin mørk + */ +public class ConfigUtils { + + + public static List createRuleList( String rules ) { + Iterator iterator = AvailableListModel.getInstance().getData().iterator(); + List list = new ArrayList(); + while( iterator.hasNext() ) { + Rule rule = ( Rule )iterator.next(); + if( rules.indexOf( rule.getName() + ", " ) > -1 ) { + list.add( rule ); + } + } + return list; + } + + /** Returns the list as text + * @param value The list to be presented as text + * @return A string containing all the values in the list + */ + public static String getValueAsText( List value ) { + StringBuffer buffer = new StringBuffer(); + if( value != null ) { + Iterator iterator = value.iterator(); + while( iterator.hasNext() ) { + Rule rule = ( Rule )iterator.next(); + buffer.append( rule.getName() ).append( ", " ); + } + } + return String.valueOf( buffer ); + } +}