_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q180700
TimeoutMap.restart
test
public void restart() { // Clear the sweep thread kill flag. sweepThreadKillFlag = false; // Start the sweep thread running with low priority. cacheSweepThread = new Thread() { public void run() { sweep(); ...
java
{ "resource": "" }
q180701
Searches.setOf
test
public static <T> Set<T> setOf(SearchMethod<T> method) { Set<T> result = new HashSet<T>(); findAll(result, method); return result; }
java
{ "resource": "" }
q180702
Searches.bagOf
test
public static <T> Collection<T> bagOf(SearchMethod<T> method) { Collection<T> result = new ArrayList<T>(); findAll(result, method); return result; }
java
{ "resource": "" }
q180703
Searches.findAll
test
private static <T> void findAll(Collection<T> result, SearchMethod<T> method) { for (Iterator<T> i = allSolutions(method); i.hasNext();) { T nextSoltn = i.next(); result.add(nextSoltn); } }
java
{ "resource": "" }
q180704
Filterator.nextInSequence
test
public T nextInSequence() { T result = null; // Loop until a filtered element is found, or the source iterator is exhausted. while (source.hasNext()) { S next = source.next(); result = mapping.apply(next); if (result != null) { ...
java
{ "resource": "" }
q180705
BeanMemento.restoreValues
test
public static void restoreValues(Object ob, Map<String, Object> values) throws NoSuchFieldException { /*log.fine("public void restore(Object ob): called");*/ /*log.fine("Object to restore to has the type: " + ob.getClass());*/ // Get the class of th object to restore to. Class obCla...
java
{ "resource": "" }
q180706
BeanMemento.get
test
public Object get(Class cls, String property) throws NoSuchFieldException { // Check that the field exists. if (!values.containsKey(property)) { throw new NoSuchFieldException("The property, " + property + ", does not exist on the underlying class."); } // Try to...
java
{ "resource": "" }
q180707
BeanMemento.put
test
public void put(Class cls, String property, TypeConverter.MultiTypeData value) { /*log.fine("public void put(String property, TypeConverter.MultiTypeData value): called");*/ /*log.fine("property = " + property);*/ /*log.fine("value = " + value);*/ // Store the multi typed data unde...
java
{ "resource": "" }
q180708
BeanMemento.put
test
public void put(Class cls, String property, Object value) { // Store the new data under the specified property name. values.put(property, value); }
java
{ "resource": "" }
q180709
BeanMemento.capture
test
private void capture(boolean ignoreNull) { // Get the class of the object to build a memento for. Class cls = ob.getClass(); // Iterate through all the public methods of the class including all super-interfaces and super-classes. Method[] methods = cls.getMethods(); for (Me...
java
{ "resource": "" }
q180710
FifoStack.pop
test
public E pop() { E ob; if (size() == 0) { return null; } ob = get(0); remove(0); return ob; }
java
{ "resource": "" }
q180711
SwingKeyCombinationBuilder.modifiersToString
test
private String modifiersToString(int modifiers) { String result = ""; if ((modifiers & InputEvent.SHIFT_MASK) != 0) { result += "shift "; } if ((modifiers & InputEvent.CTRL_MASK) != 0) { result += "ctrl "; } if ((modifiers & ...
java
{ "resource": "" }
q180712
Validation.toInteger
test
public static int toInteger(String s) { try { return Integer.parseInt(s); } catch (NumberFormatException e) { // Exception noted so can be ignored. e = null; return 0; } }
java
{ "resource": "" }
q180713
Validation.toDate
test
public static Date toDate(String s) { // Build a date formatter using the format specified by dateFormat DateFormat dateFormatter = new SimpleDateFormat(dateFormat); try { return dateFormatter.parse(s); } catch (ParseException e) { // ...
java
{ "resource": "" }
q180714
Validation.isDate
test
public static boolean isDate(String s) { // Build a date formatter using the format specified by dateFormat DateFormat dateFormatter = new SimpleDateFormat(dateFormat); try { dateFormatter.parse(s); return true; } catch (ParseException e) ...
java
{ "resource": "" }
q180715
Validation.isTime
test
public static boolean isTime(String s) { // Build a time formatter using the format specified by timeFormat DateFormat dateFormatter = new SimpleDateFormat(timeFormat); try { dateFormatter.parse(s); return true; } catch (ParseException e) ...
java
{ "resource": "" }
q180716
Validation.isDateTime
test
public static boolean isDateTime(String s) { DateFormat dateFormatter = new SimpleDateFormat(dateTimeFormat); try { dateFormatter.parse(s); return true; } catch (ParseException e) { // Exception noted so can be ignored. ...
java
{ "resource": "" }
q180717
TokenSource.getTokenSourceForString
test
public static TokenSource getTokenSourceForString(String stringToTokenize) { SimpleCharStream inputStream = new SimpleCharStream(new StringReader(stringToTokenize), 1, 1); PrologParserTokenManager tokenManager = new PrologParserTokenManager(inputStream); return new TokenSource(tokenManager)...
java
{ "resource": "" }
q180718
TokenSource.getTokenSourceForFile
test
public static TokenSource getTokenSourceForFile(File file) throws FileNotFoundException { // Create a token source to load the model rules from. Reader ins = new FileReader(file); SimpleCharStream inputStream = new SimpleCharStream(ins, 1, 1); PrologParserTokenManager tokenManager = ...
java
{ "resource": "" }
q180719
TokenSource.getTokenSourceForInputStream
test
public static Source getTokenSourceForInputStream(InputStream in) { SimpleCharStream inputStream = new SimpleCharStream(in, 1, 1); PrologParserTokenManager tokenManager = new PrologParserTokenManager(inputStream); return new TokenSource(tokenManager); }
java
{ "resource": "" }
q180720
OptimizeInstructions.isConstant
test
public boolean isConstant(WAMInstruction instruction) { Integer name = instruction.getFunctorNameReg1(); if (name != null) { FunctorName functorName = interner.getDeinternedFunctorName(name); if (functorName.getArity() == 0) { return true...
java
{ "resource": "" }
q180721
OptimizeInstructions.isVoidVariable
test
private boolean isVoidVariable(WAMInstruction instruction) { SymbolKey symbolKey = instruction.getSymbolKeyReg1(); if (symbolKey != null) { Integer count = (Integer) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_VAR_OCCURRENCE_COUNT); Boolean nonArgPositionOnly =...
java
{ "resource": "" }
q180722
OptimizeInstructions.isNonArg
test
private boolean isNonArg(WAMInstruction instruction) { SymbolKey symbolKey = instruction.getSymbolKeyReg1(); if (symbolKey != null) { Boolean nonArgPositionOnly = (Boolean) symbolTable.get(symbolKey, SymbolTableKeys.SYMKEY_FUNCTOR_NON_ARG); if (TRUE.equals(nonArgPos...
java
{ "resource": "" }
q180723
Clause.getChildren
test
public Iterator<Operator<Term>> getChildren(boolean reverse) { if ((traverser != null) && (traverser instanceof ClauseTraverser)) { return ((ClauseTraverser) traverser).traverse(this, reverse); } else { LinkedList<Operator<Term>> resultList = null; ...
java
{ "resource": "" }
q180724
Functor.getArgument
test
public Term getArgument(int index) { if ((arguments == null) || (index > (arguments.length - 1))) { return null; } else { return arguments[index]; } }
java
{ "resource": "" }
q180725
Functor.getChildren
test
public Iterator<Operator<Term>> getChildren(boolean reverse) { if ((traverser != null) && (traverser instanceof FunctorTraverser)) { return ((FunctorTraverser) traverser).traverse(this, reverse); } else { if (arguments == null) { ...
java
{ "resource": "" }
q180726
Functor.toStringArguments
test
protected String toStringArguments() { String result = ""; if (arity > 0) { result += "[ "; for (int i = 0; i < arity; i++) { Term nextArg = arguments[i]; result += ((nextArg != null) ? nextArg.toString() : "<null>") + ((i...
java
{ "resource": "" }
q180727
SqlQueryEngine.retrieveSummary
test
public <T extends MeasureAppender> T retrieveSummary(SchemaDefinition schemaDefinition, Class<T> resultClazz, QueryParameter queryParameter) throws NovieRuntimeException { final SqlQueryBuilder<T> sqlQueryBuilder = new SqlQueryBuilder<T>(schemaDefinition, resultClazz, queryParameter.partialCopy(...
java
{ "resource": "" }
q180728
SqlQueryEngine.retrieveRecords
test
public <T extends MeasureAppender> List<T> retrieveRecords(SchemaDefinition schemaDefinition, Class<T> resultClazz, QueryParameter queryParameter) throws NovieRuntimeException { final SqlQueryBuilder<T> sqlQueryBuilder = new SqlQueryBuilder<T>(schemaDefinition, resultClazz, queryParameter); return execu...
java
{ "resource": "" }
q180729
SqlQueryEngine.executeQuery
test
private <T extends MeasureAppender> List<T> executeQuery(final SqlQueryBuilder<T> sqlQueryBuilder) throws NovieRuntimeException { sqlQueryBuilder.buildQuery(); final String queryString = sqlQueryBuilder.getQueryString(); LOG.debug(queryString); long beforeQuery = System.currentTimeMilli...
java
{ "resource": "" }
q180730
WAMInstruction.emmitCode
test
public void emmitCode(ByteBuffer codeBuffer, WAMMachine machine) throws LinkageException { mnemonic.emmitCode(this, codeBuffer, machine); }
java
{ "resource": "" }
q180731
JavaType.setBasicType
test
private void setBasicType(Class c) { if (Boolean.class.equals(c)) { type = BasicTypes.BOOLEAN; } else if (Character.class.equals(c)) { type = BasicTypes.CHARACTER; } else if (Byte.class.equals(c)) { type = BasicTypes...
java
{ "resource": "" }
q180732
ResolutionEngine.consultInputStream
test
public void consultInputStream(InputStream stream) throws SourceCodeException { // Create a token source to read from the specified input stream. Source<Token> tokenSource = TokenSource.getTokenSourceForInputStream(stream); getParser().setTokenSource(tokenSource); // Consult the typ...
java
{ "resource": "" }
q180733
ResolutionEngine.printVariableBinding
test
public String printVariableBinding(Term var) { return var.toString(getInterner(), true, false) + " = " + var.getValue().toString(getInterner(), false, true); }
java
{ "resource": "" }
q180734
ResolutionEngine.expandResultSetToMap
test
public Iterable<Map<String, Variable>> expandResultSetToMap(Iterator<Set<Variable>> solutions) { return new Filterator<Set<Variable>, Map<String, Variable>>(solutions, new Function<Set<Variable>, Map<String, Variable>>() { public Map<String, Variable> apply(Set<Variab...
java
{ "resource": "" }
q180735
SocketReadThread.run
test
public void run() { try { readStream(); } catch (EOFException eof) { // Normal disconnect } catch (SocketException se) { // Do nothing if the exception occured while shutting down the // component otherwise // log the error and try to e...
java
{ "resource": "" }
q180736
SocketReadThread.readStream
test
private void readStream() throws Exception { while (!shutdown) { Element doc = reader.parseDocument().getRootElement(); if (doc == null) { // Stop reading the stream since the server has sent an end of // stream element and // probably clo...
java
{ "resource": "" }
q180737
Type1UUID.getTime
test
static long getTime() { if (RANDOM == null) initializeForType1(); long newTime = getUUIDTime(); if (newTime <= _lastMillis) { incrementSequence(); newTime = getUUIDTime(); } _lastMillis = newTime; return newTime; }
java
{ "resource": "" }
q180738
Type1UUID.getUUIDTime
test
private static long getUUIDTime() { if (_currentMillis != System.currentTimeMillis()) { _currentMillis = System.currentTimeMillis(); _counter = 0; // reset counter } // check to see if we have created too many uuid's for this timestamp if (_counter + 1 >= MILLI_M...
java
{ "resource": "" }
q180739
Player.trackInfoUpdate
test
@SuppressWarnings("unused") public void trackInfoUpdate(Playlist playlist, TrackInfo info) { this.playlist = playlist; updatePlayInfo(info); }
java
{ "resource": "" }
q180740
Player.updatePlayInfo
test
@SuppressWarnings("unused") public void updatePlayInfo(Playlist playlist, Progress progress, Volume volume) { if (playlist != null) this.playlist = playlist; if (progress != null) this.progress = progress; if (volume != null) this.volume = volume; ...
java
{ "resource": "" }
q180741
Player.renderFinalOutput
test
@Override public void renderFinalOutput(List<T> data, EventModel eventModel) { if (StartMusicRequest.verify(eventModel, capabilities, this, activators)) { if (isOutputRunning()) { playerError(PlayerError.ERROR_ALREADY_PLAYING, eventModel.getSource()); } else { ...
java
{ "resource": "" }
q180742
Player.handleResourceRequest
test
private void handleResourceRequest(EventModel eventModel) { if (MusicUsageResource.isPermanent(eventModel)) { ResourceModel resourceModel = eventModel.getListResourceContainer() .provideResource(MusicUsageResource.ID) .stream() .filter(Musi...
java
{ "resource": "" }
q180743
Player.handleEventRequest
test
private void handleEventRequest(EventModel eventModel) { playingThread = submit((Runnable) () -> { //noinspection RedundantIfStatement if (runsInPlay) { isRunning = false; } else { isRunning = true; ...
java
{ "resource": "" }
q180744
Player.fireStartMusicRequest
test
protected void fireStartMusicRequest(EventModel eventModel) { Optional<Playlist> playlist = PlaylistResource.getPlaylist(eventModel); Optional<Progress> progress = ProgressResource.getProgress(eventModel); Optional<TrackInfo> trackInfo = TrackInfoResource.getTrackInfo(eventModel); Option...
java
{ "resource": "" }
q180745
PacketReader.init
test
protected void init() { done = false; connectionID = null; readerThread = new Thread() { public void run() { parsePackets(this); } }; readerThread.setName("Smack Packet Reader (" + connection.connectionCounterValue + ")"); ...
java
{ "resource": "" }
q180746
PacketReader.startup
test
synchronized public void startup() throws XMPPException { final List<Exception> errors = new LinkedList<Exception>(); AbstractConnectionListener connectionErrorListener = new AbstractConnectionListener() { @Override public void connectionClosedOnError(Exception e) { ...
java
{ "resource": "" }
q180747
PacketReader.shutdown
test
public void shutdown() { // Notify connection listeners of the connection closing if done hasn't // already been set. if (!done) { for (ConnectionListener listener : connection .getConnectionListeners()) { try { listener.connect...
java
{ "resource": "" }
q180748
PacketReader.resetParser
test
private void resetParser() { try { innerReader = new XPPPacketReader(); innerReader.setXPPFactory(XmlPullParserFactory.newInstance()); innerReader.getXPPParser().setInput(connection.reader); reset = true; } catch (Exception xppe) { LOGGER.log(L...
java
{ "resource": "" }
q180749
PacketReader.parsePackets
test
private void parsePackets(Thread thread) { try { while (!done) { if (reset) { startStream(); LOGGER.debug("Started xmlstream..."); reset = false; continue; } Element doc = ...
java
{ "resource": "" }
q180750
PacketReader.processPacket
test
private void processPacket(Packet packet) { if (packet == null) { return; } // Loop through all collectors and notify the appropriate ones. for (PacketCollector collector : connection.getPacketCollectors()) { collector.processPacket(packet); } //...
java
{ "resource": "" }
q180751
AbstractApplicationOption.setCliOption
test
protected final void setCliOption(Option option){ if(option!=null){ this.cliOption = option; } if(this.cliOption.getDescription()!=null){ this.descr = this.cliOption.getDescription(); } else{ this.cliOption.setDescription(this.descr); } }
java
{ "resource": "" }
q180752
ChatManager.createChat
test
public Chat createChat(String userJID, MessageListener listener) { return createChat(userJID, null, listener); }
java
{ "resource": "" }
q180753
InternalContent.internalize
test
void internalize(ContentManagerImpl contentManager, boolean readOnly) { this.contentManager = contentManager; updated = false; newcontent = false; this.readOnly = readOnly; }
java
{ "resource": "" }
q180754
InternalContent.reset
test
public void reset(Map<String, Object> updatedMap) { if (!readOnly) { this.content = ImmutableMap.copyOf(updatedMap); updatedContent.clear(); updated = false; LOGGER.debug("Reset to {} ", updatedMap); } }
java
{ "resource": "" }
q180755
InternalContent.setProperty
test
public void setProperty(String key, Object value) { if (readOnly) { return; } if (value == null) { throw new IllegalArgumentException("value must not be null"); } Object o = content.get(key); if (!value.equals(o)) { updatedContent.put(k...
java
{ "resource": "" }
q180756
OrFilter.addFilter
test
public void addFilter(PacketFilter filter) { if (filter == null) { throw new IllegalArgumentException("Parameter cannot be null."); } // If there is no more room left in the filters array, expand it. if (size == filters.length) { PacketFilter[] newFilters = new Pa...
java
{ "resource": "" }
q180757
ModificationRequest.processRequest
test
public void processRequest(HttpServletRequest request) throws IOException, FileUploadException, StorageClientException, AccessDeniedException { boolean debug = LOGGER.isDebugEnabled(); if (ServletFileUpload.isMultipartContent(request)) { if (debug) { LOGGER.debug("Multipart POST "); } feedback.add("...
java
{ "resource": "" }
q180758
ModificationRequest.resetProperties
test
public void resetProperties() { for ( Entry<ParameterType, Map<String, Object>> e : stores.entrySet()) { e.getValue().clear(); } }
java
{ "resource": "" }
q180759
PacketWriter.init
test
protected void init() { this.writer = connection.writer; done = false; writerThread = new Thread() { public void run() { writePackets(this); } }; writerThread.setName("Smack Packet Writer (" + connection.connectionCounterVa...
java
{ "resource": "" }
q180760
PacketWriter.sendPacket
test
public void sendPacket(Packet packet) { if (!done) { // Invoke interceptors for the new packet that is about to be sent. // Interceptors // may modify the content of the packet. connection.firePacketInterceptors(packet); try { queue.pu...
java
{ "resource": "" }
q180761
PacketWriter.nextPacket
test
private Packet nextPacket() { Packet packet = null; // Wait until there's a packet or we're done. while (!done && (packet = queue.poll()) == null) { try { synchronized (queue) { queue.wait(); } } catch (InterruptedExcept...
java
{ "resource": "" }
q180762
PacketWriter.openStream
test
void openStream() throws IOException { StringBuilder stream = new StringBuilder(); stream.append("<stream:stream"); stream.append(" to=\"").append(connection.getServiceName()) .append("\""); stream.append(" xmlns=\"jabber:client\""); stream.append(" xmlns:stream=\...
java
{ "resource": "" }
q180763
Event.getAllInformations
test
@Override public List<String> getAllInformations() { ArrayList<String> strings = new ArrayList<>(descriptors); strings.add(type); return strings; }
java
{ "resource": "" }
q180764
Event.containsDescriptor
test
@Override public boolean containsDescriptor(String descriptor) { return descriptors.contains(descriptor) || type.equals(descriptor); }
java
{ "resource": "" }
q180765
Event.addEventLifeCycleListener
test
@SuppressWarnings("unused") public Event addEventLifeCycleListener(EventLifeCycle eventLifeCycle, Consumer<EventLifeCycle> cycleCallback) { lifeCycleListeners.compute(eventLifeCycle, (unused, list) -> { if (list == null) list = new ArrayList<>(); list.add(cycleCallbac...
java
{ "resource": "" }
q180766
TaskEngine.shutdown
test
public void shutdown() { if (executor != null) { executor.shutdownNow(); executor = null; } if (timer != null) { timer.cancel(); timer = null; } }
java
{ "resource": "" }
q180767
Files.contentEquals
test
public static Boolean contentEquals(Path file1, Path file2) throws IOException { if (!java.nio.file.Files.isRegularFile(file1)) throw new IllegalArgumentException(file1 + "is not a regular file"); if (!java.nio.file.Files.isRegularFile(file2)) throw new IllegalArgumentException(file2 + "is not a ...
java
{ "resource": "" }
q180768
Files.cleanDirectByteBuffer
test
public static void cleanDirectByteBuffer(final ByteBuffer byteBuffer) { if (byteBuffer == null) return; if (!byteBuffer.isDirect()) throw new IllegalArgumentException("byteBuffer isn't direct!"); AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { ...
java
{ "resource": "" }
q180769
TransactionalHashMap.validEntry
test
private boolean validEntry(final Entry<K,V> entry) { if (auto_commit || entry == null) return (entry != null); String id = getCurrentThreadId(); return !((entry.is(Entry.DELETED, id)) || (entry.is(Entry.ADDED, null) && entry.is(Entry.NO_CHANGE, id)...
java
{ "resource": "" }
q180770
TransactionalHashMap.maskNull
test
@SuppressWarnings("unchecked") static <T> T maskNull(T key) { return (key == null ? (T)NULL_KEY : key); }
java
{ "resource": "" }
q180771
TransactionalHashMap.eq
test
static boolean eq(Object x, Object y) { return x == y || x.equals(y); }
java
{ "resource": "" }
q180772
TransactionalHashMap.getEntry
test
Entry<K,V> getEntry(Object key) { Object k = maskNull(key); int hash = hash(k); int i = indexFor(hash, table.length); Entry<K,V> e = table[i]; while (e != null && !(e.hash == hash && validEntry(e) && eq(k, e.key))) e = e.next; return e; }
java
{ "resource": "" }
q180773
TransactionalHashMap.resize
test
@SuppressWarnings("unchecked") void resize(int newCapacity) { Entry<K,V>[] oldTable = table; int oldCapacity = oldTable.length; if (oldCapacity == MAXIMUM_CAPACITY) { threshold = Integer.MAX_VALUE; return; } Entry<K,V>[]...
java
{ "resource": "" }
q180774
TransactionalHashMap.putAll
test
@Override public void putAll(Map<? extends K, ? extends V> m) { int numKeysToBeAdded = m.size(); if (numKeysToBeAdded == 0) return; /* * Expand the map if the map if the number of mappings to be added * is greater than or equal to threshold...
java
{ "resource": "" }
q180775
TransactionalHashMap.remove
test
@Override public V remove(Object key) throws ConcurrentModificationException { Entry<K,V> e = removeEntryForKey(key); return (e == null ? null : e.value); }
java
{ "resource": "" }
q180776
TransactionalHashMap.removeEntryForKey
test
Entry<K,V> removeEntryForKey(Object key) throws ConcurrentModificationException { Object k = maskNull(key); int hash = hash(k); int i = indexFor(hash, table.length); Entry<K,V> prev = table[i]; Entry<K,V> e = prev; while (e != null) { ...
java
{ "resource": "" }
q180777
TransactionalHashMap.removeMapping
test
@SuppressWarnings("unchecked") Entry<K,V> removeMapping(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry<K,V> entry = (Map.Entry<K,V>)o; Object k = maskNull(entry.getKey()); int hash = hash(k); int i = indexFor(hash, table.le...
java
{ "resource": "" }
q180778
TransactionalHashMap.addEntry
test
void addEntry(int hash, K key, V value, int bucketIndex) { table[bucketIndex] = new Entry<K,V>(hash, key, value, table[bucketIndex]); if (!auto_commit) table[bucketIndex].setStatus(Entry.ADDED, getCurrentThreadId()); if (size++ >= threshold) resize(2 * table.len...
java
{ "resource": "" }
q180779
AugmentedMap.createDelegate
test
private static <K, V> ImmutableMap<K, V> createDelegate( final Map<K, V> base, final Set<? extends K> keys, final Function<K, V> augmentation ) { final ImmutableMap.Builder<K, V> builder = ImmutableMap.builder(); builder.putAll(base); keys.stream() .filter...
java
{ "resource": "" }
q180780
StringUtils.xmlAttribEncodeBinary
test
private static String xmlAttribEncodeBinary(String value) { StringBuilder s = new StringBuilder(); char buf[] = value.toCharArray(); for (char c : buf) { switch (c) { case '<': s.append("&lt;"); break; case '>': ...
java
{ "resource": "" }
q180781
StringUtils.encodeHex
test
public static String encodeHex(byte[] bytes) { StringBuilder hex = new StringBuilder(bytes.length * 2); for (byte aByte : bytes) { if (((int) aByte & 0xff) < 0x10) { hex.append("0"); } hex.append(Integer.toString((int) aByte & 0xff, 16)); } ...
java
{ "resource": "" }
q180782
StringUtils.encodeBase64
test
public static String encodeBase64(String data) { byte[] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { throw new IllegalStateException(uee); } return encodeBase64(bytes); }
java
{ "resource": "" }
q180783
StringUtils.encodeBase64
test
public static String encodeBase64(byte[] data, int offset, int len, boolean lineBreaks) { return Base64.encodeBytes(data, offset, len, (lineBreaks ? Base64.NO_OPTIONS : Base64.DONT_BREAK_LINES)); }
java
{ "resource": "" }
q180784
CounterIterativeCallback.iterate
test
@Override public Integer iterate(final FilterableCollection<? extends T> c) { checkUsed(); // No point doing the iteration. Just return size of collection. count = c.size(); return count; }
java
{ "resource": "" }
q180785
CommandHandler.setTrackSelectorController
test
public void setTrackSelectorController(Consumer<TrackInfo> controller) { if (controller == null) return; selectTrack = controller; capabilities.setAbleToSelectTrack(true); }
java
{ "resource": "" }
q180786
CommandHandler.setJumpProgressController
test
public void setJumpProgressController(Consumer<Progress> controller) { if (controller == null) return; jumpProgress = controller; capabilities.setAbleToJump(true); }
java
{ "resource": "" }
q180787
CommandHandler.setPlaybackChangeableController
test
public void setPlaybackChangeableController(Consumer<String> controller) { if (controller == null) return; changePlayback = controller; capabilities.setPlaybackChangeable(true); }
java
{ "resource": "" }
q180788
CommandHandler.setVolumeChangeableController
test
public void setVolumeChangeableController(Consumer<Volume> controller) { if (controller == null) return; changeVolume = controller; capabilities.setChangeVolume(true); }
java
{ "resource": "" }
q180789
CommandHandler.broadcastAvailablePlaylists
test
public void broadcastAvailablePlaylists(Supplier<List<String>> availablePlaylist, Function<String, Playlist> playlistForNameFunction) { if (availablePlaylist == null || playlistForNameFunction == null) return; this.availablePlaylist = availablePlaylist; this.playlistForNameFunction =...
java
{ "resource": "" }
q180790
CommandHandler.handleCommandResources
test
public void handleCommandResources(EventModel eventModel) { List<ResourceModel<String>> resourceModels = eventModel.getListResourceContainer() .provideResource(CommandResource.ResourceID) .stream() .filter(resourceModel -> resourceModel.getResource() instanceof St...
java
{ "resource": "" }
q180791
CommandHandler.handleVolume
test
private void handleVolume(EventModel eventModel, ResourceModel<String> resourceModel) { Optional<Volume> volumeResource = VolumeResource.getVolume(eventModel); if (!volumeResource.isPresent()) { musicHelper.playerError(PlayerError.ERROR_ILLEGAL + "command: " + resourceModel.getResource() + "...
java
{ "resource": "" }
q180792
CommandHandler.handleJump
test
private void handleJump(EventModel eventModel, ResourceModel<String> resourceModel) { Optional<Progress> progress = ProgressResource.getProgress(eventModel); if (!progress.isPresent()) { musicHelper.playerError(PlayerError.ERROR_ILLEGAL + "command: " + resourceModel.getResource() + "missing ...
java
{ "resource": "" }
q180793
CommandHandler.handleSelectTrack
test
private void handleSelectTrack(EventModel eventModel, ResourceModel<String> resourceModel) { Optional<TrackInfo> trackInfo = TrackInfoResource.getTrackInfo(eventModel); if (!trackInfo.isPresent()) { musicHelper.playerError(PlayerError.ERROR_ILLEGAL + "command: " + resourceModel.getResource()...
java
{ "resource": "" }
q180794
CacheManagerServiceImpl.getThreadCache
test
@SuppressWarnings("unchecked") private <V> Cache<V> getThreadCache(String name) { Map<String, Cache<?>> threadCacheMap = threadCacheMapHolder.get(); Cache<V> threadCache = (Cache<V>) threadCacheMap.get(name); if (threadCache == null) { threadCache = new MapCacheImpl<V>(); threadCacheMap.put(na...
java
{ "resource": "" }
q180795
CacheManagerServiceImpl.getRequestCache
test
@SuppressWarnings("unchecked") private <V> Cache<V> getRequestCache(String name) { Map<String, Cache<?>> requestCacheMap = requestCacheMapHolder.get(); Cache<V> requestCache = (Cache<V>) requestCacheMap.get(name); if (requestCache == null) { requestCache = new MapCacheImpl<V>(); requestCacheMa...
java
{ "resource": "" }
q180796
StorageClientUtils.getAltField
test
public static String getAltField(String field, String streamId) { if (streamId == null) { return field; } return field + "/" + streamId; }
java
{ "resource": "" }
q180797
StorageClientUtils.getFilterMap
test
@SuppressWarnings("unchecked") public static <K, V> Map<K, V> getFilterMap(Map<K, V> source, Map<K, V> modified, Set<K> include, Set<K> exclude, boolean includingRemoveProperties ) { if ((modified == null || modified.size() == 0) && (include == null) && ( exclude == null || exclude.size() == 0)) { ...
java
{ "resource": "" }
q180798
StorageClientUtils.shardPath
test
public static String shardPath(String id) { String hash = insecureHash(id); return hash.substring(0, 2) + "/" + hash.substring(2, 4) + "/" + hash.substring(4, 6) + "/" + id; }
java
{ "resource": "" }
q180799
StorageClientUtils.adaptToSession
test
public static Session adaptToSession(Object source) { if (source instanceof SessionAdaptable) { return ((SessionAdaptable) source).getSession(); } else { // assume this is a JCR session of someform, in which case there // should be a SparseUserManager Obje...
java
{ "resource": "" }