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