1 package net.sf.saxon.om; 2 3 7 8 public class NamespaceDeclarationsImpl implements NamespaceDeclarations { 9 10 private NamePool namePool; 11 private int[] namespaceCodes; 12 private int used; 13 14 private static final int[] emptyArray = new int[0]; 15 16 public NamespaceDeclarationsImpl() {}; 17 18 28 29 public NamespaceDeclarationsImpl(NamePool pool, int[] codes) { 30 this.namePool = pool; 31 setNamespaceCodes(codes); 32 } 33 34 37 38 public void setNamePool(NamePool pool) { 39 this.namePool = pool; 40 } 41 42 51 52 public void setNamespaceCodes(int[] codes) { 53 if (codes == null) { 54 codes = emptyArray; 55 } 56 this.namespaceCodes = codes; 57 used = codes.length; 58 for (int i=0; i<codes.length; i++) { 59 if (codes[i] == -1) { 60 used = i; 61 break; 62 } 63 } 64 } 65 66 75 76 public int[] getNamespaceCodes(int[] buffer) { 77 return namespaceCodes; 78 } 79 80 83 84 public int getLength() { 85 return used; 86 } 87 88 97 98 public String getPrefix(int index) { 99 return namePool.getPrefixFromNamespaceCode(namespaceCodes[index]); 100 } 101 102 111 112 public String getURI(int index) { 113 return namePool.getURIFromNamespaceCode(namespaceCodes[index]); 114 } 115 116 129 130 public int getNamespaceCode(int index) { 131 return namespaceCodes[index]; 132 } 133 } 134 135 136 | Popular Tags |