noticed this class is a hold over from 1.2 support so switched its
single usage over to Collections.singletonList()
This commit is contained in:
parent
8ea8f23fb8
commit
0816c3cdab
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -21,7 +22,6 @@ import java.util.Set;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.SingletonList;
|
||||
import org.eclipse.jetty.util.StringMap;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class PathMap extends HashMap implements Externalizable
|
|||
{
|
||||
_default=entry;
|
||||
_defaultSingletonList=
|
||||
SingletonList.newSingletonList(_default);
|
||||
Collections.singletonList(_default);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 1999-2009 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Iterator;
|
||||
import java.util.ListIterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Singleton List.
|
||||
* This simple efficient implementation of a List with a single
|
||||
* element is provided for JDK 1.2 JVMs, which do not provide
|
||||
* the Collections.singletonList method.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SingletonList extends AbstractList
|
||||
{
|
||||
private Object o;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private SingletonList(Object o)
|
||||
{
|
||||
this.o=o;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static SingletonList newSingletonList(Object o)
|
||||
{
|
||||
return new SingletonList(o);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Object get(int i)
|
||||
{
|
||||
if (i!=0)
|
||||
throw new IndexOutOfBoundsException("index "+i);
|
||||
return o;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public ListIterator listIterator()
|
||||
{
|
||||
return new SIterator();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public ListIterator listIterator(int i)
|
||||
{
|
||||
return new SIterator(i);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Iterator iterator()
|
||||
{
|
||||
return new SIterator();
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private class SIterator implements ListIterator
|
||||
{
|
||||
int i;
|
||||
|
||||
SIterator(){i=0;}
|
||||
SIterator(int i)
|
||||
{
|
||||
if (i<0||i>1)
|
||||
throw new IndexOutOfBoundsException("index "+i);
|
||||
this.i=i;
|
||||
}
|
||||
public void add(Object o){throw new UnsupportedOperationException("SingletonList.add()");}
|
||||
public boolean hasNext() {return i==0;}
|
||||
public boolean hasPrevious() {return i==1;}
|
||||
public Object next() {if (i!=0) throw new NoSuchElementException();i++;return o;}
|
||||
public int nextIndex() {return i;}
|
||||
public Object previous() {if (i!=1) throw new NoSuchElementException();i--;return o;}
|
||||
public int previousIndex() {return i-1;}
|
||||
public void remove(){throw new UnsupportedOperationException("SingletonList.remove()");}
|
||||
public void set(Object o){throw new UnsupportedOperationException("SingletonList.add()");}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue