1 34 package org.dspace.checker; 35 36 import java.sql.SQLException ; 37 38 import org.dspace.core.PluginManager; 39 40 49 public class LimitedCountDispatcher implements BitstreamDispatcher 50 { 51 52 private int remaining = 1; 53 54 55 private BitstreamDispatcher delegate = null; 56 57 60 public LimitedCountDispatcher() 61 { 62 this((BitstreamDispatcher) PluginManager 63 .getSinglePlugin(BitstreamDispatcher.class)); 64 } 65 66 74 public LimitedCountDispatcher(BitstreamDispatcher del, int count) 75 { 76 this(del); 77 remaining = count; 78 } 79 80 86 public LimitedCountDispatcher(BitstreamDispatcher del) 87 { 88 delegate = del; 89 } 90 91 98 public int next() 99 { 100 if (remaining > 0) 101 { 102 remaining--; 103 104 return delegate.next(); 105 } 106 else 107 { 108 return BitstreamDispatcher.SENTINEL; 109 } 110 } 111 } 112 | Popular Tags |