001package ca.uhn.fhir.rest.server;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2016 University Health Network
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.util.List;
024
025import org.hl7.fhir.instance.model.api.IBaseResource;
026
027import ca.uhn.fhir.model.primitive.InstantDt;
028
029public interface IBundleProvider {
030
031        /**
032         * Load the given collection of resources by index, plus any additional resources per the
033         * server's processing rules (e.g. _include'd resources, OperationOutcome, etc.). For example,
034         * if the method is invoked with index 0,10 the method might return 10 search results, plus an 
035         * additional 20 resources which matched a client's _include specification.
036         * 
037         * @param theFromIndex The low index (inclusive) to return
038         * @param theToIndex The high index (exclusive) to return
039         * @return A list of resources. The size of this list must be at least <code>theToIndex - theFromIndex</code>.
040         */
041        List<IBaseResource> getResources(int theFromIndex, int theToIndex);
042        
043        /**
044         * Optionally may be used to signal a preferred page size to the server, e.g. because
045         * the implementing code recognizes that the resources which will be returned by this
046         * implementation are expensive to load so a smaller page size should be used. The value
047         * returned by this method will only be used if the client has not explicitly requested
048         * a page size.
049         * 
050         * @return Returns the preferred page size or <code>null</code>
051         */
052        Integer preferredPageSize();
053        
054        /**
055         * Returns the total number of results which match the given query (exclusive of any
056         * _include's or OperationOutcome)
057         */
058        int size();
059        
060        /**
061         * Returns the instant as of which this result was valid
062         */
063        InstantDt getPublished();
064
065}