Fixes warnings.

cusax-fix
Lyubomir Marinov 17 years ago
parent 05d7637b0d
commit 0a2aa6c723

@ -7,7 +7,6 @@
package net.java.sip.communicator.impl.argdelegation; package net.java.sip.communicator.impl.argdelegation;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.version.*;
import net.java.sip.communicator.util.launchutils.*; import net.java.sip.communicator.util.launchutils.*;
import org.osgi.framework.*; import org.osgi.framework.*;

@ -12,11 +12,9 @@
import net.java.sip.communicator.service.argdelegation.*; import net.java.sip.communicator.service.argdelegation.*;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.version.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.launchutils.*; import net.java.sip.communicator.util.launchutils.*;
/** /**
* Implements the <tt>UriDelegationPeer</tt> interface from our argument handler * Implements the <tt>UriDelegationPeer</tt> interface from our argument handler
* utility. We use this handler to relay arguments to URI handlers that have * utility. We use this handler to relay arguments to URI handlers that have
@ -33,7 +31,7 @@ public class ArgDelegationPeerImpl
/** /**
* The list of uriHandlers that we are currently aware of. * The list of uriHandlers that we are currently aware of.
*/ */
private Map<String, UriHandler> uriHandlers private final Map<String, UriHandler> uriHandlers
= new Hashtable<String, UriHandler>(); = new Hashtable<String, UriHandler>();
/** /**

@ -42,7 +42,7 @@ public class AudioNotifierActivator implements BundleActivator
public void start(BundleContext bundleContext) throws Exception public void start(BundleContext bundleContext) throws Exception
{ {
try { try {
this.bundleContext = bundleContext; AudioNotifierActivator.bundleContext = bundleContext;
//Create the audio notifier service //Create the audio notifier service
audioNotifier = new AudioNotifierServiceImpl(); audioNotifier = new AudioNotifierServiceImpl();

@ -10,7 +10,6 @@
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.util.*;
/** /**
* The implementation of the AudioNotifierService. * The implementation of the AudioNotifierService.
@ -20,9 +19,8 @@
public class AudioNotifierServiceImpl public class AudioNotifierServiceImpl
implements AudioNotifierService implements AudioNotifierService
{ {
private Logger logger = Logger.getLogger(AudioNotifierServiceImpl.class); private static final Map<String, SCAudioClipImpl> audioClips =
new HashMap<String, SCAudioClipImpl>();
private static Map audioClips = new HashMap();
private boolean isMute; private boolean isMute;
@ -34,13 +32,13 @@ public class AudioNotifierServiceImpl
*/ */
public SCAudioClip createAudio(String uri) public SCAudioClip createAudio(String uri)
{ {
SCAudioClip audioClip; SCAudioClipImpl audioClip;
synchronized (audioClips) synchronized (audioClips)
{ {
if(audioClips.containsKey(uri)) if(audioClips.containsKey(uri))
{ {
audioClip = (SCAudioClip) audioClips.get(uri); audioClip = audioClips.get(uri);
} }
else else
{ {
@ -90,23 +88,15 @@ public void setMute(boolean isMute)
{ {
this.isMute = isMute; this.isMute = isMute;
Iterator audios = audioClips.entrySet().iterator(); for (SCAudioClipImpl audioClip : audioClips.values())
while (audios.hasNext())
{ {
SCAudioClipImpl audioClip
= (SCAudioClipImpl) ((Map.Entry) audios.next()).getValue();
if (isMute) if (isMute)
{ {
audioClip.internalStop(); audioClip.internalStop();
} }
else else if (audioClip.isLooping())
{ {
if(audioClip.isLooping()) audioClip.playInLoop(audioClip.getLoopInterval());
{
audioClip.playInLoop(audioClip.getLoopInterval());
}
} }
} }
} }

@ -26,7 +26,7 @@ public class SCAudioClipImpl implements SCAudioClip
{ {
private static Constructor acConstructor = null; private static Constructor acConstructor = null;
private Timer playAudioTimer = new Timer(1000, null); private Timer playAudioTimer = new Timer(1000, null);
private AudioClip audioClip; private AudioClip audioClip;

@ -37,8 +37,8 @@ public class CallHistoryServiceImpl
/** /**
* The logger for this class. * The logger for this class.
*/ */
private static Logger logger = Logger private static final Logger logger =
.getLogger(CallHistoryServiceImpl.class); Logger.getLogger(CallHistoryServiceImpl.class);
private static String[] STRUCTURE_NAMES = private static String[] STRUCTURE_NAMES =
new String[] { "callStart", "callEnd", "dir", "callParticipantIDs", new String[] { "callStart", "callEnd", "dir", "callParticipantIDs",
@ -58,12 +58,14 @@ public class CallHistoryServiceImpl
private Object syncRoot_HistoryService = new Object(); private Object syncRoot_HistoryService = new Object();
private Hashtable progressListeners = new Hashtable(); private final Map<CallHistorySearchProgressListener, SearchProgressWrapper> progressListeners =
new Hashtable<CallHistorySearchProgressListener, SearchProgressWrapper>();
private Vector currentCallRecords = new Vector(); private final List<CallRecordImpl> currentCallRecords =
new Vector<CallRecordImpl>();
private HistoryCallChangeListener historyCallChangeListener private final CallChangeListener historyCallChangeListener =
= new HistoryCallChangeListener(); new HistoryCallChangeListener();
public HistoryService getHistoryService() public HistoryService getHistoryService()
{ {
@ -80,7 +82,7 @@ public HistoryService getHistoryService()
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByStartDate(MetaContact contact, Date startDate) public Collection<CallRecord> findByStartDate(MetaContact contact, Date startDate)
throws RuntimeException throws RuntimeException
{ {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
@ -93,9 +95,10 @@ public Collection findByStartDate(MetaContact contact, Date startDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByStartDate(Date startDate) public Collection<CallRecord> findByStartDate(Date startDate)
{ {
TreeSet result = new TreeSet(new CallRecordComparator()); TreeSet<CallRecord> result =
new TreeSet<CallRecord>(new CallRecordComparator());
try try
{ {
// the default ones // the default ones
@ -128,7 +131,7 @@ public Collection findByStartDate(Date startDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByEndDate(MetaContact contact, Date endDate) public Collection<CallRecord> findByEndDate(MetaContact contact, Date endDate)
throws RuntimeException throws RuntimeException
{ {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
@ -141,9 +144,9 @@ public Collection findByEndDate(MetaContact contact, Date endDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByEndDate(Date endDate) throws RuntimeException public Collection<CallRecord> findByEndDate(Date endDate) throws RuntimeException
{ {
TreeSet result = new TreeSet(new CallRecordComparator()); TreeSet<CallRecord> result = new TreeSet<CallRecord>(new CallRecordComparator());
try try
{ {
// the default ones // the default ones
@ -176,7 +179,7 @@ public Collection findByEndDate(Date endDate) throws RuntimeException
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByPeriod(MetaContact contact, Date startDate, Date endDate) public Collection<CallRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate)
throws RuntimeException throws RuntimeException
{ {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
@ -190,10 +193,10 @@ public Collection findByPeriod(MetaContact contact, Date startDate, Date endDate
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByPeriod(Date startDate, Date endDate) throws public Collection<CallRecord> findByPeriod(Date startDate, Date endDate) throws
RuntimeException RuntimeException
{ {
TreeSet result = new TreeSet(new CallRecordComparator()); TreeSet<CallRecord> result = new TreeSet<CallRecord>(new CallRecordComparator());
try try
{ {
// the default ones // the default ones
@ -226,7 +229,7 @@ public Collection findByPeriod(Date startDate, Date endDate) throws
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findLast(MetaContact contact, int count) public Collection<CallRecord> findLast(MetaContact contact, int count)
throws RuntimeException throws RuntimeException
{ {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
@ -239,9 +242,9 @@ public Collection findLast(MetaContact contact, int count)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findLast(int count) throws RuntimeException public Collection<CallRecord> findLast(int count) throws RuntimeException
{ {
TreeSet result = new TreeSet(new CallRecordComparator()); TreeSet<CallRecord> result = new TreeSet<CallRecord>(new CallRecordComparator());
try try
{ {
// the default ones // the default ones
@ -267,10 +270,10 @@ public Collection findLast(int count) throws RuntimeException
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByParticipant(String address) public Collection<CallRecord> findByParticipant(String address)
throws RuntimeException throws RuntimeException
{ {
TreeSet result = new TreeSet(new CallRecordComparator()); TreeSet<CallRecord> result = new TreeSet<CallRecord>(new CallRecordComparator());
try try
{ {
// the default ones // the default ones
@ -335,14 +338,14 @@ private History getHistory(Contact localContact, Contact remoteContact)
* @param hr HistoryRecord * @param hr HistoryRecord
* @return Object CallRecord * @return Object CallRecord
*/ */
private Object convertHistoryRecordToCallRecord(HistoryRecord hr) private CallRecord convertHistoryRecordToCallRecord(HistoryRecord hr)
{ {
CallRecordImpl result = new CallRecordImpl(); CallRecordImpl result = new CallRecordImpl();
LinkedList callParticipantIDs = null; List<String> callParticipantIDs = null;
LinkedList callParticipantStart = null; List<String> callParticipantStart = null;
LinkedList callParticipantEnd = null; List<String> callParticipantEnd = null;
LinkedList callParticipantStates = null; List<CallParticipantState> callParticipantStates = null;
// History structure // History structure
// 0 - callStart // 0 - callStart
@ -373,18 +376,17 @@ else if(propName.equals(STRUCTURE_NAMES[6]))
callParticipantStates = getStates(value); callParticipantStates = getStates(value);
} }
for (int i = 0; i < callParticipantIDs.size(); i++) final int callParticipantCount = callParticipantIDs.size();
for (int i = 0; i < callParticipantCount; i++)
{ {
CallParticipantRecordImpl cpr =
CallParticipantRecordImpl cpr = new CallParticipantRecordImpl( new CallParticipantRecordImpl(callParticipantIDs.get(i),
(String)callParticipantIDs.get(i), new Date(Long.parseLong(callParticipantStart.get(i))),
new Date(Long.parseLong((String)callParticipantStart.get(i))), new Date(Long.parseLong(callParticipantEnd.get(i))));
new Date(Long.parseLong((String)callParticipantEnd.get(i)))
);
// if there is no record about the states (backward compability) // if there is no record about the states (backward compability)
if(callParticipantStates != null) if (callParticipantStates != null)
cpr.setState((CallParticipantState)callParticipantStates.get(i)); cpr.setState(callParticipantStates.get(i));
result.getParticipantRecords().add(cpr); result.getParticipantRecords().add(cpr);
} }
@ -398,9 +400,9 @@ else if(propName.equals(STRUCTURE_NAMES[6]))
* @param str String * @param str String
* @return LinkedList * @return LinkedList
*/ */
private LinkedList getCSVs(String str) private List<String> getCSVs(String str)
{ {
LinkedList result = new LinkedList(); List<String> result = new LinkedList<String>();
StringTokenizer toks = new StringTokenizer(str, DELIM); StringTokenizer toks = new StringTokenizer(str, DELIM);
while(toks.hasMoreTokens()) while(toks.hasMoreTokens())
{ {
@ -411,20 +413,19 @@ private LinkedList getCSVs(String str)
/** /**
* Get the delimited strings and converts them to CallParticipantState * Get the delimited strings and converts them to CallParticipantState
*
* @param str String delimited string states * @param str String delimited string states
* @return LinkedList the converted values list * @return LinkedList the converted values list
*/ */
private LinkedList getStates(String str) private List<CallParticipantState> getStates(String str)
{ {
LinkedList result = new LinkedList(); List<CallParticipantState> result =
new LinkedList<CallParticipantState>();
LinkedList stateStrs = getCSVs(str); Collection<String> stateStrs = getCSVs(str);
Iterator iter = stateStrs.iterator(); for (String item : stateStrs)
while (iter.hasNext())
{ {
String item = (String) iter.next(); result.add(convertStateStringToState(item));
result.addLast(convertStateStringToState(item));
} }
return result; return result;
@ -564,10 +565,10 @@ private void writeCall(CallRecord callRecord, Contact source,
StringBuffer callParticipantEndTime = new StringBuffer(); StringBuffer callParticipantEndTime = new StringBuffer();
StringBuffer callParticipantStates = new StringBuffer(); StringBuffer callParticipantStates = new StringBuffer();
Iterator iter = callRecord.getParticipantRecords().iterator(); for (CallParticipantRecord item : callRecord
while (iter.hasNext()) .getParticipantRecords())
{ {
if(callParticipantIDs.length() > 0) if (callParticipantIDs.length() > 0)
{ {
callParticipantIDs.append(DELIM); callParticipantIDs.append(DELIM);
callParticipantStartTime.append(DELIM); callParticipantStartTime.append(DELIM);
@ -575,10 +576,11 @@ private void writeCall(CallRecord callRecord, Contact source,
callParticipantStates.append(DELIM); callParticipantStates.append(DELIM);
} }
CallParticipantRecord item = (CallParticipantRecord) iter.next();
callParticipantIDs.append(item.getParticipantAddress()); callParticipantIDs.append(item.getParticipantAddress());
callParticipantStartTime.append(String.valueOf(item.getStartTime().getTime())); callParticipantStartTime.append(String.valueOf(item
callParticipantEndTime.append(String.valueOf(item.getEndTime().getTime())); .getStartTime().getTime()));
callParticipantEndTime.append(String.valueOf(item.getEndTime()
.getTime()));
callParticipantStates.append(item.getState().getStateString()); callParticipantStates.append(item.getState().getStateString());
} }
@ -718,10 +720,10 @@ private void handleProviderRemoved(ProtocolProviderService provider)
public void addSearchProgressListener(CallHistorySearchProgressListener public void addSearchProgressListener(CallHistorySearchProgressListener
listener) listener)
{ {
synchronized(progressListeners){ synchronized (progressListeners)
HistorySearchProgressListener wrapperListener = {
new SearchProgressWrapper(listener); progressListeners
progressListeners.put(listener, wrapperListener); .put(listener, new SearchProgressWrapper(listener));
} }
} }
@ -739,22 +741,19 @@ public void removeSearchProgressListener(
} }
/** /**
* Add the registered CallHistorySearchProgressListeners * Add the registered CallHistorySearchProgressListeners to the given
* to the given HistoryReader * HistoryReader
* *
* @param reader HistoryReader * @param reader HistoryReader
* @param countContacts number of contacts will search * @param countContacts number of contacts will search
*/ */
private void addHistorySearchProgressListeners( private void addHistorySearchProgressListeners(HistoryReader reader,
HistoryReader reader, int countContacts) int countContacts)
{ {
synchronized(progressListeners) synchronized (progressListeners)
{ {
Iterator iter = progressListeners.values().iterator(); for (SearchProgressWrapper l : progressListeners.values())
while (iter.hasNext())
{ {
SearchProgressWrapper l =
(SearchProgressWrapper) iter.next();
l.contactCount = countContacts; l.contactCount = countContacts;
reader.addSearchProgressListener(l); reader.addSearchProgressListener(l);
} }
@ -762,20 +761,17 @@ private void addHistorySearchProgressListeners(
} }
/** /**
* Removes the registered CallHistorySearchProgressListeners * Removes the registered CallHistorySearchProgressListeners from the given
* from the given HistoryReader * HistoryReader
* *
* @param reader HistoryReader * @param reader HistoryReader
*/ */
private void removeHistorySearchProgressListeners(HistoryReader reader) private void removeHistorySearchProgressListeners(HistoryReader reader)
{ {
synchronized(progressListeners) synchronized (progressListeners)
{ {
Iterator iter = progressListeners.values().iterator(); for (SearchProgressWrapper l : progressListeners.values())
while (iter.hasNext())
{ {
SearchProgressWrapper l =
(SearchProgressWrapper) iter.next();
l.clear(); l.clear();
reader.removeSearchProgressListener(l); reader.removeSearchProgressListener(l);
} }
@ -784,16 +780,18 @@ private void removeHistorySearchProgressListeners(HistoryReader reader)
/** /**
* Gets all the history readers for the contacts in the given MetaContact * Gets all the history readers for the contacts in the given MetaContact
*
* @param contact MetaContact * @param contact MetaContact
* @return Hashtable * @return Hashtable
*/ */
private Hashtable getHistoryReaders(MetaContact contact) private Map<Contact, HistoryReader> getHistoryReaders(MetaContact contact)
{ {
Hashtable readers = new Hashtable(); Map<Contact, HistoryReader> readers =
Iterator iter = contact.getContacts(); new Hashtable<Contact, HistoryReader>();
Iterator<Contact> iter = contact.getContacts();
while (iter.hasNext()) while (iter.hasNext())
{ {
Contact item = (Contact) iter.next(); Contact item = iter.next();
try try
{ {
@ -929,17 +927,15 @@ private void handleParticipantRemoved(CallParticipant callParticipant,
/** /**
* Finding a CallRecord for the given call * Finding a CallRecord for the given call
*
* @param call Call * @param call Call
* @return CallRecord * @return CallRecord
*/ */
private CallRecordImpl findCallRecord(Call call) private CallRecordImpl findCallRecord(Call call)
{ {
Iterator iter = currentCallRecords.iterator(); for (CallRecordImpl item : currentCallRecords)
while (iter.hasNext())
{ {
CallRecordImpl item = (CallRecordImpl) iter.next(); if (item.getSourceCall().equals(call))
if(item.getSourceCall().equals(call))
return item; return item;
} }
@ -985,11 +981,10 @@ private void handleNewCall(Call sourceCall, String direction)
currentCallRecords.add(newRecord); currentCallRecords.add(newRecord);
// if has already perticipants Dispatch them // if has already perticipants Dispatch them
Iterator iter = sourceCall.getCallParticipants(); Iterator<CallParticipant> iter = sourceCall.getCallParticipants();
while (iter.hasNext()) while (iter.hasNext())
{ {
CallParticipant item = (CallParticipant) iter.next(); handleParticipantAdded(iter.next());
handleParticipantAdded(item);
} }
} }
@ -1060,16 +1055,15 @@ void clear()
} }
/** /**
* Used to compare CallRecords * Used to compare CallRecords and to be ordered in TreeSet according their
* and to be ordered in TreeSet according their timestamp * timestamp
*/ */
private class CallRecordComparator private class CallRecordComparator
implements Comparator implements Comparator<CallRecord>
{ {
public int compare(Object o1, Object o2) public int compare(CallRecord o1, CallRecord o2)
{ {
return ((CallRecord)o2).getStartTime(). return o2.getStartTime().compareTo(o1.getStartTime());
compareTo(((CallRecord)o1).getStartTime());
} }
} }

@ -1,3 +1,9 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.callhistory; package net.java.sip.communicator.impl.callhistory;
import java.util.*; import java.util.*;

@ -1,3 +1,9 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.callhistory; package net.java.sip.communicator.impl.callhistory;
import java.util.*; import java.util.*;
@ -54,12 +60,12 @@ public void setEndTime(Date endTime)
{ {
this.endTime = endTime; this.endTime = endTime;
Iterator iter = participantRecords.iterator(); for (CallParticipantRecord item : participantRecords)
while (iter.hasNext())
{ {
CallParticipantRecordImpl item = (CallParticipantRecordImpl) iter.next(); CallParticipantRecordImpl itemImpl =
if(item.getEndTime() == null) (CallParticipantRecordImpl) item;
item.setEndTime(endTime); if (item.getEndTime() == null)
itemImpl.setEndTime(endTime);
} }
} }

@ -25,24 +25,24 @@ public class ChangeEventDispatcher
/** /**
* All property change listeners registered so far. * All property change listeners registered so far.
*/ */
private Vector propertyChangeListeners; private List<PropertyChangeListener> propertyChangeListeners;
/** /**
* All listeners registered for vetoable change events. * All listeners registered for vetoable change events.
*/ */
private Vector vetoableChangeListeners; private List<VetoableChangeListener> vetoableChangeListeners;
/** /**
* Hashtable for managing property change listeners registered for specific * Hashtable for managing property change listeners registered for specific
* properties. Maps property names to PropertyChangeSupport objects. * properties. Maps property names to PropertyChangeSupport objects.
*/ */
private Hashtable propertyChangeChildren; private Map<String, ChangeEventDispatcher> propertyChangeChildren;
/** /**
* Hashtable for managing vetoable change listeners registered for specific * Hashtable for managing vetoable change listeners registered for specific
* properties. Maps property names to PropertyChangeSupport objects. * properties. Maps property names to PropertyChangeSupport objects.
*/ */
private Hashtable vetoableChangeChildren; private Map<String, ChangeEventDispatcher> vetoableChangeChildren;
/** /**
* The object to be provided as the "source" for any generated events. * The object to be provided as the "source" for any generated events.
@ -74,10 +74,10 @@ public synchronized void addPropertyChangeListener(
{ {
if (propertyChangeListeners == null) if (propertyChangeListeners == null)
{ {
propertyChangeListeners = new Vector(); propertyChangeListeners = new Vector<PropertyChangeListener>();
} }
propertyChangeListeners.addElement(listener); propertyChangeListeners.add(listener);
} }
/** /**
@ -95,7 +95,8 @@ public synchronized void addPropertyChangeListener(
{ {
if (propertyChangeChildren == null) if (propertyChangeChildren == null)
{ {
propertyChangeChildren = new Hashtable(); propertyChangeChildren =
new Hashtable<String, ChangeEventDispatcher>();
} }
ChangeEventDispatcher child = (ChangeEventDispatcher) propertyChangeChildren.get( ChangeEventDispatcher child = (ChangeEventDispatcher) propertyChangeChildren.get(
propertyName); propertyName);
@ -117,12 +118,10 @@ public synchronized void addPropertyChangeListener(
public synchronized void removePropertyChangeListener( public synchronized void removePropertyChangeListener(
PropertyChangeListener listener) PropertyChangeListener listener)
{ {
if (propertyChangeListeners != null)
if (propertyChangeListeners == null)
{ {
return; propertyChangeListeners.remove(listener);
} }
propertyChangeListeners.removeElement(listener);
} }
/** /**
@ -139,8 +138,7 @@ public synchronized void removePropertyChangeListener(
{ {
return; return;
} }
ChangeEventDispatcher child = (ChangeEventDispatcher) ChangeEventDispatcher child = propertyChangeChildren.get(propertyName);
propertyChangeChildren.get( propertyName );
if (child == null) if (child == null)
{ {
@ -160,10 +158,10 @@ public synchronized void addVetoableChangeListener(
{ {
if (vetoableChangeListeners == null) if (vetoableChangeListeners == null)
{ {
vetoableChangeListeners = new Vector(); vetoableChangeListeners = new Vector<VetoableChangeListener>();
} }
vetoableChangeListeners.addElement(listener); vetoableChangeListeners.add(listener);
} }
/** /**
@ -176,12 +174,10 @@ public synchronized void addVetoableChangeListener(
public synchronized void removeVetoableChangeListener( public synchronized void removeVetoableChangeListener(
VetoableChangeListener listener) VetoableChangeListener listener)
{ {
if (vetoableChangeListeners != null)
if (vetoableChangeListeners == null)
{ {
return; vetoableChangeListeners.remove(listener);
} }
vetoableChangeListeners.removeElement(listener);
} }
/** /**
@ -199,10 +195,9 @@ public synchronized void addVetoableChangeListener(
{ {
if (vetoableChangeChildren == null) if (vetoableChangeChildren == null)
{ {
vetoableChangeChildren = new Hashtable(); vetoableChangeChildren = new Hashtable<String, ChangeEventDispatcher>();
} }
ChangeEventDispatcher child = (ChangeEventDispatcher) vetoableChangeChildren.get( ChangeEventDispatcher child = vetoableChangeChildren.get(propertyName);
propertyName);
if (child == null) if (child == null)
{ {
child = new ChangeEventDispatcher(source); child = new ChangeEventDispatcher(source);
@ -225,8 +220,7 @@ public synchronized void removeVetoableChangeListener(
{ {
return; return;
} }
ChangeEventDispatcher child = (ChangeEventDispatcher) ChangeEventDispatcher child = vetoableChangeChildren.get( propertyName );
vetoableChangeChildren.get( propertyName );
if (child == null) if (child == null)
{ {
@ -287,27 +281,29 @@ public void fireVetoableChange(PropertyChangeEvent evt) throws
return; return;
} }
Vector targets = null; VetoableChangeListener[] targets = null;
ChangeEventDispatcher child = null; ChangeEventDispatcher child = null;
synchronized (this) synchronized (this)
{ {
if (vetoableChangeListeners != null) if (vetoableChangeListeners != null)
{ {
targets = (Vector) vetoableChangeListeners.clone(); targets =
vetoableChangeListeners
.toArray(new VetoableChangeListener[vetoableChangeListeners
.size()]);
} }
if (vetoableChangeChildren != null && propertyName != null) if (vetoableChangeChildren != null && propertyName != null)
{ {
child = (ChangeEventDispatcher)vetoableChangeChildren.get(propertyName); child = vetoableChangeChildren.get(propertyName);
} }
} }
if (vetoableChangeListeners != null) if (vetoableChangeListeners != null)
{ {
for (int i = 0; i < targets.size(); i++) for (int i = 0; i < targets.length; i++)
{ {
VetoableChangeListener target = VetoableChangeListener target = targets[i];
(VetoableChangeListener) targets.elementAt(i); // don't catch the exception - let it bounce to the caller.
//don't catch the exception - let it bounce to the caller.
target.vetoableChange(evt); target.vetoableChange(evt);
} }
} }
@ -357,19 +353,16 @@ public void firePropertyChange(PropertyChangeEvent evt)
if (propertyChangeListeners != null) if (propertyChangeListeners != null)
{ {
Iterator iterator = propertyChangeListeners.iterator(); for (PropertyChangeListener target : propertyChangeListeners)
while (iterator.hasNext())
{ {
PropertyChangeListener target =
(PropertyChangeListener) iterator.next();
target.propertyChange(evt); target.propertyChange(evt);
} }
} }
if (propertyChangeChildren != null && propertyName != null) if (propertyChangeChildren != null && propertyName != null)
{ {
ChangeEventDispatcher child = null; ChangeEventDispatcher child =
child = (ChangeEventDispatcher) propertyChangeChildren.get(propertyName); propertyChangeChildren.get(propertyName);
if (child != null) if (child != null)
{ {
child.firePropertyChange(evt); child.firePropertyChange(evt);
@ -393,8 +386,8 @@ public synchronized boolean hasPropertyChangeListeners(String propertyName)
} }
if (propertyChangeChildren != null) if (propertyChangeChildren != null)
{ {
ChangeEventDispatcher child = (ChangeEventDispatcher) propertyChangeChildren.get( ChangeEventDispatcher child =
propertyName); propertyChangeChildren.get(propertyName);
if (child != null && child.propertyChangeListeners != null) if (child != null && child.propertyChangeListeners != null)
{ {
return!child.propertyChangeListeners.isEmpty(); return!child.propertyChangeListeners.isEmpty();
@ -419,7 +412,7 @@ public synchronized boolean hasVetoableChangeListeners(String propertyName)
} }
if (vetoableChangeChildren != null) if (vetoableChangeChildren != null)
{ {
ChangeEventDispatcher child = (ChangeEventDispatcher) ChangeEventDispatcher child =
vetoableChangeChildren.get(propertyName); vetoableChangeChildren.get(propertyName);
if (child != null && child.vetoableChangeListeners != null) if (child != null && child.vetoableChangeListeners != null)

@ -6,12 +6,14 @@
*/ */
package net.java.sip.communicator.impl.configuration; package net.java.sip.communicator.impl.configuration;
import java.util.*;
import org.osgi.framework.*; import org.osgi.framework.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
/** /**
*
* @author Emil Ivov * @author Emil Ivov
*/ */
public class ConfigurationActivator public class ConfigurationActivator
@ -22,7 +24,7 @@ public class ConfigurationActivator
*/ */
public static BundleContext bundleContext; public static BundleContext bundleContext;
private Logger logger = Logger.getLogger(ConfigurationServiceImpl.class); private final Logger logger = Logger.getLogger(ConfigurationServiceImpl.class);
private ConfigurationServiceImpl impl = new ConfigurationServiceImpl(); private ConfigurationServiceImpl impl = new ConfigurationServiceImpl();
/** /**
@ -36,12 +38,12 @@ public void start(BundleContext bundleContext) throws Exception
{ {
logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]"); logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]");
this.bundleContext = bundleContext; ConfigurationActivator.bundleContext = bundleContext;
impl.start(); impl.start();
bundleContext.registerService(ConfigurationService.class.getName(), bundleContext.registerService(ConfigurationService.class.getName(),
impl, impl,
new java.util.Hashtable()); new Hashtable());
logger.debug("Service Impl: " + getClass().getName() + " [REGISTERED]"); logger.debug("Service Impl: " + getClass().getName() + " [REGISTERED]");
} }

@ -11,9 +11,6 @@
import javax.xml.parsers.*; import javax.xml.parsers.*;
import org.osgi.framework.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import net.java.sip.communicator.impl.configuration.xml.*; import net.java.sip.communicator.impl.configuration.xml.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.configuration.event.*; import net.java.sip.communicator.service.configuration.event.*;
@ -21,6 +18,10 @@
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.xml.*; import net.java.sip.communicator.util.xml.*;
import org.osgi.framework.*;
import org.w3c.dom.*;
import org.xml.sax.*;
/** /**
* A straight forward implementation of the ConfigurationService using an xml * A straight forward implementation of the ConfigurationService using an xml
* file for storing properties. Currently only String properties are * file for storing properties. Currently only String properties are
@ -34,7 +35,7 @@
public class ConfigurationServiceImpl public class ConfigurationServiceImpl
implements ConfigurationService implements ConfigurationService
{ {
private Logger logger = Logger.getLogger(ConfigurationServiceImpl.class); private final Logger logger = Logger.getLogger(ConfigurationServiceImpl.class);
/** /**
* The XML Document containing the configuration file this service loaded. * The XML Document containing the configuration file this service loaded.
@ -71,13 +72,13 @@ public class ConfigurationServiceImpl
/** /**
* Our event dispatcher. * Our event dispatcher.
*/ */
private ChangeEventDispatcher changeEventDispatcher = private final ChangeEventDispatcher changeEventDispatcher =
new ChangeEventDispatcher(this); new ChangeEventDispatcher(this);
/** /**
* The list of properties currently registered in the configuration service. * The list of properties currently registered in the configuration service.
*/ */
private Map properties = new Hashtable(); private Map<String, Object> properties = new Hashtable<String, Object>();
/** /**
* Contains the properties that were initially loaded from the configuration * Contains the properties that were initially loaded from the configuration
@ -86,8 +87,9 @@ public class ConfigurationServiceImpl
* that we could determine which properties are new and do not have a * that we could determine which properties are new and do not have a
* corresponding node in the XMLDocument object. * corresponding node in the XMLDocument object.
*/ */
private Map fileExtractedProperties = new Hashtable(); private Map<String, Object> fileExtractedProperties =
new Hashtable<String, Object>();
/** /**
* Indicates whether the service is started or stopped. * Indicates whether the service is started or stopped.
*/ */
@ -215,16 +217,12 @@ public void setProperty(String propertyName, Object property,
public void removeProperty(String propertyName) public void removeProperty(String propertyName)
throws PropertyVetoException throws PropertyVetoException
{ {
List childPropertyNames = List<String> childPropertyNames =
getPropertyNamesByPrefix(propertyName, false); getPropertyNamesByPrefix(propertyName, false);
Iterator propsIter = childPropertyNames.iterator();
//remove all properties //remove all properties
while (propsIter.hasNext()) for (String pName : childPropertyNames)
{ {
String pName = (String) propsIter.next();
removeProperty(pName); removeProperty(pName);
} }
@ -306,14 +304,12 @@ public Object getProperty(String propertyName)
* @return a <tt>java.util.List</tt>containing all property name String-s * @return a <tt>java.util.List</tt>containing all property name String-s
* matching the specified conditions. * matching the specified conditions.
*/ */
public List getPropertyNamesByPrefix(String prefix, boolean exactPrefixMatch) public List<String> getPropertyNamesByPrefix(String prefix, boolean exactPrefixMatch)
{ {
LinkedList resultKeySet = new LinkedList(); List<String> resultKeySet = new LinkedList<String>();
Iterator keys = properties.keySet().iterator();
while(keys.hasNext()) for (String key : properties.keySet())
{ {
String key = (String)keys.next();
int ix = key.lastIndexOf('.'); int ix = key.lastIndexOf('.');
if(ix == -1) if(ix == -1)
@ -472,7 +468,7 @@ void start()
public void reloadConfiguration() public void reloadConfiguration()
throws IOException, XMLException throws IOException, XMLException
{ {
properties = new Hashtable(); properties = new Hashtable<String, Object>();
this.configurationFile = null; this.configurationFile = null;
fileExtractedProperties = fileExtractedProperties =
@ -490,7 +486,7 @@ public void reloadConfiguration()
* @throws IOException if the specified file does not exist * @throws IOException if the specified file does not exist
* @throws XMLException if there is a problem with the file syntax. * @throws XMLException if there is a problem with the file syntax.
*/ */
Map loadConfiguration(File file) Map<String, Object> loadConfiguration(File file)
throws IOException, XMLException throws IOException, XMLException
{ {
// restore the file if needed // restore the file if needed
@ -508,7 +504,7 @@ Map loadConfiguration(File file)
DocumentBuilderFactory factory = DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance(); DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder(); DocumentBuilder builder = factory.newDocumentBuilder();
Map properties = new Hashtable(); Map<String, Object> properties = new Hashtable<String, Object>();
//if the file is empyt (or contains only sth insignificant) //if the file is empyt (or contains only sth insignificant)
//ifnore it and create a new document. //ifnore it and create a new document.
@ -545,7 +541,7 @@ Map loadConfiguration(File file)
//it is not highly probable that this might happen - so lets just //it is not highly probable that this might happen - so lets just
//log it. //log it.
logger.error("Error finding configuration for default parsers", ex); logger.error("Error finding configuration for default parsers", ex);
return new Hashtable(); return new Hashtable<String, Object>();
} }
} }
@ -614,12 +610,11 @@ private void storeConfiguration(File file)
//create in the document the properties that were added by other //create in the document the properties that were added by other
//bundles after the initial property load. //bundles after the initial property load.
Map newlyAddedProperties = cloneProperties(); Map<String, Object> newlyAddedProperties = cloneProperties();
//remove those that were originally there; //remove those that were originally there;
Iterator propNames = fileExtractedProperties.keySet().iterator(); for (String propName : fileExtractedProperties.keySet())
while (propNames.hasNext()) newlyAddedProperties.remove(propName);
newlyAddedProperties.remove(propNames.next());
this.processNewProperties(propertiesDocument, this.processNewProperties(propertiesDocument,
newlyAddedProperties); newlyAddedProperties);
@ -653,7 +648,7 @@ private void storeConfiguration(File file)
*/ */
private void loadNode(Node node, private void loadNode(Node node,
StringBuffer propertyNameBuff, StringBuffer propertyNameBuff,
Map properties) Map<String, Object> properties)
{ {
Node currentNode = null; Node currentNode = null;
NodeList children = node.getChildNodes(); NodeList children = node.getChildNodes();
@ -696,7 +691,6 @@ private void loadNode(Node node,
//load child nodes //load child nodes
loadNode(currentNode, newPropBuff, properties); loadNode(currentNode, newPropBuff, properties);
} }
} }
} }
@ -716,7 +710,7 @@ private void loadNode(Node node,
*/ */
private void updateNode(Node node, private void updateNode(Node node,
StringBuffer propertyNameBuff, StringBuffer propertyNameBuff,
Map properties) Map<String, Object> properties)
{ {
Node currentNode = null; Node currentNode = null;
NodeList children = node.getChildNodes(); NodeList children = node.getChildNodes();
@ -955,22 +949,21 @@ File createConfigurationFile()
} }
/** /**
* Creates new entries in the xml <tt>doc</tt> for every element in the * Creates new entries in the XML <tt>doc</tt> for every element in the
* <tt>newProperties</tt> table. * <tt>newProperties</tt> table.
* *
* @param doc the XML <tt>Document</tt> where the new entries should be * @param doc the XML <tt>Document</tt> where the new entries should be
* created * created
* @param newProperties the table containing the properties that are to be * @param newProperties the table containing the properties that are to be
* in troduced in the document. * introduced in the document.
*/ */
private void processNewProperties(Document doc, private void processNewProperties(Document doc,
Map newProperties) Map<String, Object> newProperties)
{ {
Iterator propNames = newProperties.keySet().iterator(); for (Map.Entry<String, Object> entry : newProperties.entrySet())
while(propNames.hasNext())
{ {
String key = (String)propNames.next(); String key = entry.getKey();
Object value = newProperties.get(key); Object value = entry.getValue();
boolean isSystem = value instanceof PropertyReference; boolean isSystem = value instanceof PropertyReference;
value = isSystem value = isSystem
?((PropertyReference)value).getValue() ?((PropertyReference)value).getValue()
@ -1114,21 +1107,21 @@ public Object getValue()
* Returns a copy of the Map containing all configuration properties * Returns a copy of the Map containing all configuration properties
* @return a Map clone of the current configuration property set. * @return a Map clone of the current configuration property set.
*/ */
private Map cloneProperties() private Map<String, Object> cloneProperties()
{ {
//at the time I'm writing this method we're implementing the // at the time I'm writing this method we're implementing the
//configuration service through the use of a hashtable. this may very // configuration service through the use of a hashtable. this may very
//well change one day so let's not be presumptuous // well change one day so let's not be presumptuous
if(properties instanceof Hashtable) if (properties instanceof Hashtable)
return (Map)((Hashtable)properties).clone(); return (Map<String, Object>) ((Hashtable) properties).clone();
if(properties instanceof HashMap) if (properties instanceof HashMap)
return (Map)((HashMap)properties).clone(); return (Map<String, Object>) ((HashMap) properties).clone();
if(properties instanceof TreeMap) if (properties instanceof TreeMap)
return (Map)((TreeMap)properties).clone(); return (Map<String, Object>) ((TreeMap) properties).clone();
//well you can't say that I didn't try!!! // well you can't say that I didn't try!!!
return new Hashtable(properties); return new Hashtable<String, Object>(properties);
} }
/** /**

@ -198,15 +198,13 @@ public void saveAccountWizard(ProtocolProviderService protocolProvider,
{ {
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService.getPropertyNamesByPrefix(prefix, true); List<String> accounts =
configService.getPropertyNamesByPrefix(prefix, true);
boolean savedAccount = false; boolean savedAccount = false;
Iterator accountsIter = accounts.iterator();
while (accountsIter.hasNext()) for (String accountRootPropName : accounts)
{ {
String accountRootPropName = (String) accountsIter.next();
String accountUID = configService.getString(accountRootPropName); String accountUID = configService.getString(accountRootPropName);
if (accountUID.equals(protocolProvider.getAccountID() if (accountUID.equals(protocolProvider.getAccountID()

@ -16,7 +16,6 @@
import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;

@ -92,32 +92,22 @@ public void addChatProvider(ProtocolProviderService pps)
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService List<String> accounts =
.getPropertyNamesByPrefix(prefix, true); configService.getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator();
while(accountsIter.hasNext()) {
String accountRootPropName
= (String) accountsIter.next();
for (String accountRootPropName : accounts) {
String accountUID String accountUID
= configService.getString(accountRootPropName); = configService.getString(accountRootPropName);
if(accountUID.equals(pps if(accountUID.equals(pps
.getAccountID().getAccountUniqueID())) .getAccountID().getAccountUniqueID()))
{ {
List chatRooms = configService List<String> chatRooms = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
accountRootPropName + ".chatRooms", true); accountRootPropName + ".chatRooms", true);
Iterator chatRoomsIter = chatRooms.iterator(); for (String chatRoomPropName : chatRooms)
while(chatRoomsIter.hasNext())
{ {
String chatRoomPropName
= (String) chatRoomsIter.next();
String chatRoomID String chatRoomID
= configService.getString(chatRoomPropName); = configService.getString(chatRoomPropName);

@ -737,14 +737,10 @@ public String getLastStatusString(ProtocolProviderService protocolProvider)
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService.getPropertyNamesByPrefix(prefix, true); List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator(); for (String accountRootPropName : accounts)
while (accountsIter.hasNext())
{ {
String accountRootPropName = (String) accountsIter.next();
String accountUID = configService.getString(accountRootPropName); String accountUID = configService.getString(accountRootPropName);
if (accountUID.equals(protocolProvider.getAccountID() if (accountUID.equals(protocolProvider.getAccountID()

@ -80,16 +80,12 @@ protected void saveStatusInformation(
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
boolean savedAccount = false; boolean savedAccount = false;
Iterator accountsIter = accounts.iterator();
while(accountsIter.hasNext()) {
String accountRootPropName
= (String) accountsIter.next();
for (String accountRootPropName : accounts) {
String accountUID String accountUID
= configService.getString(accountRootPropName); = configService.getString(accountRootPropName);

@ -618,35 +618,25 @@ public static void saveChatRoom( ProtocolProviderService protocolProvider,
{ {
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator(); for (String accountRootPropName : accounts)
while(accountsIter.hasNext())
{ {
String accountRootPropName
= (String) accountsIter.next();
String accountUID String accountUID
= configService.getString(accountRootPropName); = configService.getString(accountRootPropName);
if(accountUID.equals(protocolProvider if(accountUID.equals(protocolProvider
.getAccountID().getAccountUniqueID())) .getAccountID().getAccountUniqueID()))
{ {
List chatRooms = configService List<String> chatRooms = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
accountRootPropName + ".chatRooms", true); accountRootPropName + ".chatRooms", true);
Iterator chatRoomsIter = chatRooms.iterator();
boolean isExistingChatRoom = false; boolean isExistingChatRoom = false;
while(chatRoomsIter.hasNext()) for (String chatRoomPropName : chatRooms)
{ {
String chatRoomPropName
= (String) chatRoomsIter.next();
String chatRoomID String chatRoomID
= configService.getString(chatRoomPropName); = configService.getString(chatRoomPropName);
@ -698,33 +688,23 @@ public static void updateChatRoomStatus(
{ {
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator(); for (String accountRootPropName : accounts)
while(accountsIter.hasNext())
{ {
String accountRootPropName
= (String) accountsIter.next();
String accountUID String accountUID
= configService.getString(accountRootPropName); = configService.getString(accountRootPropName);
if(accountUID.equals(protocolProvider if(accountUID.equals(protocolProvider
.getAccountID().getAccountUniqueID())) .getAccountID().getAccountUniqueID()))
{ {
List chatRooms = configService List<String> chatRooms = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
accountRootPropName + ".chatRooms", true); accountRootPropName + ".chatRooms", true);
Iterator chatRoomsIter = chatRooms.iterator(); for (String chatRoomPropName : chatRooms)
while(chatRoomsIter.hasNext())
{ {
String chatRoomPropName
= (String) chatRoomsIter.next();
String chatRoomID String chatRoomID
= configService.getString(chatRoomPropName); = configService.getString(chatRoomPropName);
@ -755,33 +735,23 @@ public static String getChatRoomStatus(
{ {
String prefix = "net.java.sip.communicator.impl.gui.accounts"; String prefix = "net.java.sip.communicator.impl.gui.accounts";
List accounts = configService List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator(); for (String accountRootPropName : accounts)
while(accountsIter.hasNext())
{ {
String accountRootPropName
= (String) accountsIter.next();
String accountUID String accountUID
= configService.getString(accountRootPropName); = configService.getString(accountRootPropName);
if(accountUID.equals(protocolProvider if(accountUID.equals(protocolProvider
.getAccountID().getAccountUniqueID())) .getAccountID().getAccountUniqueID()))
{ {
List chatRooms = configService List<String> chatRooms = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
accountRootPropName + ".chatRooms", true); accountRootPropName + ".chatRooms", true);
Iterator chatRoomsIter = chatRooms.iterator(); for (String chatRoomPropName : chatRooms)
while(chatRoomsIter.hasNext())
{ {
String chatRoomPropName
= (String) chatRoomsIter.next();
String chatRoomID String chatRoomID
= configService.getString(chatRoomPropName); = configService.getString(chatRoomPropName);
@ -802,17 +772,12 @@ public static void storeContactListGroupStatus( String groupID,
{ {
String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups"; String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups";
List groups = configService List<String> groups = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
Iterator groupsIter = groups.iterator();
boolean isExistingGroup = false; boolean isExistingGroup = false;
while(groupsIter.hasNext()) for (String groupRootPropName : groups)
{ {
String groupRootPropName
= (String) groupsIter.next();
String storedID String storedID
= configService.getString(groupRootPropName); = configService.getString(groupRootPropName);
@ -847,16 +812,10 @@ public static boolean getContactListGroupStatus(String groupID)
{ {
String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups"; String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups";
List groups = configService List<String> groups = configService
.getPropertyNamesByPrefix(prefix, true); .getPropertyNamesByPrefix(prefix, true);
for (String groupRootPropName : groups)
Iterator groupsIter = groups.iterator();
while(groupsIter.hasNext())
{ {
String groupRootPropName
= (String) groupsIter.next();
String storedID String storedID
= configService.getString(groupRootPropName); = configService.getString(groupRootPropName);

@ -22,17 +22,18 @@
public class NotificationServiceImpl public class NotificationServiceImpl
implements NotificationService implements NotificationService
{ {
private Logger logger = Logger.getLogger(NotificationServiceImpl.class); private final Logger logger =
Logger.getLogger(NotificationServiceImpl.class);
private static String NOTIFICATIONS_PREFIX = private static String NOTIFICATIONS_PREFIX =
"net.java.sip.communicator.impl.notifications"; "net.java.sip.communicator.impl.notifications";
/** /**
* A set of all registered event notifications. * A set of all registered event notifications.
*/ */
private Hashtable notificationsTable = new Hashtable(); private final Hashtable<String, EventNotification> notificationsTable =
new Hashtable<String, EventNotification>();
/** /**
* A set of all registered event notifications. * A set of all registered event notifications.
*/ */
@ -453,16 +454,11 @@ private void saveNotification( String eventType,
String eventTypeNodeName = null; String eventTypeNodeName = null;
String actionTypeNodeName = null; String actionTypeNodeName = null;
List eventTypes = configService List<String> eventTypes = configService
.getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true); .getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true);
Iterator eventTypesIter = eventTypes.iterator(); for (String eventTypeRootPropName : eventTypes)
while(eventTypesIter.hasNext())
{ {
String eventTypeRootPropName
= (String) eventTypesIter.next();
String eType String eType
= configService.getString(eventTypeRootPropName); = configService.getString(eventTypeRootPropName);
@ -494,16 +490,11 @@ private void saveNotification( String eventType,
// Go through contained actions. // Go through contained actions.
String actionPrefix = eventTypeNodeName + ".actions"; String actionPrefix = eventTypeNodeName + ".actions";
List actionTypes = configService List<String> actionTypes = configService
.getPropertyNamesByPrefix(actionPrefix, true); .getPropertyNamesByPrefix(actionPrefix, true);
Iterator actionTypesIter = actionTypes.iterator(); for (String actionTypeRootPropName : actionTypes)
while(actionTypesIter.hasNext())
{ {
String actionTypeRootPropName
= (String) actionTypesIter.next();
String aType String aType
= configService.getString(actionTypeRootPropName); = configService.getString(actionTypeRootPropName);
@ -601,33 +592,23 @@ else if(actionHandler instanceof CommandNotificationHandler)
*/ */
private void loadNotifications() private void loadNotifications()
{ {
List eventTypes = configService List<String> eventTypes = configService
.getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true); .getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true);
Iterator eventTypesIter = eventTypes.iterator(); for (String eventTypeRootPropName : eventTypes)
while(eventTypesIter.hasNext())
{ {
String eventTypeRootPropName
= (String) eventTypesIter.next();
boolean isEventActive = boolean isEventActive =
isEnabled(eventTypeRootPropName + ".active"); isEnabled(eventTypeRootPropName + ".active");
String eventType String eventType
= configService.getString(eventTypeRootPropName); = configService.getString(eventTypeRootPropName);
List actions = configService List<String> actions = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
eventTypeRootPropName + ".actions", true); eventTypeRootPropName + ".actions", true);
Iterator actionsIter = actions.iterator();
while(actionsIter.hasNext()) for (String actionPropName : actions)
{ {
String actionPropName
= (String) actionsIter.next();
String actionType String actionType
= configService.getString(actionPropName); = configService.getString(actionPropName);
@ -722,7 +703,7 @@ private boolean isEnabled(String configProperty)
public void setActive(String eventType, boolean isActive) public void setActive(String eventType, boolean isActive)
{ {
EventNotification eventNotification EventNotification eventNotification
= (EventNotification) notificationsTable.get(eventType); = notificationsTable.get(eventType);
if(eventNotification == null) if(eventNotification == null)
return; return;
@ -841,33 +822,23 @@ else if (eventType.equals(
private boolean isDefault(String eventType, String actionType) private boolean isDefault(String eventType, String actionType)
{ {
List eventTypes = configService List<String> eventTypes = configService
.getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true); .getPropertyNamesByPrefix(NOTIFICATIONS_PREFIX, true);
Iterator eventTypesIter = eventTypes.iterator(); for (String eventTypeRootPropName : eventTypes)
while(eventTypesIter.hasNext())
{ {
String eventTypeRootPropName
= (String) eventTypesIter.next();
String eType String eType
= configService.getString(eventTypeRootPropName); = configService.getString(eventTypeRootPropName);
if(!eType.equals(eventType)) if(!eType.equals(eventType))
continue; continue;
List actions = configService List<String> actions = configService
.getPropertyNamesByPrefix( .getPropertyNamesByPrefix(
eventTypeRootPropName + ".actions", true); eventTypeRootPropName + ".actions", true);
Iterator actionsIter = actions.iterator();
while(actionsIter.hasNext()) for (String actionPropName : actions)
{ {
String actionPropName
= (String) actionsIter.next();
String aType String aType
= configService.getString(actionPropName); = configService.getString(actionPropName);

@ -8,8 +8,8 @@
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.callhistory.event.*; import net.java.sip.communicator.service.callhistory.event.*;
import net.java.sip.communicator.service.contactlist.*;
/** /**
* The Call History Service stores info about calls made from various protocols * The Call History Service stores info about calls made from various protocols
@ -29,7 +29,7 @@ public interface CallHistoryService
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByStartDate(MetaContact contact, Date startDate) public Collection<CallRecord> findByStartDate(MetaContact contact, Date startDate)
throws RuntimeException; throws RuntimeException;
/** /**
@ -42,7 +42,7 @@ public Collection findByStartDate(MetaContact contact, Date startDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByEndDate(MetaContact contact, Date endDate) public Collection<CallRecord> findByEndDate(MetaContact contact, Date endDate)
throws RuntimeException; throws RuntimeException;
/** /**
@ -56,7 +56,7 @@ public Collection findByEndDate(MetaContact contact, Date endDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByPeriod(MetaContact contact, Date startDate, Date endDate) public Collection<CallRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate)
throws RuntimeException; throws RuntimeException;
@ -67,7 +67,7 @@ public Collection findByPeriod(MetaContact contact, Date startDate, Date endDate
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByStartDate(Date startDate) public Collection<CallRecord> findByStartDate(Date startDate)
throws RuntimeException; throws RuntimeException;
/** /**
@ -77,7 +77,7 @@ public Collection findByStartDate(Date startDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByEndDate(Date endDate) public Collection<CallRecord> findByEndDate(Date endDate)
throws RuntimeException; throws RuntimeException;
/** /**
@ -88,7 +88,7 @@ public Collection findByEndDate(Date endDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByPeriod(Date startDate, Date endDate) public Collection<CallRecord> findByPeriod(Date startDate, Date endDate)
throws RuntimeException; throws RuntimeException;
/** /**
@ -101,7 +101,7 @@ public Collection findByPeriod(Date startDate, Date endDate)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findLast(MetaContact contact, int count) public Collection<CallRecord> findLast(MetaContact contact, int count)
throws RuntimeException; throws RuntimeException;
/** /**
@ -112,7 +112,7 @@ public Collection findLast(MetaContact contact, int count)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findLast(int count) public Collection<CallRecord> findLast(int count)
throws RuntimeException; throws RuntimeException;
/** /**
@ -121,7 +121,7 @@ public Collection findLast(int count)
* @return Collection of CallRecords with CallParticipantRecord * @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException * @throws RuntimeException
*/ */
public Collection findByParticipant(String address) public Collection<CallRecord> findByParticipant(String address)
throws RuntimeException; throws RuntimeException;
/** /**

@ -18,7 +18,10 @@ public class CallRecord
public final static String IN = "in"; public final static String IN = "in";
protected String direction = null; protected String direction = null;
protected Vector participantRecords = new Vector();
protected final List<CallParticipantRecord> participantRecords =
new Vector<CallParticipantRecord>();
protected Date startTime = null; protected Date startTime = null;
protected Date endTime = null; protected Date endTime = null;
@ -47,15 +50,14 @@ public CallRecord(
/** /**
* Finds a Participant with the supplied address * Finds a Participant with the supplied address
*
* @param address String * @param address String
* @return CallParticipantRecord * @return CallParticipantRecord
*/ */
public CallParticipantRecord findParticipantRecord(String address) public CallParticipantRecord findParticipantRecord(String address)
{ {
Iterator iter = participantRecords.iterator(); for (CallParticipantRecord item : participantRecords)
while (iter.hasNext())
{ {
CallParticipantRecord item = (CallParticipantRecord) iter.next();
if (item.getParticipantAddress().equals(address)) if (item.getParticipantAddress().equals(address))
return item; return item;
} }
@ -86,7 +88,7 @@ public Date getEndTime()
* Return Vector of CallParticipantRecords * Return Vector of CallParticipantRecords
* @return Vector * @return Vector
*/ */
public Vector getParticipantRecords() public List<CallParticipantRecord> getParticipantRecords()
{ {
return participantRecords; return participantRecords;
} }

@ -131,7 +131,7 @@ public void removeProperty(String propertyName)
* @return a <tt>java.util.List</tt>containing all property name String-s * @return a <tt>java.util.List</tt>containing all property name String-s
* matching the specified conditions. * matching the specified conditions.
*/ */
public List getPropertyNamesByPrefix(String prefix, public List<String> getPropertyNamesByPrefix(String prefix,
boolean exactPrefixMatch); boolean exactPrefixMatch);
/** /**

@ -245,7 +245,7 @@ public void testGetPropertyNamesByPrefix() throws PropertyVetoException
, new Object()); , new Object());
//try an exact match first //try an exact match first
List propertyNames List<String> propertyNames
= configurationService.getPropertyNamesByPrefix(prefix, true); = configurationService.getPropertyNamesByPrefix(prefix, true);
assertTrue("Returned list did not contain all property names. " assertTrue("Returned list did not contain all property names. "

Loading…
Cancel
Save