/** * * Copyright 2003-2007 Jive Software. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jivesoftware.smack.packet; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.jivesoftware.smack.util.XmlStringBuilder; /** * Default implementation of the PacketExtension interface. Unless a PacketExtensionProvider * is registered with {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}, * instances of this class will be returned when getting packet extensions.
* * This class provides a very simple representation of an XML sub-document. Each element * is a key in a Map with its CDATA being the value. For example, given the following * XML sub-document: * *
* <foo xmlns="http://bar.com"> * <color>blue</color> * <food>pizza</food> * </foo>* * In this case, getValue("color") would return "blue", and getValue("food") would * return "pizza". This parsing mechanism mechanism is very simplistic and will not work * as desired in all cases (for example, if some of the elements have attributes. In those * cases, a custom PacketExtensionProvider should be used. * * @author Matt Tucker */ public class DefaultPacketExtension implements PacketExtension { private String elementName; private String namespace; private Map