001/** 002 * 003 * Copyright 2018-2021 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.smack.packet; 018 019import javax.xml.namespace.QName; 020 021/** 022 * Interface to represent XML elements. Every XML element in XMPP has a qualified XML name ({@link QName}). This name 023 * can be obtained via {@link #getQName()}. 024 * <p> 025 * XMPP uses "extension elements", i.e. XML elements, to provide extended functionality beyond what is in the base XMPP 026 * specification. Examples of extensions elements include message events, message properties, and extra presence data. 027 * IQ stanzas have limited support for extension elements. See {@link ExtensionElement} for more information about XMPP 028 * extension elements. 029 * </p> 030 * <p> 031 * It is recommend to use {@link ExtensionElement} over this class when creating new extension elements. 032 * </p> 033 * 034 * @see org.jivesoftware.smack.provider.ExtensionElementProvider 035 * @since 4.5 036 */ 037public interface XmlElement extends NamedElement, XmlLangElement { 038 039 /** 040 * Returns the root element XML namespace. 041 * 042 * @return the namespace. 043 */ 044 String getNamespace(); 045 046 default QName getQName() { 047 String namespaceURI = getNamespace(); 048 String localPart = getElementName(); 049 return new QName(namespaceURI, localPart); 050 } 051 052 @Override 053 default String getLanguage() { 054 return null; 055 } 056}