mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
sort items case insensitively (#1211)
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6864 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
38cc646c24
commit
ec4f9c86d5
4 files changed
+30
-21
No files matched your search
@@ -1,15 +1,14 @@
|
||||
package hudson;
|
||||
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.util.CaseInsensitiveComparator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Environment variables.
|
||||
@@ -27,11 +26,11 @@ import java.util.Collections;
|
||||
public class EnvVars extends TreeMap<String,String> {
|
||||
|
||||
public EnvVars() {
|
||||
super(CASE_INSENSITIVE_COMPARATOR);
|
||||
super(CaseInsensitiveComparator.INSTANCE);
|
||||
}
|
||||
|
||||
public EnvVars(Map<String,String> m) {
|
||||
super(CASE_INSENSITIVE_COMPARATOR);
|
||||
super(CaseInsensitiveComparator.INSTANCE);
|
||||
putAll(m);
|
||||
}
|
||||
|
||||
@@ -85,21 +84,8 @@ public class EnvVars extends TreeMap<String,String> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares strings case insensitively.
|
||||
*/
|
||||
private static final Comparator<String> CASE_INSENSITIVE_COMPARATOR = new CaseInsensitiveComparator();
|
||||
|
||||
/**
|
||||
* Environmental variables that we've inherited.
|
||||
*/
|
||||
public static final Map<String,String> masterEnvVars = new EnvVars(System.getenv());
|
||||
|
||||
private static class CaseInsensitiveComparator implements Comparator<String>, Serializable {
|
||||
public int compare(String lhs, String rhs) {
|
||||
return lhs.compareToIgnoreCase(rhs);
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import hudson.util.MultipartFormDataParser;
|
||||
import hudson.util.TextFile;
|
||||
import hudson.util.XStream2;
|
||||
import hudson.util.RemotingDiagnostics;
|
||||
import hudson.util.CaseInsensitiveComparator;
|
||||
import hudson.widgets.Widget;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.acegisecurity.Authentication;
|
||||
@@ -201,7 +202,7 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
|
||||
/**
|
||||
* All {@link Item}s keyed by their {@link Item#getName() name}s.
|
||||
*/
|
||||
/*package*/ transient final Map<String,TopLevelItem> items = new CopyOnWriteMap.Tree<String,TopLevelItem>();
|
||||
/*package*/ transient final Map<String,TopLevelItem> items = new CopyOnWriteMap.Tree<String,TopLevelItem>(CaseInsensitiveComparator.INSTANCE);
|
||||
|
||||
/**
|
||||
* The sole instance.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.Util;
|
||||
import hudson.util.CaseInsensitiveComparator;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class ListView extends View {
|
||||
/**
|
||||
* List of job names. This is what gets serialized.
|
||||
*/
|
||||
/*package*/ final Set<String> jobNames = new TreeSet<String>();
|
||||
/*package*/ final Set<String> jobNames = new TreeSet<String>(CaseInsensitiveComparator.INSTANCE);
|
||||
|
||||
/**
|
||||
* Name of this view.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package hudson.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Case-insensitive string comparator.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class CaseInsensitiveComparator implements Comparator<String>, Serializable {
|
||||
public static final Comparator<String> INSTANCE = new CaseInsensitiveComparator();
|
||||
|
||||
private CaseInsensitiveComparator() {}
|
||||
|
||||
public int compare(String lhs, String rhs) {
|
||||
return lhs.compareToIgnoreCase(rhs);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
Reference in new issue
Block a user