_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q178900
WebSheetLoader.refreshCachedCell
test
public final void refreshCachedCell(final String tblName, final int i, final int index, final Cell cell, final FacesCell fcell) { if ((cell != null) && (cell.getCellTypeEnum() == CellType.FORMULA) && (tblName != null)) { try { processRefreshCell(tblName, i, index, cell, fcell); } catch (Exception ex) { LOG.log(Level.SEVERE, "refresh Cached Cell error : " + ex.getLocalizedMessage(), ex); } } }
java
{ "resource": "" }
q178901
WebSheetLoader.processRefreshCell
test
private void processRefreshCell(final String tblName, final int i, final int index, final Cell cell, final FacesCell fcell) { String newValue = CellUtility.getCellValueWithFormat(cell, parent.getFormulaEvaluator(), parent.getDataFormatter()); if (parent.getCachedCells().isValueChanged(cell, newValue)) { if (fcell.isHasSaveAttr()) { parent.getCellHelper().saveDataInContext(cell, newValue); } RequestContext.getCurrentInstance().update(tblName + ":" + i + ":cocalc" + index); parent.getCachedCells().put(cell, CellType.FORMULA); } }
java
{ "resource": "" }
q178902
WebSheetLoader.createDynamicColumns
test
private void createDynamicColumns(final String tabName) { SheetConfiguration sheetConfig = parent.getSheetConfigMap().get(tabName); int left = sheetConfig.getBodyCellRange().getLeftCol(); int right = sheetConfig.getBodyCellRange().getRightCol(); parent.getColumns().clear(); for (int i = left; i <= right; i++) { parent.getColumns().add("column" + (i - left)); } }
java
{ "resource": "" }
q178903
WebSheetLoader.addRepeatRow
test
public final void addRepeatRow(final int rowIndex) { try { SheetConfiguration sheetConfig = parent.getSheetConfigMap().get(parent.getCurrent().getCurrentTabName()); Sheet sheet = parent.getWb().getSheet(sheetConfig.getSheetName()); ConfigBuildRef configBuildRef = new ConfigBuildRef(parent.getWbWrapper(), sheet, parent.getExpEngine(), parent.getCellHelper(), sheetConfig.getCachedCells(), parent.getCellAttributesMap(), sheetConfig.getFinalCommentMap()); // set add mode configBuildRef.setAddMode(true); configBuildRef.setCollectionObjNameMap(sheetConfig.getCollectionObjNameMap()); configBuildRef.setCommandIndexMap(sheetConfig.getCommandIndexMap()); configBuildRef.setShiftMap(sheetConfig.getShiftMap()); configBuildRef.setWatchList(sheetConfig.getWatchList()); int length = CommandUtility.addRow(configBuildRef, rowIndex, parent.getSerialDataContext().getDataContext()); refreshBodyRowsInRange(configBuildRef.getInsertPosition(), length, sheet, sheetConfig); parent.getCellHelper().reCalc(); } catch (AddRowException e) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Add Row Error", e.getMessage())); LOG.log(Level.SEVERE, "Add row error = " + e.getLocalizedMessage(), e); } catch (Exception ex) { LOG.log(Level.SEVERE, "Add row error = " + ex.getLocalizedMessage(), ex); } }
java
{ "resource": "" }
q178904
WebSheetLoader.refreshBodyRowsInRange
test
private void refreshBodyRowsInRange(final int insertPosition, final int length, final Sheet sheet, final SheetConfiguration sheetConfig) { Map<String, CellRangeAddress> cellRangeMap = ConfigurationUtility.indexMergedRegion(sheet); List<String> skippedRegionCells = ConfigurationUtility.skippedRegionCells(sheet); int top = sheetConfig.getBodyCellRange().getTopRow(); int left = sheetConfig.getBodyCellRange().getLeftCol(); int right = sheetConfig.getBodyCellRange().getRightCol(); for (int irow = insertPosition; irow < (insertPosition + length); irow++) { parent.getBodyRows().add(irow - top, assembleFacesBodyRow(irow, sheet, left, right, sheetConfig, cellRangeMap, skippedRegionCells)); } for (int irow = insertPosition + length - top; irow < parent.getBodyRows().size(); irow++) { FacesRow facesrow = parent.getBodyRows().get(irow); facesrow.setRowIndex(facesrow.getRowIndex() + length); } }
java
{ "resource": "" }
q178905
WebSheetLoader.setUnsavedStatus
test
public void setUnsavedStatus(final RequestContext requestContext, final Boolean statusFlag) { // in client js should have setUnsavedState method if (requestContext != null) { LOG.log(Level.FINE, "run setUnsavedState( {} )", statusFlag.toString()); requestContext.execute("setUnsavedState(" + statusFlag.toString() + ")"); } }
java
{ "resource": "" }
q178906
WebSheetLoader.isUnsavedStatus
test
public final Boolean isUnsavedStatus() { Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap(); Boolean flag = (Boolean) viewMap.get(TieConstants.UNSAVEDSTATE); if (flag == null) { return false; } return flag; }
java
{ "resource": "" }
q178907
Utils.commonConstructor
test
public static <T> Constructor<T> commonConstructor(Class<T> type) throws NoMethodForDependency { Constructor<?>[] cs = type.getDeclaredConstructors(); if (cs.length == 0) throw new NoMethodForDependency(raw(type)); Constructor<?> mostParamsConstructor = null; for (Constructor<?> c : cs) { if (!arrayContains(c.getParameterTypes(), type, (a, b) -> a == b) // avoid self referencing constructors (synthetic) as they cause endless loop && (mostParamsConstructor == null // || (moreVisible(c, mostParamsConstructor) == c && (moreVisible(mostParamsConstructor, c) == c || c.getParameterCount() > mostParamsConstructor.getParameterCount())))) { mostParamsConstructor = c; } } if (mostParamsConstructor == null) throw new NoMethodForDependency(raw(type)); @SuppressWarnings("unchecked") Constructor<T> c = (Constructor<T>) mostParamsConstructor; return c; }
java
{ "resource": "" }
q178908
BinaryData.writeInputStreamToOutput
test
protected static void writeInputStreamToOutput(final Context context, final InputStream source, final OutputStream output) throws IOException { BuffersPool pool = BeansManager.get(context).getContainer().getBean(BuffersPool.class); IoUtils.transfer(source, output, pool); }
java
{ "resource": "" }
q178909
CacheEntry.writeLong
test
protected static void writeLong(final Writer writer, final long value) throws IOException { writer.write(new StringBuilder().append(value).append('\n').toString()); }
java
{ "resource": "" }
q178910
CacheEntry.writeString
test
protected final void writeString(final Writer writer, final String line) throws IOException { if (line != null) { writer.write(line + '\n'); } else { writer.write('\n'); } }
java
{ "resource": "" }
q178911
BaseRequestBuilder.setConvertedTrafficStatsTag
test
protected void setConvertedTrafficStatsTag(final String tag) { result.statsTag = Utils.getTrafficStatsTag(tag); if (config.isDebugRest()) { Log.d(TAG, "TrafficStats tag <" + tag + ">=" + Integer.toHexString(result.statsTag)); } }
java
{ "resource": "" }
q178912
BaseRequestBuilder.addBitmap
test
protected void addBitmap(final String name, final Bitmap bitmap, final String fileName) { final BitmapBinaryData bdata = new BitmapBinaryData(); bdata.setName(name); bdata.setContentName(fileName); bdata.setBitmap(bitmap); result.addBinaryData(bdata); }
java
{ "resource": "" }
q178913
BaseRequestBuilder.addFileDescriptor
test
protected void addFileDescriptor(final String name, final AssetFileDescriptor fd, final String contentType, final String fileName) { final AssetFdBinaryData bdata = new AssetFdBinaryData(); bdata.setFileDescriptor(fileName, fd); bdata.setName(name); bdata.setContentType(contentType); result.addBinaryData(bdata); }
java
{ "resource": "" }
q178914
BaseRequestBuilder.removeParameter
test
protected Parameter removeParameter(final String name) { if (name == null) { throw new IllegalArgumentException("Parameter name cannot be null"); } final Iterator<Parameter> iter = result.simpleParameters.getChildren().iterator(); while (iter.hasNext()) { final Parameter p = iter.next(); if (name.equals(p.name)) { iter.remove(); return p; } } return null; }
java
{ "resource": "" }
q178915
BaseRequestBuilder.addHeader
test
protected BaseRequestBuilder<MT> addHeader(final String name, final String value) { result.addHeader(name, value); return this; }
java
{ "resource": "" }
q178916
BaseRequestBuilder.clear
test
public void clear() { final RequestDescription result = this.result; result.simpleParameters.children.clear(); result.clearBinaryData(); result.contentType = null; result.clearHeaders(); }
java
{ "resource": "" }
q178917
StreamingPlaybackController.callPlay
test
protected void callPlay(final Uri uri, final int volume, final Bundle params) { playing = true; paused = false; context.startService( createPlayIntent().setData(uri) .putExtra(StreamingPlaybackService.EXTRA_VOLUME, volume) .putExtra(StreamingPlaybackService.EXTRA_TRACK_INFO, params) ); bind(); onPlayingChanged(); preparing = true; onPreparingChanged(); }
java
{ "resource": "" }
q178918
StreamingPlaybackController.callStop
test
protected void callStop() { playing = false; paused = false; context.startService(createStopIntent()); onPlayingChanged(); preparing = false; onPreparingChanged(); }
java
{ "resource": "" }
q178919
StreamingPlaybackController.bind
test
protected final void bind() { if (bindRequested) { return; } final boolean result = context.bindService(createBindIntent(), serviceConnection, 0); if (DEBUG) { Log.v(TAG, "Bind to streaming service: " + result); } bindRequested = result; onBind(result); }
java
{ "resource": "" }
q178920
StreamingPlaybackController.unbind
test
protected final void unbind() { if (streamingPlayback != null) { dropListener(); } try { context.unbindService(serviceConnection); } catch (final RuntimeException e) { if (DEBUG) { Log.w(TAG, "Cannot unbind radio", e); } } bindRequested = false; }
java
{ "resource": "" }
q178921
StreamingPlaybackController.dropListener
test
protected final void dropListener() { if (DEBUG) { Log.v(TAG, "Drop listener"); } if (streamingPlayback != null) { try { streamingPlayback.removeListener(); } catch (final RemoteException e) { Log.e(TAG, "Cannot remove listener", e); } bindRequested = false; } }
java
{ "resource": "" }
q178922
ImageRequest.storeToDisk
test
public void storeToDisk() throws IOException { if (manager.isPresentOnDisk(url)) { return; } if (!hasAllowedSize()) { IoUtils.consumeStream(getRemoteInputStream(), manager.getBuffersPool()); return; } ImageResult result = decodeStream(getRemoteInputStream(), true); if (result.getType() == ImageSourceType.NETWORK && result.getBitmap() != null) { // image was scaled writeBitmapToDisk(result.getBitmap()); } }
java
{ "resource": "" }
q178923
IoUtils.streamToString
test
public static String streamToString(final InputStream stream, final String charset, final BuffersPool buffersPool) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); transfer(stream, output, buffersPool); return new String(output.toByteArray(), charset); }
java
{ "resource": "" }
q178924
IoUtils.streamToString
test
public static String streamToString(final InputStream stream, final BuffersPool buffersPool) throws IOException { return streamToString(stream, UTF_8_NAME, buffersPool); }
java
{ "resource": "" }
q178925
StringPart.sendData
test
@Override protected void sendData(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendData(OutputStream)"); } out.write(getContent()); }
java
{ "resource": "" }
q178926
PoolableBufferedInputStream.available
test
@Override public synchronized int available() throws IOException { final InputStream localIn = in; // 'in' could be invalidated by close() if (buf == null || localIn == null) { throw new IOException("Stream is closed"); } return count - pos + localIn.available(); }
java
{ "resource": "" }
q178927
PoolableBufferedInputStream.close
test
@Override public void close() throws IOException { final byte[] localBuf = buf; buf = null; final InputStream localIn = in; in = null; pool.release(localBuf); if (localIn != null) { localIn.close(); } }
java
{ "resource": "" }
q178928
PoolableBufferedInputStream.read
test
@Override public synchronized int read() throws IOException { // Use local refs since buf and in may be invalidated by an // unsynchronized close() byte[] localBuf = buf; final InputStream localIn = in; if (localBuf == null || localIn == null) { throw new IOException("Stream is closed"); } /* Are there buffered bytes available? */ if (pos >= count && fillbuf(localIn, localBuf) == -1) { return -1; /* no, fill buffer */ } // localBuf may have been invalidated by fillbuf if (localBuf != buf) { localBuf = buf; if (localBuf == null) { throw new IOException("Stream is closed"); } } /* Did filling the buffer fail with -1 (EOF)? */ final int mask = 0xFF; if (count - pos > 0) { return localBuf[pos++] & mask; } return -1; }
java
{ "resource": "" }
q178929
PoolableBufferedInputStream.reset
test
@Override public synchronized void reset() throws IOException { // BEGIN android-changed /* * These exceptions get thrown in some "normalish" circumstances, * so it is preferable to avoid loading up the whole big set of * messages just for these cases. */ if (buf == null) { throw new IOException("Stream is closed"); } if (-1 == markpos) { throw new IOException("Mark has been invalidated."); } // END android-changed pos = markpos; }
java
{ "resource": "" }
q178930
Part.sendStart
test
protected void sendStart(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendStart(OutputStream out)"); } out.write(EXTRA_BYTES); out.write(getPartBoundary()); out.write(CRLF_BYTES); }
java
{ "resource": "" }
q178931
Part.sendDispositionHeader
test
protected void sendDispositionHeader(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendDispositionHeader(OutputStream out)"); } out.write(CONTENT_DISPOSITION_BYTES); out.write(QUOTE_BYTES); out.write(EncodingUtils.getAsciiBytes(getName())); out.write(QUOTE_BYTES); }
java
{ "resource": "" }
q178932
Part.sendContentTypeHeader
test
protected void sendContentTypeHeader(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendContentTypeHeader(OutputStream out)"); } final String contentType = getContentType(); if (contentType != null) { out.write(CRLF_BYTES); out.write(CONTENT_TYPE_BYTES); out.write(EncodingUtils.getAsciiBytes(contentType)); final String charSet = getCharSet(); if (charSet != null) { out.write(CHARSET_BYTES); out.write(EncodingUtils.getAsciiBytes(charSet)); } } }
java
{ "resource": "" }
q178933
Part.sendTransferEncodingHeader
test
protected void sendTransferEncodingHeader(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendTransferEncodingHeader(OutputStream out)"); } final String transferEncoding = getTransferEncoding(); if (transferEncoding != null) { out.write(CRLF_BYTES); out.write(CONTENT_TRANSFER_ENCODING_BYTES); out.write(EncodingUtils.getAsciiBytes(transferEncoding)); } }
java
{ "resource": "" }
q178934
Part.sendEndOfHeader
test
protected void sendEndOfHeader(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendEndOfHeader(OutputStream out)"); } out.write(CRLF_BYTES); out.write(CRLF_BYTES); }
java
{ "resource": "" }
q178935
Part.sendEnd
test
protected void sendEnd(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendEnd(OutputStream out)"); } out.write(CRLF_BYTES); }
java
{ "resource": "" }
q178936
Part.sendParts
test
public static void sendParts(final OutputStream out, final Part[] parts, final byte[] partBoundary) throws IOException { if (parts == null) { throw new IllegalArgumentException("Parts may not be null"); } if (partBoundary == null || partBoundary.length == 0) { throw new IllegalArgumentException("partBoundary may not be empty"); } for (int i = 0; i < parts.length; i++) { // set the part boundary before the part is sent parts[i].setPartBoundary(partBoundary); parts[i].send(out); } out.write(EXTRA_BYTES); out.write(partBoundary); out.write(EXTRA_BYTES); out.write(CRLF_BYTES); }
java
{ "resource": "" }
q178937
Part.getLengthOfParts
test
public static long getLengthOfParts(final Part[] parts, final byte[] partBoundary) throws IOException { if (DEBUG) { Log.v(TAG, "getLengthOfParts(Parts[])"); } if (parts == null) { throw new IllegalArgumentException("Parts may not be null"); } long total = 0; for (int i = 0; i < parts.length; i++) { // set the part boundary before we calculate the part's length parts[i].setPartBoundary(partBoundary); final long l = parts[i].length(); if (l < 0) { return -1; } total += l; } total += EXTRA_BYTES.length; total += partBoundary.length; total += EXTRA_BYTES.length; total += CRLF_BYTES.length; return total; }
java
{ "resource": "" }
q178938
WebsockifyProxyHandler.isRedirect
test
private String isRedirect(String uri) throws URISyntaxException, MalformedURLException { // Decode the path. URI url = new URI (uri); if ( REDIRECT_PATH.equals(url.getPath()) ) { String query = url.getRawQuery(); Map<String, String> params = getQueryMap(query); String urlParam = params.get(URL_PARAMETER); if ( urlParam == null ) return null; try { return URLDecoder.decode(urlParam, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger.getLogger(WebsockifyProxyHandler.class.getName()).severe(e.getMessage()); } } return null; }
java
{ "resource": "" }
q178939
WebsockifyProxyHandler.sendNotModified
test
private void sendNotModified(ChannelHandlerContext ctx) { HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.NOT_MODIFIED); setDateHeader(response); // Close the connection as soon as the error message is sent. ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE); }
java
{ "resource": "" }
q178940
WebsockifyProxyHandler.setDateHeader
test
private void setDateHeader(HttpResponse response) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US); dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE)); Calendar time = new GregorianCalendar(); response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime())); }
java
{ "resource": "" }
q178941
WebsockifyProxyHandler.setDateAndCacheHeaders
test
private void setDateAndCacheHeaders(HttpResponse response, File fileToCache) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US); dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE)); // Date header Calendar time = new GregorianCalendar(); response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime())); // Add cache headers time.add(Calendar.SECOND, HTTP_CACHE_SECONDS); response.setHeader(HttpHeaders.Names.EXPIRES, dateFormatter.format(time.getTime())); response.setHeader(HttpHeaders.Names.CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS); response.setHeader(HttpHeaders.Names.LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified()))); }
java
{ "resource": "" }
q178942
WebsockifyProxyHandler.setContentTypeHeader
test
private void setContentTypeHeader(HttpResponse response, File file) { MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); response.setHeader(HttpHeaders.Names.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath())); }
java
{ "resource": "" }
q178943
WebsockifyProxyHandler.closeOnFlush
test
static void closeOnFlush(Channel ch) { if (ch.isConnected()) { ch.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } }
java
{ "resource": "" }
q178944
FilePart.sendDispositionHeader
test
@Override protected void sendDispositionHeader(final OutputStream out) throws IOException { if (DEBUG) { Log.v("FilePart", "enter sendDispositionHeader(OutputStream out)"); } super.sendDispositionHeader(out); final String filename = this.source.getFileName(); if (filename != null) { out.write(FILE_NAME_BYTES); out.write(QUOTE_BYTES); out.write(EncodingUtils.getAsciiBytes(filename)); out.write(QUOTE_BYTES); } }
java
{ "resource": "" }
q178945
FilePart.sendData
test
@Override protected void sendData(final OutputStream out) throws IOException { if (DEBUG) { Log.v(TAG, "enter sendData(OutputStream out)"); } if (lengthOfData() == 0) { // this file contains no data, so there is nothing to send. // we don't want to create a zero length buffer as this will // cause an infinite loop when reading. if (DEBUG) { Log.d(TAG, "No data to send."); } return; } final int size = 4096; final byte[] tmp = new byte[size]; final InputStream instream = source.createInputStream(); try { int len; while ((len = instream.read(tmp)) >= 0) { out.write(tmp, 0, len); } } finally { // we're done with the stream, close it instream.close(); } }
java
{ "resource": "" }
q178946
BaseFileResponseCache.install
test
protected void install(final int version) throws IOException { if (buffersPool == null) { throw new IllegalStateException("Buffers pool is not resolved"); } diskCache = DiskLruCache.open(ensureWorkingDirectory(), version, ENTRIES_COUNT, getMaxSize()); onCacheInstalled(); }
java
{ "resource": "" }
q178947
BaseFileResponseCache.ensureWorkingDirectory
test
private synchronized File ensureWorkingDirectory() throws IOException { File directory = getWorkingDirectory(); if (!directory.exists()) { if (!directory.mkdirs()) { throw new IOException("Working directory " + directory + " cannot be created"); } } else { if (!directory.isDirectory()) { if (!directory.delete()) { throw new IOException(directory + " is not a directory and cannot be deleted"); } if (!directory.mkdirs()) { throw new IOException("Working directory " + directory + " cannot be recreated"); } } } return directory; }
java
{ "resource": "" }
q178948
BaseFileResponseCache.get
test
protected CacheResponse get(final CacheEntry requestInfo) { if (!checkDiskCache()) { return null; } final CacheEntry entry = newCacheEntry(); final DiskLruCache.Snapshot snapshot = readCacheInfo(requestInfo, entry); if (snapshot == null) { return null; } if (!entry.matches(requestInfo) || !entry.canBeUsed()) { snapshot.close(); return null; } hitCount.incrementAndGet(); final InputStream body = newBodyInputStream(snapshot); return entry.newCacheResponse(body); }
java
{ "resource": "" }
q178949
BaseFileResponseCache.newBodyInputStream
test
private InputStream newBodyInputStream(final DiskLruCache.Snapshot snapshot) { return new FilterInputStream(snapshot.getInputStream(ENTRY_BODY)) { @Override public void close() throws IOException { snapshot.close(); super.close(); } }; }
java
{ "resource": "" }
q178950
BufferBitmapDecorator.reset
test
protected void reset(final int width, final int height) { Bitmap bitmap = this.bitmap; // recycle old buffer if (bitmap != null) { bitmap.recycle(); } bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // high quality this.bitmap = bitmap; this.bitmapCanvas = new Canvas(bitmap); }
java
{ "resource": "" }
q178951
WebsockifySslContext.getInstance
test
public static WebsockifySslContext getInstance(String keystore, String password, String keyPassword) { WebsockifySslContext context = SingletonHolder.INSTANCE_MAP.get(keystore); if ( context == null ) { context = new WebsockifySslContext ( keystore, password, keyPassword ); SingletonHolder.INSTANCE_MAP.put(keystore, context); } return context; }
java
{ "resource": "" }
q178952
WebsockifySslContext.validateKeystore
test
public static void validateKeystore ( String keystore, String password, String keyPassword ) throws KeyManagementException, UnrecoverableKeyException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException { getSSLContext(keystore, password, keyPassword); }
java
{ "resource": "" }
q178953
ImageView.replaceScaleType
test
public ScaleType replaceScaleType(final ScaleType type) { blockLayoutRequests = true; final ScaleType result = getScaleType(); setScaleType(type); blockLayoutRequests = false; return result; }
java
{ "resource": "" }
q178954
LocationBinder.stopListening
test
public void stopListening() { if (locationManager == null) { return; } if (DEBUG) { Log.d(TAG, "Stop location listening..."); } if (listener != null) { listener.onLocationStop(); } myHandler.removeMessages(MSG_STOP_FINE_PROVIDER); locationManager.removeUpdates(coarseListener); locationManager.removeUpdates(fineListener); locationManager = null; }
java
{ "resource": "" }
q178955
ServiceRequestPerformer.getPendingIntent
test
public PendingIntent getPendingIntent(final RequestBuilder<?> requestBuilder, final int flags) { return PendingIntent.getService(context, 0, getIntent(requestBuilder), flags); }
java
{ "resource": "" }
q178956
RequestMethod.disconnect
test
protected void disconnect(final URLConnection connection) { final URLConnection http = UrlConnectionWrapper.unwrap(connection); if (http instanceof HttpURLConnection) { ((HttpURLConnection) http).disconnect(); } }
java
{ "resource": "" }
q178957
ApplicationServiceSupport.bind
test
public void bind() { if (serviceObject != null) { return; } final Context context = contextRef.get(); if (context == null) { return; } // TODO make it configurable final Intent intent = new Intent(context, GoroService.class); intent.setAction(getInterfaceClass().getName()); if (DEBUG_CALLS) { Log.v(TAG, "Attempt to bind to service " + this + "/" + context, new RuntimeException()); } // start manually, so that it will be stopped manually context.startService(intent); final boolean bindResult = context.bindService(intent, this, 0); if (DEBUG) { Log.v(TAG, "Binded to service: " + bindResult + ", " + context + ", interface: " + getInterfaceClass()); } }
java
{ "resource": "" }
q178958
ApplicationServiceSupport.unbind
test
public void unbind() { if (serviceObject == null) { return; } serviceObject = null; final Context context = contextRef.get(); if (DEBUG) { Log.v(TAG, "Unbind " + context + " from " + getInterfaceClass()); } if (context == null) { return; } try { context.unbindService(this); } catch (final Exception e) { if (DEBUG) { Log.e(TAG, "Cannot unbind from application service", e); } } }
java
{ "resource": "" }
q178959
ViewImageConsumer.notifyAboutViewChanges
test
public void notifyAboutViewChanges() { final T view = this.view; if (view != null && view instanceof ImagesLoadListenerProvider) { this.listener = ((ImagesLoadListenerProvider)view).getImagesLoadListener(); } }
java
{ "resource": "" }
q178960
DirectProxyHandler.channelOpen
test
@Override public void channelOpen(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { try { // make the proxy connection ensureTargetConnection ( e.getChannel(), false, null ); } catch (Exception ex) { // target connection failed, so close the client connection e.getChannel().close(); ex.printStackTrace(); } }
java
{ "resource": "" }
q178961
RequestBuilderLoader.onAcceptData
test
protected ResponseData<MT> onAcceptData(final ResponseData<MT> previousData, final ResponseData<MT> responseData) { return responseData; }
java
{ "resource": "" }
q178962
RequestBuilderLoader.onReset
test
@Override protected void onReset() { if (DEBUG) { Log.v(TAG, "onReset " + this); } super.onReset(); onStopLoading(); if (receivedResponse != null) { onReleaseData(receivedResponse); receivedResponse = null; } }
java
{ "resource": "" }
q178963
RequestBuilderLoader.waitForLoader
test
void waitForLoader(final long time) { try { done.await(time, TimeUnit.MILLISECONDS); } catch (final InterruptedException e) { Log.e(TAG, "waitForLoader() ininterrupted", e); } }
java
{ "resource": "" }
q178964
GUIUtils.setTextOrHide
test
public static void setTextOrHide(final TextView view, final CharSequence text, final int hvisibility) { if (TextUtils.isEmpty(text)) { view.setVisibility(hvisibility); } else { view.setText(text); view.setVisibility(View.VISIBLE); } }
java
{ "resource": "" }
q178965
GUIUtils.hideSoftInput
test
public static void hideSoftInput(final View textView) { try { final InputMethodManager imm = (InputMethodManager)textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(textView.getWindowToken(), 0); } catch (final Exception e) { Log.w(TAG, "Ignore exception", e); } }
java
{ "resource": "" }
q178966
GUIUtils.showSoftInput
test
public static void showSoftInput(final View textView) { try { final InputMethodManager imm = (InputMethodManager)textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(textView, InputMethodManager.SHOW_FORCED); } catch (final Exception e) { Log.w(TAG, "Ignore exception", e); } }
java
{ "resource": "" }
q178967
GUIUtils.toggleSoftInput
test
public static void toggleSoftInput(final View textView) { try { final InputMethodManager imm = (InputMethodManager)textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInputFromWindow(textView.getWindowToken(), 0, 0); } catch (final Exception e) { Log.w(TAG, "Ignore exception", e); } }
java
{ "resource": "" }
q178968
GUIUtils.pixelsWidth
test
public static int pixelsWidth(final DisplayMetrics displayMetrics, final int dip) { final float scale = displayMetrics.density; final float alpha = 0.5f; return (int)(dip * scale + alpha); }
java
{ "resource": "" }
q178969
PortUnificationHandler.exceptionCaught
test
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { cancelDirectConnectionTimer ( ); Logger.getLogger(PortUnificationHandler.class.getName()).severe("Exception on connection to " + ctx.getChannel().getRemoteAddress() + ": " + e.getCause().getMessage() ); }
java
{ "resource": "" }
q178970
ImagesManager.clearCache
test
public boolean clearCache(final String url) { memCache.remove(url); try { return imagesResponseCache.deleteGetEntry(url); } catch (final IOException e) { Log.w(TAG, "Cannot clear disk cache for " + url, e); return false; } }
java
{ "resource": "" }
q178971
ImagesManager.populateImage
test
public void populateImage(final View view, final String url) { final Object tag = view.getTag(); ImageConsumer consumer = null; if (tag == null) { consumer = createImageConsumer(view); view.setTag(consumer); } else { if (!(tag instanceof ImageConsumer)) { throw new IllegalStateException("View already has a tag " + tag + ". Cannot store consumer"); } consumer = (ImageConsumer)tag; } populateImage(consumer, url); }
java
{ "resource": "" }
q178972
ImagesManager.cancelImageLoading
test
public void cancelImageLoading(final View view) { checkThread(); final Object tag = view.getTag(); if (tag != null && tag instanceof ImageConsumer) { cancelImageLoading((ImageConsumer)tag); } }
java
{ "resource": "" }
q178973
ImagesManager.createImageConsumer
test
protected ImageConsumer createImageConsumer(final View view) { if (this.consumerFactory == null) { throw new IllegalStateException("Image consumers factory bean not found in container. Take a look at DefaultBeansManager.edit().images() method in assist package."); } return consumerFactory.createConsumer(view); }
java
{ "resource": "" }
q178974
ImagesManager.setResultImage
test
protected final void setResultImage(final ImageConsumer consumer, final ImageResult result, final boolean animate) { decorateResult(consumer, result); consumer.setImage(createDrawable(result.getBitmap()), animate); consumer.reset(); }
java
{ "resource": "" }
q178975
ImagesManager.setLoadingImage
test
private void setLoadingImage(final ImageConsumer consumer) { if (!consumer.skipLoadingImage()) { Drawable d = getLoadingDrawable(consumer); if (!consumer.hasUndefinedSize() || (d.getIntrinsicWidth() != 0 && d.getIntrinsicHeight() != 0)) { consumer.setLoadingImage(d); } } }
java
{ "resource": "" }
q178976
ImagesManager.startImageLoaderTask
test
private void startImageLoaderTask(final ImageConsumer consumer, final ImageRequest request) { final String key = request.getKey(); if (debug) { Log.d(TAG, "Key " + key); } ImageLoader loader = currentLoads.get(key); if (loader != null) { final boolean added = loader.addTarget(consumer); if (!added) { loader = null; } } if (loader == null) { if (debug) { Log.d(TAG, "Start a new task"); } loader = new ImageLoader(request, this); if (!loader.addTarget(consumer)) { throw new IllegalStateException("Cannot add target to the new loader"); } currentLoads.put(key, loader); if (debug) { Log.d(TAG, "Current loaders count: " + currentLoads.size()); } final Executor executor = getImageTaskExecutor(); executor.execute(loader.future); } else if (debug) { Log.d(TAG, "Joined to the existing task " + key); } }
java
{ "resource": "" }
q178977
ImagesManager.memCacheImage
test
protected void memCacheImage(final String url, final Bitmap bitmap) { if (debug) { Log.d(TAG, "Memcache for " + url); } memCache.putElement(url, bitmap); }
java
{ "resource": "" }
q178978
BuffersPool.release
test
public void release(final byte[] buffer) { if (buffer == null) { return; } final int capacity = buffer.length; if (capacity == 0) { return; } synchronized (lock) { List<Object> bList = buffers.get(capacity); if (bList == null) { bList = new LinkedList<Object>(); buffers.put(capacity, bList); } bList.add(buffer); usedBuffersCount--; } }
java
{ "resource": "" }
q178979
RequestDescription.onURLConnectionPrepared
test
protected void onURLConnectionPrepared(final Context context, final URLConnection urlConnection) { if (contentType != null) { urlConnection.addRequestProperty("Content-Type", contentType); } if (contentLanguage != null) { urlConnection.addRequestProperty("Accept-Language", contentLanguage); } urlConnection.addRequestProperty("Accept-Encoding", IoUtils.ENCODING_GZIP); urlConnection.addRequestProperty("User-Agent", buildUserAgent(context)); if (headers != null) { for (String name : headers.keySet()) { urlConnection.addRequestProperty(name, headers.getString(name)); } } }
java
{ "resource": "" }
q178980
SimpleRequestBuilder.addParam
test
public SimpleRequestBuilder<MT> addParam(final String name, final String value) { addSimpleParameter(name, value); return this; }
java
{ "resource": "" }
q178981
CacheControlUrlConnection.connectWithWorkaround
test
private void connectWithWorkaround() throws IOException { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { super.connect(); return; } URLConnection coreConnection = UrlConnectionWrapper.unwrap(getCore()); if (coreConnection instanceof HttpsURLConnection) { // CHECKSTYLE:OFF try { super.connect(); } catch (NullPointerException e) { // ignore this NP } // CHECKSTYLE:ON } else { super.connect(); } }
java
{ "resource": "" }
q178982
Md5.getMd5
test
public static String getMd5(final String text) { try { final MessageDigest md = MessageDigest.getInstance("MD5"); final byte[] utf8Bytes = text.getBytes(UTF_8_NAME); md.update(utf8Bytes, 0, utf8Bytes.length); final byte[] md5hash = md.digest(); final int radix = 16; final int length = 32; final StringBuilder result = new StringBuilder(length).append(new BigInteger(1, md5hash).toString(radix)); final int zeroBeginLen = length - result.length(); if (zeroBeginLen > 0) { final char [] zeroBegin = new char[zeroBeginLen]; Arrays.fill(zeroBegin, Character.forDigit(0, radix)); result.insert(0, zeroBegin); } return result.toString(); } catch (final NoSuchAlgorithmException|UnsupportedEncodingException e) { throw new AssertionError(e); } }
java
{ "resource": "" }
q178983
cublasGemmAlgo.stringFor
test
public static String stringFor(int n) { switch (n) { case CUBLAS_GEMM_DEFAULT: return "CUBLAS_GEMM_DEFAULT"; case CUBLAS_GEMM_ALGO0: return "CUBLAS_GEMM_ALGO0"; case CUBLAS_GEMM_ALGO1: return "CUBLAS_GEMM_ALGO1"; case CUBLAS_GEMM_ALGO2: return "CUBLAS_GEMM_ALGO2"; case CUBLAS_GEMM_ALGO3: return "CUBLAS_GEMM_ALGO3"; case CUBLAS_GEMM_ALGO4: return "CUBLAS_GEMM_ALGO4"; case CUBLAS_GEMM_ALGO5: return "CUBLAS_GEMM_ALGO5"; case CUBLAS_GEMM_ALGO6: return "CUBLAS_GEMM_ALGO6"; case CUBLAS_GEMM_ALGO7: return "CUBLAS_GEMM_ALGO7"; case CUBLAS_GEMM_ALGO8: return "CUBLAS_GEMM_ALGO8"; case CUBLAS_GEMM_ALGO9: return "CUBLAS_GEMM_ALGO9"; case CUBLAS_GEMM_ALGO10: return "CUBLAS_GEMM_ALGO10"; case CUBLAS_GEMM_ALGO11: return "CUBLAS_GEMM_ALGO11"; case CUBLAS_GEMM_ALGO12: return "CUBLAS_GEMM_ALGO12"; case CUBLAS_GEMM_ALGO13: return "CUBLAS_GEMM_ALGO13"; case CUBLAS_GEMM_ALGO14: return "CUBLAS_GEMM_ALGO14"; case CUBLAS_GEMM_ALGO15: return "CUBLAS_GEMM_ALGO15"; case CUBLAS_GEMM_ALGO16: return "CUBLAS_GEMM_ALGO16"; case CUBLAS_GEMM_ALGO17: return "CUBLAS_GEMM_ALGO17"; case CUBLAS_GEMM_ALGO18: return "CUBLAS_GEMM_ALGO18"; case CUBLAS_GEMM_ALGO19: return "CUBLAS_GEMM_ALGO19"; case CUBLAS_GEMM_ALGO20: return "CUBLAS_GEMM_ALGO20"; case CUBLAS_GEMM_ALGO21: return "CUBLAS_GEMM_ALGO21"; case CUBLAS_GEMM_ALGO22: return "CUBLAS_GEMM_ALGO22"; case CUBLAS_GEMM_ALGO23: return "CUBLAS_GEMM_ALGO23"; case CUBLAS_GEMM_DEFAULT_TENSOR_OP: return "CUBLAS_GEMM_DEFAULT_TENSOR_OP"; case CUBLAS_GEMM_ALGO0_TENSOR_OP: return "CUBLAS_GEMM_ALGO0_TENSOR_OP"; case CUBLAS_GEMM_ALGO1_TENSOR_OP: return "CUBLAS_GEMM_ALGO1_TENSOR_OP"; case CUBLAS_GEMM_ALGO2_TENSOR_OP: return "CUBLAS_GEMM_ALGO2_TENSOR_OP"; case CUBLAS_GEMM_ALGO3_TENSOR_OP: return "CUBLAS_GEMM_ALGO3_TENSOR_OP"; case CUBLAS_GEMM_ALGO4_TENSOR_OP: return "CUBLAS_GEMM_ALGO4_TENSOR_OP"; case CUBLAS_GEMM_ALGO5_TENSOR_OP: return "CUBLAS_GEMM_ALGO5_TENSOR_OP"; case CUBLAS_GEMM_ALGO6_TENSOR_OP: return "CUBLAS_GEMM_ALGO6_TENSOR_OP"; case CUBLAS_GEMM_ALGO7_TENSOR_OP: return "CUBLAS_GEMM_ALGO7_TENSOR_OP"; case CUBLAS_GEMM_ALGO8_TENSOR_OP: return "CUBLAS_GEMM_ALGO8_TENSOR_OP"; case CUBLAS_GEMM_ALGO9_TENSOR_OP: return "CUBLAS_GEMM_ALGO9_TENSOR_OP"; case CUBLAS_GEMM_ALGO10_TENSOR_OP: return "CUBLAS_GEMM_ALGO10_TENSOR_OP"; case CUBLAS_GEMM_ALGO11_TENSOR_OP: return "CUBLAS_GEMM_ALGO11_TENSOR_OP"; case CUBLAS_GEMM_ALGO12_TENSOR_OP: return "CUBLAS_GEMM_ALGO12_TENSOR_OP"; case CUBLAS_GEMM_ALGO13_TENSOR_OP: return "CUBLAS_GEMM_ALGO13_TENSOR_OP"; case CUBLAS_GEMM_ALGO14_TENSOR_OP: return "CUBLAS_GEMM_ALGO14_TENSOR_OP"; } return "INVALID cublasGemmAlgo: "+n; }
java
{ "resource": "" }
q178984
cublasStatus.stringFor
test
public static String stringFor(int n) { switch (n) { case CUBLAS_STATUS_SUCCESS : return "CUBLAS_STATUS_SUCCESS"; case CUBLAS_STATUS_NOT_INITIALIZED : return "CUBLAS_STATUS_NOT_INITIALIZED"; case CUBLAS_STATUS_ALLOC_FAILED : return "CUBLAS_STATUS_ALLOC_FAILED"; case CUBLAS_STATUS_INVALID_VALUE : return "CUBLAS_STATUS_INVALID_VALUE"; case CUBLAS_STATUS_ARCH_MISMATCH : return "CUBLAS_STATUS_ARCH_MISMATCH"; case CUBLAS_STATUS_MAPPING_ERROR : return "CUBLAS_STATUS_MAPPING_ERROR"; case CUBLAS_STATUS_EXECUTION_FAILED : return "CUBLAS_STATUS_EXECUTION_FAILED"; case CUBLAS_STATUS_INTERNAL_ERROR : return "CUBLAS_STATUS_INTERNAL_ERROR"; case CUBLAS_STATUS_NOT_SUPPORTED : return "CUBLAS_STATUS_NOT_SUPPORTED"; case JCUBLAS_STATUS_INTERNAL_ERROR : return "JCUBLAS_STATUS_INTERNAL_ERROR"; } return "INVALID cublasStatus: "+n; }
java
{ "resource": "" }
q178985
JCublas2.checkResult
test
private static int checkResult(int result) { if (exceptionsEnabled && result != cublasStatus.CUBLAS_STATUS_SUCCESS) { throw new CudaException(cublasStatus.stringFor(result)); } return result; }
java
{ "resource": "" }
q178986
JCublas.checkResultBLAS
test
private static void checkResultBLAS() { if (exceptionsEnabled) { lastResult = cublasGetErrorNative(); if (lastResult != cublasStatus.CUBLAS_STATUS_SUCCESS) { throw new CudaException(cublasStatus.stringFor(lastResult)); } } }
java
{ "resource": "" }
q178987
Statistics.addLexeme
test
public void addLexeme(int lexemeId) { int count = 1; if (lexemeFrequency.get(lexemeId) != null) count = lexemeFrequency.get(lexemeId) + 1; lexemeFrequency.put(lexemeId, count); }
java
{ "resource": "" }
q178988
Statistics.addEnding
test
public void addEnding(int endingId) { int count = 1; if (endingFrequency.get(endingId) != null) count = endingFrequency.get(endingId) + 1; endingFrequency.put(endingId, count); }
java
{ "resource": "" }
q178989
Statistics.getEstimate
test
public double getEstimate(AttributeValues wordform) { double estimate = 0.1; String endingIdStr = wordform.getValue(AttributeNames.i_EndingID); int endingId = (endingIdStr == null) ? -1 : Integer.parseInt(endingIdStr); if (endingFrequency.get(endingId) != null) estimate += endingFrequency.get(endingId); String lexemeIdStr = wordform.getValue(AttributeNames.i_LexemeID); int lexemeId = (lexemeIdStr == null) ? -1 : Integer.parseInt(lexemeIdStr); if (lexemeFrequency.get(lexemeId) != null) estimate += lexemeFrequency.get(lexemeId) * lexemeWeight; return estimate; }
java
{ "resource": "" }
q178990
Wordform.longDescription
test
public void longDescription(PrintStream out) { out.println(this.token + ":"); for (String s : this.attributes.keySet()) { out.println(s + "\t" + attributes.get(s)); } }
java
{ "resource": "" }
q178991
MarkupConverter.verifyAndSetKamolsAttribute
test
private static void verifyAndSetKamolsAttribute( AttributeValues avs, StringBuilder tag, int index, char tagValue, String attribute, String attributeValue) { if (avs.isMatchingStrong(attribute, attributeValue)) tag.setCharAt(index, tagValue); }
java
{ "resource": "" }
q178992
MarkupConverter.toKamolsMarkup
test
public static String toKamolsMarkup(AttributeValues avs) { StringBuilder res = toKamolsMarkup(avs, defaulti); if (res.length() < 1) return res.toString(); // if (res.charAt(0) == 'v' && res.charAt(1) == '_') res.setCharAt(1, 'm'); PP 2012.12.07 - nezinu kāpēc tas te ir, bet tas čakarē tagošanu (jo tagsvm.... neatbilst nevienam varēt vai būt verbam) // if (res.charAt(0) == 'p' && res.charAt(6) == '_') res.setCharAt(6, 'n'); // if (res.charAt(0) == 'v' && res.charAt(3) != 'p' && res.charAt(10) == '_') res.setCharAt(10, 'n'); return res.toString(); }
java
{ "resource": "" }
q178993
MarkupConverter.verifyAndSetAVSAttribute
test
private static void verifyAndSetAVSAttribute( String tag, FeatureStructure avs, int index, char tagValue, String attribute, String attributeValue) { //TODO - šī metode 'silently fails' uz jauniem variantiem/simboliem //marķējumā. Normāli atrisinās tikai šīs klases pāreja uz xml //konfigfaila apstrādi if (index >= tag.length()) return; if (tag.charAt(index) == tagValue) avs.addAttribute(attribute, attributeValue); }
java
{ "resource": "" }
q178994
MarkupConverter.removeKamolsMarkupFormating
test
public static String removeKamolsMarkupFormating(String tag){ String result = ""; if (!tag.contains(",")) return "x"; int depth = 0; int commas = 0; for (char c : tag.toCharArray()) { if (c=='[') depth++; if (c==']') depth--; if (depth == 1 && c==',') commas++; if (commas == 2) result = result + c; } result = result.replaceAll("_[A-Z0-9]*" , "_"); result = result.replaceAll("(\\[|\\]|\\,| )",""); return result; }
java
{ "resource": "" }
q178995
MetricDataRequest.get
test
public List<MetricData> get() throws RequestException, UnauthorizedException { HttpResponse<String> response; try { response = Unirest.get( this.appdURL + "/controller/rest/applications/" + appName + "/metric-data") .header("accept", "application/json") .basicAuth(this.appdUsername, this.appdPassword) .queryString(getQueryString()) .queryString("output", "json") .asString(); } catch (UnirestException e) { throw new RequestException("Something was wrong with sending request.", e); } if (response == null) { throw new RequestException("Response is empty."); } switch (response.getStatus()) { case 200: { return process(new JsonNode(response.getBody())); } case 401: { throw new UnauthorizedException("Authentication failed"); } default: { throw new RequestException("Unhandled response code " + response.getStatus()); } } }
java
{ "resource": "" }
q178996
MetricDataRequest.getQueryString
test
protected Map<String, Object> getQueryString() { Map<String, Object> qs = new HashMap<>(); if (timeParams != null) { qs.put("time-range-type", timeParams.type); if (timeParams.duration > 0) { qs.put("duration-in-mins", timeParams.duration); } if (timeParams.startTime > 0) { qs.put("start-time", timeParams.startTime); } if (timeParams.endTime > 0) { qs.put("end-time", timeParams.endTime); } } qs.put("rollup", false); if (metricPath != null) { qs.put("metric-path", metricPath); } return qs; }
java
{ "resource": "" }
q178997
MetricDataRequest.process
test
protected List<MetricData> process(JsonNode node) { JSONArray dataArray = node.getArray(); List<MetricData> list = new LinkedList<>(); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); MetricData metricData = new MetricData(data.getString("frequency"), data.getLong("metricId"), data.getString("metricName"), data.getString("metricPath")); list.add(metricData); JSONArray valueArray = data.getJSONArray("metricValues"); for (int j = 0; j < valueArray.length(); j++) { JSONObject value = valueArray.getJSONObject(j); metricData.metricValues.add( new MetricValue(value.getLong("count"), value.getLong("value"), value.getLong("max"), value.getLong("min"), value.getLong("sum"), value.getLong("startTimeInMillis"))); } } return list; }
java
{ "resource": "" }
q178998
InfoParser.parseInfo
test
public static List<AppInfo> parseInfo(String jsonString) throws IOException { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(jsonString, new TypeReference<List<AppInfo>>() {}); }
java
{ "resource": "" }
q178999
Config.getConnectionConfig
test
public static ConnectionConfig getConnectionConfig() { boolean isValid = true; String appdUsername = getPropertyOrEnv("com.signalfx.appd.username", "APPD_USERNAME"); if (StringUtils.isEmpty(appdUsername)) { log.error("AppDynamics username not specified."); isValid = false; } String appdPassword = getPropertyOrEnv("com.signalfx.appd.password", "APPD_PASSWORD"); if (StringUtils.isEmpty(appdPassword)) { log.error("AppDynamics password not specified."); isValid = false; } String appdURL = getPropertyOrEnv("com.signalfx.appd.host", "APPD_HOST"); if (StringUtils.isEmpty(appdURL)) { log.error("AppDynamics host not specified."); isValid = false; } String fxToken = getPropertyOrEnv("com.signalfx.api.token", "SIGNALFX_TOKEN"); if (StringUtils.isEmpty(fxToken)) { log.error("SignalFx token not specified."); isValid = false; } if (isValid) { return new ConnectionConfig(appdUsername, appdPassword, appdURL, fxToken); } else { return null; } }
java
{ "resource": "" }