Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.lyncode.xoai.dataprovider.repository;
import com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException;
import com.lyncode.xoai.dataprovider.exceptions.OAIException;
import com.lyncode.xoai.dataprovider.filter.ScopedFilter;
import com.lyncode.xoai.dataprovider.handlers.results.ListItemIdentifiersResult;
import com.lyncode.xoai.dataprovider.handlers.results.ListItemsResults;
import com.lyncode.xoai.dataprovider.model.InMemoryItem;
import com.lyncode.xoai.dataprovider.model.Item;
import com.lyncode.xoai.dataprovider.model.ItemIdentifier;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static java.lang.Math.min;
import static java.util.Arrays.asList;
public class InMemoryItemRepository implements ItemRepository {
private List list = new ArrayList();
public InMemoryItemRepository withNoItems() {
return this;
}
public InMemoryItemRepository withItem(InMemoryItem item) {
list.add(item);
return this;
}
public InMemoryItemRepository withItems(InMemoryItem... item) {
list.addAll(asList(item));
return this;
}
public InMemoryItemRepository withRandomItems(int number) {
for (int i = 0; i < number; i++)
list.add(InMemoryItem.randomItem());
return this;
}
@Override
public Item getItem(String identifier) throws IdDoesNotExistException, OAIException {
for (InMemoryItem item : this.list) {
if (item.getIdentifier().equals(identifier))
return item;
}
throw new IdDoesNotExistException();
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length) throws OAIException {
return new ListItemIdentifiersResult(offset + length < list.size(), new ArrayList(list.subList(offset, min(offset + length, list.size()))));
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length, Date from) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiersUntil(List filters, int offset, int length, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length, Date from, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length, String setSpec) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length, String setSpec, Date from) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiersUntil(List filters, int offset, int length, String setSpec, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemIdentifiersResult getItemIdentifiers(List filters, int offset, int length, String setSpec, Date from, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItems(List filters, int offset, int length) throws OAIException {
return new ListItemsResults(offset + length < list.size(), new ArrayList(list.subList(offset, min(offset + length, list.size()))));
}
@Override
public ListItemsResults getItems(List filters, int offset, int length, Date from) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItemsUntil(List filters, int offset, int length, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItems(List filters, int offset, int length, Date from, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItems(List filters, int offset, int length, String setSpec) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItems(List filters, int offset, int length, String setSpec, Date from) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItemsUntil(List filters, int offset, int length, String setSpec, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public ListItemsResults getItems(List filters, int offset, int length, String setSpec, Date from, Date until) throws OAIException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
}