001/** 002 * 003 * Copyright 2017 Florian Schmaus 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.hints.element; 018 019import org.jivesoftware.smack.packet.Message; 020 021/** 022 * A "store" hint. Messages with this hint should be stored in permanent stores or archives. 023 * 024 * @see <a href="https://xmpp.org/extensions/xep-0334.html#sect-idm140684698220992">XEP-0334 ยง 4.4 Store</a> 025 */ 026public final class StoreHint extends MessageProcessingHint { 027 028 public static final StoreHint INSTANCE = new StoreHint(); 029 030 public static final String ELEMENT = "store"; 031 032 private StoreHint() { 033 } 034 035 @Override 036 public String getElementName() { 037 return ELEMENT; 038 } 039 040 @Override 041 public String toXML(String enclosingNamespace) { 042 return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>"; 043 } 044 045 @Override 046 public MessageProcessingHintType getHintType() { 047 return MessageProcessingHintType.store; 048 } 049 050 public static StoreHint from(Message message) { 051 return message.getExtension(ELEMENT, NAMESPACE); 052 } 053 054 public static boolean hasHint(Message message) { 055 return from(message) != null; 056 } 057 058 public static void set(Message message) { 059 message.overrideExtension(INSTANCE); 060 } 061}