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 |
|---|---|---|---|---|---|---|
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlidePageFragment.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String AGE = "AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_AGE = "sedation_age";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_SAME_MD = "sedation_same_md";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_STATUS = "sedation_status";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_TIME = "sedation_time";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int MODIFIER_REQUEST_CODE = 1;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SAME_MD = "SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int SEDATION_REQUEST_CODE = 2;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_STATUS = "SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String TIME = "TIME";
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import static org.epstudios.epcoding.Constants.AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_SAME_MD;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_TIME;
import static org.epstudios.epcoding.Constants.EPCODING;
import static org.epstudios.epcoding.Constants.MODIFIER_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SAME_MD;
import static org.epstudios.epcoding.Constants.SEDATION_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.TIME; | default:
break;
}
savedInstanceState.putBoolean(BUNDLE_SEDATION_SAME_MD, sameMDPerformsSedation);
savedInstanceState.putBoolean(BUNDLE_SEDATION_AGE, patientOver5YrsOld);
savedInstanceState.putInt(BUNDLE_SEDATION_TIME, sedationTime);
savedInstanceState.putString(BUNDLE_SEDATION_STATUS, sedationStatus.toString());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(EPCODING, "onActivityResult called");
if (requestCode == MODIFIER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
String[] result = data.getStringArrayExtra(Constants.MODIFIER_RESULT);
if (Objects.requireNonNull(result).length == 1 && result[0].equals(Constants.RESET_MODIFIERS)) {
resetModifiers();
resetCodes();
return;
}
Code code = Codes.setModifiersForCode(result);
if (code != null) {
redrawCheckBox(code);
}
}
}
if (requestCode == SEDATION_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
sameMDPerformsSedation = data.getBooleanExtra(SAME_MD, sameMDPerformsSedation);
patientOver5YrsOld = data.getBooleanExtra(AGE, patientOver5YrsOld); | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String AGE = "AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_AGE = "sedation_age";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_SAME_MD = "sedation_same_md";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_STATUS = "sedation_status";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_TIME = "sedation_time";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int MODIFIER_REQUEST_CODE = 1;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SAME_MD = "SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int SEDATION_REQUEST_CODE = 2;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_STATUS = "SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String TIME = "TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlidePageFragment.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import static org.epstudios.epcoding.Constants.AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_SAME_MD;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_TIME;
import static org.epstudios.epcoding.Constants.EPCODING;
import static org.epstudios.epcoding.Constants.MODIFIER_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SAME_MD;
import static org.epstudios.epcoding.Constants.SEDATION_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.TIME;
default:
break;
}
savedInstanceState.putBoolean(BUNDLE_SEDATION_SAME_MD, sameMDPerformsSedation);
savedInstanceState.putBoolean(BUNDLE_SEDATION_AGE, patientOver5YrsOld);
savedInstanceState.putInt(BUNDLE_SEDATION_TIME, sedationTime);
savedInstanceState.putString(BUNDLE_SEDATION_STATUS, sedationStatus.toString());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(EPCODING, "onActivityResult called");
if (requestCode == MODIFIER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
String[] result = data.getStringArrayExtra(Constants.MODIFIER_RESULT);
if (Objects.requireNonNull(result).length == 1 && result[0].equals(Constants.RESET_MODIFIERS)) {
resetModifiers();
resetCodes();
return;
}
Code code = Codes.setModifiersForCode(result);
if (code != null) {
redrawCheckBox(code);
}
}
}
if (requestCode == SEDATION_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
sameMDPerformsSedation = data.getBooleanExtra(SAME_MD, sameMDPerformsSedation);
patientOver5YrsOld = data.getBooleanExtra(AGE, patientOver5YrsOld); | sedationTime = data.getIntExtra(TIME, sedationTime); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlidePageFragment.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String AGE = "AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_AGE = "sedation_age";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_SAME_MD = "sedation_same_md";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_STATUS = "sedation_status";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_TIME = "sedation_time";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int MODIFIER_REQUEST_CODE = 1;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SAME_MD = "SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int SEDATION_REQUEST_CODE = 2;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_STATUS = "SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String TIME = "TIME";
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import static org.epstudios.epcoding.Constants.AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_SAME_MD;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_TIME;
import static org.epstudios.epcoding.Constants.EPCODING;
import static org.epstudios.epcoding.Constants.MODIFIER_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SAME_MD;
import static org.epstudios.epcoding.Constants.SEDATION_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.TIME; | break;
}
savedInstanceState.putBoolean(BUNDLE_SEDATION_SAME_MD, sameMDPerformsSedation);
savedInstanceState.putBoolean(BUNDLE_SEDATION_AGE, patientOver5YrsOld);
savedInstanceState.putInt(BUNDLE_SEDATION_TIME, sedationTime);
savedInstanceState.putString(BUNDLE_SEDATION_STATUS, sedationStatus.toString());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(EPCODING, "onActivityResult called");
if (requestCode == MODIFIER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
String[] result = data.getStringArrayExtra(Constants.MODIFIER_RESULT);
if (Objects.requireNonNull(result).length == 1 && result[0].equals(Constants.RESET_MODIFIERS)) {
resetModifiers();
resetCodes();
return;
}
Code code = Codes.setModifiersForCode(result);
if (code != null) {
redrawCheckBox(code);
}
}
}
if (requestCode == SEDATION_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
sameMDPerformsSedation = data.getBooleanExtra(SAME_MD, sameMDPerformsSedation);
patientOver5YrsOld = data.getBooleanExtra(AGE, patientOver5YrsOld);
sedationTime = data.getIntExtra(TIME, sedationTime); | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String AGE = "AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_AGE = "sedation_age";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_SAME_MD = "sedation_same_md";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_STATUS = "sedation_status";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String BUNDLE_SEDATION_TIME = "sedation_time";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int MODIFIER_REQUEST_CODE = 1;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SAME_MD = "SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static int SEDATION_REQUEST_CODE = 2;
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_STATUS = "SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String TIME = "TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlidePageFragment.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import static org.epstudios.epcoding.Constants.AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_AGE;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_SAME_MD;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.BUNDLE_SEDATION_TIME;
import static org.epstudios.epcoding.Constants.EPCODING;
import static org.epstudios.epcoding.Constants.MODIFIER_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SAME_MD;
import static org.epstudios.epcoding.Constants.SEDATION_REQUEST_CODE;
import static org.epstudios.epcoding.Constants.SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.TIME;
break;
}
savedInstanceState.putBoolean(BUNDLE_SEDATION_SAME_MD, sameMDPerformsSedation);
savedInstanceState.putBoolean(BUNDLE_SEDATION_AGE, patientOver5YrsOld);
savedInstanceState.putInt(BUNDLE_SEDATION_TIME, sedationTime);
savedInstanceState.putString(BUNDLE_SEDATION_STATUS, sedationStatus.toString());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(EPCODING, "onActivityResult called");
if (requestCode == MODIFIER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
String[] result = data.getStringArrayExtra(Constants.MODIFIER_RESULT);
if (Objects.requireNonNull(result).length == 1 && result[0].equals(Constants.RESET_MODIFIERS)) {
resetModifiers();
resetCodes();
return;
}
Code code = Codes.setModifiersForCode(result);
if (code != null) {
redrawCheckBox(code);
}
}
}
if (requestCode == SEDATION_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
sameMDPerformsSedation = data.getBooleanExtra(SAME_MD, sameMDPerformsSedation);
patientOver5YrsOld = data.getBooleanExtra(AGE, patientOver5YrsOld);
sedationTime = data.getIntExtra(TIME, sedationTime); | sedationStatus = (SedationStatus) data.getSerializableExtra(SEDATION_STATUS); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ModifierActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
| import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.epstudios.epcoding.Constants.EPCODING;
import androidx.annotation.NonNull;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View; |
LinearLayout checkBoxLayout = findViewById(
R.id.modifiers_checkbox_layout);
code = Codes.getCode(codeNumber);
modifierSet = code.getModifierSet();
List<Modifier> allModifiers = Modifiers.allModifiersSorted();
checkBoxes = new CheckBox[allModifiers.size()];
createCheckBoxLayoutAndModifierMap(allModifiers, checkBoxLayout);
if (savedInstanceState != null) {
boolean[] checkBoxState = savedInstanceState.getBooleanArray("ModifierState");
int i = 0;
for (CheckBox checkBox : checkBoxes) {
checkBox.setChecked(checkBoxState != null && checkBoxState[i++]);
}
}
initToolbar();
Button cancelButton = findViewById(R.id.cancel_button);
cancelButton.setOnClickListener(this);
Button resetButton = findViewById(R.id.reset_button);
resetButton.setOnClickListener(this);
Button saveButton = findViewById(R.id.save_button);
saveButton.setOnClickListener(this);
Button addButton = findViewById(R.id.add_button);
addButton.setOnClickListener(this);
| // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String EPCODING = "EPCODING";
// Path: app/src/main/java/org/epstudios/epcoding/ModifierActivity.java
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.epstudios.epcoding.Constants.EPCODING;
import androidx.annotation.NonNull;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
LinearLayout checkBoxLayout = findViewById(
R.id.modifiers_checkbox_layout);
code = Codes.getCode(codeNumber);
modifierSet = code.getModifierSet();
List<Modifier> allModifiers = Modifiers.allModifiersSorted();
checkBoxes = new CheckBox[allModifiers.size()];
createCheckBoxLayoutAndModifierMap(allModifiers, checkBoxLayout);
if (savedInstanceState != null) {
boolean[] checkBoxState = savedInstanceState.getBooleanArray("ModifierState");
int i = 0;
for (CheckBox checkBox : checkBoxes) {
checkBox.setChecked(checkBoxState != null && checkBoxState[i++]);
}
}
initToolbar();
Button cancelButton = findViewById(R.id.cancel_button);
cancelButton.setOnClickListener(this);
Button resetButton = findViewById(R.id.reset_button);
resetButton.setOnClickListener(this);
Button saveButton = findViewById(R.id.save_button);
saveButton.setOnClickListener(this);
Button addButton = findViewById(R.id.add_button);
addButton.setOnClickListener(this);
| Log.d(EPCODING, "onCreate"); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/SedationActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_TIME = "SEDATION_TIME";
| import android.widget.EditText;
import java.util.List;
import java.util.Locale;
import static org.epstudios.epcoding.Constants.SEDATION_TIME;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox; | Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
final int id = v.getId();
if (id == R.id.calculate_sedation_button) {
calculateSedationTime();
}
else if (id == R.id.no_sedation_button) {
noSedation(returnIntent);
}
else if (id == R.id.add_sedation_button) {
addCodes(returnIntent);
}
else if (id == R.id.cancel_button) {
finish();
}
else {
finish();
}
}
private void calculateSedationTime() {
Intent intent = new Intent(this, SedationTimeCalculator.class);
startActivityForResult(intent, SEDATION_CALCULATOR_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SEDATION_CALCULATOR_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) { | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String SEDATION_TIME = "SEDATION_TIME";
// Path: app/src/main/java/org/epstudios/epcoding/SedationActivity.java
import android.widget.EditText;
import java.util.List;
import java.util.Locale;
import static org.epstudios.epcoding.Constants.SEDATION_TIME;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
final int id = v.getId();
if (id == R.id.calculate_sedation_button) {
calculateSedationTime();
}
else if (id == R.id.no_sedation_button) {
noSedation(returnIntent);
}
else if (id == R.id.add_sedation_button) {
addCodes(returnIntent);
}
else if (id == R.id.cancel_button) {
finish();
}
else {
finish();
}
}
private void calculateSedationTime() {
Intent intent = new Intent(this, SedationTimeCalculator.class);
startActivityForResult(intent, SEDATION_CALCULATOR_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SEDATION_CALCULATOR_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) { | int result = data.getIntExtra(SEDATION_TIME, 0); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
| import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME; | @Override
public void onPageSelected(int position) {
// When changing pages, reset the action bar actions since they
// are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) { | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java
import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME;
@Override
public void onPageSelected(int position) {
// When changing pages, reset the action bar actions since they
// are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) { | sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
| import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME; | // When changing pages, reset the action bar actions since they
// are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus( | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java
import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME;
// When changing pages, reset the action bar actions since they
// are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus( | savedInstanceState.getString(WIZARD_SEDATION_STATUS)); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
| import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME; | // are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus(
savedInstanceState.getString(WIZARD_SEDATION_STATUS)); | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java
import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME;
// are dependent
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus(
savedInstanceState.getString(WIZARD_SEDATION_STATUS)); | sameMD = savedInstanceState.getBoolean(WIZARD_SAME_MD, sameMD); |
mannd/epcoding | app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
| import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME; | // on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus(
savedInstanceState.getString(WIZARD_SEDATION_STATUS));
sameMD = savedInstanceState.getBoolean(WIZARD_SAME_MD, sameMD); | // Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_AGE = "WIZARD_AGE";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SAME_MD = "WIZARD_SAME_MD";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_SEDATION_STATUS = "WIZARD_SEDATION_STATUS";
//
// Path: app/src/main/java/org/epstudios/epcoding/Constants.java
// public final static String WIZARD_TIME = "WIZARD_TIME";
// Path: app/src/main/java/org/epstudios/epcoding/ScreenSlideActivity.java
import android.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.core.app.NavUtils;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import static org.epstudios.epcoding.Constants.WIZARD_AGE;
import static org.epstudios.epcoding.Constants.WIZARD_SAME_MD;
import static org.epstudios.epcoding.Constants.WIZARD_SEDATION_STATUS;
import static org.epstudios.epcoding.Constants.WIZARD_TIME;
// on which page is currently active. An alternative approach is
// to have each
// fragment expose actions itself (rather than the activity
// exposing actions),
// but for simplicity, the activity provides the actions in this
// sample.
invalidateOptionsMenu();
}
});
loadSettings();
Code[] revisionCodes = Codes.getCodes(revisionCodeNumbers);
Code[] removalCodes = Codes.getCodes(removalCodeNumbers);
Code[] addingCodes = Codes.getCodes(addingCodeNumbers);
Code[] finalCodes = Codes.getCodes(Codes.icdReplacementSecondaryCodeNumbers);
List<Code> allCodes = new ArrayList<>();
allCodes.addAll(Arrays.asList(revisionCodes));
allCodes.addAll(Arrays.asList(removalCodes));
allCodes.addAll(Arrays.asList(addingCodes));
allCodes.addAll(Arrays.asList(finalCodes));
if (savedInstanceState != null) {
sedationTime = savedInstanceState.getInt(WIZARD_TIME, sedationTime);
sedationStatus = SedationStatus.stringToSedationStatus(
savedInstanceState.getString(WIZARD_SEDATION_STATUS));
sameMD = savedInstanceState.getBoolean(WIZARD_SAME_MD, sameMD); | ageOver5 = savedInstanceState.getBoolean(WIZARD_AGE, ageOver5); |
mttkay/ignition | ignition-location/ignition-location-lib/src/com/github/ignition/location/tasks/IgnitedLastKnownLocationAsyncTask.java | // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
//
// Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/utils/PlatformSpecificImplementationFactory.java
// public class PlatformSpecificImplementationFactory {
//
// /**
// * Create a new LastLocationFinder instance
// *
// * @param context
// * {@link android.content.Context}
// * @return LastLocationFinder
// */
// public static ILastLocationFinder getLastLocationFinder(Context context) {
// return IgnitedDiagnostics.supportsApiLevel(GINGERBREAD) ? new IgnitedGingerbreadLastLocationFinder(
// context) : new IgnitedLegacyLastLocationFinder(context);
// }
//
// /**
// * Create a new LocationUpdateRequester
// *
// * @param locationManager
// * {@link android.location.LocationManager}
// * @return LocationUpdateRequester
// */
// public static IgnitedAbstractLocationUpdateRequester getLocationUpdateRequester(Context context) {
// LocationManager locationManager = (LocationManager) context
// .getSystemService(LOCATION_SERVICE);
// if (IgnitedDiagnostics.supportsApiLevel(GINGERBREAD)) {
// return new IgnitedGingerbreadLocationUpdateRequester(locationManager);
// } else if (IgnitedDiagnostics.supportsApiLevel(FROYO)) {
// return new IgnitedFroyoLocationUpdateRequester(locationManager);
// } else {
// AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
// return new IgnitedLegacyLocationUpdateRequester(locationManager, alarmManager);
// }
// }
// }
| import android.app.IntentService;
import android.content.Context;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import com.github.ignition.location.IgnitedLocationConstants;
import com.github.ignition.location.annotations.IgnitedLocation;
import com.github.ignition.location.templates.ILastLocationFinder;
import com.github.ignition.location.utils.PlatformSpecificImplementationFactory; | package com.github.ignition.location.tasks;
public class IgnitedLastKnownLocationAsyncTask extends AsyncTask<Boolean, Void, Location> {
private final int locationUpdateDistanceDiff;
private final long locationUpdateInterval;
@SuppressWarnings("unused")
@IgnitedLocation
private Location currentLocation;
private ILastLocationFinder lastLocationFinder;
/**
*
* @param context
* @param locationUpdateDistanceDiff
* @param locationUpdateInterval
*/
public IgnitedLastKnownLocationAsyncTask(Context context, int locationUpdateDistanceDiff,
long locationUpdateInterval) {
this.locationUpdateDistanceDiff = locationUpdateDistanceDiff;
this.locationUpdateInterval = locationUpdateInterval; | // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
//
// Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/utils/PlatformSpecificImplementationFactory.java
// public class PlatformSpecificImplementationFactory {
//
// /**
// * Create a new LastLocationFinder instance
// *
// * @param context
// * {@link android.content.Context}
// * @return LastLocationFinder
// */
// public static ILastLocationFinder getLastLocationFinder(Context context) {
// return IgnitedDiagnostics.supportsApiLevel(GINGERBREAD) ? new IgnitedGingerbreadLastLocationFinder(
// context) : new IgnitedLegacyLastLocationFinder(context);
// }
//
// /**
// * Create a new LocationUpdateRequester
// *
// * @param locationManager
// * {@link android.location.LocationManager}
// * @return LocationUpdateRequester
// */
// public static IgnitedAbstractLocationUpdateRequester getLocationUpdateRequester(Context context) {
// LocationManager locationManager = (LocationManager) context
// .getSystemService(LOCATION_SERVICE);
// if (IgnitedDiagnostics.supportsApiLevel(GINGERBREAD)) {
// return new IgnitedGingerbreadLocationUpdateRequester(locationManager);
// } else if (IgnitedDiagnostics.supportsApiLevel(FROYO)) {
// return new IgnitedFroyoLocationUpdateRequester(locationManager);
// } else {
// AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
// return new IgnitedLegacyLocationUpdateRequester(locationManager, alarmManager);
// }
// }
// }
// Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/tasks/IgnitedLastKnownLocationAsyncTask.java
import android.app.IntentService;
import android.content.Context;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import com.github.ignition.location.IgnitedLocationConstants;
import com.github.ignition.location.annotations.IgnitedLocation;
import com.github.ignition.location.templates.ILastLocationFinder;
import com.github.ignition.location.utils.PlatformSpecificImplementationFactory;
package com.github.ignition.location.tasks;
public class IgnitedLastKnownLocationAsyncTask extends AsyncTask<Boolean, Void, Location> {
private final int locationUpdateDistanceDiff;
private final long locationUpdateInterval;
@SuppressWarnings("unused")
@IgnitedLocation
private Location currentLocation;
private ILastLocationFinder lastLocationFinder;
/**
*
* @param context
* @param locationUpdateDistanceDiff
* @param locationUpdateInterval
*/
public IgnitedLastKnownLocationAsyncTask(Context context, int locationUpdateDistanceDiff,
long locationUpdateInterval) {
this.locationUpdateDistanceDiff = locationUpdateDistanceDiff;
this.locationUpdateInterval = locationUpdateInterval; | this.lastLocationFinder = PlatformSpecificImplementationFactory |
mttkay/ignition | ignition-location/ignition-location-lib/src/com/github/ignition/location/annotations/IgnitedLocationActivity.java | // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.ignition.location.IgnitedLocationConstants; | /* Copyright (c) 2011 Stefano Dacchille
*
* 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.github.ignition.location.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface IgnitedLocationActivity {
/**
* Determines whether to use GPS when requesting location updates or not. Default value is
* {@link IgnitedLocationConstants.USE_GPS_DEFAULT}).
*
* @return true if GPS is used when requesting location updates, false otherwise.
*/ | // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
// Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/annotations/IgnitedLocationActivity.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.ignition.location.IgnitedLocationConstants;
/* Copyright (c) 2011 Stefano Dacchille
*
* 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.github.ignition.location.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface IgnitedLocationActivity {
/**
* Determines whether to use GPS when requesting location updates or not. Default value is
* {@link IgnitedLocationConstants.USE_GPS_DEFAULT}).
*
* @return true if GPS is used when requesting location updates, false otherwise.
*/ | boolean useGps() default IgnitedLocationConstants.USE_GPS_DEFAULT; |
mttkay/ignition | ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/http/IgnitedHttpRequestBase.java | // Path: ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/http/cache/CachedHttpResponse.java
// public static final class ResponseData {
// public ResponseData(int statusCode, byte[] responseBody) {
// this.statusCode = statusCode;
// this.responseBody = responseBody;
// }
//
// private int statusCode;
// private byte[] responseBody;
//
// public int getStatusCode() {
// return statusCode;
// }
//
// public byte[] getResponseBody() {
// return responseBody;
// }
// }
| import android.util.Log;
import com.github.ignition.support.http.cache.CachedHttpResponse.ResponseData;
import com.github.ignition.support.http.cache.HttpResponseCache;
import java.io.IOException;
import java.net.ConnectException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext; | ignitedHttp.setConnectionTimeout(oldConnTimeout);
ignitedHttp.setSocketTimeout(oldSocketTimeout);
}
}
}
// no retries left, crap out with exception
ConnectException ex = new ConnectException();
ex.initCause(cause);
throw ex;
}
private boolean retryRequest(IgnitedHttpRequestRetryHandler retryHandler, IOException cause,
HttpContext context) {
Log.e(IgnitedHttp.LOG_TAG, "Intercepting exception that wasn't handled by HttpClient");
executionCount = Math.max(executionCount, retryHandler.getTimesRetried());
return retryHandler.retryRequest(cause, ++executionCount, context);
}
@Override
public IgnitedHttpResponse handleResponse(HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
if (expectedStatusCodes != null && !expectedStatusCodes.isEmpty()
&& !expectedStatusCodes.contains(status)) {
throw new HttpResponseException(status, "Unexpected status code: " + status);
}
IgnitedHttpResponse bhttpr = new IgnitedHttpResponseImpl(response);
HttpResponseCache responseCache = ignitedHttp.getResponseCache();
if (responseCache != null && bhttpr.getResponseBody() != null) { | // Path: ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/http/cache/CachedHttpResponse.java
// public static final class ResponseData {
// public ResponseData(int statusCode, byte[] responseBody) {
// this.statusCode = statusCode;
// this.responseBody = responseBody;
// }
//
// private int statusCode;
// private byte[] responseBody;
//
// public int getStatusCode() {
// return statusCode;
// }
//
// public byte[] getResponseBody() {
// return responseBody;
// }
// }
// Path: ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/http/IgnitedHttpRequestBase.java
import android.util.Log;
import com.github.ignition.support.http.cache.CachedHttpResponse.ResponseData;
import com.github.ignition.support.http.cache.HttpResponseCache;
import java.io.IOException;
import java.net.ConnectException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
ignitedHttp.setConnectionTimeout(oldConnTimeout);
ignitedHttp.setSocketTimeout(oldSocketTimeout);
}
}
}
// no retries left, crap out with exception
ConnectException ex = new ConnectException();
ex.initCause(cause);
throw ex;
}
private boolean retryRequest(IgnitedHttpRequestRetryHandler retryHandler, IOException cause,
HttpContext context) {
Log.e(IgnitedHttp.LOG_TAG, "Intercepting exception that wasn't handled by HttpClient");
executionCount = Math.max(executionCount, retryHandler.getTimesRetried());
return retryHandler.retryRequest(cause, ++executionCount, context);
}
@Override
public IgnitedHttpResponse handleResponse(HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
if (expectedStatusCodes != null && !expectedStatusCodes.isEmpty()
&& !expectedStatusCodes.contains(status)) {
throw new HttpResponseException(status, "Unexpected status code: " + status);
}
IgnitedHttpResponse bhttpr = new IgnitedHttpResponseImpl(response);
HttpResponseCache responseCache = ignitedHttp.getResponseCache();
if (responseCache != null && bhttpr.getResponseBody() != null) { | ResponseData responseData = new ResponseData(status, bhttpr.getResponseBodyAsBytes()); |
mttkay/ignition | ignition-core/ignition-core-tests/remote-image-view-test/src/test/java/com/github/ignition/core/test/IgnitionCoreTestRunner.java | // Path: ignition-core/ignition-core-tests/remote-image-view-test/src/test/java/com/github/ignition/core/test/shadows/TestShadowProgressBar.java
// @Implements(ProgressBar.class)
// public class TestShadowProgressBar extends ShadowProgressBar {
//
// @Implementation
// public Drawable getIndeterminateDrawable() {
// return new BitmapDrawable();
// }
//
// }
| import java.io.File;
import java.lang.reflect.Method;
import org.junit.runners.model.InitializationError;
import com.github.ignition.core.test.shadows.TestShadowProgressBar;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.RobolectricTestRunner; | package com.github.ignition.core.test;
public class IgnitionCoreTestRunner extends RobolectricTestRunner {
public IgnitionCoreTestRunner(Class<?> testClass) throws InitializationError {
super(testClass, new File("../../ignition-core-samples"));
}
@Override
public void beforeTest(Method method) { | // Path: ignition-core/ignition-core-tests/remote-image-view-test/src/test/java/com/github/ignition/core/test/shadows/TestShadowProgressBar.java
// @Implements(ProgressBar.class)
// public class TestShadowProgressBar extends ShadowProgressBar {
//
// @Implementation
// public Drawable getIndeterminateDrawable() {
// return new BitmapDrawable();
// }
//
// }
// Path: ignition-core/ignition-core-tests/remote-image-view-test/src/test/java/com/github/ignition/core/test/IgnitionCoreTestRunner.java
import java.io.File;
import java.lang.reflect.Method;
import org.junit.runners.model.InitializationError;
import com.github.ignition.core.test.shadows.TestShadowProgressBar;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.RobolectricTestRunner;
package com.github.ignition.core.test;
public class IgnitionCoreTestRunner extends RobolectricTestRunner {
public IgnitionCoreTestRunner(Class<?> testClass) throws InitializationError {
super(testClass, new File("../../ignition-core-samples"));
}
@Override
public void beforeTest(Method method) { | Robolectric.bindShadowClass(TestShadowProgressBar.class); |
mttkay/ignition | ignition-location/ignition-location-lib/src/com/github/ignition/location/receivers/IgnitedPowerStateChangedReceiver.java | // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
| import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import com.github.ignition.location.IgnitedLocationConstants;
| /*
* Copyright 2011 Google Inc.
*
* 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.github.ignition.location.receivers;
/**
* The manifest Receiver is used to detect changes in battery state. When the system broadcasts a
* "Battery Low" warning we turn off the passive location updates to conserve battery when the app
* is in the background.
*
* When the system broadcasts "Battery OK" to indicate the battery has returned to an okay state,
* the passive location updates are resumed.
*/
public class IgnitedPowerStateChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
boolean batteryLow = intent.getAction().equals(Intent.ACTION_BATTERY_LOW);
SharedPreferences prefs = context.getSharedPreferences(
| // Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/IgnitedLocationConstants.java
// public class IgnitedLocationConstants {
// public static final boolean USE_GPS_DEFAULT = true;
// public static final boolean REQUEST_LOCATION_UPDATES_DEFAULT = true;
// // The maximum distance the user should travel between location updates.
// public static final int LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = 100; // meters
// // The maximum time that should pass before the user gets a location update.
// public static final long LOCATION_UPDATES_INTERVAL_DEFAULT = 5 * 60 * 1000; // 5 minutes
// // You will generally want passive location updates to occur less frequently
// // than active updates. You need to balance location freshness with battery
// // life. The location update distance for passive updates.
// public static final int PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT = LOCATION_UPDATES_DISTANCE_DIFF_DEFAULT;
// // The location update time for passive updates
// public static final long PASSIVE_LOCATION_UPDATES_INTERVAL_DEFAULT = LOCATION_UPDATES_INTERVAL_DEFAULT * 3;
// // When the user exits via the back button, do you want to disable passive background updates.
// public static final boolean ENABLE_PASSIVE_LOCATION_UPDATES_DEFAULT = true;
//
// public static final String SHARED_PREFERENCE_FILE = "ignition_location_shared_preference_file";
// public static final String SP_KEY_RUN_ONCE = "sp_key_run_once";
// public static final String SP_KEY_ENABLE_LOCATION_UPDATES = "sp_key_enable_location_updates";
// public static final String SP_KEY_ENABLE_PASSIVE_LOCATION_UPDATES = "sp_key_enable_passive_location_updates";
// public static final String SP_KEY_LOCATION_UPDATES_USE_GPS = "sp_key_location_updates_use_gps";
// public static final String SP_KEY_LOCATION_UPDATES_DISTANCE_DIFF = "sp_location_updates_distance_diff";
// public static final String SP_KEY_LOCATION_UPDATES_INTERVAL = "sp_key_location_updates_interval";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_DISTANCE_DIFF = "sp_passive_location_updates_distance_diff";
// public static final String SP_KEY_PASSIVE_LOCATION_UPDATES_INTERVAL = "sp_key_passive_location_updates_interval";
// public static final String SP_KEY_MIN_BATTERY_LEVEL = "sp_key_min_battery_level";
// public static final String SP_KEY_WAIT_FOR_GPS_FIX_INTERVAL = "sp_key_wait_for_gps_fix_interval";
// public static final String SP_KEY_SHOW_WAIT_FOR_LOCATION_DIALOG = "sp_key_show_wait_for_location_dialog";
//
// public static final String ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED_ACTION";
// public static final String ACTIVE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.ACTIVE_LOCATION_UPDATE_ACTION";
// public static final String UPDATE_LOCATION_UPDATES_CRITERIA_ACTION = "com.github.ignition.location.UPDATE_LOCATION_UPDATES_CRITERIA_ACTION";
//
// public static final String IGNITED_LOCATION_EXTRA = "ignited_location_extra";
// public static final String IGNITED_LAST_LOCATION_EXTRA = "ignited_last_location_extra";
//
// public static final int MIN_BATTERY_LEVEL_FOR_GPS_DEFAULT = 15;
//
// public static final long WAIT_FOR_GPS_FIX_INTERVAL_DEFAULT = 30000; // 30s
//
// public static final boolean SHOW_WAIT_FOR_LOCATION_DIALOG_DEFAULT = true;
// }
// Path: ignition-location/ignition-location-lib/src/com/github/ignition/location/receivers/IgnitedPowerStateChangedReceiver.java
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import com.github.ignition.location.IgnitedLocationConstants;
/*
* Copyright 2011 Google Inc.
*
* 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.github.ignition.location.receivers;
/**
* The manifest Receiver is used to detect changes in battery state. When the system broadcasts a
* "Battery Low" warning we turn off the passive location updates to conserve battery when the app
* is in the background.
*
* When the system broadcasts "Battery OK" to indicate the battery has returned to an okay state,
* the passive location updates are resumed.
*/
public class IgnitedPowerStateChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
boolean batteryLow = intent.getAction().equals(Intent.ACTION_BATTERY_LOW);
SharedPreferences prefs = context.getSharedPreferences(
| IgnitedLocationConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
OpenConext/Mujina | mujina-sp/src/test/java/mujina/sp/UserControllerTest.java | // Path: mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// public abstract class AbstractIntegrationTest {
//
// @Autowired
// protected SpConfiguration spConfiguration;
//
// @LocalServerPort
// protected int serverPort;
//
// @Before
// public void before() throws Exception {
// RestAssured.port = serverPort;
// given()
// .header("Content-Type", "application/json")
// .post("/api/reset")
// .then()
// .statusCode(SC_OK);
// }
//
// protected CookieFilter login() throws IOException {
// CookieFilter cookieFilter = new CookieFilter();
//
// String html = given()
// .filter(cookieFilter)
// .get("/login")
// .getBody().asString();
//
// Matcher matcher = Pattern.compile("name=\"SAMLRequest\" value=\"(.*?)\"").matcher(html);
// matcher.find();
// String samlRequest = new String(Base64.getDecoder().decode(matcher.group(1)));
//
// //Now mimic a response message
// String samlResponse = getIdPSAMLResponse(samlRequest);
// given()
// .formParam("SAMLResponse", Base64.getEncoder().encodeToString(samlResponse.getBytes()))
// .filter(cookieFilter)
// .post("/saml/SSO")
// .then()
// .statusCode(SC_MOVED_TEMPORARILY);
//
// return cookieFilter;
// }
//
// private String getIdPSAMLResponse(String saml) throws IOException {
// Matcher matcher = Pattern.compile("ID=\"(.*?)\"").matcher(saml);
// assertTrue(matcher.find());
//
// //We need the ID of the original request to mimic the real IdP authnResponse
// String inResponseTo = matcher.group(1);
//
// ZonedDateTime date = ZonedDateTime.now();
// String now = date.format(DateTimeFormatter.ISO_INSTANT);
// String samlResponse = IOUtils.toString(new ClassPathResource("saml_response.xml").getInputStream(), Charset.defaultCharset());
//
// samlResponse = samlResponse
// .replaceAll("@@IssueInstant@@", now)
// .replaceAll("@@InResponseTo@@", inResponseTo);
// return samlResponse;
// }
//
// }
| import io.restassured.filter.cookie.CookieFilter;
import mujina.AbstractIntegrationTest;
import org.junit.Test;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_OK;
import static org.hamcrest.core.StringContains.containsString; | package mujina.sp;
@TestPropertySource(properties = {"sp.expires:" + (Integer.MAX_VALUE / 2 - 1), "sp.clock_skew: " + (Integer.MAX_VALUE / 2 - 1)})
@ActiveProfiles(profiles = "test") | // Path: mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// public abstract class AbstractIntegrationTest {
//
// @Autowired
// protected SpConfiguration spConfiguration;
//
// @LocalServerPort
// protected int serverPort;
//
// @Before
// public void before() throws Exception {
// RestAssured.port = serverPort;
// given()
// .header("Content-Type", "application/json")
// .post("/api/reset")
// .then()
// .statusCode(SC_OK);
// }
//
// protected CookieFilter login() throws IOException {
// CookieFilter cookieFilter = new CookieFilter();
//
// String html = given()
// .filter(cookieFilter)
// .get("/login")
// .getBody().asString();
//
// Matcher matcher = Pattern.compile("name=\"SAMLRequest\" value=\"(.*?)\"").matcher(html);
// matcher.find();
// String samlRequest = new String(Base64.getDecoder().decode(matcher.group(1)));
//
// //Now mimic a response message
// String samlResponse = getIdPSAMLResponse(samlRequest);
// given()
// .formParam("SAMLResponse", Base64.getEncoder().encodeToString(samlResponse.getBytes()))
// .filter(cookieFilter)
// .post("/saml/SSO")
// .then()
// .statusCode(SC_MOVED_TEMPORARILY);
//
// return cookieFilter;
// }
//
// private String getIdPSAMLResponse(String saml) throws IOException {
// Matcher matcher = Pattern.compile("ID=\"(.*?)\"").matcher(saml);
// assertTrue(matcher.find());
//
// //We need the ID of the original request to mimic the real IdP authnResponse
// String inResponseTo = matcher.group(1);
//
// ZonedDateTime date = ZonedDateTime.now();
// String now = date.format(DateTimeFormatter.ISO_INSTANT);
// String samlResponse = IOUtils.toString(new ClassPathResource("saml_response.xml").getInputStream(), Charset.defaultCharset());
//
// samlResponse = samlResponse
// .replaceAll("@@IssueInstant@@", now)
// .replaceAll("@@InResponseTo@@", inResponseTo);
// return samlResponse;
// }
//
// }
// Path: mujina-sp/src/test/java/mujina/sp/UserControllerTest.java
import io.restassured.filter.cookie.CookieFilter;
import mujina.AbstractIntegrationTest;
import org.junit.Test;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_OK;
import static org.hamcrest.core.StringContains.containsString;
package mujina.sp;
@TestPropertySource(properties = {"sp.expires:" + (Integer.MAX_VALUE / 2 - 1), "sp.clock_skew: " + (Integer.MAX_VALUE / 2 - 1)})
@ActiveProfiles(profiles = "test") | public class UserControllerTest extends AbstractIntegrationTest { |
OpenConext/Mujina | mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
| import io.restassured.RestAssured;
import io.restassured.filter.cookie.CookieFilter;
import mujina.api.SpConfiguration;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.nio.charset.Charset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY;
import static org.apache.http.HttpStatus.SC_OK;
import static org.junit.Assert.assertTrue; | package mujina;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class AbstractIntegrationTest {
@Autowired | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
// Path: mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java
import io.restassured.RestAssured;
import io.restassured.filter.cookie.CookieFilter;
import mujina.api.SpConfiguration;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.nio.charset.Charset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY;
import static org.apache.http.HttpStatus.SC_OK;
import static org.junit.Assert.assertTrue;
package mujina;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class AbstractIntegrationTest {
@Autowired | protected SpConfiguration spConfiguration; |
OpenConext/Mujina | mujina-idp/src/main/java/mujina/api/IdpConfiguration.java | // Path: mujina-idp/src/main/java/mujina/idp/FederatedUserAuthenticationToken.java
// @Getter
// @Setter
// public class FederatedUserAuthenticationToken extends UsernamePasswordAuthenticationToken {
//
// private Map<String, List<String>> attributes = new TreeMap<>();
//
// public FederatedUserAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
// super(principal, credentials, authorities);
// }
//
// public FederatedUserAuthenticationToken clone() {
// FederatedUserAuthenticationToken clone = new FederatedUserAuthenticationToken(getPrincipal(), getCredentials(), getAuthorities());
// clone.setAttributes(attributes);
// return clone;
// }
// }
| import lombok.Getter;
import lombok.Setter;
import mujina.idp.FederatedUserAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.saml.key.JKSKeyManager;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap; | package mujina.api;
@Getter
@Setter
@Component
public class IdpConfiguration extends SharedConfiguration {
private String defaultEntityId;
private Map<String, List<String>> attributes = new TreeMap<>(); | // Path: mujina-idp/src/main/java/mujina/idp/FederatedUserAuthenticationToken.java
// @Getter
// @Setter
// public class FederatedUserAuthenticationToken extends UsernamePasswordAuthenticationToken {
//
// private Map<String, List<String>> attributes = new TreeMap<>();
//
// public FederatedUserAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
// super(principal, credentials, authorities);
// }
//
// public FederatedUserAuthenticationToken clone() {
// FederatedUserAuthenticationToken clone = new FederatedUserAuthenticationToken(getPrincipal(), getCredentials(), getAuthorities());
// clone.setAttributes(attributes);
// return clone;
// }
// }
// Path: mujina-idp/src/main/java/mujina/api/IdpConfiguration.java
import lombok.Getter;
import lombok.Setter;
import mujina.idp.FederatedUserAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.saml.key.JKSKeyManager;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
package mujina.api;
@Getter
@Setter
@Component
public class IdpConfiguration extends SharedConfiguration {
private String defaultEntityId;
private Map<String, List<String>> attributes = new TreeMap<>(); | private List<FederatedUserAuthenticationToken> users = new ArrayList<>(); |
OpenConext/Mujina | mujina-idp/src/main/java/mujina/api/IdpController.java | // Path: mujina-idp/src/main/java/mujina/idp/FederatedUserAuthenticationToken.java
// @Getter
// @Setter
// public class FederatedUserAuthenticationToken extends UsernamePasswordAuthenticationToken {
//
// private Map<String, List<String>> attributes = new TreeMap<>();
//
// public FederatedUserAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
// super(principal, credentials, authorities);
// }
//
// public FederatedUserAuthenticationToken clone() {
// FederatedUserAuthenticationToken clone = new FederatedUserAuthenticationToken(getPrincipal(), getCredentials(), getAuthorities());
// clone.setAttributes(attributes);
// return clone;
// }
// }
| import mujina.idp.FederatedUserAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.toList; | LOG.info("Request to set attribute {} to {}", name, values);
configuration().getAttributes().put(name, values);
}
@PutMapping("/attributes/{name:.+}/{userName:.+}")
public void setAttributeForUser(@PathVariable String name, @PathVariable String userName,
@RequestBody List<String> values) {
LOG.info("Request to set attribute {} to {} for user {}", name, values, userName);
configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals
(userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " +
"must be created", userName))).getAttributes().put(name, values);
}
@DeleteMapping("/attributes/{name:.+}")
public void removeAttribute(@PathVariable String name) {
LOG.info("Request to remove attribute {}", name);
configuration().getAttributes().remove(name);
}
@DeleteMapping("/attributes/{name:.+}/{userName:.+}")
public void removeAttributeForUser(@PathVariable String name, @PathVariable String userName) {
LOG.info("Request to remove attribute {} for user {}", name, userName);
configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals
(userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " +
"must be created", userName))).getAttributes().remove(name);
}
@PutMapping("/users")
public void addUser(@RequestBody User user) {
LOG.info("Request to add user {}", user); | // Path: mujina-idp/src/main/java/mujina/idp/FederatedUserAuthenticationToken.java
// @Getter
// @Setter
// public class FederatedUserAuthenticationToken extends UsernamePasswordAuthenticationToken {
//
// private Map<String, List<String>> attributes = new TreeMap<>();
//
// public FederatedUserAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
// super(principal, credentials, authorities);
// }
//
// public FederatedUserAuthenticationToken clone() {
// FederatedUserAuthenticationToken clone = new FederatedUserAuthenticationToken(getPrincipal(), getCredentials(), getAuthorities());
// clone.setAttributes(attributes);
// return clone;
// }
// }
// Path: mujina-idp/src/main/java/mujina/api/IdpController.java
import mujina.idp.FederatedUserAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.toList;
LOG.info("Request to set attribute {} to {}", name, values);
configuration().getAttributes().put(name, values);
}
@PutMapping("/attributes/{name:.+}/{userName:.+}")
public void setAttributeForUser(@PathVariable String name, @PathVariable String userName,
@RequestBody List<String> values) {
LOG.info("Request to set attribute {} to {} for user {}", name, values, userName);
configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals
(userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " +
"must be created", userName))).getAttributes().put(name, values);
}
@DeleteMapping("/attributes/{name:.+}")
public void removeAttribute(@PathVariable String name) {
LOG.info("Request to remove attribute {}", name);
configuration().getAttributes().remove(name);
}
@DeleteMapping("/attributes/{name:.+}/{userName:.+}")
public void removeAttributeForUser(@PathVariable String name, @PathVariable String userName) {
LOG.info("Request to remove attribute {} for user {}", name, userName);
configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals
(userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " +
"must be created", userName))).getAttributes().remove(name);
}
@PutMapping("/users")
public void addUser(@RequestBody User user) {
LOG.info("Request to add user {}", user); | FederatedUserAuthenticationToken userAuthenticationToken = new FederatedUserAuthenticationToken( |
OpenConext/Mujina | mujina-idp/src/test/java/mujina/idp/AuthenticationProviderTest.java | // Path: mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// public abstract class AbstractIntegrationTest {
//
// @Autowired
// protected SpConfiguration spConfiguration;
//
// @LocalServerPort
// protected int serverPort;
//
// @Before
// public void before() throws Exception {
// RestAssured.port = serverPort;
// given()
// .header("Content-Type", "application/json")
// .post("/api/reset")
// .then()
// .statusCode(SC_OK);
// }
//
// protected CookieFilter login() throws IOException {
// CookieFilter cookieFilter = new CookieFilter();
//
// String html = given()
// .filter(cookieFilter)
// .get("/login")
// .getBody().asString();
//
// Matcher matcher = Pattern.compile("name=\"SAMLRequest\" value=\"(.*?)\"").matcher(html);
// matcher.find();
// String samlRequest = new String(Base64.getDecoder().decode(matcher.group(1)));
//
// //Now mimic a response message
// String samlResponse = getIdPSAMLResponse(samlRequest);
// given()
// .formParam("SAMLResponse", Base64.getEncoder().encodeToString(samlResponse.getBytes()))
// .filter(cookieFilter)
// .post("/saml/SSO")
// .then()
// .statusCode(SC_MOVED_TEMPORARILY);
//
// return cookieFilter;
// }
//
// private String getIdPSAMLResponse(String saml) throws IOException {
// Matcher matcher = Pattern.compile("ID=\"(.*?)\"").matcher(saml);
// assertTrue(matcher.find());
//
// //We need the ID of the original request to mimic the real IdP authnResponse
// String inResponseTo = matcher.group(1);
//
// ZonedDateTime date = ZonedDateTime.now();
// String now = date.format(DateTimeFormatter.ISO_INSTANT);
// String samlResponse = IOUtils.toString(new ClassPathResource("saml_response.xml").getInputStream(), Charset.defaultCharset());
//
// samlResponse = samlResponse
// .replaceAll("@@IssueInstant@@", now)
// .replaceAll("@@InResponseTo@@", inResponseTo);
// return samlResponse;
// }
//
// }
//
// Path: mujina-idp/src/main/java/mujina/api/AuthenticationMethod.java
// public enum AuthenticationMethod {
// ALL, USER
// }
| import io.restassured.filter.cookie.CookieFilter;
import mujina.AbstractIntegrationTest;
import mujina.api.AuthenticationMethod;
import org.junit.Test;
import org.springframework.test.context.TestPropertySource;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY;
import static org.apache.http.HttpStatus.SC_OK;
import static org.hamcrest.core.StringContains.containsString; | package mujina.idp;
@TestPropertySource(properties = {"idp.expires:" + (Integer.MAX_VALUE / 2 - 1), "idp.clock_skew: " + (Integer.MAX_VALUE / 2 - 1)})
public class AuthenticationProviderTest extends AbstractIntegrationTest {
@Test
public void authenticateAuthMethodAll() throws Exception {
given() | // Path: mujina-sp/src/test/java/mujina/AbstractIntegrationTest.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// public abstract class AbstractIntegrationTest {
//
// @Autowired
// protected SpConfiguration spConfiguration;
//
// @LocalServerPort
// protected int serverPort;
//
// @Before
// public void before() throws Exception {
// RestAssured.port = serverPort;
// given()
// .header("Content-Type", "application/json")
// .post("/api/reset")
// .then()
// .statusCode(SC_OK);
// }
//
// protected CookieFilter login() throws IOException {
// CookieFilter cookieFilter = new CookieFilter();
//
// String html = given()
// .filter(cookieFilter)
// .get("/login")
// .getBody().asString();
//
// Matcher matcher = Pattern.compile("name=\"SAMLRequest\" value=\"(.*?)\"").matcher(html);
// matcher.find();
// String samlRequest = new String(Base64.getDecoder().decode(matcher.group(1)));
//
// //Now mimic a response message
// String samlResponse = getIdPSAMLResponse(samlRequest);
// given()
// .formParam("SAMLResponse", Base64.getEncoder().encodeToString(samlResponse.getBytes()))
// .filter(cookieFilter)
// .post("/saml/SSO")
// .then()
// .statusCode(SC_MOVED_TEMPORARILY);
//
// return cookieFilter;
// }
//
// private String getIdPSAMLResponse(String saml) throws IOException {
// Matcher matcher = Pattern.compile("ID=\"(.*?)\"").matcher(saml);
// assertTrue(matcher.find());
//
// //We need the ID of the original request to mimic the real IdP authnResponse
// String inResponseTo = matcher.group(1);
//
// ZonedDateTime date = ZonedDateTime.now();
// String now = date.format(DateTimeFormatter.ISO_INSTANT);
// String samlResponse = IOUtils.toString(new ClassPathResource("saml_response.xml").getInputStream(), Charset.defaultCharset());
//
// samlResponse = samlResponse
// .replaceAll("@@IssueInstant@@", now)
// .replaceAll("@@InResponseTo@@", inResponseTo);
// return samlResponse;
// }
//
// }
//
// Path: mujina-idp/src/main/java/mujina/api/AuthenticationMethod.java
// public enum AuthenticationMethod {
// ALL, USER
// }
// Path: mujina-idp/src/test/java/mujina/idp/AuthenticationProviderTest.java
import io.restassured.filter.cookie.CookieFilter;
import mujina.AbstractIntegrationTest;
import mujina.api.AuthenticationMethod;
import org.junit.Test;
import org.springframework.test.context.TestPropertySource;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY;
import static org.apache.http.HttpStatus.SC_OK;
import static org.hamcrest.core.StringContains.containsString;
package mujina.idp;
@TestPropertySource(properties = {"idp.expires:" + (Integer.MAX_VALUE / 2 - 1), "idp.clock_skew: " + (Integer.MAX_VALUE / 2 - 1)})
public class AuthenticationProviderTest extends AbstractIntegrationTest {
@Test
public void authenticateAuthMethodAll() throws Exception {
given() | .body(AuthenticationMethod.ALL) |
OpenConext/Mujina | mujina-common/src/main/java/mujina/api/SharedConfiguration.java | // Path: mujina-common/src/main/java/mujina/saml/KeyStoreLocator.java
// public class KeyStoreLocator {
//
// private static CertificateFactory certificateFactory;
//
// static {
// try {
// certificateFactory = CertificateFactory.getInstance("X.509");
// } catch (CertificateException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static KeyStore createKeyStore(String pemPassPhrase) {
// try {
// KeyStore keyStore = KeyStore.getInstance("JKS");
// keyStore.load(null, pemPassPhrase.toCharArray());
// return keyStore;
// } catch (Exception e) {
// //too many exceptions we can't handle, so brute force catch
// throw new RuntimeException(e);
// }
// }
//
// //privateKey must be in the DER unencrypted PKCS#8 format. See README.md
// public static void addPrivateKey(KeyStore keyStore, String alias, String privateKey, String certificate, String password) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, KeyStoreException, CertificateException {
// String wrappedCert = wrapCert(certificate);
// byte[] decodedKey = Base64.getDecoder().decode(privateKey.getBytes());
//
// char[] passwordChars = password.toCharArray();
// Certificate cert = certificateFactory.generateCertificate(new ByteArrayInputStream(wrappedCert.getBytes()));
// ArrayList<Certificate> certs = new ArrayList<>();
// certs.add(cert);
//
// byte[] privKeyBytes = IOUtils.toByteArray(new ByteArrayInputStream(decodedKey));
//
// KeySpec ks = new PKCS8EncodedKeySpec(privKeyBytes);
// RSAPrivateKey privKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(ks);
// keyStore.setKeyEntry(alias, privKey, passwordChars, certs.toArray(new Certificate[certs.size()]));
// }
//
// private static String wrapCert(String certificate) {
// return "-----BEGIN CERTIFICATE-----\n" + certificate + "\n-----END CERTIFICATE-----";
// }
//
// }
| import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import mujina.saml.KeyStoreLocator;
import org.opensaml.xml.Configuration;
import org.opensaml.xml.security.BasicSecurityConfiguration;
import org.opensaml.xml.signature.SignatureConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.saml.key.JKSKeyManager;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableEntryException;
import java.util.Enumeration; | private String defaultSignatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256;
private String signatureAlgorithm;
private String entityId;
public SharedConfiguration(JKSKeyManager keyManager) {
this.keyManager = keyManager;
}
public abstract void reset();
public void setEntityId(String newEntityId, boolean addTokenToStore) {
if (addTokenToStore) {
try {
KeyStore keyStore = keyManager.getKeyStore();
KeyStore.PasswordProtection passwordProtection = new KeyStore.PasswordProtection(keystorePassword.toCharArray());
KeyStore.Entry keyStoreEntry = keyStore.getEntry(this.entityId, passwordProtection);
keyStore.setEntry(newEntityId, keyStoreEntry, passwordProtection);
} catch (KeyStoreException | NoSuchAlgorithmException | UnrecoverableEntryException e) {
throw new RuntimeException(e);
}
}
this.entityId = newEntityId;
}
public void injectCredential(final String certificate, final String pemKey) {
try {
KeyStore keyStore = keyManager.getKeyStore();
if (keyStore.containsAlias(entityId)) {
keyStore.deleteEntry(entityId);
} | // Path: mujina-common/src/main/java/mujina/saml/KeyStoreLocator.java
// public class KeyStoreLocator {
//
// private static CertificateFactory certificateFactory;
//
// static {
// try {
// certificateFactory = CertificateFactory.getInstance("X.509");
// } catch (CertificateException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static KeyStore createKeyStore(String pemPassPhrase) {
// try {
// KeyStore keyStore = KeyStore.getInstance("JKS");
// keyStore.load(null, pemPassPhrase.toCharArray());
// return keyStore;
// } catch (Exception e) {
// //too many exceptions we can't handle, so brute force catch
// throw new RuntimeException(e);
// }
// }
//
// //privateKey must be in the DER unencrypted PKCS#8 format. See README.md
// public static void addPrivateKey(KeyStore keyStore, String alias, String privateKey, String certificate, String password) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, KeyStoreException, CertificateException {
// String wrappedCert = wrapCert(certificate);
// byte[] decodedKey = Base64.getDecoder().decode(privateKey.getBytes());
//
// char[] passwordChars = password.toCharArray();
// Certificate cert = certificateFactory.generateCertificate(new ByteArrayInputStream(wrappedCert.getBytes()));
// ArrayList<Certificate> certs = new ArrayList<>();
// certs.add(cert);
//
// byte[] privKeyBytes = IOUtils.toByteArray(new ByteArrayInputStream(decodedKey));
//
// KeySpec ks = new PKCS8EncodedKeySpec(privKeyBytes);
// RSAPrivateKey privKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(ks);
// keyStore.setKeyEntry(alias, privKey, passwordChars, certs.toArray(new Certificate[certs.size()]));
// }
//
// private static String wrapCert(String certificate) {
// return "-----BEGIN CERTIFICATE-----\n" + certificate + "\n-----END CERTIFICATE-----";
// }
//
// }
// Path: mujina-common/src/main/java/mujina/api/SharedConfiguration.java
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import mujina.saml.KeyStoreLocator;
import org.opensaml.xml.Configuration;
import org.opensaml.xml.security.BasicSecurityConfiguration;
import org.opensaml.xml.signature.SignatureConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.saml.key.JKSKeyManager;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableEntryException;
import java.util.Enumeration;
private String defaultSignatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256;
private String signatureAlgorithm;
private String entityId;
public SharedConfiguration(JKSKeyManager keyManager) {
this.keyManager = keyManager;
}
public abstract void reset();
public void setEntityId(String newEntityId, boolean addTokenToStore) {
if (addTokenToStore) {
try {
KeyStore keyStore = keyManager.getKeyStore();
KeyStore.PasswordProtection passwordProtection = new KeyStore.PasswordProtection(keystorePassword.toCharArray());
KeyStore.Entry keyStoreEntry = keyStore.getEntry(this.entityId, passwordProtection);
keyStore.setEntry(newEntityId, keyStoreEntry, passwordProtection);
} catch (KeyStoreException | NoSuchAlgorithmException | UnrecoverableEntryException e) {
throw new RuntimeException(e);
}
}
this.entityId = newEntityId;
}
public void injectCredential(final String certificate, final String pemKey) {
try {
KeyStore keyStore = keyManager.getKeyStore();
if (keyStore.containsAlias(entityId)) {
keyStore.deleteEntry(entityId);
} | KeyStoreLocator.addPrivateKey(keyStore, entityId, pemKey, certificate, keystorePassword); |
OpenConext/Mujina | mujina-sp/src/main/java/mujina/sp/SAMLConfig.java | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
//
// Path: mujina-common/src/main/java/mujina/saml/UpgradedSAMLBootstrap.java
// public class UpgradedSAMLBootstrap extends SAMLBootstrap {
//
// @Override
// public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
// super.postProcessBeanFactory(beanFactory);
// BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
// config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
// config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
// }
// }
| import mujina.api.SpConfiguration;
import mujina.saml.UpgradedSAMLBootstrap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.velocity.app.VelocityEngine;
import org.opensaml.common.SAMLException;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.binding.encoding.HTTPPostEncoder;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.saml2.core.AuthnRequest;
import org.opensaml.xml.encryption.DecryptionException;
import org.opensaml.xml.parse.ParserPool;
import org.opensaml.xml.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.saml.SAMLBootstrap;
import org.springframework.security.saml.context.SAMLMessageContext;
import org.springframework.security.saml.log.SAMLDefaultLogger;
import org.springframework.security.saml.processor.HTTPArtifactBinding;
import org.springframework.security.saml.processor.HTTPPAOS11Binding;
import org.springframework.security.saml.processor.HTTPPostBinding;
import org.springframework.security.saml.processor.HTTPRedirectDeflateBinding;
import org.springframework.security.saml.processor.HTTPSOAP11Binding;
import org.springframework.security.saml.processor.SAMLBinding;
import org.springframework.security.saml.processor.SAMLProcessor;
import org.springframework.security.saml.websso.ArtifactResolutionProfile;
import org.springframework.security.saml.websso.ArtifactResolutionProfileImpl;
import org.springframework.security.saml.websso.WebSSOProfile;
import org.springframework.security.saml.websso.WebSSOProfileConsumer;
import org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl;
import org.springframework.security.saml.websso.WebSSOProfileConsumerImpl;
import org.springframework.security.saml.websso.WebSSOProfileECPImpl;
import org.springframework.security.saml.websso.WebSSOProfileImpl;
import java.util.ArrayList;
import java.util.Collection; | HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine, "/templates/saml2-post-binding.vm");
HTTPPostDecoder decoder = new HTTPPostDecoder(parserPool);
if (!compareEndpoints) {
decoder.setURIComparator((uri1, uri2) -> true);
}
return new HTTPPostBinding(parserPool, decoder, encoder);
}
@Bean
@Autowired
public HTTPRedirectDeflateBinding httpRedirectDeflateBinding(ParserPool parserPool) {
return new HTTPRedirectDeflateBinding(parserPool);
}
@Bean
@Autowired
public HTTPSOAP11Binding httpSOAP11Binding(ParserPool parserPool) {
return new HTTPSOAP11Binding(parserPool);
}
@Bean
@Autowired
public HTTPPAOS11Binding httpPAOS11Binding(ParserPool parserPool) {
return new HTTPPAOS11Binding(parserPool);
}
@Autowired
@Bean
public SAMLProcessor processor(VelocityEngine velocityEngine,
ParserPool parserPool, | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
//
// Path: mujina-common/src/main/java/mujina/saml/UpgradedSAMLBootstrap.java
// public class UpgradedSAMLBootstrap extends SAMLBootstrap {
//
// @Override
// public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
// super.postProcessBeanFactory(beanFactory);
// BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
// config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
// config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
// }
// }
// Path: mujina-sp/src/main/java/mujina/sp/SAMLConfig.java
import mujina.api.SpConfiguration;
import mujina.saml.UpgradedSAMLBootstrap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.velocity.app.VelocityEngine;
import org.opensaml.common.SAMLException;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.binding.encoding.HTTPPostEncoder;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.saml2.core.AuthnRequest;
import org.opensaml.xml.encryption.DecryptionException;
import org.opensaml.xml.parse.ParserPool;
import org.opensaml.xml.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.saml.SAMLBootstrap;
import org.springframework.security.saml.context.SAMLMessageContext;
import org.springframework.security.saml.log.SAMLDefaultLogger;
import org.springframework.security.saml.processor.HTTPArtifactBinding;
import org.springframework.security.saml.processor.HTTPPAOS11Binding;
import org.springframework.security.saml.processor.HTTPPostBinding;
import org.springframework.security.saml.processor.HTTPRedirectDeflateBinding;
import org.springframework.security.saml.processor.HTTPSOAP11Binding;
import org.springframework.security.saml.processor.SAMLBinding;
import org.springframework.security.saml.processor.SAMLProcessor;
import org.springframework.security.saml.websso.ArtifactResolutionProfile;
import org.springframework.security.saml.websso.ArtifactResolutionProfileImpl;
import org.springframework.security.saml.websso.WebSSOProfile;
import org.springframework.security.saml.websso.WebSSOProfileConsumer;
import org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl;
import org.springframework.security.saml.websso.WebSSOProfileConsumerImpl;
import org.springframework.security.saml.websso.WebSSOProfileECPImpl;
import org.springframework.security.saml.websso.WebSSOProfileImpl;
import java.util.ArrayList;
import java.util.Collection;
HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine, "/templates/saml2-post-binding.vm");
HTTPPostDecoder decoder = new HTTPPostDecoder(parserPool);
if (!compareEndpoints) {
decoder.setURIComparator((uri1, uri2) -> true);
}
return new HTTPPostBinding(parserPool, decoder, encoder);
}
@Bean
@Autowired
public HTTPRedirectDeflateBinding httpRedirectDeflateBinding(ParserPool parserPool) {
return new HTTPRedirectDeflateBinding(parserPool);
}
@Bean
@Autowired
public HTTPSOAP11Binding httpSOAP11Binding(ParserPool parserPool) {
return new HTTPSOAP11Binding(parserPool);
}
@Bean
@Autowired
public HTTPPAOS11Binding httpPAOS11Binding(ParserPool parserPool) {
return new HTTPPAOS11Binding(parserPool);
}
@Autowired
@Bean
public SAMLProcessor processor(VelocityEngine velocityEngine,
ParserPool parserPool, | SpConfiguration spConfiguration, |
OpenConext/Mujina | mujina-sp/src/main/java/mujina/sp/SAMLConfig.java | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
//
// Path: mujina-common/src/main/java/mujina/saml/UpgradedSAMLBootstrap.java
// public class UpgradedSAMLBootstrap extends SAMLBootstrap {
//
// @Override
// public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
// super.postProcessBeanFactory(beanFactory);
// BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
// config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
// config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
// }
// }
| import mujina.api.SpConfiguration;
import mujina.saml.UpgradedSAMLBootstrap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.velocity.app.VelocityEngine;
import org.opensaml.common.SAMLException;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.binding.encoding.HTTPPostEncoder;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.saml2.core.AuthnRequest;
import org.opensaml.xml.encryption.DecryptionException;
import org.opensaml.xml.parse.ParserPool;
import org.opensaml.xml.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.saml.SAMLBootstrap;
import org.springframework.security.saml.context.SAMLMessageContext;
import org.springframework.security.saml.log.SAMLDefaultLogger;
import org.springframework.security.saml.processor.HTTPArtifactBinding;
import org.springframework.security.saml.processor.HTTPPAOS11Binding;
import org.springframework.security.saml.processor.HTTPPostBinding;
import org.springframework.security.saml.processor.HTTPRedirectDeflateBinding;
import org.springframework.security.saml.processor.HTTPSOAP11Binding;
import org.springframework.security.saml.processor.SAMLBinding;
import org.springframework.security.saml.processor.SAMLProcessor;
import org.springframework.security.saml.websso.ArtifactResolutionProfile;
import org.springframework.security.saml.websso.ArtifactResolutionProfileImpl;
import org.springframework.security.saml.websso.WebSSOProfile;
import org.springframework.security.saml.websso.WebSSOProfileConsumer;
import org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl;
import org.springframework.security.saml.websso.WebSSOProfileConsumerImpl;
import org.springframework.security.saml.websso.WebSSOProfileECPImpl;
import org.springframework.security.saml.websso.WebSSOProfileImpl;
import java.util.ArrayList;
import java.util.Collection; | @Bean
@Autowired
public HTTPSOAP11Binding httpSOAP11Binding(ParserPool parserPool) {
return new HTTPSOAP11Binding(parserPool);
}
@Bean
@Autowired
public HTTPPAOS11Binding httpPAOS11Binding(ParserPool parserPool) {
return new HTTPPAOS11Binding(parserPool);
}
@Autowired
@Bean
public SAMLProcessor processor(VelocityEngine velocityEngine,
ParserPool parserPool,
SpConfiguration spConfiguration,
@Value("${sp.compare_endpoints}") boolean compareEndpoints) {
ArtifactResolutionProfile artifactResolutionProfile = new ArtifactResolutionProfileImpl(httpClient());
Collection<SAMLBinding> bindings = new ArrayList<>();
bindings.add(httpRedirectDeflateBinding(parserPool));
bindings.add(httpPostBinding(parserPool, velocityEngine, compareEndpoints));
bindings.add(artifactBinding(parserPool, velocityEngine, artifactResolutionProfile));
bindings.add(httpSOAP11Binding(parserPool));
bindings.add(httpPAOS11Binding(parserPool));
return new ConfigurableSAMLProcessor(bindings, spConfiguration);
}
@Bean
public static SAMLBootstrap sAMLBootstrap() { | // Path: mujina-sp/src/main/java/mujina/api/SpConfiguration.java
// @Component
// @Getter
// @Setter
// public class SpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
//
// private String defaultIdpSSOServiceURL;
// private String idpSSOServiceURL;
// private String defaultProtocolBinding;
// private String protocolBinding;
// private String defaultAssertionConsumerServiceURL;
// private boolean defaultNeedsSigning;
// private String assertionConsumerServiceURL;
// private String spPrivateKey;
// private String spCertificate;
//
// @Autowired
// public SpConfiguration(JKSKeyManager keyManager,
// @Value("${sp.base_url}") String spBaseUrl,
// @Value("${sp.entity_id}") String defaultEntityId,
// @Value("${sp.single_sign_on_service_location}") String defaultIdpSSOServiceURL,
// @Value("${sp.acs_location_path}") String defaultAssertionConsumerServiceURLPath,
// @Value("${sp.protocol_binding}") String defaultProtocolBinding,
// @Value("${sp.private_key}") String spPrivateKey,
// @Value("${sp.certificate}") String spCertificate,
// @Value("${sp.needs_signing}") boolean needsSigning) {
// super(keyManager);
// this.setDefaultEntityId(defaultEntityId);
// this.setDefaultIdpSSOServiceURL(defaultIdpSSOServiceURL);
// this.setDefaultAssertionConsumerServiceURL(spBaseUrl + defaultAssertionConsumerServiceURLPath);
// this.setDefaultProtocolBinding(defaultProtocolBinding);
// this.setSpPrivateKey(spPrivateKey);
// this.setSpCertificate(spCertificate);
// this.setDefaultNeedsSigning(needsSigning);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId, false);
// setNeedsSigning(defaultNeedsSigning);
// resetKeyStore(defaultEntityId, spPrivateKey, spCertificate);
// setIdpSSOServiceURL(defaultIdpSSOServiceURL);
// setProtocolBinding(defaultProtocolBinding);
// setAssertionConsumerServiceURL(defaultAssertionConsumerServiceURL);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// }
//
// Path: mujina-common/src/main/java/mujina/saml/UpgradedSAMLBootstrap.java
// public class UpgradedSAMLBootstrap extends SAMLBootstrap {
//
// @Override
// public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
// super.postProcessBeanFactory(beanFactory);
// BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
// config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
// config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
// }
// }
// Path: mujina-sp/src/main/java/mujina/sp/SAMLConfig.java
import mujina.api.SpConfiguration;
import mujina.saml.UpgradedSAMLBootstrap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.velocity.app.VelocityEngine;
import org.opensaml.common.SAMLException;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.binding.encoding.HTTPPostEncoder;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.saml2.core.AuthnRequest;
import org.opensaml.xml.encryption.DecryptionException;
import org.opensaml.xml.parse.ParserPool;
import org.opensaml.xml.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.saml.SAMLBootstrap;
import org.springframework.security.saml.context.SAMLMessageContext;
import org.springframework.security.saml.log.SAMLDefaultLogger;
import org.springframework.security.saml.processor.HTTPArtifactBinding;
import org.springframework.security.saml.processor.HTTPPAOS11Binding;
import org.springframework.security.saml.processor.HTTPPostBinding;
import org.springframework.security.saml.processor.HTTPRedirectDeflateBinding;
import org.springframework.security.saml.processor.HTTPSOAP11Binding;
import org.springframework.security.saml.processor.SAMLBinding;
import org.springframework.security.saml.processor.SAMLProcessor;
import org.springframework.security.saml.websso.ArtifactResolutionProfile;
import org.springframework.security.saml.websso.ArtifactResolutionProfileImpl;
import org.springframework.security.saml.websso.WebSSOProfile;
import org.springframework.security.saml.websso.WebSSOProfileConsumer;
import org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl;
import org.springframework.security.saml.websso.WebSSOProfileConsumerImpl;
import org.springframework.security.saml.websso.WebSSOProfileECPImpl;
import org.springframework.security.saml.websso.WebSSOProfileImpl;
import java.util.ArrayList;
import java.util.Collection;
@Bean
@Autowired
public HTTPSOAP11Binding httpSOAP11Binding(ParserPool parserPool) {
return new HTTPSOAP11Binding(parserPool);
}
@Bean
@Autowired
public HTTPPAOS11Binding httpPAOS11Binding(ParserPool parserPool) {
return new HTTPPAOS11Binding(parserPool);
}
@Autowired
@Bean
public SAMLProcessor processor(VelocityEngine velocityEngine,
ParserPool parserPool,
SpConfiguration spConfiguration,
@Value("${sp.compare_endpoints}") boolean compareEndpoints) {
ArtifactResolutionProfile artifactResolutionProfile = new ArtifactResolutionProfileImpl(httpClient());
Collection<SAMLBinding> bindings = new ArrayList<>();
bindings.add(httpRedirectDeflateBinding(parserPool));
bindings.add(httpPostBinding(parserPool, velocityEngine, compareEndpoints));
bindings.add(artifactBinding(parserPool, velocityEngine, artifactResolutionProfile));
bindings.add(httpSOAP11Binding(parserPool));
bindings.add(httpPAOS11Binding(parserPool));
return new ConfigurableSAMLProcessor(bindings, spConfiguration);
}
@Bean
public static SAMLBootstrap sAMLBootstrap() { | return new UpgradedSAMLBootstrap(); |
OpenConext/Mujina | mujina-idp/src/test/java/mujina/AbstractIntegrationTest.java | // Path: mujina-idp/src/main/java/mujina/api/IdpConfiguration.java
// @Getter
// @Setter
// @Component
// public class IdpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
// private Map<String, List<String>> attributes = new TreeMap<>();
// private List<FederatedUserAuthenticationToken> users = new ArrayList<>();
// private String acsEndpoint;
// private AuthenticationMethod authenticationMethod;
// private AuthenticationMethod defaultAuthenticationMethod;
// private final String idpPrivateKey;
// private final String idpCertificate;
//
// @Autowired
// public IdpConfiguration(JKSKeyManager keyManager,
// @Value("${idp.entity_id}") String defaultEntityId,
// @Value("${idp.private_key}") String idpPrivateKey,
// @Value("${idp.certificate}") String idpCertificate,
// @Value("${idp.auth_method}") String authMethod) {
// super(keyManager);
// this.defaultEntityId = defaultEntityId;
// this.idpPrivateKey = idpPrivateKey;
// this.idpCertificate = idpCertificate;
// this.defaultAuthenticationMethod = AuthenticationMethod.valueOf(authMethod);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId);
// resetAttributes();
// resetKeyStore(defaultEntityId, idpPrivateKey, idpCertificate);
// resetUsers();
// setAcsEndpoint(null);
// setAuthenticationMethod(this.defaultAuthenticationMethod);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// private void resetUsers() {
// users.clear();
// users.addAll(Arrays.asList(
// new FederatedUserAuthenticationToken("admin", "secret", Arrays.asList(new SimpleGrantedAuthority("ROLE_USER"),
// new SimpleGrantedAuthority("ROLE_ADMIN"))),
// new FederatedUserAuthenticationToken("user", "secret", Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")))));
// }
//
// private void resetAttributes() {
// attributes.clear();
// putAttribute("urn:mace:dir:attribute-def:uid", "john.doe");
// putAttribute("urn:mace:dir:attribute-def:cn", "John Doe");
// putAttribute("urn:mace:dir:attribute-def:givenName", "John");
// putAttribute("urn:mace:dir:attribute-def:sn", "Doe");
// putAttribute("urn:mace:dir:attribute-def:displayName", "John Doe");
// putAttribute("urn:mace:dir:attribute-def:mail", "j.doe@example.com");
// putAttribute("urn:mace:terena.org:attribute-def:schacHomeOrganization", "example.com");
// putAttribute("urn:mace:dir:attribute-def:eduPersonPrincipalName", "j.doe@example.com");
// }
//
// private void putAttribute(String key, String... values) {
// this.attributes.put(key, Arrays.asList(values));
// }
//
// }
| import io.restassured.RestAssured;
import io.restassured.filter.cookie.CookieFilter;
import mujina.api.IdpConfiguration;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_OK; | package mujina;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"idp.auth_method=USER"})
public abstract class AbstractIntegrationTest {
@Autowired | // Path: mujina-idp/src/main/java/mujina/api/IdpConfiguration.java
// @Getter
// @Setter
// @Component
// public class IdpConfiguration extends SharedConfiguration {
//
// private String defaultEntityId;
// private Map<String, List<String>> attributes = new TreeMap<>();
// private List<FederatedUserAuthenticationToken> users = new ArrayList<>();
// private String acsEndpoint;
// private AuthenticationMethod authenticationMethod;
// private AuthenticationMethod defaultAuthenticationMethod;
// private final String idpPrivateKey;
// private final String idpCertificate;
//
// @Autowired
// public IdpConfiguration(JKSKeyManager keyManager,
// @Value("${idp.entity_id}") String defaultEntityId,
// @Value("${idp.private_key}") String idpPrivateKey,
// @Value("${idp.certificate}") String idpCertificate,
// @Value("${idp.auth_method}") String authMethod) {
// super(keyManager);
// this.defaultEntityId = defaultEntityId;
// this.idpPrivateKey = idpPrivateKey;
// this.idpCertificate = idpCertificate;
// this.defaultAuthenticationMethod = AuthenticationMethod.valueOf(authMethod);
// reset();
// }
//
// @Override
// public void reset() {
// setEntityId(defaultEntityId);
// resetAttributes();
// resetKeyStore(defaultEntityId, idpPrivateKey, idpCertificate);
// resetUsers();
// setAcsEndpoint(null);
// setAuthenticationMethod(this.defaultAuthenticationMethod);
// setSignatureAlgorithm(getDefaultSignatureAlgorithm());
// }
//
// private void resetUsers() {
// users.clear();
// users.addAll(Arrays.asList(
// new FederatedUserAuthenticationToken("admin", "secret", Arrays.asList(new SimpleGrantedAuthority("ROLE_USER"),
// new SimpleGrantedAuthority("ROLE_ADMIN"))),
// new FederatedUserAuthenticationToken("user", "secret", Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")))));
// }
//
// private void resetAttributes() {
// attributes.clear();
// putAttribute("urn:mace:dir:attribute-def:uid", "john.doe");
// putAttribute("urn:mace:dir:attribute-def:cn", "John Doe");
// putAttribute("urn:mace:dir:attribute-def:givenName", "John");
// putAttribute("urn:mace:dir:attribute-def:sn", "Doe");
// putAttribute("urn:mace:dir:attribute-def:displayName", "John Doe");
// putAttribute("urn:mace:dir:attribute-def:mail", "j.doe@example.com");
// putAttribute("urn:mace:terena.org:attribute-def:schacHomeOrganization", "example.com");
// putAttribute("urn:mace:dir:attribute-def:eduPersonPrincipalName", "j.doe@example.com");
// }
//
// private void putAttribute(String key, String... values) {
// this.attributes.put(key, Arrays.asList(values));
// }
//
// }
// Path: mujina-idp/src/test/java/mujina/AbstractIntegrationTest.java
import io.restassured.RestAssured;
import io.restassured.filter.cookie.CookieFilter;
import mujina.api.IdpConfiguration;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_OK;
package mujina;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"idp.auth_method=USER"})
public abstract class AbstractIntegrationTest {
@Autowired | protected IdpConfiguration idpConfiguration; |
neo4j/windows-wrapper | src/main/java/com/sun/jna/ptr/NativeLongByReference.java | // Path: src/main/java/com/sun/jna/NativeLong.java
// public class NativeLong extends IntegerType {
// /** Size of a native long, in bytes. */
// public static final int SIZE = Native.LONG_SIZE;
//
// /** Create a zero-valued NativeLong. */
// public NativeLong() {
// this(0);
// }
//
// /** Create a NativeLong with the given value. */
// public NativeLong(long value) {
// super(SIZE, value);
// }
// }
| import com.sun.jna.NativeLong; | /* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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.
*/
package com.sun.jna.ptr;
public class NativeLongByReference extends ByReference {
public NativeLongByReference() { | // Path: src/main/java/com/sun/jna/NativeLong.java
// public class NativeLong extends IntegerType {
// /** Size of a native long, in bytes. */
// public static final int SIZE = Native.LONG_SIZE;
//
// /** Create a zero-valued NativeLong. */
// public NativeLong() {
// this(0);
// }
//
// /** Create a NativeLong with the given value. */
// public NativeLong(long value) {
// super(SIZE, value);
// }
// }
// Path: src/main/java/com/sun/jna/ptr/NativeLongByReference.java
import com.sun.jna.NativeLong;
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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.
*/
package com.sun.jna.ptr;
public class NativeLongByReference extends ByReference {
public NativeLongByReference() { | this(new NativeLong(0)); |
neo4j/windows-wrapper | src/main/java/com/sun/jna/platform/win32/W32Errors.java | // Path: src/main/java/com/sun/jna/platform/win32/WinNT.java
// class HRESULT extends NativeLong {
// public HRESULT() {
//
// }
//
// public HRESULT(int value) {
// super(value);
// }
// }
| import com.sun.jna.platform.win32.WinNT.HRESULT; | //
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
//
// Create an HRESULT value from component pieces
//
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
//
// Map a WIN32 error value into a HRESULT
// Note: This assumes that WIN32 errors fall in the range -32k to=32k.
//
// Define bits here so macros are guaranteed to work
public static final int FACILITY_NT_BIT = 0x10000000;
| // Path: src/main/java/com/sun/jna/platform/win32/WinNT.java
// class HRESULT extends NativeLong {
// public HRESULT() {
//
// }
//
// public HRESULT(int value) {
// super(value);
// }
// }
// Path: src/main/java/com/sun/jna/platform/win32/W32Errors.java
import com.sun.jna.platform.win32.WinNT.HRESULT;
//
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
//
// Create an HRESULT value from component pieces
//
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
//
// Map a WIN32 error value into a HRESULT
// Note: This assumes that WIN32 errors fall in the range -32k to=32k.
//
// Define bits here so macros are guaranteed to work
public static final int FACILITY_NT_BIT = 0x10000000;
| public static final HRESULT HRESULT_FROM_WIN32(int x) { |
neo4j/windows-wrapper | src/main/java/com/sun/jna/platform/win32/WinspoolUtil.java | // Path: src/main/java/com/sun/jna/platform/win32/Winspool.java
// public static class PRINTER_INFO_1 extends Structure {
// public int Flags;
// public String pDescription;
// public String pName;
// public String pComment;
//
// public PRINTER_INFO_1() {
//
// }
//
// public PRINTER_INFO_1(int size) {
// super(new Memory(size));
// }
// }
//
// Path: src/main/java/com/sun/jna/ptr/IntByReference.java
// public class IntByReference extends ByReference {
//
// public IntByReference() {
// this(0);
// }
//
// public IntByReference(int value) {
// super(4);
// setValue(value);
// }
//
// public void setValue(int value) {
// getPointer().setInt(0, value);
// }
//
// public int getValue() {
// return getPointer().getInt(0);
// }
// }
| import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1;
import com.sun.jna.ptr.IntByReference;
| /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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.
*/
package com.sun.jna.platform.win32;
/**
* Winspool Utility API.
* @author dblock[at]dblock.org
*/
public abstract class WinspoolUtil {
public static PRINTER_INFO_1[] getPrinterInfo1() {
| // Path: src/main/java/com/sun/jna/platform/win32/Winspool.java
// public static class PRINTER_INFO_1 extends Structure {
// public int Flags;
// public String pDescription;
// public String pName;
// public String pComment;
//
// public PRINTER_INFO_1() {
//
// }
//
// public PRINTER_INFO_1(int size) {
// super(new Memory(size));
// }
// }
//
// Path: src/main/java/com/sun/jna/ptr/IntByReference.java
// public class IntByReference extends ByReference {
//
// public IntByReference() {
// this(0);
// }
//
// public IntByReference(int value) {
// super(4);
// setValue(value);
// }
//
// public void setValue(int value) {
// getPointer().setInt(0, value);
// }
//
// public int getValue() {
// return getPointer().getInt(0);
// }
// }
// Path: src/main/java/com/sun/jna/platform/win32/WinspoolUtil.java
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1;
import com.sun.jna.ptr.IntByReference;
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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.
*/
package com.sun.jna.platform.win32;
/**
* Winspool Utility API.
* @author dblock[at]dblock.org
*/
public abstract class WinspoolUtil {
public static PRINTER_INFO_1[] getPrinterInfo1() {
| IntByReference pcbNeeded = new IntByReference();
|
neo4j/windows-wrapper | src/main/java/jnacontrib/jna/Options.java | // Path: src/main/java/com/sun/jna/win32/W32APIFunctionMapper.java
// public class W32APIFunctionMapper implements FunctionMapper {
// public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true);
// public static final FunctionMapper ASCII = new W32APIFunctionMapper(false);
// private final String suffix;
// protected W32APIFunctionMapper(boolean unicode) {
// this.suffix = unicode ? "W" : "A";
// }
// /** Looks up the method name by adding a "W" or "A" suffix as appropriate.
// */
// public String getFunctionName(NativeLibrary library, Method method) {
// String name = method.getName();
// if (!name.endsWith("W") && !name.endsWith("A")) {
// try {
// name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName();
// }
// catch(UnsatisfiedLinkError e) {
// // ignore and let caller use undecorated name
// }
// }
// return name;
// }
// }
//
// Path: src/main/java/com/sun/jna/win32/W32APITypeMapper.java
// public class W32APITypeMapper extends DefaultTypeMapper {
//
// public static final TypeMapper UNICODE = new W32APITypeMapper(true);
// public static final TypeMapper ASCII = new W32APITypeMapper(false);
//
// protected W32APITypeMapper(boolean unicode) {
// if (unicode) {
// TypeConverter stringConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// if (value == null)
// return null;
// if (value instanceof String[]) {
// return new StringArray((String[])value, true);
// }
// return new WString(value.toString());
// }
// public Object fromNative(Object value, FromNativeContext context) {
// if (value == null)
// return null;
// return value.toString();
// }
// public Class nativeType() {
// return WString.class;
// }
// };
// addTypeConverter(String.class, stringConverter);
// addToNativeConverter(String[].class, stringConverter);
// }
// TypeConverter booleanConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// return new Integer(Boolean.TRUE.equals(value) ? 1 : 0);
// }
// public Object fromNative(Object value, FromNativeContext context) {
// return ((Integer)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE;
// }
// public Class nativeType() {
// // BOOL is 32-bit int
// return Integer.class;
// }
// };
// addTypeConverter(Boolean.class, booleanConverter);
// }
// }
| import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER;
import static com.sun.jna.Library.OPTION_TYPE_MAPPER;
import java.util.HashMap;
import java.util.Map;
import com.sun.jna.win32.W32APIFunctionMapper;
import com.sun.jna.win32.W32APITypeMapper;
| /*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library 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.
*/
package jnacontrib.jna;
/**
* @author Thomas Boerkel
*/
public interface Options
{
Map<String, Object> UNICODE_OPTIONS = new HashMap<String, Object>()
{
{
| // Path: src/main/java/com/sun/jna/win32/W32APIFunctionMapper.java
// public class W32APIFunctionMapper implements FunctionMapper {
// public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true);
// public static final FunctionMapper ASCII = new W32APIFunctionMapper(false);
// private final String suffix;
// protected W32APIFunctionMapper(boolean unicode) {
// this.suffix = unicode ? "W" : "A";
// }
// /** Looks up the method name by adding a "W" or "A" suffix as appropriate.
// */
// public String getFunctionName(NativeLibrary library, Method method) {
// String name = method.getName();
// if (!name.endsWith("W") && !name.endsWith("A")) {
// try {
// name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName();
// }
// catch(UnsatisfiedLinkError e) {
// // ignore and let caller use undecorated name
// }
// }
// return name;
// }
// }
//
// Path: src/main/java/com/sun/jna/win32/W32APITypeMapper.java
// public class W32APITypeMapper extends DefaultTypeMapper {
//
// public static final TypeMapper UNICODE = new W32APITypeMapper(true);
// public static final TypeMapper ASCII = new W32APITypeMapper(false);
//
// protected W32APITypeMapper(boolean unicode) {
// if (unicode) {
// TypeConverter stringConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// if (value == null)
// return null;
// if (value instanceof String[]) {
// return new StringArray((String[])value, true);
// }
// return new WString(value.toString());
// }
// public Object fromNative(Object value, FromNativeContext context) {
// if (value == null)
// return null;
// return value.toString();
// }
// public Class nativeType() {
// return WString.class;
// }
// };
// addTypeConverter(String.class, stringConverter);
// addToNativeConverter(String[].class, stringConverter);
// }
// TypeConverter booleanConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// return new Integer(Boolean.TRUE.equals(value) ? 1 : 0);
// }
// public Object fromNative(Object value, FromNativeContext context) {
// return ((Integer)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE;
// }
// public Class nativeType() {
// // BOOL is 32-bit int
// return Integer.class;
// }
// };
// addTypeConverter(Boolean.class, booleanConverter);
// }
// }
// Path: src/main/java/jnacontrib/jna/Options.java
import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER;
import static com.sun.jna.Library.OPTION_TYPE_MAPPER;
import java.util.HashMap;
import java.util.Map;
import com.sun.jna.win32.W32APIFunctionMapper;
import com.sun.jna.win32.W32APITypeMapper;
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library 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.
*/
package jnacontrib.jna;
/**
* @author Thomas Boerkel
*/
public interface Options
{
Map<String, Object> UNICODE_OPTIONS = new HashMap<String, Object>()
{
{
| put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
|
neo4j/windows-wrapper | src/main/java/jnacontrib/jna/Options.java | // Path: src/main/java/com/sun/jna/win32/W32APIFunctionMapper.java
// public class W32APIFunctionMapper implements FunctionMapper {
// public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true);
// public static final FunctionMapper ASCII = new W32APIFunctionMapper(false);
// private final String suffix;
// protected W32APIFunctionMapper(boolean unicode) {
// this.suffix = unicode ? "W" : "A";
// }
// /** Looks up the method name by adding a "W" or "A" suffix as appropriate.
// */
// public String getFunctionName(NativeLibrary library, Method method) {
// String name = method.getName();
// if (!name.endsWith("W") && !name.endsWith("A")) {
// try {
// name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName();
// }
// catch(UnsatisfiedLinkError e) {
// // ignore and let caller use undecorated name
// }
// }
// return name;
// }
// }
//
// Path: src/main/java/com/sun/jna/win32/W32APITypeMapper.java
// public class W32APITypeMapper extends DefaultTypeMapper {
//
// public static final TypeMapper UNICODE = new W32APITypeMapper(true);
// public static final TypeMapper ASCII = new W32APITypeMapper(false);
//
// protected W32APITypeMapper(boolean unicode) {
// if (unicode) {
// TypeConverter stringConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// if (value == null)
// return null;
// if (value instanceof String[]) {
// return new StringArray((String[])value, true);
// }
// return new WString(value.toString());
// }
// public Object fromNative(Object value, FromNativeContext context) {
// if (value == null)
// return null;
// return value.toString();
// }
// public Class nativeType() {
// return WString.class;
// }
// };
// addTypeConverter(String.class, stringConverter);
// addToNativeConverter(String[].class, stringConverter);
// }
// TypeConverter booleanConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// return new Integer(Boolean.TRUE.equals(value) ? 1 : 0);
// }
// public Object fromNative(Object value, FromNativeContext context) {
// return ((Integer)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE;
// }
// public Class nativeType() {
// // BOOL is 32-bit int
// return Integer.class;
// }
// };
// addTypeConverter(Boolean.class, booleanConverter);
// }
// }
| import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER;
import static com.sun.jna.Library.OPTION_TYPE_MAPPER;
import java.util.HashMap;
import java.util.Map;
import com.sun.jna.win32.W32APIFunctionMapper;
import com.sun.jna.win32.W32APITypeMapper;
| /*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library 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.
*/
package jnacontrib.jna;
/**
* @author Thomas Boerkel
*/
public interface Options
{
Map<String, Object> UNICODE_OPTIONS = new HashMap<String, Object>()
{
{
put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
| // Path: src/main/java/com/sun/jna/win32/W32APIFunctionMapper.java
// public class W32APIFunctionMapper implements FunctionMapper {
// public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true);
// public static final FunctionMapper ASCII = new W32APIFunctionMapper(false);
// private final String suffix;
// protected W32APIFunctionMapper(boolean unicode) {
// this.suffix = unicode ? "W" : "A";
// }
// /** Looks up the method name by adding a "W" or "A" suffix as appropriate.
// */
// public String getFunctionName(NativeLibrary library, Method method) {
// String name = method.getName();
// if (!name.endsWith("W") && !name.endsWith("A")) {
// try {
// name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName();
// }
// catch(UnsatisfiedLinkError e) {
// // ignore and let caller use undecorated name
// }
// }
// return name;
// }
// }
//
// Path: src/main/java/com/sun/jna/win32/W32APITypeMapper.java
// public class W32APITypeMapper extends DefaultTypeMapper {
//
// public static final TypeMapper UNICODE = new W32APITypeMapper(true);
// public static final TypeMapper ASCII = new W32APITypeMapper(false);
//
// protected W32APITypeMapper(boolean unicode) {
// if (unicode) {
// TypeConverter stringConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// if (value == null)
// return null;
// if (value instanceof String[]) {
// return new StringArray((String[])value, true);
// }
// return new WString(value.toString());
// }
// public Object fromNative(Object value, FromNativeContext context) {
// if (value == null)
// return null;
// return value.toString();
// }
// public Class nativeType() {
// return WString.class;
// }
// };
// addTypeConverter(String.class, stringConverter);
// addToNativeConverter(String[].class, stringConverter);
// }
// TypeConverter booleanConverter = new TypeConverter() {
// public Object toNative(Object value, ToNativeContext context) {
// return new Integer(Boolean.TRUE.equals(value) ? 1 : 0);
// }
// public Object fromNative(Object value, FromNativeContext context) {
// return ((Integer)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE;
// }
// public Class nativeType() {
// // BOOL is 32-bit int
// return Integer.class;
// }
// };
// addTypeConverter(Boolean.class, booleanConverter);
// }
// }
// Path: src/main/java/jnacontrib/jna/Options.java
import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER;
import static com.sun.jna.Library.OPTION_TYPE_MAPPER;
import java.util.HashMap;
import java.util.Map;
import com.sun.jna.win32.W32APIFunctionMapper;
import com.sun.jna.win32.W32APITypeMapper;
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library 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.
*/
package jnacontrib.jna;
/**
* @author Thomas Boerkel
*/
public interface Options
{
Map<String, Object> UNICODE_OPTIONS = new HashMap<String, Object>()
{
{
put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
| put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
| /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* @author xuanjue.hk
* @date 2013-2-25
*/
public class Binding {
private static final String TAG = "Binding-Binding";
private String path;
private DependencyProperty dp;
private DependencyObject dpo;
private Object dataContext;
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* @author xuanjue.hk
* @date 2013-2-25
*/
public class Binding {
private static final String TAG = "Binding-Binding";
private String path;
private DependencyProperty dp;
private DependencyObject dpo;
private Object dataContext;
| private IValueConverter valueConverter;
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
|
/**
* @param valueConverter the valueConverter to set
*/
public void setValueConverter(IValueConverter valueConverter) {
this.valueConverter = valueConverter;
}
public Object getDataContext() {
return dataContext;
}
public void setDependencyProperty(DependencyProperty dp) {
this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
/**
* @param valueConverter the valueConverter to set
*/
public void setValueConverter(IValueConverter valueConverter) {
this.valueConverter = valueConverter;
}
public Object getDataContext() {
return dataContext;
}
public void setDependencyProperty(DependencyProperty dp) {
this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
| BindLog.d(TAG, "OnBindDataContextChanged:\n"
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
|
public Object getDataContext() {
return dataContext;
}
public void setDependencyProperty(DependencyProperty dp) {
this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
public Object getDataContext() {
return dataContext;
}
public void setDependencyProperty(DependencyProperty dp) {
this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
| if (this.dataContext instanceof INotifyPropertyChanged) {
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
| this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
this.dp = dp;
}
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
| ((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(new IPropertyChanged() {
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
| public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(new IPropertyChanged() {
@Override
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
public void setDependencyObject(DependencyObject dpo) {
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(new IPropertyChanged() {
@Override
| public void propertyChanged(Object sender, PropertyChangedEventArgs args) {
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/Binding.java | // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
| this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(new IPropertyChanged() {
@Override
public void propertyChanged(Object sender, PropertyChangedEventArgs args) {
| // Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/Binding.java
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
this.dpo = dpo;
}
public DependencyProperty getDependencyProperty() {
return dp;
}
public DependencyObject getDependencyObject() {
return dpo;
}
public void setDataContext(Object dataContext) {
if (this.dataContext != dataContext) {
BindLog.d(TAG, "OnBindDataContextChanged:\n"
+ "\n propertyName = " + dp.getPropertyName()
+ "\n path = " + path
+ "\n oldDataContext = " + this.dataContext
+ "\n newDataContext = " + dataContext);
// unregister old
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(null);
}
this.dataContext = dataContext;
// register new
if (this.dataContext instanceof INotifyPropertyChanged) {
((INotifyPropertyChanged) this.dataContext).setPropertyChangedListener(new IPropertyChanged() {
@Override
public void propertyChanged(Object sender, PropertyChangedEventArgs args) {
| if (StringUtil.compare(path, args.getName())) {
|
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/BindEngine.java | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import android.content.Context;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil; | /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* Created by hk on 13-12-10.
*/
public class BindEngine {
private static final String TAG = "BindEngine";
private static BindEngine bindEngine;
private static IBindValueSetter bindValueSetter;
private static String propertyDeclareClass = "";
private Context mContext;
public static BindEngine instance() {
if (bindEngine == null) {
bindEngine = new BindEngine();
}
return bindEngine;
}
private BindEngine() {
}
public void init(Context context) {
mContext = context;
}
public Context getContext() {
return mContext;
}
public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
BindEngine.bindValueSetter = bindValueSetter;
}
public static IBindValueSetter getBindValueSetter() {
return bindValueSetter;
}
/**
* @param propertyDeclareClassName
*/
public static void registerPropertyDeclareClass(String propertyDeclareClassName) { | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/BindEngine.java
import android.content.Context;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* Created by hk on 13-12-10.
*/
public class BindEngine {
private static final String TAG = "BindEngine";
private static BindEngine bindEngine;
private static IBindValueSetter bindValueSetter;
private static String propertyDeclareClass = "";
private Context mContext;
public static BindEngine instance() {
if (bindEngine == null) {
bindEngine = new BindEngine();
}
return bindEngine;
}
private BindEngine() {
}
public void init(Context context) {
mContext = context;
}
public Context getContext() {
return mContext;
}
public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
BindEngine.bindValueSetter = bindValueSetter;
}
public static IBindValueSetter getBindValueSetter() {
return bindValueSetter;
}
/**
* @param propertyDeclareClassName
*/
public static void registerPropertyDeclareClass(String propertyDeclareClassName) { | if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) { |
kunka/CoolAndroidBinding | src/com/kk/binding/kernel/BindEngine.java | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import android.content.Context;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil; | /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* Created by hk on 13-12-10.
*/
public class BindEngine {
private static final String TAG = "BindEngine";
private static BindEngine bindEngine;
private static IBindValueSetter bindValueSetter;
private static String propertyDeclareClass = "";
private Context mContext;
public static BindEngine instance() {
if (bindEngine == null) {
bindEngine = new BindEngine();
}
return bindEngine;
}
private BindEngine() {
}
public void init(Context context) {
mContext = context;
}
public Context getContext() {
return mContext;
}
public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
BindEngine.bindValueSetter = bindValueSetter;
}
public static IBindValueSetter getBindValueSetter() {
return bindValueSetter;
}
/**
* @param propertyDeclareClassName
*/
public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
propertyDeclareClass = propertyDeclareClassName; | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/kernel/BindEngine.java
import android.content.Context;
import com.kk.binding.util.BindLog;
import com.kk.binding.util.StringUtil;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.kernel;
/**
* Created by hk on 13-12-10.
*/
public class BindEngine {
private static final String TAG = "BindEngine";
private static BindEngine bindEngine;
private static IBindValueSetter bindValueSetter;
private static String propertyDeclareClass = "";
private Context mContext;
public static BindEngine instance() {
if (bindEngine == null) {
bindEngine = new BindEngine();
}
return bindEngine;
}
private BindEngine() {
}
public void init(Context context) {
mContext = context;
}
public Context getContext() {
return mContext;
}
public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
BindEngine.bindValueSetter = bindValueSetter;
}
public static IBindValueSetter getBindValueSetter() {
return bindValueSetter;
}
/**
* @param propertyDeclareClassName
*/
public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
propertyDeclareClass = propertyDeclareClassName; | BindLog.d(TAG, "registerPropertyDeclareClass: " + propertyDeclareClass); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ListenerImpRegister.java | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister"; | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ListenerImpRegister.java
import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister"; | private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps; |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ListenerImpRegister.java | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() { | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ListenerImpRegister.java
import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() { | register("OnClick", OnClickListenerImp.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ListenerImpRegister.java | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class); | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ListenerImpRegister.java
import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class); | register("OnItemClick", OnItemClickListenerImp.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ListenerImpRegister.java | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class);
register("OnItemClick", OnItemClickListenerImp.class); | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ListenerImpRegister.java
import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class);
register("OnItemClick", OnItemClickListenerImp.class); | register("OnFocusChange", OnFocusChangeListenerImp.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ListenerImpRegister.java | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class);
register("OnItemClick", OnItemClickListenerImp.class);
register("OnFocusChange", OnFocusChangeListenerImp.class);
}
public static void register(String listenerName, Class<? extends ListenerToCommand> listenerImpType) { | // Path: src/com/kk/binding/listener/ListenerToCommand.java
// public abstract class ListenerToCommand {
// private ICommand mCommand;
// private Object param;
//
// public Object getParam() {
// return param;
// }
//
// public void setParam(Object param) {
// this.param = param;
// }
//
// public ICommand getCommand() {
// return mCommand;
// }
//
// public void setCommand(ICommand command) {
// mCommand = command;
// }
//
// public void executeCommand(View view, Object... args) {
// if (mCommand != null)
// try {
// mCommand.execute(view, args);
// } catch (Exception e) {
// BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
// }
// }
//
// public abstract void registerToView(View v);
// }
//
// Path: src/com/kk/binding/listener/OnClickListenerImp.java
// public class OnClickListenerImp extends ListenerToCommand implements View.OnClickListener {
// @Override
// public void registerToView(View v) {
// v.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// executeCommand(v, getParam());
// }
// }
//
// Path: src/com/kk/binding/listener/OnFocusChangeListenerImp.java
// public class OnFocusChangeListenerImp extends ListenerToCommand implements View.OnFocusChangeListener {
// @Override public void registerToView(View v) {
// v.setOnFocusChangeListener(this);
// }
//
// @Override public void onFocusChange(View v, boolean hasFocus) {
// executeCommand(v, hasFocus);
// }
// }
//
// Path: src/com/kk/binding/listener/OnItemClickListenerImp.java
// public class OnItemClickListenerImp extends ListenerToCommand implements OnItemClickListener {
// @Override
// public void registerToView(View v) {
// if (!(v instanceof AdapterView<?>))
// return;
// ((AdapterView<?>) v).setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// executeCommand(arg0, arg1, arg2, arg3);
// }
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ListenerImpRegister.java
import com.kk.binding.listener.ListenerToCommand;
import com.kk.binding.listener.OnClickListenerImp;
import com.kk.binding.listener.OnFocusChangeListenerImp;
import com.kk.binding.listener.OnItemClickListenerImp;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ListenerImpRegister {
private static final String TAG = "Binding-ListenerImpRegister";
private static HashMap<String, Class<? extends ListenerToCommand>> listenerImps;
public static HashMap<String, Class<? extends ListenerToCommand>> getListenerImps() {
if (listenerImps == null) {
listenerImps = new HashMap<String, Class<? extends ListenerToCommand>>(32);
registerInner();
}
return listenerImps;
}
private static void registerInner() {
register("OnClick", OnClickListenerImp.class);
register("OnItemClick", OnItemClickListenerImp.class);
register("OnFocusChange", OnFocusChangeListenerImp.class);
}
public static void register(String listenerName, Class<? extends ListenerToCommand> listenerImpType) { | if (!StringUtil.isNullOrEmpty(listenerName) && listenerImpType != null) |
kunka/CoolAndroidBinding | src/com/kk/binding/command/UrlNavCommand.java | // Path: src/com/kk/binding/kernel/BindEngine.java
// public class BindEngine {
// private static final String TAG = "BindEngine";
// private static BindEngine bindEngine;
// private static IBindValueSetter bindValueSetter;
// private static String propertyDeclareClass = "";
// private Context mContext;
//
// public static BindEngine instance() {
// if (bindEngine == null) {
// bindEngine = new BindEngine();
// }
// return bindEngine;
// }
//
// private BindEngine() {
// }
//
// public void init(Context context) {
// mContext = context;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
// BindEngine.bindValueSetter = bindValueSetter;
// }
//
// public static IBindValueSetter getBindValueSetter() {
// return bindValueSetter;
// }
//
// /**
// * @param propertyDeclareClassName
// */
// public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
// if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
// propertyDeclareClass = propertyDeclareClassName;
// BindLog.d(TAG, "registerPropertyDeclareClass: " + propertyDeclareClass);
// if (!StringUtil.isNullOrEmpty(propertyDeclareClass)) {
// Class<?> clazz = null;
// try {
// clazz = Class.forName(propertyDeclareClass);
// BindLog.d(TAG, "parse propertyDeclareClass success " + clazz.toString());
// } catch (ClassNotFoundException e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("parse propertyDeclareClass failed " + e.toString());
// BindLog.e(TAG, "parse propertyDeclareClass failed " + e.toString());
// }
// if (clazz != null) {
// try {
// Object instance = clazz.newInstance();
// if (instance != null)
// BindLog.d(TAG, "create propertyDeclareClass instance success " + instance.toString());
// } catch (Exception e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("create propertyDeclareClass instance failed " + e.toString());
// BindLog.e(TAG, "create propertyDeclareClass instance failed " + e.toString());
// }
// }
// }
// }
// }
//
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
| import android.content.Intent;
import android.net.Uri;
import android.view.View;
import com.kk.binding.kernel.BindEngine;
import com.kk.binding.util.BindLog; | /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.command;
/**
* Created by hk on 13-12-13.
*/
public class UrlNavCommand implements ICommand {
@Override
public void execute(View view, Object... args) {
if (args.length > 0 && args[0] instanceof String) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse((String) args[0])); | // Path: src/com/kk/binding/kernel/BindEngine.java
// public class BindEngine {
// private static final String TAG = "BindEngine";
// private static BindEngine bindEngine;
// private static IBindValueSetter bindValueSetter;
// private static String propertyDeclareClass = "";
// private Context mContext;
//
// public static BindEngine instance() {
// if (bindEngine == null) {
// bindEngine = new BindEngine();
// }
// return bindEngine;
// }
//
// private BindEngine() {
// }
//
// public void init(Context context) {
// mContext = context;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
// BindEngine.bindValueSetter = bindValueSetter;
// }
//
// public static IBindValueSetter getBindValueSetter() {
// return bindValueSetter;
// }
//
// /**
// * @param propertyDeclareClassName
// */
// public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
// if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
// propertyDeclareClass = propertyDeclareClassName;
// BindLog.d(TAG, "registerPropertyDeclareClass: " + propertyDeclareClass);
// if (!StringUtil.isNullOrEmpty(propertyDeclareClass)) {
// Class<?> clazz = null;
// try {
// clazz = Class.forName(propertyDeclareClass);
// BindLog.d(TAG, "parse propertyDeclareClass success " + clazz.toString());
// } catch (ClassNotFoundException e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("parse propertyDeclareClass failed " + e.toString());
// BindLog.e(TAG, "parse propertyDeclareClass failed " + e.toString());
// }
// if (clazz != null) {
// try {
// Object instance = clazz.newInstance();
// if (instance != null)
// BindLog.d(TAG, "create propertyDeclareClass instance success " + instance.toString());
// } catch (Exception e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("create propertyDeclareClass instance failed " + e.toString());
// BindLog.e(TAG, "create propertyDeclareClass instance failed " + e.toString());
// }
// }
// }
// }
// }
//
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
// Path: src/com/kk/binding/command/UrlNavCommand.java
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import com.kk.binding.kernel.BindEngine;
import com.kk.binding.util.BindLog;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.command;
/**
* Created by hk on 13-12-13.
*/
public class UrlNavCommand implements ICommand {
@Override
public void execute(View view, Object... args) {
if (args.length > 0 && args[0] instanceof String) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse((String) args[0])); | if (BindEngine.instance().getContext() != null) { |
kunka/CoolAndroidBinding | src/com/kk/binding/command/UrlNavCommand.java | // Path: src/com/kk/binding/kernel/BindEngine.java
// public class BindEngine {
// private static final String TAG = "BindEngine";
// private static BindEngine bindEngine;
// private static IBindValueSetter bindValueSetter;
// private static String propertyDeclareClass = "";
// private Context mContext;
//
// public static BindEngine instance() {
// if (bindEngine == null) {
// bindEngine = new BindEngine();
// }
// return bindEngine;
// }
//
// private BindEngine() {
// }
//
// public void init(Context context) {
// mContext = context;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
// BindEngine.bindValueSetter = bindValueSetter;
// }
//
// public static IBindValueSetter getBindValueSetter() {
// return bindValueSetter;
// }
//
// /**
// * @param propertyDeclareClassName
// */
// public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
// if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
// propertyDeclareClass = propertyDeclareClassName;
// BindLog.d(TAG, "registerPropertyDeclareClass: " + propertyDeclareClass);
// if (!StringUtil.isNullOrEmpty(propertyDeclareClass)) {
// Class<?> clazz = null;
// try {
// clazz = Class.forName(propertyDeclareClass);
// BindLog.d(TAG, "parse propertyDeclareClass success " + clazz.toString());
// } catch (ClassNotFoundException e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("parse propertyDeclareClass failed " + e.toString());
// BindLog.e(TAG, "parse propertyDeclareClass failed " + e.toString());
// }
// if (clazz != null) {
// try {
// Object instance = clazz.newInstance();
// if (instance != null)
// BindLog.d(TAG, "create propertyDeclareClass instance success " + instance.toString());
// } catch (Exception e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("create propertyDeclareClass instance failed " + e.toString());
// BindLog.e(TAG, "create propertyDeclareClass instance failed " + e.toString());
// }
// }
// }
// }
// }
//
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
| import android.content.Intent;
import android.net.Uri;
import android.view.View;
import com.kk.binding.kernel.BindEngine;
import com.kk.binding.util.BindLog; | /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.command;
/**
* Created by hk on 13-12-13.
*/
public class UrlNavCommand implements ICommand {
@Override
public void execute(View view, Object... args) {
if (args.length > 0 && args[0] instanceof String) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse((String) args[0]));
if (BindEngine.instance().getContext() != null) {
try {
BindEngine.instance().getContext().startActivity(intent);
} catch (Exception e) { | // Path: src/com/kk/binding/kernel/BindEngine.java
// public class BindEngine {
// private static final String TAG = "BindEngine";
// private static BindEngine bindEngine;
// private static IBindValueSetter bindValueSetter;
// private static String propertyDeclareClass = "";
// private Context mContext;
//
// public static BindEngine instance() {
// if (bindEngine == null) {
// bindEngine = new BindEngine();
// }
// return bindEngine;
// }
//
// private BindEngine() {
// }
//
// public void init(Context context) {
// mContext = context;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public static void setBindValueSetter(IBindValueSetter bindValueSetter) {
// BindEngine.bindValueSetter = bindValueSetter;
// }
//
// public static IBindValueSetter getBindValueSetter() {
// return bindValueSetter;
// }
//
// /**
// * @param propertyDeclareClassName
// */
// public static void registerPropertyDeclareClass(String propertyDeclareClassName) {
// if (!StringUtil.compare(propertyDeclareClass, propertyDeclareClassName)) {
// propertyDeclareClass = propertyDeclareClassName;
// BindLog.d(TAG, "registerPropertyDeclareClass: " + propertyDeclareClass);
// if (!StringUtil.isNullOrEmpty(propertyDeclareClass)) {
// Class<?> clazz = null;
// try {
// clazz = Class.forName(propertyDeclareClass);
// BindLog.d(TAG, "parse propertyDeclareClass success " + clazz.toString());
// } catch (ClassNotFoundException e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("parse propertyDeclareClass failed " + e.toString());
// BindLog.e(TAG, "parse propertyDeclareClass failed " + e.toString());
// }
// if (clazz != null) {
// try {
// Object instance = clazz.newInstance();
// if (instance != null)
// BindLog.d(TAG, "create propertyDeclareClass instance success " + instance.toString());
// } catch (Exception e) {
// if (BindLog.isInDesignMode())
// throw new RuntimeException("create propertyDeclareClass instance failed " + e.toString());
// BindLog.e(TAG, "create propertyDeclareClass instance failed " + e.toString());
// }
// }
// }
// }
// }
//
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
// Path: src/com/kk/binding/command/UrlNavCommand.java
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import com.kk.binding.kernel.BindEngine;
import com.kk.binding.util.BindLog;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.command;
/**
* Created by hk on 13-12-13.
*/
public class UrlNavCommand implements ICommand {
@Override
public void execute(View view, Object... args) {
if (args.length > 0 && args[0] instanceof String) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse((String) args[0]));
if (BindEngine.instance().getContext() != null) {
try {
BindEngine.instance().getContext().startActivity(intent);
} catch (Exception e) { | BindLog.e("UrlNavCommand execute exception ", e.toString()); |
kunka/CoolAndroidBinding | src/com/kk/binding/listener/ListenerToCommand.java | // Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
| import android.view.View;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.BindLog;
| /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.listener;
/**
* @author xuanjue.hk
* @date 2013-2-28
*/
public abstract class ListenerToCommand {
private ICommand mCommand;
private Object param;
public Object getParam() {
return param;
}
public void setParam(Object param) {
this.param = param;
}
public ICommand getCommand() {
return mCommand;
}
public void setCommand(ICommand command) {
mCommand = command;
}
public void executeCommand(View view, Object... args) {
if (mCommand != null)
try {
mCommand.execute(view, args);
} catch (Exception e) {
| // Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
// Path: src/com/kk/binding/listener/ListenerToCommand.java
import android.view.View;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.BindLog;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.listener;
/**
* @author xuanjue.hk
* @date 2013-2-28
*/
public abstract class ListenerToCommand {
private ICommand mCommand;
private Object param;
public Object getParam() {
return param;
}
public void setParam(Object param) {
this.param = param;
}
public ICommand getCommand() {
return mCommand;
}
public void setCommand(ICommand command) {
mCommand = command;
}
public void executeCommand(View view, Object... args) {
if (mCommand != null)
try {
mCommand.execute(view, args);
} catch (Exception e) {
| BindLog.e("ListenerToCommand", "executeCommand failed " + e.toString());
|
kunka/CoolAndroidBinding | src/com/kk/binding/property/NotifyPropertyChanged.java | // Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
| import java.util.ArrayList;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
| /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.property;
/**
* @author xuanjue.hk
* @date 2013-2-25
* */
public abstract class NotifyPropertyChanged implements INotifyPropertyChanged {
protected ArrayList<IPropertyChanged> listeners = new ArrayList<IPropertyChanged>();
public void removeListener(IPropertyChanged listener) {
listeners.remove(listener);
}
@Override
public void setPropertyChangedListener(IPropertyChanged listener) {
listeners.add(listener);
}
protected void raisePropertyChangedEvent(String PropertyName) {
for (IPropertyChanged listener : listeners) {
| // Path: src/com/kk/binding/property/INotifyPropertyChanged.java
// public interface INotifyPropertyChanged {
// public void setPropertyChangedListener(IPropertyChanged listener);
// }
//
// Path: src/com/kk/binding/property/IPropertyChanged.java
// public interface IPropertyChanged {
// public void propertyChanged(Object sender, PropertyChangedEventArgs args);
// }
//
// Path: src/com/kk/binding/property/PropertyChangedEventArgs.java
// public class PropertyChangedEventArgs {
// private String propertyName;
// private Object oldValue;
// private Object newValue;
//
// public PropertyChangedEventArgs(String propertyName) {
// this.propertyName = propertyName;
// }
//
// public PropertyChangedEventArgs(String propertyName, Object oldValue, Object newValue) {
// this.propertyName = propertyName;
// this.oldValue = oldValue;
// this.newValue = newValue;
// }
//
// /**
// * @return the propertyName
// */
// public String getName() {
// return propertyName;
// }
//
// /**
// * @return the oldValue
// */
// public Object getOldValue() {
// return oldValue;
// }
//
// /**
// * @return the newValue
// */
// public Object getNewValue() {
// return newValue;
// }
// }
// Path: src/com/kk/binding/property/NotifyPropertyChanged.java
import java.util.ArrayList;
import com.kk.binding.property.INotifyPropertyChanged;
import com.kk.binding.property.IPropertyChanged;
import com.kk.binding.property.PropertyChangedEventArgs;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.property;
/**
* @author xuanjue.hk
* @date 2013-2-25
* */
public abstract class NotifyPropertyChanged implements INotifyPropertyChanged {
protected ArrayList<IPropertyChanged> listeners = new ArrayList<IPropertyChanged>();
public void removeListener(IPropertyChanged listener) {
listeners.remove(listener);
}
@Override
public void setPropertyChangedListener(IPropertyChanged listener) {
listeners.add(listener);
}
protected void raisePropertyChangedEvent(String PropertyName) {
for (IPropertyChanged listener : listeners) {
| listener.propertyChanged(this, new PropertyChangedEventArgs(PropertyName));
|
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister"; | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister"; | private static HashMap<String, Class<? extends IValueConverter>> converters; |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() { | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() { | register("TrueToVisibleConverter", TrueToVisibleConverter.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class); | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class); | register("FalseToVisibleConverter", FalseToVisibleConverter.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class); | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class); | register("NullToVisibleConverter", NullToVisibleConverter.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class);
register("NullToVisibleConverter", NullToVisibleConverter.class); | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class);
register("NullToVisibleConverter", NullToVisibleConverter.class); | register("NotNullToVisibleConverter", NotNullToVisibleConverter.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/ConverterRegister.java | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class);
register("NullToVisibleConverter", NullToVisibleConverter.class);
register("NotNullToVisibleConverter", NotNullToVisibleConverter.class);
}
public static void register(String converterName, Class<? extends IValueConverter> converterType) { | // Path: src/com/kk/binding/converter/FalseToVisibleConverter.java
// public class FalseToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return (!Boolean.parseBoolean(String.valueOf(source))) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NotNullToVisibleConverter.java
// public class NotNullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source != null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/NullToVisibleConverter.java
// public class NullToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return source == null ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/TrueToVisibleConverter.java
// public class TrueToVisibleConverter implements IValueConverter {
//
// /*
// * (non-Javadoc)
// *
// * @see binding.kernel.IConverter#converter(java.lang.Object)
// */
// @Override
// public Object converter(Object source) {
// return Boolean.parseBoolean(String.valueOf(source)) ? View.VISIBLE : View.GONE;
// }
// }
//
// Path: src/com/kk/binding/converter/IValueConverter.java
// public interface IValueConverter {
// public Object converter(Object source) throws Exception;
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/ConverterRegister.java
import com.kk.binding.converter.FalseToVisibleConverter;
import com.kk.binding.converter.NotNullToVisibleConverter;
import com.kk.binding.converter.NullToVisibleConverter;
import com.kk.binding.converter.TrueToVisibleConverter;
import com.kk.binding.converter.IValueConverter;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-6.
*/
public class ConverterRegister {
private static final String TAG = "Binding-ConverterRegister";
private static HashMap<String, Class<? extends IValueConverter>> converters;
public static HashMap<String, Class<? extends IValueConverter>> getConverters() {
if (converters == null) {
converters = new HashMap<String, Class<? extends IValueConverter>>(32);
registerInner();
}
return converters;
}
private static void registerInner() {
register("TrueToVisibleConverter", TrueToVisibleConverter.class);
register("FalseToVisibleConverter", FalseToVisibleConverter.class);
register("NullToVisibleConverter", NullToVisibleConverter.class);
register("NotNullToVisibleConverter", NotNullToVisibleConverter.class);
}
public static void register(String converterName, Class<? extends IValueConverter> converterType) { | if (!StringUtil.isNullOrEmpty(converterName) && converterType != null) |
kunka/CoolAndroidBinding | src/com/kk/binding/register/MethodCache.java | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
| import com.kk.binding.util.BindLog;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
| /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* @author xuanjue.hk
* @date 2014-1-7
*/
public class MethodCache {
private static final String TAG = "Binding-MethodCache";
private static HashMap<Class<?>, HashMap<String, Method>> methodCache;
private static HashMap<Class<?>, HashMap<String, Method>> getMethodCache() {
if (methodCache == null) {
methodCache = new HashMap<Class<?>, HashMap<String, Method>>(256);
}
return methodCache;
}
public static Method obtain(String methodName, Class<?> clazz) {
HashMap<String, Method> methodHashMap = getMethodCache().get(clazz);
| // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
// Path: src/com/kk/binding/register/MethodCache.java
import com.kk.binding.util.BindLog;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* @author xuanjue.hk
* @date 2014-1-7
*/
public class MethodCache {
private static final String TAG = "Binding-MethodCache";
private static HashMap<Class<?>, HashMap<String, Method>> methodCache;
private static HashMap<Class<?>, HashMap<String, Method>> getMethodCache() {
if (methodCache == null) {
methodCache = new HashMap<Class<?>, HashMap<String, Method>>(256);
}
return methodCache;
}
public static Method obtain(String methodName, Class<?> clazz) {
HashMap<String, Method> methodHashMap = getMethodCache().get(clazz);
| BindLog.d(TAG, "obtain method: methodName = " + methodName
|
kunka/CoolAndroidBinding | src/com/kk/binding/register/CommandRegister.java | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister"; | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/CommandRegister.java
import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister"; | private static HashMap<String, Class<? extends ICommand>> commands; |
kunka/CoolAndroidBinding | src/com/kk/binding/register/CommandRegister.java | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister";
private static HashMap<String, Class<? extends ICommand>> commands;
public static HashMap<String, Class<? extends ICommand>> getCommands() {
if (commands == null) {
commands = new HashMap<String, Class<? extends ICommand>>(32);
initCommandRegisterInner();
}
return commands;
}
private static void initCommandRegisterInner() { | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/CommandRegister.java
import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister";
private static HashMap<String, Class<? extends ICommand>> commands;
public static HashMap<String, Class<? extends ICommand>> getCommands() {
if (commands == null) {
commands = new HashMap<String, Class<? extends ICommand>>(32);
initCommandRegisterInner();
}
return commands;
}
private static void initCommandRegisterInner() { | register("urlNavCommand", UrlNavCommand.class); |
kunka/CoolAndroidBinding | src/com/kk/binding/register/CommandRegister.java | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
| import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap; | /*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister";
private static HashMap<String, Class<? extends ICommand>> commands;
public static HashMap<String, Class<? extends ICommand>> getCommands() {
if (commands == null) {
commands = new HashMap<String, Class<? extends ICommand>>(32);
initCommandRegisterInner();
}
return commands;
}
private static void initCommandRegisterInner() {
register("urlNavCommand", UrlNavCommand.class);
}
public static void register(String commandName, Class<? extends ICommand> commandType) { | // Path: src/com/kk/binding/command/UrlNavCommand.java
// public class UrlNavCommand implements ICommand {
// @Override
// public void execute(View view, Object... args) {
// if (args.length > 0 && args[0] instanceof String) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse((String) args[0]));
// if (BindEngine.instance().getContext() != null) {
// try {
// BindEngine.instance().getContext().startActivity(intent);
// } catch (Exception e) {
// BindLog.e("UrlNavCommand execute exception ", e.toString());
// }
// }
// }
// }
// }
//
// Path: src/com/kk/binding/command/ICommand.java
// public interface ICommand {
// public void execute(View view, Object... args);
// }
//
// Path: src/com/kk/binding/util/StringUtil.java
// public class StringUtil {
// public static boolean isNullOrEmpty(String str) {
// return str == null || str.isEmpty();
// }
//
// public static boolean compare(String str1, String str2) {
// return (str1 == null || str2 == null) ? str1 == str2 : str1.equals(str2);
// }
// }
// Path: src/com/kk/binding/register/CommandRegister.java
import com.kk.binding.command.UrlNavCommand;
import com.kk.binding.command.ICommand;
import com.kk.binding.util.StringUtil;
import java.util.HashMap;
/*
* Copyright (C) 2014 kk-team.com.
*
* 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.kk.binding.register;
/**
* Created by xj on 14-1-1.
*/
public class CommandRegister {
private static final String TAG = "Binding-CommandRegister";
private static HashMap<String, Class<? extends ICommand>> commands;
public static HashMap<String, Class<? extends ICommand>> getCommands() {
if (commands == null) {
commands = new HashMap<String, Class<? extends ICommand>>(32);
initCommandRegisterInner();
}
return commands;
}
private static void initCommandRegisterInner() {
register("urlNavCommand", UrlNavCommand.class);
}
public static void register(String commandName, Class<? extends ICommand> commandType) { | if (!StringUtil.isNullOrEmpty(commandName) && commandType != null) |
kunka/CoolAndroidBinding | src/com/kk/binding/adapter/SimpleListAdapter.java | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.kk.binding.util.BindLog;
import java.util.List;
import java.util.concurrent.TimeUnit; | public int getCount() {
return mData.size();
}
@Override
public Object getItem(int i) {
return mData.get(i);
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public final int getItemViewType(int position) {
return super.getItemViewType(position);
}
@Override
public final int getViewTypeCount() {
return super.getViewTypeCount();
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
if (position < 0 || position > mData.size() - 1)
return convertView;
View v = convertView; | // Path: src/com/kk/binding/util/BindLog.java
// public class BindLog {
// private static boolean inDesignMode = false;
// private static StringBuilder fullLog;
// private static boolean logOpen = true;
//
// public static void d(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.d(tag, log);
// }
// }
//
// public static void i(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.i(tag, log);
// }
// }
//
// public static void v(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.v(tag, log);
// }
// }
//
// public static void e(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.e(tag, log);
// }
// }
//
// public static void w(String tag, String log) {
// if (inDesignMode) {
// designLog(tag, log);
// } else if (logOpen) {
// Log.w(tag, log);
// }
// }
//
// private static void designLog(String tag, String log) {
// if (fullLog != null) {
// fullLog.append("\nTAG: ").append(tag).append(" ");
// fullLog.append(log);
// fullLog.append("\n");
// }
// }
//
// public static void throwDesignLog() {
// if (inDesignMode) {
// throw new RuntimeException(fullLog != null ? fullLog.toString() : null);
// }
// }
//
// public static void setInDesignMode(boolean inDesignMode) {
// BindLog.inDesignMode = inDesignMode;
// if (inDesignMode) {
// fullLog = new StringBuilder(1024 * 10);
// }
// }
//
// public static boolean isInDesignMode() {
// return inDesignMode;
// }
//
// public static void setBindLogOpen(boolean open) {
// logOpen = open;
// }
//
// public static boolean isLogOpen() {
// return logOpen;
// }
// }
// Path: src/com/kk/binding/adapter/SimpleListAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.kk.binding.util.BindLog;
import java.util.List;
import java.util.concurrent.TimeUnit;
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int i) {
return mData.get(i);
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public final int getItemViewType(int position) {
return super.getItemViewType(position);
}
@Override
public final int getViewTypeCount() {
return super.getViewTypeCount();
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
if (position < 0 || position > mData.size() - 1)
return convertView;
View v = convertView; | boolean isLogOpen = BindLog.isLogOpen(); |
kunka/CoolAndroidBinding | src/com/kk/binding/adapter/SimpleBindListAdapter.java | // Path: src/com/kk/binding/view/BindViewUtil.java
// public class BindViewUtil {
// private static final String TAG = "Bind-BindViewUtil";
// private static Converter converter;
//
// private static Converter defaultConverter = new Converter() {
// @Override
// public Object from(String string, Type type) {
// return JSON.parseObject(string);//JSON.parseObject(string, type);
// }
//
// @Override
// public Object from(byte[] data, Type type) {
// return JSON.parseObject(new String(data));//JSON.parseObject(data, type);
// }
// };
//
// public static void setConverter(Converter converter) {
// BindViewUtil.converter = converter;
// }
//
// // for design use
// public static View inflateView(Context context, int layoutId, ViewGroup parent, boolean attachToRoot) {
// injectInflater(context);
// return LayoutInflater.from(context).inflate(layoutId, parent, attachToRoot);
// }
//
// /**
// * inject inflater with our binding view factory
// *
// * @param context
// */
// public static void injectInflater(Context context) {
// LayoutInflater inflater = LayoutInflater.from(context);
// if (inflater.getFactory() == null) {
// BindLog.d(TAG, "did injectInflater");
// ViewFactory factory = new ViewFactory(inflater);
// inflater.setFactory(factory);
// }
// }
//
// public static DependencyObject getDependencyObject(View view) {
// DependencyObject dpo = (DependencyObject) view.getTag(R.id.tag_for_attach_property);
// if (dpo == null) {
// dpo = new DependencyObject();
// dpo.setOriginTarget(view);
// view.setTag(R.id.tag_for_attach_property, dpo);
// }
// return dpo;
// }
//
// public static void setDataContext(View view, String string, Type claszz) {
// IConverter c = converter == null ? defaultConverter : converter;
// Object obj = null;
// try {
// obj = c.from(string, claszz);
// } catch (Exception e) {
//
// }
// setDataContext(view, obj);
// }
//
// public static void setDataContext(View view, byte[] data, Type claszz) {
// IConverter c = converter == null ? defaultConverter : converter;
// Object obj = null;
// try {
// obj = c.from(data, claszz);
// } catch (Exception e) {
//
// }
// setDataContext(view, obj);
// }
//
// private static void setDataContextInner(final View view, final Object dataContext) {
// if (view == null || getBindDataObject(view) == dataContext)
// return;
// // view.toString() will throw exception when you set a view's id in xml
// // BindLog.d(TAG, "setDataContext : view(" + level + ") = \n"
// // + (view.isInEditMode() ? view.getClass().getName() : view.toString())
// // + "\n dataContext= " + (dataContext != null ? dataContext.toString() : null));
// view.setTag(R.id.tag_for_binding_data_object, dataContext);
//
// DependencyObject dpo = getDependencyObject(view);
// boolean handled = dpo.setDataContext(dataContext);
// if (handled) return;
//
// if (view instanceof ViewGroup) {
// Object targetObject = dpo.getResolvedTargetObject();
// ViewGroup vg = (ViewGroup) view;
// int count = vg.getChildCount();
// for (int i = 0; i < count; i++) {
// View v = vg.getChildAt(i);
// setDataContext(v, targetObject);
// }
// }
// }
//
// public static void setDataContext(final View view, final Object dataContext) {
// long start = 0;
// if (BindLog.isLogOpen()) {
// start = System.nanoTime();
// }
//
// setDataContextInner(view, dataContext);
//
// if (BindLog.isLogOpen()) {
// long end = System.nanoTime();
// long delta = TimeUnit.NANOSECONDS.toMillis(end - start);
// BindLog.w(TAG, "setDataContext for view (" + view.getClass().getSimpleName() + "), time(ms) = " + delta);
// }
// }
//
// public static Object getBindDataObject(View view) {
// return view.getTag(R.id.tag_for_binding_data_object);
// }
// }
| import android.content.Context;
import android.view.View;
import com.kk.binding.view.BindViewUtil;
import java.util.Arrays;
import java.util.List; | /*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.adapter;
/**
* Created by xj on 13-7-6.
*/
public class SimpleBindListAdapter extends SimpleListAdapter<Object> {
private static final String TAG = "Binding-SimpleBindListAdapter";
public SimpleBindListAdapter(Context context, int resId, List<Object> data) {
super(context, resId, data);
}
public SimpleBindListAdapter(Context context, int mResId, Object[] obj) {
this(context, mResId, Arrays.asList(obj));
}
@Override protected void onBindData(View view, Object data, int position) { | // Path: src/com/kk/binding/view/BindViewUtil.java
// public class BindViewUtil {
// private static final String TAG = "Bind-BindViewUtil";
// private static Converter converter;
//
// private static Converter defaultConverter = new Converter() {
// @Override
// public Object from(String string, Type type) {
// return JSON.parseObject(string);//JSON.parseObject(string, type);
// }
//
// @Override
// public Object from(byte[] data, Type type) {
// return JSON.parseObject(new String(data));//JSON.parseObject(data, type);
// }
// };
//
// public static void setConverter(Converter converter) {
// BindViewUtil.converter = converter;
// }
//
// // for design use
// public static View inflateView(Context context, int layoutId, ViewGroup parent, boolean attachToRoot) {
// injectInflater(context);
// return LayoutInflater.from(context).inflate(layoutId, parent, attachToRoot);
// }
//
// /**
// * inject inflater with our binding view factory
// *
// * @param context
// */
// public static void injectInflater(Context context) {
// LayoutInflater inflater = LayoutInflater.from(context);
// if (inflater.getFactory() == null) {
// BindLog.d(TAG, "did injectInflater");
// ViewFactory factory = new ViewFactory(inflater);
// inflater.setFactory(factory);
// }
// }
//
// public static DependencyObject getDependencyObject(View view) {
// DependencyObject dpo = (DependencyObject) view.getTag(R.id.tag_for_attach_property);
// if (dpo == null) {
// dpo = new DependencyObject();
// dpo.setOriginTarget(view);
// view.setTag(R.id.tag_for_attach_property, dpo);
// }
// return dpo;
// }
//
// public static void setDataContext(View view, String string, Type claszz) {
// IConverter c = converter == null ? defaultConverter : converter;
// Object obj = null;
// try {
// obj = c.from(string, claszz);
// } catch (Exception e) {
//
// }
// setDataContext(view, obj);
// }
//
// public static void setDataContext(View view, byte[] data, Type claszz) {
// IConverter c = converter == null ? defaultConverter : converter;
// Object obj = null;
// try {
// obj = c.from(data, claszz);
// } catch (Exception e) {
//
// }
// setDataContext(view, obj);
// }
//
// private static void setDataContextInner(final View view, final Object dataContext) {
// if (view == null || getBindDataObject(view) == dataContext)
// return;
// // view.toString() will throw exception when you set a view's id in xml
// // BindLog.d(TAG, "setDataContext : view(" + level + ") = \n"
// // + (view.isInEditMode() ? view.getClass().getName() : view.toString())
// // + "\n dataContext= " + (dataContext != null ? dataContext.toString() : null));
// view.setTag(R.id.tag_for_binding_data_object, dataContext);
//
// DependencyObject dpo = getDependencyObject(view);
// boolean handled = dpo.setDataContext(dataContext);
// if (handled) return;
//
// if (view instanceof ViewGroup) {
// Object targetObject = dpo.getResolvedTargetObject();
// ViewGroup vg = (ViewGroup) view;
// int count = vg.getChildCount();
// for (int i = 0; i < count; i++) {
// View v = vg.getChildAt(i);
// setDataContext(v, targetObject);
// }
// }
// }
//
// public static void setDataContext(final View view, final Object dataContext) {
// long start = 0;
// if (BindLog.isLogOpen()) {
// start = System.nanoTime();
// }
//
// setDataContextInner(view, dataContext);
//
// if (BindLog.isLogOpen()) {
// long end = System.nanoTime();
// long delta = TimeUnit.NANOSECONDS.toMillis(end - start);
// BindLog.w(TAG, "setDataContext for view (" + view.getClass().getSimpleName() + "), time(ms) = " + delta);
// }
// }
//
// public static Object getBindDataObject(View view) {
// return view.getTag(R.id.tag_for_binding_data_object);
// }
// }
// Path: src/com/kk/binding/adapter/SimpleBindListAdapter.java
import android.content.Context;
import android.view.View;
import com.kk.binding.view.BindViewUtil;
import java.util.Arrays;
import java.util.List;
/*
* Copyright (C) 2013 kk-team.com.
*
* 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.kk.binding.adapter;
/**
* Created by xj on 13-7-6.
*/
public class SimpleBindListAdapter extends SimpleListAdapter<Object> {
private static final String TAG = "Binding-SimpleBindListAdapter";
public SimpleBindListAdapter(Context context, int resId, List<Object> data) {
super(context, resId, data);
}
public SimpleBindListAdapter(Context context, int mResId, Object[] obj) {
this(context, mResId, Arrays.asList(obj));
}
@Override protected void onBindData(View view, Object data, int position) { | BindViewUtil.setDataContext(view, data); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/view/activity/settings/SettingsActivity.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/data/local/PreferencesHelper.java
// public class PreferencesHelper extends BasePreferenceUtils {
//
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_NOTIFICATIONS_PREFERENCES = "notifications_preferences";
// private static SharedPreferences mPref;
//
// public PreferencesHelper(Context context) {
// mPref = getSharedPreference(context);
// }
//
// public long getUserId() {
// return mPref.getLong(KEY_USER_ID, 1);
// }
//
// public void setUserId(long userId) {
// mPref.edit().putLong(KEY_USER_ID, userId).apply();
// }
//
// public boolean getNotificationsPrefs() {
// return mPref.getBoolean(KEY_NOTIFICATIONS_PREFERENCES, false);
// }
//
// public void setNotificationsPrefs(boolean acceptsNotifications) {
// mPref.edit().putBoolean(KEY_NOTIFICATIONS_PREFERENCES, acceptsNotifications).apply();
// }
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java
// public abstract class AppActivity extends AppCompatActivity {
//
// private ActivityComponent mComponent;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
// }
//
// protected ActivityComponent getComponent() {
// return mComponent;
// }
//
// protected BaseApplication getApp() {
// return (BaseApplication) getApplicationContext();
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/fragment/preference/MyPreferenceFragment.java
// public class MyPreferenceFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// Preference version = findPreference("version");
// try {
// String versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
// version.setSummary(versionName);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
//
// Preference buttonfeedback = findPreference(getString(R.string.send_feedback));
// buttonfeedback.setOnPreferenceClickListener(preference -> {
// Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "your_email@gmail.com", null));
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.app_name) + " Feedback");
// emailIntent.putExtra(Intent.EXTRA_TEXT, "Write your feedback here...");
// startActivity(Intent.createChooser(emailIntent, "Send email..."));
//
// return true;
// });
// }
//
// }
| import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import net.derohimat.samplebasemvp.data.local.PreferencesHelper;
import net.derohimat.samplebasemvp.view.AppActivity;
import net.derohimat.samplebasemvp.view.fragment.preference.MyPreferenceFragment;
import javax.inject.Inject; | package net.derohimat.samplebasemvp.view.activity.settings;
public class SettingsActivity extends AppActivity {
@Inject | // Path: sample/src/main/java/net/derohimat/samplebasemvp/data/local/PreferencesHelper.java
// public class PreferencesHelper extends BasePreferenceUtils {
//
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_NOTIFICATIONS_PREFERENCES = "notifications_preferences";
// private static SharedPreferences mPref;
//
// public PreferencesHelper(Context context) {
// mPref = getSharedPreference(context);
// }
//
// public long getUserId() {
// return mPref.getLong(KEY_USER_ID, 1);
// }
//
// public void setUserId(long userId) {
// mPref.edit().putLong(KEY_USER_ID, userId).apply();
// }
//
// public boolean getNotificationsPrefs() {
// return mPref.getBoolean(KEY_NOTIFICATIONS_PREFERENCES, false);
// }
//
// public void setNotificationsPrefs(boolean acceptsNotifications) {
// mPref.edit().putBoolean(KEY_NOTIFICATIONS_PREFERENCES, acceptsNotifications).apply();
// }
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java
// public abstract class AppActivity extends AppCompatActivity {
//
// private ActivityComponent mComponent;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
// }
//
// protected ActivityComponent getComponent() {
// return mComponent;
// }
//
// protected BaseApplication getApp() {
// return (BaseApplication) getApplicationContext();
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/fragment/preference/MyPreferenceFragment.java
// public class MyPreferenceFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// Preference version = findPreference("version");
// try {
// String versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
// version.setSummary(versionName);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
//
// Preference buttonfeedback = findPreference(getString(R.string.send_feedback));
// buttonfeedback.setOnPreferenceClickListener(preference -> {
// Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "your_email@gmail.com", null));
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.app_name) + " Feedback");
// emailIntent.putExtra(Intent.EXTRA_TEXT, "Write your feedback here...");
// startActivity(Intent.createChooser(emailIntent, "Send email..."));
//
// return true;
// });
// }
//
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/activity/settings/SettingsActivity.java
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import net.derohimat.samplebasemvp.data.local.PreferencesHelper;
import net.derohimat.samplebasemvp.view.AppActivity;
import net.derohimat.samplebasemvp.view.fragment.preference.MyPreferenceFragment;
import javax.inject.Inject;
package net.derohimat.samplebasemvp.view.activity.settings;
public class SettingsActivity extends AppActivity {
@Inject | PreferencesHelper preferencesHelper; |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/view/activity/settings/SettingsActivity.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/data/local/PreferencesHelper.java
// public class PreferencesHelper extends BasePreferenceUtils {
//
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_NOTIFICATIONS_PREFERENCES = "notifications_preferences";
// private static SharedPreferences mPref;
//
// public PreferencesHelper(Context context) {
// mPref = getSharedPreference(context);
// }
//
// public long getUserId() {
// return mPref.getLong(KEY_USER_ID, 1);
// }
//
// public void setUserId(long userId) {
// mPref.edit().putLong(KEY_USER_ID, userId).apply();
// }
//
// public boolean getNotificationsPrefs() {
// return mPref.getBoolean(KEY_NOTIFICATIONS_PREFERENCES, false);
// }
//
// public void setNotificationsPrefs(boolean acceptsNotifications) {
// mPref.edit().putBoolean(KEY_NOTIFICATIONS_PREFERENCES, acceptsNotifications).apply();
// }
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java
// public abstract class AppActivity extends AppCompatActivity {
//
// private ActivityComponent mComponent;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
// }
//
// protected ActivityComponent getComponent() {
// return mComponent;
// }
//
// protected BaseApplication getApp() {
// return (BaseApplication) getApplicationContext();
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/fragment/preference/MyPreferenceFragment.java
// public class MyPreferenceFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// Preference version = findPreference("version");
// try {
// String versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
// version.setSummary(versionName);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
//
// Preference buttonfeedback = findPreference(getString(R.string.send_feedback));
// buttonfeedback.setOnPreferenceClickListener(preference -> {
// Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "your_email@gmail.com", null));
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.app_name) + " Feedback");
// emailIntent.putExtra(Intent.EXTRA_TEXT, "Write your feedback here...");
// startActivity(Intent.createChooser(emailIntent, "Send email..."));
//
// return true;
// });
// }
//
// }
| import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import net.derohimat.samplebasemvp.data.local.PreferencesHelper;
import net.derohimat.samplebasemvp.view.AppActivity;
import net.derohimat.samplebasemvp.view.fragment.preference.MyPreferenceFragment;
import javax.inject.Inject; | package net.derohimat.samplebasemvp.view.activity.settings;
public class SettingsActivity extends AppActivity {
@Inject
PreferencesHelper preferencesHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getComponent().inject(this); | // Path: sample/src/main/java/net/derohimat/samplebasemvp/data/local/PreferencesHelper.java
// public class PreferencesHelper extends BasePreferenceUtils {
//
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_NOTIFICATIONS_PREFERENCES = "notifications_preferences";
// private static SharedPreferences mPref;
//
// public PreferencesHelper(Context context) {
// mPref = getSharedPreference(context);
// }
//
// public long getUserId() {
// return mPref.getLong(KEY_USER_ID, 1);
// }
//
// public void setUserId(long userId) {
// mPref.edit().putLong(KEY_USER_ID, userId).apply();
// }
//
// public boolean getNotificationsPrefs() {
// return mPref.getBoolean(KEY_NOTIFICATIONS_PREFERENCES, false);
// }
//
// public void setNotificationsPrefs(boolean acceptsNotifications) {
// mPref.edit().putBoolean(KEY_NOTIFICATIONS_PREFERENCES, acceptsNotifications).apply();
// }
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java
// public abstract class AppActivity extends AppCompatActivity {
//
// private ActivityComponent mComponent;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
// }
//
// protected ActivityComponent getComponent() {
// return mComponent;
// }
//
// protected BaseApplication getApp() {
// return (BaseApplication) getApplicationContext();
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/fragment/preference/MyPreferenceFragment.java
// public class MyPreferenceFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.settings);
//
// Preference version = findPreference("version");
// try {
// String versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
// version.setSummary(versionName);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
//
// Preference buttonfeedback = findPreference(getString(R.string.send_feedback));
// buttonfeedback.setOnPreferenceClickListener(preference -> {
// Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "your_email@gmail.com", null));
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.app_name) + " Feedback");
// emailIntent.putExtra(Intent.EXTRA_TEXT, "Write your feedback here...");
// startActivity(Intent.createChooser(emailIntent, "Send email..."));
//
// return true;
// });
// }
//
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/activity/settings/SettingsActivity.java
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import net.derohimat.samplebasemvp.data.local.PreferencesHelper;
import net.derohimat.samplebasemvp.view.AppActivity;
import net.derohimat.samplebasemvp.view.fragment.preference.MyPreferenceFragment;
import javax.inject.Inject;
package net.derohimat.samplebasemvp.view.activity.settings;
public class SettingsActivity extends AppActivity {
@Inject
PreferencesHelper preferencesHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getComponent().inject(this); | getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit(); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/view/MvpActivity.java | // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ActivityComponent.java
// @ActivityScope
// @Component(dependencies = ApplicationComponent.class)
// public interface ActivityComponent extends ApplicationComponent {
//
// void inject(MainActivity mainActivity);
//
// void inject(SettingsActivity settingsActivity);
// }
| import android.os.Bundle;
import net.derohimat.baseapp.ui.BaseActivity;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.di.component.ActivityComponent;
import net.derohimat.samplebasemvp.di.component.DaggerActivityComponent; | package net.derohimat.samplebasemvp.view;
public abstract class MvpActivity extends BaseActivity {
private ActivityComponent mComponent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
}
protected ActivityComponent getComponent() {
return mComponent;
}
| // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ActivityComponent.java
// @ActivityScope
// @Component(dependencies = ApplicationComponent.class)
// public interface ActivityComponent extends ApplicationComponent {
//
// void inject(MainActivity mainActivity);
//
// void inject(SettingsActivity settingsActivity);
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/MvpActivity.java
import android.os.Bundle;
import net.derohimat.baseapp.ui.BaseActivity;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.di.component.ActivityComponent;
import net.derohimat.samplebasemvp.di.component.DaggerActivityComponent;
package net.derohimat.samplebasemvp.view;
public abstract class MvpActivity extends BaseActivity {
private ActivityComponent mComponent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
}
protected ActivityComponent getComponent() {
return mComponent;
}
| protected BaseApplication getApp() { |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/data/remote/UnauthorisedInterceptor.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
| import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import javax.inject.Inject;
import okhttp3.Interceptor;
import okhttp3.Response; | package net.derohimat.samplebasemvp.data.remote;
public class UnauthorisedInterceptor implements Interceptor {
@Inject
EventBus eventBus;
public UnauthorisedInterceptor(Context context) { | // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/data/remote/UnauthorisedInterceptor.java
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import javax.inject.Inject;
import okhttp3.Interceptor;
import okhttp3.Response;
package net.derohimat.samplebasemvp.data.remote;
public class UnauthorisedInterceptor implements Interceptor {
@Inject
EventBus eventBus;
public UnauthorisedInterceptor(Context context) { | BaseApplication.get(context).getApplicationComponent().inject(this); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/data/remote/UnauthorisedInterceptor.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
| import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import javax.inject.Inject;
import okhttp3.Interceptor;
import okhttp3.Response; | package net.derohimat.samplebasemvp.data.remote;
public class UnauthorisedInterceptor implements Interceptor {
@Inject
EventBus eventBus;
public UnauthorisedInterceptor(Context context) {
BaseApplication.get(context).getApplicationComponent().inject(this);
}
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
if (response.code() == 401) { | // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/data/remote/UnauthorisedInterceptor.java
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import javax.inject.Inject;
import okhttp3.Interceptor;
import okhttp3.Response;
package net.derohimat.samplebasemvp.data.remote;
public class UnauthorisedInterceptor implements Interceptor {
@Inject
EventBus eventBus;
public UnauthorisedInterceptor(Context context) {
BaseApplication.get(context).getApplicationComponent().inject(this);
}
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
if (response.code() == 401) { | new Handler(Looper.getMainLooper()).post(() -> eventBus.post(new AuthenticationErrorEvent())); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber; | package net.derohimat.samplebasemvp;
public class BaseApplication extends Application {
@Inject
EventBus mEventBus;
private Scheduler mScheduler; | // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber;
package net.derohimat.samplebasemvp;
public class BaseApplication extends Application {
@Inject
EventBus mEventBus;
private Scheduler mScheduler; | private ApplicationComponent mApplicationComponent; |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber; | package net.derohimat.samplebasemvp;
public class BaseApplication extends Application {
@Inject
EventBus mEventBus;
private Scheduler mScheduler;
private ApplicationComponent mApplicationComponent;
public static BaseApplication get(Context context) {
return (BaseApplication) context.getApplicationContext();
}
@Override
public void onCreate() {
super.onCreate();
boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
if (isDebuggable) {
Timber.plant(new Timber.DebugTree());
}
| // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber;
package net.derohimat.samplebasemvp;
public class BaseApplication extends Application {
@Inject
EventBus mEventBus;
private Scheduler mScheduler;
private ApplicationComponent mApplicationComponent;
public static BaseApplication get(Context context) {
return (BaseApplication) context.getApplicationContext();
}
@Override
public void onCreate() {
super.onCreate();
boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
if (isDebuggable) {
Timber.plant(new Timber.DebugTree());
}
| mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build(); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber; |
public ApplicationComponent getApplicationComponent() {
return mApplicationComponent;
}
@VisibleForTesting
public void setApplicationComponent(ApplicationComponent applicationComponent) {
this.mApplicationComponent = applicationComponent;
}
public Scheduler getSubscribeScheduler() {
if (mScheduler == null) {
mScheduler = Schedulers.io();
}
return mScheduler;
}
@Override
public void onLowMemory() {
super.onLowMemory();
Timber.e("########## onLowMemory ##########");
}
@Override
public void onTerminate() {
mEventBus.unregister(this);
super.onTerminate();
}
@Subscribe | // Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {ApplicationModule.class})
// public interface ApplicationComponent {
//
// void inject(MainPresenter mainPresenter);
//
// void inject(DetailPresenter detailPresenter);
//
// void inject(BaseApplication baseApplication);
//
// void inject(UnauthorisedInterceptor unauthorisedInterceptor);
//
// APIService apiService();
//
// EventBus eventBus();
//
// PreferencesHelper prefsHelper();
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final BaseApplication mBaseApplication;
//
// public ApplicationModule(BaseApplication baseApplication) {
// this.mBaseApplication = baseApplication;
// }
//
// @Provides
// @Singleton
// public BaseApplication provideApplication() {
// return mBaseApplication;
// }
//
// @Provides
// @Singleton
// public APIService provideApiService() {
// return APIService.Factory.create(mBaseApplication);
// }
//
// @Provides
// @Singleton
// public EventBus eventBus() {
// return new EventBus();
// }
//
// @Provides
// @Singleton
// public PreferencesHelper prefsHelper() {
// return new PreferencesHelper(mBaseApplication);
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/events/AuthenticationErrorEvent.java
// public class AuthenticationErrorEvent {
// public AuthenticationErrorEvent() {
// }
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.support.annotation.VisibleForTesting;
import net.derohimat.samplebasemvp.di.component.ApplicationComponent;
import net.derohimat.samplebasemvp.di.component.DaggerApplicationComponent;
import net.derohimat.samplebasemvp.di.module.ApplicationModule;
import net.derohimat.samplebasemvp.events.AuthenticationErrorEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import timber.log.Timber;
public ApplicationComponent getApplicationComponent() {
return mApplicationComponent;
}
@VisibleForTesting
public void setApplicationComponent(ApplicationComponent applicationComponent) {
this.mApplicationComponent = applicationComponent;
}
public Scheduler getSubscribeScheduler() {
if (mScheduler == null) {
mScheduler = Schedulers.io();
}
return mScheduler;
}
@Override
public void onLowMemory() {
super.onLowMemory();
Timber.e("########## onLowMemory ##########");
}
@Override
public void onTerminate() {
mEventBus.unregister(this);
super.onTerminate();
}
@Subscribe | public void onEvent(AuthenticationErrorEvent event) { |
derohimat/android-base-mvp | library/src/main/java/net/derohimat/baseapp/ui/adapter/viewholder/BaseItemViewHolder.java | // Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnItemClickListener {
// void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnLongItemClickListener {
// void onLongItemClick(View view, int position);
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import butterknife.ButterKnife;
import timber.log.Timber;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnItemClickListener;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnLongItemClickListener; | package net.derohimat.baseapp.ui.adapter.viewholder;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseItemViewHolder<Data> extends RecyclerView.ViewHolder implements
View.OnClickListener,
View.OnLongClickListener {
protected Context mContext; | // Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnItemClickListener {
// void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnLongItemClickListener {
// void onLongItemClick(View view, int position);
// }
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/viewholder/BaseItemViewHolder.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import butterknife.ButterKnife;
import timber.log.Timber;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnItemClickListener;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnLongItemClickListener;
package net.derohimat.baseapp.ui.adapter.viewholder;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseItemViewHolder<Data> extends RecyclerView.ViewHolder implements
View.OnClickListener,
View.OnLongClickListener {
protected Context mContext; | private OnItemClickListener mItemClickListener; |
derohimat/android-base-mvp | library/src/main/java/net/derohimat/baseapp/ui/adapter/viewholder/BaseItemViewHolder.java | // Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnItemClickListener {
// void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnLongItemClickListener {
// void onLongItemClick(View view, int position);
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import butterknife.ButterKnife;
import timber.log.Timber;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnItemClickListener;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnLongItemClickListener; | package net.derohimat.baseapp.ui.adapter.viewholder;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseItemViewHolder<Data> extends RecyclerView.ViewHolder implements
View.OnClickListener,
View.OnLongClickListener {
protected Context mContext;
private OnItemClickListener mItemClickListener; | // Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnItemClickListener {
// void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/BaseRecyclerAdapter.java
// public interface OnLongItemClickListener {
// void onLongItemClick(View view, int position);
// }
// Path: library/src/main/java/net/derohimat/baseapp/ui/adapter/viewholder/BaseItemViewHolder.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import butterknife.ButterKnife;
import timber.log.Timber;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnItemClickListener;
import static net.derohimat.baseapp.ui.adapter.BaseRecyclerAdapter.OnLongItemClickListener;
package net.derohimat.baseapp.ui.adapter.viewholder;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseItemViewHolder<Data> extends RecyclerView.ViewHolder implements
View.OnClickListener,
View.OnLongClickListener {
protected Context mContext;
private OnItemClickListener mItemClickListener; | private OnLongItemClickListener mLongItemClickListener; |
derohimat/android-base-mvp | library/src/main/java/net/derohimat/baseapp/ui/fragment/BaseFragment.java | // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
| import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import net.derohimat.baseapp.ui.BaseActivity;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import timber.log.Timber; | this.mData = data;
}
protected abstract int getResourceLayout();
protected abstract void onViewReady(@Nullable Bundle savedInstanceState);
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable("mDatas", mData);
super.onSaveInstanceState(outState);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onDestroy() {
mData = null;
super.onDestroy();
}
protected void showToast(String message) {
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
}
protected ActionBar getSupportActionBar() { | // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
// Path: library/src/main/java/net/derohimat/baseapp/ui/fragment/BaseFragment.java
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import net.derohimat.baseapp.ui.BaseActivity;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import timber.log.Timber;
this.mData = data;
}
protected abstract int getResourceLayout();
protected abstract void onViewReady(@Nullable Bundle savedInstanceState);
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable("mDatas", mData);
super.onSaveInstanceState(outState);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onDestroy() {
mData = null;
super.onDestroy();
}
protected void showToast(String message) {
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
}
protected ActionBar getSupportActionBar() { | return ((BaseActivity) getActivity()).getSupportActionBar(); |
derohimat/android-base-mvp | sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java | // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ActivityComponent.java
// @ActivityScope
// @Component(dependencies = ApplicationComponent.class)
// public interface ActivityComponent extends ApplicationComponent {
//
// void inject(MainActivity mainActivity);
//
// void inject(SettingsActivity settingsActivity);
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.di.component.ActivityComponent;
import net.derohimat.samplebasemvp.di.component.DaggerActivityComponent; | package net.derohimat.samplebasemvp.view;
public abstract class AppActivity extends AppCompatActivity {
private ActivityComponent mComponent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
}
protected ActivityComponent getComponent() {
return mComponent;
}
| // Path: sample/src/main/java/net/derohimat/samplebasemvp/BaseApplication.java
// public class BaseApplication extends Application {
//
// @Inject
// EventBus mEventBus;
// private Scheduler mScheduler;
// private ApplicationComponent mApplicationComponent;
//
// public static BaseApplication get(Context context) {
// return (BaseApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
//
// if (isDebuggable) {
// Timber.plant(new Timber.DebugTree());
// }
//
// mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
//
// mApplicationComponent.inject(this);
// mEventBus.register(this);
// }
//
// public ApplicationComponent getApplicationComponent() {
// return mApplicationComponent;
// }
//
// @VisibleForTesting
// public void setApplicationComponent(ApplicationComponent applicationComponent) {
// this.mApplicationComponent = applicationComponent;
// }
//
// public Scheduler getSubscribeScheduler() {
// if (mScheduler == null) {
// mScheduler = Schedulers.io();
// }
// return mScheduler;
// }
//
// @Override
// public void onLowMemory() {
// super.onLowMemory();
// Timber.e("########## onLowMemory ##########");
// }
//
// @Override
// public void onTerminate() {
// mEventBus.unregister(this);
// super.onTerminate();
// }
//
// @Subscribe
// public void onEvent(AuthenticationErrorEvent event) {
// Timber.e("Unauthorized! Redirect to Signin Activity..!.");
// }
//
// }
//
// Path: sample/src/main/java/net/derohimat/samplebasemvp/di/component/ActivityComponent.java
// @ActivityScope
// @Component(dependencies = ApplicationComponent.class)
// public interface ActivityComponent extends ApplicationComponent {
//
// void inject(MainActivity mainActivity);
//
// void inject(SettingsActivity settingsActivity);
// }
// Path: sample/src/main/java/net/derohimat/samplebasemvp/view/AppActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import net.derohimat.samplebasemvp.BaseApplication;
import net.derohimat.samplebasemvp.di.component.ActivityComponent;
import net.derohimat.samplebasemvp.di.component.DaggerActivityComponent;
package net.derohimat.samplebasemvp.view;
public abstract class AppActivity extends AppCompatActivity {
private ActivityComponent mComponent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mComponent = DaggerActivityComponent.builder().applicationComponent(getApp().getApplicationComponent()).build();
}
protected ActivityComponent getComponent() {
return mComponent;
}
| protected BaseApplication getApp() { |
derohimat/android-base-mvp | library/src/main/java/net/derohimat/baseapp/ui/fragment/dialog/BaseDialogFragment.java | // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
| import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Toast;
import net.derohimat.baseapp.ui.BaseActivity;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import timber.log.Timber; | package net.derohimat.baseapp.ui.fragment.dialog;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseDialogFragment extends DialogFragment {
protected Context mContext;
protected LayoutInflater mInflater;
private Unbinder unbinder;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mContext = activity;
mInflater = LayoutInflater.from(mContext);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = mInflater.inflate(getResourceLayout(), null);
unbinder = ButterKnife.bind(this, view);
Timber.tag(getClass().getSimpleName());
return setupDialog(view);
}
protected Dialog setupDialog(View view) {
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x4000));
return dialog;
}
protected abstract int getResourceLayout();
| // Path: library/src/main/java/net/derohimat/baseapp/ui/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// protected Context mContext = this;
// protected Toolbar mToolbar;
// protected LayoutInflater mInflater;
//
// protected ActionBar mActionBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(getResourceLayout());
// ButterKnife.bind(this);
// Timber.tag(getClass().getSimpleName());
// mInflater = LayoutInflater.from(mContext);
// onViewReady(savedInstanceState);
// }
//
// public FragmentManager getBaseFragmentManager() {
// return super.getSupportFragmentManager();
// }
//
// protected void setupToolbar(final Toolbar toolbar) {
// setupToolbar(toolbar, null);
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// protected void setupToolbar(final Toolbar toolbar, final View.OnClickListener onClickListener) {
//
// mToolbar = toolbar;
// setSupportActionBar(toolbar);
// mActionBar = getSupportActionBar();
// if (mActionBar != null)
// mActionBar.setHomeButtonEnabled(true);
//
// if (onClickListener != null)
// toolbar.setNavigationOnClickListener(onClickListener);
// }
//
// public Toolbar getToolbar() {
// return mToolbar;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// onBackPressed();
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
// }
//
// @Override
// public void setTitle(int title) {
// super.setTitle(title);
// if (mActionBar != null)
// mActionBar.setTitle(getString(title));
// }
//
// public ActionBar getBaseActionBar() {
// ActionBar actionBar = getSupportActionBar();
// assert actionBar != null;
// return actionBar;
// }
//
// @Override
// public void onBackPressed() {
// if (getBaseFragmentManager().getBackStackEntryCount() > 0) {
// getBaseFragmentManager().popBackStack();
// } else {
// super.onBackPressed();
// }
// }
//
// protected void showToast(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
// }
//
// protected abstract int getResourceLayout();
//
// protected abstract void onViewReady(Bundle savedInstanceState);
// }
// Path: library/src/main/java/net/derohimat/baseapp/ui/fragment/dialog/BaseDialogFragment.java
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Toast;
import net.derohimat.baseapp.ui.BaseActivity;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import timber.log.Timber;
package net.derohimat.baseapp.ui.fragment.dialog;
/**
* Created on : 05-03-2016
* Author : derohimat
* Name : Deni Rohimat
* Email : rohimatdeni@gmail.com
* GitHub : https://github.com/derohimat
* LinkedIn : https://www.linkedin.com/in/derohimat
*/
public abstract class BaseDialogFragment extends DialogFragment {
protected Context mContext;
protected LayoutInflater mInflater;
private Unbinder unbinder;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mContext = activity;
mInflater = LayoutInflater.from(mContext);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = mInflater.inflate(getResourceLayout(), null);
unbinder = ButterKnife.bind(this, view);
Timber.tag(getClass().getSimpleName());
return setupDialog(view);
}
protected Dialog setupDialog(View view) {
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x4000));
return dialog;
}
protected abstract int getResourceLayout();
| protected BaseActivity getBaseActivity() { |
RalleYTN/SimpleAudio | src/main/java/de/ralleytn/simple/audio/AbstractAudio.java | // Path: src/main/java/de/ralleytn/simple/audio/internal/VorbisInputStream.java
// public class VorbisInputStream extends InputStream {
//
// private VorbisStream source;
//
// /**
// * @param source the instance of {@linkplain VorbisStream} to wrap
// * @since 1.2.2
// */
// public VorbisInputStream(VorbisStream source) {
//
// this.source = source;
// }
//
// @Override
// public int read(byte[] buffer) throws IOException {
//
// return this.read(buffer, 0, buffer.length);
// }
//
// @Override
// public int read(byte[] buffer, int offset, int length) throws IOException {
//
// try {
//
// return this.source.readPcm(buffer, offset, length);
//
// // catch is empty because this code was copied and throwing a RuntimeException could break it
// } catch(EndOfOggStreamException exception) {}
//
// return -1;
// }
//
// @Override
// public int read() throws IOException {
//
// return 0;
// }
//
// /**
// * @return the {@linkplain AudioFormat} of the wrapped {@linkplain VorbisStream}.
// * @since 1.2.2
// */
// public AudioFormat getAudioFormat() {
//
// return new AudioFormat(this.source.getIdentificationHeader().getSampleRate(), 16, this.source.getIdentificationHeader().getChannels(), true, true);
// }
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.EnumControl;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import de.jarnbjo.ogg.LogicalOggStream;
import de.jarnbjo.ogg.OnDemandUrlStream;
import de.jarnbjo.vorbis.VorbisStream;
import de.ralleytn.simple.audio.internal.VorbisInputStream; |
/**
* @param resource the resource from which you want the {@linkplain AudioInputStream} from
* @return the {@linkplain AudioInputStream} from the resource
* @throws AudioException if something went wrong while retrieving the {@linkplain AudioInputStream}
* @since 1.1.0
*/
public static AudioInputStream getAudioInputStream(URL resource) throws AudioException {
AudioInputStream audioInputStream = null;
FileFormat fileFormat = FileFormat.getFormatByName(resource.toExternalForm());
try {
switch(fileFormat) {
case MP3:
audioInputStream = AudioSystem.getAudioInputStream(resource);
AudioFormat baseFormat = audioInputStream.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16,baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
audioInputStream = AudioSystem.getAudioInputStream(decodedFormat, audioInputStream);
break;
case OGG:
LogicalOggStream loggs = (LogicalOggStream)new OnDemandUrlStream(resource).getLogicalStreams().iterator().next();
if(!loggs.getFormat().equals(LogicalOggStream.FORMAT_VORBIS)) {
throw new AudioException("Not a plain Ogg/Vorbis audio file!");
}
| // Path: src/main/java/de/ralleytn/simple/audio/internal/VorbisInputStream.java
// public class VorbisInputStream extends InputStream {
//
// private VorbisStream source;
//
// /**
// * @param source the instance of {@linkplain VorbisStream} to wrap
// * @since 1.2.2
// */
// public VorbisInputStream(VorbisStream source) {
//
// this.source = source;
// }
//
// @Override
// public int read(byte[] buffer) throws IOException {
//
// return this.read(buffer, 0, buffer.length);
// }
//
// @Override
// public int read(byte[] buffer, int offset, int length) throws IOException {
//
// try {
//
// return this.source.readPcm(buffer, offset, length);
//
// // catch is empty because this code was copied and throwing a RuntimeException could break it
// } catch(EndOfOggStreamException exception) {}
//
// return -1;
// }
//
// @Override
// public int read() throws IOException {
//
// return 0;
// }
//
// /**
// * @return the {@linkplain AudioFormat} of the wrapped {@linkplain VorbisStream}.
// * @since 1.2.2
// */
// public AudioFormat getAudioFormat() {
//
// return new AudioFormat(this.source.getIdentificationHeader().getSampleRate(), 16, this.source.getIdentificationHeader().getChannels(), true, true);
// }
// }
// Path: src/main/java/de/ralleytn/simple/audio/AbstractAudio.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.EnumControl;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import de.jarnbjo.ogg.LogicalOggStream;
import de.jarnbjo.ogg.OnDemandUrlStream;
import de.jarnbjo.vorbis.VorbisStream;
import de.ralleytn.simple.audio.internal.VorbisInputStream;
/**
* @param resource the resource from which you want the {@linkplain AudioInputStream} from
* @return the {@linkplain AudioInputStream} from the resource
* @throws AudioException if something went wrong while retrieving the {@linkplain AudioInputStream}
* @since 1.1.0
*/
public static AudioInputStream getAudioInputStream(URL resource) throws AudioException {
AudioInputStream audioInputStream = null;
FileFormat fileFormat = FileFormat.getFormatByName(resource.toExternalForm());
try {
switch(fileFormat) {
case MP3:
audioInputStream = AudioSystem.getAudioInputStream(resource);
AudioFormat baseFormat = audioInputStream.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16,baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
audioInputStream = AudioSystem.getAudioInputStream(decodedFormat, audioInputStream);
break;
case OGG:
LogicalOggStream loggs = (LogicalOggStream)new OnDemandUrlStream(resource).getLogicalStreams().iterator().next();
if(!loggs.getFormat().equals(LogicalOggStream.FORMAT_VORBIS)) {
throw new AudioException("Not a plain Ogg/Vorbis audio file!");
}
| VorbisInputStream vis = new VorbisInputStream(new VorbisStream(loggs)); |
quake0day/Jigglypuff | DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/stopcollaboratelisten/Encoder.java | // Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/reedsolomon/CRCGen.java
// public class CRCGen implements Settings {
//
// /*
// * Reads in a sequence of bytes and returns its 16 bit Cylcic Redundancy
// * Check (CRC-CCIIT 0xFFFF).
// *
// * 1 + x + x^5 + x^12 + x^16 is irreducible polynomial.
// *
// * Copyright 2000Ð2011, Robert Sedgewick and Kevin Wayne
// * source: http://introcs.cs.princeton.edu/java/51data/CRC16CCITT.java.html
// */
// public static int crc_16_ccitt(byte[] msg, int len) {
// int crc = 0xFFFF; // initial value
// int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
//
// boolean bit, c15;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c15 = ((crc >> 15 & 1) == 1);
// crc <<= 1;
// if (c15 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return crc;
// }
//
// /* Computes the CRC-8-CCITT checksum on array of byte data, length len */
// public static byte crc_8_ccitt(byte[] msg, int len) {
// int crc = (byte) 0xFF; // initial value
// int polynomial = 0x07; // (0, 1, 2) : 0x07 / 0xE0 / 0x83
//
// boolean bit, c7;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c7 = ((crc >> 7 & 1) == 1);
// crc <<= 1;
// if (c7 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return (byte) crc;
// }
//
// /* Computes the CRC-CCITT checksum on array of byte data, length len */
// public static int crc_ccitt(byte[] msg, int len) {
// int i, acc = 0;
//
// for (i = 0; i < len; i++) {
// acc = crchware((0xFF & (int)msg[i]), 0x1021, acc);
// }
//
// return acc;
// }
//
// /* models crc hardware (minor variation on polynomial division algorithm) */
// public static int crchware(int data, int genpoly, int accum) {
// int i;
// data <<= 8;
// for (i = 8; i > 0; i--) {
// if (((data ^ accum) & 0x8000) == 1)
// accum = (((accum << 1) ^ genpoly) & 0xFFFF);
// else
// accum = ((accum << 1) & 0xFFFF);
// data = ((data << 1) & 0xFFFF);
// }
// return accum;
// }
// }
| import java.io.*;
import com.jonas.reedsolomon.CRCGen; | /**
* @param output the stream of audio samples representing the SOS hail
*/
public static void generateSOS(OutputStream output) throws IOException {
byte[] zeros = new byte[kSamplesPerDuration];
output.write(zeros);
output.write(getSOSSequence());
}
/**
* @param bitPosition the position in the kBytesPerDuration wide byte array for which you want a frequency
* @return the frequency in which to sound to indicate a 1 for this bitPosition
* NOTE!: This blindly assumes that bitPosition is in the range [0 - 7]
*/
public static int getFrequency(int bitPosition){
return Constants.kFrequencies[bitPosition];
}
/*
public static double getFrequency(int bitPosition){
return Constants.kFrequencies[bitPosition];
}
*/
/**
* @param input an array of bytes to generate CRC for
* @return the same array of bytes with its CRC appended at the end
*/
public static byte[] appendCRC(byte[] input) {
byte[] output = new byte[input.length + 1]; | // Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/reedsolomon/CRCGen.java
// public class CRCGen implements Settings {
//
// /*
// * Reads in a sequence of bytes and returns its 16 bit Cylcic Redundancy
// * Check (CRC-CCIIT 0xFFFF).
// *
// * 1 + x + x^5 + x^12 + x^16 is irreducible polynomial.
// *
// * Copyright 2000Ð2011, Robert Sedgewick and Kevin Wayne
// * source: http://introcs.cs.princeton.edu/java/51data/CRC16CCITT.java.html
// */
// public static int crc_16_ccitt(byte[] msg, int len) {
// int crc = 0xFFFF; // initial value
// int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
//
// boolean bit, c15;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c15 = ((crc >> 15 & 1) == 1);
// crc <<= 1;
// if (c15 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return crc;
// }
//
// /* Computes the CRC-8-CCITT checksum on array of byte data, length len */
// public static byte crc_8_ccitt(byte[] msg, int len) {
// int crc = (byte) 0xFF; // initial value
// int polynomial = 0x07; // (0, 1, 2) : 0x07 / 0xE0 / 0x83
//
// boolean bit, c7;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c7 = ((crc >> 7 & 1) == 1);
// crc <<= 1;
// if (c7 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return (byte) crc;
// }
//
// /* Computes the CRC-CCITT checksum on array of byte data, length len */
// public static int crc_ccitt(byte[] msg, int len) {
// int i, acc = 0;
//
// for (i = 0; i < len; i++) {
// acc = crchware((0xFF & (int)msg[i]), 0x1021, acc);
// }
//
// return acc;
// }
//
// /* models crc hardware (minor variation on polynomial division algorithm) */
// public static int crchware(int data, int genpoly, int accum) {
// int i;
// data <<= 8;
// for (i = 8; i > 0; i--) {
// if (((data ^ accum) & 0x8000) == 1)
// accum = (((accum << 1) ^ genpoly) & 0xFFFF);
// else
// accum = ((accum << 1) & 0xFFFF);
// data = ((data << 1) & 0xFFFF);
// }
// return accum;
// }
// }
// Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/stopcollaboratelisten/Encoder.java
import java.io.*;
import com.jonas.reedsolomon.CRCGen;
/**
* @param output the stream of audio samples representing the SOS hail
*/
public static void generateSOS(OutputStream output) throws IOException {
byte[] zeros = new byte[kSamplesPerDuration];
output.write(zeros);
output.write(getSOSSequence());
}
/**
* @param bitPosition the position in the kBytesPerDuration wide byte array for which you want a frequency
* @return the frequency in which to sound to indicate a 1 for this bitPosition
* NOTE!: This blindly assumes that bitPosition is in the range [0 - 7]
*/
public static int getFrequency(int bitPosition){
return Constants.kFrequencies[bitPosition];
}
/*
public static double getFrequency(int bitPosition){
return Constants.kFrequencies[bitPosition];
}
*/
/**
* @param input an array of bytes to generate CRC for
* @return the same array of bytes with its CRC appended at the end
*/
public static byte[] appendCRC(byte[] input) {
byte[] output = new byte[input.length + 1]; | byte crc8 = CRCGen.crc_8_ccitt(input, input.length); |
quake0day/Jigglypuff | DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/stopcollaboratelisten/Decoder.java | // Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/reedsolomon/CRCGen.java
// public class CRCGen implements Settings {
//
// /*
// * Reads in a sequence of bytes and returns its 16 bit Cylcic Redundancy
// * Check (CRC-CCIIT 0xFFFF).
// *
// * 1 + x + x^5 + x^12 + x^16 is irreducible polynomial.
// *
// * Copyright 2000Ð2011, Robert Sedgewick and Kevin Wayne
// * source: http://introcs.cs.princeton.edu/java/51data/CRC16CCITT.java.html
// */
// public static int crc_16_ccitt(byte[] msg, int len) {
// int crc = 0xFFFF; // initial value
// int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
//
// boolean bit, c15;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c15 = ((crc >> 15 & 1) == 1);
// crc <<= 1;
// if (c15 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return crc;
// }
//
// /* Computes the CRC-8-CCITT checksum on array of byte data, length len */
// public static byte crc_8_ccitt(byte[] msg, int len) {
// int crc = (byte) 0xFF; // initial value
// int polynomial = 0x07; // (0, 1, 2) : 0x07 / 0xE0 / 0x83
//
// boolean bit, c7;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c7 = ((crc >> 7 & 1) == 1);
// crc <<= 1;
// if (c7 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return (byte) crc;
// }
//
// /* Computes the CRC-CCITT checksum on array of byte data, length len */
// public static int crc_ccitt(byte[] msg, int len) {
// int i, acc = 0;
//
// for (i = 0; i < len; i++) {
// acc = crchware((0xFF & (int)msg[i]), 0x1021, acc);
// }
//
// return acc;
// }
//
// /* models crc hardware (minor variation on polynomial division algorithm) */
// public static int crchware(int data, int genpoly, int accum) {
// int i;
// data <<= 8;
// for (i = 8; i > 0; i--) {
// if (((data ^ accum) & 0x8000) == 1)
// accum = (((accum << 1) ^ genpoly) & 0xFFFF);
// else
// accum = ((accum << 1) & 0xFFFF);
// data = ((data << 1) & 0xFFFF);
// }
// return accum;
// }
// }
| import java.io.ByteArrayOutputStream;
import com.jonas.reedsolomon.CRCGen; | complexDetect(durationInput, Encoder.getFrequency(j));
/*
if (j == 0)
System.out.println("\nsignal[" + j + "][" + i + "]=" + signal [j][i]);
else
System.out.println("signal[" + j + "][" + i + "]=" + signal [j][i]);
*/
}
}
return signal;
}
public static void getKeySignalStrengths(byte[] signal, double[] signalStrengths){
byte[] partialSignal = ArrayUtils.subarray(signal, 0, kSamplesPerDuration);
for(int j = 1; j < kBitsPerByte * kBytesPerDuration; j += 2){
signalStrengths[j] = complexDetect(partialSignal, Encoder.getFrequency(j));
}
byte[] partialSignal2 = ArrayUtils.subarray(signal, kSamplesPerDuration, kSamplesPerDuration);
for(int j = 0; j < kBitsPerByte * kBytesPerDuration; j += 2){
signalStrengths[j] = complexDetect(partialSignal2, Encoder.getFrequency(j));
//System.out.println(signalStrengths[j]);
}
}
/**
* @param input array of bytes with CRC appended at the end
* @return true if appended CRC == calculated CRC, false otherwise
*/
public static boolean crcCheckOk(byte[] input) { | // Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/reedsolomon/CRCGen.java
// public class CRCGen implements Settings {
//
// /*
// * Reads in a sequence of bytes and returns its 16 bit Cylcic Redundancy
// * Check (CRC-CCIIT 0xFFFF).
// *
// * 1 + x + x^5 + x^12 + x^16 is irreducible polynomial.
// *
// * Copyright 2000Ð2011, Robert Sedgewick and Kevin Wayne
// * source: http://introcs.cs.princeton.edu/java/51data/CRC16CCITT.java.html
// */
// public static int crc_16_ccitt(byte[] msg, int len) {
// int crc = 0xFFFF; // initial value
// int polynomial = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
//
// boolean bit, c15;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c15 = ((crc >> 15 & 1) == 1);
// crc <<= 1;
// if (c15 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return crc;
// }
//
// /* Computes the CRC-8-CCITT checksum on array of byte data, length len */
// public static byte crc_8_ccitt(byte[] msg, int len) {
// int crc = (byte) 0xFF; // initial value
// int polynomial = 0x07; // (0, 1, 2) : 0x07 / 0xE0 / 0x83
//
// boolean bit, c7;
// for (int b = 0; b < len; b++) {
// for (int i = 0; i < 8; i++) {
// bit = ((msg[b] >> (7 - i) & 1) == 1);
// c7 = ((crc >> 7 & 1) == 1);
// crc <<= 1;
// if (c7 ^ bit)
// crc ^= polynomial;
// }
// }
// crc &= 0xffff;
//
// return (byte) crc;
// }
//
// /* Computes the CRC-CCITT checksum on array of byte data, length len */
// public static int crc_ccitt(byte[] msg, int len) {
// int i, acc = 0;
//
// for (i = 0; i < len; i++) {
// acc = crchware((0xFF & (int)msg[i]), 0x1021, acc);
// }
//
// return acc;
// }
//
// /* models crc hardware (minor variation on polynomial division algorithm) */
// public static int crchware(int data, int genpoly, int accum) {
// int i;
// data <<= 8;
// for (i = 8; i > 0; i--) {
// if (((data ^ accum) & 0x8000) == 1)
// accum = (((accum << 1) ^ genpoly) & 0xFFFF);
// else
// accum = ((accum << 1) & 0xFFFF);
// data = ((data << 1) & 0xFFFF);
// }
// return accum;
// }
// }
// Path: DigitalVoices-ASK-StopCollaborateListen/src/com/jonas/stopcollaboratelisten/Decoder.java
import java.io.ByteArrayOutputStream;
import com.jonas.reedsolomon.CRCGen;
complexDetect(durationInput, Encoder.getFrequency(j));
/*
if (j == 0)
System.out.println("\nsignal[" + j + "][" + i + "]=" + signal [j][i]);
else
System.out.println("signal[" + j + "][" + i + "]=" + signal [j][i]);
*/
}
}
return signal;
}
public static void getKeySignalStrengths(byte[] signal, double[] signalStrengths){
byte[] partialSignal = ArrayUtils.subarray(signal, 0, kSamplesPerDuration);
for(int j = 1; j < kBitsPerByte * kBytesPerDuration; j += 2){
signalStrengths[j] = complexDetect(partialSignal, Encoder.getFrequency(j));
}
byte[] partialSignal2 = ArrayUtils.subarray(signal, kSamplesPerDuration, kSamplesPerDuration);
for(int j = 0; j < kBitsPerByte * kBytesPerDuration; j += 2){
signalStrengths[j] = complexDetect(partialSignal2, Encoder.getFrequency(j));
//System.out.println(signalStrengths[j]);
}
}
/**
* @param input array of bytes with CRC appended at the end
* @return true if appended CRC == calculated CRC, false otherwise
*/
public static boolean crcCheckOk(byte[] input) { | return input[input.length - 1] == CRCGen.crc_8_ccitt(input, input.length - 1); |
quake0day/Jigglypuff | PriWhisper/src/com/slk/androidaudio/ReceiverActivity.java | // Path: PriWhisper/src/com/slk/androidaudio/receiver/AudioReceiver.java
// public class AudioReceiver {
//
// // arduino messages
// // [0-9] button events
// // [10-19] specific messages
// // [20-30] protocol codes
// private static boolean isLogging = true;
// public static final int ARDUINO_PROTOCOL_ARQ = 20; // Automatic repeat
// // request
// public static final int ARDUINO_PROTOCOL_ACK = 21; // Message received
// // acknowledgment
//
// public static final int LAST_MESSAGE_MAX_RETRY_TIMES = 5; // Number of times
// // that last
// // message is
// // repeated
// public static final int CONSECUTIVE_CHK_ERROR_LIMIT = 1; // Number of
// // consecutive
// // checksum
// // errors to
// // send an ARQ
//
// private Handler mHandler;
// private ArduinoService mArduinoS;
// private ReceiverActivity mActivity;
// private int lastMessage;
// private int lastMessageCounter = 0;
// private int checksumErrorCounter = 0;
//
// private static void debugInfo(String message) {
// if (isLogging) {
// Log.i("TAG", "AudioReceiver:" + message);
// }
// }
//
// public AudioReceiver(ReceiverActivity activity) {
// this.mActivity = activity;
// this.mHandler = new Handler() {
// public void handleMessage(Message msg) {
// messageReceived(msg);
// }
// };
// }
//
// public void stop() {
// debugInfo("stop()");
// // STOP the arduino service
// if (this.mArduinoS != null)
// this.mArduinoS.stopAndClean();
// }
//
// public void start() {
// // START the arduino service
// this.mArduinoS = new ArduinoService(this.mHandler);
// new Thread(this.mArduinoS).start();
// }
//
// private void messageReceived(Message msg) {
// int target = msg.what;
// int value = msg.arg1;
// int type = msg.arg2;
//
// debugInfo("messageReceived(): target=" + target + " value="
// + value + " type=" + type);
//
// switch (target) {
// case ArduinoService.HANDLER_MESSAGE_FROM_ARDUINO:
// switch (value) {
// case ARDUINO_PROTOCOL_ARQ:
// checksumErrorCounter = 0;
// sendLastMessage();
// break;
// case ErrorDetection.CHECKSUM_ERROR:
// checksumErrorCounter++;
// if (checksumErrorCounter > CONSECUTIVE_CHK_ERROR_LIMIT) {
// checksumErrorCounter = 0;
// sendMessage(ARDUINO_PROTOCOL_ARQ);// ARQ after two
// // consecutive CHK ERROR
// // received
// }
// break;
//
// /*
// * case ARDUINO_MSG_START_GAME: this.mServer.startGameClick();
// * break; case ARDUINO_MSG_END_GAME_WINNER:
// * this.mServer.endGame("0"); break; case
// * ARDUINO_MSG_END_GAME_LOSER: this.mServer.endGame("1"); break;
// * default: this.mServer.buttonClick(""+value); break;
// */
// default:
// checksumErrorCounter = 0;
// debugInfo("messageReceived() ACK send");
// this.sendMessage(ARDUINO_PROTOCOL_ACK);
// break;
// }
//
// this.mActivity.showDebugMessage("ARD: " + value, false);
// debugInfo("messageReceived() from arduino value="
// + value);
// break;
// default:
// // FIXME error happened handling messages
// break;
// }
// }
//
// private void sendLastMessage() {
// this.sendMessage(lastMessage);
// if (lastMessageCounter > LAST_MESSAGE_MAX_RETRY_TIMES) {
// // stop repeating last message, ERROR
// this.mActivity.showDebugMessage("ERROR MAX RETRY msg="
// + this.lastMessage, false);
// debugInfo("sendLastMessage() ERROR MAX RETRY value="
// + lastMessage);
// this.sendMessage(ARDUINO_PROTOCOL_ACK); // send ack to avoid ARQ
// debugInfo("sendLastMessage() ERROR MAX RETRY SENDING ACK instead");
// lastMessageCounter = 0;
// } else {
// debugInfo("sendLastMessage() value=" + lastMessage);
// this.sendMessage(lastMessage);
// lastMessageCounter++;
// }
// }
//
// private void sendMessage(int number) {
// debugInfo("sendMessage() number=" + number);
// //this.mArduinoS.write(number);
// }
//
// protected void developmentSendMessage(int number) {
// this.sendMessage(number);
// }
//
// }
| import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import com.slk.androidaudio.receiver.AudioReceiver; | package com.slk.androidaudio;
public class ReceiverActivity extends Activity {
private static final String TAG = "MainActivity"; | // Path: PriWhisper/src/com/slk/androidaudio/receiver/AudioReceiver.java
// public class AudioReceiver {
//
// // arduino messages
// // [0-9] button events
// // [10-19] specific messages
// // [20-30] protocol codes
// private static boolean isLogging = true;
// public static final int ARDUINO_PROTOCOL_ARQ = 20; // Automatic repeat
// // request
// public static final int ARDUINO_PROTOCOL_ACK = 21; // Message received
// // acknowledgment
//
// public static final int LAST_MESSAGE_MAX_RETRY_TIMES = 5; // Number of times
// // that last
// // message is
// // repeated
// public static final int CONSECUTIVE_CHK_ERROR_LIMIT = 1; // Number of
// // consecutive
// // checksum
// // errors to
// // send an ARQ
//
// private Handler mHandler;
// private ArduinoService mArduinoS;
// private ReceiverActivity mActivity;
// private int lastMessage;
// private int lastMessageCounter = 0;
// private int checksumErrorCounter = 0;
//
// private static void debugInfo(String message) {
// if (isLogging) {
// Log.i("TAG", "AudioReceiver:" + message);
// }
// }
//
// public AudioReceiver(ReceiverActivity activity) {
// this.mActivity = activity;
// this.mHandler = new Handler() {
// public void handleMessage(Message msg) {
// messageReceived(msg);
// }
// };
// }
//
// public void stop() {
// debugInfo("stop()");
// // STOP the arduino service
// if (this.mArduinoS != null)
// this.mArduinoS.stopAndClean();
// }
//
// public void start() {
// // START the arduino service
// this.mArduinoS = new ArduinoService(this.mHandler);
// new Thread(this.mArduinoS).start();
// }
//
// private void messageReceived(Message msg) {
// int target = msg.what;
// int value = msg.arg1;
// int type = msg.arg2;
//
// debugInfo("messageReceived(): target=" + target + " value="
// + value + " type=" + type);
//
// switch (target) {
// case ArduinoService.HANDLER_MESSAGE_FROM_ARDUINO:
// switch (value) {
// case ARDUINO_PROTOCOL_ARQ:
// checksumErrorCounter = 0;
// sendLastMessage();
// break;
// case ErrorDetection.CHECKSUM_ERROR:
// checksumErrorCounter++;
// if (checksumErrorCounter > CONSECUTIVE_CHK_ERROR_LIMIT) {
// checksumErrorCounter = 0;
// sendMessage(ARDUINO_PROTOCOL_ARQ);// ARQ after two
// // consecutive CHK ERROR
// // received
// }
// break;
//
// /*
// * case ARDUINO_MSG_START_GAME: this.mServer.startGameClick();
// * break; case ARDUINO_MSG_END_GAME_WINNER:
// * this.mServer.endGame("0"); break; case
// * ARDUINO_MSG_END_GAME_LOSER: this.mServer.endGame("1"); break;
// * default: this.mServer.buttonClick(""+value); break;
// */
// default:
// checksumErrorCounter = 0;
// debugInfo("messageReceived() ACK send");
// this.sendMessage(ARDUINO_PROTOCOL_ACK);
// break;
// }
//
// this.mActivity.showDebugMessage("ARD: " + value, false);
// debugInfo("messageReceived() from arduino value="
// + value);
// break;
// default:
// // FIXME error happened handling messages
// break;
// }
// }
//
// private void sendLastMessage() {
// this.sendMessage(lastMessage);
// if (lastMessageCounter > LAST_MESSAGE_MAX_RETRY_TIMES) {
// // stop repeating last message, ERROR
// this.mActivity.showDebugMessage("ERROR MAX RETRY msg="
// + this.lastMessage, false);
// debugInfo("sendLastMessage() ERROR MAX RETRY value="
// + lastMessage);
// this.sendMessage(ARDUINO_PROTOCOL_ACK); // send ack to avoid ARQ
// debugInfo("sendLastMessage() ERROR MAX RETRY SENDING ACK instead");
// lastMessageCounter = 0;
// } else {
// debugInfo("sendLastMessage() value=" + lastMessage);
// this.sendMessage(lastMessage);
// lastMessageCounter++;
// }
// }
//
// private void sendMessage(int number) {
// debugInfo("sendMessage() number=" + number);
// //this.mArduinoS.write(number);
// }
//
// protected void developmentSendMessage(int number) {
// this.sendMessage(number);
// }
//
// }
// Path: PriWhisper/src/com/slk/androidaudio/ReceiverActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import com.slk.androidaudio.receiver.AudioReceiver;
package com.slk.androidaudio;
public class ReceiverActivity extends Activity {
private static final String TAG = "MainActivity"; | private AudioReceiver mAudioReceiver; |
msmithcp/owlwg-test | owlapi3/src/com/clarkparsia/owlwg/owlapi3/testcase/impl/OwlApi3ETImpl.java | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
| import java.util.EnumMap;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.StringInputSource;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat; | package com.clarkparsia.owlwg.owlapi3.testcase.impl;
/**
* <p>
* Title: OWLAPIv3 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi3ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi3Case {
private final OWLOntologyManager manager; | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
// Path: owlapi3/src/com/clarkparsia/owlwg/owlapi3/testcase/impl/OwlApi3ETImpl.java
import java.util.EnumMap;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.StringInputSource;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat;
package com.clarkparsia.owlwg.owlapi3.testcase.impl;
/**
* <p>
* Title: OWLAPIv3 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi3ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi3Case {
private final OWLOntologyManager manager; | private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion; |
msmithcp/owlwg-test | owlapi3/src/com/clarkparsia/owlwg/owlapi3/testcase/impl/OwlApi3ETImpl.java | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
| import java.util.EnumMap;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.StringInputSource;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat; | package com.clarkparsia.owlwg.owlapi3.testcase.impl;
/**
* <p>
* Title: OWLAPIv3 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi3ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi3Case {
private final OWLOntologyManager manager;
private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion;
private final EnumMap<SerializationFormat, OWLOntology> parsedPremise;
public OwlApi3ETImpl(org.semanticweb.owl.model.OWLOntology ontology,
org.semanticweb.owl.model.OWLIndividual i, boolean positive) {
super( ontology, i, positive );
parsedPremise = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
parsedConclusion = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
manager = OWLManager.createOWLOntologyManager();
}
public OWLOntologyManager getOWLOntologyManager() {
return manager;
}
public OWLOntology parseConclusionOntology(SerializationFormat format) | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
// Path: owlapi3/src/com/clarkparsia/owlwg/owlapi3/testcase/impl/OwlApi3ETImpl.java
import java.util.EnumMap;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.StringInputSource;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat;
package com.clarkparsia.owlwg.owlapi3.testcase.impl;
/**
* <p>
* Title: OWLAPIv3 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi3ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi3Case {
private final OWLOntologyManager manager;
private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion;
private final EnumMap<SerializationFormat, OWLOntology> parsedPremise;
public OwlApi3ETImpl(org.semanticweb.owl.model.OWLOntology ontology,
org.semanticweb.owl.model.OWLIndividual i, boolean positive) {
super( ontology, i, positive );
parsedPremise = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
parsedConclusion = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
manager = OWLManager.createOWLOntologyManager();
}
public OWLOntologyManager getOWLOntologyManager() {
return manager;
}
public OWLOntology parseConclusionOntology(SerializationFormat format) | throws OntologyParseException { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/ImportsHelper.java | // Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
| import static java.lang.String.format;
import java.net.URI;
import java.util.logging.Logger;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.SerializationFormat; | package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Imports Helper
* </p>
* <p>
* Description: Static implementation used to load imports for a test case into
* the ontology manager
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class ImportsHelper {
private final static Logger log;
static {
log = Logger.getLogger( ImportsHelper.class.getCanonicalName() );
}
public static void loadImports(OwlApi2Case t) throws OWLOntologyCreationException {
final OWLOntologyManager manager = t.getOWLOntologyManager();
for( URI u : t.getImportedOntologies() ) {
if( !manager.contains( u ) ) { | // Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
// Path: core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/ImportsHelper.java
import static java.lang.String.format;
import java.net.URI;
import java.util.logging.Logger;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.SerializationFormat;
package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Imports Helper
* </p>
* <p>
* Description: Static implementation used to load imports for a test case into
* the ontology manager
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class ImportsHelper {
private final static Logger log;
static {
log = Logger.getLogger( ImportsHelper.class.getCanonicalName() );
}
public static void loadImports(OwlApi2Case t) throws OWLOntologyCreationException {
final OWLOntologyManager manager = t.getOWLOntologyManager();
for( URI u : t.getImportedOntologies() ) {
if( !manager.contains( u ) ) { | String str = t.getImportedOntology( u, SerializationFormat.RDFXML ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import com.clarkparsia.owlwg.runner.TestRunner;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testrun;
/**
* <p>
* Title: Test Run Result
* </p>
* <p>
* Description: Interface based on result ontology described at <a
* href="http://www.w3.org/2007/OWL/wiki/Test_Result_Format"
* >http://www.w3.org/2007/OWL/wiki/Test_Result_Format</a>.
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public interface TestRunResult {
public void accept(TestRunResultVisitor visitor);
public String getDetails();
public RunResultType getResultType();
| // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java
import com.clarkparsia.owlwg.runner.TestRunner;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testrun;
/**
* <p>
* Title: Test Run Result
* </p>
* <p>
* Description: Interface based on result ontology described at <a
* href="http://www.w3.org/2007/OWL/wiki/Test_Result_Format"
* >http://www.w3.org/2007/OWL/wiki/Test_Result_Format</a>.
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public interface TestRunResult {
public void accept(TestRunResultVisitor visitor);
public String getDetails();
public RunResultType getResultType();
| public TestCase getTestCase(); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testrun/AbstractRun.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import com.clarkparsia.owlwg.runner.TestRunner;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testrun;
/**
* <p>
* Title: Abstract Run
* </p>
* <p>
* Description: Base implementation used by other {@link TestRunResult}
* implementations
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class AbstractRun implements TestRunResult {
private final String details;
private final RunResultType resultType;
private final TestRunner runner; | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testrun/AbstractRun.java
import com.clarkparsia.owlwg.runner.TestRunner;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testrun;
/**
* <p>
* Title: Abstract Run
* </p>
* <p>
* Description: Base implementation used by other {@link TestRunResult}
* implementations
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class AbstractRun implements TestRunResult {
private final String details;
private final RunResultType resultType;
private final TestRunner runner; | private final TestCase testcase; |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testcase/filter/StatusFilter.java | // Path: core/src/com/clarkparsia/owlwg/testcase/Status.java
// public enum Status {
//
// APPROVED(Individual.APPROVED), EXTRACREDIT(Individual.EXTRACREDIT),
// PROPOSED(Individual.PROPOSED), REJECTED(Individual.REJECTED);
//
// public static Status get(OWLIndividual i) {
// for( Status s : Status.values() ) {
// if( s.getOWLIndividual().equals( i ) )
// return s;
// }
//
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private Status(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import com.clarkparsia.owlwg.testcase.Status;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Status Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests with a particular status (or no
* status).
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class StatusFilter implements FilterCondition {
public final static StatusFilter APPROVED, EXTRACREDIT, NOSTATUS, PROPOSED, REJECTED;
static { | // Path: core/src/com/clarkparsia/owlwg/testcase/Status.java
// public enum Status {
//
// APPROVED(Individual.APPROVED), EXTRACREDIT(Individual.EXTRACREDIT),
// PROPOSED(Individual.PROPOSED), REJECTED(Individual.REJECTED);
//
// public static Status get(OWLIndividual i) {
// for( Status s : Status.values() ) {
// if( s.getOWLIndividual().equals( i ) )
// return s;
// }
//
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private Status(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/StatusFilter.java
import com.clarkparsia.owlwg.testcase.Status;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Status Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests with a particular status (or no
* status).
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class StatusFilter implements FilterCondition {
public final static StatusFilter APPROVED, EXTRACREDIT, NOSTATUS, PROPOSED, REJECTED;
static { | APPROVED = new StatusFilter( Status.APPROVED ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testcase/filter/StatusFilter.java | // Path: core/src/com/clarkparsia/owlwg/testcase/Status.java
// public enum Status {
//
// APPROVED(Individual.APPROVED), EXTRACREDIT(Individual.EXTRACREDIT),
// PROPOSED(Individual.PROPOSED), REJECTED(Individual.REJECTED);
//
// public static Status get(OWLIndividual i) {
// for( Status s : Status.values() ) {
// if( s.getOWLIndividual().equals( i ) )
// return s;
// }
//
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private Status(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import com.clarkparsia.owlwg.testcase.Status;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Status Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests with a particular status (or no
* status).
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class StatusFilter implements FilterCondition {
public final static StatusFilter APPROVED, EXTRACREDIT, NOSTATUS, PROPOSED, REJECTED;
static {
APPROVED = new StatusFilter( Status.APPROVED );
EXTRACREDIT = new StatusFilter( Status.EXTRACREDIT );
NOSTATUS = new StatusFilter( null );
PROPOSED = new StatusFilter( Status.PROPOSED );
REJECTED = new StatusFilter( Status.REJECTED );
}
final private Status status;
/**
* @param status
* {@link Status} for test case or <code>null</code> if filter
* should match cases that have no status
*/
public StatusFilter(Status status) {
this.status = status;
}
| // Path: core/src/com/clarkparsia/owlwg/testcase/Status.java
// public enum Status {
//
// APPROVED(Individual.APPROVED), EXTRACREDIT(Individual.EXTRACREDIT),
// PROPOSED(Individual.PROPOSED), REJECTED(Individual.REJECTED);
//
// public static Status get(OWLIndividual i) {
// for( Status s : Status.values() ) {
// if( s.getOWLIndividual().equals( i ) )
// return s;
// }
//
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private Status(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/StatusFilter.java
import com.clarkparsia.owlwg.testcase.Status;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Status Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests with a particular status (or no
* status).
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class StatusFilter implements FilterCondition {
public final static StatusFilter APPROVED, EXTRACREDIT, NOSTATUS, PROPOSED, REJECTED;
static {
APPROVED = new StatusFilter( Status.APPROVED );
EXTRACREDIT = new StatusFilter( Status.EXTRACREDIT );
NOSTATUS = new StatusFilter( null );
PROPOSED = new StatusFilter( Status.PROPOSED );
REJECTED = new StatusFilter( Status.REJECTED );
}
final private Status status;
/**
* @param status
* {@link Status} for test case or <code>null</code> if filter
* should match cases that have no status
*/
public StatusFilter(Status status) {
this.status = status;
}
| public boolean accepts(TestCase testcase) { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testcase/AbstractBaseTestCase.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestVocabulary.java
// public enum Individual {
// APPROVED("Approved"), DIRECT("DIRECT"), DL("DL"), EL("EL"), EXTRACREDIT("Extracredit"),
// FULL("FULL"), FUNCTIONAL("FUNCTIONAL"), OWLXML("OWLXML"), PROPOSED("Proposed"), QL("QL"),
// RDF_BASED("RDF-BASED"), RDFXML("RDFXML"), REJECTED("Rejected"), RL("RL");
//
// private final OWLIndividual i;
//
// private Individual(String localName) {
// i = manager.getOWLDataFactory().getOWLIndividual( URI.create( URI_BASE + localName ) );
// }
//
// public OWLIndividual getOWLIndividual() {
// return i;
// }
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.DatatypeProperty.IDENTIFIER;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Individual.FULL;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.IMPORTED_ONTOLOGY;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.PROFILE;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.SEMANTICS;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.SPECIES;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.STATUS;
import static java.lang.String.format;
import static java.util.Collections.unmodifiableSet;
import java.net.URI;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLConstant;
import org.semanticweb.owl.model.OWLDataPropertyExpression;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLObjectPropertyExpression;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.TestVocabulary.Individual; | status = null;
else if( statuses.size() > 1 )
throw new IllegalArgumentException();
else {
OWLIndividual s = statuses.iterator().next();
status = Status.get( s );
if( status == null )
throw new NullPointerException( format(
"Unexpected status ( %s ) for test case %s", s.getURI().toASCIIString(), i
.getURI() ) );
}
satisfied = EnumSet.noneOf( SyntaxConstraint.class );
Set<OWLIndividual> profiles = opValues.get( PROFILE.getOWLObjectProperty() );
if( profiles != null ) {
for( OWLIndividual p : profiles ) {
SyntaxConstraint c = SyntaxConstraint.get( p );
if( c == null )
throw new NullPointerException( format(
"Unexpected profile ( %s ) for test case %s", p.getURI()
.toASCIIString(), i.getURI() ) );
satisfied.add( c );
}
}
Set<OWLIndividual> species = opValues.get( SPECIES.getOWLObjectProperty() );
if( species != null ) {
for( OWLIndividual s : species ) {
if( FULL.getOWLIndividual().equals( s ) )
continue; | // Path: core/src/com/clarkparsia/owlwg/testcase/TestVocabulary.java
// public enum Individual {
// APPROVED("Approved"), DIRECT("DIRECT"), DL("DL"), EL("EL"), EXTRACREDIT("Extracredit"),
// FULL("FULL"), FUNCTIONAL("FUNCTIONAL"), OWLXML("OWLXML"), PROPOSED("Proposed"), QL("QL"),
// RDF_BASED("RDF-BASED"), RDFXML("RDFXML"), REJECTED("Rejected"), RL("RL");
//
// private final OWLIndividual i;
//
// private Individual(String localName) {
// i = manager.getOWLDataFactory().getOWLIndividual( URI.create( URI_BASE + localName ) );
// }
//
// public OWLIndividual getOWLIndividual() {
// return i;
// }
// }
// Path: core/src/com/clarkparsia/owlwg/testcase/AbstractBaseTestCase.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.DatatypeProperty.IDENTIFIER;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Individual.FULL;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.IMPORTED_ONTOLOGY;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.PROFILE;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.SEMANTICS;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.SPECIES;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.ObjectProperty.STATUS;
import static java.lang.String.format;
import static java.util.Collections.unmodifiableSet;
import java.net.URI;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLConstant;
import org.semanticweb.owl.model.OWLDataPropertyExpression;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLObjectPropertyExpression;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.TestVocabulary.Individual;
status = null;
else if( statuses.size() > 1 )
throw new IllegalArgumentException();
else {
OWLIndividual s = statuses.iterator().next();
status = Status.get( s );
if( status == null )
throw new NullPointerException( format(
"Unexpected status ( %s ) for test case %s", s.getURI().toASCIIString(), i
.getURI() ) );
}
satisfied = EnumSet.noneOf( SyntaxConstraint.class );
Set<OWLIndividual> profiles = opValues.get( PROFILE.getOWLObjectProperty() );
if( profiles != null ) {
for( OWLIndividual p : profiles ) {
SyntaxConstraint c = SyntaxConstraint.get( p );
if( c == null )
throw new NullPointerException( format(
"Unexpected profile ( %s ) for test case %s", p.getURI()
.toASCIIString(), i.getURI() ) );
satisfied.add( c );
}
}
Set<OWLIndividual> species = opValues.get( SPECIES.getOWLObjectProperty() );
if( species != null ) {
for( OWLIndividual s : species ) {
if( FULL.getOWLIndividual().equals( s ) )
continue; | if( Individual.DL.getOWLIndividual().equals( s ) ) |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/TestCollection.java | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition; | package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
| // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
| public TestCollection(TestCaseFactory<O> factory, OWLOntology o) { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/TestCollection.java | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition; | package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
public TestCollection(TestCaseFactory<O> factory, OWLOntology o) { | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
public TestCollection(TestCaseFactory<O> factory, OWLOntology o) { | this( factory, o, FilterCondition.ACCEPT_ALL ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/TestCollection.java | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition; | package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
public TestCollection(TestCaseFactory<O> factory, OWLOntology o) {
this( factory, o, FilterCondition.ACCEPT_ALL );
}
public TestCollection(TestCaseFactory<O> factory, OWLOntology o, FilterCondition filter) {
if( factory == null )
throw new NullPointerException();
if( filter == null )
throw new NullPointerException();
cases = new HashMap<OWLIndividual, TestCase<O>>();
Set<OWLClassAssertionAxiom> axioms;
axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual(); | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
package com.clarkparsia.owlwg;
/**
* <p>
* Title: Test Collection
* </p>
* <p>
* Description: Converts an ontology containing test case descriptions into an
* iterable collection of {@link TestCase} objects
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class TestCollection<O> implements Iterable<TestCase<O>> {
private final Map<OWLIndividual, TestCase<O>> cases;
public TestCollection(TestCaseFactory<O> factory, OWLOntology o) {
this( factory, o, FilterCondition.ACCEPT_ALL );
}
public TestCollection(TestCaseFactory<O> factory, OWLOntology o, FilterCondition filter) {
if( factory == null )
throw new NullPointerException();
if( filter == null )
throw new NullPointerException();
cases = new HashMap<OWLIndividual, TestCase<O>>();
Set<OWLClassAssertionAxiom> axioms;
axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual(); | final PositiveEntailmentTest<O> t = factory.getPositiveEntailmentTestCase( o, i ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/TestCollection.java | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition; | axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final PositiveEntailmentTest<O> t = factory.getPositiveEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( NEGATIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final NegativeEntailmentTest<O> t = factory.getNegativeEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( CONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
/*
* Verify the identifier is not already in the map because both
* entailment tests may also be marked as consistency tests.
*/
if( cases.containsKey( i ) )
continue; | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final PositiveEntailmentTest<O> t = factory.getPositiveEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( NEGATIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final NegativeEntailmentTest<O> t = factory.getNegativeEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( CONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
/*
* Verify the identifier is not already in the map because both
* entailment tests may also be marked as consistency tests.
*/
if( cases.containsKey( i ) )
continue; | final ConsistencyTest<O> t = factory.getConsistencyTestCase( o, i ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/TestCollection.java | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
| import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition; | axioms = o.getClassAssertionAxioms( NEGATIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final NegativeEntailmentTest<O> t = factory.getNegativeEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( CONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
/*
* Verify the identifier is not already in the map because both
* entailment tests may also be marked as consistency tests.
*/
if( cases.containsKey( i ) )
continue;
final ConsistencyTest<O> t = factory.getConsistencyTestCase( o, i );
if( filter.accepts( t ) && !cases.containsKey( i ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( INCONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual(); | // Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
//
// public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
//
// public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
//
// public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
//
// /**
// * Test a {@link TestCase} against a condition
// *
// * @param testcase
// * The {@link TestCase} to evaluate
// * @return <code>true</code> if the filter condition accepts the test case,
// * <code>false</code> otherwise
// */
// public boolean accepts(TestCase testcase);
//
// /**
// * Filter condition which accepts all test cases. Useful as a default
// * condition.
// */
// public final FilterCondition ACCEPT_ALL = new FilterCondition() {
// public boolean accepts(TestCase testcase) {
// return true;
// }
// };
// }
// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
axioms = o.getClassAssertionAxioms( NEGATIVE_ENTAILMENT_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
final NegativeEntailmentTest<O> t = factory.getNegativeEntailmentTestCase( o, i );
if( filter.accepts( t ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( CONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual();
/*
* Verify the identifier is not already in the map because both
* entailment tests may also be marked as consistency tests.
*/
if( cases.containsKey( i ) )
continue;
final ConsistencyTest<O> t = factory.getConsistencyTestCase( o, i );
if( filter.accepts( t ) && !cases.containsKey( i ) )
cases.put( i, t );
}
}
axioms = o.getClassAssertionAxioms( INCONSISTENCY_TEST.getOWLClass() );
if( axioms != null ) {
for( OWLClassAssertionAxiom ax : axioms ) {
final OWLIndividual i = ax.getIndividual(); | final InconsistencyTest<O> t = factory.getInconsistencyTestCase( o, i ); |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/OwlApi2ETImpl.java | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
| import java.util.EnumMap;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat; | package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi2ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi2Case {
private final OWLOntologyManager manager; | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
// Path: core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/OwlApi2ETImpl.java
import java.util.EnumMap;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat;
package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi2ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi2Case {
private final OWLOntologyManager manager; | private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion; |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/OwlApi2ETImpl.java | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
| import java.util.EnumMap;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat; | package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi2ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi2Case {
private final OWLOntologyManager manager;
private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion;
private final EnumMap<SerializationFormat, OWLOntology> parsedPremise;
public OwlApi2ETImpl(OWLOntology ontology, OWLIndividual i, boolean positive) {
super( ontology, i, positive );
parsedPremise = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
parsedConclusion = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
manager = OWLManager.createOWLOntologyManager();
}
public OWLOntologyManager getOWLOntologyManager() {
return manager;
}
public OWLOntology parseConclusionOntology(SerializationFormat format) | // Path: core/src/com/clarkparsia/owlwg/testcase/EntailmentTest.java
// public interface EntailmentTest<O> extends PremisedTest<O> {
//
// public Set<SerializationFormat> getConclusionFormats();
//
// public String getConclusionOntology(SerializationFormat format);
//
// public O parseConclusionOntology(SerializationFormat format) throws OntologyParseException;
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/OntologyParseException.java
// public class OntologyParseException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public OntologyParseException() {
// }
//
// public OntologyParseException(String message) {
// super( message );
// }
//
// public OntologyParseException(Throwable cause) {
// super( cause );
// }
//
// public OntologyParseException(String message, Throwable cause) {
// super( message, cause );
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/SerializationFormat.java
// public enum SerializationFormat {
//
// /**
// * OWL 2 Functional-Style Syntax
// */
// FUNCTIONAL(Individual.FUNCTIONAL, FUNCTIONAL_INPUT_ONTOLOGY, FUNCTIONAL_PREMISE_ONTOLOGY, FUNCTIONAL_CONCLUSION_ONTOLOGY, FUNCTIONAL_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 XML Syntax
// */
// OWLXML(Individual.OWLXML, OWLXML_INPUT_ONTOLOGY, OWLXML_PREMISE_ONTOLOGY, OWLXML_CONCLUSION_ONTOLOGY, OWLXML_NONCONCLUSION_ONTOLOGY),
// /**
// * OWL 2 RDF/XML Syntax
// */
// RDFXML(Individual.RDFXML, RDFXML_INPUT_ONTOLOGY, RDFXML_PREMISE_ONTOLOGY, RDFXML_CONCLUSION_ONTOLOGY, RDFXML_NONCONCLUSION_ONTOLOGY);
//
// private final TestVocabulary.DatatypeProperty conclusion;
// private final TestVocabulary.DatatypeProperty input;
// private final TestVocabulary.Individual i;
// private final TestVocabulary.DatatypeProperty nonconclusion;
// private final TestVocabulary.DatatypeProperty premise;
//
// private SerializationFormat(TestVocabulary.Individual i, TestVocabulary.DatatypeProperty input,
// TestVocabulary.DatatypeProperty premise, TestVocabulary.DatatypeProperty conclusion,
// TestVocabulary.DatatypeProperty nonconclusion) {
// this.i = i;
// this.input = input;
// this.premise = premise;
// this.conclusion = conclusion;
// this.nonconclusion = nonconclusion;
// }
//
// public OWLDataProperty getConclusionOWLDataProperty() {
// return conclusion.getOWLDataProperty();
// }
//
// public OWLDataProperty getNonConclusionOWLDataProperty() {
// return nonconclusion.getOWLDataProperty();
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
//
// public OWLDataProperty getPremiseOWLDataProperty() {
// return premise.getOWLDataProperty();
// }
//
// public OWLDataProperty getInputOWLDataProperty() {
// return input.getOWLDataProperty();
// }
// }
// Path: core/src/com/clarkparsia/owlwg/owlapi2/testcase/impl/OwlApi2ETImpl.java
import java.util.EnumMap;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.io.StringInputSource;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
import com.clarkparsia.owlwg.testcase.AbstractEntailmentTest;
import com.clarkparsia.owlwg.testcase.EntailmentTest;
import com.clarkparsia.owlwg.testcase.OntologyParseException;
import com.clarkparsia.owlwg.testcase.SerializationFormat;
package com.clarkparsia.owlwg.owlapi2.testcase.impl;
/**
* <p>
* Title: OWLAPIv2 Entailment Test Case Base Class
* </p>
* <p>
* Description: Extended for positive and negative entailment cases
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public abstract class OwlApi2ETImpl extends AbstractEntailmentTest<OWLOntology> implements
EntailmentTest<OWLOntology>, OwlApi2Case {
private final OWLOntologyManager manager;
private final EnumMap<SerializationFormat, OWLOntology> parsedConclusion;
private final EnumMap<SerializationFormat, OWLOntology> parsedPremise;
public OwlApi2ETImpl(OWLOntology ontology, OWLIndividual i, boolean positive) {
super( ontology, i, positive );
parsedPremise = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
parsedConclusion = new EnumMap<SerializationFormat, OWLOntology>( SerializationFormat.class );
manager = OWLManager.createOWLOntologyManager();
}
public OWLOntologyManager getOWLOntologyManager() {
return manager;
}
public OWLOntology parseConclusionOntology(SerializationFormat format) | throws OntologyParseException { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testcase/filter/SemanticsFilter.java | // Path: core/src/com/clarkparsia/owlwg/testcase/SyntaxConstraint.java
// public enum SyntaxConstraint {
//
// DL(Individual.DL), EL(Individual.EL), QL(Individual.QL), RL(Individual.RL);
//
// public static SyntaxConstraint get(OWLIndividual i) {
// for( SyntaxConstraint c : values() ) {
// if( c.getOWLIndividual().equals( i ) )
// return c;
// }
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private SyntaxConstraint(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import com.clarkparsia.owlwg.testcase.Semantics;
import com.clarkparsia.owlwg.testcase.SyntaxConstraint;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Semantics Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests for which a particular semantics
* is applicable.
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class SemanticsFilter implements FilterCondition {
public static final SemanticsFilter DIRECT, RDF;
static {
DIRECT = new SemanticsFilter( Semantics.DIRECT );
RDF = new SemanticsFilter( Semantics.RDF );
}
final private Semantics semantics;
/**
* @throws NullPointerException
* if <code>semantics == null</code>
*/
public SemanticsFilter(Semantics semantics) {
if( semantics == null )
throw new NullPointerException();
this.semantics = semantics;
}
| // Path: core/src/com/clarkparsia/owlwg/testcase/SyntaxConstraint.java
// public enum SyntaxConstraint {
//
// DL(Individual.DL), EL(Individual.EL), QL(Individual.QL), RL(Individual.RL);
//
// public static SyntaxConstraint get(OWLIndividual i) {
// for( SyntaxConstraint c : values() ) {
// if( c.getOWLIndividual().equals( i ) )
// return c;
// }
// return null;
// }
//
// private final TestVocabulary.Individual i;
//
// private SyntaxConstraint(TestVocabulary.Individual i) {
// this.i = i;
// }
//
// public OWLIndividual getOWLIndividual() {
// return i.getOWLIndividual();
// }
// }
//
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/SemanticsFilter.java
import com.clarkparsia.owlwg.testcase.Semantics;
import com.clarkparsia.owlwg.testcase.SyntaxConstraint;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Semantics Filter Condition
* </p>
* <p>
* Description: Filter condition to match tests for which a particular semantics
* is applicable.
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class SemanticsFilter implements FilterCondition {
public static final SemanticsFilter DIRECT, RDF;
static {
DIRECT = new SemanticsFilter( Semantics.DIRECT );
RDF = new SemanticsFilter( Semantics.RDF );
}
final private Semantics semantics;
/**
* @throws NullPointerException
* if <code>semantics == null</code>
*/
public SemanticsFilter(Semantics semantics) {
if( semantics == null )
throw new NullPointerException();
this.semantics = semantics;
}
| public boolean accepts(TestCase testcase) { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/testcase/filter/DisjunctionFilter.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
| import java.util.Arrays;
import java.util.Collection;
import com.clarkparsia.owlwg.testcase.TestCase; | package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Disjunction Filter Condition
* </p>
* <p>
* Description: Filter condition that acts as a disjunction of other filter
* conditions
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class DisjunctionFilter implements FilterCondition {
public static DisjunctionFilter or(Collection<? extends FilterCondition> conditions) {
return new DisjunctionFilter( conditions );
}
public static DisjunctionFilter or(FilterCondition... conditions) {
return or( Arrays.asList( conditions ) );
}
final private FilterCondition[] conditions;
public DisjunctionFilter(Collection<? extends FilterCondition> conditions) {
if( conditions == null )
throw new NullPointerException();
this.conditions = conditions.toArray( new FilterCondition[0] );
}
public DisjunctionFilter(FilterCondition... conditions) {
final int n = conditions.length;
this.conditions = new FilterCondition[n];
System.arraycopy( conditions, 0, this.conditions, 0, n );
}
| // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/DisjunctionFilter.java
import java.util.Arrays;
import java.util.Collection;
import com.clarkparsia.owlwg.testcase.TestCase;
package com.clarkparsia.owlwg.testcase.filter;
/**
* <p>
* Title: Disjunction Filter Condition
* </p>
* <p>
* Description: Filter condition that acts as a disjunction of other filter
* conditions
* </p>
* <p>
* Copyright: Copyright © 2009
* </p>
* <p>
* Company: Clark & Parsia, LLC. <a
* href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
* </p>
*
* @author Mike Smith <msmith@clarkparsia.com>
*/
public class DisjunctionFilter implements FilterCondition {
public static DisjunctionFilter or(Collection<? extends FilterCondition> conditions) {
return new DisjunctionFilter( conditions );
}
public static DisjunctionFilter or(FilterCondition... conditions) {
return or( Arrays.asList( conditions ) );
}
final private FilterCondition[] conditions;
public DisjunctionFilter(Collection<? extends FilterCondition> conditions) {
if( conditions == null )
throw new NullPointerException();
this.conditions = conditions.toArray( new FilterCondition[0] );
}
public DisjunctionFilter(FilterCondition... conditions) {
final int n = conditions.length;
this.conditions = new FilterCondition[n];
System.arraycopy( conditions, 0, this.conditions, 0, n );
}
| public boolean accepts(TestCase testcase) { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/runner/ReadOnlyTestRunner.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java
// public interface TestRunResult {
//
// public void accept(TestRunResultVisitor visitor);
//
// public String getDetails();
//
// public RunResultType getResultType();
//
// public TestCase getTestCase();
//
// public TestRunner getTestRunner();
//
// public RunTestType getTestType();
// }
| import java.net.URI;
import java.util.Collection;
import org.semanticweb.owl.inference.OWLReasonerException;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testrun.TestRunResult; | this.uri = uri;
this.name = name;
}
@Override
public boolean equals(Object obj) {
if( this == obj )
return true;
if( obj instanceof ReadOnlyTestRunner ) {
final ReadOnlyTestRunner other = (ReadOnlyTestRunner) obj;
return this.uri.equals( other.uri );
}
return false;
}
public String getName() {
return name;
}
public URI getURI() {
return uri;
}
@Override
public int hashCode() {
return uri.hashCode();
}
| // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java
// public interface TestRunResult {
//
// public void accept(TestRunResultVisitor visitor);
//
// public String getDetails();
//
// public RunResultType getResultType();
//
// public TestCase getTestCase();
//
// public TestRunner getTestRunner();
//
// public RunTestType getTestType();
// }
// Path: core/src/com/clarkparsia/owlwg/runner/ReadOnlyTestRunner.java
import java.net.URI;
import java.util.Collection;
import org.semanticweb.owl.inference.OWLReasonerException;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testrun.TestRunResult;
this.uri = uri;
this.name = name;
}
@Override
public boolean equals(Object obj) {
if( this == obj )
return true;
if( obj instanceof ReadOnlyTestRunner ) {
final ReadOnlyTestRunner other = (ReadOnlyTestRunner) obj;
return this.uri.equals( other.uri );
}
return false;
}
public String getName() {
return name;
}
public URI getURI() {
return uri;
}
@Override
public int hashCode() {
return uri.hashCode();
}
| public Collection<TestRunResult> run(TestCase testcase, long timeout) { |
msmithcp/owlwg-test | core/src/com/clarkparsia/owlwg/runner/ReadOnlyTestRunner.java | // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java
// public interface TestRunResult {
//
// public void accept(TestRunResultVisitor visitor);
//
// public String getDetails();
//
// public RunResultType getResultType();
//
// public TestCase getTestCase();
//
// public TestRunner getTestRunner();
//
// public RunTestType getTestType();
// }
| import java.net.URI;
import java.util.Collection;
import org.semanticweb.owl.inference.OWLReasonerException;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testrun.TestRunResult; | this.uri = uri;
this.name = name;
}
@Override
public boolean equals(Object obj) {
if( this == obj )
return true;
if( obj instanceof ReadOnlyTestRunner ) {
final ReadOnlyTestRunner other = (ReadOnlyTestRunner) obj;
return this.uri.equals( other.uri );
}
return false;
}
public String getName() {
return name;
}
public URI getURI() {
return uri;
}
@Override
public int hashCode() {
return uri.hashCode();
}
| // Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
//
// public void accept(TestCaseVisitor<O> visitor);
//
// public Set<Semantics> getApplicableSemantics();
//
// public String getIdentifier();
//
// public Set<URI> getImportedOntologies();
//
// public String getImportedOntology(URI uri, SerializationFormat format);
//
// public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
//
// public Set<Semantics> getNotApplicableSemantics();
//
// public Set<SyntaxConstraint> getSatisfiedConstraints();
//
// public Status getStatus();
//
// public Set<SyntaxConstraint> getUnsatisfiedConstraints();
//
// public URI getURI();
// }
//
// Path: core/src/com/clarkparsia/owlwg/testrun/TestRunResult.java
// public interface TestRunResult {
//
// public void accept(TestRunResultVisitor visitor);
//
// public String getDetails();
//
// public RunResultType getResultType();
//
// public TestCase getTestCase();
//
// public TestRunner getTestRunner();
//
// public RunTestType getTestType();
// }
// Path: core/src/com/clarkparsia/owlwg/runner/ReadOnlyTestRunner.java
import java.net.URI;
import java.util.Collection;
import org.semanticweb.owl.inference.OWLReasonerException;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testrun.TestRunResult;
this.uri = uri;
this.name = name;
}
@Override
public boolean equals(Object obj) {
if( this == obj )
return true;
if( obj instanceof ReadOnlyTestRunner ) {
final ReadOnlyTestRunner other = (ReadOnlyTestRunner) obj;
return this.uri.equals( other.uri );
}
return false;
}
public String getName() {
return name;
}
public URI getURI() {
return uri;
}
@Override
public int hashCode() {
return uri.hashCode();
}
| public Collection<TestRunResult> run(TestCase testcase, long timeout) { |
andrewrapp/xbee-api | src/main/java/com/rapplogic/xbee/api/InputStreamThread.java | // Path: src/main/java/com/rapplogic/xbee/XBeeConnection.java
// public interface XBeeConnection {
// public OutputStream getOutputStream();
// public InputStream getInputStream();
// public void close() throws IOException;
// }
| import com.rapplogic.xbee.util.ByteUtils;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.log4j.Logger;
import com.rapplogic.xbee.XBeeConnection;
| /**
* Copyright (c) 2008 Andrew Rapp. All rights reserved.
*
* This file is part of XBee-API.
*
* XBee-API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XBee-API 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBee-API. If not, see <http://www.gnu.org/licenses/>.
*/
package com.rapplogic.xbee.api;
/**
* Reads data from the input stream and hands off to PacketParser for packet parsing.
* Notifies XBee class when a new packet is parsed
* <p/>
* @author andrew
*
*/
public class InputStreamThread implements Runnable {
private final static Logger log = Logger.getLogger(InputStreamThread.class);
private Thread thread;
private ExecutorService listenerPool;
private volatile boolean done = false;
| // Path: src/main/java/com/rapplogic/xbee/XBeeConnection.java
// public interface XBeeConnection {
// public OutputStream getOutputStream();
// public InputStream getInputStream();
// public void close() throws IOException;
// }
// Path: src/main/java/com/rapplogic/xbee/api/InputStreamThread.java
import com.rapplogic.xbee.util.ByteUtils;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.log4j.Logger;
import com.rapplogic.xbee.XBeeConnection;
/**
* Copyright (c) 2008 Andrew Rapp. All rights reserved.
*
* This file is part of XBee-API.
*
* XBee-API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XBee-API 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBee-API. If not, see <http://www.gnu.org/licenses/>.
*/
package com.rapplogic.xbee.api;
/**
* Reads data from the input stream and hands off to PacketParser for packet parsing.
* Notifies XBee class when a new packet is parsed
* <p/>
* @author andrew
*
*/
public class InputStreamThread implements Runnable {
private final static Logger log = Logger.getLogger(InputStreamThread.class);
private Thread thread;
private ExecutorService listenerPool;
private volatile boolean done = false;
| private final XBeeConnection connection;
|
andrewrapp/xbee-api | src/main/java/com/rapplogic/xbee/socket/SocketXBeeExample.java | // Path: src/main/java/com/rapplogic/xbee/XBeeConnection.java
// public interface XBeeConnection {
// public OutputStream getOutputStream();
// public InputStream getInputStream();
// public void close() throws IOException;
// }
| import com.rapplogic.xbee.XBeeConnection;
import com.rapplogic.xbee.api.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.IOException;
import java.net.SocketException;
import java.net.UnknownHostException; | package com.rapplogic.xbee.socket;
public class SocketXBeeExample {
private final static Logger log = Logger.getLogger(SocketXBeeExample.class);
public static void main(String[] args) throws UnknownHostException, XBeeException, IOException {
PropertyConfigurator.configure("log4j.properties");
try {
// must disable start checks until bug fixed
XBee xbee = new XBee(new XBeeConfiguration().withStartupChecks(false)); | // Path: src/main/java/com/rapplogic/xbee/XBeeConnection.java
// public interface XBeeConnection {
// public OutputStream getOutputStream();
// public InputStream getInputStream();
// public void close() throws IOException;
// }
// Path: src/main/java/com/rapplogic/xbee/socket/SocketXBeeExample.java
import com.rapplogic.xbee.XBeeConnection;
import com.rapplogic.xbee.api.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.IOException;
import java.net.SocketException;
import java.net.UnknownHostException;
package com.rapplogic.xbee.socket;
public class SocketXBeeExample {
private final static Logger log = Logger.getLogger(SocketXBeeExample.class);
public static void main(String[] args) throws UnknownHostException, XBeeException, IOException {
PropertyConfigurator.configure("log4j.properties");
try {
// must disable start checks until bug fixed
XBee xbee = new XBee(new XBeeConfiguration().withStartupChecks(false)); | xbee.initProviderConnection((XBeeConnection)new SocketXBeeConnection("pi", 9000)); |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ExceptionSubscriber.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/dialog/ProgressCancelListener.java
// public interface ProgressCancelListener {
// void onCancelProgress();
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/dialog/ProgressDialogHandler.java
// public class ProgressDialogHandler extends Handler {
//
// public static final int SHOW_PROGRESS_DIALOG = 1;
// public static final int DISMISS_PROGRESS_DIALOG = 2;
//
// private Dialog pd;
//
// private Context context;
// private boolean cancelable;
// private ProgressCancelListener mProgressCancelListener;
//
// AnimationDrawable drawable;
// ImageView imageView;
//
// Dialog loadingDialog;
// public ProgressDialogHandler(Context context, ProgressCancelListener mProgressCancelListener,
// boolean cancelable) {
// super();
// this.context = context;
// this.mProgressCancelListener = mProgressCancelListener;
// this.cancelable = cancelable;
// }
//
//
// private void dismissProgressDialog(){
// if (loadingDialog != null) {
// loadingDialog.dismiss();
// }
// }
//
//
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case SHOW_PROGRESS_DIALOG:
// initProgressDialog();
// break;
// case DISMISS_PROGRESS_DIALOG:
// dismissProgressDialog();
// break;
// }
// }
//
// private void initProgressDialog() {
// LayoutInflater inflater = LayoutInflater.from(context);
// View v = inflater.inflate(R.layout.loader_base_loading, null); // 得到加载view
// FrameLayout layout = (FrameLayout) v.findViewById(R.id.id_loading_and_retry);
//
// imageView = (ImageView) v.findViewById(R.id.imageView); // 加载布局
// drawable = (AnimationDrawable) imageView.getBackground();
// drawable.start();
//
// loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog
// // loadingDialog.setCancelable(true);// 不可以用"返回键"取消
// loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
// LinearLayout.LayoutParams.WRAP_CONTENT));
// loadingDialog.show();
// }
// }
| import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import com.zhy.authproject.dialog.ProgressCancelListener;
import com.zhy.authproject.dialog.ProgressDialogHandler;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import rx.Subscriber; | package com.zhy.authproject.data.remote;
/**
* Created by zhanghaoye on 10/29/16.
*/
public class ExceptionSubscriber<T> extends Subscriber<T> implements ProgressCancelListener{
private SimpleCallback<T> simpleCallback;
private Application application;
| // Path: AuthProject/app/src/main/java/com/zhy/authproject/dialog/ProgressCancelListener.java
// public interface ProgressCancelListener {
// void onCancelProgress();
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/dialog/ProgressDialogHandler.java
// public class ProgressDialogHandler extends Handler {
//
// public static final int SHOW_PROGRESS_DIALOG = 1;
// public static final int DISMISS_PROGRESS_DIALOG = 2;
//
// private Dialog pd;
//
// private Context context;
// private boolean cancelable;
// private ProgressCancelListener mProgressCancelListener;
//
// AnimationDrawable drawable;
// ImageView imageView;
//
// Dialog loadingDialog;
// public ProgressDialogHandler(Context context, ProgressCancelListener mProgressCancelListener,
// boolean cancelable) {
// super();
// this.context = context;
// this.mProgressCancelListener = mProgressCancelListener;
// this.cancelable = cancelable;
// }
//
//
// private void dismissProgressDialog(){
// if (loadingDialog != null) {
// loadingDialog.dismiss();
// }
// }
//
//
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case SHOW_PROGRESS_DIALOG:
// initProgressDialog();
// break;
// case DISMISS_PROGRESS_DIALOG:
// dismissProgressDialog();
// break;
// }
// }
//
// private void initProgressDialog() {
// LayoutInflater inflater = LayoutInflater.from(context);
// View v = inflater.inflate(R.layout.loader_base_loading, null); // 得到加载view
// FrameLayout layout = (FrameLayout) v.findViewById(R.id.id_loading_and_retry);
//
// imageView = (ImageView) v.findViewById(R.id.imageView); // 加载布局
// drawable = (AnimationDrawable) imageView.getBackground();
// drawable.start();
//
// loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog
// // loadingDialog.setCancelable(true);// 不可以用"返回键"取消
// loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
// LinearLayout.LayoutParams.WRAP_CONTENT));
// loadingDialog.show();
// }
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ExceptionSubscriber.java
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import com.zhy.authproject.dialog.ProgressCancelListener;
import com.zhy.authproject.dialog.ProgressDialogHandler;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import rx.Subscriber;
package com.zhy.authproject.data.remote;
/**
* Created by zhanghaoye on 10/29/16.
*/
public class ExceptionSubscriber<T> extends Subscriber<T> implements ProgressCancelListener{
private SimpleCallback<T> simpleCallback;
private Application application;
| private ProgressDialogHandler mProgressDialogHandler; |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
// public static final String PREFERENCES_NAME = "androidarchitecture";
// private SharedPreferences sharedPreferences;
//
//
// public PreferencesManager(Application application){
// sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
// }
//
// public void saveLoginInfo(String username,String password){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString("username",username);
// editor.putString("password",password);
// editor.commit();
// }
//
//
//
// public String getUserName(){
// return sharedPreferences.getString("username","");
// }
//
// public String getPassword(){
// return sharedPreferences.getString("password","");
// }
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
| import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import dagger.Module;
import dagger.Provides; | package com.zhy.authproject.module.login;
/**
* Created by zhanghaoye on 10/21/16.
*/
@Module
public class LoginModule {
private final LoginView loginView;
public LoginModule(LoginView loginView) {
this.loginView = loginView;
}
@Provides
LoginView provideLoginView() {
return loginView;
}
@Provides | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
// public static final String PREFERENCES_NAME = "androidarchitecture";
// private SharedPreferences sharedPreferences;
//
//
// public PreferencesManager(Application application){
// sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
// }
//
// public void saveLoginInfo(String username,String password){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString("username",username);
// editor.putString("password",password);
// editor.commit();
// }
//
//
//
// public String getUserName(){
// return sharedPreferences.getString("username","");
// }
//
// public String getPassword(){
// return sharedPreferences.getString("password","");
// }
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java
import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import dagger.Module;
import dagger.Provides;
package com.zhy.authproject.module.login;
/**
* Created by zhanghaoye on 10/21/16.
*/
@Module
public class LoginModule {
private final LoginView loginView;
public LoginModule(LoginView loginView) {
this.loginView = loginView;
}
@Provides
LoginView provideLoginView() {
return loginView;
}
@Provides | LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) { |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
// public static final String PREFERENCES_NAME = "androidarchitecture";
// private SharedPreferences sharedPreferences;
//
//
// public PreferencesManager(Application application){
// sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
// }
//
// public void saveLoginInfo(String username,String password){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString("username",username);
// editor.putString("password",password);
// editor.commit();
// }
//
//
//
// public String getUserName(){
// return sharedPreferences.getString("username","");
// }
//
// public String getPassword(){
// return sharedPreferences.getString("password","");
// }
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
| import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import dagger.Module;
import dagger.Provides; | package com.zhy.authproject.module.login;
/**
* Created by zhanghaoye on 10/21/16.
*/
@Module
public class LoginModule {
private final LoginView loginView;
public LoginModule(LoginView loginView) {
this.loginView = loginView;
}
@Provides
LoginView provideLoginView() {
return loginView;
}
@Provides | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
// public static final String PREFERENCES_NAME = "androidarchitecture";
// private SharedPreferences sharedPreferences;
//
//
// public PreferencesManager(Application application){
// sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
// }
//
// public void saveLoginInfo(String username,String password){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString("username",username);
// editor.putString("password",password);
// editor.commit();
// }
//
//
//
// public String getUserName(){
// return sharedPreferences.getString("username","");
// }
//
// public String getPassword(){
// return sharedPreferences.getString("password","");
// }
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java
import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import dagger.Module;
import dagger.Provides;
package com.zhy.authproject.module.login;
/**
* Created by zhanghaoye on 10/21/16.
*/
@Module
public class LoginModule {
private final LoginView loginView;
public LoginModule(LoginView loginView) {
this.loginView = loginView;
}
@Provides
LoginView provideLoginView() {
return loginView;
}
@Provides | LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) { |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/di/ApiModule.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
// String SERVER_URL = "http://127.0.0.1:3000/";
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/login")
// Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/{id}/modify_activity")
// Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
//
// @GET("/api/v1/authproject/{id}")
// Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
//
// }
| import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | package com.zhy.authproject.di;
/**
* Created by zhanghaoye on 10/24/16.
*/
@Module
public class ApiModule {
@Provides
@Singleton
public OkHttpClient provideOkHttpClient() {
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(logging);
}
builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
.readTimeout(60 * 1000, TimeUnit.MILLISECONDS);
return builder.build();
}
@Provides
@Singleton
public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
Retrofit.Builder builder = new Retrofit.Builder();
builder.client(okHttpClient) | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
// String SERVER_URL = "http://127.0.0.1:3000/";
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/login")
// Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/{id}/modify_activity")
// Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
//
// @GET("/api/v1/authproject/{id}")
// Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
//
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/ApiModule.java
import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
package com.zhy.authproject.di;
/**
* Created by zhanghaoye on 10/24/16.
*/
@Module
public class ApiModule {
@Provides
@Singleton
public OkHttpClient provideOkHttpClient() {
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(logging);
}
builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
.readTimeout(60 * 1000, TimeUnit.MILLISECONDS);
return builder.build();
}
@Provides
@Singleton
public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
Retrofit.Builder builder = new Retrofit.Builder();
builder.client(okHttpClient) | .baseUrl(ApiService.SERVER_URL) |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/di/ApiModule.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
// String SERVER_URL = "http://127.0.0.1:3000/";
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/login")
// Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/{id}/modify_activity")
// Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
//
// @GET("/api/v1/authproject/{id}")
// Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
//
// }
| import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(logging);
}
builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
.readTimeout(60 * 1000, TimeUnit.MILLISECONDS);
return builder.build();
}
@Provides
@Singleton
public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
Retrofit.Builder builder = new Retrofit.Builder();
builder.client(okHttpClient)
.baseUrl(ApiService.SERVER_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
@Provides
@Singleton
public ApiService provideApiService(Retrofit restAdapter) {
return restAdapter.create(ApiService.class);
}
@Provides
@Singleton | // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
// private final ApiService apiService;
//
// private final Application application;
//
// public ApiManager(ApiService apiService, Application application) {
// this.apiService = apiService;
// this.application = application;
// }
//
// //登录
// public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
// apiService.login(username,password)
// .flatMap(new BaseResponseFunc<User>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
// }
//
// //获取活动列表
// public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
// apiService.getActivityInfo(id,user_id,access_token)
// .flatMap(new BaseResponseFunc<ActivityInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
// }
//
// //修改活动信息
// public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
// apiService.modifyActivity(activity_id,user_id,access_token)
// .flatMap(new BaseResponseFunc<CommonInfo>())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
// }
//
//
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
// String SERVER_URL = "http://127.0.0.1:3000/";
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/login")
// Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
//
// @FormUrlEncoded
// @POST("/api/v1/authproject/{id}/modify_activity")
// Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
//
// @GET("/api/v1/authproject/{id}")
// Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
//
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/ApiModule.java
import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(logging);
}
builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
.readTimeout(60 * 1000, TimeUnit.MILLISECONDS);
return builder.build();
}
@Provides
@Singleton
public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
Retrofit.Builder builder = new Retrofit.Builder();
builder.client(okHttpClient)
.baseUrl(ApiService.SERVER_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
@Provides
@Singleton
public ApiService provideApiService(Retrofit restAdapter) {
return restAdapter.create(ApiService.class);
}
@Provides
@Singleton | public ApiManager provideApiManager(Application application, ApiService githubApiService) { |
xzwc/AndroidProject | AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java | // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginComponent.java
// @Subcomponent(modules = LoginModule.class)
// public interface LoginComponent {
// LoginActivity inject(LoginActivity loginActivity);
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java
// @Module
// public class LoginModule {
// private final LoginView loginView;
//
// public LoginModule(LoginView loginView) {
// this.loginView = loginView;
// }
//
// @Provides
// LoginView provideLoginView() {
// return loginView;
// }
//
//
// @Provides
// LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) {
// return new LoginPresenter(loginView,apiManager,preferencesManager);
// }
// }
| import com.zhy.authproject.module.login.LoginComponent;
import com.zhy.authproject.module.login.LoginModule;
import javax.inject.Singleton;
import dagger.Component; | package com.zhy.authproject.di;
/**
* Created by zhanghaoye on 10/24/16.
*/
@Singleton
@Component(modules = {AppModule.class, ApiModule.class})
public interface AppComponent { | // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginComponent.java
// @Subcomponent(modules = LoginModule.class)
// public interface LoginComponent {
// LoginActivity inject(LoginActivity loginActivity);
// }
//
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java
// @Module
// public class LoginModule {
// private final LoginView loginView;
//
// public LoginModule(LoginView loginView) {
// this.loginView = loginView;
// }
//
// @Provides
// LoginView provideLoginView() {
// return loginView;
// }
//
//
// @Provides
// LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) {
// return new LoginPresenter(loginView,apiManager,preferencesManager);
// }
// }
// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java
import com.zhy.authproject.module.login.LoginComponent;
import com.zhy.authproject.module.login.LoginModule;
import javax.inject.Singleton;
import dagger.Component;
package com.zhy.authproject.di;
/**
* Created by zhanghaoye on 10/24/16.
*/
@Singleton
@Component(modules = {AppModule.class, ApiModule.class})
public interface AppComponent { | LoginComponent plus(LoginModule loginModule); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.