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 "no copy" hint. Messages with this hint should not be copied to addresses other than the one to which it is addressed. 023 * 024 * @see <a href="https://xmpp.org/extensions/xep-0334.html#no-copy">XEP-0344 ยง 4.3 No copies</a> 025 */ 026public final class NoCopyHint extends MessageProcessingHint { 027 028 public static final NoCopyHint INSTANCE = new NoCopyHint(); 029 030 public static final String ELEMENT = "no-copy"; 031 032 private NoCopyHint() { 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.no_copy; 048 } 049 050 public static NoCopyHint 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}