Java Code Examples for java.util.AbstractList

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project CIShell, under directory /core/org.cishell.reference/src/org/cishell/reference/service/conversion/.

Source file: DataConversionServiceImpl.java

  21 
vote

/** 
 * Get the shortest converter path.  This returns a single converter path
 * @param inType The source data type
 * @param outType The target data type
 * @return Single converter path, or null if no path can be found
 */
private ConverterImpl getConverter(String inType,String outType){
  Vertex sourceVertex=dataTypeToVertex.get(inType);
  Vertex targetVertex=dataTypeToVertex.get(outType);
  if (sourceVertex != null && targetVertex != null) {
    DijkstraShortestPath shortestPathAlg=new DijkstraShortestPath(graph);
    @SuppressWarnings("unchecked") List<Edge> edgeList=shortestPathAlg.getPath(sourceVertex,targetVertex);
    if (edgeList.size() > 0) {
      List<ServiceReference<AlgorithmFactory>> serviceReferences=Lists.newArrayList();
      for (      Edge edge : edgeList) {
        AbstractList converterList=(AbstractList)edge.getUserDatum(SERVICE_LIST);
        serviceReferences.add((ServiceReference)converterList.get(0));
      }
      return ConverterImpl.createConverter(bContext,ciContext,serviceReferences);
    }
  }
  return null;
}
 

Example 2

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/data/.

Source file: LazyLoadingContainer.java

  19 
vote

public Collection<?> getItemIds(){
  return new AbstractList<Integer>(){
    public int size(){
      return size();
    }
    public Integer get(    int index){
      return index;
    }
  }
;
}
 

Example 3

From project android_external_guava, under directory /src/com/google/common/base/.

Source file: Joiner.java

  19 
vote

private static Iterable<Object> iterable(final Object first,final Object second,final Object[] rest){
  checkNotNull(rest);
  return new AbstractList<Object>(){
    @Override public int size(){
      return rest.length + 2;
    }
    @Override public Object get(    int index){
switch (index) {
case 0:
        return first;
case 1:
      return second;
default :
    return rest[index - 2];
}
}
}
;
}
 

Example 4

From project BlameSubversion-plugin, under directory /src/main/java/hudson/scm/.

Source file: BlameSubversionChangeLogSet.java

  19 
vote

@Override public Collection<String> getAffectedPaths(){
  return new AbstractList<String>(){
    public String get(    int index){
      return preparePath(paths.get(index).value);
    }
    public int size(){
      return paths.size();
    }
  }
;
}
 

Example 5

From project cvs-plugin, under directory /src/main/java/hudson/scm/.

Source file: CVSChangeLogSet.java

  19 
vote

@Override public Collection<String> getAffectedPaths(){
  return new AbstractList<String>(){
    @Override public String get(    final int index){
      return files.get(index).getName();
    }
    @Override public int size(){
      return files.size();
    }
  }
;
}
 

Example 6

From project drools-chance, under directory /drools-chance-core/src/main/java/org/drools/chance/core/util/.

Source file: MicroMap.java

  19 
vote

/** 
 * @see java.util.Map#values()
 */
public Collection<T> values(){
  return new AbstractList<T>(){
    public T get(    final int index){
      return value;
    }
    public int size(){
      return MicroMap.this.size();
    }
  }
;
}
 

Example 7

From project fastjson, under directory /src/test/java/com/alibaba/json/bvt/parser/deser/.

Source file: CollectionDeserializerTest.java

  19 
vote

public void test_AbstractList() throws Exception {
  Assert.assertEquals(ArrayList.class,JSON.parseObject("{value:[]}",V5.class).getValue().getClass());
  Assert.assertEquals(ArrayList.class,JSON.parseObject("[]",AbstractList.class).getClass());
  Assert.assertEquals(null,JSON.parseObject("{value:null}",V5.class).getValue());
  Assert.assertEquals(null,JSON.parseObject("null",AbstractList.class));
}
 

Example 8

From project gatein-common, under directory /common/src/test/java/org/gatein/common/reflect/.

Source file: ReflectionTestCase.java

  19 
vote

public void testSafeCast(){
  Integer i=3;
  assertSame(i,Reflection.safeCast(i,Integer.class));
  assertNull(Reflection.safeCast(3L,Integer.class));
  ArrayList list=new ArrayList();
  assertSame(list,Reflection.safeCast(list,List.class));
  assertSame(list,Reflection.safeCast(list,AbstractList.class));
  try {
    Reflection.safeCast(null,null);
    fail();
  }
 catch (  IllegalArgumentException ignore) {
  }
  try {
    Reflection.safeCast("foo",null);
    fail();
  }
 catch (  IllegalArgumentException ignore) {
  }
}
 

Example 9

From project github-api, under directory /src/main/java/org/kohsuke/github/.

