Skip to content
Snippets Groups Projects
Commit 6228c9f2 authored by Gwenaelle ABEILLE's avatar Gwenaelle ABEILLE
Browse files

ignore case for attributes names

parent d04fec4a
Branches
Tags
No related merge requests found
package Common.Archiver.Collector;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;
import fr.esrf.tangoatk.core.ErrorEvent;
import fr.soleil.commonarchivingapi.ArchivingTools.Diary.ILogger;
......@@ -8,7 +9,7 @@ import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.ScalarEvent;
public abstract class ArchiverCollector {
// This hashtable contains the mode counters by attribute
private final Hashtable<String, ModesCounters> m_attributeModeHandlerHastable;
private final Map<String, ModesCounters> attributeModeCounterMap = new HashMap<String, ModesCounters>();
// Diary file
protected ILogger m_logger;
......@@ -19,7 +20,6 @@ public abstract class ArchiverCollector {
protected ModeHandler m_modeHandler;
public ArchiverCollector(ModeHandler modeHandler) {
m_attributeModeHandlerHastable = new Hashtable<String, ModesCounters>();
m_modeHandler = modeHandler;
}
......@@ -28,27 +28,30 @@ public abstract class ArchiverCollector {
}
/* Allows to indicate to the collector that a new attribute must be managed */
protected void addAttribute(String name) {
if (m_attributeModeHandlerHastable.containsKey(name)) {
protected synchronized void addAttribute(String name) {
String lower = name.toLowerCase();
if (attributeModeCounterMap.containsKey(lower)) {
m_logger.trace(ILogger.LEVEL_WARNING, "ArchiverCollector.addAttribute : The attribute " + name
+ "already exists in the map ==> Counter Re-init");
m_attributeModeHandlerHastable.get(name).init();
attributeModeCounterMap.get(lower).init();
} else {
m_attributeModeHandlerHastable.put(name, new ModesCounters());
attributeModeCounterMap.put(lower, new ModesCounters());
}
}
/* Allows to indicate to the collector that an attribute has been stopped */
protected void removeAttribute(String name) {
if (m_attributeModeHandlerHastable.containsKey(name)) {
m_attributeModeHandlerHastable.remove(name);
protected synchronized void removeAttribute(String name) {
String lower = name.toLowerCase();
if (attributeModeCounterMap.containsKey(lower)) {
attributeModeCounterMap.remove(lower);
}
}
/* Allows to retrieve the ModesCounters object of one attribute */
protected ModesCounters getModeCounter(String name) {
if (m_attributeModeHandlerHastable.containsKey(name)) {
return m_attributeModeHandlerHastable.get(name);
String lower = name.toLowerCase();
if (attributeModeCounterMap.containsKey(lower)) {
return attributeModeCounterMap.get(lower);
}
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment