1 package net.sf.saxon.om; 2 3 import java.util.List ; 4 import java.util.Iterator ; 5 import java.util.ArrayList ; 6 7 11 public class NamespaceResolverAsDeclarations implements NamespaceDeclarations { 12 13 private NamePool pool; 14 private NamespaceResolver resolver; 15 private List prefixes; 16 17 public NamespaceResolverAsDeclarations(NamePool pool, NamespaceResolver resolver) { 18 this.pool = pool; 19 this.resolver = resolver; 20 prefixes = new ArrayList (10); 21 Iterator iter = resolver.iteratePrefixes(); 22 while (iter.hasNext()) { 23 prefixes.add(iter.next()); 24 } 25 } 26 27 30 31 public int getLength() { 32 return prefixes.size(); 33 } 34 35 44 45 public String getPrefix(int index) { 46 return (String )prefixes.get(index); 47 } 48 49 58 59 public String getURI(int index) { 60 return resolver.getURIForPrefix((String )prefixes.get(index), true); 61 } 62 63 76 77 public int getNamespaceCode(int index) { 78 String prefix = getPrefix(index); 79 String uri = getURI(index); 80 return pool.allocateNamespaceCode(prefix, uri); 81 } 82 83 92 93 public int[] getNamespaceCodes(int[] buffer) { 94 if (buffer.length < getLength()) { 95 buffer = new int[getLength()]; 96 } 97 for (int i=0; i<getLength(); i++) { 98 buffer[i] = getNamespaceCode(i); 99 } 100 return buffer; 101 } 102 } 103 104 | Popular Tags |