Source file: GHCommit.java

  19 
vote

/** 
 * Returns the SHA1 of parent commit objects.
 */
public List<String> getParentSHA1s(){
  if (parents == null)   return Collections.emptyList();
  return new AbstractList<String>(){
    @Override public String get(    int index){
      return parents.get(index).sha;
    }
    @Override public int size(){
      return parents.size();
    }
  }
;
}
 

Example 10

From project GraphLab, under directory /src/graphlab/library/algorithms/sorting/.

Source file: TopologicalSort.java

  19 
vote

public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>AbstractList<VertexType> doSort(BaseGraph<VertexType,EdgeType> graph){
  ArrayList<VertexType> alv=new ArrayList<VertexType>();
  ArrayList<VertexType> out=new ArrayList<VertexType>();
  LibraryUtils.falsifyEdgeMarks(graph);
  for (  VertexType v : graph)   if (graph.getInDegree(v) == 0)   alv.add(v);
  while (alv.size() != 0) {
    VertexType v=alv.remove(0);
    out.add(v);
    Iterator<EdgeType> iet=graph.edgeIterator(v,true);
    while (iet.hasNext()) {
      EdgeType e=iet.next();
      if (graph.getInDegree(e.target) == 1)       alv.add(e.target);
    }
  }
  if (LibraryUtils.falsifyEdgeMarks(graph))   return null;
 else   return out;
}
 

Example 11

From project guice-jit-providers, under directory /core/test/com/google/inject/matcher/.

Source file: MatcherTest.java

  19 
vote

public void testSerialization() throws IOException {
  assertEqualWhenReserialized(any());
  assertEqualWhenReserialized(not(any()));
  assertEqualWhenReserialized(annotatedWith(Named.class));
  assertEqualWhenReserialized(annotatedWith(Names.named("foo")));
  assertEqualWhenReserialized(only("foo"));
  assertEqualWhenReserialized(identicalTo(Object.class));
  assertEqualWhenReserialized(inPackage(String.class.getPackage()));
  assertEqualWhenReserialized(inSubpackage(String.class.getPackage().getName()));
  assertEqualWhenReserialized(returns(any()));
  assertEqualWhenReserialized(subclassesOf(AbstractList.class));
  assertEqualWhenReserialized(only("a").or(only("b")));
  assertEqualWhenReserialized(only("a").and(only("b")));
}
 

Example 12

From project ioke, under directory /src/ikj/main/com/google/common/base/.

Source file: Joiner.java

  19 
vote

private static Iterable<Object> iterable(final Object first,final Object second,final Object[] rest){
  checkNotNull(rest);
  return new AbstractList<Object>(){
    @Override public int size(){
      return rest.length + 2;
    }
    @Override public Object get(    int index){
switch (index) {
case 0:
        return first;
case 1:
      return second;
default :
    return rest[index - 2];
}
}
}
;
}
 

Example 13

From project iPage, under directory /src/test/java/com/github/zhongl/page/.

Source file: BinderBenchmark.java

  19 
vote

private AbstractList<byte[]> list(final int times){
  return new AbstractList<byte[]>(){
    @Override public byte[] get(    int index){
      return new byte[1024];
    }
    @Override public int size(){
      return times;
    }
  }
;
}
 

Example 14

From project jCAE, under directory /amibe/src/org/jcae/mesh/amibe/algos3d/.

Source file: Remesh.java

  19 
vote

public Collection<Vertex> insertNodes(final DoubleBuffer vertices,int group,double liaisonError,double insertionTol){
  final int size=vertices.limit() / 3;
  AbstractList<Vertex> l=new AbstractList<Vertex>(){
    @Override public Vertex get(    int index){
      int n=index * 3;
      return new Vertex(null,vertices.get(n),vertices.get(n + 1),vertices.get(n + 2));
    }
    @Override public int size(){
      return size;
    }
  }
;
  return insertNodes(l,group,liaisonError,insertionTol);
}
 

Example 15

From project jPOS, under directory /jpos/src/test/java/org/jpos/transaction/.

Source file: TransactionManagerTest.java

  19 
vote

@Test public void testPrepare10() throws Throwable {
  HasEntry hasEntry=new HasEntry();
  AbstractList<TransactionParticipant> arrayList=new ArrayList();
  arrayList.add(new Debug());
  int result=transactionManager.prepare(1,100L,new NotActiveException("testTransactionManagerParam1"),members,arrayList.iterator(),members.add(hasEntry),null,null);
  assertEquals("(ArrayList) members.size()",2,members.size());
  assertSame("(ArrayList) members.get(0)",hasEntry,members.get(0));
  assertEquals("result",0,result);
}
 

Example 16

From project LateralGM, under directory /org/lateralgm/ui/swing/visuals/.

Source file: BinVisual.java

  19 
