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.roster.rosterstore; 018 019import java.util.Collection; 020import java.util.List; 021 022import org.jivesoftware.smack.roster.packet.RosterPacket; 023import org.jxmpp.jid.Jid; 024 025/** 026 * This is an interface for persistent roster store needed to implement 027 * roster versioning as per RFC 6121. 028 */ 029 030public interface RosterStore { 031 032 /** 033 * This method returns a list of all roster items contained in this store. If there was an error while loading the store, then <code>null</code> is returned. 034 * 035 * @return List of {@link org.jivesoftware.smack.roster.RosterEntry} or <code>null</code>. 036 */ 037 public List<RosterPacket.Item> getEntries(); 038 039 /** 040 * This method returns the roster item in this store for the given JID. 041 * @param bareJid The bare JID of the RosterEntry 042 * @return The {@link org.jivesoftware.smack.roster.RosterEntry} which belongs to that user 043 */ 044 public RosterPacket.Item getEntry(Jid bareJid); 045 /** 046 * This method returns the version number as specified by the "ver" attribute 047 * of the local store. For a fresh store, this MUST be the empty string. 048 * @return local roster version 049 */ 050 public String getRosterVersion(); 051 /** 052 * This method stores a new roster entry in this store or updates an existing one. 053 * @param item the entry to store 054 * @param version the new roster version 055 * @return True if successful 056 */ 057 public boolean addEntry(RosterPacket.Item item, String version); 058 /** 059 * This method updates the store so that it contains only the given entries. 060 * @param items the entries to store 061 * @param version the new roster version 062 * @return True if successful 063 */ 064 public boolean resetEntries(Collection<RosterPacket.Item> items, String version); 065 /** 066 * Removes an entry from the store. 067 * @param bareJid The bare JID of the entry to be removed 068 * @param version the new roster version 069 * @return True if successful 070 */ 071 public boolean removeEntry(Jid bareJid, String version); 072 073 /** 074 * Reset the store by removing all entries and setting the version to the empty String. 075 * 076 * @since 4.2 077 */ 078 public void resetStore(); 079}