1 /* ---------------------------------------------------------------------------- 2 * This file was automatically generated by SWIG (http://www.swig.org). 3 * Version 4.0.2 4 * 5 * Do not make changes to this file unless you know what you are doing--modify 6 * the SWIG interface file instead. 7 * ----------------------------------------------------------------------------- */ 8 9 package org.sbml.libsbml; 10 11 /** 12 * Base class for filter functions. 13 <p> 14 * <p style='color: #777; font-style: italic'> 15 This class of objects is defined by libSBML only and has no direct 16 equivalent in terms of SBML components. It is a class used in 17 the implementation of extra functionality provided by libSBML. 18 </p> 19 20 <p> 21 * Some libSBML objects provide the ability to return lists of components. 22 * To provide callers with greater control over exactly what is 23 * returned, these methods take optional arguments in the form of filters. 24 * The {@link ElementFilter} class is the parent class for these filters. 25 */ 26 27 public class ElementFilter { 28 private long swigCPtr; 29 protected boolean swigCMemOwn; 30 ElementFilter(long cPtr, boolean cMemoryOwn)31 protected ElementFilter(long cPtr, boolean cMemoryOwn) 32 { 33 swigCMemOwn = cMemoryOwn; 34 swigCPtr = cPtr; 35 } 36 getCPtr(ElementFilter obj)37 protected static long getCPtr(ElementFilter obj) 38 { 39 return (obj == null) ? 0 : obj.swigCPtr; 40 } 41 getCPtrAndDisown(ElementFilter obj)42 protected static long getCPtrAndDisown (ElementFilter obj) 43 { 44 long ptr = 0; 45 46 if (obj != null) 47 { 48 ptr = obj.swigCPtr; 49 obj.swigCMemOwn = false; 50 } 51 52 return ptr; 53 } 54 55 @SuppressWarnings("deprecation") finalize()56 protected void finalize() { 57 delete(); 58 } 59 delete()60 public synchronized void delete() { 61 if (swigCPtr != 0) { 62 if (swigCMemOwn) { 63 swigCMemOwn = false; 64 libsbmlJNI.delete_ElementFilter(swigCPtr); 65 } 66 swigCPtr = 0; 67 } 68 } 69 swigDirectorDisconnect()70 protected void swigDirectorDisconnect() { 71 swigCMemOwn = false; 72 delete(); 73 } 74 swigReleaseOwnership()75 public void swigReleaseOwnership() { 76 swigCMemOwn = false; 77 libsbmlJNI.ElementFilter_change_ownership(this, swigCPtr, false); 78 } 79 swigTakeOwnership()80 public void swigTakeOwnership() { 81 swigCMemOwn = true; 82 libsbmlJNI.ElementFilter_change_ownership(this, swigCPtr, true); 83 } 84 85 86 /** 87 * Creates a new {@link ElementFilter} object. 88 */ public ElementFilter()89 ElementFilter() { 90 this(libsbmlJNI.new_ElementFilter(), true); 91 libsbmlJNI.ElementFilter_director_connect(this, swigCPtr, true, true); 92 } 93 94 95 /** 96 * Predicate to test elements. 97 <p> 98 * This is the central predicate of the {@link ElementFilter} class. In subclasses 99 * of {@link ElementFilter}, callers should implement this method such that it 100 * returns <code>true</code> for <code>element</code> arguments that are 'desirable' and 101 * <code>false</code> for those that are 'undesirable' in whatever filtering context the 102 * {@link ElementFilter} subclass is designed to be used. 103 <p> 104 * @param element the element to be tested. 105 <p> 106 * @return <code>true</code> if the <code>element</code> is desirable or should be kept, 107 * <code>false</code> otherwise. 108 */ public filter(SBase element)109 boolean filter(SBase element) { 110 return (getClass() == ElementFilter.class) ? libsbmlJNI.ElementFilter_filter(swigCPtr, this, SBase.getCPtr(element), element) : libsbmlJNI.ElementFilter_filterSwigExplicitElementFilter(swigCPtr, this, SBase.getCPtr(element), element); 111 } 112 113 } 114