vote

/** 
 * @return A collection of Points (keys to binMap), corresponding to the bins overlapped by rect.
 */
private Collection<Point> overlappingBins(Rectangle rect){
  if (rect.isEmpty())   return Collections.emptyList();
  final int binx=calculateBinCoord(rect.x);
  final int biny=calculateBinCoord(rect.y);
  final int binwidth=calculateBinCoord(rect.x + rect.width - 1) - binx + 1;
  final int binheight=calculateBinCoord(rect.y + rect.height - 1) - biny + 1;
  return new AbstractList<Point>(){
    @Override public Point get(    int index){
      if (index < 0 || index >= size())       throw new IndexOutOfBoundsException();
      return new Point(binx + (index % binwidth),biny + (index / binwidth));
    }
    @Override public int size(){
      return binwidth * binheight;
    }
  }
;
}
 

Example 17

From project linq4j, under directory /src/main/java/net/hydromatic/linq4j/expressions/.

Source file: MethodDeclaration.java

  19 
vote

public void accept(ExpressionWriter writer){
  String modifiers=Modifier.toString(modifier);
  writer.append(modifiers);
  if (!modifiers.isEmpty()) {
    writer.append(' ');
  }
  writer.append(resultType).append(' ').append(name).list("(",", ",")",new AbstractList<String>(){
    public String get(    int index){
      ParameterExpression parameter=parameters.get(index);
      return Types.className(parameter.getType()) + " " + parameter.name;
    }
    public int size(){
      return parameters.size();
    }
  }
).append(' ').append(body);
}
 

Example 18

From project lyo.core, under directory /OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/.

Source file: OslcRdfXmlCollectionProvider.java

  19 
vote

@Override public Collection<Object> readFrom(final Class<Collection<Object>> type,final Type genericType,final Annotation[] annotations,final MediaType mediaType,final MultivaluedMap<String,String> map,final InputStream inputStream) throws IOException, WebApplicationException {
  if (genericType instanceof ParameterizedType) {
    final ParameterizedType parameterizedType=(ParameterizedType)genericType;
    final Type[] actualTypeArguments=parameterizedType.getActualTypeArguments();
    if (actualTypeArguments.length == 1) {
      final Type actualTypeArgument=actualTypeArguments[0];
      if (actualTypeArgument instanceof Class) {
        final Object[] objects=readFrom((Class<?>)actualTypeArgument,mediaType,map,inputStream);
        final Collection<Object> collection;
        if ((Collection.class.equals(type)) || (List.class.equals(type)) || (Deque.class.equals(type))|| (Queue.class.equals(type))|| (AbstractCollection.class.equals(type))|| (AbstractList.class.equals(type))|| (AbstractSequentialList.class.equals(type))) {
          collection=new LinkedList<Object>();
        }
 else         if ((Set.class.equals(type)) || (AbstractSet.class.equals(type))) {
          collection=new HashSet<Object>();
        }
 else         if ((SortedSet.class.equals(type)) || (NavigableSet.class.equals(type))) {
          collection=new TreeSet<Object>();
        }
 else {
          try {
            @SuppressWarnings("cast") final Collection<Object> tempCollection=((Collection<Object>)type.newInstance());
            collection=tempCollection;
          }
 catch (          final Exception exception) {
            throw new WebApplicationException(exception,buildBadRequestResponse(exception,mediaType,map));
          }
        }
        collection.addAll(Arrays.asList(objects));
        return collection;
      }
    }
  }
  return null;
}
 

Example 19

From project platform_external_guava, under directory /src/com/google/common/base/.

Source file: Joiner.java

  19 
vote

private static Iterable<Object> iterable(final Object first,final Object second,final Object[] rest){
  checkNotNull(rest);
  return new AbstractList<Object>(){
    @Override public int size(){
      return rest.length + 2;
    }
    @Override public Object get(    int index){
switch (index) {
case 0:
        return first;
case 1:
      return second;
default :
    return rest[index - 2];
}
}
}
;
}
 

Example 20

From project replication-benchmarker, under directory /src/main/java/crdt/tree/orderedtree/.

Source file: WootHashTreeNode.java

  19 
vote

@Override public List<WootHashTreeNode<T>> getElements(){
  return new AbstractList<WootHashTreeNode<T>>(){
    @Override public WootHashTreeNode<T> get(    int i){
      return getVisible(i).getContent();
    }
    @Override public int size(){
      return viewLength();
    }
  }
;
}
 

Example 21

From project sisu-guice, under directory /core/test/com/google/inject/matcher/.

Source file: MatcherTest.java

  19 
vote

