_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q179000
|
ReportAppD.perform
|
test
|
public void perform(List<AppInfo> apps, MetricDataRequest.TimeParams timeParams) {
List<SignalFxProtocolBuffers.DataPoint> dataPoints = new LinkedList<>();
for (AppInfo app : apps) {
dataRequest.setAppName(app.name);
for (MetricInfo metricInfo : app.metrics) {
dataRequest.setTimeParams(timeParams);
dataRequest.setMetricPath(metricInfo.metricPathQuery);
List<MetricData> metricDataList;
try {
metricDataList = dataRequest.get();
} catch (RequestException e) {
// too bad
log.error("Metric query failure for \"{}\"", metricInfo.metricPathQuery);
counterAppDRequestFailure.inc();
continue;
} catch (UnauthorizedException e) {
log.error("AppDynamics authentication failed");
return;
}
if (metricDataList != null && metricDataList.size() > 0) {
for (MetricData metricData : metricDataList) {
MetricTimeSeries mts =
metricInfo.getMetricTimeSeries(metricData.metricPath);
List<SignalFxProtocolBuffers.DataPoint> mtsDataPoints = processor
.process(mts, metricData.metricValues);
dataPoints.addAll(mtsDataPoints);
if (!mtsDataPoints.isEmpty()) {
counterMtsReported.inc();
} else {
counterMtsEmpty.inc();
}
}
} else {
// no metrics found, something is wrong with selection
log.warn("No metric found for query \"{}\"", metricInfo.metricPathQuery);
}
}
}
if (!dataPoints.isEmpty()) {
try {
reporter.report(dataPoints);
counterDataPointsReported.inc(dataPoints.size());
} catch (Reporter.ReportException e) {
log.error("There were errors reporting metric");
}
}
}
|
java
|
{
"resource": ""
}
|
q179001
|
GenericodeReader.gc04CodeList
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v04.CodeListDocument> gc04CodeList ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC04_CODE_LIST,
com.helger.genericode.v04.CodeListDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179002
|
GenericodeReader.gc04CodeListSet
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v04.CodeListSetDocument> gc04CodeListSet ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC04_CODE_LIST_SET,
com.helger.genericode.v04.CodeListSetDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179003
|
GenericodeReader.gc04ColumnSet
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v04.ColumnSetDocument> gc04ColumnSet ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC04_COLUMN_SET,
com.helger.genericode.v04.ColumnSetDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179004
|
GenericodeReader.gc10CodeList
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v10.CodeListDocument> gc10CodeList ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC10_CODE_LIST,
com.helger.genericode.v10.CodeListDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179005
|
GenericodeReader.gc10CodeListSet
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v10.CodeListSetDocument> gc10CodeListSet ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC10_CODE_LIST_SET,
com.helger.genericode.v10.CodeListSetDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179006
|
GenericodeReader.gc10ColumnSet
|
test
|
@Nonnull
public static GenericodeReader <com.helger.genericode.v10.ColumnSetDocument> gc10ColumnSet ()
{
return new GenericodeReader<> (EGenericodeDocumentType.GC10_COLUMN_SET,
com.helger.genericode.v10.ColumnSetDocument.class);
}
|
java
|
{
"resource": ""
}
|
q179007
|
Genericode10Helper.getColumnElementID
|
test
|
@Nonnull
public static String getColumnElementID (@Nonnull final Object aColumnElement)
{
if (aColumnElement instanceof ColumnRef)
return ((ColumnRef) aColumnElement).getId ();
if (aColumnElement instanceof Column)
return ((Column) aColumnElement).getId ();
if (aColumnElement instanceof Key)
{
final List <KeyColumnRef> aKeyColumnRefs = ((Key) aColumnElement).getColumnRef ();
final KeyColumnRef aKeyColumnRef = CollectionHelper.getFirstElement (aKeyColumnRefs);
if (aKeyColumnRef == null)
throw new IllegalArgumentException ("Key contains not KeyColumnRef!!");
final Object aRef = aKeyColumnRef.getRef ();
if (aRef instanceof Column)
return ((Column) aRef).getId ();
throw new IllegalArgumentException ("Unsupported referenced object: " +
aRef +
" - " +
ClassHelper.getSafeClassName (aRef));
}
throw new IllegalArgumentException ("Illegal column element: " +
aColumnElement +
" - " +
ClassHelper.getSafeClassName (aColumnElement));
}
|
java
|
{
"resource": ""
}
|
q179008
|
Genericode10Helper.getRowValue
|
test
|
@Nullable
public static String getRowValue (@Nonnull final Row aRow, @Nonnull final String sColumnID)
{
for (final Value aValue : aRow.getValue ())
{
final String sID = getColumnElementID (aValue.getColumnRef ());
if (sID.equals (sColumnID))
{
final SimpleValue aSimpleValue = aValue.getSimpleValue ();
return aSimpleValue != null ? aSimpleValue.getValue () : null;
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q179009
|
Genericode10Helper.getColumnOfID
|
test
|
@Nullable
public static Column getColumnOfID (@Nonnull final ColumnSet aColumnSet, @Nullable final String sID)
{
if (sID != null)
for (final Column aColumn : getAllColumns (aColumnSet))
if (aColumn.getId ().equals (sID))
return aColumn;
return null;
}
|
java
|
{
"resource": ""
}
|
q179010
|
Genericode10Helper.getAllKeyIDs
|
test
|
public static void getAllKeyIDs (@Nonnull final ColumnSet aColumnSet, @Nonnull final Collection <String> aTarget)
{
CollectionHelper.findAll (aColumnSet.getKeyChoice (), o -> o instanceof Key, o -> aTarget.add (((Key) o).getId ()));
}
|
java
|
{
"resource": ""
}
|
q179011
|
Genericode10Helper.getKeyOfID
|
test
|
@Nullable
public static Key getKeyOfID (@Nonnull final ColumnSet aColumnSet, @Nullable final String sID)
{
if (sID != null)
for (final Key aKey : getAllKeys (aColumnSet))
if (aKey.getId ().equals (sID))
return aKey;
return null;
}
|
java
|
{
"resource": ""
}
|
q179012
|
Genericode10Helper.isKeyColumn
|
test
|
public static boolean isKeyColumn (@Nonnull final ColumnSet aColumnSet, @Nullable final String sColumnID)
{
if (sColumnID != null)
for (final Key aKey : getAllKeys (aColumnSet))
for (final KeyColumnRef aColumnRef : aKey.getColumnRef ())
if (aColumnRef.getRef () instanceof Column)
if (((Column) aColumnRef.getRef ()).getId ().equals (sColumnID))
return true;
return false;
}
|
java
|
{
"resource": ""
}
|
q179013
|
Genericode10Helper.createColumn
|
test
|
@Nonnull
public static Column createColumn (@Nonnull @Nonempty final String sColumnID,
@Nonnull final UseType eUseType,
@Nonnull @Nonempty final String sShortName,
@Nullable final String sLongName,
@Nonnull @Nonempty final String sDataType)
{
ValueEnforcer.notEmpty (sColumnID, "ColumnID");
ValueEnforcer.notNull (eUseType, "useType");
ValueEnforcer.notEmpty (sShortName, "ShortName");
ValueEnforcer.notEmpty (sDataType, "DataType");
final Column aColumn = s_aFactory.createColumn ();
aColumn.setId (sColumnID);
aColumn.setUse (eUseType);
aColumn.setShortName (createShortName (sShortName));
if (StringHelper.hasText (sLongName))
aColumn.getLongName ().add (createLongName (sLongName));
final Data aData = s_aFactory.createData ();
aData.setType (sDataType);
aColumn.setData (aData);
return aColumn;
}
|
java
|
{
"resource": ""
}
|
q179014
|
Genericode10Helper.createKey
|
test
|
@Nonnull
public static Key createKey (@Nonnull @Nonempty final String sColumnID,
@Nonnull @Nonempty final String sShortName,
@Nullable final String sLongName,
@Nonnull final Column aColumn)
{
ValueEnforcer.notEmpty (sColumnID, "ColumnID");
ValueEnforcer.notEmpty (sShortName, "ShortName");
ValueEnforcer.notNull (aColumn, "Column");
final Key aKey = s_aFactory.createKey ();
aKey.setId (sColumnID);
aKey.setShortName (createShortName (sShortName));
if (StringHelper.hasText (sLongName))
aKey.getLongName ().add (createLongName (sLongName));
aKey.getColumnRef ().add (createKeyColumnRef (aColumn));
return aKey;
}
|
java
|
{
"resource": ""
}
|
q179015
|
ExcelReadOptions.setLinesToSkip
|
test
|
@Nonnull
public ExcelReadOptions <USE_TYPE> setLinesToSkip (@Nonnegative final int nLinesToSkip)
{
ValueEnforcer.isGE0 (nLinesToSkip, "LinesToSkip");
m_nLinesToSkip = nLinesToSkip;
return this;
}
|
java
|
{
"resource": ""
}
|
q179016
|
ExcelReadOptions.addColumn
|
test
|
@Nonnull
public ExcelReadOptions <USE_TYPE> addColumn (@Nonnegative final int nIndex,
@Nonnull @Nonempty final String sColumnID,
@Nonnull final USE_TYPE eUseType,
@Nonnull @Nonempty final String sDataType,
final boolean bKeyColumn)
{
ValueEnforcer.isGE0 (nIndex, "Index");
final Integer aIndex = Integer.valueOf (nIndex);
if (m_aColumns.containsKey (aIndex))
throw new IllegalArgumentException ("The column at index " + nIndex + " is already mapped!");
m_aColumns.put (aIndex, new ExcelReadColumn <> (nIndex, sColumnID, eUseType, sDataType, bKeyColumn));
return this;
}
|
java
|
{
"resource": ""
}
|
q179017
|
GenericodeWriter.gc04CodeList
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v04.CodeListDocument> gc04CodeList ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC04_CODE_LIST);
}
|
java
|
{
"resource": ""
}
|
q179018
|
GenericodeWriter.gc04CodeListSet
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v04.CodeListSetDocument> gc04CodeListSet ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC04_CODE_LIST_SET);
}
|
java
|
{
"resource": ""
}
|
q179019
|
GenericodeWriter.gc04ColumnSet
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v04.ColumnSetDocument> gc04ColumnSet ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC04_COLUMN_SET);
}
|
java
|
{
"resource": ""
}
|
q179020
|
GenericodeWriter.gc10CodeList
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v10.CodeListDocument> gc10CodeList ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC10_CODE_LIST);
}
|
java
|
{
"resource": ""
}
|
q179021
|
GenericodeWriter.gc10CodeListSet
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v10.CodeListSetDocument> gc10CodeListSet ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC10_CODE_LIST_SET);
}
|
java
|
{
"resource": ""
}
|
q179022
|
GenericodeWriter.gc10ColumnSet
|
test
|
@Nonnull
public static GenericodeWriter <com.helger.genericode.v10.ColumnSetDocument> gc10ColumnSet ()
{
return new GenericodeWriter<> (EGenericodeDocumentType.GC10_COLUMN_SET);
}
|
java
|
{
"resource": ""
}
|
q179023
|
GenericodeValidator.gc04CodeList
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v04.CodeListDocument> gc04CodeList ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC04_CODE_LIST);
}
|
java
|
{
"resource": ""
}
|
q179024
|
GenericodeValidator.gc04CodeListSet
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v04.CodeListSetDocument> gc04CodeListSet ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC04_CODE_LIST_SET);
}
|
java
|
{
"resource": ""
}
|
q179025
|
GenericodeValidator.gc04ColumnSet
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v04.ColumnSetDocument> gc04ColumnSet ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC04_COLUMN_SET);
}
|
java
|
{
"resource": ""
}
|
q179026
|
GenericodeValidator.gc10CodeList
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v10.CodeListDocument> gc10CodeList ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC10_CODE_LIST);
}
|
java
|
{
"resource": ""
}
|
q179027
|
GenericodeValidator.gc10CodeListSet
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v10.CodeListSetDocument> gc10CodeListSet ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC10_CODE_LIST_SET);
}
|
java
|
{
"resource": ""
}
|
q179028
|
GenericodeValidator.gc10ColumnSet
|
test
|
@Nonnull
public static GenericodeValidator <com.helger.genericode.v10.ColumnSetDocument> gc10ColumnSet ()
{
return new GenericodeValidator<> (EGenericodeDocumentType.GC10_COLUMN_SET);
}
|
java
|
{
"resource": ""
}
|
q179029
|
SendAppFeedback.sendLogsToServer
|
test
|
protected static void sendLogsToServer(boolean setSentTime){
long timeSent = new Date().getTime();
String appFeedBackSummary = Utility.convertFileToString("AppFeedBackSummary.json");
if ( "".equals(appFeedBackSummary) || "{}".equals(appFeedBackSummary) ) {
return;
}else{
try{
JSONObject appFeedBacksummaryJSON = new JSONObject(appFeedBackSummary);
JSONArray savedArray = (JSONArray) appFeedBacksummaryJSON.get("saved");
HashMap<String, String> timeSentMap = new HashMap<>();
//Add timeSent to all the json file's which are not set with timeSent
for (int i = 0; i < savedArray.length(); i++) {
String instanceName = (String) savedArray.get(i);
String screenFeedBackJsonFile = Utility.getJSONfileName(instanceName);
String actualTimeSent = Utility.addAndFetchSentTimeFromScreenFeedBackJson(screenFeedBackJsonFile, timeSent, setSentTime);
if(actualTimeSent != null){
timeSentMap.put(instanceName,actualTimeSent);
}
}
//Iterate each feedback element which is not yet sent
for (int i = 0; i < savedArray.length(); i++) {
String instanceName = (String)savedArray.get(i);
String screenFeedBackJsonFile = Utility.getJSONfileName(instanceName);
String actualTimeSent = timeSentMap.get(instanceName);
String zipFile = Utility.storageDirectory+instanceName+"_"+ actualTimeSent+".zip";
List<String> fileList = new ArrayList<>();
fileList.add(Utility.getImageFileName(instanceName));
fileList.add(screenFeedBackJsonFile);
Utility.createZipArchive(fileList,zipFile);
LogPersister.sendInAppFeedBackFile(zipFile, new FeedBackUploadResponseListener(instanceName,zipFile,actualTimeSent));
}
}catch (JSONException je){
}
}
}
|
java
|
{
"resource": ""
}
|
q179030
|
LogPersister.setContext
|
test
|
static public void setContext(final Context context) {
// once setContext is called, we can set up the uncaught exception handler since
// it will force logging to the file
if (null == LogPersister.context) {
// set a custom JUL Handler so we can capture third-party and internal java.util.logging.Logger API calls
LogManager.getLogManager().getLogger("").addHandler(julHandler);
java.util.logging.Logger.getLogger("").setLevel(Level.ALL);
LogPersister.context = context;
// now that we have a context, let's set the fileLoggerInstance properly unless it was already set by tests
if (fileLoggerInstance == null || fileLoggerInstance instanceof FileLogger) {
FileLogger.setContext(context);
fileLoggerInstance = FileLogger.getInstance();
}
SharedPreferences prefs = LogPersister.context.getSharedPreferences (SHARED_PREF_KEY, Context.MODE_PRIVATE);
// level
if (null != level) { // someone called setLevel method before setContext
setLevelSync(level); // seems redundant, but we do this to save to SharedPrefs now that we have Context
} else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
setLevelSync(Logger.LEVEL.fromString(prefs.getString(SHARED_PREF_KEY_level, getLevelDefault().toString())));
}
// logFileMaxSize
if (null != logFileMaxSize) { // someone called setMaxStoreSize method before setContext
setMaxLogStoreSize(logFileMaxSize); // seems redundant, but we do this to save to SharedPrefs now that we have Context
} else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
setMaxLogStoreSize(prefs.getInt(SHARED_PREF_KEY_logFileMaxSize, DEFAULT_logFileMaxSize));
}
// capture
if (null != capture) { // someone called setCapture method before setContext
setCaptureSync(capture); // seems redundant, but we do this to save to SharedPrefs now that we have Context
} else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
setCaptureSync(prefs.getBoolean (SHARED_PREF_KEY_logPersistence, DEFAULT_capture));
}
uncaughtExceptionHandler = new UncaughtExceptionHandler ();
Thread.setDefaultUncaughtExceptionHandler (uncaughtExceptionHandler);
}
}
|
java
|
{
"resource": ""
}
|
q179031
|
LogPersister.getLogLevel
|
test
|
static public Logger.LEVEL getLogLevel() {
final Future<Logger.LEVEL> task = ThreadPoolWorkQueue.submit(new Callable<Logger.LEVEL>() {
@Override public Logger.LEVEL call() {
return getLevelSync();
}
});
try {
return task.get();
}
catch (Exception e) {
return getLevelSync();
}
}
|
java
|
{
"resource": ""
}
|
q179032
|
LogPersister.getCapture
|
test
|
static public boolean getCapture() {
final Future<Boolean> task = ThreadPoolWorkQueue.submit(new Callable<Boolean>() {
@Override public Boolean call() {
return getCaptureSync();
}
});
try {
return task.get();
}
catch (Exception e) {
return getCaptureSync();
}
}
|
java
|
{
"resource": ""
}
|
q179033
|
LogPersister.setMaxLogStoreSize
|
test
|
static public void setMaxLogStoreSize(final int bytes) {
// TODO: also check if bytes is bigger than remaining disk space?
if (bytes >= 10000) {
logFileMaxSize = bytes;
}
if (null != context) {
SharedPreferences prefs = context.getSharedPreferences (SHARED_PREF_KEY, Context.MODE_PRIVATE);
prefs.edit ().putInt (SHARED_PREF_KEY_logFileMaxSize, logFileMaxSize).commit();
}
}
|
java
|
{
"resource": ""
}
|
q179034
|
LogPersister.prependMetadata
|
test
|
protected static String prependMetadata (String message, JSONObject metadata) {
try {
if (null != metadata) {
String clazz = "";
String method = "";
String file = "";
String line = "";
if (metadata.has ("$class")) {
clazz = metadata.getString ("$class");
clazz = clazz.substring (clazz.lastIndexOf ('.') + 1, clazz.length ());
}
if (metadata.has ("$method")) {
method = metadata.getString ("$method");
}
if (metadata.has ("$file")) {
file = metadata.getString ("$file");
}
if (metadata.has ("$line")) {
line = metadata.getString ("$line");
}
if (!(clazz + method + file + line).equals ("")) {
// we got something...
message = clazz + "." + method + " in " + file + ":" + line + " :: " + message;
}
}
} catch (Exception e) {
// ignore... it's best effort anyway
}
return message;
}
|
java
|
{
"resource": ""
}
|
q179035
|
LogPersister.appendStackMetadata
|
test
|
protected static JSONObject appendStackMetadata(JSONObject additionalMetadata) {
JSONObject jsonMetadata;
if(additionalMetadata != null){
jsonMetadata = additionalMetadata;
}
else{
jsonMetadata = new JSONObject();
}
try {
// try/catch Exception wraps all because I don't know yet if I can trust getStackTrace... needs more testing
// below is slightly more performant than: Thread.currentThread().getStackTrace();
StackTraceElement[] stackTraceElements = new Exception().getStackTrace();
int index = 0;
// find the start of the Logger call stack:
while(!stackTraceElements[index].getClassName ().equals (LogPersister.class.getName())) {
index++;
}
// then find the caller:
while(stackTraceElements[index].getClassName().equals (LogPersister.class.getName())
|| stackTraceElements[index].getClassName().startsWith (JULHandler.class.getName())
|| stackTraceElements[index].getClassName().startsWith (java.util.logging.Logger.class.getName())
|| stackTraceElements[index].getClassName().startsWith (BMSAnalytics.class.getName())) {
index++;
}
jsonMetadata.put ("$class", stackTraceElements[index].getClassName ());
jsonMetadata.put ("$file", stackTraceElements[index].getFileName ());
jsonMetadata.put ("$method", stackTraceElements[index].getMethodName ());
jsonMetadata.put ("$line", stackTraceElements[index].getLineNumber ());
jsonMetadata.put ("$src", "java");
} catch (Exception e) {
Log.e(LOG_TAG_NAME, "Could not generate jsonMetadata object.", e);
}
return jsonMetadata;
}
|
java
|
{
"resource": ""
}
|
q179036
|
LogPersister.createJSONObject
|
test
|
private static JSONObject createJSONObject(final Logger.LEVEL level, final String pkg, final String message, long timestamp, final JSONObject jsonMetadata, final Throwable t) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put ("timestamp", timestamp);
jsonObject.put ("level", level.toString());
jsonObject.put ("pkg", pkg);
jsonObject.put ("msg", message);
jsonObject.put ("threadid", Thread.currentThread ().getId());
if (null != jsonMetadata) {
jsonObject.put ("metadata", jsonMetadata);
}
if (null != t) {
jsonObject.put ("metadata", appendFullStackTrace(jsonMetadata, t));
}
}
catch (JSONException e) {
Log.e(LOG_TAG_NAME, "Error adding JSONObject key/value pairs", e);
}
return jsonObject;
}
|
java
|
{
"resource": ""
}
|
q179037
|
BMSAnalytics.logLocation
|
test
|
public static void logLocation(){
if (!BMSAnalytics.collectLocation ) {
logger.error("You must enable collectLocation before location can be logged");
return;
}
if( !locationService.getInitLocationRequests()){
logger.error("locationService Initialization has failed");
return;
}
// Create metadata object to log
JSONObject metadata = new JSONObject();
String hashedUserID = UUID.nameUUIDFromBytes(DEFAULT_USER_ID.getBytes()).toString();
try {
metadata.put(CATEGORY, LOG_LOCATION_KEY);
metadata.put(LATITUDE_KEY,locationService.getLatitude());
metadata.put(LONGITUDE_KEY,locationService.getLongitude());
metadata.put(TIMESTAMP_KEY, (new Date()).getTime());
metadata.put(APP_SESSION_ID_KEY, MFPAnalyticsActivityLifecycleListener.getAppSessionID());
metadata.put(USER_ID_KEY,hashedUserID);
} catch (JSONException e) {
logger.debug("JSONException encountered logging change in user context: " + e.getMessage());
}
log(metadata);
}
|
java
|
{
"resource": ""
}
|
q179038
|
BMSAnalytics.setUserIdentity
|
test
|
private static void setUserIdentity(final String user, boolean isInitialCtx) {
if (!isInitialCtx && !BMSAnalytics.hasUserContext) {
// log it to file:
logger.error("Cannot set user identity with anonymous user collection enabled.");
return;
}
// Create metadata object to log
JSONObject metadata = new JSONObject();
DEFAULT_USER_ID=user;
String hashedUserID = UUID.nameUUIDFromBytes(user.getBytes()).toString();
try {
if (isInitialCtx) {
metadata.put(CATEGORY, INITIAL_CTX_CATEGORY);
} else {
metadata.put(CATEGORY, USER_SWITCH_CATEGORY);
}
if (BMSAnalytics.collectLocation ) {
if(locationService.getInitLocationRequests() ){
metadata.put(LONGITUDE_KEY, locationService.getLongitude());
metadata.put(LATITUDE_KEY, locationService.getLatitude());
}
}
metadata.put(TIMESTAMP_KEY, (new Date()).getTime());
metadata.put(APP_SESSION_ID_KEY, MFPAnalyticsActivityLifecycleListener.getAppSessionID());
metadata.put(USER_ID_KEY, hashedUserID);
} catch (JSONException e) {
logger.debug("JSONException encountered logging change in user context: " + e.getMessage());
}
MFPInAppFeedBackListner.setUserIdentity(user);
log(metadata);
}
|
java
|
{
"resource": ""
}
|
q179039
|
FileLogger.getByteArrayFromFile
|
test
|
private byte[] getByteArrayFromFile (final String file) throws UnsupportedEncodingException {
String ret = "";
File fl = new File(context.getFilesDir (), file);
if (fl.exists()) {
try {
FileInputStream fin = new FileInputStream(fl);
ByteArrayOutputStream baos = new ByteArrayOutputStream((int) fl.length ());
copyStream (fin, baos);
return baos.toByteArray ();
} catch (IOException e) {
Log.e(LogPersister.LOG_TAG_NAME, "problem reading file " + fl.toString(), e);
}
}
return ret.getBytes ("UTF-8");
}
|
java
|
{
"resource": ""
}
|
q179040
|
MFPAnalyticsLocationListener.startLocationUpdates
|
test
|
protected void startLocationUpdates() {
if (ActivityCompat.checkSelfPermission(Context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(Context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
|
java
|
{
"resource": ""
}
|
q179041
|
ObjectSizing.sizeRegion
|
test
|
public void sizeRegion(Region<?,?> region, int numEntries) {
if (region == null) {
throw new IllegalArgumentException("Region is null.");
}
if (region instanceof PartitionedRegion) {
sizePartitionedRegion(region, numEntries);
} else {
sizeReplicatedOrLocalRegion(region, numEntries);
}
}
|
java
|
{
"resource": ""
}
|
q179042
|
ObjectSizing.sizePartitionedRegion
|
test
|
private void sizePartitionedRegion(Region<?,?> region, int numEntries) {
Region<?,?> primaryDataSet = PartitionRegionHelper.getLocalData(region);
int regionSize = primaryDataSet.size();
if (numEntries == 0) {
numEntries = primaryDataSet.size();
} else if (numEntries > regionSize) {
numEntries = regionSize;
}
int count = 0;
for (Iterator<?> i = primaryDataSet.entrySet().iterator(); i.hasNext();) {
if (count == numEntries) {
break;
}
EntrySnapshot entry = (EntrySnapshot) i.next();
RegionEntry re = entry.getRegionEntry();
dumpSizes(entry, re);
}
dumpTotalAndAverageSizes(numEntries);
clearTotals();
}
|
java
|
{
"resource": ""
}
|
q179043
|
ObjectSizing.sizeReplicatedOrLocalRegion
|
test
|
private void sizeReplicatedOrLocalRegion(Region<?,?> region, int numEntries) {
Set<?> entries = region.entrySet();
int regionSize = entries.size();
if (numEntries == 0) {
numEntries = entries.size();
} else if (numEntries > regionSize) {
numEntries = regionSize;
}
int count = 0;
for (Iterator<?> i = entries.iterator(); i.hasNext();) {
if (count == numEntries) {
break;
}
LocalRegion.NonTXEntry entry = (LocalRegion.NonTXEntry) i.next();
RegionEntry re = entry.getRegionEntry();
dumpSizes(entry, re);
}
dumpTotalAndAverageSizes(numEntries);
clearTotals();
}
|
java
|
{
"resource": ""
}
|
q179044
|
SnapshotRecordReader.readSnapshotRecord
|
test
|
public SnapshotRecord readSnapshotRecord() throws IOException, ClassNotFoundException {
byte[] key = DataSerializer.readByteArray(dis);
if (key == null) {
return null;
}
byte[] value = DataSerializer.readByteArray(dis);
return new SnapshotRecord(key, value);
}
|
java
|
{
"resource": ""
}
|
q179045
|
TimeStampSeries.dump
|
test
|
void dump(PrintWriter stream) {
stream.print("[size=" + count);
for (int i = 0; i < count; i++) {
if (i != 0) {
stream.print(", ");
stream.print(timeStamps[i] - timeStamps[i - 1]);
} else {
stream.print(" " + timeStamps[i]);
}
}
stream.println("]");
}
|
java
|
{
"resource": ""
}
|
q179046
|
TimeStampSeries.getTimeValuesSinceIdx
|
test
|
double[] getTimeValuesSinceIdx(int idx) {
int resultSize = this.count - idx;
double[] result = new double[resultSize];
for (int i = 0; i < resultSize; i++) {
result[i] = getMilliTimeStamp(idx + i);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q179047
|
StatsToChart.convert
|
test
|
public Chart convert(File file)
{
if(file == null)
return null;
try
{
if(file.isDirectory())
{
//Process for all files
Set<File> statsFiles = IO.listFileRecursive(file, "*.gfs");
if(statsFiles == null || statsFiles.isEmpty())
return null;
for (File statFile : statsFiles)
{
GfStatsReader reader = new GfStatsReader(statFile.getAbsolutePath());
reader.accept(visitor);
}
}
else
{
GfStatsReader reader = new GfStatsReader(file.getAbsolutePath());
reader.accept(visitor);
}
return visitor.getChart();
}
catch (IOException e)
{
throw new RuntimeException ("File:"+file+" ERROR:"+e.getMessage(),e);
}
}
|
java
|
{
"resource": ""
}
|
q179048
|
GemFireJmxClient.getPoolForServer
|
test
|
public static synchronized Pool getPoolForServer(String serverName, JMX jmx)
throws InstanceNotFoundException
{
Pool pool = PoolManager.find(serverName);
if(pool != null)
return pool;
PoolFactory poolFactory = PoolManager.createFactory();
//LogWriter logWriter = getClientCache(jmx).getLogger();
try
{
//get host name
//ex: object GemFire:type=Member,member=server_1
ObjectName objectName = new ObjectName(new StringBuilder("GemFire:type=Member,member=").append(serverName).toString());
String host = jmx.getAttribute(objectName, "Host");
if(host == null || host.length() == 0)
throw new IllegalArgumentException("host not found for serverName:"+serverName+" not found");
host = lookupNetworkHost(host);
String findJmxPort = new StringBuilder("GemFire:service=CacheServer,port=*,type=Member,member=")
.append(serverName).toString();
//search ObjectNames
Set<ObjectName> objectNames = jmx.searchObjectNames(findJmxPort);
if(objectNames == null || objectNames.isEmpty())
throw new IllegalArgumentException("Unable to to find port with server name:"+serverName);
ObjectName portObjectName = objectNames.iterator().next();
Integer port = jmx.getAttribute(portObjectName, "Port");
if(port == null)
throw new IllegalArgumentException("Unable to obtain port for objectName:"+portObjectName+" for server:"+serverName);
System.out.println("Found cache server host"+host+" port:"+port);
poolFactory= poolFactory.addServer(host, port.intValue());
return poolFactory.create(serverName);
}
catch(InstanceNotFoundException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("Unable to create pool for servername:"+serverName+" error:"+e.getMessage(),e);
}
}
|
java
|
{
"resource": ""
}
|
q179049
|
GemFireJmxClient.getPoolForLocator
|
test
|
public static synchronized Pool getPoolForLocator(JMX jmx)
{
String locatorsPoolName = jmx.getHost()+"["+jmx.getPort()+"]";
Pool pool = PoolManager.find(locatorsPoolName);
if(pool != null)
return pool;
PoolFactory poolFactory = PoolManager.createFactory();
try
{
int port = getLocatorPort(jmx);
poolFactory= poolFactory.addLocator(jmx.getHost(), port);
return poolFactory.create(locatorsPoolName);
}
catch (Exception e)
{
throw new RuntimeException("Unable to create pool for locator:"+jmx.getHost()+" error:"+e.getMessage(),e);
}
}
|
java
|
{
"resource": ""
}
|
q179050
|
GemFireJmxClient.isExistingRegionOnServer
|
test
|
private static boolean isExistingRegionOnServer(String regionName,JMX jmx)
{
String regionJmxPattern = String.format("GemFire:service=Region,name=/%s,type=Distributed",regionName);
//System.out.println("searching for:"+regionJmxPattern);
Set<ObjectName> regionObjNameSet = jmx.searchObjectNames(regionJmxPattern);
if(regionObjNameSet == null || regionObjNameSet.isEmpty())
{
//search with quotes
regionJmxPattern = String.format("GemFire:service=Region,name=\"/%s\",type=Distributed",regionName);
//System.out.println("searching for:"+regionJmxPattern);
regionObjNameSet = jmx.searchObjectNames(regionJmxPattern);
}
return regionObjNameSet != null && !regionObjNameSet.isEmpty();
}
|
java
|
{
"resource": ""
}
|
q179051
|
GemFireJmxClient.getMember
|
test
|
public static MemberMXBean getMember(String name,JMX jmx)
{
try
{
String pattern = "GemFire:type=Member,member="+name;
Set<ObjectName> objectNames = jmx.searchObjectNames(pattern);
if(objectNames == null || objectNames.isEmpty())
return null;
ObjectName serverName = new ObjectName(pattern);
return jmx.newBean(MemberMXBean.class,serverName);
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException("Unable to get member "+name
+" ERROR:"+e.getMessage(),e);
}
}
|
java
|
{
"resource": ""
}
|
q179052
|
GemFireJmxClient.listHosts
|
test
|
public static Collection<String> listHosts(JMX jmx)
{
Set<ObjectName> objectNames = jmx.searchObjectNames("GemFire:type=Member,member=*");
if(objectNames == null || objectNames.isEmpty())
{
return null;
}
HashSet<String> hostLists = new HashSet<String>(objectNames.size());
MemberMXBean memberMXBean = null;
for (ObjectName objectName : objectNames)
{
memberMXBean = jmx.newBean(MemberMXBean.class, objectName);
hostLists.add(memberMXBean.getHost());
}
return hostLists;
}
|
java
|
{
"resource": ""
}
|
q179053
|
GemFireJmxClient.lookupNetworkHost
|
test
|
static synchronized String lookupNetworkHost(String host)
{
try
{
if(_bundle == null)
{
URL url = GemFireJmxClient.class.getResource(hostPropFileName);
String filePath = null;
if(url == null)
filePath = hostPropFileName;
else
filePath = url.toString();
System.out.println(new StringBuilder("Loading IP addresses from ")
.append(filePath).toString());
_bundle = ResourceBundle.getBundle("host");
}
System.out.println(new StringBuilder("Looking for host name \"").append(host).append("\" IP address in ")
.append(hostPropFileName).toString());
String newHost = _bundle.getString(host);
System.out.println(new StringBuilder(host).append("=").append(newHost).toString());
return newHost;
}
catch(RuntimeException e)
{
System.out.println("Using host:"+host);
return host;
}
}
|
java
|
{
"resource": ""
}
|
q179054
|
GemFireIO.isErrorAndSendException
|
test
|
public static boolean isErrorAndSendException(ResultSender<Object> resultSender, Object data)
{
if(data instanceof Throwable)
{
Throwable e = (Throwable)data;
resultSender.sendException(e);
return true;
}
return false;
}
|
java
|
{
"resource": ""
}
|
q179055
|
GemFireIO.exeWithResults
|
test
|
@SuppressWarnings("unchecked")
public static <T> Collection<T> exeWithResults(Execution<?,?,?> execution, Function<?> function)
throws Exception
{
ResultCollector<?, ?> resultCollector;
try
{
resultCollector = execution.execute(function);
}
catch (FunctionException e)
{
if(e.getCause() instanceof NullPointerException)
throw new RuntimeException("Unable to execute function:"+function.getId()+
" assert hostnames(s) for locators and cache server can be resovled. "+
" If you do not have access to the host file, create host.properties and add to the CLASSPATH. "+
" Example: locahost=127.1.0.0 "+
" also assert that all cache servers have been initialized. Check if the server's cache.xml has all required <initializer>..</initializer> configurations",
e);
else
throw e;
}
Object resultsObject = resultCollector.getResult();
//Return a result in collection (for a single response)
Collection<Object> collectionResults = (Collection<Object>)resultsObject;
//if empty return null
if(collectionResults.isEmpty())
return null;
Collection<Object> list = new ArrayList<Object>(collectionResults.size());
flatten(collectionResults, list);
if(list.isEmpty())
return null;
return (Collection<T>)list;
}
|
java
|
{
"resource": ""
}
|
q179056
|
GemFireIO.flatten
|
test
|
@SuppressWarnings("unchecked")
public static <T> void flatten(Collection<Object> input,
Collection<Object> flattenOutput)
throws Exception
{
if (input == null || input.isEmpty() || flattenOutput == null)
return;
for (Object inputObj : input)
{
if(inputObj instanceof Exception )
throw (Exception)inputObj;
if(inputObj == null)
continue;
if(inputObj instanceof Collection)
flatten((Collection<Object>)inputObj,flattenOutput);
else
flattenOutput.add(inputObj);
}
}
|
java
|
{
"resource": ""
}
|
q179057
|
Querier.query
|
test
|
@SuppressWarnings("unchecked")
public static <ReturnType> Collection<ReturnType> query(Query queryObj, RegionFunctionContext rfc, Object... params)
throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException
{
SelectResults<ReturnType> selectResults;
// Execute Query locally. Returns results set.
if (rfc == null || JvmRegionFunctionContext.class.isAssignableFrom(rfc.getClass()))
{
if(params == null || params.length == 0)
{
selectResults = (SelectResults<ReturnType>) queryObj.execute();
}
else
{
selectResults = (SelectResults<ReturnType>) queryObj.execute(params);
}
if (selectResults == null || selectResults.isEmpty())
return null;
ArrayList<ReturnType> results = new ArrayList<ReturnType>(selectResults.size());
results.addAll(selectResults.asList());
return results;
}
else
{
if(params == null || params.length == 0)
{
selectResults = (SelectResults<ReturnType>) queryObj.execute(rfc);
}
else
{
selectResults = (SelectResults<ReturnType>) queryObj.execute(rfc,params);
}
if (selectResults == null || selectResults.isEmpty())
return null;
return selectResults;
}
}
|
java
|
{
"resource": ""
}
|
q179058
|
CacheListenerBridge.forAfterPut
|
test
|
public static<K, V> CacheListenerBridge<K, V> forAfterPut(Consumer<EntryEvent<K, V>> consumer)
{
return new CacheListenerBridge<K, V>(consumer,null);
}
|
java
|
{
"resource": ""
}
|
q179059
|
CacheListenerBridge.forAfterDelete
|
test
|
public static<K, V> CacheListenerBridge<K, V> forAfterDelete(Consumer<EntryEvent<K, V>> consumer)
{
return new CacheListenerBridge<K, V>(null,consumer);
}
|
java
|
{
"resource": ""
}
|
q179060
|
GeodeRegionRestService.handleException
|
test
|
@ExceptionHandler(Exception.class)
private DataError handleException(HttpServletRequest request, HttpServletResponse response,Exception e )
{
return faultAgent.handleException(request,response,e);
}
|
java
|
{
"resource": ""
}
|
q179061
|
FunctionFacts.getOnRegionFilterKeyFacts
|
test
|
public OnRegionFilterKeyFacts[] getOnRegionFilterKeyFacts()
{
if(onRegionFilterKeyFacts == null)
return null;
return Arrays.copyOf(onRegionFilterKeyFacts, onRegionFilterKeyFacts.length);
}
|
java
|
{
"resource": ""
}
|
q179062
|
ReadExportFunction.execute
|
test
|
@Override
public void execute(FunctionContext<Object> functionContext)
{
ResultSender<Object> sender = functionContext.getResultSender();
Cache cache = CacheFactory.getAnyInstance();
Logger logWriter = LogManager.getLogger(getClass());
try
{
//export data
String[] args = (String[])functionContext.getArguments();
if(args == null || args.length != 2 )
throw new FunctionException("Required array args: [region,extension]");
String extensionArg = args[0];
if(extensionArg == null || extensionArg.length() == 0)
{
throw new IllegalArgumentException("File extension required");
}
ExportFileType extension = ExportFileType.valueOf(extensionArg);
String regionName = args[1]; //TODO: accept multiple regions
Region<Object,Object> region = cache.getRegion(regionName);
if(region == null)
{
sender.lastResult(null);
return;
}
//TODO: get file from functions
File file = new File(new StringBuilder(directoryPath).append("/").append(regionName)
.append(".").append(extensionArg).toString());
//get server name
String serverName = cache.getDistributedSystem().getDistributedMember().getName();
switch(extension)
{
case gfd:
new GfdExportFunction().exportRegion(region);
break;
default:
throw new IllegalArgumentException("Unsupported extension file type:"+extension);
}
Serializable content = readContent(file,extension,logWriter);
Serializable[] arrayResults = {serverName,content,file.getAbsolutePath()};
sender.lastResult(arrayResults);
}
catch (Exception e)
{
String stackTrace = Debugger.stackTrace(e);
logWriter.error(stackTrace);
throw new FunctionException(stackTrace);
}
}
|
java
|
{
"resource": ""
}
|
q179063
|
GemFireInspector.listHosts
|
test
|
public static Set<String> listHosts(JMX jmx)
{
Set<ObjectName> memberObjects = jmx.searchObjectNames("GemFire:type=Member,member=*");
if(memberObjects == null || memberObjects.isEmpty())
{
return null;
}
HashSet<String> hostList = new HashSet<String>(memberObjects.size());
MemberMXBean bean = null;
for (ObjectName objectName : memberObjects)
{
bean = jmx.newBean(MemberMXBean.class, objectName);
try
{
hostList.add(bean.getHost());
}
catch(UndeclaredThrowableException e)
{
//will not be added
}
}
return hostList;
}
|
java
|
{
"resource": ""
}
|
q179064
|
LuceneSearchFunction.execute
|
test
|
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void execute(FunctionContext functionContext)
{
Cache cache = CacheFactory.getAnyInstance();
try
{
//Function must be executed on REgion
if(!(functionContext instanceof RegionFunctionContext))
{
throw new FunctionException("Execute on a region");
}
Object args = functionContext.getArguments();
if (args == null)
throw new FunctionException("arguments is required");
TextPageCriteria criteria = null;
if(args instanceof PdxInstance)
{
PdxInstance pdxInstance = (PdxInstance)args;
try
{
criteria = (TextPageCriteria)(pdxInstance.getObject());
}
catch (PdxSerializationException e)
{
throw new FunctionException(e.getMessage()+" JSON:"+JSONFormatter.toJSON(pdxInstance));
}
}
else
{
criteria = (TextPageCriteria)args;
}
Region<String, Collection<Object>> pagingRegion = cache.getRegion(criteria.getPageRegionName());
Region<?,?> region = cache.getRegion(criteria.getRegionName());
GeodePagination pagination = new GeodePagination();
TextPolicySearchStrategy geodeSearch = new TextPolicySearchStrategy(cache);
//Collection<String> keys = (Collection<String>)checkCachedKeysByCriteria(criteria,searchRequest,pagination,pagingRegion);
geodeSearch.saveSearchResultsWithPageKeys(criteria, criteria.getQuery(),null, (Region<String,Collection<Object>>)pagingRegion);
//build results
Collection<Object> collection = pagination.readResultsByPageValues(criteria.getId(),criteria.getSortField(),
criteria.isSortDescending(),
criteria.getBeginIndex(),
(Region<Object,Object>)region, (Region)pagingRegion);
if(collection == null)
{
functionContext.getResultSender().lastResult(null);
return;
}
PagingCollection<Object> pageCollection = new PagingCollection<Object>(collection, criteria);
functionContext.getResultSender().lastResult(pageCollection);
}
catch (RuntimeException e)
{
Logger logger = LogManager.getLogger(LuceneSearchFunction.class);
logger.error(Debugger.stackTrace(e));
throw e;
}
}
|
java
|
{
"resource": ""
}
|
q179065
|
StatsUtil.getAppName
|
test
|
public static String getAppName(ResourceInst[] resources)
{
if(resources == null || resources.length == 0)
return null;
ResourceType rt = null;
for (ResourceInst resourceInst : resources)
{
if(resourceInst == null)
continue;
rt = resourceInst.getType();
if(rt == null)
continue;
if(!"CacheServerStats".equals(rt.getName()))
continue;
return resourceInst.getName();
}
return null;
}
|
java
|
{
"resource": ""
}
|
q179066
|
GeodeClient.constructSecurity
|
test
|
protected static void constructSecurity(Properties props) throws IOException
{
props.setProperty("security-client-auth-init", GeodeConfigAuthInitialize.class.getName()+".create");
//write to file
File sslFile = saveEnvFile(GeodeConfigConstants.SSL_KEYSTORE_CLASSPATH_FILE_PROP);
System.out.println("sslFile:"+sslFile);
File sslTrustStoreFile = saveEnvFile(GeodeConfigConstants.SSL_TRUSTSTORE_CLASSPATH_FILE_PROP);
String sslTrustStoreFilePath = "";
if(sslTrustStoreFile != null)
sslTrustStoreFilePath = sslTrustStoreFile.getAbsolutePath();
props.setProperty("ssl-keystore",(sslFile != null) ? sslFile.getAbsolutePath(): "");
props.setProperty("ssl-keystore-password",Config.getPropertyEnv("ssl-keystore-password",""));
props.setProperty("ssl-truststore",sslTrustStoreFilePath);
props.setProperty("ssl-protocols",Config.getPropertyEnv("ssl-protocols",""));
props.setProperty("ssl-truststore-password",Config.getPropertyEnv("ssl-truststore-password",""));
props.setProperty("ssl-keystore-type",Config.getPropertyEnv("ssl-keystore-type","") );
props.setProperty("ssl-ciphers",Config.getPropertyEnv("ssl-ciphers",""));
props.setProperty("ssl-require-authentication",Config.getPropertyEnv("ssl-require-authentication","") );
props.setProperty("ssl-enabled-components", Config.getPropertyEnv("ssl-enabled-components",""));
}
|
java
|
{
"resource": ""
}
|
q179067
|
GeodeClient.getRegion
|
test
|
@SuppressWarnings("unchecked")
public <K,V> Region<K,V> getRegion(String regionName)
{
if(regionName == null || regionName.length() == 0)
return null;
Region<K,V> region = (Region<K,V>)clientCache.getRegion(regionName);
if(region != null )
return (Region<K,V>)region;
region = (Region<K,V>)this.createRegion(regionName);
//Client side data policy is typically NORMAL or EMPTY
if(cachingProxy)
{
//NORMAL data policy are typically used for CACHING_PROXY
//You should interest so updates for the server will be pushed to the clients
region.registerInterestRegex(".*");
}
return region;
}
|
java
|
{
"resource": ""
}
|
q179068
|
GeodeClient.getRegion
|
test
|
@SuppressWarnings("unchecked")
public static <K,V> Region<K,V> getRegion(ClientCache clientCache, String regionName)
{
if(regionName == null || regionName.length() == 0)
return null;
Region<K,V> region = (Region<K,V>)clientCache.getRegion(regionName);
if(region != null )
return (Region<K,V>)region;
region = (Region<K,V>)clientCache
.createClientRegionFactory(ClientRegionShortcut.PROXY).create(regionName);
return region;
}
|
java
|
{
"resource": ""
}
|
q179069
|
RegionDiffDirector.constructComparison
|
test
|
public void constructComparison(Map<?,BigInteger> sourceChecksumMap, Map<?,BigInteger> targetMap)
{
if(sourceChecksumMap == null)
{
if(targetMap != null && !targetMap.isEmpty())
{
this.keysRemovedFromSource.addAll(targetMap.keySet());
}
return;
}
if(targetMap == null)
{
this.keysMissingOnTarget.addAll(sourceChecksumMap.keySet());
return;
}
BigInteger targetBi = null;
BigInteger sourceBi = null;
for (Map.Entry<?, BigInteger> entrySource : sourceChecksumMap.entrySet())
{
targetBi = targetMap.get(entrySource.getKey());
sourceBi = sourceChecksumMap.get(entrySource.getKey());
if(targetBi == null)
{
keysMissingOnTarget.add(entrySource.getKey());
}
else if(!targetBi.equals(sourceBi))
{
keysDifferentOnTarget.add(entrySource.getKey());
}
}
//determine keysRemovedFromSource
Set<?> sourceKeySet = sourceChecksumMap.keySet();
for (Map.Entry<?, ?> targetEntry : targetMap.entrySet())
{
if(!sourceKeySet.contains(targetEntry.getKey()))
{
keysRemovedFromSource.add(targetEntry.getKey());
}
}
}
|
java
|
{
"resource": ""
}
|
q179070
|
ComboValue.mustInsert
|
test
|
private static boolean mustInsert(int nextIdx, long[] valueTimeStamps,
long tsAtInsertPoint) {
return (nextIdx < valueTimeStamps.length)
&& (valueTimeStamps[nextIdx] <= tsAtInsertPoint);
}
|
java
|
{
"resource": ""
}
|
q179071
|
GfStatsReader.close
|
test
|
public void close() throws IOException
{
if (!this.closed)
{
this.closed = true;
this.is.close();
this.dataIn.close();
this.is = null;
this.dataIn = null;
int typeCount = 0;
if (this.resourceTypeTable != null)
{ // fix for bug 32320
for (int i = 0; i < this.resourceTypeTable.length; i++)
{
if (this.resourceTypeTable[i] != null)
{
if (this.resourceTypeTable[i].close())
{
this.resourceTypeTable[i] = null;
}
else
{
typeCount++;
}
}
}
ResourceType[] newTypeTable = new ResourceType[typeCount];
typeCount = 0;
for (ResourceType aResourceTypeTable : this.resourceTypeTable)
{
if (aResourceTypeTable != null)
{
newTypeTable[typeCount] = aResourceTypeTable;
typeCount++;
}
}
this.resourceTypeTable = newTypeTable;
}
if (this.resourceInstTable != null)
{ // fix for bug 32320
int instCount = 0;
for (int i = 0; i < this.resourceInstTable.length; i++)
{
if (this.resourceInstTable[i] != null)
{
if (this.resourceInstTable[i].close())
{
this.resourceInstTable[i] = null;
}
else
{
instCount++;
}
}
}
ResourceInst[] newInstTable = new ResourceInst[instCount];
instCount = 0;
for (ResourceInst aResourceInstTable : this.resourceInstTable)
{
if (aResourceInstTable != null)
{
newInstTable[instCount] = aResourceInstTable;
instCount++;
}
}
this.resourceInstTable = newInstTable;
this.resourceInstSize = instCount;
}
// optimize memory usage of timeSeries now that no more samples
this.timeSeries.shrink();
// filters are no longer needed since file will not be read from
this.filters = null;
}
}
|
java
|
{
"resource": ""
}
|
q179072
|
GfStatsReader.toCvsFiles
|
test
|
public static void toCvsFiles(File directory)
throws IOException
{
Set<File> statsFiles = IO.listFileRecursive(directory, "*.gfs");
if(statsFiles == null || statsFiles.isEmpty())
return;
for (File archiveFile : statsFiles)
{
GfStatsReader reader = new GfStatsReader(archiveFile.getAbsolutePath());
reader.dumpCsvFiles();
}
}
|
java
|
{
"resource": ""
}
|
q179073
|
GfStatsReader.main
|
test
|
public static void main(String[] args)
{
File archiveFile, csvFile;
if(args.length < 1)
{
System.err.println("Usage: java "+GfStatsReader.class.getName()+" archiveFile [csvFile [statName ]*]");
return;
}
try
{
archiveFile = Paths.get(args[0]).toFile();
if(archiveFile.isDirectory())
{
toCvsFiles(archiveFile);
return;
}
if(args.length < 2)
{
GfStatsReader reader = new GfStatsReader(archiveFile.getAbsolutePath());
reader.dumpCsvFiles();
return;
}
String typeName = args[1];
csvFile = Paths.get(args[2]).toFile();
GenericCsvStatsVisitor visitor = null;
if(args.length > 3)
{
String[] stateNames = Arrays.copyOfRange(args, 2, args.length-1);
visitor = new GenericCsvStatsVisitor(csvFile,typeName,stateNames);
}
else
visitor = new GenericCsvStatsVisitor(csvFile,typeName);
System.out.println("accepting");
GfStatsReader reader = new GfStatsReader(archiveFile.getAbsolutePath());
reader.accept(visitor);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
java
|
{
"resource": ""
}
|
q179074
|
SingletonGemFireJmx.reconnect
|
test
|
public synchronized static JMX reconnect()
{
try
{
ClientCache cache = null;
cache = ClientCacheFactory.getAnyInstance();
if(cache != null && !cache.isClosed())
{
cache.close();
}
}
catch (Exception e)
{
System.out.println("Cache was closed");
}
if(jmx != null)
{
jmx.dispose();
jmx = null;
}
return getJmx();
}
|
java
|
{
"resource": ""
}
|
q179075
|
GemFireMgmt.stopMembersOnHost
|
test
|
public static int stopMembersOnHost(String hostName)
{
JMX jmx = SingletonGemFireJmx.getJmx();
String objectNamePattern = "GemFire:type=Member,member=*";
QueryExp queryExp = null;
ValueExp[] values = null;
//Also get the IP
try
{
InetAddress[] addresses = InetAddress.getAllByName(hostName);
InetAddress address = null;
if(addresses != null)
{
values = new ValueExp[addresses.length];
for (int i=0; i <addresses.length;i++)
{
address = addresses[i];
values[i] = Query.value(address.getHostAddress());
}
}
}
catch (UnknownHostException e)
{
Debugger.println(e.getMessage());
}
if(values != null)
{
queryExp = Query.or(Query.eq(Query.attr("Host"), Query.value(hostName)),
Query.in(Query.attr("Host"), values));
}
else
{
queryExp = Query.eq(Query.attr("Host"), Query.value(hostName));
}
/*
* QueryExp query = Query.and(Query.eq(Query.attr("Enabled"), Query.value(true)),
Query.eq(Query.attr("Owner"), Query.value("Duke")));
*/
Set<ObjectName> memberObjectNames = jmx.searchObjectNames(objectNamePattern, queryExp);
if(memberObjectNames == null || memberObjectNames.isEmpty())
return 0;
int memberCount = memberObjectNames.size();
MemberMXBean member = null;
Collection<String> locators = new ArrayList<String>();
for (ObjectName objectName : memberObjectNames)
{
member = GemFireJmxClient.getMember(objectName.getKeyProperty("member"), SingletonGemFireJmx.getJmx());
if(member.isLocator())
{
locators.add(member.getName());
}
else
{
shutDownMember(member.getName());
}
}
for (String locatorName : locators)
{
shutDownMember(locatorName);
}
return memberCount;
}
|
java
|
{
"resource": ""
}
|
q179076
|
GemFireMgmt.shutDownMember
|
test
|
public static void shutDownMember(String name)
{
try
{
ObjectName serverName = new ObjectName("GemFire:type=Member,member="+name);
JMX jmx = SingletonGemFireJmx.getJmx();
MemberMXBean bean = jmx.newBean(MemberMXBean.class,serverName);
bean.shutDownMember();
//wait for member to shutdown
System.out.println("Waiting for member:"+name+" to shutdown");
while(GemFireJmxClient.checkMemberStatus(name,SingletonGemFireJmx.getJmx()))
{
Thread.sleep(shutDownDelay);
}
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException("Unable to shutdown member "+name
+" ERROR:"+e.getMessage(),e);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
|
java
|
{
"resource": ""
}
|
q179077
|
GemFireMgmt.shutDown
|
test
|
public static String [] shutDown(JMX jmx)
{
try
{
DistributedSystemMXBean bean = toDistributeSystem(jmx);
return bean.shutDownAllMembers();
}
catch (Exception e)
{
throw new RuntimeException(" ERROR:"+e.getMessage(),e);
}
}
|
java
|
{
"resource": ""
}
|
q179078
|
GemFireMgmt.shutDownRedundancyZone
|
test
|
public static void shutDownRedundancyZone(String redundancyZone)
{
if (redundancyZone == null || redundancyZone.length() == 0)
throw new IllegalArgumentException("redundancyZone required");
String objectNamePattern = "GemFire:type=Member,member=*";
QueryExp exp = Query.eq(Query.attr("RedundancyZone"),Query.value(redundancyZone));
Collection<ObjectName> memberObjectNames = SingletonGemFireJmx.getJmx().searchObjectNames(objectNamePattern, exp);
for (ObjectName objectName : memberObjectNames)
{
GemFireMgmt.shutDownMember(objectName.getKeyProperty("member"));
}
}
|
java
|
{
"resource": ""
}
|
q179079
|
GeodePagination.storePaginationMap
|
test
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public <K, V> List<String> storePaginationMap(String id,int pageSize,
Region<String, Collection<K>> pageKeysRegion,
List<Map.Entry<K, V>> results)
{
if(results == null || results.isEmpty())
return null;
//add to pages
List<Collection<K>> pagesCollection = toKeyPages((List)results, pageSize);
int pageIndex = 1;
String key = null;
ArrayList<String> keys = new ArrayList<String>(pageSize);
for (Collection<K> page : pagesCollection)
{
//store in region
key = toPageKey(id,pageIndex++);
pageKeysRegion.put(key, page);
keys.add(key);
}
keys.trimToSize();
return keys;
}
|
java
|
{
"resource": ""
}
|
q179080
|
GeodePagination.readResultsByPage
|
test
|
public <K,V> Map<K,V> readResultsByPage(TextPageCriteria criteria, int pageNumber, Region<K,V> region, Region<String,Collection<?>> pageRegion)
{
if(pageRegion == null )
return null;
Collection<?> regionKeys = pageRegion.get(criteria.toPageKey(pageNumber));
if(regionKeys == null|| regionKeys.isEmpty())
return null;
return region.getAll(regionKeys);
}
|
java
|
{
"resource": ""
}
|
q179081
|
GfdImportFunction.importRegion
|
test
|
private boolean importRegion(Region<Object, Object> region)
throws Exception
{
File file = DataOpsSecretary.determineFile(ExportFileType.gfd, region.getName());
if(!file.exists())
return false;
region.getSnapshotService().load(file, SnapshotFormat.GEMFIRE);
return true;
}
|
java
|
{
"resource": ""
}
|
q179082
|
GemFireNetworking.checkRemoteLocatorsAndLocatorsMatch
|
test
|
public static boolean checkRemoteLocatorsAndLocatorsMatch(String remoteLocators, String locators)
{
if(remoteLocators == null || remoteLocators.length() == 0)
return false;
if(remoteLocators.equalsIgnoreCase(locators))
return true;
String[] remoteLocatorsArray = remoteLocators.split(",");
if(locators == null || locators.length() == 0)
return false;
String[] locatorsArray = locators.split(",");
String remoteLocatorHost, locatorHost;
int remoteLocatorPort, locatorPort;
for (String remoteLocator : remoteLocatorsArray)
{
if(remoteLocator == null || remoteLocator.length() == 0)
continue;
//parse host
for(String locator: locatorsArray)
{
if(locator == null || locator.length() == 0)
continue;
try
{
remoteLocatorHost = parseLocatorHost(remoteLocator);
locatorHost = parseLocatorHost(locator);
remoteLocatorPort = parseLocatorPort(remoteLocator);
locatorPort = parseLocatorPort(locator);
if(Networking.hostEquals(remoteLocatorHost,locatorHost)
&& remoteLocatorPort == locatorPort)
{
return true;
}
else
{
//check if ip address match
}
}
catch (NumberFormatException e)
{
//port parse exception
return false;
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException("remoteLocator:"+remoteLocator+" locator:"+locator+" ERROR:"+e.getMessage(),e);
}
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q179083
|
GetEntriesChecksumFunction.execute
|
test
|
@Override
public void execute(FunctionContext<Object> functionContext)
{
try
{
String[] args = (String[])functionContext.getArguments();
if(args == null || args.length == 0)
throw new IllegalArgumentException("region argument required");
String regionName = args[0];
if(regionName == null || regionName.length() == 0)
throw new IllegalArgumentException("region name argument required");
Region<Serializable,Object> region = CacheFactory.getAnyInstance().getRegion(regionName);
if(region == null)
throw new IllegalArgumentException("region:"+regionName+" not found");
functionContext.getResultSender().lastResult(buildCheckSumMap(region));
}
catch (Exception e)
{
String stack = Debugger.stackTrace(e);
LogManager.getLogger(getClass()).error(stack);
throw new FunctionException(stack);
}
}
|
java
|
{
"resource": ""
}
|
q179084
|
GetEntriesChecksumFunction.buildCheckSumMap
|
test
|
HashMap<Serializable,BigInteger> buildCheckSumMap(Region<Serializable,Object> region)
{
if(region.getAttributes().getDataPolicy().withPartitioning())
{
region = PartitionRegionHelper.getLocalData(region);
}
Set<Serializable> keySet = region.keySet();
if(keySet == null || keySet.isEmpty())
return null;
HashMap<Serializable,BigInteger> regionCheckSumMap = new HashMap<Serializable,BigInteger>(keySet.size());
Object object = null;
Object tmp = null;
for (Map.Entry<Serializable,Object> entry :region.entrySet())
{
object = entry.getValue();
if(PdxInstance.class.isAssignableFrom(object.getClass()))
{
tmp = ((PdxInstance)object).getObject();
if(Serializable.class.isAssignableFrom(tmp.getClass()))
{
object = tmp;
}
//else use PdxInstance.hashCode
}
if(!(PdxInstance.class.isAssignableFrom(object.getClass())))
{
regionCheckSumMap.put(entry.getKey(), MD.checksum(object));
}
else
{
regionCheckSumMap.put(entry.getKey(), BigInteger.valueOf(object.hashCode()));
}
}
return regionCheckSumMap;
}
|
java
|
{
"resource": ""
}
|
q179085
|
QueryBuilder.valueOf
|
test
|
private Object valueOf(String columnName, Object value) {
java.lang.reflect.Field field;
try {
field = tableObject.getDeclaredField(columnName);
} catch (NoSuchFieldException e) {
throw new RuntimeException(
String.format("%s isEqualTo not a field found in %s", columnName, tableObject));
}
return field.getType() == String.class ? String.format("\'%s\'", value) : value;
}
|
java
|
{
"resource": ""
}
|
q179086
|
SqliteInteger.isTypeOf
|
test
|
boolean isTypeOf(TypeMirror typeMirror) {
if (integerKinds.contains(typeMirror.getKind())) {
return true;
}
if (integerObjects.contains(typeMirror.toString())) {
return true;
}
return false;
}
|
java
|
{
"resource": ""
}
|
q179087
|
ShillelaghUtil.serialize
|
test
|
public static <T> byte[] serialize(T object) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(object);
return byteArrayOutputStream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
{
"resource": ""
}
|
q179088
|
ShillelaghUtil.deserialize
|
test
|
public static <K> K deserialize(byte[] bytes) {
try {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
@SuppressWarnings("unchecked") final K k = (K) objectInputStream.readObject();
return k;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
|
java
|
{
"resource": ""
}
|
q179089
|
ShillelaghUtil.createInstance
|
test
|
@SuppressWarnings("unchecked")
public static <T> T createInstance(Class<T> clazz) {
if (clazz.isInterface()) {
if (clazz == List.class) {
return (T) new ArrayList();
} else if (clazz == Map.class) {
return (T) new HashMap();
}
throw new UnsupportedOperationException("Interface types can not be instantiated.");
}
ObjectInstantiator instantiator = OBJENESIS.getInstantiatorOf(clazz);
return (T) instantiator.newInstance();
}
|
java
|
{
"resource": ""
}
|
q179090
|
ShillelaghProcessor.checkForTableId
|
test
|
private void checkForTableId(TableObject tableObject, Element element) {
// Check if user wants to use an id other than _id
Id idAnnotation = element.getAnnotation(Id.class);
if (idAnnotation != null) {
if (element.asType().getKind() != TypeKind.LONG && !("java.lang.Long".equals(
element.asType().toString()))) {
logger.e("@Id must be on a long");
}
// Id attribute set and continue
String columnName = Strings.isBlank(idAnnotation.name()) //
? element.getSimpleName().toString() //
: idAnnotation.name();
final TableColumn idColumn = new TableColumn(columnName, element.getSimpleName().toString(),
element.asType().toString(), SqliteType.INTEGER);
tableObject.setIdColumn(idColumn);
}
}
|
java
|
{
"resource": ""
}
|
q179091
|
ShillelaghProcessor.checkForFields
|
test
|
private void checkForFields(TableObject tableObject, Element columnElement) {
Column columnAnnotation = columnElement.getAnnotation(Column.class);
if (columnAnnotation == null) return;
// Convert the element from a field to a type
final Element typeElement = typeUtils.asElement(columnElement.asType());
final String type = typeElement == null ? columnElement.asType().toString()
: elementUtils.getBinaryName((TypeElement) typeElement).toString();
TableColumn tableColumn = new TableColumn(columnElement, type, columnAnnotation.name());
if (tableColumn.isBlob() && !tableColumn.isByteArray()) {
String columnType = columnElement.asType().toString();
logger.d("Column Element Type: " + columnType);
if (!checkForSuperType(columnElement, Serializable.class)
&& !columnType.equals("java.lang.Byte[]")
&& !columnType.startsWith("java.util.Map")
&& !columnType.startsWith("java.util.List")) {
logger.e(String.format(
"%s in %s is not Serializable and will not be able to be converted to a byte array",
columnElement.toString(), tableObject.getTableName()));
}
} else if (tableColumn.isOneToMany()) {
// List<T> should only have one generic type. Get that type and make sure
// it has @Table annotation
TypeMirror typeMirror = ((DeclaredType) columnElement.asType()).getTypeArguments().get(0);
if (typeUtils.asElement(typeMirror).getAnnotation(Table.class) == null) {
logger.e("One to many relationship in class %s where %s is not annotated with @Table",
tableObject.getTableName(), tableColumn.getColumnName());
}
oneToManyCache.put(typeMirror.toString(), tableObject);
TypeElement childColumnElement = elementUtils.getTypeElement(typeMirror.toString());
tableColumn.setType(getClassName(childColumnElement, getPackageName(childColumnElement)));
} else if (tableColumn.getSqlType() == SqliteType.UNKNOWN) {
@SuppressWarnings("ConstantConditions") Table annotation =
typeElement.getAnnotation(Table.class);
if (annotation == null) {
logger.e(String.format(
"%s in %s needs to be marked as a blob or should be " + "annotated with @Table",
columnElement.toString(), tableObject.getTableName()));
}
tableColumn.setOneToOne(true);
}
tableObject.addColumn(tableColumn);
}
|
java
|
{
"resource": ""
}
|
q179092
|
ShillelaghProcessor.checkForSuperType
|
test
|
private boolean checkForSuperType(Element element, Class type) {
List<? extends TypeMirror> superTypes = typeUtils.directSupertypes(element.asType());
for (TypeMirror superType : superTypes) {
if (superType.toString().equals(type.getName())) {
return true;
}
}
return false;
}
|
java
|
{
"resource": ""
}
|
q179093
|
TableObject.getSchema
|
test
|
private String getSchema() {
StringBuilder sb = new StringBuilder();
Iterator<TableColumn> iterator = columns.iterator();
while (iterator.hasNext()) {
TableColumn column = iterator.next();
if (column.isOneToMany()) {
if (!iterator.hasNext()) {
// remove the extra ", " after one to many
int length = sb.length();
sb.replace(length - 2, length, "");
}
continue;
}
sb.append(column);
if (iterator.hasNext()) {
sb.append(", ");
}
}
// writes out id_missing for logging, the actual idMissing check happens
// by the annotation processor.
String idCol = idColumn == null ? "id_missing" : idColumn.getColumnName();
return String.format(CREATE_TABLE_DEFAULT, getTableName(), idCol, sb.toString());
}
|
java
|
{
"resource": ""
}
|
q179094
|
TableObject.brewJava
|
test
|
void brewJava(Writer writer) throws IOException {
logger.d("brewJava");
JavaWriter javaWriter = new JavaWriter(writer);
javaWriter.setCompressingTypes(false);
javaWriter.emitSingleLineComment("Generated code from Shillelagh. Do not modify!") //
.emitPackage(classPackage) //
/* Knows nothing of android types, must use strings. */ //
.emitImports("android.content.ContentValues", "android.database.Cursor", //
"android.database.DatabaseUtils", "android.database.sqlite.SQLiteDatabase") //
.emitImports(ShillelaghUtil.class, ByteArrayInputStream.class, ByteArrayOutputStream.class,
IOException.class, ObjectInputStream.class, ObjectOutputStream.class, LinkedList.class,
Date.class, List.class) //
.beginType(className, "class", EnumSet.of(PUBLIC, FINAL));
if (this.isChildTable) {
emitParentInsert(javaWriter);
emitSelectAll(javaWriter);
}
emitInsert(javaWriter);
emitOneToOneInsert(javaWriter);
emitGetId(javaWriter);
emitCreateTable(javaWriter);
emitDropTable(javaWriter);
emitUpdate(javaWriter);
emitUpdateColumnId(javaWriter);
emitDeleteWithId(javaWriter);
emitDeleteWithObject(javaWriter);
emitMapCursorToObject(javaWriter);
emitSingleMap(javaWriter);
emitSelectById(javaWriter);
javaWriter.endType();
}
|
java
|
{
"resource": ""
}
|
q179095
|
TableObject.emitGetId
|
test
|
private void emitGetId(JavaWriter javaWriter) throws IOException {
logger.d("emitGetId");
javaWriter.beginMethod("long", GET_ID_FUNCTION, EnumSet.of(PUBLIC, STATIC), getTargetClass(),
"value").emitStatement("return value.%s", idColumn.getMemberName()).endMethod();
}
|
java
|
{
"resource": ""
}
|
q179096
|
Builder.toObservable
|
test
|
public final Observable<T> toObservable() {
if (!HAS_RX_JAVA) {
throw new RuntimeException(
"RxJava not available! Add RxJava to your build to use this feature");
}
return shillelagh.getObservable(tableObject, new CursorLoader() {
@Override public Cursor getCursor() {
return shillelagh.rawQuery(query.toString());
}
});
}
|
java
|
{
"resource": ""
}
|
q179097
|
Builder.checkColumnName
|
test
|
final void checkColumnName(String columnName) {
try {
tableObject.getDeclaredField(columnName);
} catch (NoSuchFieldException e) {
throw new RuntimeException(
String.format("%s isEqualTo not a field found in %s", columnName, tableObject));
}
}
|
java
|
{
"resource": ""
}
|
q179098
|
Strings.valueOrDefault
|
test
|
static String valueOrDefault(String string, String defaultString) {
return isBlank(string) ? defaultString : string;
}
|
java
|
{
"resource": ""
}
|
q179099
|
Strings.capitalize
|
test
|
static String capitalize(String string) {
if (isBlank(string)) {
return "";
}
char first = string.charAt(0);
if (Character.isUpperCase(first)) {
return string;
} else {
return Character.toUpperCase(first) + string.substring(1);
}
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.