001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.0.12 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * An interface to an XML input stream. 013 */ 014 015public class XMLInputStream { 016 private long swigCPtr; 017 protected boolean swigCMemOwn; 018 019 protected XMLInputStream(long cPtr, boolean cMemoryOwn) 020 { 021 swigCMemOwn = cMemoryOwn; 022 swigCPtr = cPtr; 023 } 024 025 protected static long getCPtr(XMLInputStream obj) 026 { 027 return (obj == null) ? 0 : obj.swigCPtr; 028 } 029 030 protected static long getCPtrAndDisown (XMLInputStream obj) 031 { 032 long ptr = 0; 033 034 if (obj != null) 035 { 036 ptr = obj.swigCPtr; 037 obj.swigCMemOwn = false; 038 } 039 040 return ptr; 041 } 042 043 protected void finalize() { 044 delete(); 045 } 046 047 public synchronized void delete() { 048 if (swigCPtr != 0) { 049 if (swigCMemOwn) { 050 swigCMemOwn = false; 051 libsbmlJNI.delete_XMLInputStream(swigCPtr); 052 } 053 swigCPtr = 0; 054 } 055 } 056 057 058/** 059 * Creates a new {@link XMLInputStream}. 060 <p> 061 * <code>content</code> the source of the stream. 062 <p> 063 * <code>isFile</code> boolean flag to indicate whether <code>content</code> is a file name. 064 * If <code>true</code>, <code>content</code> is assumed to be the file from which the XML 065 * content is to be read. If <code>false</code>, <code>content</code> is taken to be a 066 * string that <em>is</em> the content to be read. 067 <p> 068 * <code>library</code> the name of the parser library to use. 069 <p> 070 * <code>errorLog</code> the {@link XMLErrorLog} object to use. 071 <p> 072 * 073</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 074The native C++ implementation of this method defines a default argument 075value. In the documentation generated for different libSBML language 076bindings, you may or may not see corresponding arguments in the method 077declarations. For example, in Java and C#, a default argument is handled by 078declaring two separate methods, with one of them having the argument and 079the other one lacking the argument. However, the libSBML documentation will 080be <em>identical</em> for both methods. Consequently, if you are reading 081this and do not see an argument even though one is described, please look 082for descriptions of other variants of this method near where this one 083appears in the documentation. 084</dd></dl> 085 086 */ public 087 XMLInputStream(String content, boolean isFile, String library, XMLErrorLog errorLog) { 088 this(libsbmlJNI.new_XMLInputStream__SWIG_0(content, isFile, library, XMLErrorLog.getCPtr(errorLog), errorLog), true); 089 } 090 091 092/** 093 * Creates a new {@link XMLInputStream}. 094 <p> 095 * <code>content</code> the source of the stream. 096 <p> 097 * <code>isFile</code> boolean flag to indicate whether <code>content</code> is a file name. 098 * If <code>true</code>, <code>content</code> is assumed to be the file from which the XML 099 * content is to be read. If <code>false</code>, <code>content</code> is taken to be a 100 * string that <em>is</em> the content to be read. 101 <p> 102 * <code>library</code> the name of the parser library to use. 103 <p> 104 * <code>errorLog</code> the {@link XMLErrorLog} object to use. 105 <p> 106 * 107</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 108The native C++ implementation of this method defines a default argument 109value. In the documentation generated for different libSBML language 110bindings, you may or may not see corresponding arguments in the method 111declarations. For example, in Java and C#, a default argument is handled by 112declaring two separate methods, with one of them having the argument and 113the other one lacking the argument. However, the libSBML documentation will 114be <em>identical</em> for both methods. Consequently, if you are reading 115this and do not see an argument even though one is described, please look 116for descriptions of other variants of this method near where this one 117appears in the documentation. 118</dd></dl> 119 120 */ public 121 XMLInputStream(String content, boolean isFile, String library) { 122 this(libsbmlJNI.new_XMLInputStream__SWIG_1(content, isFile, library), true); 123 } 124 125 126/** 127 * Creates a new {@link XMLInputStream}. 128 <p> 129 * <code>content</code> the source of the stream. 130 <p> 131 * <code>isFile</code> boolean flag to indicate whether <code>content</code> is a file name. 132 * If <code>true</code>, <code>content</code> is assumed to be the file from which the XML 133 * content is to be read. If <code>false</code>, <code>content</code> is taken to be a 134 * string that <em>is</em> the content to be read. 135 <p> 136 * <code>library</code> the name of the parser library to use. 137 <p> 138 * <code>errorLog</code> the {@link XMLErrorLog} object to use. 139 <p> 140 * 141</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 142The native C++ implementation of this method defines a default argument 143value. In the documentation generated for different libSBML language 144bindings, you may or may not see corresponding arguments in the method 145declarations. For example, in Java and C#, a default argument is handled by 146declaring two separate methods, with one of them having the argument and 147the other one lacking the argument. However, the libSBML documentation will 148be <em>identical</em> for both methods. Consequently, if you are reading 149this and do not see an argument even though one is described, please look 150for descriptions of other variants of this method near where this one 151appears in the documentation. 152</dd></dl> 153 154 */ public 155 XMLInputStream(String content, boolean isFile) { 156 this(libsbmlJNI.new_XMLInputStream__SWIG_2(content, isFile), true); 157 } 158 159 160/** 161 * Creates a new {@link XMLInputStream}. 162 <p> 163 * <code>content</code> the source of the stream. 164 <p> 165 * <code>isFile</code> boolean flag to indicate whether <code>content</code> is a file name. 166 * If <code>true</code>, <code>content</code> is assumed to be the file from which the XML 167 * content is to be read. If <code>false</code>, <code>content</code> is taken to be a 168 * string that <em>is</em> the content to be read. 169 <p> 170 * <code>library</code> the name of the parser library to use. 171 <p> 172 * <code>errorLog</code> the {@link XMLErrorLog} object to use. 173 <p> 174 * 175</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 176The native C++ implementation of this method defines a default argument 177value. In the documentation generated for different libSBML language 178bindings, you may or may not see corresponding arguments in the method 179declarations. For example, in Java and C#, a default argument is handled by 180declaring two separate methods, with one of them having the argument and 181the other one lacking the argument. However, the libSBML documentation will 182be <em>identical</em> for both methods. Consequently, if you are reading 183this and do not see an argument even though one is described, please look 184for descriptions of other variants of this method near where this one 185appears in the documentation. 186</dd></dl> 187 188 */ public 189 XMLInputStream(String content) { 190 this(libsbmlJNI.new_XMLInputStream__SWIG_3(content), true); 191 } 192 193 194/** 195 * Returns the encoding of the XML stream. 196 <p> 197 * @return the encoding of the XML stream. 198 */ public 199 String getEncoding() { 200 return libsbmlJNI.XMLInputStream_getEncoding(swigCPtr, this); 201 } 202 203 204/** 205 * Returns the version of the XML stream. 206 <p> 207 * @return the version of the XML stream. 208 */ public 209 String getVersion() { 210 return libsbmlJNI.XMLInputStream_getVersion(swigCPtr, this); 211 } 212 213 214/** 215 * Returns an {@link XMLErrorLog} which can be used to log XML parse errors and 216 * other validation errors (and messages). 217 <p> 218 * @return an {@link XMLErrorLog} which can be used to log XML parse errors and 219 * other validation errors (and messages). 220 */ public 221 XMLErrorLog getErrorLog() { 222 long cPtr = libsbmlJNI.XMLInputStream_getErrorLog(swigCPtr, this); 223 return (cPtr == 0) ? null : new XMLErrorLog(cPtr, false); 224 } 225 226 227/** 228 * Returns true if end of file (stream) has been reached, false 229 * otherwise. 230 <p> 231 * @return true if end of file (stream) has been reached, false 232 * otherwise. 233 */ public 234 boolean isEOF() { 235 return libsbmlJNI.XMLInputStream_isEOF(swigCPtr, this); 236 } 237 238 239/** 240 * Returns true if a fatal error occurred while reading from this stream. 241 <p> 242 * @return true if a fatal error occurred while reading from this stream. 243 */ public 244 boolean isError() { 245 return libsbmlJNI.XMLInputStream_isError(swigCPtr, this); 246 } 247 248 249/** 250 * Returns true if the stream is in a good state (i.e. isEOF() and 251 * isError() are both false), false otherwise. 252 <p> 253 * @return true if the stream is in a good state (i.e. isEOF() and 254 * isError() are both false), false otherwise. 255 */ public 256 boolean isGood() { 257 return libsbmlJNI.XMLInputStream_isGood(swigCPtr, this); 258 } 259 260 261/** 262 * Consumes the next {@link XMLToken} and return it. 263 <p> 264 * @return the next {@link XMLToken} or EOF (XMLToken.isEOF() == true). 265 */ public 266 XMLToken next() { 267 return new XMLToken(libsbmlJNI.XMLInputStream_next(swigCPtr, this), true); 268 } 269 270 271/** 272 * Returns the next {@link XMLToken} without consuming it. A subsequent call to 273 * either peek() or next() will return the same token. 274 <p> 275 * @return the next {@link XMLToken} or EOF (XMLToken.isEOF() == true). 276 */ public 277 XMLToken peek() { 278 return new XMLToken(libsbmlJNI.XMLInputStream_peek(swigCPtr, this), false); 279 } 280 281 282/** 283 * Consume zero or more XMLTokens up to and including the corresponding 284 * end XML element or EOF. 285 */ public 286 void skipPastEnd(XMLToken element) { 287 libsbmlJNI.XMLInputStream_skipPastEnd(swigCPtr, this, XMLToken.getCPtr(element), element); 288 } 289 290 291/** 292 * Consume zero or more XMLTokens up to but not including the next XML 293 * element or EOF. 294 */ public 295 void skipText() { 296 libsbmlJNI.XMLInputStream_skipText(swigCPtr, this); 297 } 298 299 300/** 301 * Sets the {@link XMLErrorLog} this stream will use to log errors. 302 <p> 303 * @return integer value indicating success/failure of the 304 * function. The possible values 305 * returned by this function are: 306 * <ul> 307 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 308 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 309 * </ul> 310 */ public 311 int setErrorLog(XMLErrorLog log) { 312 return libsbmlJNI.XMLInputStream_setErrorLog(swigCPtr, this, XMLErrorLog.getCPtr(log), log); 313 } 314 315 316/** 317 * Prints a string representation of the underlying token stream, for 318 * debugging purposes. 319 */ public 320 String toString() { 321 return libsbmlJNI.XMLInputStream_toString(swigCPtr, this); 322 } 323 324 325/** 326 * Returns the {@link SBMLNamespaces} object attached to this {@link XMLInputStream} 327 * if it has been set, null otherwise. 328 <p> 329 * @return the {@link SBMLNamespaces} object or null if none has been set. 330 */ public 331 SBMLNamespaces getSBMLNamespaces() { 332 return libsbml.DowncastSBMLNamespaces(libsbmlJNI.XMLInputStream_getSBMLNamespaces(swigCPtr, this), false); 333} 334 335 336/** 337 * Sets the {@link SBMLNamespaces} object to allow this stream to reference 338 * the available SBML namespaces being read. 339 */ public 340 void setSBMLNamespaces(SBMLNamespaces sbmlns) { 341 libsbmlJNI.XMLInputStream_setSBMLNamespaces(swigCPtr, this, SBMLNamespaces.getCPtr(sbmlns), sbmlns); 342 } 343 344 345/** 346 * Analyses the tokens in the stream and returns the number of 347 * child tokens of the given element. 348 <p> 349 * @param elementName a string representing the name of the element 350 * for which the number of children are to be determined. 351 <p> 352 * This function allows information from the input stream to be determined 353 * without the need to actually read and consume the tokens in 354 * the stream. This functionality 355 * is particularly utilized when reading MathML. 356 <p> 357 * The function will return the number of child elements of the 358 * element represented by the elementName supplied, i.e. the number 359 * of child elements encountered before the closing tag for the 360 * elementname supplied. If the elementName 361 * has not been supplied then the function assumes that it is reading 362 * an apply element followed by a function element. 363 <p> 364 * @note This function assumes the stream has been read up to and 365 * including the element elementName. 366 <p> 367 * @return a long integer giving the number of children of the 368 * element specified. 369 */ public 370 long determineNumberChildren(String elementName) { 371 return libsbmlJNI.XMLInputStream_determineNumberChildren__SWIG_0(swigCPtr, this, elementName); 372 } 373 374 375/** 376 * Analyses the tokens in the stream and returns the number of 377 * child tokens of the given element. 378 <p> 379 * @param elementName a string representing the name of the element 380 * for which the number of children are to be determined. 381 <p> 382 * This function allows information from the input stream to be determined 383 * without the need to actually read and consume the tokens in 384 * the stream. This functionality 385 * is particularly utilized when reading MathML. 386 <p> 387 * The function will return the number of child elements of the 388 * element represented by the elementName supplied, i.e. the number 389 * of child elements encountered before the closing tag for the 390 * elementname supplied. If the elementName 391 * has not been supplied then the function assumes that it is reading 392 * an apply element followed by a function element. 393 <p> 394 * @note This function assumes the stream has been read up to and 395 * including the element elementName. 396 <p> 397 * @return a long integer giving the number of children of the 398 * element specified. 399 */ public 400 long determineNumberChildren() { 401 return libsbmlJNI.XMLInputStream_determineNumberChildren__SWIG_1(swigCPtr, this); 402 } 403 404 405/** 406 * Analyses the tokens in the stream and returns the number of 407 * child tokens of the specified type within the given element. 408 <p> 409 * @param childName a string representing the name of the child 410 * element whose number is to be determined. 411 * @param container a string representing the name of the element 412 * for which the number of children are to be determined. 413 <p> 414 * This function allows information from the input stream to be determined 415 * without the need to actually read and consume the tokens in 416 * the stream. This functionality 417 * is particularly utilized when reading MathML. 418 <p> 419 * The function will return the number of child elements of the 420 * element represented by the childName supplied within the element 421 * specified by the container, i.e. the number 422 * of child elements encountered before the closing tag for the 423 * container supplied. 424 <p> 425 * @note This function assumes the stream has been read up to and 426 * including the element container. 427 <p> 428 * @return a long integer giving the number of children of type childName 429 * within the container element specified. 430 */ public 431 long determineNumSpecificChildren(String childName, String container) { 432 return libsbmlJNI.XMLInputStream_determineNumSpecificChildren(swigCPtr, this, childName, container); 433 } 434 435}