|
|||||||||||||||||||
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
PrefixMappings.java | 0% | 0% | 0% | 0% |
|
1 |
/* |
|
2 |
* JBind |
|
3 |
* |
|
4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
5 |
* |
|
6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
8 |
* 'Apache Software License V 1.1'. |
|
9 |
*/ |
|
10 |
package org.jbind.xml.base; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.HashMap; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
|
16 |
|
|
17 |
public class PrefixMappings implements IPrefixMappings { |
|
18 |
|
|
19 |
private Map myCurrentMapping = new HashMap(17); |
|
20 |
private Map myBookKeeping = new HashMap(17); |
|
21 |
|
|
22 | 0 |
public PrefixMappings() {} |
23 |
|
|
24 | 0 |
public Map getCurrentMapping() { |
25 | 0 |
return myCurrentMapping; |
26 |
} |
|
27 |
|
|
28 | 0 |
public void startPrefixMapping(String aPrefix, String anUri) { |
29 | 0 |
myCurrentMapping = new HashMap(myCurrentMapping); |
30 | 0 |
myCurrentMapping.put(aPrefix, anUri); |
31 | 0 |
List l = (List)myBookKeeping.get(aPrefix); |
32 | 0 |
if (null == l) { |
33 | 0 |
l = new ArrayList(); |
34 | 0 |
myBookKeeping.put(aPrefix, l); |
35 |
} |
|
36 | 0 |
l.add(anUri); |
37 |
} |
|
38 |
|
|
39 | 0 |
public void endPrefixMapping(String aPrefix) { |
40 | 0 |
myCurrentMapping = new HashMap(myCurrentMapping); |
41 | 0 |
myCurrentMapping.remove(aPrefix); |
42 | 0 |
List l = (List)myBookKeeping.get(aPrefix); |
43 |
// Check if there was a previous mapping and restore it. |
|
44 | 0 |
int p = l.size() - 1; |
45 | 0 |
if (p >= 0) { |
46 | 0 |
myCurrentMapping.put(aPrefix, l.get(p)); |
47 | 0 |
l.remove(p); |
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
} |
|
52 |
|
|