1 package org.jaxen; 2 3 48 49 import java.io.Serializable ; 50 import java.util.ArrayList ; 51 import java.util.Collections ; 52 import java.util.List ; 53 54 77 public class Context 78 implements Serializable 79 { 80 84 85 private ContextSupport contextSupport; 86 87 88 private List nodeSet; 89 90 91 private int size; 92 93 94 private int position; 95 96 100 104 public Context(ContextSupport contextSupport) 105 { 106 this.contextSupport = contextSupport; 107 this.nodeSet = Collections.EMPTY_LIST; 108 } 109 110 114 118 public void setNodeSet(List nodeSet) 119 { 120 this.nodeSet = nodeSet; 121 } 122 123 127 public List getNodeSet() 128 { 129 return this.nodeSet; 130 } 131 132 136 public void setContextSupport(ContextSupport contextSupport) 137 { 138 this.contextSupport = contextSupport; 139 } 140 141 145 public ContextSupport getContextSupport() 146 { 147 return this.contextSupport; 148 } 149 150 154 public Navigator getNavigator() 155 { 156 return getContextSupport().getNavigator(); 157 } 158 159 165 public String translateNamespacePrefixToUri(String prefix) 166 { 167 return getContextSupport().translateNamespacePrefixToUri( prefix ); 168 } 169 170 180 public Object getVariableValue(String namespaceURI, 181 String prefix, 182 String localName) 183 throws UnresolvableException 184 { 185 return getContextSupport().getVariableValue( namespaceURI, 186 prefix, 187 localName ); 188 } 189 190 200 public Function getFunction(String namespaceURI, 201 String prefix, 202 String localName) 203 throws UnresolvableException 204 { 205 return getContextSupport().getFunction( namespaceURI, 206 prefix, 207 localName ); 208 } 209 210 214 218 public void setSize(int size) 219 { 220 this.size = size; 221 } 222 223 227 public int getSize() 228 { 229 return this.size; 230 } 231 232 236 public void setPosition(int position) 237 { 238 this.position = position; 239 } 240 241 245 public int getPosition() 246 { 247 return this.position; 248 } 249 250 254 258 public Context duplicate() 259 { 260 Context dupe = new Context( getContextSupport() ); 261 262 List thisNodeSet = getNodeSet(); 263 264 if ( thisNodeSet != null ) 265 { 266 List dupeNodeSet = new ArrayList ( thisNodeSet.size() ); 267 dupeNodeSet.addAll( thisNodeSet ); 268 dupe.setNodeSet( dupeNodeSet ); 269 } 270 271 return dupe; 272 } 273 } 274 | Popular Tags |