private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { boolean done = false; String jid = null; String nickname = null; Date joined = null; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && "jid".equals(parser.getName())) { jid = parser.nextText(); } else if (eventType == XmlPullParser.START_TAG && "nickname".equals(parser.getName())) { nickname = parser.nextText(); } else if (eventType == XmlPullParser.START_TAG && "joined".equals(parser.getName())) { try { synchronized (UTC_FORMAT) { joined = UTC_FORMAT.parse(parser.nextText()); } } catch (ParseException e) { throw new SmackException(e); } } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { done = true; } } return new OccupantInfo(jid, nickname, joined); } }
public String getChildElementXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE); buf.append("\" roomID=\"").append(roomID).append("\">"); synchronized (occupants) { for (OccupantInfo occupant : occupants) { buf.append("<occupant>"); // Add the occupant jid buf.append("<jid>"); buf.append(occupant.getJID()); buf.append("</jid>"); // Add the occupant nickname buf.append("<name>"); buf.append(occupant.getNickname()); buf.append("</name>"); // Add the date when the occupant joined the room buf.append("<joined>"); buf.append(UTC_FORMAT.format(occupant.getJoined())); buf.append("</joined>"); buf.append("</occupant>"); } } buf.append("</").append(ELEMENT_NAME).append("> "); return buf.toString(); }
public String getChildElementXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE); buf.append("\" roomID=\"").append(roomID).append("\">"); synchronized (occupants) { for (OccupantInfo occupant : occupants) { buf.append("<occupant>"); // Add the occupant jid buf.append("<jid>"); buf.append(occupant.getJID()); buf.append("</jid>"); // Add the occupant nickname buf.append("<name>"); buf.append(occupant.getNickname()); buf.append("</name>"); // Add the date when the occupant joined the room buf.append("<joined>"); buf.append(UTC_FORMAT.format(occupant.getJoined())); buf.append("</joined>"); buf.append("</occupant>"); } } buf.append("</").append(ELEMENT_NAME).append("> "); return buf.toString(); }
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws Exception { boolean done = false; String jid = null; String nickname = null; Date joined = null; while (!done) { int eventType = parser.next(); if ((eventType == XmlPullParser.START_TAG) && ("jid".equals(parser.getName()))) { jid = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("nickname".equals(parser.getName()))) { nickname = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("joined".equals(parser.getName()))) { joined = UTC_FORMAT.parse(parser.nextText()); } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { done = true; } } return new OccupantInfo(jid, nickname, joined); } }
public String getChildElementXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE); buf.append("\" roomID=\"").append(roomID).append("\">"); synchronized (occupants) { for (OccupantInfo occupant : occupants) { buf.append("<occupant>"); // Add the occupant jid buf.append("<jid>"); buf.append(occupant.getJID()); buf.append("</jid>"); // Add the occupant nickname buf.append("<name>"); buf.append(occupant.getNickname()); buf.append("</name>"); // Add the date when the occupant joined the room buf.append("<joined>"); buf.append(UTC_FORMAT.format(occupant.getJoined())); buf.append("</joined>"); buf.append("</occupant>"); } } buf.append("</").append(ELEMENT_NAME).append("> "); return buf.toString(); }
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws Exception { boolean done = false; String jid = null; String nickname = null; Date joined = null; while (!done) { int eventType = parser.next(); if ((eventType == XmlPullParser.START_TAG) && ("jid".equals(parser.getName()))) { jid = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("nickname".equals(parser.getName()))) { nickname = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("joined".equals(parser.getName()))) { joined = UTC_FORMAT.parse(parser.nextText()); } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { done = true; } } return new OccupantInfo(jid, nickname, joined); } }
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws Exception { boolean done = false; String jid = null; String nickname = null; Date joined = null; while (!done) { int eventType = parser.next(); if ((eventType == XmlPullParser.START_TAG) && ("jid".equals(parser.getName()))) { jid = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("nickname".equals(parser.getName()))) { nickname = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("joined".equals(parser.getName()))) { joined = UTC_FORMAT.parse(parser.nextText()); } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { done = true; } } return new OccupantInfo(jid, nickname, joined); } }
@Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) { buf.append(" roomID=\"").append(roomID).append("\">"); synchronized (occupants) { for (OccupantInfo occupant : occupants) { buf.append("<occupant>"); // Add the occupant jid buf.append("<jid>"); buf.append(occupant.getJID()); buf.append("</jid>"); // Add the occupant nickname buf.append("<name>"); buf.append(occupant.getNickname()); buf.append("</name>"); // Add the date when the occupant joined the room buf.append("<joined>"); synchronized (UTC_FORMAT) { buf.append(UTC_FORMAT.format(occupant.getJoined())); } buf.append("</joined>"); buf.append("</occupant>"); } } return buf; }