_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25100 | WebcamDefaultDevice.startFramesRefresher | train | private Thread startFramesRefresher() {
Thread refresher = new Thread(this, String.format("frames-refresher-[%s]", id));
refresher.setUncaughtExceptionHandler(WebcamExceptionHandler.getInstance());
refresher.setDaemon(true);
refresher.start();
return refresher;
} | java | {
"resource": ""
} |
q25101 | WebcamDefaultDevice.updateFrameBuffer | train | private void updateFrameBuffer() {
LOG.trace("Next frame");
if (t1 == -1 || t2 == -1) {
t1 = System.currentTimeMillis();
t2 = System.currentTimeMillis();
}
int result = new NextFrameTask(this).nextFrame();
t1 = t2;
t2 = System.currentTimeMillis();
fps = (4 * fps + 1000 / (t2 - t1 ... | java | {
"resource": ""
} |
q25102 | WebcamMotionDetectorDefaultAlgorithm.isInDoNotEngageZone | train | private boolean isInDoNotEngageZone(final int x, final int y) {
for (final Rectangle zone : doNotEnganeZones) {
if (zone.contains(x, y)) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q25103 | WebcamMotionDetector.notifyMotionListeners | train | private void notifyMotionListeners(BufferedImage currentOriginal) {
WebcamMotionEvent wme = new WebcamMotionEvent(this, previousOriginal, currentOriginal, algorithm.getArea(), algorithm.getCog(), algorithm.getPoints());
for (WebcamMotionListener l : listeners) {
try {
l.motionDetected(wme);
} catch (... | java | {
"resource": ""
} |
q25104 | WebcamMotionDetector.getMotionCog | train | public Point getMotionCog() {
Point cog = algorithm.getCog();
if (cog == null) {
// detectorAlgorithm hasn't been called so far - get image center
int w = webcam.getViewSize().width;
int h = webcam.getViewSize().height;
cog = new Point(w / 2, h / 2);
}
return cog;
} | java | {
"resource": ""
} |
q25105 | WebcamTask.process | train | public void process() throws InterruptedException {
boolean alreadyInSync = Thread.currentThread() instanceof WebcamProcessor.ProcessorThread;
if (alreadyInSync) {
handle();
} else {
if (doSync) {
if (processor == null) {
throw new RuntimeException("Driver should be synchronized, but processor is... | java | {
"resource": ""
} |
q25106 | WebcamDiscoveryService.getDevices | train | private static List<WebcamDevice> getDevices(List<Webcam> webcams) {
List<WebcamDevice> devices = new ArrayList<WebcamDevice>();
for (Webcam webcam : webcams) {
devices.add(webcam.getDevice());
}
return devices;
} | java | {
"resource": ""
} |
q25107 | WebcamDiscoveryService.scan | train | public void scan() {
WebcamDiscoveryListener[] listeners = Webcam.getDiscoveryListeners();
List<WebcamDevice> tmpnew = driver.getDevices();
List<WebcamDevice> tmpold = null;
try {
tmpold = getDevices(getWebcams(Long.MAX_VALUE, TimeUnit.MILLISECONDS));
} catch (TimeoutException e) {
throw new WebcamEx... | java | {
"resource": ""
} |
q25108 | WebcamDiscoveryService.stop | train | public void stop() {
// return if not running
if (!running.compareAndSet(true, false)) {
return;
}
try {
runner.join();
} catch (InterruptedException e) {
throw new WebcamException("Joint interrupted");
}
LOG.debug("Discovery service has been stopped");
runner = null;
} | java | {
"resource": ""
} |
q25109 | WebcamDiscoveryService.start | train | public void start() {
// if configured to not start, then simply return
if (!enabled.get()) {
LOG.info("Discovery service has been disabled and thus it will not be started");
return;
}
// capture driver does not support discovery - nothing to do
if (support == null) {
LOG.info("Discovery will not... | java | {
"resource": ""
} |
q25110 | WebcamUpdater.start | train | public void start() {
if (running.compareAndSet(false, true)) {
image.set(new WebcamGetImageTask(Webcam.getDriver(), webcam.getDevice()).getImage());
executor = Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
executor.execute(this);
LOG.debug("Webcam updater has been started");
} else {
... | java | {
"resource": ""
} |
q25111 | WebcamUpdater.stop | train | public void stop() {
if (running.compareAndSet(true, false)) {
executor.shutdown();
while (!executor.isTerminated()) {
try {
executor.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return;
}
}
LOG.debug("Webcam updater has been stopped");
} else ... | java | {
"resource": ""
} |
q25112 | WebcamUpdater.getImage | train | public BufferedImage getImage() {
int i = 0;
while (image.get() == null) {
// Just in case if another thread starts calling this method before
// updater has been properly started. This will loop while image is
// not available.
try {
Thread.sleep(100);
} catch (InterruptedException e) {
t... | java | {
"resource": ""
} |
q25113 | GStreamerDevice.init | train | private synchronized void init() {
if (!initialized.compareAndSet(false, true)) {
return;
}
LOG.debug("GStreamer webcam device initialization");
pipe = new Pipeline(getName());
source = ElementFactory.make(GStreamerDriver.getSourceBySystem(), "source");
if (Platform.isWindows()) {
sour... | java | {
"resource": ""
} |
q25114 | GStreamerDevice.parseResolutions | train | private Dimension[] parseResolutions(Pad pad) {
Caps caps = pad.getCaps();
format = findPreferredFormat(caps);
LOG.debug("Best format is {}", format);
Dimension r = null;
Structure s = null;
String mime = null;
final int n = caps.size();
int i = 0;
Map<String, Dimension> map = new... | java | {
"resource": ""
} |
q25115 | JmfDevice.getControl | train | private Control getControl(String name) {
Control control = player.getControl(name);
if (control == null) {
throw new RuntimeException("Cannot find format control " + name);
}
return control;
} | java | {
"resource": ""
} |
q25116 | JmfDevice.getSizedVideoFormat | train | private VideoFormat getSizedVideoFormat(Dimension size) {
Format[] formats = device.getFormats();
VideoFormat format = null;
for (Format f : formats) {
if (!"RGB".equalsIgnoreCase(f.getEncoding()) || !(f instanceof VideoFormat)) {
continue;
}
Dimension d = ((VideoFormat) f).getSize();
... | java | {
"resource": ""
} |
q25117 | JHBlurFilter.premultiply | train | public static void premultiply(int[] p, int offset, int length) {
length += offset;
for (int i = offset; i < length; i++) {
int rgb = p[i];
int a = (rgb >> 24) & 0xff;
int r = (rgb >> 16) & 0xff;
int g = (rgb >> 8) & 0xff;
int b = rgb & 0xff;
float f = a * (1.0f / 255.0f);
r *= f;
g *= f;
... | java | {
"resource": ""
} |
q25118 | JHBlurFilter.clamp | train | public static int clamp(int x, int a, int b) {
return (x < a) ? a : (x > b) ? b : x;
} | java | {
"resource": ""
} |
q25119 | IpCamDevice.isOnline | train | public boolean isOnline() {
LOG.debug("Checking online status for {} at {}", getName(), getURL());
try {
return client
.execute(new HttpHead(toURI(getURL())))
.getStatusLine()
.getStatusCode() != 404;
} catch (Exception e) {
return false;
}
} | java | {
"resource": ""
} |
q25120 | WebcamLock.lock | train | public void lock() {
if (disabled.get()) {
return;
}
if (isLocked()) {
throw new WebcamLockException(String.format("Webcam %s has already been locked", webcam.getName()));
}
if (!locked.compareAndSet(false, true)) {
return;
}
LOG.debug("Lock {}", webcam);
update();
upd... | java | {
"resource": ""
} |
q25121 | WebcamLock.disable | train | public void disable() {
if (disabled.compareAndSet(false, true)) {
LOG.info("Locking mechanism has been disabled in {}", webcam);
if (updater != null) {
updater.interrupt();
}
}
} | java | {
"resource": ""
} |
q25122 | WebcamLock.unlock | train | public void unlock() {
// do nothing when lock disabled
if (disabled.get()) {
return;
}
if (!locked.compareAndSet(true, false)) {
return;
}
LOG.debug("Unlock {}", webcam);
updater.interrupt();
write(-1);
if (!lock.delete()) {
lock.deleteOnExit();
}
} | java | {
"resource": ""
} |
q25123 | WebcamLock.isLocked | train | public boolean isLocked() {
// always return false when lock is disabled
if (disabled.get()) {
return false;
}
// check if locked by current process
if (locked.get()) {
return true;
}
// check if locked by other process
if (!lock.exists()) {
return false;
}
long n... | java | {
"resource": ""
} |
q25124 | PNGDecoder.decode | train | public final BufferedImage decode() throws IOException {
if (!validPNG) {
return null;
}
ColorModel cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
SampleModel smodel = new ComponentSampleModel(DATA_TYPE, width, height, 3, width * 3, BAND_OFFSETS);
byte[]... | java | {
"resource": ""
} |
q25125 | IPCDriver.parseArguments | train | protected void parseArguments(final Options options, String[] cmdArray) {
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, cmdArray);
Option[] opts = cmd.getOptions();
for (Option o : opts) {
arguments.put(o.getLongOpt(), o.getValue() == null ? "" : o.getValue... | java | {
"resource": ""
} |
q25126 | GStreamerDriver.setPreferredFormats | train | public void setPreferredFormats(List<String> preferredFormats) {
if (preferredFormats.isEmpty()) {
throw new IllegalArgumentException("Preferred formats list must not be empty");
}
this.preferredFormats = new ArrayList<>(preferredFormats);
} | java | {
"resource": ""
} |
q25127 | WebcamDriverUtils.findDriver | train | protected static WebcamDriver findDriver(List<String> names, List<Class<?>> classes) {
for (String name : names) {
LOG.info("Searching driver {}", name);
Class<?> clazz = null;
for (Class<?> c : classes) {
if (c.getCanonicalName().equals(name)) {
clazz = c;
break;
}
}
... | java | {
"resource": ""
} |
q25128 | WebcamDriverUtils.findClasses | train | private static List<Class<?>> findClasses(File dir, String pkgname, boolean flat) throws ClassNotFoundException {
List<Class<?>> classes = new ArrayList<Class<?>>();
if (!dir.exists()) {
return classes;
}
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory() && !fla... | java | {
"resource": ""
} |
q25129 | WebcamProcessor.process | train | public void process(WebcamTask task) throws InterruptedException {
if (started.compareAndSet(false, true)) {
runner = Executors.newSingleThreadExecutor(new ProcessorThreadFactory());
runner.execute(processor);
}
if (!runner.isShutdown()) {
processor.process(task);
} else {
throw new RejectedExecut... | java | {
"resource": ""
} |
q25130 | IpCamDeviceRegistry.register | train | public static IpCamDevice register(IpCamDevice ipcam) {
for (WebcamDevice d : DEVICES) {
String name = ipcam.getName();
if (d.getName().equals(name)) {
throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
}
}
DEVICES.add(ipcam);
rescan();
... | java | {
"resource": ""
} |
q25131 | IpCamDeviceRegistry.isRegistered | train | public static boolean isRegistered(IpCamDevice ipcam) {
if (ipcam == null) {
throw new IllegalArgumentException("IP camera device cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(ipcam.getName())) {
return true;
}
... | java | {
"resource": ""
} |
q25132 | IpCamDeviceRegistry.isRegistered | train | public static boolean isRegistered(String name) {
if (name == null) {
throw new IllegalArgumentException("Device name cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(name)) {
return true;
}
}
return false;
... | java | {
"resource": ""
} |
q25133 | IpCamDeviceRegistry.unregister | train | public static boolean unregister(String name) {
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
IpCamDevice d = di.next();
if (d.getName().equals(name)) {
di.remove();
rescan();
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q25134 | WebcamDeallocator.store | train | protected static void store(Webcam[] webcams) {
if (HANDLER.get() == null) {
HANDLER.set(new WebcamDeallocator(webcams));
} else {
throw new IllegalStateException("Deallocator is already set!");
}
} | java | {
"resource": ""
} |
q25135 | MultipointMotionDetectionExample.motionDetected | train | @Override
public void motionDetected(WebcamMotionEvent wme) {
for (Point p : wme.getPoints()) {
motionPoints.put(p, 0);
}
} | java | {
"resource": ""
} |
q25136 | JobExecutor.execute | train | public JobReport execute(Job job) {
try {
return executorService.submit(job).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Unable to execute job " + job.getName(), e);
}
} | java | {
"resource": ""
} |
q25137 | JobExecutor.awaitTermination | train | public void awaitTermination(long timeout, TimeUnit unit) {
try {
executorService.awaitTermination(timeout, unit);
} catch (InterruptedException e) {
throw new RuntimeException("Job executor was interrupted while waiting");
}
} | java | {
"resource": ""
} |
q25138 | ObjectMapper.mapObject | train | public T mapObject(final Map<String, String> values) throws Exception {
T result = createInstance();
// for each field
for (Map.Entry<String, String> entry : values.entrySet()) {
String field = entry.getKey();
//get field raw value
String value = values.get... | java | {
"resource": ""
} |
q25139 | JobScheduler.scheduleAtWithInterval | train | public void scheduleAtWithInterval(final org.easybatch.core.job.Job job, final Date startTime, final int interval) throws JobSchedulerException {
checkNotNull(job, "job");
checkNotNull(startTime, "startTime");
String name = job.getName();
String jobName = JOB_NAME_PREFIX + name;
... | java | {
"resource": ""
} |
q25140 | JobScheduler.unschedule | train | public void unschedule(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
LOGGER.info("Unscheduling job ''{}'' ", jobName);
try {
scheduler.unscheduleJob(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (Schedule... | java | {
"resource": ""
} |
q25141 | JobScheduler.isScheduled | train | public boolean isScheduled(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
try {
return scheduler.checkExists(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (SchedulerException e) {
throw new JobSchedule... | java | {
"resource": ""
} |
q25142 | DefaultJobReportMerger.mergerReports | train | @Override
public JobReport mergerReports(JobReport... jobReports) {
List<Long> startTimes = new ArrayList<>();
List<Long> endTimes = new ArrayList<>();
List<String> jobNames = new ArrayList<>();
JobParameters parameters = new JobParameters();
JobMetrics metrics = new JobMet... | java | {
"resource": ""
} |
q25143 | RetryTemplate.execute | train | public <T> T execute(final Callable<T> callable) throws Exception {
int attempts = 0;
int maxAttempts = retryPolicy.getMaxAttempts();
long delay = retryPolicy.getDelay();
TimeUnit timeUnit = retryPolicy.getTimeUnit();
while(attempts < maxAttempts) {
try {
... | java | {
"resource": ""
} |
q25144 | PayloadExtractor.extractPayloads | train | public static <P> List<P> extractPayloads(final List<? extends Record<P>> records) {
List<P> payloads = new ArrayList<>();
for (Record<P> record : records) {
payloads.add(record.getPayload());
}
return payloads;
} | java | {
"resource": ""
} |
q25145 | FixedLengthRecordMapper.calculateOffsets | train | private int[] calculateOffsets(final int[] lengths) {
int[] offsets = new int[lengths.length + 1];
offsets[0] = 0;
for (int i = 0; i < lengths.length; i++) {
offsets[i + 1] = offsets[i] + lengths[i];
}
return offsets;
} | java | {
"resource": ""
} |
q25146 | DelimitedRecordMapper.setDelimiter | train | public void setDelimiter(final String delimiter) {
String prefix = "";
//escape the "pipe" character used in regular expression of String.split method
if ("|".equals(delimiter)) {
prefix = "\\";
}
this.delimiter = prefix + delimiter;
} | java | {
"resource": ""
} |
q25147 | RestAction.queue | train | @SuppressWarnings("unchecked")
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
{
Route.CompiledRoute route = finalizeRoute();
Checks.notNull(route, "Route");
RequestBody data = finalizeData();
CaseInsensitiveMap<String, String> headers = finali... | java | {
"resource": ""
} |
q25148 | WebSocketClient.reconnect | train | public void reconnect(boolean callFromQueue) throws InterruptedException
{
Set<MDC.MDCCloseable> contextEntries = null;
Map<String, String> previousContext = null;
{
ConcurrentMap<String, String> contextMap = api.getContextMap();
if (callFromQueue && contextMap != nul... | java | {
"resource": ""
} |
q25149 | GuildController.setNickname | train | @CheckReturnValue
public AuditableRestAction<Void> setNickname(Member member, String nickname)
{
Checks.notNull(member, "Member");
checkGuild(member.getGuild(), "Member");
if(member.equals(getGuild().getSelfMember()))
{
if(!member.hasPermission(Permission.NICKNAME_CH... | java | {
"resource": ""
} |
q25150 | GuildController.unban | train | @CheckReturnValue
public AuditableRestAction<Void> unban(String userId)
{
Checks.isSnowflake(userId, "User ID");
checkPermission(Permission.BAN_MEMBERS);
Route.CompiledRoute route = Route.Guilds.UNBAN.compile(getGuild().getId(), userId);
return new AuditableRestAction<Void>(getG... | java | {
"resource": ""
} |
q25151 | MessageListenerExample.main | train | public static void main(String[] args)
{
//We construct a builder for a BOT account. If we wanted to use a CLIENT account
// we would use AccountType.CLIENT
try
{
JDA jda = new JDABuilder("Your-Token-Goes-Here") // The token of the account that is logging in.
... | java | {
"resource": ""
} |
q25152 | AuditLogEntry.getChangesForKeys | train | public List<AuditLogChange> getChangesForKeys(AuditLogKey... keys)
{
Checks.notNull(keys, "Keys");
List<AuditLogChange> changes = new ArrayList<>(keys.length);
for (AuditLogKey key : keys)
{
AuditLogChange change = getChangeByKey(key);
if (change != null)
... | java | {
"resource": ""
} |
q25153 | DefaultShardManagerBuilder.removeEventListenerProviders | train | public DefaultShardManagerBuilder removeEventListenerProviders(final Collection<IntFunction<Object>> listenerProviders)
{
Checks.noneNull(listenerProviders, "listener providers");
this.listenerProviders.removeAll(listenerProviders);
return this;
} | java | {
"resource": ""
} |
q25154 | MessageAction.clearFiles | train | @CheckReturnValue
public MessageAction clearFiles(BiConsumer<String, InputStream> finalizer)
{
Checks.notNull(finalizer, "Finalizer");
for (Iterator<Map.Entry<String, InputStream>> it = files.entrySet().iterator(); it.hasNext();)
{
Map.Entry<String, InputStream> entry = it.ne... | java | {
"resource": ""
} |
q25155 | SelfUpdateAvatarEvent.getOldAvatarUrl | train | public String getOldAvatarUrl()
{
return previous == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), previous, previous.startsWith("a_") ? ".gif" : ".png");
} | java | {
"resource": ""
} |
q25156 | SelfUpdateAvatarEvent.getNewAvatarUrl | train | public String getNewAvatarUrl()
{
return next == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), next, next.startsWith("a_") ? ".gif" : ".png");
} | java | {
"resource": ""
} |
q25157 | EmbedBuilder.isEmpty | train | public boolean isEmpty()
{
return title == null
&& description.length() == 0
&& timestamp == null
//&& color == null color alone is not enough to send
&& thumbnail == null
&& author == null
&& footer == null
... | java | {
"resource": ""
} |
q25158 | EmbedBuilder.setDescription | train | public final EmbedBuilder setDescription(CharSequence description)
{
this.description.setLength(0);
if (description != null && description.length() >= 1)
appendDescription(description);
return this;
} | java | {
"resource": ""
} |
q25159 | EmbedBuilder.appendDescription | train | public EmbedBuilder appendDescription(CharSequence description)
{
Checks.notNull(description, "description");
Checks.check(this.description.length() + description.length() <= MessageEmbed.TEXT_MAX_LENGTH,
"Description cannot be longer than %d characters.", MessageEmbed.TEXT_MAX_LENGT... | java | {
"resource": ""
} |
q25160 | EmbedBuilder.setTimestamp | train | public EmbedBuilder setTimestamp(TemporalAccessor temporal)
{
if (temporal == null)
{
this.timestamp = null;
}
else if (temporal instanceof OffsetDateTime)
{
this.timestamp = (OffsetDateTime) temporal;
}
else
{
ZoneO... | java | {
"resource": ""
} |
q25161 | EmbedBuilder.setColor | train | public EmbedBuilder setColor(Color color)
{
this.color = color == null ? Role.DEFAULT_COLOR_RAW : color.getRGB();
return this;
} | java | {
"resource": ""
} |
q25162 | EmbedBuilder.setThumbnail | train | public EmbedBuilder setThumbnail(String url)
{
if (url == null)
{
this.thumbnail = null;
}
else
{
urlCheck(url);
this.thumbnail = new MessageEmbed.Thumbnail(url, null, 0, 0);
}
return this;
} | java | {
"resource": ""
} |
q25163 | EmbedBuilder.setImage | train | public EmbedBuilder setImage(String url)
{
if (url == null)
{
this.image = null;
}
else
{
urlCheck(url);
this.image = new MessageEmbed.ImageInfo(url, null, 0, 0);
}
return this;
} | java | {
"resource": ""
} |
q25164 | EmbedBuilder.setAuthor | train | public EmbedBuilder setAuthor(String name, String url)
{
return setAuthor(name, url, null);
} | java | {
"resource": ""
} |
q25165 | EmbedBuilder.setAuthor | train | public EmbedBuilder setAuthor(String name, String url, String iconUrl)
{
//We only check if the name is null because its presence is what determines if the
// the author will appear in the embed.
if (name == null)
{
this.author = null;
}
else
{
... | java | {
"resource": ""
} |
q25166 | EmbedBuilder.setFooter | train | public EmbedBuilder setFooter(String text, String iconUrl)
{
//We only check if the text is null because its presence is what determines if the
// footer will appear in the embed.
if (text == null)
{
this.footer = null;
}
else
{
Checks.... | java | {
"resource": ""
} |
q25167 | EmbedBuilder.addField | train | public EmbedBuilder addField(String name, String value, boolean inline)
{
if (name == null && value == null)
return this;
this.fields.add(new MessageEmbed.Field(name, value, inline));
return this;
} | java | {
"resource": ""
} |
q25168 | WebhookMessageBuilder.reset | train | public WebhookMessageBuilder reset()
{
content.setLength(0);
embeds.clear();
resetFiles();
username = null;
avatarUrl = null;
isTTS = false;
return this;
} | java | {
"resource": ""
} |
q25169 | WebhookMessageBuilder.append | train | public WebhookMessageBuilder append(String content)
{
Checks.notNull(content, "Content");
Checks.check(this.content.length() + content.length() <= 2000,
"Content may not exceed 2000 characters!");
this.content.append(content);
return this;
} | java | {
"resource": ""
} |
q25170 | AccountManager.setName | train | @CheckReturnValue
public AccountManager setName(String name, String currentPassword)
{
Checks.notBlank(name, "Name");
Checks.check(name.length() >= 2 && name.length() <= 32, "Name must be between 2-32 characters long");
this.currentPassword = currentPassword;
this.name = name;
... | java | {
"resource": ""
} |
q25171 | AccountManager.setAvatar | train | @CheckReturnValue
public AccountManager setAvatar(Icon avatar, String currentPassword)
{
this.currentPassword = currentPassword;
this.avatar = avatar;
set |= AVATAR;
return this;
} | java | {
"resource": ""
} |
q25172 | AccountManager.setEmail | train | @CheckReturnValue
public AccountManager setEmail(String email, String currentPassword)
{
Checks.notNull(email, "email");
this.currentPassword = currentPassword;
this.email = email;
set |= EMAIL;
return this;
} | java | {
"resource": ""
} |
q25173 | OrderAction.swapPosition | train | @SuppressWarnings("unchecked")
public M swapPosition(int swapPosition)
{
Checks.notNegative(swapPosition, "Provided swapPosition");
Checks.check(swapPosition < orderList.size(), "Provided swapPosition is too big and is out of bounds. swapPosition: "
+ swapPosition);
T se... | java | {
"resource": ""
} |
q25174 | OrderAction.swapPosition | train | @SuppressWarnings("unchecked")
public M swapPosition(T swapEntity)
{
Checks.notNull(swapEntity, "Provided swapEntity");
validateInput(swapEntity);
return swapPosition(orderList.indexOf(swapEntity));
} | java | {
"resource": ""
} |
q25175 | MessageBuilder.replace | train | public MessageBuilder replace(String target, String replacement)
{
int index = builder.indexOf(target);
while (index != -1)
{
builder.replace(index, index + target.length(), replacement);
index = builder.indexOf(target, index + replacement.length());
}
... | java | {
"resource": ""
} |
q25176 | MessageBuilder.replaceFirst | train | public MessageBuilder replaceFirst(String target, String replacement)
{
int index = builder.indexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | java | {
"resource": ""
} |
q25177 | MessageBuilder.replaceLast | train | public MessageBuilder replaceLast(String target, String replacement)
{
int index = builder.lastIndexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | java | {
"resource": ""
} |
q25178 | MessageBuilder.indexOf | train | public int indexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromIndex >... | java | {
"resource": ""
} |
q25179 | MessageBuilder.lastIndexOf | train | public int lastIndexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromInd... | java | {
"resource": ""
} |
q25180 | ChannelAction.setName | train | @CheckReturnValue
public ChannelAction setName(String name)
{
Checks.notNull(name, "Channel name");
if (name.length() < 1 || name.length() > 100)
throw new IllegalArgumentException("Provided channel name must be 1 to 100 characters in length");
this.name = name;
retu... | java | {
"resource": ""
} |
q25181 | ChannelAction.setTopic | train | @CheckReturnValue
public ChannelAction setTopic(String topic)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set the topic for a TextChannel!");
if (topic != null && topic.length() > 1024)
throw new IllegalArgumentException("Channel Topi... | java | {
"resource": ""
} |
q25182 | ChannelAction.setNSFW | train | @CheckReturnValue
public ChannelAction setNSFW(boolean nsfw)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set nsfw for a TextChannel!");
this.nsfw = nsfw;
return this;
} | java | {
"resource": ""
} |
q25183 | ChannelAction.setSlowmode | train | @CheckReturnValue
public ChannelAction setSlowmode(int slowmode)
{
Checks.check(slowmode <= 120 && slowmode >= 0, "Slowmode must be between 0 and 120 (seconds)!");
this.slowmode = slowmode;
return this;
} | java | {
"resource": ""
} |
q25184 | ChannelAction.setBitrate | train | @CheckReturnValue
public ChannelAction setBitrate(Integer bitrate)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the bitrate for a VoiceChannel!");
if (bitrate != null)
{
int maxBitrate = guild.getFeatures().contains("VIP_R... | java | {
"resource": ""
} |
q25185 | ChannelAction.setUserlimit | train | @CheckReturnValue
public ChannelAction setUserlimit(Integer userlimit)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the userlimit for a VoiceChannel!");
if (userlimit != null && (userlimit < 0 || userlimit > 99))
throw new Illegal... | java | {
"resource": ""
} |
q25186 | WebSocketSendingThread.send | train | private boolean send(String request)
{
needRateLimit = !client.send(request, false);
attemptedToSend = true;
return !needRateLimit;
} | java | {
"resource": ""
} |
q25187 | IOUtil.readFully | train | public static byte[] readFully(File file) throws IOException
{
Checks.notNull(file, "File");
Checks.check(file.exists(), "Provided file does not exist!");
try (InputStream is = new FileInputStream(file))
{
// Get the size of the file
long length = file.length... | java | {
"resource": ""
} |
q25188 | WidgetUtil.getPremadeWidgetHtml | train | public static String getPremadeWidgetHtml(Guild guild, WidgetTheme theme, int width, int height)
{
Checks.notNull(guild, "Guild");
return getPremadeWidgetHtml(guild.getId(), theme, width, height);
} | java | {
"resource": ""
} |
q25189 | WidgetUtil.getPremadeWidgetHtml | train | public static String getPremadeWidgetHtml(String guildId, WidgetTheme theme, int width, int height)
{
Checks.notNull(guildId, "GuildId");
Checks.notNull(theme, "WidgetTheme");
Checks.notNegative(width, "Width");
Checks.notNegative(height, "Height");
return String.format(WIDGE... | java | {
"resource": ""
} |
q25190 | MiscUtil.appendTo | train | public static void appendTo(Formatter formatter, int width, int precision, boolean leftJustified, String out)
{
try
{
Appendable appendable = formatter.out();
if (precision > -1 && out.length() > precision)
{
appendable.append(Helpers.truncate(out,... | java | {
"resource": ""
} |
q25191 | WebhookClient.send | train | public RequestFuture<?> send(String content)
{
Checks.notBlank(content, "Content");
Checks.check(content.length() <= 2000, "Content may not exceed 2000 characters!");
return execute(newBody(new JSONObject().put("content", content).toString()));
} | java | {
"resource": ""
} |
q25192 | RoleAction.setColor | train | @CheckReturnValue
public RoleAction setColor(Color color)
{
return this.setColor(color != null ? color.getRGB() : null);
} | java | {
"resource": ""
} |
q25193 | Game.of | train | public static Game of(GameType type, String name)
{
return of(type, name, null);
} | java | {
"resource": ""
} |
q25194 | PaginationAction.limit | train | @SuppressWarnings("unchecked")
public M limit(final int limit)
{
Checks.check(maxLimit == 0 || limit <= maxLimit, "Limit must not exceed %d!", maxLimit);
Checks.check(minLimit == 0 || limit >= minLimit, "Limit must be greater or equal to %d", minLimit);
synchronized (this.limit)
... | java | {
"resource": ""
} |
q25195 | BubbleChartRenderer.processBubble | train | private float processBubble(BubbleValue bubbleValue, PointF point) {
final float rawX = computator.computeRawX(bubbleValue.getX());
final float rawY = computator.computeRawY(bubbleValue.getY());
float radius = (float) Math.sqrt(Math.abs(bubbleValue.getZ()) / Math.PI);
float rawRadius;
... | java | {
"resource": ""
} |
q25196 | FloatUtils.nextUpF | train | public static float nextUpF(float f) {
if (Float.isNaN(f) || f == Float.POSITIVE_INFINITY) {
return f;
} else {
f += 0.0f;
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1));
}
} | java | {
"resource": ""
} |
q25197 | FloatUtils.nextDownF | train | public static float nextDownF(float f) {
if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
return f;
} else {
if (f == 0.0f) {
return -Float.MIN_VALUE;
} else {
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f > 0.0f) ? ... | java | {
"resource": ""
} |
q25198 | FloatUtils.nextUp | train | public static double nextUp(double d) {
if (Double.isNaN(d) || d == Double.POSITIVE_INFINITY) {
return d;
} else {
d += 0.0;
return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0) ? +1 : -1));
}
} | java | {
"resource": ""
} |
q25199 | FloatUtils.almostEqual | train | public static boolean almostEqual(float a, float b, float absoluteDiff, float relativeDiff) {
float diff = Math.abs(a - b);
if (diff <= absoluteDiff) {
return true;
}
a = Math.abs(a);
b = Math.abs(b);
float largest = (a > b) ? a : b;
if (diff <= larg... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.