public void setName ( String name ) { synchronized ( entries ) { for ( RosterEntry entry : entries ) { Roster packet = new Roster ( ) ; packet . setType ( IQ . Type . set ) ; List < String > groupNames = new LinkedList < String > ( entry . getGroupNames ( ) ) ; groupNames . remove ( this . name ) ; groupNames . add ( name ) ; packet . addItem ( new JID ( entry . getUser ( ) ) , entry . getName ( ) , entry . getAsk ( ) , entry . getSubscription ( ) , groupNames ) ; connection . sendPacket ( packet ) ; } } }
Sets the name of the group . Changing the group s name is like moving all the group entries of the group to a new group specified by the new name . Since this group won t have entries it will be removed from the roster . This means that all the references to this object will be invalid and will need to be updated to the new group specified by the new name .