_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q181000
ExecS.main
test
public static void main(String[] args) { ExecS run = new ExecS(); int ret = run.execute(args); System.exit(ret); }
java
{ "resource": "" }
q181001
MuteEvent.createMuteEvent
test
public static Optional<MuteEvent> createMuteEvent(Identification source, Identification target) { if (target == null || target.equals(source)) return Optional.empty(); try { MuteEvent muteRequest = new MuteEvent(source); muteRequest.addResource(new SelectorResource(so...
java
{ "resource": "" }
q181002
MuteEvent.createMuteEvent
test
public static Optional<MuteEvent> createMuteEvent(Identification source) { if (source == null) return Optional.empty(); try { MuteEvent muteRequest = new MuteEvent(source); return Optional.of(muteRequest); } catch (IllegalArgumentException e) { ret...
java
{ "resource": "" }
q181003
CachingGoodwillAccessor.getSchema
test
public GoodwillSchema getSchema(final String schemaName) { GoodwillSchema schema = knownSchemata.get(schemaName); if (schema == null) { refreshSchemataCache(); schema = knownSchemata.get(schemaName); } return schema; }
java
{ "resource": "" }
q181004
Gen_ExecJarScripts.writeFile
test
public boolean writeFile(File file, List<String> lines){ if(file.exists()){ file.delete(); } try { FileWriter out = new FileWriter(file); for(String s : lines){ out.write(s); out.write(System.getProperty("line.separator")); } out.close(); file.setExecutable(true); } catc...
java
{ "resource": "" }
q181005
Gen_ExecJarScripts.inExecJar
test
protected boolean inExecJar(){ Class<Gen_ExecJarScripts> clazz = Gen_ExecJarScripts.class; String className = clazz.getSimpleName() + ".class"; String classPath = clazz.getResource(className).toString(); if (!classPath.startsWith("jar")) { System.err.println(this.getAppName() + ": not started in a jar, ...
java
{ "resource": "" }
q181006
Gen_ExecJarScripts.addOption
test
protected void addOption(ApplicationOption<?> option){ if(option!=null){ this.getCli().addOption(option); this.options.add(option); } }
java
{ "resource": "" }
q181007
GoodwillSchema.getSchema
test
public ArrayList<GoodwillSchemaField> getSchema() { final ArrayList<GoodwillSchemaField> items = new ArrayList<GoodwillSchemaField>(thriftItems.values()); Collections.sort(items, new Comparator<GoodwillSchemaField>() { @Override public int compare(final GoodwillSchem...
java
{ "resource": "" }
q181008
GoodwillSchema.getFieldByName
test
public GoodwillSchemaField getFieldByName(final String name) { for (final GoodwillSchemaField field : thriftItems.values()) { if (field.getName().equals(name)) { return field; } } return null; }
java
{ "resource": "" }
q181009
CF_Utils.getPkgName
test
public final static String getPkgName(JarEntry entry){ if(entry==null){ return ""; } String s = entry.getName(); if(s==null){ return ""; } if(s.length()==0){ return s; } if(s.startsWith("/")){ s = s.substring(1, s.length()); } if(s.endsWith("/")){ s = s.substring(0, s.length()-1); }...
java
{ "resource": "" }
q181010
ContentMap.mapContentToValues
test
private ImmutableMap<C, V> mapContentToValues( final ImmutableMap<K, V> base ) { final ImmutableMap.Builder<C, V> builder = ImmutableMap.builder(); for (final Entry<K, V> entry : base.entrySet()) { builder.put( this.key(entry.getKey()), entry.getVa...
java
{ "resource": "" }
q181011
EventListener.createEventListener
test
public static Optional<EventListener> createEventListener(String descriptor, String description, String descriptorID, Identifiable identifiable) throws IllegalArgumentException{...
java
{ "resource": "" }
q181012
IterativeCallback.setState
test
public IterativeState<T,R> setState(IterativeState<T,R> new_state) { IterativeState<T,R> old_state = this.state; this.state = new_state; return old_state; }
java
{ "resource": "" }
q181013
IterativeCallback.iterate
test
public R iterate(final FilterableCollection<? extends T> c) { initState(); checkUsed(); // If collection is decorated with a syncronized wrapper then synchronize the iteration if (c instanceof SynchronizedFilterableCollection) { return SyncUtils.synchro...
java
{ "resource": "" }
q181014
IterativeCallback.doIteration
test
private R doIteration(Iterator<? extends T> it) { // save the iterator into member variable state.i = it; state.iterations = 0; if (state.do_break == true) return state.return_object; // do the iteration calling nextobject on each while...
java
{ "resource": "" }
q181015
TrackInfoResource.getTrackInfo
test
public static Optional<TrackInfo> getTrackInfo(EventModel eventModel) { if (eventModel.getListResourceContainer().containsResourcesFromSource(RESOURCE_ID)) { return eventModel .getListResourceContainer() .provideResource(RESOURCE_ID) .strea...
java
{ "resource": "" }
q181016
Progress.export
test
public HashMap<String, Long> export() { HashMap<String, Long> data = new HashMap<>(); data.put(lengthDescriptor, length); data.put(knownPositionDescriptor, knownPosition); data.put(knownMillisTimeStampDescriptor, knownMillisTimeStamp); return data; }
java
{ "resource": "" }
q181017
Progress.importResource
test
public static Optional<Progress> importResource(ResourceModel resourceModel) { Object resource = resourceModel.getResource(); try { //noinspection unchecked HashMap<String, Long> data = (HashMap<String, Long>) resource; long length = data.get(lengthDescriptor); ...
java
{ "resource": "" }
q181018
FireREST.errorImage
test
public BufferedImage errorImage(String... lines) { if (imageBuffer == null || imageBuffer.getWidth() != imageWidth || imageBuffer.getHeight() != imageHeight) { imageBuffer = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB); } Graphics2D g = (Graphics2D) imageBuffer.getGraphics();...
java
{ "resource": "" }
q181019
FireREST.getImage
test
public BufferedImage getImage(URL url) { String now = new Date().toString(); if (url == null) { return errorImage(now, "(No image url)"); } try { HttpURLConnection urlconn = (HttpURLConnection) url.openConnection(); urlconn.setReadTimeout(msTimeout); urlconn.setConnectTimeout(msT...
java
{ "resource": "" }
q181020
FireREST.getJSON
test
public JSONResult getJSON(URL url) { try { logger.debug("Requesting {}", url); StringBuilder text = new StringBuilder(); String line; HttpURLConnection urlconn = (HttpURLConnection) url.openConnection(); urlconn.setReadTimeout(msTimeout); urlconn.setConnectTimeout(msTimeout); ...
java
{ "resource": "" }
q181021
CollectionUtilities.reverse
test
public static <K,V> void reverse(Map<K,V> source, Map<V,K> target) { Iterator<K> i = source.keySet().iterator(); while (i.hasNext()) { K key = i.next(); V value = source.get(key); target.put(value, key); } }
java
{ "resource": "" }
q181022
CartesianProduct.multiplication
test
private Set<R> multiplication() { final Set<R> answer = new LinkedHashSet<>( this.one.size() * this.two.size() ); for (final A left : this.one) { for (final B right : this.two) { final R element = this.function.apply(left, right); if (answe...
java
{ "resource": "" }
q181023
WorkerThread.start
test
@Override public synchronized void start() { if (!running && !used) { this.running = true; this.used = true; this.setDaemon(true); super.start(); } }
java
{ "resource": "" }
q181024
WorkerThread.returnToPool
test
private void returnToPool() { if(pool != null) { try { pool.returnObject(this); } catch (Exception e1) { log.error("Exception :", e1); } this.pool = null; } }
java
{ "resource": "" }
q181025
EndedEvent.createEndedEvent
test
public static Optional<EndedEvent> createEndedEvent(Identification source) { try { EndedEvent stopRequest = new EndedEvent(source); return Optional.of(stopRequest); } catch (IllegalArgumentException e) { return Optional.empty(); } }
java
{ "resource": "" }
q181026
Playlist.getCurrent
test
public TrackInfo getCurrent() { TrackInfo trackInfo = null; try { trackInfo = queue.get(position); } catch (IndexOutOfBoundsException e) { trackInfo = null; } return trackInfo; }
java
{ "resource": "" }
q181027
Playlist.update
test
public Playlist update(TrackInfo old, TrackInfo newTrackInfo) { List<TrackInfo> list = new ArrayList<>(queue); list.set(list.indexOf(old), newTrackInfo); return new Playlist(queue, name, playbackModes, position); }
java
{ "resource": "" }
q181028
Playlist.shuffle
test
public Playlist shuffle() { int position = getPosition(); long seed = System.nanoTime(); if (position >= 0 && position < queue.size()) { List<TrackInfo> trackInfos = queue.subList(0, position); List<TrackInfo> notPlayed = queue.subList(position, queue.size()); ...
java
{ "resource": "" }
q181029
Playlist.verify
test
public boolean verify(Capabilities capabilities) { for (PlaybackMode playbackMode : playbackModes) { switch (playbackMode) { case REPEAT: if (!capabilities.canRepeatPlayback()) { return false; } else { ...
java
{ "resource": "" }
q181030
Playlist.export
test
public HashMap<String, Object> export() { HashMap<String, Object> data = new HashMap<>(); for (int i = 0; i < queue.size(); i++) { data.put(QUEUE_DESCRIPTOR+i, queue.get(i).export()); } for (int i = 0; i < playbackModes.size(); i++) { data.put(PLAYBACK_MODE_DESCRI...
java
{ "resource": "" }
q181031
StringUtils.escapeForXML
test
public static final String escapeForXML(String string) { if (string == null) { return null; } char ch; int i = 0; int last = 0; char[] input = string.toCharArray(); int len = input.length; StringBuffer out = new StringBuffer((int) (len * 1.3));...
java
{ "resource": "" }
q181032
SASLMechanism.challengeReceived
test
public void challengeReceived(String challenge) throws IOException { byte response[]; if (challenge != null) { response = sc .evaluateChallenge(StringUtils.decodeBase64(challenge)); } else { response = sc.evaluateChallenge(new byte[0]); } ...
java
{ "resource": "" }
q181033
GoodwillSchemaField.toJSON
test
public ByteArrayOutputStream toJSON() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, this); return out; }
java
{ "resource": "" }
q181034
OutputPluginArgument.run
test
@Override public void run() { while (!stop) { EventModel event; try { event = blockingQueueHandling(); //gets the new Event if one was added to the blockingQueue } catch (InterruptedException e) { getContext().getLogger().warn(e); ...
java
{ "resource": "" }
q181035
ContentEventListener.handleEvent
test
public void handleEvent(Event event) { String topic = event.getTopic(); LOGGER.debug("Got Event {} {} ", event, handlers); Collection<IndexingHandler> contentIndexHandler = handlers.get(topic); if (contentIndexHandler != null && contentIndexHandler.size() > 0) { try { int ttl = Utils.toInt(event.getPrope...
java
{ "resource": "" }
q181036
ContentEventListener.joinAll
test
protected void joinAll() throws InterruptedException { if (queues != null) { for (QueueManager q : queues) { q.getQueueDispatcher().join(); } } }
java
{ "resource": "" }
q181037
Authorizable.setProperty
test
public void setProperty(String name, Object value) { if (!readOnly && !FILTER_PROPERTIES.contains(name)) { Object cv = authorizableMap.get(name); if ( value == null ) { if ( cv != null && !(cv instanceof RemoveProperty)) { modifiedMap.put(name, new Re...
java
{ "resource": "" }
q181038
Authorizable.removeProperty
test
public void removeProperty(String key) { if (!readOnly && (authorizableMap.containsKey(key) || modifiedMap.containsKey(key))) { modifiedMap.put(key, new RemoveProperty()); } }
java
{ "resource": "" }
q181039
Authorizable.addPrincipal
test
public void addPrincipal(String principal) { if (!readOnly && !principals.contains(principal)) { principals.add(principal); principalsModified = true; } }
java
{ "resource": "" }
q181040
Authorizable.removePrincipal
test
public void removePrincipal(String principal) { if (!readOnly && principals.contains(principal)) { principals.remove(principal); principalsModified = true; } }
java
{ "resource": "" }
q181041
LiteDebugger.rootWindowClosing
test
public void rootWindowClosing(WindowEvent evt) { connection.removePacketListener(listener); ((ObservableReader) reader).removeReaderListener(readerListener); ((ObservableWriter) writer).removeWriterListener(writerListener); }
java
{ "resource": "" }
q181042
PresenceNonConstant.userEncountered
test
@SuppressWarnings("unused") public void userEncountered() { List<String> descriptors = new ArrayList<>(); /* if (strict && ((!present && !fireUnknownIfNotPresent)|| !strictPresent) && addResponseDescriptors) { if (lastSeen.until(LocalDateTime.now(), ChronoUnit.MINUTES) > getMajor...
java
{ "resource": "" }
q181043
PresenceNonConstant.eventFired
test
@Override public void eventFired(EventModel event) { if (event.containsDescriptor(LeavingEvent.ID) || event.containsDescriptor(PresenceEvent.ID)) { if (event.containsDescriptor(LeavingEvent.ID)) { if (event.containsDescriptor(LeavingEvent.GENERAL_DESCRIPTOR)) { ...
java
{ "resource": "" }
q181044
MusicUsageResource.isPermanent
test
public static boolean isPermanent(ResourceModel resourceModel) { Object resource = resourceModel.getResource(); try { return (Boolean) resource; } catch (ClassCastException e) { return false; } }
java
{ "resource": "" }
q181045
RosterGroup.setName
test
public void setName(String name) { synchronized (entries) { for (RosterEntry entry : entries) { Roster packet = new Roster(); packet.setType(IQ.Type.set); List<String> groupNames = new LinkedList<String>( entry.getGroupNames());...
java
{ "resource": "" }
q181046
AbstractHashedMap.containsKey
test
public boolean containsKey(Object key) { int hashCode = hash((key == null) ? NULL : key); HashEntry entry = data[hashIndex(hashCode, data.length)]; // no local // for hash ...
java
{ "resource": "" }
q181047
AbstractHashedMap.containsValue
test
public boolean containsValue(Object value) { if (value == null) { for (int i = 0, isize = data.length; i < isize; i++) { HashEntry entry = data[i]; while (entry != null) { if (entry.getValue() == null) { return true; ...
java
{ "resource": "" }
q181048
AbstractHashedMap.put
test
public V put(K key, V value) { int hashCode = hash((key == null) ? NULL : key); int index = hashIndex(hashCode, data.length); HashEntry<K, V> entry = data[index]; while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(key, entry.getKey())) { V ol...
java
{ "resource": "" }
q181049
AbstractHashedMap.clear
test
public void clear() { modCount++; HashEntry[] data = this.data; for (int i = data.length - 1; i >= 0; i--) { data[i] = null; } size = 0; }
java
{ "resource": "" }
q181050
AbstractHashedMap.hash
test
protected int hash(Object key) { // same as JDK 1.4 int h = key.hashCode(); h += ~(h << 9); h ^= (h >>> 14); h += (h << 4); h ^= (h >>> 10); return h; }
java
{ "resource": "" }
q181051
AbstractHashedMap.isEqualKey
test
protected boolean isEqualKey(Object key1, Object key2) { return (key1 == key2 || ((key1 != null) && key1.equals(key2))); }
java
{ "resource": "" }
q181052
AbstractHashedMap.isEqualValue
test
protected boolean isEqualValue(Object value1, Object value2) { return (value1 == value2 || value1.equals(value2)); }
java
{ "resource": "" }
q181053
AbstractHashedMap.ensureCapacity
test
protected void ensureCapacity(int newCapacity) { int oldCapacity = data.length; if (newCapacity <= oldCapacity) { return; } if (size == 0) { threshold = calculateThreshold(newCapacity, loadFactor); data = new HashEntry[newCapacity]; } else { ...
java
{ "resource": "" }
q181054
AbstractHashedMap.calculateNewCapacity
test
protected int calculateNewCapacity(int proposedCapacity) { int newCapacity = 1; if (proposedCapacity > MAXIMUM_CAPACITY) { newCapacity = MAXIMUM_CAPACITY; } else { while (newCapacity < proposedCapacity) { newCapacity <<= 1; // multiply by two }...
java
{ "resource": "" }
q181055
AbstractHashedMap.createEntrySetIterator
test
protected Iterator<Map.Entry<K, V>> createEntrySetIterator() { if (size() == 0) { return EmptyIterator.INSTANCE; } return new EntrySetIterator<K, V>(this); }
java
{ "resource": "" }
q181056
Types.loadFromStream
test
public static void loadFromStream(String key, Map<String, Object> output, InputStream binaryStream, String type) throws IOException { DataInputStream dis = new DataInputStream(binaryStream); String ckey = dis.readUTF(); if (!key.equals(ckey)) { throw new IOException("Body...
java
{ "resource": "" }
q181057
AddOn.register
test
@Override public void register() { prepare(); ContentGenerator[] contentGenerators = registerContentGenerator(); if (contentGenerators != null) { for (ContentGenerator contentGenerator : contentGenerators) { try { getContext().getContentGenerat...
java
{ "resource": "" }
q181058
AddOn.initAddOn
test
@Override public void initAddOn(org.intellimate.izou.system.Context context) { this.context = new Context(context); }
java
{ "resource": "" }
q181059
ReconnectionManager.notifyReconnectionFailed
test
protected void notifyReconnectionFailed(Exception exception) { if (isReconnectionAllowed()) { for (ConnectionListener listener : connection.connectionListeners) { listener.reconnectionFailed(exception); } } }
java
{ "resource": "" }
q181060
ReconnectionManager.notifyAttemptToReconnectIn
test
protected void notifyAttemptToReconnectIn(int seconds) { if (isReconnectionAllowed()) { for (ConnectionListener listener : connection.connectionListeners) { listener.reconnectingIn(seconds); } } }
java
{ "resource": "" }