001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Bogdan Stefanescu 018 * Florent Guillaume 019 */ 020 021package org.nuxeo.ecm.core.api.impl; 022 023import java.util.ArrayList; 024import java.util.List; 025 026import org.nuxeo.ecm.core.api.DocumentRef; 027import org.nuxeo.ecm.core.api.DocumentRefList; 028 029/** 030 * @author Bogdan Stefanescu 031 */ 032public class DocumentRefListImpl extends ArrayList<DocumentRef> implements DocumentRefList { 033 034 private static final long serialVersionUID = -7915146644486566862L; 035 036 protected long totalSize = -1; 037 038 public DocumentRefListImpl() { 039 } 040 041 public DocumentRefListImpl(int size) { 042 super(size); 043 } 044 045 public DocumentRefListImpl(List<DocumentRef> list) { 046 super(list); 047 } 048 049 /** 050 * Constructs a DocumentModelListImpl and sets the "total size" information. 051 * <p> 052 * The total size is additional information that can be provided in some cases where the list returned is a slice of 053 * a bigger list, this is used when getting paged results from a database for instance. 054 * 055 * @param list the list of documents 056 * @param totalSize the total size, with -1 meaning "same as the list's size" 057 */ 058 public DocumentRefListImpl(List<DocumentRef> list, long totalSize) { 059 super(list); 060 this.totalSize = totalSize; 061 } 062 063 public void setTotalSize(long totalSize) { 064 this.totalSize = totalSize; 065 } 066 067 @Override 068 public long totalSize() { 069 if (totalSize == -1) { 070 return size(); 071 } 072 return totalSize; 073 } 074 075}