public void testSerialization() throws IOException {
  assertEqualWhenReserialized(any());
  assertEqualWhenReserialized(not(any()));
  assertEqualWhenReserialized(annotatedWith(Named.class));
  assertEqualWhenReserialized(annotatedWith(Names.named("foo")));
  assertEqualWhenReserialized(only("foo"));
  assertEqualWhenReserialized(identicalTo(Object.class));
  assertEqualWhenReserialized(inPackage(String.class.getPackage()));
  assertEqualWhenReserialized(inSubpackage(String.class.getPackage().getName()));
  assertEqualWhenReserialized(returns(any()));
  assertEqualWhenReserialized(subclassesOf(AbstractList.class));
  assertEqualWhenReserialized(only("a").or(only("b")));
  assertEqualWhenReserialized(only("a").and(only("b")));
}
 

Example 22

From project SPREAD, under directory /src/utils/.

Source file: HeapSort.java

  19 
vote

/** 
 * Sorts an array of indices to vector of comparable objects into increasing order.
 */
@SuppressWarnings({"rawtypes"}) public static void sort(AbstractList<Comparable> array,int[] indices){
  for (int i=0; i < indices.length; i++) {
    indices[i]=i;
  }
  int temp;
  int j, n=array.size();
  for (j=n / 2; j > 0; j--) {
    adjust(array,indices,j,n);
  }
  for (j=n - 1; j > 0; j--) {
    temp=indices[0];
    indices[0]=indices[j];
    indices[j]=temp;
    adjust(array,indices,1,j);
  }
}
 

Example 23

From project spring-webflow, under directory /spring-binding/src/test/java/org/springframework/binding/convert/service/.

Source file: DefaultConversionServiceTests.java

  19 
vote

public void testArrayAbstractListConversion(){
  DefaultConversionService service=new DefaultConversionService();
  try {
    service.getConversionExecutor(String[].class,AbstractList.class);
  }
 catch (  IllegalArgumentException e) {
  }
}
 

Example 24

From project st-js, under directory /generator/src/main/java/org/stjs/generator/utils/.

Source file: Lists.java

  19 
vote

public static <T>List<T> union(final List<T> list1,final List<T> list2){
  return new AbstractList<T>(){
    @Override public T get(    int i){
      if (i < list1.size()) {
        return list1.get(i);
      }
      return list2.get(i - list1.size());
    }
    @Override public int size(){
      return list1.size() + list2.size();
    }
  }
;
}
 

Example 25

From project subversion-plugin, under directory /src/main/java/hudson/scm/.

Source file: SubversionChangeLogSet.java

  19 
vote

@Override public Collection<String> getAffectedPaths(){
  return new AbstractList<String>(){
    public String get(    int index){
      return preparePath(paths.get(index).value);
    }
    public int size(){
      return paths.size();
    }
  }
;
}
 

Example 26

From project subversion-plugin_1, under directory /src/main/java/hudson/scm/.

Source file: SubversionChangeLogSet.java

  19 
vote

/** 
 * {@inheritDoc}
 */
public Collection<String> getAffectedPaths(){
  return new AbstractList<String>(){
    public String get(    int index){
      return preparePath(paths.get(index).value);
    }
    public int size(){
      return paths.size();
    }
  }
;
}
 

Example 27

From project tools4j, under directory /config/config-provider/config-bean-provider/config-provider-bean-hbase/src/main/java/org/deephacks/tools4j/config/internal/core/hbase/.

Source file: HBeanRow.java

  19 
vote

/** 
 * Second version of getIids that takes a set of bean ids instead. 
 */
public static byte[] getIids2(final List<BeanId> ids,final UniqueIds uids){
  final AbstractList<String> list=new AbstractList<String>(){
    @Override public String get(    int index){
      return ids.get(index).getInstanceId();
    }
    @Override public int size(){
      return ids.size();
    }
  }
;
  return getIids(list,uids);
}
 

Example 28

From project vraptor, under directory /vraptor-core/src/test/java/br/com/caelum/vraptor/ioc/.

Source file: AbstractComponentRegistryTest.java

  19 
vote

@Test public void shouldRegisterComponentUsingAllPossibleSupertypes(){
  abstractRegistry.deepRegister(ArrayListSubclass.class);
  verify(registry).register(ArrayListSubclass.class,ArrayListSubclass.class);
  verify(registry).register(ArrayList.class,ArrayListSubclass.class);
  verify(registry).register(List.class,ArrayListSubclass.class);
  verify(registry).register(Collection.class,ArrayListSubclass.class);
  verify(registry).register(Iterable.class,ArrayListSubclass.class);
  verify(registry).register(Cloneable.class,ArrayListSubclass.class);
  verify(registry).register(Serializable.class,ArrayListSubclass.class);
  verify(registry).register(RandomAccess.class,ArrayListSubclass.class);
  verify(registry).register(AbstractList.class,ArrayListSubclass.class);
  verify(registry).register(AbstractCollection.class,ArrayListSubclass.class);
}