001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.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 * Base class for filter functions. 013 <p> 014 * <p style='color: #777; font-style: italic'> 015This class of objects is defined by libSBML only and has no direct 016equivalent in terms of SBML components. It is a class used in 017the implementation of extra functionality provided by libSBML. 018</p> 019 020 <p> 021 * Some libSBML objects provide the ability to return lists of components. 022 * To provide callers with greater control over exactly what is 023 * returned, these methods take optional arguments in the form of filters. 024 * The {@link ElementFilter} class is the parent class for these filters. 025 */ 026 027public class ElementFilter { 028 private long swigCPtr; 029 protected boolean swigCMemOwn; 030 031 protected ElementFilter(long cPtr, boolean cMemoryOwn) 032 { 033 swigCMemOwn = cMemoryOwn; 034 swigCPtr = cPtr; 035 } 036 037 protected static long getCPtr(ElementFilter obj) 038 { 039 return (obj == null) ? 0 : obj.swigCPtr; 040 } 041 042 protected static long getCPtrAndDisown (ElementFilter obj) 043 { 044 long ptr = 0; 045 046 if (obj != null) 047 { 048 ptr = obj.swigCPtr; 049 obj.swigCMemOwn = false; 050 } 051 052 return ptr; 053 } 054 055 protected void finalize() { 056 delete(); 057 } 058 059 public synchronized void delete() { 060 if (swigCPtr != 0) { 061 if (swigCMemOwn) { 062 swigCMemOwn = false; 063 libsbmlJNI.delete_ElementFilter(swigCPtr); 064 } 065 swigCPtr = 0; 066 } 067 } 068 069 protected void swigDirectorDisconnect() { 070 swigCMemOwn = false; 071 delete(); 072 } 073 074 public void swigReleaseOwnership() { 075 swigCMemOwn = false; 076 libsbmlJNI.ElementFilter_change_ownership(this, swigCPtr, false); 077 } 078 079 public void swigTakeOwnership() { 080 swigCMemOwn = true; 081 libsbmlJNI.ElementFilter_change_ownership(this, swigCPtr, true); 082 } 083 084 085/** 086 * Creates a new {@link ElementFilter} object. 087 */ public 088 ElementFilter() { 089 this(libsbmlJNI.new_ElementFilter(), true); 090 libsbmlJNI.ElementFilter_director_connect(this, swigCPtr, swigCMemOwn, true); 091 } 092 093 094/** 095 * Predicate to test elements. 096 <p> 097 * This is the central predicate of the {@link ElementFilter} class. In subclasses 098 * of {@link ElementFilter}, callers should implement this method such that it 099 * returns <code>true</code> for <code>element</code> arguments that are 'desirable' and 100 * <code>false</code> for those that are 'undesirable' in whatever filtering context the 101 * {@link ElementFilter} subclass is designed to be used. 102 <p> 103 * @param element the element to be tested. 104 <p> 105 * @return <code>true</code> if the <code>element</code> is desirable or should be kept, 106 * <code>false</code> otherwise. 107 */ public 108 boolean filter(SBase element) { 109 return (getClass() == ElementFilter.class) ? libsbmlJNI.ElementFilter_filter(swigCPtr, this, SBase.getCPtr(element), element) : libsbmlJNI.ElementFilter_filterSwigExplicitElementFilter(swigCPtr, this, SBase.getCPtr(element), element); 110 } 111 112}