001/** 002 * 003 * Copyright © 2016 Fernando Ramirez 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.smackx.mam.element; 018 019import org.jivesoftware.smack.packet.IQ; 020 021import org.jivesoftware.smackx.rsm.packet.RSMSet; 022 023/** 024 * MAM fin IQ class. 025 * 026 * @see <a href="http://xmpp.org/extensions/xep-0313.html">XEP-0313: Message 027 * Archive Management</a> 028 * @author Fernando Ramirez 029 * 030 */ 031public class MamFinIQ extends IQ { 032 033 /** 034 * fin element. 035 */ 036 public static final String ELEMENT = "fin"; 037 038 /** 039 * the IQ NAMESPACE. 040 */ 041 public static final String NAMESPACE = MamElements.NAMESPACE; 042 043 /** 044 * RSM set. 045 */ 046 private final RSMSet rsmSet; 047 048 /** 049 * if is complete. 050 */ 051 private final boolean complete; 052 053 /** 054 * if is stable. 055 */ 056 private final boolean stable; 057 058 /** 059 * the query id. 060 */ 061 private final String queryId; 062 063 /** 064 * MamFinIQ constructor. 065 * 066 * @param queryId 067 * @param rsmSet 068 * @param complete 069 * @param stable 070 */ 071 public MamFinIQ(String queryId, RSMSet rsmSet, boolean complete, boolean stable) { 072 super(ELEMENT, NAMESPACE); 073 if (rsmSet == null) { 074 throw new IllegalArgumentException("rsmSet must not be null"); 075 } 076 this.rsmSet = rsmSet; 077 this.complete = complete; 078 this.stable = stable; 079 this.queryId = queryId; 080 } 081 082 /** 083 * Get RSM set. 084 * 085 * @return the RSM set 086 */ 087 public RSMSet getRSMSet() { 088 return rsmSet; 089 } 090 091 /** 092 * Return if it is complete. 093 * 094 * @return true if it is complete 095 */ 096 public boolean isComplete() { 097 return complete; 098 } 099 100 /** 101 * Return if it is stable. 102 * 103 * @return true if it is stable 104 */ 105 public boolean isStable() { 106 return stable; 107 } 108 109 /** 110 * Get query id. 111 * 112 * @return the query id 113 */ 114 public final String getQueryId() { 115 return queryId; 116 } 117 118 @Override 119 protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) { 120 xml.optAttribute("queryid", queryId); 121 xml.optBooleanAttribute("complete", complete); 122 xml.optBooleanAttribute("stable", stable); 123 if (rsmSet == null) { 124 xml.setEmptyElement(); 125 } else { 126 xml.rightAngleBracket(); 127 xml.element(rsmSet); 128 } 129 return xml; 130 } 131 132}