/** * Converts a String into the corresponding types. Valid String values that can be converted * to types are: "chat", "available", "away", "xa", and "dnd". * * @param string the String value to covert. * @return the corresponding Type. * @throws IllegalArgumentException when not able to parse the string parameter * @throws NullPointerException if the string is null */ public static Mode fromString(String string) { return Mode.valueOf(string.toLowerCase(Locale.US)); } }
/** * Converts a String into the corresponding types. Valid String values that can be converted * to types are: "chat", "available", "away", "xa", and "dnd". * * @param string the String value to covert. * @return the corresponding Type. * @throws IllegalArgumentException when not able to parse the string parameter * @throws NullPointerException if the string is null */ public static Mode fromString(String string) { return Mode.valueOf(string.toLowerCase(Locale.US)); } }
@Override public void setGuiFieldsFromSampler(JMeterXMPPSampler sampler) { recipient.setText(sampler.getPropertyAsString(RECIPIENT)); text.setText(sampler.getPropertyAsString(STATUS_TEXT)); type.setSelectedItem(Presence.Type.valueOf(sampler.getPropertyAsString(TYPE, Presence.Type.available.toString()))); mode.setSelectedItem(Presence.Mode.valueOf(sampler.getPropertyAsString(MODE, Presence.Mode.available.toString()))); }
String modeText = parser.nextText(); try { presence.setMode(Presence.Mode.valueOf(modeText));
String modeText = parser.nextText(); try { presence.setMode(Presence.Mode.valueOf(modeText));
String modeText = parser.nextText(); try { presence.setMode(Presence.Mode.valueOf(modeText)); } catch (IllegalArgumentException iae) { System.err.println("Found invalid presence mode " + modeText);
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { Presence.Type typeVal = Presence.Type.valueOf(sampler.getPropertyAsString(TYPE, Presence.Type.available.toString())); Presence.Mode modeVal = Presence.Mode.valueOf(sampler.getPropertyAsString(MODE, Presence.Mode.available.toString())); Presence presence = new Presence(typeVal); presence.setMode(modeVal); String to = sampler.getPropertyAsString(RECIPIENT); if (!to.isEmpty()) { presence.setTo(to); } String text = sampler.getPropertyAsString(STATUS_TEXT); if (!text.isEmpty()) { presence.setStatus(text); } sampler.getXMPPConnection().sendPacket(presence); res.setSamplerData(presence.toXML().toString()); return res; }