comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/StackFrames.java @ 372:fc3cf0ef777e

Added meta data service. flys-artifacts/trunk@1781 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 29 Apr 2011 15:10:44 +0000
parents
children 7c018f466d6d
comparison
equal deleted inserted replaced
371:dfbb3d50b0bd 372:fc3cf0ef777e
1 package de.intevation.flys.artifacts.services.meta;
2
3 import java.util.Map;
4 import java.util.List;
5 import java.util.HashMap;
6 import java.util.ArrayList;
7
8 public class StackFrames
9 {
10 protected List<Map<String, Object>> frames;
11
12 public StackFrames() {
13 frames = new ArrayList<Map<String, Object>>();
14 }
15
16 public void enter() {
17 frames.add(new HashMap<String, Object>());
18 }
19
20 public void leave() {
21 frames.remove(frames.size()-1);
22 }
23
24 public void put(String [] keys, Object [] values) {
25 Map<String, Object> top = frames.get(frames.size()-1);
26 for (int i = 0; i < keys.length; ++i) {
27 top.put(keys[i], values[i]);
28 }
29 }
30
31 public Object get(String key) {
32 return get(key, null);
33 }
34
35 public Object get(String key, Object def) {
36
37 for (int i = frames.size()-1; i >= 0; --i) {
38 Map<String, Object> frame = frames.get(i);
39 if (frame.containsKey(key)) {
40 return frame.get(key);
41 }
42 }
43
44 return def;
45 }
46 }
47 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org