[Minor] using Deque instead of Stack

This commit is contained in:
Robert von Burg 2014-02-01 13:47:31 +01:00
parent 9620d374ed
commit 13db5f5cc8
1 changed files with 8 additions and 7 deletions

View File

@ -17,13 +17,14 @@ package li.strolch.runtime.configuration;
import java.io.File; import java.io.File;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Stack;
import li.strolch.model.Locator; import li.strolch.model.Locator;
import li.strolch.model.Locator.LocatorBuilder; import li.strolch.model.Locator.LocatorBuilder;
@ -40,11 +41,11 @@ public class ConfigurationSaxParser extends DefaultHandler {
private ConfigurationBuilder configurationBuilder; private ConfigurationBuilder configurationBuilder;
private LocatorBuilder locatorBuilder; private LocatorBuilder locatorBuilder;
private Stack<ElementHandler> delegateHandlers; private Deque<ElementHandler> delegateHandlers;
public ConfigurationSaxParser() { public ConfigurationSaxParser() {
this.locatorBuilder = new LocatorBuilder(); this.locatorBuilder = new LocatorBuilder();
this.delegateHandlers = new Stack<>(); this.delegateHandlers = new ArrayDeque<>();
this.configurationBuilder = new ConfigurationBuilder(); this.configurationBuilder = new ConfigurationBuilder();
} }
@ -63,24 +64,24 @@ public class ConfigurationSaxParser extends DefaultHandler {
case "StrolchConfiguration/Runtime": //$NON-NLS-1$ case "StrolchConfiguration/Runtime": //$NON-NLS-1$
RuntimeHandler runtimeHandler = new RuntimeHandler(this.configurationBuilder, locator); RuntimeHandler runtimeHandler = new RuntimeHandler(this.configurationBuilder, locator);
this.delegateHandlers.addElement(runtimeHandler); this.delegateHandlers.push(runtimeHandler);
break; break;
case "StrolchConfiguration/Runtime/Properties": //$NON-NLS-1$ case "StrolchConfiguration/Runtime/Properties": //$NON-NLS-1$
PropertiesHandler runtimePropertiesHandler = new PropertiesHandler(this.configurationBuilder, locator); PropertiesHandler runtimePropertiesHandler = new PropertiesHandler(this.configurationBuilder, locator);
this.delegateHandlers.addElement(runtimePropertiesHandler); this.delegateHandlers.push(runtimePropertiesHandler);
this.configurationBuilder.setPropertyBuilder(this.configurationBuilder.runtimeBuilder()); this.configurationBuilder.setPropertyBuilder(this.configurationBuilder.runtimeBuilder());
break; break;
case "StrolchConfiguration/Component": //$NON-NLS-1$ case "StrolchConfiguration/Component": //$NON-NLS-1$
this.configurationBuilder.nextComponentBuilder(); this.configurationBuilder.nextComponentBuilder();
ComponentHandler componentHandler = new ComponentHandler(this.configurationBuilder, locator); ComponentHandler componentHandler = new ComponentHandler(this.configurationBuilder, locator);
this.delegateHandlers.addElement(componentHandler); this.delegateHandlers.push(componentHandler);
break; break;
case "StrolchConfiguration/Component/Properties": //$NON-NLS-1$ case "StrolchConfiguration/Component/Properties": //$NON-NLS-1$
PropertiesHandler componentPropertiesHandler = new PropertiesHandler(this.configurationBuilder, locator); PropertiesHandler componentPropertiesHandler = new PropertiesHandler(this.configurationBuilder, locator);
this.delegateHandlers.addElement(componentPropertiesHandler); this.delegateHandlers.push(componentPropertiesHandler);
this.configurationBuilder.setPropertyBuilder(this.configurationBuilder.componentBuilder()); this.configurationBuilder.setPropertyBuilder(this.configurationBuilder.componentBuilder());
break; break;