package de.thedevstack.conversationsplus.xmpp.chatstate; import de.thedevstack.conversationsplus.xml.Element; public enum ChatState { ACTIVE, INACTIVE, GONE, COMPOSING, PAUSED; public static final String NAMESPACE = "http://jabber.org/protocol/chatstates"; public static ChatState parse(Element element) { if (element.hasChild("active",NAMESPACE)) { return ACTIVE; } else if (element.hasChild("inactive",NAMESPACE)) { return INACTIVE; } else if (element.hasChild("composing",NAMESPACE)) { return COMPOSING; } else if (element.hasChild("gone",NAMESPACE)) { return GONE; } else if (element.hasChild("paused",NAMESPACE)) { return PAUSED; } else { return null; } } public static Element toElement(ChatState state) { final Element element = new Element(state.toString().toLowerCase()); element.setAttribute("xmlns",NAMESPACE); return element; } }