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