repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | package com.antest1.kcanotify;
public class ToolsActivity extends AppCompatActivity {
Toolbar toolbar;
KcaDBHelper dbHelper;
static Gson gson = new Gson();
LinearLayout view_fleetlist, view_shiplist, view_equipment, view_droplog, view_reslog, view_akashi, view_expcalc, view_expdtable;
public ToolsActivity() {
LocaleUtils.updateConfig(this);
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
| // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
package com.antest1.kcanotify;
public class ToolsActivity extends AppCompatActivity {
Toolbar toolbar;
KcaDBHelper dbHelper;
static Gson gson = new Gson();
LinearLayout view_fleetlist, view_shiplist, view_equipment, view_droplog, view_reslog, view_akashi, view_expcalc, view_expdtable;
public ToolsActivity() {
LocaleUtils.updateConfig(this);
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
| dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | package com.antest1.kcanotify;
public class ToolsActivity extends AppCompatActivity {
Toolbar toolbar;
KcaDBHelper dbHelper;
static Gson gson = new Gson();
LinearLayout view_fleetlist, view_shiplist, view_equipment, view_droplog, view_reslog, view_akashi, view_expcalc, view_expdtable;
public ToolsActivity() {
LocaleUtils.updateConfig(this);
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
package com.antest1.kcanotify;
public class ToolsActivity extends AppCompatActivity {
Toolbar toolbar;
KcaDBHelper dbHelper;
static Gson gson = new Gson();
LinearLayout view_fleetlist, view_shiplist, view_equipment, view_droplog, view_reslog, view_akashi, view_expcalc, view_expdtable;
public ToolsActivity() {
LocaleUtils.updateConfig(this);
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); | JsonObject kcDataObj = dbHelper.getJsonObjectValue(DB_KEY_STARTDATA); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | }
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
JsonObject kcDataObj = dbHelper.getJsonObjectValue(DB_KEY_STARTDATA);
if (kcDataObj != null && kcDataObj.has("api_data")) {
KcaApiData.getKcGameData(kcDataObj.getAsJsonObject("api_data"));
}
view_fleetlist.setOnClickListener(view -> { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
JsonObject kcDataObj = dbHelper.getJsonObjectValue(DB_KEY_STARTDATA);
if (kcDataObj != null && kcDataObj.has("api_data")) {
KcaApiData.getKcGameData(kcDataObj.getAsJsonObject("api_data"));
}
view_fleetlist.setOnClickListener(view -> { | sendUserAnalytics(getApplicationContext(), OPEN_TOOL.concat("FleetInfo"), null); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | }
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
JsonObject kcDataObj = dbHelper.getJsonObjectValue(DB_KEY_STARTDATA);
if (kcDataObj != null && kcDataObj.has("api_data")) {
KcaApiData.getKcGameData(kcDataObj.getAsJsonObject("api_data"));
}
view_fleetlist.setOnClickListener(view -> { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
}
private String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool_list);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.action_tools));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
view_fleetlist = findViewById(R.id.action_fleetlist);
view_shiplist = findViewById(R.id.action_shiplist);
view_equipment = findViewById(R.id.action_equipment);
view_droplog = findViewById(R.id.action_droplog);
view_reslog = findViewById(R.id.action_reslog);
view_akashi = findViewById(R.id.action_akashi);
view_expcalc = findViewById(R.id.action_expcalc);
view_expdtable = findViewById(R.id.action_expdtable);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
JsonObject kcDataObj = dbHelper.getJsonObjectValue(DB_KEY_STARTDATA);
if (kcDataObj != null && kcDataObj.has("api_data")) {
KcaApiData.getKcGameData(kcDataObj.getAsJsonObject("api_data"));
}
view_fleetlist.setOnClickListener(view -> { | sendUserAnalytics(getApplicationContext(), OPEN_TOOL.concat("FleetInfo"), null); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | Intent intent = new Intent(ToolsActivity.this, ExpeditionTableActivity.class);
startActivity(intent);
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
KcaApplication.defaultLocale = newConfig.getLocales().get(0);
} else {
Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
KcaApplication.defaultLocale = newConfig.locale;
} | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
Intent intent = new Intent(ToolsActivity.this, ExpeditionTableActivity.class);
startActivity(intent);
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
KcaApplication.defaultLocale = newConfig.getLocales().get(0);
} else {
Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
KcaApplication.defaultLocale = newConfig.locale;
} | if(getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).startsWith("default")) { |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ToolsActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
| import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics; | Intent intent = new Intent(ToolsActivity.this, ExpeditionTableActivity.class);
startActivity(intent);
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
KcaApplication.defaultLocale = newConfig.getLocales().get(0);
} else {
Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
KcaApplication.defaultLocale = newConfig.locale;
} | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_STARTDATA = "key_startdata";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_TOOL = "OpenTool";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
// Bundle params = new Bundle();
// FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
// if (value != null) {
// for (String key: value.keySet()) {
// params.putString(key, value.get(key).getAsString());
// }
// }
// mFirebaseAnalytics.logEvent(event, params);
// }
// Path: app/src/main/java/com/antest1/kcanotify/ToolsActivity.java
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.LinearLayout;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_TOOL;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
Intent intent = new Intent(ToolsActivity.this, ExpeditionTableActivity.class);
startActivity(intent);
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
KcaApplication.defaultLocale = newConfig.getLocales().get(0);
} else {
Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
KcaApplication.defaultLocale = newConfig.locale;
} | if(getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).startsWith("default")) { |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaExpedition2.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaAlarmService.java
// public static long ALARM_DELAY = 61000;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getTimeStr(int left_time, boolean is_min) {
// int sec, min, hour;
// sec = left_time;
// min = sec / 60;
// hour = min / 60;
// sec = sec % 60;
// min = min % 60;
// if (is_min) return KcaUtils.format("%02d:%02d", hour * 60 + min, sec);
// else return KcaUtils.format("%02d:%02d:%02d", hour, min, sec);
// }
| import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import static android.text.TextUtils.concat;
import static com.antest1.kcanotify.KcaAlarmService.ALARM_DELAY;
import static com.antest1.kcanotify.KcaUtils.getTimeStr; |
public static boolean isCanceled(int idx) {
return canceled_flag[idx];
}
public static String getDeckName(int idx) {
return deck_name[idx];
}
public static int getIdxByMissionNo(int mission) {
for (int i = 1; i < mission_no.length; i++) {
if (mission_no[i] == mission) {
return i;
}
}
return -1;
}
public static void cancel(int idx, long arrive_time) {
canceled_flag[idx] = true;
complete_time_check[idx] = arrive_time;
}
public static long getArriveTime(int idx) {
return complete_time_check[idx];
}
public static String getLeftTimeStr(int idx) {
if (complete_time_check[idx] == -1) return "";
else { | // Path: app/src/main/java/com/antest1/kcanotify/KcaAlarmService.java
// public static long ALARM_DELAY = 61000;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getTimeStr(int left_time, boolean is_min) {
// int sec, min, hour;
// sec = left_time;
// min = sec / 60;
// hour = min / 60;
// sec = sec % 60;
// min = min % 60;
// if (is_min) return KcaUtils.format("%02d:%02d", hour * 60 + min, sec);
// else return KcaUtils.format("%02d:%02d:%02d", hour, min, sec);
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaExpedition2.java
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import static android.text.TextUtils.concat;
import static com.antest1.kcanotify.KcaAlarmService.ALARM_DELAY;
import static com.antest1.kcanotify.KcaUtils.getTimeStr;
public static boolean isCanceled(int idx) {
return canceled_flag[idx];
}
public static String getDeckName(int idx) {
return deck_name[idx];
}
public static int getIdxByMissionNo(int mission) {
for (int i = 1; i < mission_no.length; i++) {
if (mission_no[i] == mission) {
return i;
}
}
return -1;
}
public static void cancel(int idx, long arrive_time) {
canceled_flag[idx] = true;
complete_time_check[idx] = arrive_time;
}
public static long getArriveTime(int idx) {
return complete_time_check[idx];
}
public static String getLeftTimeStr(int idx) {
if (complete_time_check[idx] == -1) return "";
else { | int left_time = (int) (complete_time_check[idx] - System.currentTimeMillis() - ALARM_DELAY) / 1000; |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaExpedition2.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaAlarmService.java
// public static long ALARM_DELAY = 61000;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getTimeStr(int left_time, boolean is_min) {
// int sec, min, hour;
// sec = left_time;
// min = sec / 60;
// hour = min / 60;
// sec = sec % 60;
// min = min % 60;
// if (is_min) return KcaUtils.format("%02d:%02d", hour * 60 + min, sec);
// else return KcaUtils.format("%02d:%02d:%02d", hour, min, sec);
// }
| import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import static android.text.TextUtils.concat;
import static com.antest1.kcanotify.KcaAlarmService.ALARM_DELAY;
import static com.antest1.kcanotify.KcaUtils.getTimeStr; | }
public static String getDeckName(int idx) {
return deck_name[idx];
}
public static int getIdxByMissionNo(int mission) {
for (int i = 1; i < mission_no.length; i++) {
if (mission_no[i] == mission) {
return i;
}
}
return -1;
}
public static void cancel(int idx, long arrive_time) {
canceled_flag[idx] = true;
complete_time_check[idx] = arrive_time;
}
public static long getArriveTime(int idx) {
return complete_time_check[idx];
}
public static String getLeftTimeStr(int idx) {
if (complete_time_check[idx] == -1) return "";
else {
int left_time = (int) (complete_time_check[idx] - System.currentTimeMillis() - ALARM_DELAY) / 1000;
if (left_time < 0) return "";
String mission_no_head = getExpeditionHeader(mission_no[idx]); | // Path: app/src/main/java/com/antest1/kcanotify/KcaAlarmService.java
// public static long ALARM_DELAY = 61000;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getTimeStr(int left_time, boolean is_min) {
// int sec, min, hour;
// sec = left_time;
// min = sec / 60;
// hour = min / 60;
// sec = sec % 60;
// min = min % 60;
// if (is_min) return KcaUtils.format("%02d:%02d", hour * 60 + min, sec);
// else return KcaUtils.format("%02d:%02d:%02d", hour, min, sec);
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaExpedition2.java
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import static android.text.TextUtils.concat;
import static com.antest1.kcanotify.KcaAlarmService.ALARM_DELAY;
import static com.antest1.kcanotify.KcaUtils.getTimeStr;
}
public static String getDeckName(int idx) {
return deck_name[idx];
}
public static int getIdxByMissionNo(int mission) {
for (int i = 1; i < mission_no.length; i++) {
if (mission_no[i] == mission) {
return i;
}
}
return -1;
}
public static void cancel(int idx, long arrive_time) {
canceled_flag[idx] = true;
complete_time_check[idx] = arrive_time;
}
public static long getArriveTime(int idx) {
return complete_time_check[idx];
}
public static String getLeftTimeStr(int idx) {
if (complete_time_check[idx] == -1) return "";
else {
int left_time = (int) (complete_time_check[idx] - System.currentTimeMillis() - ALARM_DELAY) / 1000;
if (left_time < 0) return "";
String mission_no_head = getExpeditionHeader(mission_no[idx]); | return mission_no_head.concat(getTimeStr(left_time)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaAutomationReceiver.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON; | package com.antest1.kcanotify;
public class KcaAutomationReceiver extends BroadcastReceiver {
public static final String SNIFFER_ON_ACTION = "sniffer_on";
public static final String SNIFFER_OFF_ACTION = "sniffer_off";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
switch (action) {
case SNIFFER_ON_ACTION:
try {
VpnService.prepare(context); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";
// Path: app/src/main/java/com/antest1/kcanotify/KcaAutomationReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON;
package com.antest1.kcanotify;
public class KcaAutomationReceiver extends BroadcastReceiver {
public static final String SNIFFER_ON_ACTION = "sniffer_on";
public static final String SNIFFER_OFF_ACTION = "sniffer_off";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
switch (action) {
case SNIFFER_ON_ACTION:
try {
VpnService.prepare(context); | prefs.edit().putBoolean(PREF_VPN_ENABLED, true).apply(); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaAutomationReceiver.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON; | package com.antest1.kcanotify;
public class KcaAutomationReceiver extends BroadcastReceiver {
public static final String SNIFFER_ON_ACTION = "sniffer_on";
public static final String SNIFFER_OFF_ACTION = "sniffer_off";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
switch (action) {
case SNIFFER_ON_ACTION:
try {
VpnService.prepare(context);
prefs.edit().putBoolean(PREF_VPN_ENABLED, true).apply();
KcaVpnService.start("prepared", context);
} catch (Throwable ex) {
// Prepare failed
Log.e("KCA", ex.toString() + "\n" + Log.getStackTraceString(ex));
}
break;
case SNIFFER_OFF_ACTION: | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";
// Path: app/src/main/java/com/antest1/kcanotify/KcaAutomationReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON;
package com.antest1.kcanotify;
public class KcaAutomationReceiver extends BroadcastReceiver {
public static final String SNIFFER_ON_ACTION = "sniffer_on";
public static final String SNIFFER_OFF_ACTION = "sniffer_off";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
switch (action) {
case SNIFFER_ON_ACTION:
try {
VpnService.prepare(context);
prefs.edit().putBoolean(PREF_VPN_ENABLED, true).apply();
KcaVpnService.start("prepared", context);
} catch (Throwable ex) {
// Prepare failed
Log.e("KCA", ex.toString() + "\n" + Log.getStackTraceString(ex));
}
break;
case SNIFFER_OFF_ACTION: | KcaVpnService.stop(VPN_STOP_REASON, context); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaApplication.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
| import android.content.Context;
import android.content.SharedPreferences;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE; | package com.antest1.kcanotify;
public class KcaApplication extends MultiDexApplication {
public static Locale defaultLocale;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
public void onCreate() {
super.onCreate();
String language, country;
defaultLocale = Locale.getDefault();
SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
// Path: app/src/main/java/com/antest1/kcanotify/KcaApplication.java
import android.content.Context;
import android.content.SharedPreferences;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.util.Locale;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
package com.antest1.kcanotify;
public class KcaApplication extends MultiDexApplication {
public static Locale defaultLocale;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
public void onCreate() {
super.onCreate();
String language, country;
defaultLocale = Locale.getDefault();
SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE); | String[] pref_locale = pref.getString(PREF_KCA_LANGUAGE, "").split("-"); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaFleetViewMenuOrderActivity extends AppCompatActivity {
Toolbar toolbar;
private static Handler sHandler;
static Gson gson = new Gson();
DragListView listview;
KcaFleetViewMenuOrderAdpater adapter;
JsonArray order_data = new JsonArray();
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>(); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaFleetViewMenuOrderActivity extends AppCompatActivity {
Toolbar toolbar;
private static Handler sHandler;
static Gson gson = new Gson();
DragListView listview;
KcaFleetViewMenuOrderAdpater adapter;
JsonArray order_data = new JsonArray();
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>(); | String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaFleetViewMenuOrderActivity extends AppCompatActivity {
Toolbar toolbar;
private static Handler sHandler;
static Gson gson = new Gson();
DragListView listview;
KcaFleetViewMenuOrderAdpater adapter;
JsonArray order_data = new JsonArray();
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>(); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaFleetViewMenuOrderActivity extends AppCompatActivity {
Toolbar toolbar;
private static Handler sHandler;
static Gson gson = new Gson();
DragListView listview;
KcaFleetViewMenuOrderAdpater adapter;
JsonArray order_data = new JsonArray();
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>(); | String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; |
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>();
String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER);
if (pref_value.length() > 0) {
order_data = new JsonParser().parse(pref_value).getAsJsonArray();
for (int i = 0; i < order_data.size(); i++) {
JsonObject item = new JsonObject();
int key = order_data.get(i).getAsInt();
item.addProperty("key", key); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
public static void setHandler(Handler h) {
sHandler = h;
}
public KcaFleetViewMenuOrderActivity() {
LocaleUtils.updateConfig(this);
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>();
String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER);
if (pref_value.length() > 0) {
order_data = new JsonParser().parse(pref_value).getAsJsonArray();
for (int i = 0; i < order_data.size(); i++) {
JsonObject item = new JsonObject();
int key = order_data.get(i).getAsInt();
item.addProperty("key", key); | item.addProperty("value", fleetview_menu_keys[key]); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>();
String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER);
if (pref_value.length() > 0) {
order_data = new JsonParser().parse(pref_value).getAsJsonArray();
for (int i = 0; i < order_data.size(); i++) {
JsonObject item = new JsonObject();
int key = order_data.get(i).getAsInt();
item.addProperty("key", key);
item.addProperty("value", fleetview_menu_keys[key]);
item.addProperty("label", getStringWithLocale(KcaUtils.getId(
KcaUtils.format("viewmenu_%s", fleetview_menu_keys[key]), R.string.class)));
data.add(item);
}
} else {
for (int i = 0; i < fleetview_menu_keys.length; i++) {
JsonObject item = new JsonObject();
item.addProperty("key", i);
item.addProperty("value", fleetview_menu_keys[i]);
item.addProperty("label", getStringWithLocale(KcaUtils.getId(
KcaUtils.format("viewmenu_%s", fleetview_menu_keys[i]), R.string.class)));
data.add(item);
order_data.add(i);
} | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_FV_MENU_ORDER = "fleetview_menu_order";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewService.java
// public static final String[] fleetview_menu_keys = {"quest", "excheck", "develop", "construction", "docking", "maphp", "fchk", "labinfo", "akashi"};
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaFleetViewMenuOrderActivity.java
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.woxthebox.draglistview.DragListView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_FV_MENU_ORDER;
import static com.antest1.kcanotify.KcaFleetViewService.fleetview_menu_keys;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_mbtn_order);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getStringWithLocale(R.string.setting_menu_kand_title_fleetview_button_order));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayList<JsonObject> data = new ArrayList<>();
String pref_value = getStringPreferences(getApplicationContext(), PREF_FV_MENU_ORDER);
if (pref_value.length() > 0) {
order_data = new JsonParser().parse(pref_value).getAsJsonArray();
for (int i = 0; i < order_data.size(); i++) {
JsonObject item = new JsonObject();
int key = order_data.get(i).getAsInt();
item.addProperty("key", key);
item.addProperty("value", fleetview_menu_keys[key]);
item.addProperty("label", getStringWithLocale(KcaUtils.getId(
KcaUtils.format("viewmenu_%s", fleetview_menu_keys[key]), R.string.class)));
data.add(item);
}
} else {
for (int i = 0; i < fleetview_menu_keys.length; i++) {
JsonObject item = new JsonObject();
item.addProperty("key", i);
item.addProperty("value", fleetview_menu_keys[i]);
item.addProperty("label", getStringWithLocale(KcaUtils.getId(
KcaUtils.format("viewmenu_%s", fleetview_menu_keys[i]), R.string.class)));
data.add(item);
order_data.add(i);
} | setPreferences(getApplicationContext(), PREF_FV_MENU_ORDER, order_data.toString()); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | ImageView ed_icon;
TextView ed_name, ed_count, ed_ship, ed_time;
public static int type;
public static boolean active = false;
public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this); | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
ImageView ed_icon;
TextView ed_name, ed_count, ed_ship, ed_time;
public static int type;
public static boolean active = false;
public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this); | dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; |
public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA); | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA); | String s = dbHelper.getValue(DB_KEY_BATTLEINFO); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO); | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
public static boolean isActive() {
return active;
}
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO); | broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
}; | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
}; | loadTranslationData(getApplicationContext()); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
};
loadTranslationData(getApplicationContext()); | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
active = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
broadcaster = LocalBroadcastManager.getInstance(this);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
};
loadTranslationData(getApplicationContext()); | LocalBroadcastManager.getInstance(this).registerReceiver((data_receiver), new IntentFilter(KCA_MSG_BATTLE_INFO)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
};
loadTranslationData(getApplicationContext());
LocalBroadcastManager.getInstance(this).registerReceiver((data_receiver), new IntentFilter(KCA_MSG_BATTLE_INFO));
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
notificationManager = NotificationManagerCompat.from(getApplicationContext());
mView = mInflater.inflate(R.layout.view_equip_dev, null);
mView.setOnTouchListener(mViewTouchListener);
((TextView) mView.findViewById(R.id.view_ed_title)).setText(getStringWithLocale(R.string.viewmenu_develop_title));
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWidth = mView.getMeasuredWidth();
popupHeight = mView.getMeasuredHeight();
ed_ship = (TextView) mView.findViewById(R.id.ed_ship);
ed_time = (TextView) mView.findViewById(R.id.ed_time);
// Button (Fairy) Settings
mParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT, | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
data_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//String s = intent.getStringExtra(KCA_MSG_DATA);
String s = dbHelper.getValue(DB_KEY_BATTLEINFO);
broadcaster.sendBroadcast(new Intent(KCA_MSG_BATTLE_VIEW_REFRESH));
Log.e("KCA", "KCA_MSG_BATTLE_INFO Received: \n".concat(s));
}
};
loadTranslationData(getApplicationContext());
LocalBroadcastManager.getInstance(this).registerReceiver((data_receiver), new IntentFilter(KCA_MSG_BATTLE_INFO));
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
notificationManager = NotificationManagerCompat.from(getApplicationContext());
mView = mInflater.inflate(R.layout.view_equip_dev, null);
mView.setOnTouchListener(mViewTouchListener);
((TextView) mView.findViewById(R.id.view_ed_title)).setText(getStringWithLocale(R.string.viewmenu_develop_title));
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWidth = mView.getMeasuredWidth();
popupHeight = mView.getMeasuredHeight();
ed_ship = (TextView) mView.findViewById(R.id.ed_ship);
ed_time = (TextView) mView.findViewById(R.id.ed_time);
// Button (Fairy) Settings
mParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT, | getWindowLayoutType(), |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
mParams.gravity = Gravity.TOP | Gravity.START;
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
screenHeight = size.y;
Log.e("KCA", "w/h: " + String.valueOf(screenWidth) + " " + String.valueOf(screenHeight));
mParams.x = (screenWidth - popupWidth) / 2;
mParams.y = (screenHeight - popupHeight) / 2;
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mManager.addView(mView, mParams);
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e("KCA-CPS", "onStartCommand");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else if (intent != null) {
JsonObject data = null;
if(intent.getAction() != null && intent.getAction().equals(DEV_DATA_ACTION)) {
data = new JsonParser().parse(intent.getExtras().getString("data")).getAsJsonObject();
} else { | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
mParams.gravity = Gravity.TOP | Gravity.START;
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
screenHeight = size.y;
Log.e("KCA", "w/h: " + String.valueOf(screenWidth) + " " + String.valueOf(screenHeight));
mParams.x = (screenWidth - popupWidth) / 2;
mParams.y = (screenHeight - popupHeight) / 2;
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mManager.addView(mView, mParams);
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e("KCA-CPS", "onStartCommand");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else if (intent != null) {
JsonObject data = null;
if(intent.getAction() != null && intent.getAction().equals(DEV_DATA_ACTION)) {
data = new JsonParser().parse(intent.getExtras().getString("data")).getAsJsonObject();
} else { | data = dbHelper.getJsonObjectValue(DB_KEY_LATESTDEV); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
| import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType; | JsonObject data = null;
if(intent.getAction() != null && intent.getAction().equals(DEV_DATA_ACTION)) {
data = new JsonParser().parse(intent.getExtras().getString("data")).getAsJsonObject();
} else {
data = dbHelper.getJsonObjectValue(DB_KEY_LATESTDEV);
}
if (data != null) {
ed_time.setText(data.get("time").getAsString());
ed_ship.setText(KcaApiData.getShipTranslation(data.get("flagship").getAsString(), false));
if (data.has("items")) {
JsonArray arr = data.getAsJsonArray("items");
for (int i = 0; i < arr.size(); i++) {
setItemLayout(i+1, arr.get(i).getAsJsonObject());
}
} else {
setSingleItemLayout(data.getAsJsonObject());
}
}
}
return super.onStartCommand(intent, flags, startId);
}
private void setSingleItemLayout(JsonObject data) {
setItemLayout(1, data);
mView.findViewById(R.id.ed_item2).setVisibility(View.GONE);
mView.findViewById(R.id.ed_item3).setVisibility(View.GONE);
}
private void setItemLayout(int index, JsonObject data) {
int typeres = 0; | // Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
// loadTranslationData(context, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_BATTLEINFO = "key_battleinfo";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_LATESTDEV = "key_latestdev";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_INFO = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_INFO";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_MSG_BATTLE_VIEW_REFRESH = "com.antest1.kcanotify.KcaService.KCA_MSG_BATTLE_VIEW_REFRESH";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
// int windowLayoutType = -1;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
// }
// return windowLayoutType;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaDevelopPopupService.java
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_BATTLEINFO;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LATESTDEV;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_INFO;
import static com.antest1.kcanotify.KcaConstants.KCA_MSG_BATTLE_VIEW_REFRESH;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
JsonObject data = null;
if(intent.getAction() != null && intent.getAction().equals(DEV_DATA_ACTION)) {
data = new JsonParser().parse(intent.getExtras().getString("data")).getAsJsonObject();
} else {
data = dbHelper.getJsonObjectValue(DB_KEY_LATESTDEV);
}
if (data != null) {
ed_time.setText(data.get("time").getAsString());
ed_ship.setText(KcaApiData.getShipTranslation(data.get("flagship").getAsString(), false));
if (data.has("items")) {
JsonArray arr = data.getAsJsonArray("items");
for (int i = 0; i < arr.size(); i++) {
setItemLayout(i+1, arr.get(i).getAsJsonObject());
}
} else {
setSingleItemLayout(data.getAsJsonObject());
}
}
}
return super.onStartCommand(intent, flags, startId);
}
private void setSingleItemLayout(JsonObject data) {
setItemLayout(1, data);
mView.findViewById(R.id.ed_item2).setVisibility(View.GONE);
mView.findViewById(R.id.ed_item3).setVisibility(View.GONE);
}
private void setItemLayout(int index, JsonObject data) {
int typeres = 0; | ImageView ed_icon = mView.findViewById(getId("ed_icon" + index, R.id.class)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
| import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr; | package com.antest1.kcanotify;
public class ErrorlogActivity extends AppCompatActivity{
private final int SHOW_LIMIT = 50;
private final String LOG_PATH = "/logs";
Vibrator vibrator;
KcaDBHelper dbHelper;
Toolbar toolbar;
Button loadbtn, clearbtn, exportbtn;
TextView text, exportPathView;
String exportPath;
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
// Path: app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr;
package com.antest1.kcanotify;
public class ErrorlogActivity extends AppCompatActivity{
private final int SHOW_LIMIT = 50;
private final String LOG_PATH = "/logs";
Vibrator vibrator;
KcaDBHelper dbHelper;
Toolbar toolbar;
Button loadbtn, clearbtn, exportbtn;
TextView text, exportPathView;
String exportPath;
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); | dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
| import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr; | Toolbar toolbar;
Button loadbtn, clearbtn, exportbtn;
TextView text, exportPathView;
String exportPath;
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
text = findViewById(R.id.errorlogview);
text.setText("");
text.setLongClickable(true);
text.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText())); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
// Path: app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr;
Toolbar toolbar;
Button loadbtn, clearbtn, exportbtn;
TextView text, exportPathView;
String exportPath;
public String getStringWithLocale(int id) {
return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
text = findViewById(R.id.errorlogview);
text.setText("");
text.setLongClickable(true);
text.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText())); | doVibrate(vibrator, 100); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
| import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr; | setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
text = findViewById(R.id.errorlogview);
text.setText("");
text.setLongClickable(true);
text.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText()));
doVibrate(vibrator, 100);
Toast.makeText(getApplicationContext(), getStringWithLocale(R.string.copied_to_clipboard), Toast.LENGTH_LONG).show();
return false;
}
});
loadbtn = findViewById(R.id.error_load);
loadbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<String> loglist = dbHelper.getErrorLog(SHOW_LIMIT, false);
if (loglist.size() > 0) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void doVibrate(Vibrator v, int time) {
// if (Build.VERSION.SDK_INT >= 26) {
// v.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
// } else {
// v.vibrate(time);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String joinStr(List<String> list, String delim) {
// String resultStr = "";
// if (list.size() > 0) {
// int i;
// for (i = 0; i < list.size() - 1; i++) {
// resultStr = resultStr.concat(list.get(i));
// resultStr = resultStr.concat(delim);
// }
// resultStr = resultStr.concat(list.get(i));
// }
// return resultStr;
// }
// Path: app/src/main/java/com/antest1/kcanotify/ErrorlogActivity.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Vibrator;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaUtils.doVibrate;
import static com.antest1.kcanotify.KcaUtils.joinStr;
setContentView(R.layout.activity_errorlog);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.action_errorlog);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
text = findViewById(R.id.errorlogview);
text.setText("");
text.setLongClickable(true);
text.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clip.setPrimaryClip(ClipData.newPlainText("text", ((TextView) v).getText()));
doVibrate(vibrator, 100);
Toast.makeText(getApplicationContext(), getStringWithLocale(R.string.copied_to_clipboard), Toast.LENGTH_LONG).show();
return false;
}
});
loadbtn = findViewById(R.id.error_load);
loadbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<String> loglist = dbHelper.getErrorLog(SHOW_LIMIT, false);
if (loglist.size() > 0) { | text.setText(joinStr(loglist, "\n")); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | setPreferences(getApplicationContext(), PREF_NOTICE_CHK_FLAG, NOTICE_CHK_CODE); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | setPreferences(getApplicationContext(), PREF_NOTICE_CHK_FLAG, NOTICE_CHK_CODE); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String NOTICE_CHK_CODE = "chk002";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_NOTICE_CHK_FLAG = "kr_notice_chk";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaNoticeActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static com.antest1.kcanotify.KcaConstants.NOTICE_CHK_CODE;
import static com.antest1.kcanotify.KcaConstants.PREF_NOTICE_CHK_FLAG;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaNoticeActivity extends AppCompatActivity {
Toolbar toolbar;
public static final String TAG = "KCA";
public KcaNoticeActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init_notice);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CheckBox noshow = findViewById(R.id.notice_noshow);
noshow.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { | setPreferences(getApplicationContext(), PREF_NOTICE_CHK_FLAG, NOTICE_CHK_CODE); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; | ImageView view_delete;
View view_holder;
ScrollView sv;
KcaDBHelper dbHelper;
KcaQuestTracker questTracker;
int scroll_h_total = 0;
int scroll_h_layout = 0;
int scroll_touch_count = 0;
ScheduledExecutorService autoScrollScheduler;
public KcaInspectorDetailActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
final String type_key = bundle.getString("key", null);
if (type_key == null) {
finish();
} else {
setContentView(R.layout.activity_inspector_detail);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(type_key);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
| // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
ImageView view_delete;
View view_holder;
ScrollView sv;
KcaDBHelper dbHelper;
KcaQuestTracker questTracker;
int scroll_h_total = 0;
int scroll_h_layout = 0;
int scroll_touch_count = 0;
ScheduledExecutorService autoScrollScheduler;
public KcaInspectorDetailActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
final String type_key = bundle.getString("key", null);
if (type_key == null) {
finish();
} else {
setContentView(R.layout.activity_inspector_detail);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(type_key);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
| dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; | View view_holder;
ScrollView sv;
KcaDBHelper dbHelper;
KcaQuestTracker questTracker;
int scroll_h_total = 0;
int scroll_h_layout = 0;
int scroll_touch_count = 0;
ScheduledExecutorService autoScrollScheduler;
public KcaInspectorDetailActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
final String type_key = bundle.getString("key", null);
if (type_key == null) {
finish();
} else {
setContentView(R.layout.activity_inspector_detail);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(type_key);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
View view_holder;
ScrollView sv;
KcaDBHelper dbHelper;
KcaQuestTracker questTracker;
int scroll_h_total = 0;
int scroll_h_layout = 0;
int scroll_touch_count = 0;
ScheduledExecutorService autoScrollScheduler;
public KcaInspectorDetailActivity() {
LocaleUtils.updateConfig(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
final String type_key = bundle.getString("key", null);
if (type_key == null) {
finish();
} else {
setContentView(R.layout.activity_inspector_detail);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(type_key);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION); | questTracker = new KcaQuestTracker(getApplicationContext(), null, KCANOTIFY_QTDB_VERSION); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; |
String[] type_key_list = type_key.split(" ");
key = type_key_list[1];
view_key.setText(key);
view_format.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (value_text == null || value_text.length() > 0) {
is_formatted = !is_formatted;
setText(type_key);
}
}
});
view_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (value_text != null) {
if (type_key.startsWith(DB_PREFIX)) {
dbHelper.deleteValue(key);
} else if (type_key.startsWith(QT_PREFIX)) {
questTracker.clearQuestTrack();
} else if (type_key.startsWith(DQ_PREFIX)) {
dbHelper.clearQuest();
} else if (type_key.startsWith(PREF_PREFIX)) {
SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
String value = SettingActivity.getDefaultValue(key);
if (value.startsWith("R.string.")) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
String[] type_key_list = type_key.split(" ");
key = type_key_list[1];
view_key.setText(key);
view_format.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (value_text == null || value_text.length() > 0) {
is_formatted = !is_formatted;
setText(type_key);
}
}
});
view_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (value_text != null) {
if (type_key.startsWith(DB_PREFIX)) {
dbHelper.deleteValue(key);
} else if (type_key.startsWith(QT_PREFIX)) {
questTracker.clearQuestTrack();
} else if (type_key.startsWith(DQ_PREFIX)) {
dbHelper.clearQuest();
} else if (type_key.startsWith(PREF_PREFIX)) {
SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
String value = SettingActivity.getDefaultValue(key);
if (value.startsWith("R.string.")) { | editor.putString(key, getString(getId(value.replace("R.string.", ""), R.string.class))); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; |
sv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
sv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) { | if (PREFS_BOOLEAN_LIST.contains(key)) { |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; | sv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) {
if (PREFS_BOOLEAN_LIST.contains(key)) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
sv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) {
if (PREFS_BOOLEAN_LIST.contains(key)) { | value_text = String.valueOf(getBooleanPreferences(getApplicationContext(), key)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
| import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences; | public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) {
if (PREFS_BOOLEAN_LIST.contains(key)) {
value_text = String.valueOf(getBooleanPreferences(getApplicationContext(), key));
} else { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final List<String> PREFS_BOOLEAN_LIST = Arrays.asList(PREF_BOOLEAN_ARRAY);
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
// try {
// Field idField = c.getDeclaredField(resourceName);
// return idField.getInt(idField);
// } catch (Exception e) {
// throw new RuntimeException("No resource ID found for: "
// + resourceName + " / " + c, e);
// }
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaInspectorDetailActivity.java
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREFS_BOOLEAN_LIST;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
int y = (int) motionEvent.getY();
int direction = 1;
if (y < scroll_h_layout / 2) direction = -1;
scroll_touch_count = 0;
autoScrollScheduler = Executors.newSingleThreadScheduledExecutor();
autoScrollScheduler.scheduleAtFixedRate(auto_scroll(direction), 800, 200, TimeUnit.MILLISECONDS);
break;
case MotionEvent.ACTION_UP:
autoScrollScheduler.shutdown();
break;
}
return false;
}
});
}
});
}
}
public void setText(String type_key) {
if (type_key.startsWith(DB_PREFIX)) {
value_text = dbHelper.getValue(key);
if (value_text == null) value_text = "<null>";
} else if (type_key.startsWith(PREF_PREFIX)) {
if (PREFS_BOOLEAN_LIST.contains(key)) {
value_text = String.valueOf(getBooleanPreferences(getApplicationContext(), key));
} else { | value_text = getStringPreferences(getApplicationContext(), key); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
| import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG; | }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
// Path: app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java
import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) { | case STATE_HEAVYDMG: |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
| import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG; | public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) {
case STATE_HEAVYDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorHeavyDmgState));
break; | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
// Path: app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java
import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG;
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) {
case STATE_HEAVYDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorHeavyDmgState));
break; | case STATE_MODERATEDMG: |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
| import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG; |
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) {
case STATE_HEAVYDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorHeavyDmgState));
break;
case STATE_MODERATEDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorModerateDmgState));
break; | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_HEAVYDMG = 3;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_LIGHTDMG = 1;
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int STATE_MODERATEDMG = 2;
// Path: app/src/main/java/com/antest1/kcanotify/KcaDockingPopupListAdapter.java
import android.content.Context;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaConstants.STATE_HEAVYDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_LIGHTDMG;
import static com.antest1.kcanotify.KcaConstants.STATE_MODERATEDMG;
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_dock, parent, false);
ViewHolder holder = new ViewHolder();
holder.shipname = (TextView) v.findViewById(R.id.dock_ship);
holder.repairtime = (TextView) v.findViewById(R.id.dock_time);
v.setTag(holder);
}
final JsonObject item = itemList.get(position).getAsJsonObject();
ViewHolder holder = (ViewHolder) v.getTag();
holder.shipname.setText(item.get("name").getAsString());
holder.repairtime.setText(item.get("time").getAsString());
int state = item.get("state").getAsInt();
boolean in_dock = item.get("dock").getAsBoolean();
if (in_dock) {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.colorNormalState));
} else {
holder.shipname.setTextColor(ContextCompat.getColor(context, R.color.white));
}
switch (state) {
case STATE_HEAVYDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorHeavyDmgState));
break;
case STATE_MODERATEDMG:
holder.repairtime.setBackgroundColor(ContextCompat.getColor(context, R.color.colorModerateDmgState));
break; | case STATE_LIGHTDMG: |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaAkashiListViewAdpater extends BaseAdapter {
private boolean isSafeChecked = false;
private static Handler sHandler;
private ArrayList<KcaAkashiListViewItem> listViewItemList = new ArrayList<KcaAkashiListViewItem>();
public void setHandler(Handler h) {
sHandler = h;
}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
// format: |1|23|55|260| | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaAkashiListViewAdpater extends BaseAdapter {
private boolean isSafeChecked = false;
private static Handler sHandler;
private ArrayList<KcaAkashiListViewItem> listViewItemList = new ArrayList<KcaAkashiListViewItem>();
public void setHandler(Handler h) {
sHandler = h;
}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
// format: |1|23|55|260| | String starlistData = getStringPreferences(context, PREF_AKASHI_STARLIST); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | package com.antest1.kcanotify;
public class KcaAkashiListViewAdpater extends BaseAdapter {
private boolean isSafeChecked = false;
private static Handler sHandler;
private ArrayList<KcaAkashiListViewItem> listViewItemList = new ArrayList<KcaAkashiListViewItem>();
public void setHandler(Handler h) {
sHandler = h;
}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
// format: |1|23|55|260| | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
package com.antest1.kcanotify;
public class KcaAkashiListViewAdpater extends BaseAdapter {
private boolean isSafeChecked = false;
private static Handler sHandler;
private ArrayList<KcaAkashiListViewItem> listViewItemList = new ArrayList<KcaAkashiListViewItem>();
public void setHandler(Handler h) {
sHandler = h;
}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
View v = convertView;
// format: |1|23|55|260| | String starlistData = getStringPreferences(context, PREF_AKASHI_STARLIST); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences; | ViewHolder holder = (ViewHolder) v.getTag();
holder.iconView.setImageResource(item.getEquipIconMipmap());
holder.nameView.setText(item.getEquipName());
holder.materialView.setText(item.getEquipMaterials());
holder.screwView.setText(item.getEquipScrews());
holder.supportView.setText(item.getEquipSupport());
holder.materialView.setTextColor(ContextCompat.getColor(context, getMaterialTextColor(isSafeChecked)));
holder.screwView.setTextColor(ContextCompat.getColor(context, getScrewTextColor(isSafeChecked)));
if (checkStarred(starlistData, itemId)) {
holder.starView.setText(context.getString(R.string.aa_btn_star1));
} else {
holder.starView.setText(context.getString(R.string.aa_btn_star0));
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, AkashiDetailActivity.class);
intent.putExtra("item_id", itemId);
intent.putExtra("item_info", itemImprovementData);
context.startActivity(intent);
}
});
holder.starView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String starred = getStringPreferences(context, PREF_AKASHI_STARLIST);
TextView tv = (TextView) v;
if (tv.getText().equals(context.getString(R.string.aa_btn_star0))) { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_AKASHI_STARLIST = "akashi_starlist";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// try {
// return String.valueOf(pref.getInt(key, 0));
// } catch (Exception e) {
// // Nothing to do
// }
// return pref.getString(key, "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor = pref.edit();
// if (value instanceof String) {
// editor.putString(key, (String) value);
// } else if (value instanceof Boolean) {
// editor.putBoolean(key, (Boolean) value);
// } else if (value instanceof Integer) {
// editor.putString(key, String.valueOf(value));
// } else {
// editor.putString(key, value.toString());
// }
// editor.commit();
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaAkashiListViewAdpater.java
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
ViewHolder holder = (ViewHolder) v.getTag();
holder.iconView.setImageResource(item.getEquipIconMipmap());
holder.nameView.setText(item.getEquipName());
holder.materialView.setText(item.getEquipMaterials());
holder.screwView.setText(item.getEquipScrews());
holder.supportView.setText(item.getEquipSupport());
holder.materialView.setTextColor(ContextCompat.getColor(context, getMaterialTextColor(isSafeChecked)));
holder.screwView.setTextColor(ContextCompat.getColor(context, getScrewTextColor(isSafeChecked)));
if (checkStarred(starlistData, itemId)) {
holder.starView.setText(context.getString(R.string.aa_btn_star1));
} else {
holder.starView.setText(context.getString(R.string.aa_btn_star0));
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, AkashiDetailActivity.class);
intent.putExtra("item_id", itemId);
intent.putExtra("item_info", itemImprovementData);
context.startActivity(intent);
}
});
holder.starView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String starred = getStringPreferences(context, PREF_AKASHI_STARLIST);
TextView tv = (TextView) v;
if (tv.getText().equals(context.getString(R.string.aa_btn_star0))) { | setPreferences(context, PREF_AKASHI_STARLIST, |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaVpnData.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
| import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata; | boolean chunkflag = (portToLength.get(tport) == -1);
boolean gzipflag = portToGzipped.get(tport);
Byte[] empty = {};
Byte[] responsePrevData = portToResponseData.get(tport, empty);
portToResponseData.put(tport, ArrayUtils.toObject(Bytes.concat(ArrayUtils.toPrimitive(responsePrevData), data)));
if (portToLength.get(tport) == -1 && isChunkEnd(ArrayUtils.toPrimitive(portToResponseData.get(tport)))) {
isreadyflag = true;
} else if (portToResponseData.get(tport).length == portToResponseHeaderLength.get(tport) + 4 + portToLength.get(tport)) {
isreadyflag = true;
}
if (isreadyflag) {
String requestStr = portToRequestData.get(tport).toString();
String[] requestHeadBody = requestStr.split("\r\n\r\n", 2);
if (requestHeadBody.length > 1) {
byte[] requestBody = new byte[]{};
if (requestHeadBody[1].length() > 0) {
requestBody = requestHeadBody[1].getBytes();
}
byte[] responseData = ArrayUtils.toPrimitive(portToResponseData.get(tport));
byte[] responseBody = Arrays.copyOfRange(responseData, portToResponseHeaderLength.get(tport) + 4, responseData.length);
//Log.e("KCA", String.valueOf(responseData.length));
//Log.e("KCA", String.valueOf(portToResponseHeaderPart.get(tport).length()));
//Log.e("KCA", "====================================");
if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport)); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
boolean chunkflag = (portToLength.get(tport) == -1);
boolean gzipflag = portToGzipped.get(tport);
Byte[] empty = {};
Byte[] responsePrevData = portToResponseData.get(tport, empty);
portToResponseData.put(tport, ArrayUtils.toObject(Bytes.concat(ArrayUtils.toPrimitive(responsePrevData), data)));
if (portToLength.get(tport) == -1 && isChunkEnd(ArrayUtils.toPrimitive(portToResponseData.get(tport)))) {
isreadyflag = true;
} else if (portToResponseData.get(tport).length == portToResponseHeaderLength.get(tport) + 4 + portToLength.get(tport)) {
isreadyflag = true;
}
if (isreadyflag) {
String requestStr = portToRequestData.get(tport).toString();
String[] requestHeadBody = requestStr.split("\r\n\r\n", 2);
if (requestHeadBody.length > 1) {
byte[] requestBody = new byte[]{};
if (requestHeadBody[1].length() > 0) {
requestBody = requestHeadBody[1].getBytes();
}
byte[] responseData = ArrayUtils.toPrimitive(portToResponseData.get(tport));
byte[] responseBody = Arrays.copyOfRange(responseData, portToResponseHeaderLength.get(tport) + 4, responseData.length);
//Log.e("KCA", String.valueOf(responseData.length));
//Log.e("KCA", String.valueOf(portToResponseHeaderPart.get(tport).length()));
//Log.e("KCA", "====================================");
if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport)); | responseBody = gzipdecompress(responseBody); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaVpnData.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
| import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata; | //Log.e("KCA", String.valueOf(responseData.length));
//Log.e("KCA", String.valueOf(portToResponseHeaderPart.get(tport).length()));
//Log.e("KCA", "====================================");
if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace(); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
//Log.e("KCA", String.valueOf(responseData.length));
//Log.e("KCA", String.valueOf(portToResponseHeaderPart.get(tport).length()));
//Log.e("KCA", "====================================");
if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace(); | String error_uri = KCA_API_VPN_DATA_ERROR; |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaVpnData.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
| import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata; | if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace();
String error_uri = KCA_API_VPN_DATA_ERROR;
String empty_request = "";
JsonObject error_data = new JsonObject(); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
if (chunkflag && responseBody.length > 0) {
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, 0, 15)));
//Log.e("KCA", byteArrayToHex(Arrays.copyOfRange(responseBody, responseBody.length - 15, responseBody.length)));
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace();
String error_uri = KCA_API_VPN_DATA_ERROR;
String empty_request = "";
JsonObject error_data = new JsonObject(); | error_data.addProperty("error", getStringFromException(e)); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaVpnData.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
| import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata; | responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace();
String error_uri = KCA_API_VPN_DATA_ERROR;
String empty_request = "";
JsonObject error_data = new JsonObject();
error_data.addProperty("error", getStringFromException(e));
error_data.addProperty("uri", requestUri);
error_data.addProperty("request", requestData.toString()); | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
responseBody = unchunkAllData(responseBody, gzipflag);
} else if (gzipflag && responseBody.length > 0) {
//Log.e("KCA", "Ungzip " + String.valueOf(tport));
responseBody = gzipdecompress(responseBody);
}
//Log.e("KCA", String.valueOf(responseData.length));
String requestUri = portToUri.get(tport);
if (checkKcApi(requestUri)) {
KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
executorService.execute(k);
}
portToUri.delete(tport);
portToRequestData.delete(tport);
portToResponseData.delete(tport);
portToResponseHeaderLength.delete(tport);
portToLength.delete(tport);
portToGzipped.delete(tport);
isreadyflag = false;
}
}
}
} catch (IOException e) {
e.printStackTrace();
String error_uri = KCA_API_VPN_DATA_ERROR;
String empty_request = "";
JsonObject error_data = new JsonObject();
error_data.addProperty("error", getStringFromException(e));
error_data.addProperty("uri", requestUri);
error_data.addProperty("request", requestData.toString()); | String responseDataStr = byteArrayToHex(responseData); |
antest1/kcanotify | app/src/main/java/com/antest1/kcanotify/KcaVpnData.java | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
| import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata; | String responseDataStr = byteArrayToHex(responseData);
if (responseDataStr.length() > 240) {
error_data.addProperty("response", responseDataStr.substring(0, 240));
} else {
error_data.addProperty("response", responseDataStr);
}
KcaHandler k = new KcaHandler(handler, error_uri, empty_request.getBytes(), error_data.toString().getBytes());
executorService.execute(k);
Log.e("KCA", getStringFromException(e));
}
}
private static boolean checkKcApi(String uri) {
boolean isKcaVer = uri.contains("/kca/version");
boolean isKcsApi = uri.contains("/kcsapi/api_");
//Log.e("KCA", uri + " " + String.valueOf(isKcaVer || isKcsApi));
return (isKcaVer || isKcsApi);
}
private static boolean checkKcRes(String uri) {
boolean isKcsSwf = uri.contains("/kc") && uri.contains(".swf");
boolean isKcaRes = uri.contains("/kc") && uri.contains("/resources");
boolean isKcsSound = uri.contains("/kcs/sound");
boolean isKcsWorld = uri.contains("/api_world/get_id/");
boolean isKcs2Res = uri.contains("/kcs2/img/");
//Log.e("KCA", uri + " " + String.valueOf(isKcaVer || isKcsApi));
return (isKcsSwf || isKcaRes || isKcsSound || isKcsWorld | isKcs2Res);
}
private static byte[] unchunkAllData(byte[] data, boolean gzipped) throws IOException { | // Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
// StringBuilder sb = new StringBuilder();
// for (final byte b : a)
// sb.append(KcaUtils.format("%02x ", b & 0xff));
// return sb.toString();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
// SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
// return pref.getBoolean(key, false);
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
// StringWriter errors = new StringWriter();
// ex.printStackTrace(new PrintWriter(errors));
// return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// try {
// ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// return out.toByteArray();
// }
//
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
// byte[] unchunkedData = null;
// byte[] buffer = new byte[1024];
// ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
// ChunkedInputStream cis = new ChunkedInputStream(bis);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// int read = -1;
// while ((read = cis.read(buffer)) != -1) {
// bos.write(buffer, 0, read);
// }
// unchunkedData = bos.toByteArray();
// bos.close();
//
// return unchunkedData;
// }
// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
String responseDataStr = byteArrayToHex(responseData);
if (responseDataStr.length() > 240) {
error_data.addProperty("response", responseDataStr.substring(0, 240));
} else {
error_data.addProperty("response", responseDataStr);
}
KcaHandler k = new KcaHandler(handler, error_uri, empty_request.getBytes(), error_data.toString().getBytes());
executorService.execute(k);
Log.e("KCA", getStringFromException(e));
}
}
private static boolean checkKcApi(String uri) {
boolean isKcaVer = uri.contains("/kca/version");
boolean isKcsApi = uri.contains("/kcsapi/api_");
//Log.e("KCA", uri + " " + String.valueOf(isKcaVer || isKcsApi));
return (isKcaVer || isKcsApi);
}
private static boolean checkKcRes(String uri) {
boolean isKcsSwf = uri.contains("/kc") && uri.contains(".swf");
boolean isKcaRes = uri.contains("/kc") && uri.contains("/resources");
boolean isKcsSound = uri.contains("/kcs/sound");
boolean isKcsWorld = uri.contains("/api_world/get_id/");
boolean isKcs2Res = uri.contains("/kcs2/img/");
//Log.e("KCA", uri + " " + String.valueOf(isKcaVer || isKcsApi));
return (isKcsSwf || isKcaRes || isKcsSound || isKcsWorld | isKcs2Res);
}
private static byte[] unchunkAllData(byte[] data, boolean gzipped) throws IOException { | byte[] rawdata = unchunkdata(data); |
liuyangming/ByteTCC-sample | springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/SimplifiedController.java | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
| import org.bytesoft.compensable.Compensable;
import org.bytesoft.compensable.CompensableCancel;
import org.bytesoft.compensable.CompensableConfirm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService; | package com.bytesvc.consumer.controller;
@Compensable(interfaceClass = ITransferService.class, simplified = true)
@RestController
public class SimplifiedController implements ITransferService {
@Autowired | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/SimplifiedController.java
import org.bytesoft.compensable.Compensable;
import org.bytesoft.compensable.CompensableCancel;
import org.bytesoft.compensable.CompensableConfirm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService;
package com.bytesvc.consumer.controller;
@Compensable(interfaceClass = ITransferService.class, simplified = true)
@RestController
public class SimplifiedController implements ITransferService {
@Autowired | private TransferDao transferDao; |
liuyangming/ByteTCC-sample | springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/SimplifiedController.java | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
| import org.bytesoft.compensable.Compensable;
import org.bytesoft.compensable.CompensableCancel;
import org.bytesoft.compensable.CompensableConfirm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService; | package com.bytesvc.consumer.controller;
@Compensable(interfaceClass = ITransferService.class, simplified = true)
@RestController
public class SimplifiedController implements ITransferService {
@Autowired
private TransferDao transferDao;
@Autowired | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/SimplifiedController.java
import org.bytesoft.compensable.Compensable;
import org.bytesoft.compensable.CompensableCancel;
import org.bytesoft.compensable.CompensableConfirm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService;
package com.bytesvc.consumer.controller;
@Compensable(interfaceClass = ITransferService.class, simplified = true)
@RestController
public class SimplifiedController implements ITransferService {
@Autowired
private TransferDao transferDao;
@Autowired | private IAccountService acctService; |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/GenericTransferServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = ITransferService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Service("genericTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class GenericTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate; | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/GenericTransferServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = ITransferService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Service("genericTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class GenericTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate; | @com.alibaba.dubbo.config.annotation.Reference(interfaceClass = IAccountService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/GenericTransferServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = ITransferService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Service("genericTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class GenericTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
@com.alibaba.dubbo.config.annotation.Reference(interfaceClass = IAccountService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
private IAccountService remoteAccountService;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/GenericTransferServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = ITransferService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Service("genericTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class GenericTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
@com.alibaba.dubbo.config.annotation.Reference(interfaceClass = IAccountService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
private IAccountService remoteAccountService;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/cancel/TransferServiceCancel.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.cancel;
@Service("transferServiceCancel")
public class TransferServiceCancel implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/cancel/TransferServiceCancel.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.cancel;
@Service("transferServiceCancel")
public class TransferServiceCancel implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/TransferController.java | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService; | package com.bytesvc.consumer.controller;
/**
* 本类中不涉及Confirm逻辑, Confirm逻辑样例在SimplifiedController类中.<br />
* 如需为本类添加Confirm逻辑, 可参考Cancel逻辑的做法, 设置confirmableKey即可.
*/
@Compensable(interfaceClass = ITransferService.class, cancellableKey = "transferServiceCancel")
@RestController
public class TransferController implements ITransferService {
@Autowired | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/TransferController.java
import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService;
package com.bytesvc.consumer.controller;
/**
* 本类中不涉及Confirm逻辑, Confirm逻辑样例在SimplifiedController类中.<br />
* 如需为本类添加Confirm逻辑, 可参考Cancel逻辑的做法, 设置confirmableKey即可.
*/
@Compensable(interfaceClass = ITransferService.class, cancellableKey = "transferServiceCancel")
@RestController
public class TransferController implements ITransferService {
@Autowired | private TransferDao transferDao; |
liuyangming/ByteTCC-sample | springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/TransferController.java | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService; | package com.bytesvc.consumer.controller;
/**
* 本类中不涉及Confirm逻辑, Confirm逻辑样例在SimplifiedController类中.<br />
* 如需为本类添加Confirm逻辑, 可参考Cancel逻辑的做法, 设置confirmableKey即可.
*/
@Compensable(interfaceClass = ITransferService.class, cancellableKey = "transferServiceCancel")
@RestController
public class TransferController implements ITransferService {
@Autowired
private TransferDao transferDao;
@Autowired | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/feign/service/IAccountService.java
// @FeignClient(value = "SPRINGCLOUD-SAMPLE-PROVIDER")
// public interface IAccountService {
//
// @RequestMapping(method = RequestMethod.POST, value = "/increase")
// public void increaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// @RequestMapping(method = RequestMethod.POST, value = "/decrease")
// public void decreaseAmount(@RequestParam("acctId") String accountId, @RequestParam("amount") double amount);
//
// }
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/controller/TransferController.java
import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
import com.bytesvc.feign.service.IAccountService;
package com.bytesvc.consumer.controller;
/**
* 本类中不涉及Confirm逻辑, Confirm逻辑样例在SimplifiedController类中.<br />
* 如需为本类添加Confirm逻辑, 可参考Cancel逻辑的做法, 设置confirmableKey即可.
*/
@Compensable(interfaceClass = ITransferService.class, cancellableKey = "transferServiceCancel")
@RestController
public class TransferController implements ITransferService {
@Autowired
private TransferDao transferDao;
@Autowired | private IAccountService acctService; |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/main/MultiDsConsumerMain.java | // Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.springframework.beans.BeansException;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import com.bytesvc.service.ITransferService; | package com.bytesvc.main;
/**
* 多数据源场景
*/
@EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = { "com.bytesvc.service", "com.bytesvc.config" })
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class }) // 使用文件存储时, 不需要配置mongodb
public class MultiDsConsumerMain implements ApplicationContextAware {
static ApplicationContext context = null;
public static void main(String... args) throws Throwable {
SpringApplication application = new SpringApplication(MultiDsConsumerMain.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
try { | // Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/main/MultiDsConsumerMain.java
import org.springframework.beans.BeansException;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import com.bytesvc.service.ITransferService;
package com.bytesvc.main;
/**
* 多数据源场景
*/
@EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = { "com.bytesvc.service", "com.bytesvc.config" })
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class }) // 使用文件存储时, 不需要配置mongodb
public class MultiDsConsumerMain implements ApplicationContextAware {
static ApplicationContext context = null;
public static void main(String... args) throws Throwable {
SpringApplication application = new SpringApplication(MultiDsConsumerMain.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
try { | ITransferService transferSvc = (ITransferService) context.getBean("multiDsTransferService"); |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/main/GenericConsumerMain.java | // Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.springframework.beans.BeansException;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import com.bytesvc.service.ITransferService; | package com.bytesvc.main;
/**
* 远程调用场景
*/
@EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = { "com.bytesvc.service", "com.bytesvc.config" })
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class }) // 使用文件存储时, 不需要配置mongodb
public class GenericConsumerMain implements ApplicationContextAware {
static ApplicationContext context = null;
public static void main(String... args) throws Throwable {
SpringApplication application = new SpringApplication(GenericConsumerMain.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
try { | // Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/main/GenericConsumerMain.java
import org.springframework.beans.BeansException;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import com.bytesvc.service.ITransferService;
package com.bytesvc.main;
/**
* 远程调用场景
*/
@EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = { "com.bytesvc.service", "com.bytesvc.config" })
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class }) // 使用文件存储时, 不需要配置mongodb
public class GenericConsumerMain implements ApplicationContextAware {
static ApplicationContext context = null;
public static void main(String... args) throws Throwable {
SpringApplication application = new SpringApplication(GenericConsumerMain.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
try { | ITransferService transferService = (ITransferService) context.getBean("genericTransferService"); |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/MultiDsTransferServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.impl;
@Service("multiDsTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class MultiDsTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "accountService") | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/MultiDsTransferServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.impl;
@Service("multiDsTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class MultiDsTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "accountService") | private IAccountService nativeAccountService; |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/MultiDsTransferServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.impl;
@Service("multiDsTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class MultiDsTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "accountService")
private IAccountService nativeAccountService;
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/MultiDsTransferServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.impl;
@Service("multiDsTransferService")
@Compensable(interfaceClass = ITransferService.class, confirmableKey = "transferServiceConfirm", cancellableKey = "transferServiceCancel")
public class MultiDsTransferServiceImpl implements ITransferService {
@javax.annotation.Resource(name = "accountService")
private IAccountService nativeAccountService;
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/impl/TransferServiceCancel.java | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService; | package com.bytesvc.consumer.service.impl;
@Service("transferServiceCancel")
public class TransferServiceCancel implements ITransferService {
@Autowired | // Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/dao/TransferDao.java
// @Mapper
// public interface TransferDao {
//
// @Update("update tb_account_two set amount = amount + #{amount} where acct_id = #{acctId}")
// public int increaseAmount(@Param("acctId") String accountId, @Param("amount") double amount);
//
// @Update("update tb_account_two set amount = amount - #{amount} where acct_id = #{acctId}")
// public int cancelIncrease(@Param("acctId") String accountId, @Param("amount") double amount);
//
// }
//
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount);
//
// }
// Path: springcloud-sample/sample-consumer/src/main/java/com/bytesvc/consumer/service/impl/TransferServiceCancel.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.consumer.dao.TransferDao;
import com.bytesvc.consumer.service.ITransferService;
package com.bytesvc.consumer.service.impl;
@Service("transferServiceCancel")
public class TransferServiceCancel implements ITransferService {
@Autowired | private TransferDao transferDao; |
liuyangming/ByteTCC-sample | springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/controller/ProviderController.java | // Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/interfaces/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount);
//
// public void decreaseAmount(String accountId, double amount);
//
// }
//
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/model/Account.java
// @Entity
// @Table(name = "tb_account_one")
// public class Account implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "acct_id", nullable = false)
// private String identifier;
// @Column(name = "amount", nullable = false)
// private double amount;
// @Column(name = "frozen", nullable = false)
// private double frozen;
//
// public String getIdentifier() {
// return identifier;
// }
//
// public void setIdentifier(String identifier) {
// this.identifier = identifier;
// }
//
// public double getFrozen() {
// return frozen;
// }
//
// public void setFrozen(double frozen) {
// this.frozen = frozen;
// }
//
// public double getAmount() {
// return amount;
// }
//
// public void setAmount(double amount) {
// this.amount = amount;
// }
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.provider.dao.IAccountDao;
import com.bytesvc.provider.interfaces.IAccountService;
import com.bytesvc.provider.model.Account; | package com.bytesvc.provider.controller;
@Compensable(interfaceClass = IAccountService.class, cancellableKey = "accountServiceCancel")
@RestController
public class ProviderController {
@Autowired
private IAccountDao accountDao;
@ResponseBody
@RequestMapping(value = "/increase/{acctId}/{amount}", method = RequestMethod.POST)
@Transactional
public void increaseAmount(@PathVariable("acctId") String acctId, @PathVariable("amount") double amount) { | // Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/interfaces/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount);
//
// public void decreaseAmount(String accountId, double amount);
//
// }
//
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/model/Account.java
// @Entity
// @Table(name = "tb_account_one")
// public class Account implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "acct_id", nullable = false)
// private String identifier;
// @Column(name = "amount", nullable = false)
// private double amount;
// @Column(name = "frozen", nullable = false)
// private double frozen;
//
// public String getIdentifier() {
// return identifier;
// }
//
// public void setIdentifier(String identifier) {
// this.identifier = identifier;
// }
//
// public double getFrozen() {
// return frozen;
// }
//
// public void setFrozen(double frozen) {
// this.frozen = frozen;
// }
//
// public double getAmount() {
// return amount;
// }
//
// public void setAmount(double amount) {
// this.amount = amount;
// }
//
// }
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/controller/ProviderController.java
import org.bytesoft.compensable.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bytesvc.provider.dao.IAccountDao;
import com.bytesvc.provider.interfaces.IAccountService;
import com.bytesvc.provider.model.Account;
package com.bytesvc.provider.controller;
@Compensable(interfaceClass = IAccountService.class, cancellableKey = "accountServiceCancel")
@RestController
public class ProviderController {
@Autowired
private IAccountDao accountDao;
@ResponseBody
@RequestMapping(value = "/increase/{acctId}/{amount}", method = RequestMethod.POST)
@Transactional
public void increaseAmount(@PathVariable("acctId") String acctId, @PathVariable("amount") double amount) { | Account account = this.accountDao.findById(acctId); |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/AccountServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.impl;
@Service("accountService")
@Compensable(interfaceClass = IAccountService.class, confirmableKey = "accountServiceConfirm", cancellableKey = "accountServiceCancel")
public class AccountServiceImpl implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/impl/AccountServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.impl;
@Service("accountService")
@Compensable(interfaceClass = IAccountService.class, confirmableKey = "accountServiceConfirm", cancellableKey = "accountServiceCancel")
public class AccountServiceImpl implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/cancel/AccountServiceCancel.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.cancel;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/cancel/AccountServiceCancel.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.cancel;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/impl/AccountServiceImpl.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = IAccountService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Compensable(interfaceClass = IAccountService.class, confirmableKey = "accountServiceConfirm", cancellableKey = "accountServiceCancel")
public class AccountServiceImpl implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/impl/AccountServiceImpl.java
import org.bytesoft.compensable.Compensable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.impl;
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = IAccountService.class, group = "x-bytetcc", filter = "bytetcc", loadbalance = "bytetcc", cluster = "failfast", retries = -1)
@Compensable(interfaceClass = IAccountService.class, confirmableKey = "accountServiceConfirm", cancellableKey = "accountServiceCancel")
public class AccountServiceImpl implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/service/AccountServiceCancel.java | // Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/interfaces/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount);
//
// public void decreaseAmount(String accountId, double amount);
//
// }
//
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/model/Account.java
// @Entity
// @Table(name = "tb_account_one")
// public class Account implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "acct_id", nullable = false)
// private String identifier;
// @Column(name = "amount", nullable = false)
// private double amount;
// @Column(name = "frozen", nullable = false)
// private double frozen;
//
// public String getIdentifier() {
// return identifier;
// }
//
// public void setIdentifier(String identifier) {
// this.identifier = identifier;
// }
//
// public double getFrozen() {
// return frozen;
// }
//
// public void setFrozen(double frozen) {
// this.frozen = frozen;
// }
//
// public double getAmount() {
// return amount;
// }
//
// public void setAmount(double amount) {
// this.amount = amount;
// }
//
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.provider.dao.IAccountDao;
import com.bytesvc.provider.interfaces.IAccountService;
import com.bytesvc.provider.model.Account; | package com.bytesvc.provider.service;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@Autowired
private IAccountDao accountDao;
@Transactional
public void increaseAmount(String acctId, double amount) { | // Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/interfaces/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount);
//
// public void decreaseAmount(String accountId, double amount);
//
// }
//
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/model/Account.java
// @Entity
// @Table(name = "tb_account_one")
// public class Account implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "acct_id", nullable = false)
// private String identifier;
// @Column(name = "amount", nullable = false)
// private double amount;
// @Column(name = "frozen", nullable = false)
// private double frozen;
//
// public String getIdentifier() {
// return identifier;
// }
//
// public void setIdentifier(String identifier) {
// this.identifier = identifier;
// }
//
// public double getFrozen() {
// return frozen;
// }
//
// public void setFrozen(double frozen) {
// this.frozen = frozen;
// }
//
// public double getAmount() {
// return amount;
// }
//
// public void setAmount(double amount) {
// this.amount = amount;
// }
//
// }
// Path: springboot-sample/sample-provider/src/main/java/com/bytesvc/provider/service/AccountServiceCancel.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.provider.dao.IAccountDao;
import com.bytesvc.provider.interfaces.IAccountService;
import com.bytesvc.provider.model.Account;
package com.bytesvc.provider.service;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@Autowired
private IAccountDao accountDao;
@Transactional
public void increaseAmount(String acctId, double amount) { | Account account = this.accountDao.findById(acctId); |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/cancel/AccountServiceCancel.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.cancel;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/cancel/AccountServiceCancel.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.cancel;
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/confirm/AccountServiceConfirm.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.confirm;
@Service("accountServiceConfirm")
public class AccountServiceConfirm implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/confirm/AccountServiceConfirm.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.confirm;
@Service("accountServiceConfirm")
public class AccountServiceConfirm implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate1")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/confirm/TransferServiceConfirm.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.ITransferService; | package com.bytesvc.service.confirm;
@Service("transferServiceConfirm")
public class TransferServiceConfirm implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/ITransferService.java
// public interface ITransferService {
//
// public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-consumer/src/main/java/com/bytesvc/service/confirm/TransferServiceConfirm.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.ITransferService;
package com.bytesvc.service.confirm;
@Service("transferServiceConfirm")
public class TransferServiceConfirm implements ITransferService {
@javax.annotation.Resource(name = "jdbcTemplate2")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
liuyangming/ByteTCC-sample | dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/confirm/AccountServiceConfirm.java | // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
| import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService; | package com.bytesvc.service.confirm;
@Service("accountServiceConfirm")
public class AccountServiceConfirm implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| // Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/ServiceException.java
// public class ServiceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public ServiceException(String message) {
// super(message);
// }
//
// }
//
// Path: dubbo-sample/sample-api/src/main/java/com/bytesvc/service/IAccountService.java
// public interface IAccountService {
//
// public void increaseAmount(String accountId, double amount) throws ServiceException;
//
// public void decreaseAmount(String accountId, double amount) throws ServiceException;
//
// }
// Path: dubbo-sample/sample-provider/src/main/java/com/bytesvc/service/confirm/AccountServiceConfirm.java
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bytesvc.ServiceException;
import com.bytesvc.service.IAccountService;
package com.bytesvc.service.confirm;
@Service("accountServiceConfirm")
public class AccountServiceConfirm implements IAccountService {
@javax.annotation.Resource(name = "jdbcTemplate")
private JdbcTemplate jdbcTemplate;
| @Transactional(rollbackFor = ServiceException.class) |
yangting/openjtcc | tcc-core/src/main/java/org/bytesoft/openjtcc/common/TransactionContext.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/xa/XidImpl.java
// public class XidImpl implements Xid, Serializable {
// public static final int xidFormatId = 13923;
//
// private final int formatId = xidFormatId;
// private byte[] globalTransactionId;
// private byte[] branchQualifier;
//
// public XidImpl() {
// this(new byte[0], new byte[0]);
// }
//
// public XidImpl(byte[] global) {
// this(global, new byte[0]);
// }
//
// public XidImpl(byte[] global, byte[] branch) {
// if (global == null) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)不能为空.");
// } else if (global.length > MAXGTRIDSIZE) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)长度不能超过64.");
// }
//
// if (branch == null) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)不能为空.");
// } else if (branch.length > MAXBQUALSIZE) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)长度不能超过64.");
// }
// this.globalTransactionId = global;
// this.branchQualifier = branch;
// }
//
// public byte[] getBranchQualifier() {
// return this.branchQualifier;
// }
//
// public int getFormatId() {
// return this.formatId;
// }
//
// public byte[] getGlobalTransactionId() {
// return this.globalTransactionId;
// }
//
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + formatId;
// result = prime * result + Arrays.hashCode(branchQualifier);
// result = prime * result + Arrays.hashCode(globalTransactionId);
// return result;
// }
//
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// } else if (obj == null) {
// return false;
// } else if (getClass() != obj.getClass()) {
// return false;
// }
// XidImpl other = (XidImpl) obj;
// if (formatId != other.formatId) {
// return false;
// } else if (Arrays.equals(branchQualifier, other.branchQualifier) == false) {
// return false;
// } else if (Arrays.equals(globalTransactionId, other.globalTransactionId) == false) {
// return false;
// }
// return true;
// }
//
// public String toString() {
// String global = this.globalTransactionId == null ? null : ByteUtils.byteArrayToString(this.globalTransactionId);
// String branch = this.branchQualifier == null ? null : ByteUtils.byteArrayToString(this.branchQualifier);
// return String.format("%s-%s-%s", this.formatId, global, branch);
// }
//
// }
| import java.io.Serializable;
import java.util.Stack;
import org.bytesoft.openjtcc.xa.XidImpl;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.common;
public class TransactionContext implements Serializable, Cloneable {
private transient boolean coordinator;
private transient boolean recovery;
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/xa/XidImpl.java
// public class XidImpl implements Xid, Serializable {
// public static final int xidFormatId = 13923;
//
// private final int formatId = xidFormatId;
// private byte[] globalTransactionId;
// private byte[] branchQualifier;
//
// public XidImpl() {
// this(new byte[0], new byte[0]);
// }
//
// public XidImpl(byte[] global) {
// this(global, new byte[0]);
// }
//
// public XidImpl(byte[] global, byte[] branch) {
// if (global == null) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)不能为空.");
// } else if (global.length > MAXGTRIDSIZE) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)长度不能超过64.");
// }
//
// if (branch == null) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)不能为空.");
// } else if (branch.length > MAXBQUALSIZE) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)长度不能超过64.");
// }
// this.globalTransactionId = global;
// this.branchQualifier = branch;
// }
//
// public byte[] getBranchQualifier() {
// return this.branchQualifier;
// }
//
// public int getFormatId() {
// return this.formatId;
// }
//
// public byte[] getGlobalTransactionId() {
// return this.globalTransactionId;
// }
//
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + formatId;
// result = prime * result + Arrays.hashCode(branchQualifier);
// result = prime * result + Arrays.hashCode(globalTransactionId);
// return result;
// }
//
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// } else if (obj == null) {
// return false;
// } else if (getClass() != obj.getClass()) {
// return false;
// }
// XidImpl other = (XidImpl) obj;
// if (formatId != other.formatId) {
// return false;
// } else if (Arrays.equals(branchQualifier, other.branchQualifier) == false) {
// return false;
// } else if (Arrays.equals(globalTransactionId, other.globalTransactionId) == false) {
// return false;
// }
// return true;
// }
//
// public String toString() {
// String global = this.globalTransactionId == null ? null : ByteUtils.byteArrayToString(this.globalTransactionId);
// String branch = this.branchQualifier == null ? null : ByteUtils.byteArrayToString(this.branchQualifier);
// return String.format("%s-%s-%s", this.formatId, global, branch);
// }
//
// }
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/common/TransactionContext.java
import java.io.Serializable;
import java.util.Stack;
import org.bytesoft.openjtcc.xa.XidImpl;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.common;
public class TransactionContext implements Serializable, Cloneable {
private transient boolean coordinator;
private transient boolean recovery;
| private transient XidImpl creationXid;
|
yangting/openjtcc | tcc-core/src/main/java/org/bytesoft/openjtcc/task/TransactionTimingTask.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/schedule/TimingProcesser.java
// public interface TimingProcesser {
//
// public void processTimingTransaction();
//
// public void processExpireTransaction();
//
// }
| import org.bytesoft.openjtcc.supports.schedule.TimingProcesser;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.task;
public class TransactionTimingTask extends AbstractScheduleTask {
private static final int MIN_INTERVAL_SECONDS = 1;
private static final int MAX_INTERVAL_SECONDS = 1800;
private static final int DEFAULT_INTERVAL_SECONDS = 1;
private int timingIntervalSeconds = DEFAULT_INTERVAL_SECONDS;
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/schedule/TimingProcesser.java
// public interface TimingProcesser {
//
// public void processTimingTransaction();
//
// public void processExpireTransaction();
//
// }
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/task/TransactionTimingTask.java
import org.bytesoft.openjtcc.supports.schedule.TimingProcesser;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.task;
public class TransactionTimingTask extends AbstractScheduleTask {
private static final int MIN_INTERVAL_SECONDS = 1;
private static final int MAX_INTERVAL_SECONDS = 1800;
private static final int DEFAULT_INTERVAL_SECONDS = 1;
private int timingIntervalSeconds = DEFAULT_INTERVAL_SECONDS;
| private TimingProcesser timingProcesser;
|
yangting/openjtcc | tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/xa/XidImpl.java
// public class XidImpl implements Xid, Serializable {
// public static final int xidFormatId = 13923;
//
// private final int formatId = xidFormatId;
// private byte[] globalTransactionId;
// private byte[] branchQualifier;
//
// public XidImpl() {
// this(new byte[0], new byte[0]);
// }
//
// public XidImpl(byte[] global) {
// this(global, new byte[0]);
// }
//
// public XidImpl(byte[] global, byte[] branch) {
// if (global == null) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)不能为空.");
// } else if (global.length > MAXGTRIDSIZE) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)长度不能超过64.");
// }
//
// if (branch == null) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)不能为空.");
// } else if (branch.length > MAXBQUALSIZE) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)长度不能超过64.");
// }
// this.globalTransactionId = global;
// this.branchQualifier = branch;
// }
//
// public byte[] getBranchQualifier() {
// return this.branchQualifier;
// }
//
// public int getFormatId() {
// return this.formatId;
// }
//
// public byte[] getGlobalTransactionId() {
// return this.globalTransactionId;
// }
//
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + formatId;
// result = prime * result + Arrays.hashCode(branchQualifier);
// result = prime * result + Arrays.hashCode(globalTransactionId);
// return result;
// }
//
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// } else if (obj == null) {
// return false;
// } else if (getClass() != obj.getClass()) {
// return false;
// }
// XidImpl other = (XidImpl) obj;
// if (formatId != other.formatId) {
// return false;
// } else if (Arrays.equals(branchQualifier, other.branchQualifier) == false) {
// return false;
// } else if (Arrays.equals(globalTransactionId, other.globalTransactionId) == false) {
// return false;
// }
// return true;
// }
//
// public String toString() {
// String global = this.globalTransactionId == null ? null : ByteUtils.byteArrayToString(this.globalTransactionId);
// String branch = this.branchQualifier == null ? null : ByteUtils.byteArrayToString(this.branchQualifier);
// return String.format("%s-%s-%s", this.formatId, global, branch);
// }
//
// }
| import java.io.Serializable;
import org.bytesoft.openjtcc.xa.XidImpl;
import org.bytesoft.utils.CommonUtils;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.serialize;
public class TerminatorInfo implements Serializable {
private static final long serialVersionUID = 1L;
private String application;
private String endpoint;
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/xa/XidImpl.java
// public class XidImpl implements Xid, Serializable {
// public static final int xidFormatId = 13923;
//
// private final int formatId = xidFormatId;
// private byte[] globalTransactionId;
// private byte[] branchQualifier;
//
// public XidImpl() {
// this(new byte[0], new byte[0]);
// }
//
// public XidImpl(byte[] global) {
// this(global, new byte[0]);
// }
//
// public XidImpl(byte[] global, byte[] branch) {
// if (global == null) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)不能为空.");
// } else if (global.length > MAXGTRIDSIZE) {
// throw new IllegalArgumentException("全局事务ID(globalTransactionId)长度不能超过64.");
// }
//
// if (branch == null) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)不能为空.");
// } else if (branch.length > MAXBQUALSIZE) {
// throw new IllegalArgumentException("事务分支标识(branchQualifier)长度不能超过64.");
// }
// this.globalTransactionId = global;
// this.branchQualifier = branch;
// }
//
// public byte[] getBranchQualifier() {
// return this.branchQualifier;
// }
//
// public int getFormatId() {
// return this.formatId;
// }
//
// public byte[] getGlobalTransactionId() {
// return this.globalTransactionId;
// }
//
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + formatId;
// result = prime * result + Arrays.hashCode(branchQualifier);
// result = prime * result + Arrays.hashCode(globalTransactionId);
// return result;
// }
//
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// } else if (obj == null) {
// return false;
// } else if (getClass() != obj.getClass()) {
// return false;
// }
// XidImpl other = (XidImpl) obj;
// if (formatId != other.formatId) {
// return false;
// } else if (Arrays.equals(branchQualifier, other.branchQualifier) == false) {
// return false;
// } else if (Arrays.equals(globalTransactionId, other.globalTransactionId) == false) {
// return false;
// }
// return true;
// }
//
// public String toString() {
// String global = this.globalTransactionId == null ? null : ByteUtils.byteArrayToString(this.globalTransactionId);
// String branch = this.branchQualifier == null ? null : ByteUtils.byteArrayToString(this.branchQualifier);
// return String.format("%s-%s-%s", this.formatId, global, branch);
// }
//
// }
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java
import java.io.Serializable;
import org.bytesoft.openjtcc.xa.XidImpl;
import org.bytesoft.utils.CommonUtils;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.serialize;
public class TerminatorInfo implements Serializable {
private static final long serialVersionUID = 1L;
private String application;
private String endpoint;
| private XidImpl branchXid;
|
yangting/openjtcc | tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/internal/RemoteInvocationResponseImpl.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/common/TerminalKey.java
// public class TerminalKey implements Cloneable, Serializable {
// private String application = "unspecified";
// private String endpoint = "unspecified";
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public TerminalKey clone() throws CloneNotSupportedException {
// TerminalKey that = new TerminalKey();
// that.setApplication(this.application);
// that.setEndpoint(this.endpoint);
// return that;
// }
//
// public int hashCode() {
// int hash = 23;
// hash += 29 * (this.application == null ? 0 : this.application.hashCode());
// hash += 31 * (this.endpoint == null ? 0 : this.endpoint.hashCode());
// return hash;
// }
//
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminalKey.class.equals(obj.getClass()) == false) {
// return false;
// }
//
// TerminalKey that = (TerminalKey) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// return appEquals && endEquals;
// }
//
// public String toString() {
// return String.format("terminal: application= %s, endpoint= %s", this.application, this.endpoint);
// }
//
// }
//
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/RemoteInvocationType.java
// public enum RemoteInvocationType {
// service, transaction, cleanup
// }
| import java.io.Serializable;
import org.bytesoft.openjtcc.common.TerminalKey;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationType;
import org.bytesoft.openjtcc.supports.rmi.RemoteInvocationResponse;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.dubbo.internal;
public class RemoteInvocationResponseImpl implements RemoteInvocationResponse, Serializable {
private static final long serialVersionUID = 1L;
private transient RemoteInvocationRequestImpl request;
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/common/TerminalKey.java
// public class TerminalKey implements Cloneable, Serializable {
// private String application = "unspecified";
// private String endpoint = "unspecified";
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public TerminalKey clone() throws CloneNotSupportedException {
// TerminalKey that = new TerminalKey();
// that.setApplication(this.application);
// that.setEndpoint(this.endpoint);
// return that;
// }
//
// public int hashCode() {
// int hash = 23;
// hash += 29 * (this.application == null ? 0 : this.application.hashCode());
// hash += 31 * (this.endpoint == null ? 0 : this.endpoint.hashCode());
// return hash;
// }
//
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminalKey.class.equals(obj.getClass()) == false) {
// return false;
// }
//
// TerminalKey that = (TerminalKey) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// return appEquals && endEquals;
// }
//
// public String toString() {
// return String.format("terminal: application= %s, endpoint= %s", this.application, this.endpoint);
// }
//
// }
//
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/RemoteInvocationType.java
// public enum RemoteInvocationType {
// service, transaction, cleanup
// }
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/internal/RemoteInvocationResponseImpl.java
import java.io.Serializable;
import org.bytesoft.openjtcc.common.TerminalKey;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationType;
import org.bytesoft.openjtcc.supports.rmi.RemoteInvocationResponse;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.dubbo.internal;
public class RemoteInvocationResponseImpl implements RemoteInvocationResponse, Serializable {
private static final long serialVersionUID = 1L;
private transient RemoteInvocationRequestImpl request;
| private RemoteInvocationType invocationType;
|
yangting/openjtcc | tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/internal/RemoteInvocationResponseImpl.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/common/TerminalKey.java
// public class TerminalKey implements Cloneable, Serializable {
// private String application = "unspecified";
// private String endpoint = "unspecified";
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public TerminalKey clone() throws CloneNotSupportedException {
// TerminalKey that = new TerminalKey();
// that.setApplication(this.application);
// that.setEndpoint(this.endpoint);
// return that;
// }
//
// public int hashCode() {
// int hash = 23;
// hash += 29 * (this.application == null ? 0 : this.application.hashCode());
// hash += 31 * (this.endpoint == null ? 0 : this.endpoint.hashCode());
// return hash;
// }
//
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminalKey.class.equals(obj.getClass()) == false) {
// return false;
// }
//
// TerminalKey that = (TerminalKey) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// return appEquals && endEquals;
// }
//
// public String toString() {
// return String.format("terminal: application= %s, endpoint= %s", this.application, this.endpoint);
// }
//
// }
//
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/RemoteInvocationType.java
// public enum RemoteInvocationType {
// service, transaction, cleanup
// }
| import java.io.Serializable;
import org.bytesoft.openjtcc.common.TerminalKey;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationType;
import org.bytesoft.openjtcc.supports.rmi.RemoteInvocationResponse;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.dubbo.internal;
public class RemoteInvocationResponseImpl implements RemoteInvocationResponse, Serializable {
private static final long serialVersionUID = 1L;
private transient RemoteInvocationRequestImpl request;
private RemoteInvocationType invocationType;
private Object result;
private Object transactionContext;
private Throwable throwable;
private boolean failure;
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/common/TerminalKey.java
// public class TerminalKey implements Cloneable, Serializable {
// private String application = "unspecified";
// private String endpoint = "unspecified";
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public TerminalKey clone() throws CloneNotSupportedException {
// TerminalKey that = new TerminalKey();
// that.setApplication(this.application);
// that.setEndpoint(this.endpoint);
// return that;
// }
//
// public int hashCode() {
// int hash = 23;
// hash += 29 * (this.application == null ? 0 : this.application.hashCode());
// hash += 31 * (this.endpoint == null ? 0 : this.endpoint.hashCode());
// return hash;
// }
//
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminalKey.class.equals(obj.getClass()) == false) {
// return false;
// }
//
// TerminalKey that = (TerminalKey) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// return appEquals && endEquals;
// }
//
// public String toString() {
// return String.format("terminal: application= %s, endpoint= %s", this.application, this.endpoint);
// }
//
// }
//
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/RemoteInvocationType.java
// public enum RemoteInvocationType {
// service, transaction, cleanup
// }
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/dubbo/internal/RemoteInvocationResponseImpl.java
import java.io.Serializable;
import org.bytesoft.openjtcc.common.TerminalKey;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationType;
import org.bytesoft.openjtcc.supports.rmi.RemoteInvocationResponse;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.dubbo.internal;
public class RemoteInvocationResponseImpl implements RemoteInvocationResponse, Serializable {
private static final long serialVersionUID = 1L;
private transient RemoteInvocationRequestImpl request;
private RemoteInvocationType invocationType;
private Object result;
private Object transactionContext;
private Throwable throwable;
private boolean failure;
| private TerminalKey terminalKey;
|
yangting/openjtcc | tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/marshall/TerminatorMarshallerImpl.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/remote/RemoteTerminator.java
// public interface RemoteTerminator extends Prepareable, Committable, Rollbackable, Cleanupable {
//
// public TerminalKey getTerminalKey();
//
// public int hashCode();
//
// public boolean equals(Object obj);
//
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java
// public class TerminatorInfo implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private String application;
// private String endpoint;
// private XidImpl branchXid;
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public XidImpl getBranchXid() {
// return branchXid;
// }
//
// public void setBranchXid(XidImpl branchXid) {
// this.branchXid = branchXid;
// }
//
// @Override
// public int hashCode() {
// int hash = 31;
// hash += (this.application == null) ? 13 : this.application.hashCode();
// hash += (this.endpoint == null) ? 17 : this.endpoint.hashCode();
// hash += (this.branchXid == null) ? 19 : this.branchXid.hashCode();
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminatorInfo.class.isInstance(obj) == false) {
// return false;
// }
// TerminatorInfo that = (TerminatorInfo) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// boolean xidEquals = CommonUtils.equals(this.branchXid, that.branchXid);
// return appEquals && endEquals && xidEquals;
// }
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorMarshaller.java
// public interface TerminatorMarshaller {
//
// public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException;
//
// public RemoteTerminator unmarshallTerminator(TerminatorInfo info) throws IOException;
//
// }
| import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.bytesoft.openjtcc.remote.RemoteTerminator;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationService;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationServiceMarshaller;
import org.bytesoft.openjtcc.supports.dubbo.internal.RemoteTerminatorHandler;
import org.bytesoft.openjtcc.supports.serialize.TerminatorInfo;
import org.bytesoft.openjtcc.supports.serialize.TerminatorMarshaller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.marshall;
public class TerminatorMarshallerImpl implements TerminatorMarshaller, RemoteInvocationServiceMarshaller,
ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/remote/RemoteTerminator.java
// public interface RemoteTerminator extends Prepareable, Committable, Rollbackable, Cleanupable {
//
// public TerminalKey getTerminalKey();
//
// public int hashCode();
//
// public boolean equals(Object obj);
//
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java
// public class TerminatorInfo implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private String application;
// private String endpoint;
// private XidImpl branchXid;
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public XidImpl getBranchXid() {
// return branchXid;
// }
//
// public void setBranchXid(XidImpl branchXid) {
// this.branchXid = branchXid;
// }
//
// @Override
// public int hashCode() {
// int hash = 31;
// hash += (this.application == null) ? 13 : this.application.hashCode();
// hash += (this.endpoint == null) ? 17 : this.endpoint.hashCode();
// hash += (this.branchXid == null) ? 19 : this.branchXid.hashCode();
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminatorInfo.class.isInstance(obj) == false) {
// return false;
// }
// TerminatorInfo that = (TerminatorInfo) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// boolean xidEquals = CommonUtils.equals(this.branchXid, that.branchXid);
// return appEquals && endEquals && xidEquals;
// }
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorMarshaller.java
// public interface TerminatorMarshaller {
//
// public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException;
//
// public RemoteTerminator unmarshallTerminator(TerminatorInfo info) throws IOException;
//
// }
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/marshall/TerminatorMarshallerImpl.java
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.bytesoft.openjtcc.remote.RemoteTerminator;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationService;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationServiceMarshaller;
import org.bytesoft.openjtcc.supports.dubbo.internal.RemoteTerminatorHandler;
import org.bytesoft.openjtcc.supports.serialize.TerminatorInfo;
import org.bytesoft.openjtcc.supports.serialize.TerminatorMarshaller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.marshall;
public class TerminatorMarshallerImpl implements TerminatorMarshaller, RemoteInvocationServiceMarshaller,
ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
| public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException {
|
yangting/openjtcc | tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/marshall/TerminatorMarshallerImpl.java | // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/remote/RemoteTerminator.java
// public interface RemoteTerminator extends Prepareable, Committable, Rollbackable, Cleanupable {
//
// public TerminalKey getTerminalKey();
//
// public int hashCode();
//
// public boolean equals(Object obj);
//
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java
// public class TerminatorInfo implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private String application;
// private String endpoint;
// private XidImpl branchXid;
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public XidImpl getBranchXid() {
// return branchXid;
// }
//
// public void setBranchXid(XidImpl branchXid) {
// this.branchXid = branchXid;
// }
//
// @Override
// public int hashCode() {
// int hash = 31;
// hash += (this.application == null) ? 13 : this.application.hashCode();
// hash += (this.endpoint == null) ? 17 : this.endpoint.hashCode();
// hash += (this.branchXid == null) ? 19 : this.branchXid.hashCode();
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminatorInfo.class.isInstance(obj) == false) {
// return false;
// }
// TerminatorInfo that = (TerminatorInfo) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// boolean xidEquals = CommonUtils.equals(this.branchXid, that.branchXid);
// return appEquals && endEquals && xidEquals;
// }
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorMarshaller.java
// public interface TerminatorMarshaller {
//
// public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException;
//
// public RemoteTerminator unmarshallTerminator(TerminatorInfo info) throws IOException;
//
// }
| import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.bytesoft.openjtcc.remote.RemoteTerminator;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationService;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationServiceMarshaller;
import org.bytesoft.openjtcc.supports.dubbo.internal.RemoteTerminatorHandler;
import org.bytesoft.openjtcc.supports.serialize.TerminatorInfo;
import org.bytesoft.openjtcc.supports.serialize.TerminatorMarshaller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
| /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.marshall;
public class TerminatorMarshallerImpl implements TerminatorMarshaller, RemoteInvocationServiceMarshaller,
ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
| // Path: tcc-core/src/main/java/org/bytesoft/openjtcc/remote/RemoteTerminator.java
// public interface RemoteTerminator extends Prepareable, Committable, Rollbackable, Cleanupable {
//
// public TerminalKey getTerminalKey();
//
// public int hashCode();
//
// public boolean equals(Object obj);
//
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorInfo.java
// public class TerminatorInfo implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private String application;
// private String endpoint;
// private XidImpl branchXid;
//
// public String getApplication() {
// return application;
// }
//
// public void setApplication(String application) {
// this.application = application;
// }
//
// public String getEndpoint() {
// return endpoint;
// }
//
// public void setEndpoint(String endpoint) {
// this.endpoint = endpoint;
// }
//
// public XidImpl getBranchXid() {
// return branchXid;
// }
//
// public void setBranchXid(XidImpl branchXid) {
// this.branchXid = branchXid;
// }
//
// @Override
// public int hashCode() {
// int hash = 31;
// hash += (this.application == null) ? 13 : this.application.hashCode();
// hash += (this.endpoint == null) ? 17 : this.endpoint.hashCode();
// hash += (this.branchXid == null) ? 19 : this.branchXid.hashCode();
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// } else if (TerminatorInfo.class.isInstance(obj) == false) {
// return false;
// }
// TerminatorInfo that = (TerminatorInfo) obj;
// boolean appEquals = CommonUtils.equals(this.application, that.application);
// boolean endEquals = CommonUtils.equals(this.endpoint, that.endpoint);
// boolean xidEquals = CommonUtils.equals(this.branchXid, that.branchXid);
// return appEquals && endEquals && xidEquals;
// }
// }
//
// Path: tcc-core/src/main/java/org/bytesoft/openjtcc/supports/serialize/TerminatorMarshaller.java
// public interface TerminatorMarshaller {
//
// public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException;
//
// public RemoteTerminator unmarshallTerminator(TerminatorInfo info) throws IOException;
//
// }
// Path: tcc-supports/src/main/java/org/bytesoft/openjtcc/supports/marshall/TerminatorMarshallerImpl.java
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.bytesoft.openjtcc.remote.RemoteTerminator;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationService;
import org.bytesoft.openjtcc.supports.dubbo.RemoteInvocationServiceMarshaller;
import org.bytesoft.openjtcc.supports.dubbo.internal.RemoteTerminatorHandler;
import org.bytesoft.openjtcc.supports.serialize.TerminatorInfo;
import org.bytesoft.openjtcc.supports.serialize.TerminatorMarshaller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.supports.marshall;
public class TerminatorMarshallerImpl implements TerminatorMarshaller, RemoteInvocationServiceMarshaller,
ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
| public TerminatorInfo marshallTerminator(RemoteTerminator terminator) throws IOException {
|
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public class RecoveringPathLexerTest {
private final RecoveringPathLexer lexer = new RecoveringPathLexer();
@Test(expected = IllegalStateException.class)
public void lexProblems() {
LexerResult result = this.lexer.lex("Q"); | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public class RecoveringPathLexerTest {
private final RecoveringPathLexer lexer = new RecoveringPathLexer();
@Test(expected = IllegalStateException.class)
public void lexProblems() {
LexerResult result = this.lexer.lex("Q"); | assertProblemCount(result, 1); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; | assertProblemCount(result, 1);
}
@Test
public void illegalDotChildWildcard() {
LexerResult result = this.lexer.lex(".dot_child*");
assertProblemCount(result, 1);
}
@Test
public void illegalDoubleQuoteWildcard() {
LexerResult result = this.lexer.lex("[\"array_child*\"]");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcard() {
LexerResult result = this.lexer.lex("['array_child*']");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcardLate() {
LexerResult result = this.lexer.lex("['*a']");
assertProblemCount(result, 1);
}
@Test
public void root() {
LexerResult result = this.lexer.lex("$"); | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
assertProblemCount(result, 1);
}
@Test
public void illegalDotChildWildcard() {
LexerResult result = this.lexer.lex(".dot_child*");
assertProblemCount(result, 1);
}
@Test
public void illegalDoubleQuoteWildcard() {
LexerResult result = this.lexer.lex("[\"array_child*\"]");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcard() {
LexerResult result = this.lexer.lex("['array_child*']");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcardLate() {
LexerResult result = this.lexer.lex("['*a']");
assertProblemCount(result, 1);
}
@Test
public void root() {
LexerResult result = this.lexer.lex("$"); | assertNoProblems(result); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; | }
@Test
public void illegalDotChildWildcard() {
LexerResult result = this.lexer.lex(".dot_child*");
assertProblemCount(result, 1);
}
@Test
public void illegalDoubleQuoteWildcard() {
LexerResult result = this.lexer.lex("[\"array_child*\"]");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcard() {
LexerResult result = this.lexer.lex("['array_child*']");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcardLate() {
LexerResult result = this.lexer.lex("['*a']");
assertProblemCount(result, 1);
}
@Test
public void root() {
LexerResult result = this.lexer.lex("$");
assertNoProblems(result); | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexerTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
}
@Test
public void illegalDotChildWildcard() {
LexerResult result = this.lexer.lex(".dot_child*");
assertProblemCount(result, 1);
}
@Test
public void illegalDoubleQuoteWildcard() {
LexerResult result = this.lexer.lex("[\"array_child*\"]");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcard() {
LexerResult result = this.lexer.lex("['array_child*']");
assertProblemCount(result, 1);
}
@Test
public void illegalQuoteWildcardLate() {
LexerResult result = this.lexer.lex("['*a']");
assertProblemCount(result, 1);
}
@Test
public void root() {
LexerResult result = this.lexer.lex("$");
assertNoProblems(result); | assertEquals(new Token(TokenType.ROOT, 0), result.getTokenStream().remove()); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/ProblemContainer.java
// public interface ProblemContainer {
//
// /**
// * The collection of problems contained within this type
// *
// * @return The collection of problems contained within this type
// */
// List<ExpressionProblem> getProblems();
//
// }
| import static org.junit.Assert.assertEquals;
import com.nebhale.jsonpath.internal.parser.ProblemContainer; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.testutils;
public final class AssertUtils {
private AssertUtils() {
}
| // Path: src/main/java/com/nebhale/jsonpath/internal/parser/ProblemContainer.java
// public interface ProblemContainer {
//
// /**
// * The collection of problems contained within this type
// *
// * @return The collection of problems contained within this type
// */
// List<ExpressionProblem> getProblems();
//
// }
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
import static org.junit.Assert.assertEquals;
import com.nebhale.jsonpath.internal.parser.ProblemContainer;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.testutils;
public final class AssertUtils {
private AssertUtils() {
}
| public static void assertNoProblems(ProblemContainer problemContainer) { |
nebhale/JsonPath | src/main/java/com/nebhale/jsonpath/internal/parser/StandardPathScanner.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
/**
* A {@link PathScanner} that scans into the following types:
* <p />
*
* <pre>
* COMPLEX_NAME_CHARACTER: LETTER | DIGIT | COMMA | HYPHEN | SPACE | UNDERSCORE
* SIMPLE_NAME_CHARACTER: LETTER | DIGIT | UNDERSCORE
* INDEX_CHARACTER: DIGIT | COMMA | SPACE
* LETTER: [A-Za-z]
* DIGIT: [0-9]
*
* ARRAY_CLOSE: ]
* ARRAY_OPEN: [
* COMMA: ,
* DOT: .
* DOUBLE_QUOTE: "
* HYPHEN: -
* QUOTE: '
* ROOT: $
* SPACE: ' '
* UNDERSCORE: _
* WILDCARD: *
* </pre>
*
* <strong>Concurrent Semantics</strong><br />
*
* Not thread-safe
*/
final class StandardPathScanner implements PathScanner {
private static final char ARRAY_CLOSE = ']';
private static final char ARRAY_OPEN = '[';
private static final char COMMA = ',';
private static final char DOT = '.';
private static final char DOUBLE_QUOTE = '"';
private static final char HYPHEN = '-';
private static final char QUOTE = '\'';
private static final char ROOT = '$';
private static final char SPACE = ' ';
private static final char UNDERSCORE = '_';
private static final char WILDCARD = '*';
private final List<PathCharacter> pathCharacters = new ArrayList<PathCharacter>();
private volatile int position = 0;
StandardPathScanner(String expression) {
int counter = 0;
for (char c : expression.toCharArray()) { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/StandardPathScanner.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
/**
* A {@link PathScanner} that scans into the following types:
* <p />
*
* <pre>
* COMPLEX_NAME_CHARACTER: LETTER | DIGIT | COMMA | HYPHEN | SPACE | UNDERSCORE
* SIMPLE_NAME_CHARACTER: LETTER | DIGIT | UNDERSCORE
* INDEX_CHARACTER: DIGIT | COMMA | SPACE
* LETTER: [A-Za-z]
* DIGIT: [0-9]
*
* ARRAY_CLOSE: ]
* ARRAY_OPEN: [
* COMMA: ,
* DOT: .
* DOUBLE_QUOTE: "
* HYPHEN: -
* QUOTE: '
* ROOT: $
* SPACE: ' '
* UNDERSCORE: _
* WILDCARD: *
* </pre>
*
* <strong>Concurrent Semantics</strong><br />
*
* Not thread-safe
*/
final class StandardPathScanner implements PathScanner {
private static final char ARRAY_CLOSE = ']';
private static final char ARRAY_OPEN = '[';
private static final char COMMA = ',';
private static final char DOT = '.';
private static final char DOUBLE_QUOTE = '"';
private static final char HYPHEN = '-';
private static final char QUOTE = '\'';
private static final char ROOT = '$';
private static final char SPACE = ' ';
private static final char UNDERSCORE = '_';
private static final char WILDCARD = '*';
private final List<PathCharacter> pathCharacters = new ArrayList<PathCharacter>();
private volatile int position = 0;
StandardPathScanner(String expression) {
int counter = 0;
for (char c : expression.toCharArray()) { | Set<CharacterType> characterTypes = new HashSet<CharacterType>(); |
nebhale/JsonPath | src/main/java/com/nebhale/jsonpath/internal/parser/StandardPathScanner.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets; | characterTypes.add(CharacterType.HYPHEN);
} else if (Character.isLetter(c)) {
characterTypes.add(CharacterType.LETTER);
} else if (c == QUOTE) {
characterTypes.add(CharacterType.QUOTE);
} else if (c == ROOT) {
characterTypes.add(CharacterType.ROOT);
} else if (c == SPACE) {
characterTypes.add(CharacterType.SPACE);
} else if (c == UNDERSCORE) {
characterTypes.add(CharacterType.UNDERSCORE);
} else if (c == WILDCARD) {
characterTypes.add(CharacterType.WILDCARD);
}
if (isComplexNameCharacter(c)) {
characterTypes.add(CharacterType.COMPLEX_NAME_CHARACTER);
}
if (isSimpleNameCharacter(c)) {
characterTypes.add(CharacterType.SIMPLE_NAME_CHARACTER);
}
if (isIndexCharacter(c)) {
characterTypes.add(CharacterType.INDEX_CHARACTER);
}
this.pathCharacters.add(new PathCharacter(characterTypes, c, counter++));
}
| // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/StandardPathScanner.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
characterTypes.add(CharacterType.HYPHEN);
} else if (Character.isLetter(c)) {
characterTypes.add(CharacterType.LETTER);
} else if (c == QUOTE) {
characterTypes.add(CharacterType.QUOTE);
} else if (c == ROOT) {
characterTypes.add(CharacterType.ROOT);
} else if (c == SPACE) {
characterTypes.add(CharacterType.SPACE);
} else if (c == UNDERSCORE) {
characterTypes.add(CharacterType.UNDERSCORE);
} else if (c == WILDCARD) {
characterTypes.add(CharacterType.WILDCARD);
}
if (isComplexNameCharacter(c)) {
characterTypes.add(CharacterType.COMPLEX_NAME_CHARACTER);
}
if (isSimpleNameCharacter(c)) {
characterTypes.add(CharacterType.SIMPLE_NAME_CHARACTER);
}
if (isIndexCharacter(c)) {
characterTypes.add(CharacterType.INDEX_CHARACTER);
}
this.pathCharacters.add(new PathCharacter(characterTypes, c, counter++));
}
| this.pathCharacters.add(new PathCharacter(Sets.asSet(CharacterType.END), '\0', counter)); |
nebhale/JsonPath | src/main/java/com/nebhale/jsonpath/internal/component/ChildPathComponent.java | // Path: src/main/java/com/nebhale/jsonpath/internal/util/ArrayUtils.java
// public final class ArrayUtils {
//
// private static final String DELIMITERS = ", ";
//
// private ArrayUtils() {
// }
//
// public static int[] parseAsIntArray(String value) {
// StringTokenizer tokenizer = new StringTokenizer(value, DELIMITERS);
// int[] array = new int[tokenizer.countTokens()];
// for (int i = 0; i < array.length; i++) {
// array[i] = Integer.parseInt(tokenizer.nextToken());
// }
// return array;
// }
//
// public static String[] parseAsStringArray(String value) {
// StringTokenizer tokenizer = new StringTokenizer(value, DELIMITERS);
// String[] array = new String[tokenizer.countTokens()];
// for (int i = 0; i < array.length; i++) {
// array[i] = tokenizer.nextToken();
// }
// return array;
// }
// }
| import java.util.Arrays;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.nebhale.jsonpath.internal.util.ArrayUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
/**
* A {@link PathComponent} that handles child names
* <p />
*
* <strong>Concurrent Semantics</strong><br />
*
* Thread-safe
*/
public final class ChildPathComponent extends AbstractChainedPathComponent {
private final String[] names;
public ChildPathComponent(PathComponent delegate, String names) {
super(delegate); | // Path: src/main/java/com/nebhale/jsonpath/internal/util/ArrayUtils.java
// public final class ArrayUtils {
//
// private static final String DELIMITERS = ", ";
//
// private ArrayUtils() {
// }
//
// public static int[] parseAsIntArray(String value) {
// StringTokenizer tokenizer = new StringTokenizer(value, DELIMITERS);
// int[] array = new int[tokenizer.countTokens()];
// for (int i = 0; i < array.length; i++) {
// array[i] = Integer.parseInt(tokenizer.nextToken());
// }
// return array;
// }
//
// public static String[] parseAsStringArray(String value) {
// StringTokenizer tokenizer = new StringTokenizer(value, DELIMITERS);
// String[] array = new String[tokenizer.countTokens()];
// for (int i = 0; i < array.length; i++) {
// array[i] = tokenizer.nextToken();
// }
// return array;
// }
// }
// Path: src/main/java/com/nebhale/jsonpath/internal/component/ChildPathComponent.java
import java.util.Arrays;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.nebhale.jsonpath.internal.util.ArrayUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
/**
* A {@link PathComponent} that handles child names
* <p />
*
* <strong>Concurrent Semantics</strong><br />
*
* Thread-safe
*/
public final class ChildPathComponent extends AbstractChainedPathComponent {
private final String[] names;
public ChildPathComponent(PathComponent delegate, String names) {
super(delegate); | this.names = ArrayUtils.parseAsStringArray(names); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/component/DeepWildcardPathComponentTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class DeepWildcardPathComponentTest {
@Test
public void select() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/component/DeepWildcardPathComponentTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class DeepWildcardPathComponentTest {
@Test
public void select() { | JsonNode result = new DeepWildcardPathComponent(null).select(NODE); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/TokenTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenTest {
@Test
public void test() { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/TokenTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenTest {
@Test
public void test() { | Token token = new Token(TokenType.ROOT, 0); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/TokenTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenTest {
@Test
public void test() {
Token token = new Token(TokenType.ROOT, 0);
assertEquals(TokenType.ROOT, token.getType());
assertNull(token.getValue());
assertEquals(0, token.getStartPosition());
assertEquals(0, token.getEndPosition());
}
@Test
public void equalsHashCode() { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/TokenTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenTest {
@Test
public void test() {
Token token = new Token(TokenType.ROOT, 0);
assertEquals(TokenType.ROOT, token.getType());
assertNull(token.getValue());
assertEquals(0, token.getStartPosition());
assertEquals(0, token.getEndPosition());
}
@Test
public void equalsHashCode() { | new EqualsAndHashCodeTestUtils<Token>(new Token(TokenType.ROOT, "test-value", 0, 1)) // |
nebhale/JsonPath | src/main/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexer.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
/**
* An implementation of {@link PathLexer} that tokenizes into the following types:
* <p />
*
* <pre>
* ROOT: ROOT
* CHILD: DOT_CHILD | ARRAY_CHILD
* INDEX: ARRAY_OPEN ( INDEX_CHARACTER* | WILDCARD ) ARRAY_CLOSE
* DOT_CHILD: DOT SIMPLE_NAME
* ARRAY_CHILD: ARRAY_OPEN ( QUOTE COMPLEX_NAME QUOTE | DOUBLE_QUOTE COMPLEX_NAME DOUBLE_QUOTE ) ARRAY_CLOSE
* SIMPLE_NAME: SIMPLE_NAME_CHARACTER* | WILDCARD
* COMPLEX_NAME: COMPLEX_NAME_CHARACTER* | WILDCARD
* </pre>
*
* <strong>Concurrent Semantics</strong><br />
*
* Thread-safe
*
* @see StandardPathScanner
*/
final class RecoveringPathLexer implements PathLexer {
@Override
public LexerResult lex(String expression) {
LexerContext context = new LexerContext(expression);
PathScanner scanner = context.scanner;
while (scanner.ready()) {
PathCharacter c = scanner.get();
if (context.parsingState == ParsingState.BASE) {
base(context, c);
} else if (context.parsingState == ParsingState.ARRAY_OPEN) {
arrayOpen(context, c);
} else if (context.parsingState == ParsingState.ARRAY_CLOSE) {
arrayClose(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CHILD) { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexer.java
import java.util.ArrayList;
import java.util.List;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
/**
* An implementation of {@link PathLexer} that tokenizes into the following types:
* <p />
*
* <pre>
* ROOT: ROOT
* CHILD: DOT_CHILD | ARRAY_CHILD
* INDEX: ARRAY_OPEN ( INDEX_CHARACTER* | WILDCARD ) ARRAY_CLOSE
* DOT_CHILD: DOT SIMPLE_NAME
* ARRAY_CHILD: ARRAY_OPEN ( QUOTE COMPLEX_NAME QUOTE | DOUBLE_QUOTE COMPLEX_NAME DOUBLE_QUOTE ) ARRAY_CLOSE
* SIMPLE_NAME: SIMPLE_NAME_CHARACTER* | WILDCARD
* COMPLEX_NAME: COMPLEX_NAME_CHARACTER* | WILDCARD
* </pre>
*
* <strong>Concurrent Semantics</strong><br />
*
* Thread-safe
*
* @see StandardPathScanner
*/
final class RecoveringPathLexer implements PathLexer {
@Override
public LexerResult lex(String expression) {
LexerContext context = new LexerContext(expression);
PathScanner scanner = context.scanner;
while (scanner.ready()) {
PathCharacter c = scanner.get();
if (context.parsingState == ParsingState.BASE) {
base(context, c);
} else if (context.parsingState == ParsingState.ARRAY_OPEN) {
arrayOpen(context, c);
} else if (context.parsingState == ParsingState.ARRAY_CLOSE) {
arrayClose(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CHILD) { | arrayChild(context, c, CharacterType.DOUBLE_QUOTE, ParsingState.DOUBLE_QUOTE_CLOSE); |
nebhale/JsonPath | src/main/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexer.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; |
if (context.parsingState == ParsingState.BASE) {
base(context, c);
} else if (context.parsingState == ParsingState.ARRAY_OPEN) {
arrayOpen(context, c);
} else if (context.parsingState == ParsingState.ARRAY_CLOSE) {
arrayClose(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CHILD) {
arrayChild(context, c, CharacterType.DOUBLE_QUOTE, ParsingState.DOUBLE_QUOTE_CLOSE);
} else if (context.parsingState == ParsingState.QUOTE_CHILD) {
arrayChild(context, c, CharacterType.QUOTE, ParsingState.QUOTE_CLOSE);
} else if (context.parsingState == ParsingState.DOT_CHILD) {
dotChild(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CLOSE) {
arrayChildClose(context, c, CharacterType.DOUBLE_QUOTE);
} else if (context.parsingState == ParsingState.INDEX) {
index(context, c);
} else if (context.parsingState == ParsingState.QUOTE_CLOSE) {
arrayChildClose(context, c, CharacterType.QUOTE);
}
}
return new LexerResult(context.tokenStream, context.problems);
}
private void arrayChild(LexerContext context, PathCharacter c, CharacterType quoteType, ParsingState closeState) {
if (c.isType(CharacterType.COMPLEX_NAME_CHARACTER)) {
context.value.add(c);
context.scanner.consume();
} else if (c.isType(quoteType)) { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/RecoveringPathLexer.java
import java.util.ArrayList;
import java.util.List;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
if (context.parsingState == ParsingState.BASE) {
base(context, c);
} else if (context.parsingState == ParsingState.ARRAY_OPEN) {
arrayOpen(context, c);
} else if (context.parsingState == ParsingState.ARRAY_CLOSE) {
arrayClose(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CHILD) {
arrayChild(context, c, CharacterType.DOUBLE_QUOTE, ParsingState.DOUBLE_QUOTE_CLOSE);
} else if (context.parsingState == ParsingState.QUOTE_CHILD) {
arrayChild(context, c, CharacterType.QUOTE, ParsingState.QUOTE_CLOSE);
} else if (context.parsingState == ParsingState.DOT_CHILD) {
dotChild(context, c);
} else if (context.parsingState == ParsingState.DOUBLE_QUOTE_CLOSE) {
arrayChildClose(context, c, CharacterType.DOUBLE_QUOTE);
} else if (context.parsingState == ParsingState.INDEX) {
index(context, c);
} else if (context.parsingState == ParsingState.QUOTE_CLOSE) {
arrayChildClose(context, c, CharacterType.QUOTE);
}
}
return new LexerResult(context.tokenStream, context.problems);
}
private void arrayChild(LexerContext context, PathCharacter c, CharacterType quoteType, ParsingState closeState) {
if (c.isType(CharacterType.COMPLEX_NAME_CHARACTER)) {
context.value.add(c);
context.scanner.consume();
} else if (c.isType(quoteType)) { | context.tokenStream.add(createToken(TokenType.CHILD, context)); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/JsonPathTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath;
public final class JsonPathTest {
@Test
public void compileValid() {
assertNotNull(JsonPath.compile("$"));
}
@Test(expected = InvalidJsonPathExpressionException.class)
public void compileInvalid() {
JsonPath.compile(".");
}
@Test
public void stringInputClassOutputStatic() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/test/java/com/nebhale/jsonpath/JsonPathTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath;
public final class JsonPathTest {
@Test
public void compileValid() {
assertNotNull(JsonPath.compile("$"));
}
@Test(expected = InvalidJsonPathExpressionException.class)
public void compileInvalid() {
JsonPath.compile(".");
}
@Test
public void stringInputClassOutputStatic() { | assertNotNull(JsonPath.read("$", STRING_VALID, Map.class)); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/JsonPathTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath;
public final class JsonPathTest {
@Test
public void compileValid() {
assertNotNull(JsonPath.compile("$"));
}
@Test(expected = InvalidJsonPathExpressionException.class)
public void compileInvalid() {
JsonPath.compile(".");
}
@Test
public void stringInputClassOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, Map.class));
}
@Test
public void stringInputTypeReferenceOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, new TypeReference<JsonNode>() {
}));
}
@Test
public void stringInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, SimpleType.construct(Object.class)));
}
@Test
public void jsonNodeInputClassOutputStatic() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/test/java/com/nebhale/jsonpath/JsonPathTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath;
public final class JsonPathTest {
@Test
public void compileValid() {
assertNotNull(JsonPath.compile("$"));
}
@Test(expected = InvalidJsonPathExpressionException.class)
public void compileInvalid() {
JsonPath.compile(".");
}
@Test
public void stringInputClassOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, Map.class));
}
@Test
public void stringInputTypeReferenceOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, new TypeReference<JsonNode>() {
}));
}
@Test
public void stringInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, SimpleType.construct(Object.class)));
}
@Test
public void jsonNodeInputClassOutputStatic() { | assertNotNull(JsonPath.read("$", NODE, Map.class)); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/JsonPathTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets; | }
@Test
public void stringInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, SimpleType.construct(Object.class)));
}
@Test
public void jsonNodeInputClassOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, Map.class));
}
@Test
public void jsonNodeInputTypeReferenceOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, new TypeReference<JsonNode>() {
}));
}
@Test
public void jsonNodeInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, SimpleType.construct(Object.class)));
}
@Test
public void readValid() {
assertNotNull(JsonPath.compile("$").read(STRING_VALID, Map.class));
}
@Test(expected = InvalidJsonException.class)
public void readStringInputClassOutputInvalid() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/test/java/com/nebhale/jsonpath/JsonPathTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets;
}
@Test
public void stringInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", STRING_VALID, SimpleType.construct(Object.class)));
}
@Test
public void jsonNodeInputClassOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, Map.class));
}
@Test
public void jsonNodeInputTypeReferenceOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, new TypeReference<JsonNode>() {
}));
}
@Test
public void jsonNodeInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, SimpleType.construct(Object.class)));
}
@Test
public void readValid() {
assertNotNull(JsonPath.compile("$").read(STRING_VALID, Map.class));
}
@Test(expected = InvalidJsonException.class)
public void readStringInputClassOutputInvalid() { | JsonPath.compile("$").read(STRING_INVALID, Map.class); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/JsonPathTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets; |
@Test
public void jsonNodeInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, SimpleType.construct(Object.class)));
}
@Test
public void readValid() {
assertNotNull(JsonPath.compile("$").read(STRING_VALID, Map.class));
}
@Test(expected = InvalidJsonException.class)
public void readStringInputClassOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, Map.class);
}
@Test(expected = InvalidJsonException.class)
public void readStringInputTypeReferenceOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, new TypeReference<JsonNode>() {
});
}
@Test(expected = InvalidJsonException.class)
public void readStringInputJavaTypeOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, SimpleType.construct(Object.class));
}
@Test
public void stringInputClassOutput() {
assertEquals("Sayings of the Century", JsonPath.read("$.store.book[0].title", STRING_VALID, String.class)); | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_INVALID;
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final String STRING_VALID;
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
// Path: src/test/java/com/nebhale/jsonpath/JsonPathTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_INVALID;
import static com.nebhale.jsonpath.testutils.JsonUtils.STRING_VALID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.nebhale.jsonpath.internal.util.Sets;
@Test
public void jsonNodeInputJavaTypeOutputStatic() {
assertNotNull(JsonPath.read("$", NODE, SimpleType.construct(Object.class)));
}
@Test
public void readValid() {
assertNotNull(JsonPath.compile("$").read(STRING_VALID, Map.class));
}
@Test(expected = InvalidJsonException.class)
public void readStringInputClassOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, Map.class);
}
@Test(expected = InvalidJsonException.class)
public void readStringInputTypeReferenceOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, new TypeReference<JsonNode>() {
});
}
@Test(expected = InvalidJsonException.class)
public void readStringInputJavaTypeOutputInvalid() {
JsonPath.compile("$").read(STRING_INVALID, SimpleType.construct(Object.class));
}
@Test
public void stringInputClassOutput() {
assertEquals("Sayings of the Century", JsonPath.read("$.store.book[0].title", STRING_VALID, String.class)); | assertEquals(Sets.asSet("Sayings of the Century", "Sword of Honour"), JsonPath.read("$.store.book[0,1].title", STRING_VALID, Set.class)); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/component/ChildPathComponentTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class ChildPathComponentTest {
@Test
public void selectSingle() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/component/ChildPathComponentTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class ChildPathComponentTest {
@Test
public void selectSingle() { | JsonNode expected = NODE.get("store"); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/component/WildcardPathComponentTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class WildcardPathComponentTest {
@Test
public void selectWildcardArray() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/component/WildcardPathComponentTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class WildcardPathComponentTest {
@Test
public void selectWildcardArray() { | JsonNode nodeBook = NODE.get("store").get("book"); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/TokenStreamTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenStreamTest {
private final TokenStream tokenStream = new TokenStream();
| // Path: src/main/java/com/nebhale/jsonpath/internal/parser/Token.java
// enum TokenType {
//
// CHILD, //
// DEEP_WILDCARD, //
// INDEX, //
// ROOT, //
// WILDCARD
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/TokenStreamTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.Token.TokenType;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class TokenStreamTest {
private final TokenStream tokenStream = new TokenStream();
| private final Token token = new Token(TokenType.ROOT, 0); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child"); | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child"); | assertProblemCount(result, 1); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child");
assertProblemCount(result, 1);
}
@Test
public void root() {
ParserResult result = this.parser.parse("$");
| // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child");
assertProblemCount(result, 1);
}
@Test
public void root() {
ParserResult result = this.parser.parse("$");
| assertNoProblems(result); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child");
assertProblemCount(result, 1);
}
@Test
public void root() {
ParserResult result = this.parser.parse("$");
assertNoProblems(result); | // Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertNoProblems(ProblemContainer problemContainer) {
// assertProblemCount(problemContainer, 0);
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/AssertUtils.java
// public static void assertProblemCount(ProblemContainer problemContainer, int count) {
// assertEquals(problemContainer.getProblems().toString(), count, problemContainer.getProblems().size());
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/RecoveringPathParserTest.java
import static com.nebhale.jsonpath.testutils.AssertUtils.assertNoProblems;
import static com.nebhale.jsonpath.testutils.AssertUtils.assertProblemCount;
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class RecoveringPathParserTest {
private final RecoveringPathParser parser = new RecoveringPathParser();
@Test
public void illegalToken() {
ParserResult result = this.parser.parse(".dot_child");
assertProblemCount(result, 1);
}
@Test
public void root() {
ParserResult result = this.parser.parse("$");
assertNoProblems(result); | assertEquals(NODE, result.getPathComponent().get(NODE)); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() { | PathCharacter pathCharacter = new PathCharacter(Sets.asSet(CharacterType.ROOT), '$', 0); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() { | PathCharacter pathCharacter = new PathCharacter(Sets.asSet(CharacterType.ROOT), '$', 0); |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() {
PathCharacter pathCharacter = new PathCharacter(Sets.asSet(CharacterType.ROOT), '$', 0);
assertTrue(pathCharacter.isType(CharacterType.ROOT));
assertEquals('$', pathCharacter.getValue());
assertEquals(0, pathCharacter.getPosition());
}
@Test
public void equalsHashCode() { | // Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
// ARRAY_CLOSE, //
// ARRAY_OPEN, //
// COMMA, //
// COMPLEX_NAME_CHARACTER, //
// DIGIT, //
// DOT, //
// DOUBLE_QUOTE, //
// END, //
// HYPHEN, //
// INDEX_CHARACTER, //
// LETTER, //
// QUOTE, //
// ROOT, //
// SIMPLE_NAME_CHARACTER, //
// SPACE, //
// UNDERSCORE, //
// WILDCARD;
// }
//
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
//
// private Sets() {
// }
//
// /**
// * Creates a {@link Set} from a collection of items
// *
// * @param items The items to create the set from
// * @return The set created from the collection of items
// */
// public static <T> Set<T> asSet(T... items) {
// Set<T> set = new HashSet<T>();
// for (T item : items) {
// set.add(item);
// }
// return set;
// }
// }
//
// Path: src/test/java/com/nebhale/jsonpath/testutils/EqualsAndHashCodeTestUtils.java
// public final class EqualsAndHashCodeTestUtils<T> {
//
// private final T control;
//
// /**
// * Creates an instance of this utility with an {@link Object} to use as a control instance. Ensures the following
// *
// * <ul>
// * <li>{@code control}'s type is not {@link Object}</li>
// * <li>{@code control} is not equal to a different type</li>
// * <li>{@code control} is not equal to null</li>
// * <li>{@code control} is equal to itself</li>
// * </ul>
// *
// * @param control The {@link Object} to use as a control instance
// */
// public EqualsAndHashCodeTestUtils(T control) {
// this.control = control;
//
// assertFalse("control type cannot be Object", Object.class.getClass().equals(this.control.getClass()));
// assertFalse("control is equal to a different type", this.control.equals(new Object()));
// assertFalse("control is equal to null", this.control.equals(null));
// assertTrue("control is not equal to itself", this.control.equals(this.control));
// }
//
// /**
// * Asserts that an instance is equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is equal to {@code equal}</li>
// * <li>{@code equal} is equal to {@code}</li>
// * <li>{@code control}'s hash code is equal to {@code equal}'s hash code</li>
// * </ul>
// *
// * @param equals The instances that should be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertEqual(T... equals) {
// for (T equal : equals) {
// assertTrue(String.format("'%s' was not equal to '%s'", this.control, equal), this.control.equals(equal));
// assertTrue(String.format("'%s' was not equal to '%s'", equal, this.control), equal.equals(this.control));
// assertTrue(String.format("The hash code of '%s' was not equal to the hash code of '%s'", this.control, equal),
// this.control.hashCode() == equal.hashCode());
// }
// return this;
// }
//
// /**
// * Asserts that an instance is not equal to the control instance. This means the following
// *
// * <ul>
// * <li>{@code control} is not equal to {@code notEqual}</li>
// * <li>{@code notEqual} is not equal to {@code}</li>
// * <li>{@code control}'s hash code is not equal to {@code notEqual}'s hash code</li>
// * </ul>
// *
// * @param notEquals The instances that should not be equal to the control instance
// *
// * @return The called instance to allow chained invocation
// */
// public EqualsAndHashCodeTestUtils<T> assertNotEqual(T... notEquals) {
// for (Object notEqual : notEquals) {
// assertFalse(String.format("'%s' was equal to '%s'", this.control, notEqual), this.control.equals(notEqual));
// assertFalse(String.format("'%s' was equal to '%s'", notEqual, this.control), notEqual.equals(this.control));
// assertFalse(String.format("The hash code of '%s' was equal to the hash code of '%s'", this.control, notEqual),
// this.control.hashCode() == notEqual.hashCode());
// }
// return this;
// }
//
// }
// Path: src/test/java/com/nebhale/jsonpath/internal/parser/PathCharacterTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
import com.nebhale.jsonpath.testutils.EqualsAndHashCodeTestUtils;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.parser;
public final class PathCharacterTest {
@Test
public void test() {
PathCharacter pathCharacter = new PathCharacter(Sets.asSet(CharacterType.ROOT), '$', 0);
assertTrue(pathCharacter.isType(CharacterType.ROOT));
assertEquals('$', pathCharacter.getValue());
assertEquals(0, pathCharacter.getPosition());
}
@Test
public void equalsHashCode() { | new EqualsAndHashCodeTestUtils<PathCharacter>(new PathCharacter(Sets.asSet(CharacterType.ROOT), '$', 0)) // |
nebhale/JsonPath | src/test/java/com/nebhale/jsonpath/internal/component/RootPathComponentTest.java | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
| import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import org.junit.Test; | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class RootPathComponentTest {
private final RootPathComponent pathComponent = new RootPathComponent(null);
@Test
public void select() { | // Path: src/test/java/com/nebhale/jsonpath/testutils/JsonUtils.java
// public static final JsonNode NODE;
// Path: src/test/java/com/nebhale/jsonpath/internal/component/RootPathComponentTest.java
import static com.nebhale.jsonpath.testutils.JsonUtils.NODE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import org.junit.Test;
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nebhale.jsonpath.internal.component;
public final class RootPathComponentTest {
private final RootPathComponent pathComponent = new RootPathComponent(null);
@Test
public void select() { | assertSame(NODE, this.pathComponent.select(NODE)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.