Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 18 package org.apache.batik.dom.util; 19 20 26 public class HashTableStack { 27 30 protected Link current = new Link(null); 31 32 35 public HashTableStack() { 36 } 37 38 41 public void push() { 42 current.pushCount++; 43 } 44 45 48 public void pop() { 49 if (current.pushCount-- == 0) { 50 current = current.next; 51 } 52 } 53 54 57 public String put(String s, String v) { 58 if (current.pushCount != 0) { 59 current.pushCount--; 60 current = new Link(current); 61 } 62 if (s.length() == 0) current.defaultStr = v; 63 return (String )current.table.put(s, v); 64 } 65 66 69 public String get(String s) { 70 if (s.length() == 0) return current.defaultStr; 71 72 for (Link l = current; l != null; l = l.next) { 73 String uri = (String )l.table.get(s); 74 if (uri != null) { 75 return uri; 76 } 77 } 78 return null; 79 } 80 81 84 protected static class Link { 85 88 public HashTable table; 89 90 93 public Link next; 94 95 98 public String defaultStr; 99 100 104 public int pushCount = 0; 105 106 109 public Link(Link n) { 110 table = new HashTable(); 111 next = n; 112 if (next != null) 113 defaultStr = next.defaultStr; 114 } 115 } 116 } 117
| Popular Tags
|