PrivacyList.java

  1. /**
  2.  *
  3.  * Copyright the original author or authors
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.privacy;

  18. import java.util.List;

  19. import org.jivesoftware.smackx.privacy.packet.PrivacyItem;

  20. /**
  21.  * A privacy list represents a list of contacts that is a read only class used to represent a set of allowed or blocked communications.
  22.  * Basically it can:<ul>
  23.  *
  24.  *      <li>Handle many {@link org.jivesoftware.smackx.privacy.packet.PrivacyItem}.</li>
  25.  *      <li>Answer if it is the default list.</li>
  26.  *      <li>Answer if it is the active list.</li>
  27.  * </ul>
  28.  *
  29.  * {@link PrivacyItem Privacy Items} can handle different kind of blocking communications based on JID, group,
  30.  * subscription type or globally.
  31.  *
  32.  * @author Francisco Vives
  33.  */
  34. public class PrivacyList {

  35.     /** Holds if it is an active list or not **/
  36.     private final boolean isActiveList;
  37.     /** Holds if it is an default list or not **/
  38.     private final boolean isDefaultList;
  39.     /** Holds the list name used to print **/
  40.     private final String listName;
  41.     /** Holds the list of {@link PrivacyItem} */
  42.     private final List<PrivacyItem> items;

  43.     protected PrivacyList(boolean isActiveList, boolean isDefaultList,
  44.             String listName, List<PrivacyItem> privacyItems) {
  45.         super();
  46.         this.isActiveList = isActiveList;
  47.         this.isDefaultList = isDefaultList;
  48.         this.listName = listName;
  49.         this.items = privacyItems;
  50.     }

  51.     public String getName() {
  52.         return listName;
  53.     }

  54.     public boolean isActiveList() {
  55.         return isActiveList;
  56.     }

  57.     public boolean isDefaultList() {
  58.         return isDefaultList;
  59.     }

  60.     public List<PrivacyItem> getItems() {
  61.         return items;
  62.     }

  63.     @Override
  64.     public String toString() {
  65.         return "Privacy List: " + listName + "(active:" + isActiveList + ", default:" + isDefaultList + ")";
  66.     }
  67. }