001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 4.0.2 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 com.avpkit.core; 010import com.avpkit.ferry.*; 011/** 012 * Time (duration) values with units.<br> 013 * This class also has methods<br> 014 * that correctly account for long wrapping when comparing time values.<br> 015 * @deprecated . Do not use. 016 */ 017public class ITimeValue extends RefCounted { 018 // JNIHelper.swg: Start generated code 019 // >>>>>>>>>>>>>>>>>>>>>>>>>>> 020 /** 021 * This method is only here to use some references and remove 022 * a Eclipse compiler warning. 023 */ 024 @SuppressWarnings("unused") 025 private void noop() 026 { 027 IBuffer.make(null, 1); 028 } 029 030 private volatile long swigCPtr; 031 032 /** 033 * Internal Only. 034 */ 035 protected ITimeValue(long cPtr, boolean cMemoryOwn) { 036 super(AVPKitJNI.ITimeValue_SWIGUpcast(cPtr), cMemoryOwn); 037 swigCPtr = cPtr; 038 } 039 040 /** 041 * Internal Only. 042 */ 043 protected ITimeValue(long cPtr, boolean cMemoryOwn, 044 java.util.concurrent.atomic.AtomicLong ref) 045 { 046 super(AVPKitJNI.ITimeValue_SWIGUpcast(cPtr), 047 cMemoryOwn, ref); 048 swigCPtr = cPtr; 049 } 050 051 /** 052 * Internal Only. Not part of public API. 053 * 054 * Get the raw value of the native object that obj is proxying for. 055 * 056 * @param obj The java proxy object for a native object. 057 * @return The raw pointer obj is proxying for. 058 */ 059 public static long getCPtr(ITimeValue obj) { 060 if (obj == null) return 0; 061 return obj.getMyCPtr(); 062 } 063 064 /** 065 * Internal Only. Not part of public API. 066 * 067 * Get the raw value of the native object that we're proxying for. 068 * 069 * @return The raw pointer we're proxying for. 070 */ 071 public long getMyCPtr() { 072 if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted"); 073 return swigCPtr; 074 } 075 076 /** 077 * Create a new ITimeValue object that is actually referring to the 078 * exact same underlying native object. 079 * 080 * @return the new Java object. 081 */ 082 @Override 083 public ITimeValue copyReference() { 084 if (swigCPtr == 0) 085 return null; 086 else 087 return new ITimeValue(swigCPtr, swigCMemOwn, getJavaRefCount()); 088 } 089 090 /** 091 * Compares two values, returning true if the underlying objects in native code are the same object. 092 * 093 * That means you can have two different Java objects, but when you do a comparison, you'll find out 094 * they are the EXACT same object. 095 * 096 * @return True if the underlying native object is the same. False otherwise. 097 */ 098 public boolean equals(Object obj) { 099 boolean equal = false; 100 if (obj instanceof ITimeValue) 101 equal = (((ITimeValue)obj).swigCPtr == this.swigCPtr); 102 return equal; 103 } 104 105 /** 106 * Get a hashable value for this object. 107 * 108 * @return the hashable value. 109 */ 110 public int hashCode() { 111 return (int)swigCPtr; 112 } 113 114 // <<<<<<<<<<<<<<<<<<<<<<<<<<< 115 // JNIHelper.swg: End generated code 116 117 /** 118 * Make a new time value.<br> 119 * @param value The value.<br> 120 * @param unit The unit value is expressed in.<br> 121 * @return a new time value. 122 */ 123 public static ITimeValue make(long value, ITimeValue.Unit unit) { 124 long cPtr = AVPKitJNI.ITimeValue_make__SWIG_0(value, unit.swigValue()); 125 return (cPtr == 0) ? null : new ITimeValue(cPtr, false); 126 } 127 128 /** 129 * Make a copy of a time value from another time value.<br> 130 * @param src The time value to copy. If 0 this method returns 0.<br> 131 * @return a new time value. 132 */ 133 public static ITimeValue make(ITimeValue src) { 134 long cPtr = AVPKitJNI.ITimeValue_make__SWIG_1(ITimeValue.getCPtr(src), src); 135 return (cPtr == 0) ? null : new ITimeValue(cPtr, false); 136 } 137 138 /** 139 * Get the value of this ITimeValue, in the specified Unit.<br> 140 * @param unit The unit you want to get a value as.<br> 141 * @return The value, converted into the appropriate Unit. 142 */ 143 public long get(ITimeValue.Unit unit) { 144 return AVPKitJNI.ITimeValue_get(swigCPtr, this, unit.swigValue()); 145 } 146 147 /** 148 * Compare this timeValue to another.<br> 149 * This compareTo will compare the values, but will assume that the values<br> 150 * can never be more than half of int64_t's MAX_VALUE apart. If they are<br> 151 * it will assume long wrapping has occurred. This is required especially<br> 152 * if you're using TimeValue's as absolute time stamps, and want to know<br> 153 * which is earlier.<br> 154 * @param other the value to compare to<br> 155 * @return -1 if this < other; +1 if this > other; 0 otherwise 156 */ 157 public int compareTo(ITimeValue other) { 158 return AVPKitJNI.ITimeValue_compareTo(swigCPtr, this, ITimeValue.getCPtr(other), other); 159 } 160 161 /** 162 * Convenience method that calls a.compareTo(b).<br> 163 * @see #compareTo<br> 164 * @param a first value.<br> 165 * @param b second value.<br> 166 * @return -1 if a < b; +1 if a > b; 0 otherwise 167 */ 168 public static int compare(ITimeValue a, ITimeValue b) { 169 return AVPKitJNI.ITimeValue_compare__SWIG_0(ITimeValue.getCPtr(a), a, ITimeValue.getCPtr(b), b); 170 } 171 172 /** 173 * And another convenience method that deals with un-unitted long values.<br> 174 * @param a the first object.<br> 175 * @param b the second object.<br> 176 * @return #compare(ITimeValue, ITimeValue) where both a and b are assumed to be MICROSECONDS. 177 */ 178 public static int compare(long a, long b) { 179 return AVPKitJNI.ITimeValue_compare__SWIG_1(a, b); 180 } 181 182 public enum Unit { 183 DAYS, 184 HOURS, 185 MINUTES, 186 SECONDS, 187 MILLISECONDS, 188 MICROSECONDS, 189 NANOSECONDS; 190 191 public final int swigValue() { 192 return swigValue; 193 } 194 195 public static Unit swigToEnum(int swigValue) { 196 Unit[] swigValues = Unit.class.getEnumConstants(); 197 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) 198 return swigValues[swigValue]; 199 for (Unit swigEnum : swigValues) 200 if (swigEnum.swigValue == swigValue) 201 return swigEnum; 202 throw new IllegalArgumentException("No enum " + Unit.class + " with value " + swigValue); 203 } 204 205 @SuppressWarnings("unused") 206 private Unit() { 207 this.swigValue = SwigNext.next++; 208 } 209 210 @SuppressWarnings("unused") 211 private Unit(int swigValue) { 212 this.swigValue = swigValue; 213 SwigNext.next = swigValue+1; 214 } 215 216 @SuppressWarnings("unused") 217 private Unit(Unit swigEnum) { 218 this.swigValue = swigEnum.swigValue; 219 SwigNext.next = this.swigValue+1; 220 } 221 222 private final int swigValue; 223 224 private static class SwigNext { 225 private static int next = 0; 226 } 227 } 228 229}