001/**
002 *
003 * Copyright the original author or authors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smack;
018
019import java.util.Collection;
020
021import org.jivesoftware.smack.packet.RosterPacket;
022
023/**
024 * This is an interface for persistent roster store needed to implement
025 * roster versioning as per RFC 6121.
026 */
027
028public interface RosterStore {
029
030    /**
031     * This method returns a collection of all roster items contained in this store.
032     * @return List of {@link RosterEntry}
033     */
034    public Collection<RosterPacket.Item> getEntries();
035    /**
036     * This method returns the roster item in this store for the given JID.
037     * @param bareJid The bare JID of the RosterEntry
038     * @return The {@link RosterEntry} which belongs to that user
039     */
040    public RosterPacket.Item getEntry(String bareJid);
041    /**
042     * This method returns the version number as specified by the "ver" attribute
043     * of the local store. For a fresh store, this MUST be the empty string.
044     * @return local roster version
045     */
046    public String getRosterVersion();
047    /**
048     * This method stores a new roster entry in this store or updates an existing one.
049     * @param item the entry to store
050     * @param version the new roster version
051     * @return True if successful
052     */
053    public boolean addEntry(RosterPacket.Item item, String version);
054    /**
055     * This method updates the store so that it contains only the given entries.
056     * @param items the entries to store
057     * @param version the new roster version
058     * @return True if successful
059     */
060    public boolean resetEntries(Collection<RosterPacket.Item> items, String version);
061    /**
062     * Removes an entry from the store
063     * @param bareJid The bare JID of the entry to be removed
064     * @param version the new roster version
065     * @return True if successful
066     */
067    public boolean removeEntry(String bareJid, String version);
068
069}