1 package com.icl.saxon.tree; 2 3 14 15 public class SystemIdMap { 16 17 private int[] sequenceNumbers; 18 private String [] uris; 19 private int allocated; 20 21 public SystemIdMap() { 22 sequenceNumbers = new int[10]; 23 uris = new String [10]; 24 allocated = 0; 25 } 26 27 30 31 public void setSystemId(int sequence, String uri) { 32 if (allocated>0 && uri.equals(uris[allocated-1])) { 34 return; 35 } 36 if (sequenceNumbers.length <= allocated + 1) { 37 int[] s = new int[allocated * 2]; 38 String [] u = new String [allocated * 2]; 39 System.arraycopy(sequenceNumbers, 0, s, 0, allocated); 40 System.arraycopy(uris, 0, u, 0, allocated); 41 sequenceNumbers = s; 42 uris = u; 43 } 44 sequenceNumbers[allocated] = sequence; 45 uris[allocated] = uri; 46 allocated++; 47 } 48 49 52 53 public String getSystemId(int sequence) { 54 for (int i=1; i<allocated; i++) { 56 if (sequenceNumbers[i] > sequence) { 57 return uris[i-1]; 58 } 59 } 60 return uris[allocated-1]; 61 } 62 63 64 } 65 66 | Popular Tags |