@@ -340,91 +340,6 @@ open class Card : Cloneable {
340340 flags = setFlagInInt(flags, flag.code)
341341 }
342342
343- @NotInLibAnki
344- val isInDynamicDeck: Boolean
345- get() = // In Anki Desktop, a card with oDue <> 0 && oDid == 0 is not marked as dynamic.
346- oDid != 0L
347-
348- /* * A cache represents an intermediary step between a card id and a card object. Creating a Card has some fixed cost
349- * in term of database access. Using an id has an unknown cost: none if the card is never accessed, heavy if the
350- * card is accessed a lot of time. CardCache ensure that the cost is paid at most once, by waiting for first access
351- * to load the data, and then saving them. Since CPU and RAM is usually less of a bottleneck than database access,
352- * it may often be worth using this cache.
353- *
354- * Beware that the card is loaded only once. Change in the database are not reflected, so use it only if you can
355- * safely assume that the card has not changed. That is
356- * long id;
357- * Card card = col.getCard(id);
358- * ....
359- * Card card2 = col.getCard(id);
360- * is not equivalent to
361- * long id;
362- * Card.Cache cache = new Cache(col, id);
363- * Card card = cache.getCard();
364- * ....
365- * Card card2 = cache.getCard();
366- *
367- * It is equivalent to:
368- * long id;
369- * Card.Cache cache = new Cache(col, id);
370- * Card card = cache.getCard();
371- * ....
372- * cache.reload();
373- * Card card2 = cache.getCard();
374- */
375- @NotInLibAnki
376- open class Cache : Cloneable {
377- val col: Collection
378- val id: CardId
379- private var _card : Card ? = null
380-
381- constructor (col: Collection , id: CardId ) {
382- this .col = col
383- this .id = id
384- }
385-
386- /* * Copy of cache. Useful to create a copy of a subclass without loosing card if it is loaded. */
387- protected constructor (cache: Cache ) {
388- col = cache.col
389- this .id = cache.id
390- _card = cache._card
391- }
392-
393- /* *
394- * The card with id given at creation. Note that it has content of the time at which the card was loaded, which
395- * may have changed in database. So it is not equivalent to getCol().getCard(getId()). If you need fresh data, reload
396- * first. */
397- @get:Synchronized
398- val card: Card
399- get() {
400- if (_card == null ) {
401- _card = col.getCard(this .id)
402- }
403- return _card !!
404- }
405-
406- /* * Next access to card will reload the card from the database. */
407- @Synchronized
408- open fun reload () {
409- _card = null
410- }
411-
412- override fun hashCode (): Int =
413- java.lang.Long
414- .valueOf(this .id)
415- .hashCode()
416-
417- /* * The cloned version represents the same card but data are not loaded. */
418- public override fun clone (): Cache = Cache (col, this .id)
419-
420- override fun equals (other : Any? ): Boolean =
421- if (other !is Cache ) {
422- false
423- } else {
424- this .id == other.id
425- }
426- }
427-
428343 companion object {
429344 // A list of class members to skip in the toString() representation
430345 val SKIP_PRINT : Set <String > =
0 commit comments