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 |
|---|---|---|---|---|---|---|
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/GlobalClass.java | // Path: app/src/main/java/it/unisannio/security/DoApp/model/ExceptionReport.java
// public class ExceptionReport {
//
// private String appName; //component name
// private String processName; //package name
// private int PID;
// private Date time;
// private String type;
// private Stack<PointOfFailure> stacktrace;
// private ArrayList<MalIntent> malIntents;
//
// public ExceptionReport(){
// stacktrace = new Stack<PointOfFailure>();
// malIntents = new ArrayList<MalIntent>();
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getProcessName() {
// return processName;
// }
//
// public void setProcessName(String processName) {
// this.processName = processName;
// }
//
// public int getPID() {
// return PID;
// }
//
// public void setPID(int PID) {
// this.PID = PID;
// }
//
// public Date getTime() {
// return time;
// }
//
// public void setTime(Date time) {
// this.time = time;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Stack<PointOfFailure> getStacktrace() {
// return stacktrace;
// }
//
// public void addPointOfFailure(PointOfFailure pof){
// stacktrace.push(pof);
// }
//
// public ArrayList<MalIntent> getMalIntents() {
// return malIntents;
// }
//
// public void addMalIntent(MalIntent malIntent) {
// if(malIntent!=null)
// malIntents.add(malIntent);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ExceptionReport that = (ExceptionReport) o;
//
// if (appName != null ? !appName.equals(that.appName) : that.appName != null) return false;
// if (processName != null ? !processName.equals(that.processName) : that.processName != null)
// return false;
// if (type != null ? !type.equals(that.type) : that.type != null) return false;
// if (stacktrace.size()!=that.stacktrace.size()) return false;
//
// for(int i = 0; i<stacktrace.size(); i++){
// if(!stacktrace.get(i).equals(that.stacktrace.get(i)))
// return false;
// }
// return true;
//
// }
//
//
// public String toString(){
// String stack_string="";
// Iterator<PointOfFailure> iterator = stacktrace.iterator();
// while(iterator.hasNext()){
// PointOfFailure pof = iterator.next();
// stack_string = stack_string+"\t"+pof.getClassName()+":"+pof.getLineNumber()+"\n";
// }
//
// String malintent_string="";
// for(MalIntent m : malIntents)
// malintent_string+= "\n "+m.toString();
//
// return "ExceptionReport: "+
// "\n\t Package Name: "+processName+
// "\n\t Component Name: "+appName+
// "\n\t Crash PID: "+PID+
// "\n\t"+ ((malintent_string.isEmpty())?"MalIntent Unknown" : malintent_string) +
// "\n\t" + "ExceptionType: "+type+"" +
// "\n\t Stacktrace: \n"+stack_string;
// }
// }
| import android.app.Application;
import java.util.List;
import it.unisannio.security.DoApp.model.ExceptionReport; | package it.unisannio.security.DoApp;
/**
* Created by antonio on 27/01/17.
* Classe usata per condividere oggetti tra i vari componenti
*/
public class GlobalClass extends Application {
private static GlobalClass singleton;
| // Path: app/src/main/java/it/unisannio/security/DoApp/model/ExceptionReport.java
// public class ExceptionReport {
//
// private String appName; //component name
// private String processName; //package name
// private int PID;
// private Date time;
// private String type;
// private Stack<PointOfFailure> stacktrace;
// private ArrayList<MalIntent> malIntents;
//
// public ExceptionReport(){
// stacktrace = new Stack<PointOfFailure>();
// malIntents = new ArrayList<MalIntent>();
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getProcessName() {
// return processName;
// }
//
// public void setProcessName(String processName) {
// this.processName = processName;
// }
//
// public int getPID() {
// return PID;
// }
//
// public void setPID(int PID) {
// this.PID = PID;
// }
//
// public Date getTime() {
// return time;
// }
//
// public void setTime(Date time) {
// this.time = time;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Stack<PointOfFailure> getStacktrace() {
// return stacktrace;
// }
//
// public void addPointOfFailure(PointOfFailure pof){
// stacktrace.push(pof);
// }
//
// public ArrayList<MalIntent> getMalIntents() {
// return malIntents;
// }
//
// public void addMalIntent(MalIntent malIntent) {
// if(malIntent!=null)
// malIntents.add(malIntent);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ExceptionReport that = (ExceptionReport) o;
//
// if (appName != null ? !appName.equals(that.appName) : that.appName != null) return false;
// if (processName != null ? !processName.equals(that.processName) : that.processName != null)
// return false;
// if (type != null ? !type.equals(that.type) : that.type != null) return false;
// if (stacktrace.size()!=that.stacktrace.size()) return false;
//
// for(int i = 0; i<stacktrace.size(); i++){
// if(!stacktrace.get(i).equals(that.stacktrace.get(i)))
// return false;
// }
// return true;
//
// }
//
//
// public String toString(){
// String stack_string="";
// Iterator<PointOfFailure> iterator = stacktrace.iterator();
// while(iterator.hasNext()){
// PointOfFailure pof = iterator.next();
// stack_string = stack_string+"\t"+pof.getClassName()+":"+pof.getLineNumber()+"\n";
// }
//
// String malintent_string="";
// for(MalIntent m : malIntents)
// malintent_string+= "\n "+m.toString();
//
// return "ExceptionReport: "+
// "\n\t Package Name: "+processName+
// "\n\t Component Name: "+appName+
// "\n\t Crash PID: "+PID+
// "\n\t"+ ((malintent_string.isEmpty())?"MalIntent Unknown" : malintent_string) +
// "\n\t" + "ExceptionType: "+type+"" +
// "\n\t Stacktrace: \n"+stack_string;
// }
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/GlobalClass.java
import android.app.Application;
import java.util.List;
import it.unisannio.security.DoApp.model.ExceptionReport;
package it.unisannio.security.DoApp;
/**
* Created by antonio on 27/01/17.
* Classe usata per condividere oggetti tra i vari componenti
*/
public class GlobalClass extends Application {
private static GlobalClass singleton;
| public static List<ExceptionReport> reports; |
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/activities/CrashedListActivity.java | // Path: app/src/main/java/it/unisannio/security/DoApp/GlobalClass.java
// public class GlobalClass extends Application {
//
// private static GlobalClass singleton;
//
// public static List<ExceptionReport> reports;
//
// public static GlobalClass getInstance() {
// return singleton;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// singleton = this;
// }
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
| import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import it.unisannio.security.DoApp.GlobalClass;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons; | package it.unisannio.security.DoApp.activities;
public class CrashedListActivity extends AppCompatActivity {
ListView list;
TextView tvResult;
String pathfile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crashed_list);
//path al file contente il report | // Path: app/src/main/java/it/unisannio/security/DoApp/GlobalClass.java
// public class GlobalClass extends Application {
//
// private static GlobalClass singleton;
//
// public static List<ExceptionReport> reports;
//
// public static GlobalClass getInstance() {
// return singleton;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// singleton = this;
// }
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/activities/CrashedListActivity.java
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import it.unisannio.security.DoApp.GlobalClass;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons;
package it.unisannio.security.DoApp.activities;
public class CrashedListActivity extends AppCompatActivity {
ListView list;
TextView tvResult;
String pathfile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crashed_list);
//path al file contente il report | pathfile = getIntent().getStringExtra(Commons.pathFile); |
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/util/ReportWriter.java | // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/ExceptionReport.java
// public class ExceptionReport {
//
// private String appName; //component name
// private String processName; //package name
// private int PID;
// private Date time;
// private String type;
// private Stack<PointOfFailure> stacktrace;
// private ArrayList<MalIntent> malIntents;
//
// public ExceptionReport(){
// stacktrace = new Stack<PointOfFailure>();
// malIntents = new ArrayList<MalIntent>();
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getProcessName() {
// return processName;
// }
//
// public void setProcessName(String processName) {
// this.processName = processName;
// }
//
// public int getPID() {
// return PID;
// }
//
// public void setPID(int PID) {
// this.PID = PID;
// }
//
// public Date getTime() {
// return time;
// }
//
// public void setTime(Date time) {
// this.time = time;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Stack<PointOfFailure> getStacktrace() {
// return stacktrace;
// }
//
// public void addPointOfFailure(PointOfFailure pof){
// stacktrace.push(pof);
// }
//
// public ArrayList<MalIntent> getMalIntents() {
// return malIntents;
// }
//
// public void addMalIntent(MalIntent malIntent) {
// if(malIntent!=null)
// malIntents.add(malIntent);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ExceptionReport that = (ExceptionReport) o;
//
// if (appName != null ? !appName.equals(that.appName) : that.appName != null) return false;
// if (processName != null ? !processName.equals(that.processName) : that.processName != null)
// return false;
// if (type != null ? !type.equals(that.type) : that.type != null) return false;
// if (stacktrace.size()!=that.stacktrace.size()) return false;
//
// for(int i = 0; i<stacktrace.size(); i++){
// if(!stacktrace.get(i).equals(that.stacktrace.get(i)))
// return false;
// }
// return true;
//
// }
//
//
// public String toString(){
// String stack_string="";
// Iterator<PointOfFailure> iterator = stacktrace.iterator();
// while(iterator.hasNext()){
// PointOfFailure pof = iterator.next();
// stack_string = stack_string+"\t"+pof.getClassName()+":"+pof.getLineNumber()+"\n";
// }
//
// String malintent_string="";
// for(MalIntent m : malIntents)
// malintent_string+= "\n "+m.toString();
//
// return "ExceptionReport: "+
// "\n\t Package Name: "+processName+
// "\n\t Component Name: "+appName+
// "\n\t Crash PID: "+PID+
// "\n\t"+ ((malintent_string.isEmpty())?"MalIntent Unknown" : malintent_string) +
// "\n\t" + "ExceptionType: "+type+"" +
// "\n\t Stacktrace: \n"+stack_string;
// }
// }
| import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.List;
import it.unisannio.security.DoApp.model.Commons;
import it.unisannio.security.DoApp.model.ExceptionReport; | package it.unisannio.security.DoApp.util;
/**
* Created by Luigi on 15/01/2017.
*/
public class ReportWriter {
public static String scriviSuFile(List<ExceptionReport> reports, String pkgname){
try {
String fil=".txt"; | // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/ExceptionReport.java
// public class ExceptionReport {
//
// private String appName; //component name
// private String processName; //package name
// private int PID;
// private Date time;
// private String type;
// private Stack<PointOfFailure> stacktrace;
// private ArrayList<MalIntent> malIntents;
//
// public ExceptionReport(){
// stacktrace = new Stack<PointOfFailure>();
// malIntents = new ArrayList<MalIntent>();
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getProcessName() {
// return processName;
// }
//
// public void setProcessName(String processName) {
// this.processName = processName;
// }
//
// public int getPID() {
// return PID;
// }
//
// public void setPID(int PID) {
// this.PID = PID;
// }
//
// public Date getTime() {
// return time;
// }
//
// public void setTime(Date time) {
// this.time = time;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Stack<PointOfFailure> getStacktrace() {
// return stacktrace;
// }
//
// public void addPointOfFailure(PointOfFailure pof){
// stacktrace.push(pof);
// }
//
// public ArrayList<MalIntent> getMalIntents() {
// return malIntents;
// }
//
// public void addMalIntent(MalIntent malIntent) {
// if(malIntent!=null)
// malIntents.add(malIntent);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ExceptionReport that = (ExceptionReport) o;
//
// if (appName != null ? !appName.equals(that.appName) : that.appName != null) return false;
// if (processName != null ? !processName.equals(that.processName) : that.processName != null)
// return false;
// if (type != null ? !type.equals(that.type) : that.type != null) return false;
// if (stacktrace.size()!=that.stacktrace.size()) return false;
//
// for(int i = 0; i<stacktrace.size(); i++){
// if(!stacktrace.get(i).equals(that.stacktrace.get(i)))
// return false;
// }
// return true;
//
// }
//
//
// public String toString(){
// String stack_string="";
// Iterator<PointOfFailure> iterator = stacktrace.iterator();
// while(iterator.hasNext()){
// PointOfFailure pof = iterator.next();
// stack_string = stack_string+"\t"+pof.getClassName()+":"+pof.getLineNumber()+"\n";
// }
//
// String malintent_string="";
// for(MalIntent m : malIntents)
// malintent_string+= "\n "+m.toString();
//
// return "ExceptionReport: "+
// "\n\t Package Name: "+processName+
// "\n\t Component Name: "+appName+
// "\n\t Crash PID: "+PID+
// "\n\t"+ ((malintent_string.isEmpty())?"MalIntent Unknown" : malintent_string) +
// "\n\t" + "ExceptionType: "+type+"" +
// "\n\t Stacktrace: \n"+stack_string;
// }
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/util/ReportWriter.java
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.List;
import it.unisannio.security.DoApp.model.Commons;
import it.unisannio.security.DoApp.model.ExceptionReport;
package it.unisannio.security.DoApp.util;
/**
* Created by Luigi on 15/01/2017.
*/
public class ReportWriter {
public static String scriviSuFile(List<ExceptionReport> reports, String pkgname){
try {
String fil=".txt"; | File fa = new File(Commons.path); |
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/activities/ViewReportActivity.java | // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/MalIntent.java
// public class MalIntent extends Intent{
//
// private AndroidComponent targetComponent;
//
// public MalIntent(IntentDataInfo datafield){
// super();
// this.targetComponent = datafield.getComponent();
// String packageName = datafield.getPackageName();
//
// // se il nome inizia per '.' è necessario creare il nome completo del componente
// // altrimenti si va in ActivityNotFoundException durante lo startActivity()
// String name = targetComponent.name;
// if(name.startsWith("."))
// name = packageName+name;
//
// this.setComponent(new ComponentName(packageName, name));
// }
//
// //empty constructor
// private MalIntent(){super();}
//
// public AndroidComponent getTargetComponent() {
// return targetComponent;
// }
//
// public void setTargetComponent(AndroidComponent targetComponent) {
// this.targetComponent = targetComponent;
// }
//
// public MalIntent clone(){
// MalIntent cloned = new MalIntent();
// cloned.setType(this.getType());
// cloned.setComponent(this.getComponent());
// if(this.getExtras()!=null)
// cloned.putExtras(this.getExtras());
// cloned.setTargetComponent(this.targetComponent);
// cloned.setData(this.getData());
//
// return cloned;
// }
//
// @Override
// public boolean equals(Object object){
// MalIntent mal1 = (MalIntent) object;
// // filterEquals fa: Returns true if action, data, type, class, and categories are the same.
// if(this.filterEquals(mal1)){
// //dobbiamo fare il confronto per gli extra in qualche modo
// Bundle b1 = mal1.getExtras();
// Bundle b = this.getExtras();
// if (b1 == null && b == null)
// return true;
// else if (b1 == null ^ b == null) // xor: ^
// return false;
// else {
// // dynamic binding (speriamo che va)
// return equalsObject(b.get(Intent.EXTRA_TEXT), b1.get(Intent.EXTRA_TEXT)) &&
// equalsObject(b.get(Intent.EXTRA_STREAM), b1.get(EXTRA_STREAM)) &&
// equalsObject(this.getData(), mal1.getData());
// }
// }
// return false;
// }
//
// private static boolean equalsObject(Object o, Object o1){
// if ( o == null && o1 == null)
// return true;
// else if (o == null ^ o1 == null)
// return false;
// else return o.equals(o1);
// }
//
// public String toString(){
// return "MalIntent: \n\t Type: "+((getType()==null)? "null" : getType()) +
// "\t - Action:" + ((getAction() == null) ? "null" : getAction())+
// "\t - Extra Text: "+((getExtras()==null) || ((getExtras().get(Intent.EXTRA_TEXT) == null))? "null" : getExtras().get(Intent.EXTRA_TEXT)) +
// "\t - Extra Stream: "+((getExtras()==null) || ((getExtras().get(Intent.EXTRA_STREAM) == null))? "null" : getExtras().get(Intent.EXTRA_STREAM)) +
// "\t - Data: " + ((getData() == null ) ? "null" : getData().toString());
// }
//
//
//
// }
| import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons;
import it.unisannio.security.DoApp.model.MalIntent; | package it.unisannio.security.DoApp.activities;
public class ViewReportActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_activity);
| // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
//
// Path: app/src/main/java/it/unisannio/security/DoApp/model/MalIntent.java
// public class MalIntent extends Intent{
//
// private AndroidComponent targetComponent;
//
// public MalIntent(IntentDataInfo datafield){
// super();
// this.targetComponent = datafield.getComponent();
// String packageName = datafield.getPackageName();
//
// // se il nome inizia per '.' è necessario creare il nome completo del componente
// // altrimenti si va in ActivityNotFoundException durante lo startActivity()
// String name = targetComponent.name;
// if(name.startsWith("."))
// name = packageName+name;
//
// this.setComponent(new ComponentName(packageName, name));
// }
//
// //empty constructor
// private MalIntent(){super();}
//
// public AndroidComponent getTargetComponent() {
// return targetComponent;
// }
//
// public void setTargetComponent(AndroidComponent targetComponent) {
// this.targetComponent = targetComponent;
// }
//
// public MalIntent clone(){
// MalIntent cloned = new MalIntent();
// cloned.setType(this.getType());
// cloned.setComponent(this.getComponent());
// if(this.getExtras()!=null)
// cloned.putExtras(this.getExtras());
// cloned.setTargetComponent(this.targetComponent);
// cloned.setData(this.getData());
//
// return cloned;
// }
//
// @Override
// public boolean equals(Object object){
// MalIntent mal1 = (MalIntent) object;
// // filterEquals fa: Returns true if action, data, type, class, and categories are the same.
// if(this.filterEquals(mal1)){
// //dobbiamo fare il confronto per gli extra in qualche modo
// Bundle b1 = mal1.getExtras();
// Bundle b = this.getExtras();
// if (b1 == null && b == null)
// return true;
// else if (b1 == null ^ b == null) // xor: ^
// return false;
// else {
// // dynamic binding (speriamo che va)
// return equalsObject(b.get(Intent.EXTRA_TEXT), b1.get(Intent.EXTRA_TEXT)) &&
// equalsObject(b.get(Intent.EXTRA_STREAM), b1.get(EXTRA_STREAM)) &&
// equalsObject(this.getData(), mal1.getData());
// }
// }
// return false;
// }
//
// private static boolean equalsObject(Object o, Object o1){
// if ( o == null && o1 == null)
// return true;
// else if (o == null ^ o1 == null)
// return false;
// else return o.equals(o1);
// }
//
// public String toString(){
// return "MalIntent: \n\t Type: "+((getType()==null)? "null" : getType()) +
// "\t - Action:" + ((getAction() == null) ? "null" : getAction())+
// "\t - Extra Text: "+((getExtras()==null) || ((getExtras().get(Intent.EXTRA_TEXT) == null))? "null" : getExtras().get(Intent.EXTRA_TEXT)) +
// "\t - Extra Stream: "+((getExtras()==null) || ((getExtras().get(Intent.EXTRA_STREAM) == null))? "null" : getExtras().get(Intent.EXTRA_STREAM)) +
// "\t - Data: " + ((getData() == null ) ? "null" : getData().toString());
// }
//
//
//
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/activities/ViewReportActivity.java
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons;
import it.unisannio.security.DoApp.model.MalIntent;
package it.unisannio.security.DoApp.activities;
public class ViewReportActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_activity);
| String pathFile = getIntent().getStringExtra(Commons.pathFile); |
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/util/PackageInfoExtractor.java | // Path: app/src/main/java/it/unisannio/security/DoApp/model/IntentDataInfo.java
// public class IntentDataInfo extends IntentFilter.IntentData{
//
// private AndroidComponent component;
// private String packageName;
// private IntentFilter filter; //intent-filter in which is declared the <data> field
//
// public IntentDataInfo(IntentFilter.IntentData data, AndroidComponent component, String packageName, IntentFilter filter) {
// super(data.scheme, data.host, data.port, data.path, data.pathPattern, data.pathPrefix, data.mimeType, data.type);
// this.component = component;
// this.packageName = packageName;
// this.filter = filter;
// }
//
// public AndroidComponent getComponent(){
// return component;
// }
//
// public void setComponent(AndroidComponent component){
// this.component = component;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public IntentFilter getFilter() {
// return filter;
// }
//
// public void setFilter(IntentFilter filter) {
// this.filter = filter;
// }
// }
| import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import it.unisannio.security.DoApp.model.IntentDataInfo;
import com.jaredrummler.apkparser.ApkParser;
import com.jaredrummler.apkparser.model.AndroidComponent;
import com.jaredrummler.apkparser.model.AndroidManifest;
import com.jaredrummler.apkparser.model.IntentFilter;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; | package it.unisannio.security.DoApp.util;
/**
* Created by antonio on 05/01/17.
*/
public class PackageInfoExtractor {
private Context context;
private String pkgname;
public PackageInfoExtractor(Context context, String pkgname){
this.context = context;
this.pkgname = pkgname;
}
public List<AndroidComponent> extractComponents(){
ApkParser manifestParser = null;
List<AndroidComponent> components = new ArrayList<AndroidComponent>();
try {
manifestParser = ApkParser.create(context.getPackageManager(), pkgname);
AndroidManifest manifest = null;
try{
manifest = manifestParser.getAndroidManifest();
components = manifest.getComponents();
}
catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return components;
}
| // Path: app/src/main/java/it/unisannio/security/DoApp/model/IntentDataInfo.java
// public class IntentDataInfo extends IntentFilter.IntentData{
//
// private AndroidComponent component;
// private String packageName;
// private IntentFilter filter; //intent-filter in which is declared the <data> field
//
// public IntentDataInfo(IntentFilter.IntentData data, AndroidComponent component, String packageName, IntentFilter filter) {
// super(data.scheme, data.host, data.port, data.path, data.pathPattern, data.pathPrefix, data.mimeType, data.type);
// this.component = component;
// this.packageName = packageName;
// this.filter = filter;
// }
//
// public AndroidComponent getComponent(){
// return component;
// }
//
// public void setComponent(AndroidComponent component){
// this.component = component;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public IntentFilter getFilter() {
// return filter;
// }
//
// public void setFilter(IntentFilter filter) {
// this.filter = filter;
// }
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/util/PackageInfoExtractor.java
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import it.unisannio.security.DoApp.model.IntentDataInfo;
import com.jaredrummler.apkparser.ApkParser;
import com.jaredrummler.apkparser.model.AndroidComponent;
import com.jaredrummler.apkparser.model.AndroidManifest;
import com.jaredrummler.apkparser.model.IntentFilter;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
package it.unisannio.security.DoApp.util;
/**
* Created by antonio on 05/01/17.
*/
public class PackageInfoExtractor {
private Context context;
private String pkgname;
public PackageInfoExtractor(Context context, String pkgname){
this.context = context;
this.pkgname = pkgname;
}
public List<AndroidComponent> extractComponents(){
ApkParser manifestParser = null;
List<AndroidComponent> components = new ArrayList<AndroidComponent>();
try {
manifestParser = ApkParser.create(context.getPackageManager(), pkgname);
AndroidManifest manifest = null;
try{
manifest = manifestParser.getAndroidManifest();
components = manifest.getComponents();
}
catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return components;
}
| public List<IntentDataInfo> extractIntentFiltersDataType(){ |
sundevin/PicturePicker | picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java | // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate; | package devin.com.picturepicker.adapter;
/**
* <p> Created by Devin Sun on 2016/10/15.
*/
public class PopupFolderListAdapter extends BaseAdapter {
private String currentSelectFolderPath;
private Context context; | // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
// Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate;
package devin.com.picturepicker.adapter;
/**
* <p> Created by Devin Sun on 2016/10/15.
*/
public class PopupFolderListAdapter extends BaseAdapter {
private String currentSelectFolderPath;
private Context context; | private List<PictureFolder> pictureFolderList; |
sundevin/PicturePicker | picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java | // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate; | package devin.com.picturepicker.adapter;
/**
* <p> Created by Devin Sun on 2016/10/15.
*/
public class PopupFolderListAdapter extends BaseAdapter {
private String currentSelectFolderPath;
private Context context;
private List<PictureFolder> pictureFolderList;
public PopupFolderListAdapter(Context context, List<PictureFolder> pictureFolderList) {
this.context = context;
this.pictureFolderList = pictureFolderList;
}
@Override
public int getCount() {
return pictureFolderList == null ? 0 : pictureFolderList.size();
}
@Override
public Object getItem(int position) {
return pictureFolderList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
| // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
// Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate;
package devin.com.picturepicker.adapter;
/**
* <p> Created by Devin Sun on 2016/10/15.
*/
public class PopupFolderListAdapter extends BaseAdapter {
private String currentSelectFolderPath;
private Context context;
private List<PictureFolder> pictureFolderList;
public PopupFolderListAdapter(Context context, List<PictureFolder> pictureFolderList) {
this.context = context;
this.pictureFolderList = pictureFolderList;
}
@Override
public int getCount() {
return pictureFolderList == null ? 0 : pictureFolderList.size();
}
@Override
public Object getItem(int position) {
return pictureFolderList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
| ItemFolderListHolder holder; |
sundevin/PicturePicker | picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java | // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate; | }
@Override
public int getCount() {
return pictureFolderList == null ? 0 : pictureFolderList.size();
}
@Override
public Object getItem(int position) {
return pictureFolderList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemFolderListHolder holder;
if (convertView == null) {
convertView = inflate(context, R.layout.item_folder_list, null);
holder = new ItemFolderListHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ItemFolderListHolder) convertView.getTag();
}
PictureFolder pictureFolder = pictureFolderList.get(position); | // Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/viewholder/ItemFolderListHolder.java
// public class ItemFolderListHolder extends RecyclerView.ViewHolder {
// private ImageView ivFolderCover;
// private TextView tvFolderName;
// private TextView tvPictureCount;
// private ImageView ivFolderCheck;
//
// public ItemFolderListHolder(LayoutInflater inflater, ViewGroup parent) {
// this(inflater.inflate(R.layout.item_folder_list, parent, false));
// }
//
// public ItemFolderListHolder(View view) {
// super(view);
// ivFolderCover = (ImageView) view.findViewById(R.id.iv_folder_cover);
// tvFolderName = (TextView) view.findViewById(R.id.tv_folder_name);
// tvPictureCount = (TextView) view.findViewById(R.id.tv_picture_count);
// ivFolderCheck = (ImageView) view.findViewById(R.id.iv_folder_check);
// }
//
// public TextView getTvFolderName() {
// return tvFolderName;
// }
//
// public TextView getTvPictureCount() {
// return tvPictureCount;
// }
//
// public ImageView getIvFolderCheck() {
// return ivFolderCheck;
// }
//
// public ImageView getIvFolderCover() {
// return ivFolderCover;
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/utils/ImageLoader.java
// public class ImageLoader {
//
// public static void load(Context context, String path, ImageView imageView) {
// RequestOptions requestOptions =
// new RequestOptions()
// .placeholder(R.drawable.default_picture)
// .error(R.drawable.default_picture);
// Glide.with(context)
// .load(path)
// .apply(requestOptions)
// .into(imageView);
//
// }
// }
// Path: picturepicker/src/main/java/devin/com/picturepicker/adapter/PopupFolderListAdapter.java
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.adapter.viewholder.ItemFolderListHolder;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.utils.ImageLoader;
import static android.view.View.inflate;
}
@Override
public int getCount() {
return pictureFolderList == null ? 0 : pictureFolderList.size();
}
@Override
public Object getItem(int position) {
return pictureFolderList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemFolderListHolder holder;
if (convertView == null) {
convertView = inflate(context, R.layout.item_folder_list, null);
holder = new ItemFolderListHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ItemFolderListHolder) convertView.getTag();
}
PictureFolder pictureFolder = pictureFolderList.get(position); | ImageLoader.load(context, pictureFolder.folderCover.pictureAbsPath, holder.getIvFolderCover()); |
sundevin/PicturePicker | picturepicker/src/main/java/devin/com/picturepicker/pick/PictureScanner.java | // Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureItem.java
// public class PictureItem implements Serializable {
//
// /**
// * 图片名称
// */
// public String pictureName;
// /**
// * 图片绝对路径
// */
// public String pictureAbsPath;
// /**
// * 图片类型
// */
// public String pictureMimeType;
// /**
// * 图片大小
// */
// public long pictureSize;
// /**
// * 图片加入的时间
// */
// public long pictureAddTime;
// /**
// * 图片的宽
// */
// public int pictureWidth;
// /**
// * 图片的高
// */
// public int pictureHeight;
//
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureItem) {
// PictureItem pictureItem = ((PictureItem) o);
// return TextUtils.equals(pictureItem.pictureAbsPath, pictureAbsPath)
// &&
// pictureItem.pictureAddTime == pictureAddTime;
// }
// return super.equals(o);
// }
// }
| import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.javabean.PictureItem; | package devin.com.picturepicker.pick;
/**
* <p> Created by Devin Sun on 2016/10/14.
*/
public class PictureScanner implements LoaderManager.LoaderCallbacks<Cursor> {
private final int SCANNER_ID = 0;
/**
* 查询图片需要的数据列
*/
private final String[] IMAGE_PROJECTION = {
////图片的显示名称 aaa.jpg
MediaStore.Images.Media.DISPLAY_NAME,
//图片的真实路径 /storage/emulated/0/pp/downloader/wallpaper/aaa.jpg
MediaStore.Images.Media.DATA,
//图片的大小,long型 132492
MediaStore.Images.Media.SIZE,
//图片的宽度,int型 1920
MediaStore.Images.Media.WIDTH,
//图片的高度,int型 1080
MediaStore.Images.Media.HEIGHT,
//图片被添加的时间,long型 1450518608
MediaStore.Images.Media.DATE_ADDED,
//图片的类型 image/jpeg
MediaStore.Images.Media.MIME_TYPE};
/**
* 图片扫描成的回调接口
*/
public interface OnScanFinishListener {
/**
* 扫描完成
*
* @param pictureFolders
*/ | // Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureItem.java
// public class PictureItem implements Serializable {
//
// /**
// * 图片名称
// */
// public String pictureName;
// /**
// * 图片绝对路径
// */
// public String pictureAbsPath;
// /**
// * 图片类型
// */
// public String pictureMimeType;
// /**
// * 图片大小
// */
// public long pictureSize;
// /**
// * 图片加入的时间
// */
// public long pictureAddTime;
// /**
// * 图片的宽
// */
// public int pictureWidth;
// /**
// * 图片的高
// */
// public int pictureHeight;
//
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureItem) {
// PictureItem pictureItem = ((PictureItem) o);
// return TextUtils.equals(pictureItem.pictureAbsPath, pictureAbsPath)
// &&
// pictureItem.pictureAddTime == pictureAddTime;
// }
// return super.equals(o);
// }
// }
// Path: picturepicker/src/main/java/devin/com/picturepicker/pick/PictureScanner.java
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.javabean.PictureItem;
package devin.com.picturepicker.pick;
/**
* <p> Created by Devin Sun on 2016/10/14.
*/
public class PictureScanner implements LoaderManager.LoaderCallbacks<Cursor> {
private final int SCANNER_ID = 0;
/**
* 查询图片需要的数据列
*/
private final String[] IMAGE_PROJECTION = {
////图片的显示名称 aaa.jpg
MediaStore.Images.Media.DISPLAY_NAME,
//图片的真实路径 /storage/emulated/0/pp/downloader/wallpaper/aaa.jpg
MediaStore.Images.Media.DATA,
//图片的大小,long型 132492
MediaStore.Images.Media.SIZE,
//图片的宽度,int型 1920
MediaStore.Images.Media.WIDTH,
//图片的高度,int型 1080
MediaStore.Images.Media.HEIGHT,
//图片被添加的时间,long型 1450518608
MediaStore.Images.Media.DATE_ADDED,
//图片的类型 image/jpeg
MediaStore.Images.Media.MIME_TYPE};
/**
* 图片扫描成的回调接口
*/
public interface OnScanFinishListener {
/**
* 扫描完成
*
* @param pictureFolders
*/ | void onScanFinish(List<PictureFolder> pictureFolders); |
sundevin/PicturePicker | picturepicker/src/main/java/devin/com/picturepicker/pick/PictureScanner.java | // Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureItem.java
// public class PictureItem implements Serializable {
//
// /**
// * 图片名称
// */
// public String pictureName;
// /**
// * 图片绝对路径
// */
// public String pictureAbsPath;
// /**
// * 图片类型
// */
// public String pictureMimeType;
// /**
// * 图片大小
// */
// public long pictureSize;
// /**
// * 图片加入的时间
// */
// public long pictureAddTime;
// /**
// * 图片的宽
// */
// public int pictureWidth;
// /**
// * 图片的高
// */
// public int pictureHeight;
//
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureItem) {
// PictureItem pictureItem = ((PictureItem) o);
// return TextUtils.equals(pictureItem.pictureAbsPath, pictureAbsPath)
// &&
// pictureItem.pictureAddTime == pictureAddTime;
// }
// return super.equals(o);
// }
// }
| import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.javabean.PictureItem; | loader.setSelection(selection);
String[] selectionArgs;
if (PicturePicker.getInstance().getPickPictureOptions().isSelectGif()) {
selectionArgs = new String[]{"image/jpeg", "image/png", "image/jpg", "image/gif", scanFolderAbsPath};
} else {
selectionArgs = new String[]{"image/jpeg", "image/png", "image/jpg", scanFolderAbsPath};
}
loader.setSelectionArgs(selectionArgs);
}
//按加入时间降序排列
loader.setSortOrder(MediaStore.Images.Media.DATE_ADDED + " DESC");
return loader;
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return createLoader();
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
pictureFolderList.clear();
if (data != null) {
// new一个集合存储所有图片 | // Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureFolder.java
// public class PictureFolder implements Serializable {
//
// /**
// * 图片文件夹名称
// */
// public String folderName;
// /**
// * 图片文件夹绝对路径
// */
// public String folderAbsPath;
// /**
// * 图片文件夹需要要显示的封面
// */
// public PictureItem folderCover;
// /**
// * 图片文件夹下所有的图片
// */
// public List<PictureItem> pictureItemList;
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureFolder){
// PictureFolder folder= (PictureFolder) o;
// return TextUtils.equals(folder.folderAbsPath,folderAbsPath);
// }
// return super.equals(o);
// }
// }
//
// Path: picturepicker/src/main/java/devin/com/picturepicker/javabean/PictureItem.java
// public class PictureItem implements Serializable {
//
// /**
// * 图片名称
// */
// public String pictureName;
// /**
// * 图片绝对路径
// */
// public String pictureAbsPath;
// /**
// * 图片类型
// */
// public String pictureMimeType;
// /**
// * 图片大小
// */
// public long pictureSize;
// /**
// * 图片加入的时间
// */
// public long pictureAddTime;
// /**
// * 图片的宽
// */
// public int pictureWidth;
// /**
// * 图片的高
// */
// public int pictureHeight;
//
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof PictureItem) {
// PictureItem pictureItem = ((PictureItem) o);
// return TextUtils.equals(pictureItem.pictureAbsPath, pictureAbsPath)
// &&
// pictureItem.pictureAddTime == pictureAddTime;
// }
// return super.equals(o);
// }
// }
// Path: picturepicker/src/main/java/devin/com/picturepicker/pick/PictureScanner.java
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import devin.com.picturepicker.R;
import devin.com.picturepicker.javabean.PictureFolder;
import devin.com.picturepicker.javabean.PictureItem;
loader.setSelection(selection);
String[] selectionArgs;
if (PicturePicker.getInstance().getPickPictureOptions().isSelectGif()) {
selectionArgs = new String[]{"image/jpeg", "image/png", "image/jpg", "image/gif", scanFolderAbsPath};
} else {
selectionArgs = new String[]{"image/jpeg", "image/png", "image/jpg", scanFolderAbsPath};
}
loader.setSelectionArgs(selectionArgs);
}
//按加入时间降序排列
loader.setSortOrder(MediaStore.Images.Media.DATE_ADDED + " DESC");
return loader;
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return createLoader();
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
pictureFolderList.clear();
if (data != null) {
// new一个集合存储所有图片 | List<PictureItem> allPictureList = new ArrayList<>(); |
100rabhkr/DownZLibrary | downzlibrary/src/main/java/com/example/downzlibrary/DataTypes/Type.java | // Path: downzlibrary/src/main/java/com/example/downzlibrary/ListnerInterface/HttpListener.java
// public interface HttpListener<T> {
// /**
// * callback starts
// */
// public void onRequest();
//
// /**
// * Callback that's fired after response
// *
// * @param data of the type T holds the response
// */
// public void onResponse(T data);
//
// public void onError();
//
// public void onCancel();
// }
//
// Path: downzlibrary/src/main/java/com/example/downzlibrary/Utilities/CacheManagerInterface.java
// public interface CacheManagerInterface<T> {
// public void addDataToCache(String key, T data);
//
// public void removeDataFromCache(String key);
//
// public T getDataFromCache(String key);
//
// public void evictUnused();
// }
| import com.example.downzlibrary.ListnerInterface.HttpListener;
import com.example.downzlibrary.Utilities.CacheManagerInterface; | package com.example.downzlibrary.DataTypes;
/**
* Created by saurabhkumar on 06/08/17.
*/
public abstract class Type<T> {
public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager);
| // Path: downzlibrary/src/main/java/com/example/downzlibrary/ListnerInterface/HttpListener.java
// public interface HttpListener<T> {
// /**
// * callback starts
// */
// public void onRequest();
//
// /**
// * Callback that's fired after response
// *
// * @param data of the type T holds the response
// */
// public void onResponse(T data);
//
// public void onError();
//
// public void onCancel();
// }
//
// Path: downzlibrary/src/main/java/com/example/downzlibrary/Utilities/CacheManagerInterface.java
// public interface CacheManagerInterface<T> {
// public void addDataToCache(String key, T data);
//
// public void removeDataFromCache(String key);
//
// public T getDataFromCache(String key);
//
// public void evictUnused();
// }
// Path: downzlibrary/src/main/java/com/example/downzlibrary/DataTypes/Type.java
import com.example.downzlibrary.ListnerInterface.HttpListener;
import com.example.downzlibrary.Utilities.CacheManagerInterface;
package com.example.downzlibrary.DataTypes;
/**
* Created by saurabhkumar on 06/08/17.
*/
public abstract class Type<T> {
public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager);
| public abstract Type setCallback(HttpListener<T> callback); |
wso2/carbon-registry | components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/services/utils/GetPropertyUtil.java | // Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/PropertiesBean.java
// @SuppressWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
// public class PropertiesBean {
// private Property[] properties;
//
// public Property[] getProperties() {
// return properties;
// }
//
// public void setProperties(Property[] properties) {
// this.properties = properties;
// }
// }
//
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/Property.java
// public class Property {
// private String key;
// private String value;
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.util.Properties;
import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.registry.core.Resource;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.registry.resource.beans.PermissionEntry;
import org.wso2.carbon.registry.resource.beans.PropertiesBean;
import org.wso2.carbon.registry.resource.beans.Property;
import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
| /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.wso2.carbon.registry.resource.services.utils;
/**
*
*/
public class GetPropertyUtil {
private static final Log log = LogFactory.getLog(GetPropertyUtil.class);
public static String getProperty(UserRegistry registry,
String resourcePath, String key) throws RegistryException {
try {
if (registry.resourceExists(resourcePath)) {
Resource resource = registry.get(resourcePath);
if (resource != null) {
String value = resource.getProperty(key);
resource.discard();
return value;
}
}
} catch (RegistryException e) {
String msg = "Failed to get the resource information of resource " + resourcePath +
" for retrieving a property with key : " + key + ". Error :" +
((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw e;
}
return "";
}
| // Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/PropertiesBean.java
// @SuppressWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
// public class PropertiesBean {
// private Property[] properties;
//
// public Property[] getProperties() {
// return properties;
// }
//
// public void setProperties(Property[] properties) {
// this.properties = properties;
// }
// }
//
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/Property.java
// public class Property {
// private String key;
// private String value;
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/services/utils/GetPropertyUtil.java
import java.util.Properties;
import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.registry.core.Resource;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.registry.resource.beans.PermissionEntry;
import org.wso2.carbon.registry.resource.beans.PropertiesBean;
import org.wso2.carbon.registry.resource.beans.Property;
import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.wso2.carbon.registry.resource.services.utils;
/**
*
*/
public class GetPropertyUtil {
private static final Log log = LogFactory.getLog(GetPropertyUtil.class);
public static String getProperty(UserRegistry registry,
String resourcePath, String key) throws RegistryException {
try {
if (registry.resourceExists(resourcePath)) {
Resource resource = registry.get(resourcePath);
if (resource != null) {
String value = resource.getProperty(key);
resource.discard();
return value;
}
}
} catch (RegistryException e) {
String msg = "Failed to get the resource information of resource " + resourcePath +
" for retrieving a property with key : " + key + ". Error :" +
((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw e;
}
return "";
}
| public static PropertiesBean getProperties(UserRegistry registry, String resourcePath) throws RegistryException {
|
wso2/carbon-registry | components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/services/utils/GetPropertyUtil.java | // Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/PropertiesBean.java
// @SuppressWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
// public class PropertiesBean {
// private Property[] properties;
//
// public Property[] getProperties() {
// return properties;
// }
//
// public void setProperties(Property[] properties) {
// this.properties = properties;
// }
// }
//
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/Property.java
// public class Property {
// private String key;
// private String value;
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.util.Properties;
import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.registry.core.Resource;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.registry.resource.beans.PermissionEntry;
import org.wso2.carbon.registry.resource.beans.PropertiesBean;
import org.wso2.carbon.registry.resource.beans.Property;
import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
| if (resource != null) {
String value = resource.getProperty(key);
resource.discard();
return value;
}
}
} catch (RegistryException e) {
String msg = "Failed to get the resource information of resource " + resourcePath +
" for retrieving a property with key : " + key + ". Error :" +
((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw e;
}
return "";
}
public static PropertiesBean getProperties(UserRegistry registry, String resourcePath) throws RegistryException {
try {
if (registry.resourceExists(resourcePath)) {
Resource resource = registry.get(resourcePath);
if (resource != null) {
Properties props = resource.getProperties();
PropertiesBean propertiesBean = new PropertiesBean();
| // Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/PropertiesBean.java
// @SuppressWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
// public class PropertiesBean {
// private Property[] properties;
//
// public Property[] getProperties() {
// return properties;
// }
//
// public void setProperties(Property[] properties) {
// this.properties = properties;
// }
// }
//
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/beans/Property.java
// public class Property {
// private String key;
// private String value;
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: components/registry/org.wso2.carbon.registry.resource/src/main/java/org/wso2/carbon/registry/resource/services/utils/GetPropertyUtil.java
import java.util.Properties;
import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.registry.core.Resource;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.registry.resource.beans.PermissionEntry;
import org.wso2.carbon.registry.resource.beans.PropertiesBean;
import org.wso2.carbon.registry.resource.beans.Property;
import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
if (resource != null) {
String value = resource.getProperty(key);
resource.discard();
return value;
}
}
} catch (RegistryException e) {
String msg = "Failed to get the resource information of resource " + resourcePath +
" for retrieving a property with key : " + key + ". Error :" +
((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw e;
}
return "";
}
public static PropertiesBean getProperties(UserRegistry registry, String resourcePath) throws RegistryException {
try {
if (registry.resourceExists(resourcePath)) {
Resource resource = registry.get(resourcePath);
if (resource != null) {
Properties props = resource.getProperties();
PropertiesBean propertiesBean = new PropertiesBean();
| java.util.List<Property> p = new ArrayList<>();
|
rrbrambley/MessageBeast-Android | src/main/java/com/alwaysallthetime/messagebeast/AnnotationFactory.java | // Path: src/main/java/com/alwaysallthetime/messagebeast/model/CustomPlace.java
// public class CustomPlace extends Place {
//
// private String id;
//
// /**
// * Construct a new CustomPlace.
// *
// * @param id
// * @param place
// */
// public CustomPlace(String id, Place place) {
// this.id = id;
//
// this.name = place.getName();
// this.address = place.getAddress();
// this.addressExtended = place.getAddressExtended();
// this.locality = place.getLocality();
// this.region = place.getRegion();
// this.adminRegion = place.getAdminRegion();
// this.postTown = place.getPostTown();
// this.poBox = place.getPoBox();
// this.postcode = place.getPostcode();
// this.countryCode = place.getCountryCode();
// this.latitude = place.getLatitude();
// this.longitude = place.getLongitude();
// this.isOpen = place.isOpen();
// this.telephone = place.getTelephone();
// this.fax = place.getFax();
// this.website = place.getWebsite();
// this.categories = place.getCategories();
// }
//
// public String getId() {
// return id;
// }
// }
| import com.alwaysallthetime.adnlib.Annotations;
import com.alwaysallthetime.adnlib.data.Annotation;
import com.alwaysallthetime.adnlib.data.File;
import com.alwaysallthetime.messagebeast.model.CustomPlace;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List; | package com.alwaysallthetime.messagebeast;
/**
* A factory for Annotations.
*/
public class AnnotationFactory {
/**
* Get an Annotation of type net.app.core.checkin with the given Factual id.
*
* The Annotation will have a +net.app.core.place key whose associated Map
* will contain a "factual_id" key/value pair.
*
* @param factualId the Factual id to embed in the checkin annotation.
* @return an Annotation of type net.app.core.checkin with the given Factual id.
*/
public static Annotation getCheckinAnnotation(String factualId) {
HashMap<String, Object> value = new HashMap<String, Object>(1);
HashMap<String, String> replacement = new HashMap<String, String>(1);
replacement.put("factual_id", factualId);
value.put(Annotations.REPLACEMENT_PLACE, replacement);
Annotation a = new Annotation(Annotations.CHECKIN);
a.setValue(value);
return a;
}
| // Path: src/main/java/com/alwaysallthetime/messagebeast/model/CustomPlace.java
// public class CustomPlace extends Place {
//
// private String id;
//
// /**
// * Construct a new CustomPlace.
// *
// * @param id
// * @param place
// */
// public CustomPlace(String id, Place place) {
// this.id = id;
//
// this.name = place.getName();
// this.address = place.getAddress();
// this.addressExtended = place.getAddressExtended();
// this.locality = place.getLocality();
// this.region = place.getRegion();
// this.adminRegion = place.getAdminRegion();
// this.postTown = place.getPostTown();
// this.poBox = place.getPoBox();
// this.postcode = place.getPostcode();
// this.countryCode = place.getCountryCode();
// this.latitude = place.getLatitude();
// this.longitude = place.getLongitude();
// this.isOpen = place.isOpen();
// this.telephone = place.getTelephone();
// this.fax = place.getFax();
// this.website = place.getWebsite();
// this.categories = place.getCategories();
// }
//
// public String getId() {
// return id;
// }
// }
// Path: src/main/java/com/alwaysallthetime/messagebeast/AnnotationFactory.java
import com.alwaysallthetime.adnlib.Annotations;
import com.alwaysallthetime.adnlib.data.Annotation;
import com.alwaysallthetime.adnlib.data.File;
import com.alwaysallthetime.messagebeast.model.CustomPlace;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
package com.alwaysallthetime.messagebeast;
/**
* A factory for Annotations.
*/
public class AnnotationFactory {
/**
* Get an Annotation of type net.app.core.checkin with the given Factual id.
*
* The Annotation will have a +net.app.core.place key whose associated Map
* will contain a "factual_id" key/value pair.
*
* @param factualId the Factual id to embed in the checkin annotation.
* @return an Annotation of type net.app.core.checkin with the given Factual id.
*/
public static Annotation getCheckinAnnotation(String factualId) {
HashMap<String, Object> value = new HashMap<String, Object>(1);
HashMap<String, String> replacement = new HashMap<String, String>(1);
replacement.put("factual_id", factualId);
value.put(Annotations.REPLACEMENT_PLACE, replacement);
Annotation a = new Annotation(Annotations.CHECKIN);
a.setValue(value);
return a;
}
| public static Annotation getOhaiLocationAnnotation(CustomPlace customPlace) { |
rrbrambley/MessageBeast-Android | src/main/java/com/alwaysallthetime/messagebeast/ADNSharedPreferences.java | // Path: src/main/java/com/alwaysallthetime/messagebeast/model/FullSyncState.java
// public enum FullSyncState {
// NOT_STARTED,
// STARTED,
// COMPLETE;
//
// public static FullSyncState fromOrdinal(int ordinal) {
// if(ordinal == 0) {
// return NOT_STARTED;
// } else if(ordinal == 1) {
// return STARTED;
// }
// return COMPLETE;
// }
// }
| import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.alwaysallthetime.adnlib.data.Channel;
import com.alwaysallthetime.adnlib.data.Configuration;
import com.alwaysallthetime.adnlib.data.Token;
import com.alwaysallthetime.adnlib.data.User;
import com.alwaysallthetime.adnlib.gson.AppDotNetGson;
import com.alwaysallthetime.messagebeast.model.FullSyncState;
import com.google.gson.Gson;
import java.util.Date; | package com.alwaysallthetime.messagebeast;
public class ADNSharedPreferences {
private static final String ACCESS_TOKEN = "accessToken";
private static final String TOKEN_OBJECT = "tokenObject";
private static final String CONFIGURATION_OBJECT = "configurationObject";
private static final String CONFIGURATION_DATE = "configurationDate";
private static final String USER_OBJECT = "user";
private static final String CHANNEL_OBJECT = "channel";
private static final String ACTION_CHANNEL_OBJECT = "actionChannel";
private static final String FULL_SYNC_STATE = "fullSyncState";
private static SharedPreferences sPrefs;
private static Gson gson;
static {
sPrefs = PreferenceManager.getDefaultSharedPreferences(ADNApplication.getContext());
gson = AppDotNetGson.getPersistenceInstance();
}
| // Path: src/main/java/com/alwaysallthetime/messagebeast/model/FullSyncState.java
// public enum FullSyncState {
// NOT_STARTED,
// STARTED,
// COMPLETE;
//
// public static FullSyncState fromOrdinal(int ordinal) {
// if(ordinal == 0) {
// return NOT_STARTED;
// } else if(ordinal == 1) {
// return STARTED;
// }
// return COMPLETE;
// }
// }
// Path: src/main/java/com/alwaysallthetime/messagebeast/ADNSharedPreferences.java
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.alwaysallthetime.adnlib.data.Channel;
import com.alwaysallthetime.adnlib.data.Configuration;
import com.alwaysallthetime.adnlib.data.Token;
import com.alwaysallthetime.adnlib.data.User;
import com.alwaysallthetime.adnlib.gson.AppDotNetGson;
import com.alwaysallthetime.messagebeast.model.FullSyncState;
import com.google.gson.Gson;
import java.util.Date;
package com.alwaysallthetime.messagebeast;
public class ADNSharedPreferences {
private static final String ACCESS_TOKEN = "accessToken";
private static final String TOKEN_OBJECT = "tokenObject";
private static final String CONFIGURATION_OBJECT = "configurationObject";
private static final String CONFIGURATION_DATE = "configurationDate";
private static final String USER_OBJECT = "user";
private static final String CHANNEL_OBJECT = "channel";
private static final String ACTION_CHANNEL_OBJECT = "actionChannel";
private static final String FULL_SYNC_STATE = "fullSyncState";
private static SharedPreferences sPrefs;
private static Gson gson;
static {
sPrefs = PreferenceManager.getDefaultSharedPreferences(ADNApplication.getContext());
gson = AppDotNetGson.getPersistenceInstance();
}
| public static FullSyncState getFullSyncState(String channelId) { |
rrbrambley/MessageBeast-Android | src/main/java/com/alwaysallthetime/messagebeast/PrivateChannelUtility.java | // Path: src/main/java/com/alwaysallthetime/messagebeast/model/FullSyncState.java
// public enum FullSyncState {
// NOT_STARTED,
// STARTED,
// COMPLETE;
//
// public static FullSyncState fromOrdinal(int ordinal) {
// if(ordinal == 0) {
// return NOT_STARTED;
// } else if(ordinal == 1) {
// return STARTED;
// }
// return COMPLETE;
// }
// }
| import android.util.Log;
import com.alwaysallthetime.adnlib.AppDotNetClient;
import com.alwaysallthetime.adnlib.GeneralParameter;
import com.alwaysallthetime.adnlib.QueryParameters;
import com.alwaysallthetime.adnlib.data.Annotation;
import com.alwaysallthetime.adnlib.data.Channel;
import com.alwaysallthetime.adnlib.data.ChannelList;
import com.alwaysallthetime.adnlib.data.User;
import com.alwaysallthetime.adnlib.response.ChannelListResponseHandler;
import com.alwaysallthetime.adnlib.response.ChannelResponseHandler;
import com.alwaysallthetime.messagebeast.model.FullSyncState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; | }
});
}
private static void createChannel(final AppDotNetClient client, final String channelType, List<Annotation> channelAnnotations, final PrivateChannelHandler handler) {
User currentUser = ADNSharedPreferences.getToken().getUser();
Channel c = new Channel();
c.setType(channelType);
Channel.Acl writer = new Channel.Acl(true);
writer.setUserIds(new String[] { currentUser.getId() });
writer.setAnyUser(false);
Channel.Acl reader = new Channel.Acl(false);
c.setWriters(writer);
c.setReaders(reader);
for(Annotation a : channelAnnotations) {
c.addAnnotation(a);
}
final QueryParameters params = new QueryParameters(GeneralParameter.INCLUDE_CHANNEL_ANNOTATIONS);
client.createChannel(c, params, new ChannelResponseHandler() {
@Override
public void onSuccess(final Channel responseData) {
client.subscribeChannel(responseData, params, new ChannelResponseHandler() {
@Override
public void onSuccess(Channel responseData) { | // Path: src/main/java/com/alwaysallthetime/messagebeast/model/FullSyncState.java
// public enum FullSyncState {
// NOT_STARTED,
// STARTED,
// COMPLETE;
//
// public static FullSyncState fromOrdinal(int ordinal) {
// if(ordinal == 0) {
// return NOT_STARTED;
// } else if(ordinal == 1) {
// return STARTED;
// }
// return COMPLETE;
// }
// }
// Path: src/main/java/com/alwaysallthetime/messagebeast/PrivateChannelUtility.java
import android.util.Log;
import com.alwaysallthetime.adnlib.AppDotNetClient;
import com.alwaysallthetime.adnlib.GeneralParameter;
import com.alwaysallthetime.adnlib.QueryParameters;
import com.alwaysallthetime.adnlib.data.Annotation;
import com.alwaysallthetime.adnlib.data.Channel;
import com.alwaysallthetime.adnlib.data.ChannelList;
import com.alwaysallthetime.adnlib.data.User;
import com.alwaysallthetime.adnlib.response.ChannelListResponseHandler;
import com.alwaysallthetime.adnlib.response.ChannelResponseHandler;
import com.alwaysallthetime.messagebeast.model.FullSyncState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
}
});
}
private static void createChannel(final AppDotNetClient client, final String channelType, List<Annotation> channelAnnotations, final PrivateChannelHandler handler) {
User currentUser = ADNSharedPreferences.getToken().getUser();
Channel c = new Channel();
c.setType(channelType);
Channel.Acl writer = new Channel.Acl(true);
writer.setUserIds(new String[] { currentUser.getId() });
writer.setAnyUser(false);
Channel.Acl reader = new Channel.Acl(false);
c.setWriters(writer);
c.setReaders(reader);
for(Annotation a : channelAnnotations) {
c.addAnnotation(a);
}
final QueryParameters params = new QueryParameters(GeneralParameter.INCLUDE_CHANNEL_ANNOTATIONS);
client.createChannel(c, params, new ChannelResponseHandler() {
@Override
public void onSuccess(final Channel responseData) {
client.subscribeChannel(responseData, params, new ChannelResponseHandler() {
@Override
public void onSuccess(Channel responseData) { | ADNSharedPreferences.setFullSyncState(responseData.getId(), FullSyncState.COMPLETE); |
callstats-io/callstats.java | callstats-java-sdk/src/main/java/io/callstats/sdk/messages/ConferenceSetupEvent.java | // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/data/ServerInfo.java
// public class ServerInfo {
//
// /** The name. */
// String buildName;
//
// String buildVersion;
// /** The os. */
// String os;
//
// /** The ver. */
// String osVersion;
//
// String appVersion;
//
// String callstatsVersion;
//
// String type = CallStatsConst.END_POINT_TYPE;
//
// /**
// * Instantiates a new ServerInfo info.
// */
// public ServerInfo() {
// callstatsVersion = CallStatsConst.CS_VERSION;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return buildName;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(String name) {
// this.buildName = name;
// }
//
// /**
// * Gets the os.
// *
// * @return the os
// */
// public String getOs() {
// return os;
// }
//
// /**
// * Sets the os.
// *
// * @param os the new os
// */
// public void setOs(String os) {
// this.os = os;
// }
//
// /**
// * Gets the ver.
// *
// * @return the ver
// */
// public String getVer() {
// return osVersion;
// }
//
// /**
// * Sets the ver.
// *
// * @param ver the new ver
// */
// public void setVer(String ver) {
// this.osVersion = ver;
// }
//
// public String getEndpointType() {
// return type;
// }
//
// public void setEndpointType(String endpointType) {
// this.type = endpointType;
// }
//
// }
| import io.callstats.sdk.data.ServerInfo; | package io.callstats.sdk.messages;
public class ConferenceSetupEvent {
String localID;
String originID;
String deviceID;
long timestamp; | // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/data/ServerInfo.java
// public class ServerInfo {
//
// /** The name. */
// String buildName;
//
// String buildVersion;
// /** The os. */
// String os;
//
// /** The ver. */
// String osVersion;
//
// String appVersion;
//
// String callstatsVersion;
//
// String type = CallStatsConst.END_POINT_TYPE;
//
// /**
// * Instantiates a new ServerInfo info.
// */
// public ServerInfo() {
// callstatsVersion = CallStatsConst.CS_VERSION;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return buildName;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(String name) {
// this.buildName = name;
// }
//
// /**
// * Gets the os.
// *
// * @return the os
// */
// public String getOs() {
// return os;
// }
//
// /**
// * Sets the os.
// *
// * @param os the new os
// */
// public void setOs(String os) {
// this.os = os;
// }
//
// /**
// * Gets the ver.
// *
// * @return the ver
// */
// public String getVer() {
// return osVersion;
// }
//
// /**
// * Sets the ver.
// *
// * @param ver the new ver
// */
// public void setVer(String ver) {
// this.osVersion = ver;
// }
//
// public String getEndpointType() {
// return type;
// }
//
// public void setEndpointType(String endpointType) {
// this.type = endpointType;
// }
//
// }
// Path: callstats-java-sdk/src/main/java/io/callstats/sdk/messages/ConferenceSetupEvent.java
import io.callstats.sdk.data.ServerInfo;
package io.callstats.sdk.messages;
public class ConferenceSetupEvent {
String localID;
String originID;
String deviceID;
long timestamp; | ServerInfo endpointInfo; |
callstats-io/callstats.java | callstats-java-sdk/src/main/java/io/callstats/sdk/listeners/CallStatsStartConferenceListener.java | // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/CallStatsErrors.java
// public enum CallStatsErrors {
//
// /** The none. */
// NONE(0, "none"),
//
// /** The success. */
// SUCCESS(1, "Success"),
//
// /** The http error. */
// HTTP_ERROR(2, "Http Error"),
//
// /** The auth error. */
// AUTH_ERROR(3, "Authentication Error"),
//
// /** The cs proto error. */
// CS_PROTO_ERROR(4, "CallStats Protocol Error"),
//
// /** The app connectivity error. */
// APP_CONNECTIVITY_ERROR(5, "App Connectivity Error"),
//
// INVALID_TOKEN_ERROR(6, "Invalid client token");
//
// /** The index. */
// private int index;
//
// /** The reason. */
// private String reason;
//
// /**
// * Instantiates a new call stats errors.
// *
// * @param index the index
// * @param reason the reason
// *
// */
// private CallStatsErrors(int index, String reason) {
// this.index = index;
// this.reason = reason;
// }
//
// /**
// * Gets the index.
// *
// * @return the index
// */
// public int getIndex() {
// return index;
// }
//
// /**
// * Gets the reason.
// *
// * @return the reason
// */
// public String getReason() {
// return reason;
// }
// }
| import io.callstats.sdk.CallStatsErrors; | package io.callstats.sdk.listeners;
public interface CallStatsStartConferenceListener {
public void onResponse(String ucid);
| // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/CallStatsErrors.java
// public enum CallStatsErrors {
//
// /** The none. */
// NONE(0, "none"),
//
// /** The success. */
// SUCCESS(1, "Success"),
//
// /** The http error. */
// HTTP_ERROR(2, "Http Error"),
//
// /** The auth error. */
// AUTH_ERROR(3, "Authentication Error"),
//
// /** The cs proto error. */
// CS_PROTO_ERROR(4, "CallStats Protocol Error"),
//
// /** The app connectivity error. */
// APP_CONNECTIVITY_ERROR(5, "App Connectivity Error"),
//
// INVALID_TOKEN_ERROR(6, "Invalid client token");
//
// /** The index. */
// private int index;
//
// /** The reason. */
// private String reason;
//
// /**
// * Instantiates a new call stats errors.
// *
// * @param index the index
// * @param reason the reason
// *
// */
// private CallStatsErrors(int index, String reason) {
// this.index = index;
// this.reason = reason;
// }
//
// /**
// * Gets the index.
// *
// * @return the index
// */
// public int getIndex() {
// return index;
// }
//
// /**
// * Gets the reason.
// *
// * @return the reason
// */
// public String getReason() {
// return reason;
// }
// }
// Path: callstats-java-sdk/src/main/java/io/callstats/sdk/listeners/CallStatsStartConferenceListener.java
import io.callstats.sdk.CallStatsErrors;
package io.callstats.sdk.listeners;
public interface CallStatsStartConferenceListener {
public void onResponse(String ucid);
| void onError(CallStatsErrors error, String errMsg); |
callstats-io/callstats.java | callstats-java-sdk/src/main/java/io/callstats/sdk/messages/ConferenceStatsEvent.java | // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/data/ConferenceStats.java
// public class ConferenceStats {
//
// transient String localID;
// transient String remoteID;
// @SerializedName("type")
// String statsType; // inbound or outbound
// long ssrc;
// String originID;
// transient String ucID;
// transient String confID;
// Long packetsSent;
// Long packetsReceived;
// Long packetsLost;
// Long packetsDuplicated;
// Long packetsDiscarded;
// Long packetsRepaired;
//
// Long bytesSent;
// Long bytesReceived;
// Long bytesDuplicated;
// Long bytesDiscarded;
// Long bytesRepaired;
//
// Long burstPacketsLost;
// Long burstLossIntervalCount;
// Long burstPacketsDiscarded;
// Long burstDiscardIntervalCount;
//
// Double gapLossRate;
// Double gapDiscardRate;
//
// Double fractionalPacketLost;
// Double fractionalPacketDiscarded;
//
// Long framesSent;
// Long framesReceived;
// Long framesLost;
// Long framesDropped;
// Long framesCorrupted;
//
// Integer rtt;
// Double jitter;
//
// Double currentPlayoutDelay;
// Double maxPlayoutDelay;
// Double minPlayoutDelay;
//
// Double currentJBDelay;
// Double highWatermarkJBDelay;
// Double lowWatermarkJBDelay;
// Double maxJBDelay;
// Double minJBDelay;
// Double avsync;
// String mediaType;
//
// public ConferenceStats() {
//
// }
//
// public ConferenceStats(ConferenceStatsBuilder builder) {
// this.localID = builder.getLocalUserID();
// this.statsType = builder.getStatsType();
// this.originID = builder.getFromUserID();
// this.ssrc = Long.parseLong(builder.getSsrc());
// this.remoteID = builder.getRemoteUserID();
// this.ucID = builder.getUcID();
// this.confID = builder.getConfID();
// this.packetsSent = builder.getPacketsSent();
// this.packetsReceived = builder.getPacketsReceived();
// this.packetsLost = builder.getPacketsLost();
// this.packetsDuplicated = builder.getPacketsDuplicated();
// this.packetsDiscarded = builder.getPacketsDiscarded();
// this.packetsRepaired = builder.getPacketsRepaired();
//
// this.bytesSent = builder.getBytesSent();
// this.bytesReceived = builder.getBytesReceived();
// this.bytesDuplicated = builder.getBytesDuplicated();
// this.bytesDiscarded = builder.getBytesDiscarded();
// this.bytesRepaired = builder.getBytesRepaired();
//
// this.burstPacketsLost = builder.getBurstPacketsLost();
// this.burstLossIntervalCount = builder.getBurstLossIntervalCount();
// this.burstPacketsDiscarded = builder.getBurstPacketsDiscarded();
// this.burstDiscardIntervalCount = builder.getBurstDiscardIntervalCount();
//
// this.gapLossRate = builder.getGapLossRate();
// this.gapDiscardRate = builder.getGapDiscardRate();
//
// this.fractionalPacketLost = builder.getFractionalPacketLost();
// this.fractionalPacketDiscarded = builder.getFractionalPacketDiscarded();
//
// this.framesSent = builder.getFramesSent();
// this.framesReceived = builder.getFramesReceived();
// this.framesLost = builder.getFramesLost();
// this.framesDropped = builder.getFramesDropped();
// this.framesCorrupted = builder.getFramesCorrupted();
//
// this.rtt = builder.getRtt();
// this.jitter = builder.getJitter();
//
// this.currentPlayoutDelay = builder.getCurrentPlayoutDelay();
// this.maxPlayoutDelay = builder.getMaxPlayoutDelay();
// this.minPlayoutDelay = builder.getMinPlayoutDelay();
//
// this.currentJBDelay = builder.getCurrentJBDelay();
// this.highWatermarkJBDelay = builder.getHighWatermarkJBDelay();
// this.lowWatermarkJBDelay = builder.getLowWatermarkJBDelay();
// this.maxJBDelay = builder.getMaxJBDelay();
// this.minJBDelay = builder.getMinJBDelay();
// this.avsync = builder.getAvsync();
// this.mediaType = builder.getMediaType();
// }
//
// public String getUcID() {
// return this.ucID;
// }
//
// public void setUcID(String ucID) {
// this.ucID = ucID;
// }
//
// public String getConfID() {
// return this.confID;
// }
//
// public void setConfID(String confID) {
// this.confID = confID;
// }
//
// public String getLocalUserID() {
// return this.localID;
// }
//
// public void setLocalUserID(String localUserID) {
// this.localID = localUserID;
// }
//
// public long getSsrc() {
// return this.ssrc;
// }
//
// public void setSsrc(String ssrc) {
// this.ssrc = Long.parseLong(ssrc);
// }
//
// public String getFromUserID() {
// return this.originID;
// }
//
// public void setFromUserID(String fromUserID) {
// this.originID = fromUserID;
// }
//
// public String getStatsType() {
// return this.statsType;
// }
//
// public void setStatsType(CallStatsStreamType statsType) {
// this.statsType = statsType.getMessageType();
// }
//
// public String getRemoteUserID() {
// return this.remoteID;
// }
//
// public void setRemoteUserID(String remoteUserID) {
// this.remoteID = remoteUserID;
// }
//
// public String getMediaType() {
// return this.mediaType;
// }
//
// public void setMediaType(String mediaType) {
// this.mediaType = mediaType;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.SerializedName;
import io.callstats.sdk.data.ConferenceStats; | package io.callstats.sdk.messages;
public class ConferenceStatsEvent {
String localID;
String originID;
String deviceID;
String remoteID;
String connectionID;
long timestamp;
@SerializedName("stats") | // Path: callstats-java-sdk/src/main/java/io/callstats/sdk/data/ConferenceStats.java
// public class ConferenceStats {
//
// transient String localID;
// transient String remoteID;
// @SerializedName("type")
// String statsType; // inbound or outbound
// long ssrc;
// String originID;
// transient String ucID;
// transient String confID;
// Long packetsSent;
// Long packetsReceived;
// Long packetsLost;
// Long packetsDuplicated;
// Long packetsDiscarded;
// Long packetsRepaired;
//
// Long bytesSent;
// Long bytesReceived;
// Long bytesDuplicated;
// Long bytesDiscarded;
// Long bytesRepaired;
//
// Long burstPacketsLost;
// Long burstLossIntervalCount;
// Long burstPacketsDiscarded;
// Long burstDiscardIntervalCount;
//
// Double gapLossRate;
// Double gapDiscardRate;
//
// Double fractionalPacketLost;
// Double fractionalPacketDiscarded;
//
// Long framesSent;
// Long framesReceived;
// Long framesLost;
// Long framesDropped;
// Long framesCorrupted;
//
// Integer rtt;
// Double jitter;
//
// Double currentPlayoutDelay;
// Double maxPlayoutDelay;
// Double minPlayoutDelay;
//
// Double currentJBDelay;
// Double highWatermarkJBDelay;
// Double lowWatermarkJBDelay;
// Double maxJBDelay;
// Double minJBDelay;
// Double avsync;
// String mediaType;
//
// public ConferenceStats() {
//
// }
//
// public ConferenceStats(ConferenceStatsBuilder builder) {
// this.localID = builder.getLocalUserID();
// this.statsType = builder.getStatsType();
// this.originID = builder.getFromUserID();
// this.ssrc = Long.parseLong(builder.getSsrc());
// this.remoteID = builder.getRemoteUserID();
// this.ucID = builder.getUcID();
// this.confID = builder.getConfID();
// this.packetsSent = builder.getPacketsSent();
// this.packetsReceived = builder.getPacketsReceived();
// this.packetsLost = builder.getPacketsLost();
// this.packetsDuplicated = builder.getPacketsDuplicated();
// this.packetsDiscarded = builder.getPacketsDiscarded();
// this.packetsRepaired = builder.getPacketsRepaired();
//
// this.bytesSent = builder.getBytesSent();
// this.bytesReceived = builder.getBytesReceived();
// this.bytesDuplicated = builder.getBytesDuplicated();
// this.bytesDiscarded = builder.getBytesDiscarded();
// this.bytesRepaired = builder.getBytesRepaired();
//
// this.burstPacketsLost = builder.getBurstPacketsLost();
// this.burstLossIntervalCount = builder.getBurstLossIntervalCount();
// this.burstPacketsDiscarded = builder.getBurstPacketsDiscarded();
// this.burstDiscardIntervalCount = builder.getBurstDiscardIntervalCount();
//
// this.gapLossRate = builder.getGapLossRate();
// this.gapDiscardRate = builder.getGapDiscardRate();
//
// this.fractionalPacketLost = builder.getFractionalPacketLost();
// this.fractionalPacketDiscarded = builder.getFractionalPacketDiscarded();
//
// this.framesSent = builder.getFramesSent();
// this.framesReceived = builder.getFramesReceived();
// this.framesLost = builder.getFramesLost();
// this.framesDropped = builder.getFramesDropped();
// this.framesCorrupted = builder.getFramesCorrupted();
//
// this.rtt = builder.getRtt();
// this.jitter = builder.getJitter();
//
// this.currentPlayoutDelay = builder.getCurrentPlayoutDelay();
// this.maxPlayoutDelay = builder.getMaxPlayoutDelay();
// this.minPlayoutDelay = builder.getMinPlayoutDelay();
//
// this.currentJBDelay = builder.getCurrentJBDelay();
// this.highWatermarkJBDelay = builder.getHighWatermarkJBDelay();
// this.lowWatermarkJBDelay = builder.getLowWatermarkJBDelay();
// this.maxJBDelay = builder.getMaxJBDelay();
// this.minJBDelay = builder.getMinJBDelay();
// this.avsync = builder.getAvsync();
// this.mediaType = builder.getMediaType();
// }
//
// public String getUcID() {
// return this.ucID;
// }
//
// public void setUcID(String ucID) {
// this.ucID = ucID;
// }
//
// public String getConfID() {
// return this.confID;
// }
//
// public void setConfID(String confID) {
// this.confID = confID;
// }
//
// public String getLocalUserID() {
// return this.localID;
// }
//
// public void setLocalUserID(String localUserID) {
// this.localID = localUserID;
// }
//
// public long getSsrc() {
// return this.ssrc;
// }
//
// public void setSsrc(String ssrc) {
// this.ssrc = Long.parseLong(ssrc);
// }
//
// public String getFromUserID() {
// return this.originID;
// }
//
// public void setFromUserID(String fromUserID) {
// this.originID = fromUserID;
// }
//
// public String getStatsType() {
// return this.statsType;
// }
//
// public void setStatsType(CallStatsStreamType statsType) {
// this.statsType = statsType.getMessageType();
// }
//
// public String getRemoteUserID() {
// return this.remoteID;
// }
//
// public void setRemoteUserID(String remoteUserID) {
// this.remoteID = remoteUserID;
// }
//
// public String getMediaType() {
// return this.mediaType;
// }
//
// public void setMediaType(String mediaType) {
// this.mediaType = mediaType;
// }
// }
// Path: callstats-java-sdk/src/main/java/io/callstats/sdk/messages/ConferenceStatsEvent.java
import java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.SerializedName;
import io.callstats.sdk.data.ConferenceStats;
package io.callstats.sdk.messages;
public class ConferenceStatsEvent {
String localID;
String originID;
String deviceID;
String remoteID;
String connectionID;
long timestamp;
@SerializedName("stats") | List<ConferenceStats> conferenceStatsList = new ArrayList<ConferenceStats>(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/BuildingEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; |
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public int getFaithCost() {
return mFaithCost;
}
public void setFaithCost(int faithCost) {
this.mFaithCost = faithCost;
}
public int getMaintenance() {
return mMaintenance;
}
public void setMaintenance(int maintenance) {
this.mMaintenance = maintenance;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/BuildingEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public int getFaithCost() {
return mFaithCost;
}
public void setFaithCost(int faithCost) {
this.mFaithCost = faithCost;
}
public int getMaintenance() {
return mMaintenance;
}
public void setMaintenance(int maintenance) {
this.mMaintenance = maintenance;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/UnitEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; |
public int getRangedCombat() {
return mRangedCombat;
}
public void setRangedCombat(int rangedCombat) {
this.mRangedCombat = rangedCombat;
}
public int getMoves() {
return mMoves;
}
public void setMoves(int moves) {
this.mMoves = moves;
}
public int getRange() {
return mRange;
}
public void setRange(int range) {
this.mRange = range;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/UnitEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public int getRangedCombat() {
return mRangedCombat;
}
public void setRangedCombat(int rangedCombat) {
this.mRangedCombat = rangedCombat;
}
public int getMoves() {
return mMoves;
}
public void setMoves(int moves) {
this.mMoves = moves;
}
public int getRange() {
return mRange;
}
public void setRange(int range) {
this.mRange = range;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/PolicyEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; | public String getGroup() {
return mGroup;
}
public void setGroup(String group) {
mGroup = group;
}
public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct types sorted by the sort order | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/PolicyEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public String getGroup() {
return mGroup;
}
public void setGroup(String group) {
mGroup = group;
}
public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct types sorted by the sort order | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/ReligionEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; | return mName;
}
public void setName(String name) {
this.mName = name;
}
@Override
public String getGroup() {
return mGroup;
}
public void setGroup(String group) {
mGroup = group;
}
public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct types sorted by cost | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/ReligionEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
return mName;
}
public void setName(String name) {
this.mName = name;
}
@Override
public String getGroup() {
return mGroup;
}
public void setGroup(String group) {
mGroup = group;
}
public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct types sorted by cost | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/TechnologyEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; | public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct eras sorted by cost | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/TechnologyEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public String getCivilopedia() {
return mCivilopedia;
}
public void setCivilopedia(String civilopedia) {
this.mCivilopedia = civilopedia;
}
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try {
// Gets distinct eras sorted by cost | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
davidfischer/civilopedia-v | src/name/davidfischer/civilopedia/entries/WonderEntry.java | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log; |
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public String getQuote() {
return mQuote;
}
public void setQuote(String quote) {
this.mQuote = quote;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | // Path: src/name/davidfischer/civilopedia/helpers/CivilopediaDatabaseHelper.java
// public class CivilopediaDatabaseHelper extends SQLiteOpenHelper {
// private static final String TAG = CivilopediaDatabaseHelper.class.getName();
// private static final String DATABASE_NAME = "civilopedia.db";
// private static final int DATABASE_VERSION = 1;
// private static final int BUFFER_SIZE = 1024;
//
// private Context mContext;
// private String mDatabasePath;
//
// /**
// * Create a database connection helper and copy the database from assets
// * if the database does not already exist.
// *
// * @param context the activity context for this database
// * @throws IOException if the database could not be copied
// */
// public CivilopediaDatabaseHelper(Context context) throws IOException {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.mContext = context;
// this.mDatabasePath = context.getDatabasePath(DATABASE_NAME).getPath();
//
// if (this.upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// this.copyDatabase();
// }
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// // Do nothing
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// if (upgradeRequired()) {
// Log.i(TAG, "Database upgrade required");
// try {
// copyDatabase();
// } catch (IOException e) {
// Log.e(TAG, "Failed onUpgrade: " + e.getLocalizedMessage());
// }
// }
// }
//
// private void copyDatabase() throws IOException {
// Log.i(TAG, "Copying database from assets");
// // Must be called before copying or else
// // Android will not let the app overwrite the database
// getReadableDatabase();
//
// InputStream inputFile = mContext.getAssets().open(DATABASE_NAME);
// OutputStream outputFile = new FileOutputStream(mDatabasePath);
//
// // copy the database from the assets to the database location
// // be that internal memory or the SD card
// byte [] buffer = new byte[BUFFER_SIZE];
// int length;
// while ((length = inputFile.read(buffer)) > 0) {
// outputFile.write(buffer, 0, length);
// }
//
// //Close the streams
// outputFile.flush();
// outputFile.close();
// inputFile.close();
// }
//
// private boolean databaseExists() {
// SQLiteDatabase conn = null;
//
// try {
// conn = SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// } catch (SQLiteException e) {
// // No connection
// Log.d(TAG, "This connection failure can be safely ignored");
// }
//
// if (null != conn) {
// conn.close();
// return true;
// }
//
// return false;
// }
//
// private boolean upgradeRequired() {
// InputStream existingDatabase = null;
// InputStream newDatabase = null;
// byte [] buffer1 = new byte[BUFFER_SIZE];
// byte [] buffer2 = new byte[BUFFER_SIZE];
// int charsRead1, charsRead2 = 0;
//
// if (!databaseExists()) {
// return true;
// }
//
// // Compare the two files byte by byte to ensure they are the same
// try {
// existingDatabase = new FileInputStream(mDatabasePath);
// newDatabase = mContext.getAssets().open(DATABASE_NAME);
// while (true) {
// charsRead1 = existingDatabase.read(buffer1);
// charsRead2 = newDatabase.read(buffer2);
// if (!Arrays.equals(buffer1, buffer2)) {
// return true;
// } else if (charsRead1 == -1 && charsRead2 == -1) {
// break;
// }
// }
// } catch (IOException e) {
// Log.w(TAG, "Error reading database: " + e.getLocalizedMessage());
// return true;
// } finally {
// if (null != existingDatabase) {
// try {
// existingDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// if (null != newDatabase) {
// try {
// newDatabase.close();
// } catch (IOException e1) {
// Log.w(TAG, e1.getLocalizedMessage());
// }
// }
// }
//
// return false;
// }
//
// public SQLiteDatabase openConnection() {
// return SQLiteDatabase.openDatabase(mDatabasePath, null, SQLiteDatabase.OPEN_READONLY);
// }
// }
// Path: src/name/davidfischer/civilopedia/entries/WonderEntry.java
import java.io.IOException;
import java.util.ArrayList;
import name.davidfischer.civilopedia.helpers.CivilopediaDatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public String getHelp() {
return mHelp;
}
public void setHelp(String help) {
this.mHelp = help;
}
public int getCost() {
return mCost;
}
public void setCost(int cost) {
this.mCost = cost;
}
public String getQuote() {
return mQuote;
}
public void setQuote(String quote) {
this.mQuote = quote;
}
public static ArrayList<String> getGroups(Context context) {
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase conn = null;
Cursor cursor = null;
try { | conn = new CivilopediaDatabaseHelper(context).openConnection(); |
Aevi-UK/android-pos-print-api | print-api/src/main/java/com/aevi/print/model/PrintPayload.java | // Path: print-api/src/main/java/com/aevi/print/PrinterManager.java
// public interface PrinterManager {
//
// /**
// * @return True if the printing service is installed and available
// */
// boolean isPrinterServiceAvailable();
//
// /**
// * Send a payload for printing
// *
// * @param printPayload The payload to print
// * @return An observable stream of {@link PrintJob} which indicates the status of the printout
// */
// Observable<PrintJob> print(PrintPayload printPayload);
//
// /**
// * Send an action to a printer
// *
// * @param printerId The id of the printer to send the action to
// * @param action The action to perform (see {@link PrinterSettings#getCommands() for a list of commands the printer supports}
// */
// void sendAction(String printerId, String action);
//
// /**
// * A stream of {@link PrinterStatus} indicating the current state of the printer
// *
// * @param printerId The printerId to listen to
// * @return An observable stream of {@link PrinterStatus}
// */
// Observable<PrinterStatus> status(String printerId);
//
// /**
// * Returns the current settings for the default printer
// *
// * @return A Single which will emit the default printer settings if available
// */
// Single<PrinterSettings> getDefaultPrinterSettings();
//
// /**
// * Returns an observable stream which will emit settings for all the available printers
// *
// * @return An observable stream containing a list of {@link PrinterSettings} objects contained in a {@link PrinterSettingsList} object
// */
// Observable<PrinterSettingsList> getPrintersSettings();
// }
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
| import android.graphics.Bitmap;
import com.aevi.print.PrinterManager;
import com.aevi.util.json.JsonConverter;
import com.aevi.util.json.JsonOption;
import com.aevi.util.json.Jsonable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.aevi.print.util.Preconditions.checkNotNull; | /*
* 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.aevi.print.model;
/**
* A {@link PrintPayload} contains a collection of {@link PrintRow} that
* represent a printable text document.
*
* By binding to the {@link PrinterManager} this pay load can be send to the
* receipt printer for printing.
*/
public class PrintPayload implements Jsonable {
private final List<JsonOption> rows = new ArrayList<>();
private int codePage = -1;
private String printerId;
private String languageCode;
/**
* Creates an empty {@link PrintPayload} object.
*/
public PrintPayload() {
}
/**
* Creates an empty {@link PrintPayload} object.
*
* To be sent to a specific printer driver
*
* @param printerId The id of the printer to send this payload to for printing
*/
public PrintPayload(String printerId) {
this.printerId = printerId;
}
/**
* Appends the given text row to this printer pay load.
*
* @param text the text to append to the printer pay load. This parameter
* must not be null.
* @return The new {@link TextRow} object added to the payload
*/
public TextRow append(String text) {
return append(text, null);
}
/**
* Appends the given text row to this printer payload and ensure the printer font given is used
*
* The font must match a {@link PrinterFont} as provided by the printer via its settings methods. See {@link PrinterSettings#getPrinterFonts()}.
*
* @param text The text to add
* @param printerFont The printer font to use
* @return The new {@link TextRow} object added to the payload
*/
public TextRow append(String text, PrinterFont printerFont) { | // Path: print-api/src/main/java/com/aevi/print/PrinterManager.java
// public interface PrinterManager {
//
// /**
// * @return True if the printing service is installed and available
// */
// boolean isPrinterServiceAvailable();
//
// /**
// * Send a payload for printing
// *
// * @param printPayload The payload to print
// * @return An observable stream of {@link PrintJob} which indicates the status of the printout
// */
// Observable<PrintJob> print(PrintPayload printPayload);
//
// /**
// * Send an action to a printer
// *
// * @param printerId The id of the printer to send the action to
// * @param action The action to perform (see {@link PrinterSettings#getCommands() for a list of commands the printer supports}
// */
// void sendAction(String printerId, String action);
//
// /**
// * A stream of {@link PrinterStatus} indicating the current state of the printer
// *
// * @param printerId The printerId to listen to
// * @return An observable stream of {@link PrinterStatus}
// */
// Observable<PrinterStatus> status(String printerId);
//
// /**
// * Returns the current settings for the default printer
// *
// * @return A Single which will emit the default printer settings if available
// */
// Single<PrinterSettings> getDefaultPrinterSettings();
//
// /**
// * Returns an observable stream which will emit settings for all the available printers
// *
// * @return An observable stream containing a list of {@link PrinterSettings} objects contained in a {@link PrinterSettingsList} object
// */
// Observable<PrinterSettingsList> getPrintersSettings();
// }
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
// Path: print-api/src/main/java/com/aevi/print/model/PrintPayload.java
import android.graphics.Bitmap;
import com.aevi.print.PrinterManager;
import com.aevi.util.json.JsonConverter;
import com.aevi.util.json.JsonOption;
import com.aevi.util.json.Jsonable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.aevi.print.util.Preconditions.checkNotNull;
/*
* 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.aevi.print.model;
/**
* A {@link PrintPayload} contains a collection of {@link PrintRow} that
* represent a printable text document.
*
* By binding to the {@link PrinterManager} this pay load can be send to the
* receipt printer for printing.
*/
public class PrintPayload implements Jsonable {
private final List<JsonOption> rows = new ArrayList<>();
private int codePage = -1;
private String printerId;
private String languageCode;
/**
* Creates an empty {@link PrintPayload} object.
*/
public PrintPayload() {
}
/**
* Creates an empty {@link PrintPayload} object.
*
* To be sent to a specific printer driver
*
* @param printerId The id of the printer to send this payload to for printing
*/
public PrintPayload(String printerId) {
this.printerId = printerId;
}
/**
* Appends the given text row to this printer pay load.
*
* @param text the text to append to the printer pay load. This parameter
* must not be null.
* @return The new {@link TextRow} object added to the payload
*/
public TextRow append(String text) {
return append(text, null);
}
/**
* Appends the given text row to this printer payload and ensure the printer font given is used
*
* The font must match a {@link PrinterFont} as provided by the printer via its settings methods. See {@link PrinterSettings#getPrinterFonts()}.
*
* @param text The text to add
* @param printerFont The printer font to use
* @return The new {@link TextRow} object added to the payload
*/
public TextRow append(String text, PrinterFont printerFont) { | checkNotNull(text, "text must not be null"); |
Aevi-UK/android-pos-print-api | print-api/src/main/java/com/aevi/print/model/PrinterSettings.java | // Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
| import com.aevi.util.json.Jsonable;
import java.util.Map;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter; | /*
* 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.aevi.print.model;
/**
* Contains information such as name, DPI and paper width for a specific PrinterSettings on the Device.
*/
public class PrinterSettings implements Jsonable {
public static final String OPTION_DEFAULT = "default";
private final String printerId;
private final int paperWidth;
private final int printableWidth;
private final float paperDotsPmm;
private final PaperKind paperKind;
private final String[] commands;
private final int[] codepages;
private final Map<String, String> options;
private final boolean canHandleCommands;
private final boolean doesReportStatus;
private final boolean doesSupportCodepages;
private final String[] supportedLanguages;
private final PrinterFont[] printerFonts;
private String displayName;
PrinterSettings(String printerId, int paperWidth, int printableWidth, float paperDotsPmm,
PaperKind paperKind, PrinterFont[] printerFonts,
boolean canHandleCommands, String[] commands,
boolean doesReportStatus,
int[] codepages, boolean doesSupportCodepages,
Map<String, String> options,
String[] supportedLanguages) {
| // Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
// Path: print-api/src/main/java/com/aevi/print/model/PrinterSettings.java
import com.aevi.util.json.Jsonable;
import java.util.Map;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter;
/*
* 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.aevi.print.model;
/**
* Contains information such as name, DPI and paper width for a specific PrinterSettings on the Device.
*/
public class PrinterSettings implements Jsonable {
public static final String OPTION_DEFAULT = "default";
private final String printerId;
private final int paperWidth;
private final int printableWidth;
private final float paperDotsPmm;
private final PaperKind paperKind;
private final String[] commands;
private final int[] codepages;
private final Map<String, String> options;
private final boolean canHandleCommands;
private final boolean doesReportStatus;
private final boolean doesSupportCodepages;
private final String[] supportedLanguages;
private final PrinterFont[] printerFonts;
private String displayName;
PrinterSettings(String printerId, int paperWidth, int printableWidth, float paperDotsPmm,
PaperKind paperKind, PrinterFont[] printerFonts,
boolean canHandleCommands, String[] commands,
boolean doesReportStatus,
int[] codepages, boolean doesSupportCodepages,
Map<String, String> options,
String[] supportedLanguages) {
| this.printerId = checkNotNull(printerId, "printerId must not be null") ; |
Aevi-UK/android-pos-print-api | print-api/src/main/java/com/aevi/print/model/ImageRow.java | // Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
| import com.aevi.util.json.JsonConverter;
import static com.aevi.print.util.Preconditions.checkNotNull;
import android.graphics.Bitmap; | /*
* 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.aevi.print.model;
/**
* This class represents an image line in a {@link PrintPayload}.
*/
public class ImageRow implements PrintRow {
private static final int DEFAULT_CONTRAST_LEVEL = 50;
private final Bitmap image;
private final boolean scaleToFit;
private Alignment alignment = Alignment.LEFT;
private int contrastLevel = DEFAULT_CONTRAST_LEVEL;
/**
* Creates a left aligned image row at normal contrast (50) with the given
* bitmap.
*
* NOTE: If the (unscaled) image is too large to print onto the page it <strong>will</strong> be scaled by the printer driver to fit the width.
*
* @param image the image to print. This parameter must not be null.
*/
public ImageRow(Bitmap image) {
this(image, true);
}
/**
* Creates a left aligned image row at normal contrast (50) with the given
* bitmap.
*
* @param image the image to print. This parameter must not be null.
* @param scaleToFit If true the image will be scaled down to fit the page if it is too large. If false the image will be cropped.
*/
public ImageRow(Bitmap image, boolean scaleToFit) { | // Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
// Path: print-api/src/main/java/com/aevi/print/model/ImageRow.java
import com.aevi.util.json.JsonConverter;
import static com.aevi.print.util.Preconditions.checkNotNull;
import android.graphics.Bitmap;
/*
* 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.aevi.print.model;
/**
* This class represents an image line in a {@link PrintPayload}.
*/
public class ImageRow implements PrintRow {
private static final int DEFAULT_CONTRAST_LEVEL = 50;
private final Bitmap image;
private final boolean scaleToFit;
private Alignment alignment = Alignment.LEFT;
private int contrastLevel = DEFAULT_CONTRAST_LEVEL;
/**
* Creates a left aligned image row at normal contrast (50) with the given
* bitmap.
*
* NOTE: If the (unscaled) image is too large to print onto the page it <strong>will</strong> be scaled by the printer driver to fit the width.
*
* @param image the image to print. This parameter must not be null.
*/
public ImageRow(Bitmap image) {
this(image, true);
}
/**
* Creates a left aligned image row at normal contrast (50) with the given
* bitmap.
*
* @param image the image to print. This parameter must not be null.
* @param scaleToFit If true the image will be scaled down to fit the page if it is too large. If false the image will be cropped.
*/
public ImageRow(Bitmap image, boolean scaleToFit) { | this.image = checkNotNull(image, "image must not be null"); |
Aevi-UK/android-pos-print-api | print-api/src/main/java/com/aevi/print/model/TextRow.java | // Path: print-api/src/main/java/com/aevi/print/model/PrinterFont.java
// public static final int DEFAULT_FONT = -1;
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
| import static com.aevi.print.model.PrinterFont.DEFAULT_FONT;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter; | /*
* 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.aevi.print.model;
/**
* This class represents a single text line in a {@link com.aevi.print.model.PrintPayload}.
*/
public class TextRow implements PrintRow, Cloneable {
private final String text; | // Path: print-api/src/main/java/com/aevi/print/model/PrinterFont.java
// public static final int DEFAULT_FONT = -1;
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
// Path: print-api/src/main/java/com/aevi/print/model/TextRow.java
import static com.aevi.print.model.PrinterFont.DEFAULT_FONT;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter;
/*
* 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.aevi.print.model;
/**
* This class represents a single text line in a {@link com.aevi.print.model.PrintPayload}.
*/
public class TextRow implements PrintRow, Cloneable {
private final String text; | private int printerFontId = DEFAULT_FONT; |
Aevi-UK/android-pos-print-api | print-api/src/main/java/com/aevi/print/model/TextRow.java | // Path: print-api/src/main/java/com/aevi/print/model/PrinterFont.java
// public static final int DEFAULT_FONT = -1;
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
| import static com.aevi.print.model.PrinterFont.DEFAULT_FONT;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter; | /*
* 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.aevi.print.model;
/**
* This class represents a single text line in a {@link com.aevi.print.model.PrintPayload}.
*/
public class TextRow implements PrintRow, Cloneable {
private final String text;
private int printerFontId = DEFAULT_FONT;
private Underline underline = Underline.NONE;
private FontStyle fontStyle = FontStyle.NORMAL;
private Alignment alignment = Alignment.LEFT;
/**
* Creates a left aligned text row with with no styling.
*
* @param text The row text. This parameter must not be null.
*/
public TextRow(String text) {
this(text, null);
}
/**
* Creates a left aligned text row using the font given by the fontId.
* The font must match a {@link PrinterFont} as provided by the printer via its settings methods. See {@link PrinterSettings#getPrinterFonts()}.
*
* @param text The text to add
* @param printerFont The printer font to use
*/
public TextRow(String text, PrinterFont printerFont) { | // Path: print-api/src/main/java/com/aevi/print/model/PrinterFont.java
// public static final int DEFAULT_FONT = -1;
//
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
// return object;
// }
// Path: print-api/src/main/java/com/aevi/print/model/TextRow.java
import static com.aevi.print.model.PrinterFont.DEFAULT_FONT;
import static com.aevi.print.util.Preconditions.checkNotNull;
import com.aevi.util.json.JsonConverter;
/*
* 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.aevi.print.model;
/**
* This class represents a single text line in a {@link com.aevi.print.model.PrintPayload}.
*/
public class TextRow implements PrintRow, Cloneable {
private final String text;
private int printerFontId = DEFAULT_FONT;
private Underline underline = Underline.NONE;
private FontStyle fontStyle = FontStyle.NORMAL;
private Alignment alignment = Alignment.LEFT;
/**
* Creates a left aligned text row with with no styling.
*
* @param text The row text. This parameter must not be null.
*/
public TextRow(String text) {
this(text, null);
}
/**
* Creates a left aligned text row using the font given by the fontId.
* The font must match a {@link PrinterFont} as provided by the printer via its settings methods. See {@link PrinterSettings#getPrinterFonts()}.
*
* @param text The text to add
* @param printerFont The printer font to use
*/
public TextRow(String text, PrinterFont printerFont) { | this.text = checkNotNull(text, "text must not be null"); |
chengzichen/KrGallery | gallery/src/main/java/com/dhc/gallery/utils/AndroidUtilities.java | // Path: gallery/src/main/java/com/dhc/gallery/utils/Gallery.java
// public volatile static Application applicationContext;
| import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.StateSet;
import android.view.Display;
import android.view.Surface;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.EdgeEffect;
import android.widget.ListView;
import android.widget.Toast;
import com.dhc.gallery.R;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
import java.util.regex.Pattern;
import static com.dhc.gallery.utils.Gallery.applicationContext; | final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final Pattern IP_ADDRESS = Pattern.compile(
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
+ "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
+ "|[1-9][0-9]|[0-9]))");
final String IRI = "[" + GOOD_IRI_CHAR + "]([" + GOOD_IRI_CHAR + "\\-]{0,61}["
+ GOOD_IRI_CHAR + "]){0,1}";
final String GOOD_GTLD_CHAR = "a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final String GTLD = "[" + GOOD_GTLD_CHAR + "]{2,63}";
final String HOST_NAME = "(" + IRI + "\\.)+" + GTLD;
final Pattern DOMAIN_NAME = Pattern.compile("(" + HOST_NAME + "|" + IP_ADDRESS + ")");
WEB_URL = Pattern.compile(
"((?:(http|https|Http|Https):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ "(?:" + DOMAIN_NAME + ")"
+ "(?:\\:\\d{1,5})?)" // plus option port number
+ "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus
// option
// query
// params
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ "(?:\\b|$)");
} catch (Exception e) {
e.printStackTrace();
}
}
static { | // Path: gallery/src/main/java/com/dhc/gallery/utils/Gallery.java
// public volatile static Application applicationContext;
// Path: gallery/src/main/java/com/dhc/gallery/utils/AndroidUtilities.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.StateSet;
import android.view.Display;
import android.view.Surface;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.EdgeEffect;
import android.widget.ListView;
import android.widget.Toast;
import com.dhc.gallery.R;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
import java.util.regex.Pattern;
import static com.dhc.gallery.utils.Gallery.applicationContext;
final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final Pattern IP_ADDRESS = Pattern.compile(
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
+ "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
+ "|[1-9][0-9]|[0-9]))");
final String IRI = "[" + GOOD_IRI_CHAR + "]([" + GOOD_IRI_CHAR + "\\-]{0,61}["
+ GOOD_IRI_CHAR + "]){0,1}";
final String GOOD_GTLD_CHAR = "a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final String GTLD = "[" + GOOD_GTLD_CHAR + "]{2,63}";
final String HOST_NAME = "(" + IRI + "\\.)+" + GTLD;
final Pattern DOMAIN_NAME = Pattern.compile("(" + HOST_NAME + "|" + IP_ADDRESS + ")");
WEB_URL = Pattern.compile(
"((?:(http|https|Http|Https):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ "(?:" + DOMAIN_NAME + ")"
+ "(?:\\:\\d{1,5})?)" // plus option port number
+ "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus
// option
// query
// params
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ "(?:\\b|$)");
} catch (Exception e) {
e.printStackTrace();
}
}
static { | density = applicationContext.getResources().getDisplayMetrics().density; |
chengzichen/KrGallery | gallery/src/main/java/com/dhc/gallery/actionbar/BaseFragment.java | // Path: gallery/src/main/java/com/dhc/gallery/Theme.java
// public class Theme {
//
// public static final int ACTION_BAR_COLOR = 0xff527da3;
// public static final int ACTION_BAR_PHOTO_VIEWER_COLOR = 0x7f000000;
// public static final int ACTION_BAR_MEDIA_PICKER_COLOR = 0xff333333;
// public static final int ACTION_BAR_SUBTITLE_COLOR = 0xffd5e8f7;
// public static final int ACTION_BAR_SELECTOR_COLOR = 0xff406d94;
//
// public static final int ACTION_BAR_PICKER_SELECTOR_COLOR = 0xff3d3d3d;
// public static final int ACTION_BAR_WHITE_SELECTOR_COLOR = 0x40ffffff;
// public static final int ACTION_BAR_AUDIO_SELECTOR_COLOR = 0x2f000000;
// public static final int ACTION_BAR_MODE_SELECTOR_COLOR = 0xfff0f0f0;
//
// private static Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
// private static HashMap<String, Integer> defaultColors = new HashMap<>();
// private static HashMap<String, Integer> currentColors;
//
//
// public static final String key_chat_serviceBackground = "chat_serviceBackground";
// private static int serviceMessageColor;
//
// public static Drawable createBarSelectorDrawable(int color) {
// return createBarSelectorDrawable(color, true);
// }
//
// public static Drawable createBarSelectorDrawable(int color, boolean masked) {
// if (Build.VERSION.SDK_INT >= 21) {
// Drawable maskDrawable = null;
// if (masked) {
// maskPaint.setColor(0xffffffff);
// maskDrawable = new Drawable() {
// @Override
// public void draw(Canvas canvas) {
// android.graphics.Rect bounds = getBounds();
// canvas.drawCircle(bounds.centerX(), bounds.centerY(),
// AndroidUtilities.dp(18), maskPaint);
// }
//
// @Override
// public void setAlpha(int alpha) {
//
// }
//
// @Override
// public void setColorFilter(ColorFilter colorFilter) {
//
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
// };
// }
// ColorStateList colorStateList = new ColorStateList(
// new int[][] {
// new int[] {}
// },
// new int[] {
// color
// });
// return new RippleDrawable(colorStateList, null, maskDrawable);
// } else {
// StateListDrawable stateListDrawable = new StateListDrawable();
// stateListDrawable.addState(new int[] {
// android.R.attr.state_pressed
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_focused
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_selected
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_activated
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {}, new ColorDrawable(0x00000000));
// return stateListDrawable;
// }
// }
//
//
//
// }
| import android.animation.AnimatorSet;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import com.dhc.gallery.Theme; | } catch (Exception e) {
e.printStackTrace();
}
}
if (parentLayout != null && parentLayout.getContext() != fragmentView.getContext()) {
fragmentView = null;
}
}
if (actionBar != null) {
ViewGroup parent = (ViewGroup) actionBar.getParent();
if (parent != null) {
try {
parent.removeView(actionBar);
} catch (Exception e) {
e.printStackTrace();
}
}
if (parentLayout != null && parentLayout.getContext() != actionBar.getContext()) {
actionBar = null;
}
}
if (parentLayout != null && actionBar == null) {
actionBar = createActionBar(parentLayout.getContext());
actionBar.parentFragment = this;
}
}
}
protected ActionBar createActionBar(Context context) {
ActionBar actionBar = new ActionBar(context); | // Path: gallery/src/main/java/com/dhc/gallery/Theme.java
// public class Theme {
//
// public static final int ACTION_BAR_COLOR = 0xff527da3;
// public static final int ACTION_BAR_PHOTO_VIEWER_COLOR = 0x7f000000;
// public static final int ACTION_BAR_MEDIA_PICKER_COLOR = 0xff333333;
// public static final int ACTION_BAR_SUBTITLE_COLOR = 0xffd5e8f7;
// public static final int ACTION_BAR_SELECTOR_COLOR = 0xff406d94;
//
// public static final int ACTION_BAR_PICKER_SELECTOR_COLOR = 0xff3d3d3d;
// public static final int ACTION_BAR_WHITE_SELECTOR_COLOR = 0x40ffffff;
// public static final int ACTION_BAR_AUDIO_SELECTOR_COLOR = 0x2f000000;
// public static final int ACTION_BAR_MODE_SELECTOR_COLOR = 0xfff0f0f0;
//
// private static Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
// private static HashMap<String, Integer> defaultColors = new HashMap<>();
// private static HashMap<String, Integer> currentColors;
//
//
// public static final String key_chat_serviceBackground = "chat_serviceBackground";
// private static int serviceMessageColor;
//
// public static Drawable createBarSelectorDrawable(int color) {
// return createBarSelectorDrawable(color, true);
// }
//
// public static Drawable createBarSelectorDrawable(int color, boolean masked) {
// if (Build.VERSION.SDK_INT >= 21) {
// Drawable maskDrawable = null;
// if (masked) {
// maskPaint.setColor(0xffffffff);
// maskDrawable = new Drawable() {
// @Override
// public void draw(Canvas canvas) {
// android.graphics.Rect bounds = getBounds();
// canvas.drawCircle(bounds.centerX(), bounds.centerY(),
// AndroidUtilities.dp(18), maskPaint);
// }
//
// @Override
// public void setAlpha(int alpha) {
//
// }
//
// @Override
// public void setColorFilter(ColorFilter colorFilter) {
//
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
// };
// }
// ColorStateList colorStateList = new ColorStateList(
// new int[][] {
// new int[] {}
// },
// new int[] {
// color
// });
// return new RippleDrawable(colorStateList, null, maskDrawable);
// } else {
// StateListDrawable stateListDrawable = new StateListDrawable();
// stateListDrawable.addState(new int[] {
// android.R.attr.state_pressed
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_focused
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_selected
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {
// android.R.attr.state_activated
// }, new ColorDrawable(color));
// stateListDrawable.addState(new int[] {}, new ColorDrawable(0x00000000));
// return stateListDrawable;
// }
// }
//
//
//
// }
// Path: gallery/src/main/java/com/dhc/gallery/actionbar/BaseFragment.java
import android.animation.AnimatorSet;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import com.dhc.gallery.Theme;
} catch (Exception e) {
e.printStackTrace();
}
}
if (parentLayout != null && parentLayout.getContext() != fragmentView.getContext()) {
fragmentView = null;
}
}
if (actionBar != null) {
ViewGroup parent = (ViewGroup) actionBar.getParent();
if (parent != null) {
try {
parent.removeView(actionBar);
} catch (Exception e) {
e.printStackTrace();
}
}
if (parentLayout != null && parentLayout.getContext() != actionBar.getContext()) {
actionBar = null;
}
}
if (parentLayout != null && actionBar == null) {
actionBar = createActionBar(parentLayout.getContext());
actionBar.parentFragment = this;
}
}
}
protected ActionBar createActionBar(Context context) {
ActionBar actionBar = new ActionBar(context); | actionBar.setBackgroundColor(Theme.ACTION_BAR_COLOR); |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DCommand.java | // Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
| import org.drupal.project.computing.exception.DCommandExecutionException;
import org.drupal.project.computing.exception.DRuntimeException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.concurrent.Callable;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* <p>This is the base class for all Drupal Computing command. A DCommand class is instantiated and executed when a
* DApplication process the list of DRecord (computing record entity) from a DSite (Drupal site). A DCommand sub-class
* should focus on its own logic, instead of worrying about reading/writing data with Drupal. Input data from Drupal
* should be processed in prepare(), and results should be saved in "this.result" and "this.message" field, which are
* then saved back to Drupal.
* <p/>
*
* <p>You need to overrides 2 methods:</p> <ol> <li>prepare(): initialize input from a Bindings object. throws
* IllegalArgumentException if needed</li> <li>execute(): execute the command. throws DCommandExecutionException if
* necessary. otherwise saves results to "this.result" (Bindings) and "this.message" (StringBuffer)</li> </ol>
*/
abstract public class DCommand implements Runnable, Callable<Void> {
/**
* Prepare the command by taking data from "input" and set internal states.
*
* Design decisions:
* 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
* 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
* 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
* 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
*
* @param input data from DRecord.input.
*/
abstract public void prepare(Bindings input) throws IllegalArgumentException;
/**
* This is the core of DCommand. Execute the command after fully initialized from Input data.
* We expect execute() to run successfully. If an error occurs, throw an exception.
*
* Execution should also write to "message" and "result" to pass results back to DApplication.
*/ | // Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DCommand.java
import org.drupal.project.computing.exception.DCommandExecutionException;
import org.drupal.project.computing.exception.DRuntimeException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.concurrent.Callable;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* <p>This is the base class for all Drupal Computing command. A DCommand class is instantiated and executed when a
* DApplication process the list of DRecord (computing record entity) from a DSite (Drupal site). A DCommand sub-class
* should focus on its own logic, instead of worrying about reading/writing data with Drupal. Input data from Drupal
* should be processed in prepare(), and results should be saved in "this.result" and "this.message" field, which are
* then saved back to Drupal.
* <p/>
*
* <p>You need to overrides 2 methods:</p> <ol> <li>prepare(): initialize input from a Bindings object. throws
* IllegalArgumentException if needed</li> <li>execute(): execute the command. throws DCommandExecutionException if
* necessary. otherwise saves results to "this.result" (Bindings) and "this.message" (StringBuffer)</li> </ol>
*/
abstract public class DCommand implements Runnable, Callable<Void> {
/**
* Prepare the command by taking data from "input" and set internal states.
*
* Design decisions:
* 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
* 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
* 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
* 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
*
* @param input data from DRecord.input.
*/
abstract public void prepare(Bindings input) throws IllegalArgumentException;
/**
* This is the core of DCommand. Execute the command after fully initialized from Input data.
* We expect execute() to run successfully. If an error occurs, throw an exception.
*
* Execution should also write to "message" and "result" to pass results back to DApplication.
*/ | abstract public void execute() throws DCommandExecutionException; |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DCommand.java | // Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
| import org.drupal.project.computing.exception.DCommandExecutionException;
import org.drupal.project.computing.exception.DRuntimeException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.concurrent.Callable;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* <p>This is the base class for all Drupal Computing command. A DCommand class is instantiated and executed when a
* DApplication process the list of DRecord (computing record entity) from a DSite (Drupal site). A DCommand sub-class
* should focus on its own logic, instead of worrying about reading/writing data with Drupal. Input data from Drupal
* should be processed in prepare(), and results should be saved in "this.result" and "this.message" field, which are
* then saved back to Drupal.
* <p/>
*
* <p>You need to overrides 2 methods:</p> <ol> <li>prepare(): initialize input from a Bindings object. throws
* IllegalArgumentException if needed</li> <li>execute(): execute the command. throws DCommandExecutionException if
* necessary. otherwise saves results to "this.result" (Bindings) and "this.message" (StringBuffer)</li> </ol>
*/
abstract public class DCommand implements Runnable, Callable<Void> {
/**
* Prepare the command by taking data from "input" and set internal states.
*
* Design decisions:
* 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
* 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
* 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
* 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
*
* @param input data from DRecord.input.
*/
abstract public void prepare(Bindings input) throws IllegalArgumentException;
/**
* This is the core of DCommand. Execute the command after fully initialized from Input data.
* We expect execute() to run successfully. If an error occurs, throw an exception.
*
* Execution should also write to "message" and "result" to pass results back to DApplication.
*/
abstract public void execute() throws DCommandExecutionException;
/////////////////////////////////// default implementation or Runnable and Callable ////////////////////////
@Override
public void run() {
try {
execute();
} catch (DCommandExecutionException e) {
// the caller should catch this exception, and then get "e", which is the DCommandExecutionException. | // Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DCommand.java
import org.drupal.project.computing.exception.DCommandExecutionException;
import org.drupal.project.computing.exception.DRuntimeException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.concurrent.Callable;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* <p>This is the base class for all Drupal Computing command. A DCommand class is instantiated and executed when a
* DApplication process the list of DRecord (computing record entity) from a DSite (Drupal site). A DCommand sub-class
* should focus on its own logic, instead of worrying about reading/writing data with Drupal. Input data from Drupal
* should be processed in prepare(), and results should be saved in "this.result" and "this.message" field, which are
* then saved back to Drupal.
* <p/>
*
* <p>You need to overrides 2 methods:</p> <ol> <li>prepare(): initialize input from a Bindings object. throws
* IllegalArgumentException if needed</li> <li>execute(): execute the command. throws DCommandExecutionException if
* necessary. otherwise saves results to "this.result" (Bindings) and "this.message" (StringBuffer)</li> </ol>
*/
abstract public class DCommand implements Runnable, Callable<Void> {
/**
* Prepare the command by taking data from "input" and set internal states.
*
* Design decisions:
* 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
* 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
* 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
* 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
*
* @param input data from DRecord.input.
*/
abstract public void prepare(Bindings input) throws IllegalArgumentException;
/**
* This is the core of DCommand. Execute the command after fully initialized from Input data.
* We expect execute() to run successfully. If an error occurs, throw an exception.
*
* Execution should also write to "message" and "result" to pass results back to DApplication.
*/
abstract public void execute() throws DCommandExecutionException;
/////////////////////////////////// default implementation or Runnable and Callable ////////////////////////
@Override
public void run() {
try {
execute();
} catch (DCommandExecutionException e) {
// the caller should catch this exception, and then get "e", which is the DCommandExecutionException. | throw new DRuntimeException(e); |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DUtils.java | // Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.google.gson.*;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.logging.Logger; | */
public String encodeURLQueryParameters(Properties params) {
StringBuilder sb = new StringBuilder();
Iterator<String> keysIterator = params.stringPropertyNames().iterator();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
try {
sb.append(URLEncoder.encode(key, "UTF-8")).append('=').append(URLEncoder.encode(params.getProperty(key), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
if (keysIterator.hasNext()) {
sb.append('&');
}
}
return sb.toString();
}
/**
* Execute a command in the working dir, and return the output as a String. If error, log the errors in logger.
*
* @param commandLine The command line object
* @param workingDir The working directory. Could be null. The it's default user.dir.
* @param input Input string
* @return command output.
*/ | // Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DUtils.java
import com.google.gson.*;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.logging.Logger;
*/
public String encodeURLQueryParameters(Properties params) {
StringBuilder sb = new StringBuilder();
Iterator<String> keysIterator = params.stringPropertyNames().iterator();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
try {
sb.append(URLEncoder.encode(key, "UTF-8")).append('=').append(URLEncoder.encode(params.getProperty(key), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
if (keysIterator.hasNext()) {
sb.append('&');
}
}
return sb.toString();
}
/**
* Execute a command in the working dir, and return the output as a String. If error, log the errors in logger.
*
* @param commandLine The command line object
* @param workingDir The working directory. Could be null. The it's default user.dir.
* @param input Input string
* @return command output.
*/ | public String executeShell(CommandLine commandLine, File workingDir, String input) throws DSystemExecutionException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DUtils.java | // Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.google.gson.*;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.logging.Logger; | * @return
*/
public boolean getBoolean(Object value) {
if (value == null) {
return false;
} else if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof Integer) {
return BooleanUtils.toBoolean((Integer) value);
} else if (value instanceof String) {
String str = (String) value;
if (StringUtils.isBlank(str)) return false;
try {
int i = Integer.parseInt(str);
return BooleanUtils.toBoolean(i);
} catch (NumberFormatException e) {
return BooleanUtils.toBoolean(str);
}
} else {
throw new IllegalArgumentException("Cannot parse value: " + value.toString());
}
}
public Properties loadProperties(String configString) {
Properties config = new Properties();
try {
config.load(new StringReader(configString));
} catch (IOException e) { | // Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DUtils.java
import com.google.gson.*;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.logging.Logger;
* @return
*/
public boolean getBoolean(Object value) {
if (value == null) {
return false;
} else if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof Integer) {
return BooleanUtils.toBoolean((Integer) value);
} else if (value instanceof String) {
String str = (String) value;
if (StringUtils.isBlank(str)) return false;
try {
int i = Integer.parseInt(str);
return BooleanUtils.toBoolean(i);
} catch (NumberFormatException e) {
return BooleanUtils.toBoolean(str);
}
} else {
throw new IllegalArgumentException("Cannot parse value: " + value.toString());
}
}
public Properties loadProperties(String configString) {
Properties config = new Properties();
try {
config.load(new StringReader(configString));
} catch (IOException e) { | throw new DRuntimeException("Cannot read config string in DUtils."); |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DDrushSite.java | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings; | package org.drupal.project.computing;
/**
* The Drupal site instance that can be accessed directly through drush.
*/
public class DDrushSite extends DSite implements DSiteExtended {
private DDrush drush;
public DDrushSite(DDrush drush) {
this.drush = drush;
}
/**
* Factory method. Create DDrushSite using default config.properties file.
* @return Default DDrushSite object.
*/
public static DDrushSite loadDefault() {
return new DDrushSite(DDrush.loadDefault());
}
/**
* each Drush site would be able to return a database connection.
* although remote drupal site usually has "localhost" as host. If that's the case, remote site could use
* $databases['computing']['default'] is settings.php to get a valid connection
*
* @return DDatabase connection. Caller is responsible to close it.
*/
// @Deprecated
// public DDatabase getDatabase() throws DSiteException {
// DConfig config = new DConfig();
// config.setProperty("drupal.drush", drush.getDrushExec());
// try {
// Properties dbProperties = config.getDbProperties();
// DDatabase db = new DDatabase(dbProperties);
// return db;
// } catch (DConfigException e) {
// throw new DSiteException("Cannot get database connection to Drupal with drush. Please read documentations.", e);
// }
// }
public DDrush getDrush() {
return drush;
}
@Override | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DDrushSite.java
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
package org.drupal.project.computing;
/**
* The Drupal site instance that can be accessed directly through drush.
*/
public class DDrushSite extends DSite implements DSiteExtended {
private DDrush drush;
public DDrushSite(DDrush drush) {
this.drush = drush;
}
/**
* Factory method. Create DDrushSite using default config.properties file.
* @return Default DDrushSite object.
*/
public static DDrushSite loadDefault() {
return new DDrushSite(DDrush.loadDefault());
}
/**
* each Drush site would be able to return a database connection.
* although remote drupal site usually has "localhost" as host. If that's the case, remote site could use
* $databases['computing']['default'] is settings.php to get a valid connection
*
* @return DDatabase connection. Caller is responsible to close it.
*/
// @Deprecated
// public DDatabase getDatabase() throws DSiteException {
// DConfig config = new DConfig();
// config.setProperty("drupal.drush", drush.getDrushExec());
// try {
// Properties dbProperties = config.getDbProperties();
// DDatabase db = new DDatabase(dbProperties);
// return db;
// } catch (DConfigException e) {
// throw new DSiteException("Cannot get database connection to Drupal with drush. Please read documentations.", e);
// }
// }
public DDrush getDrush() {
return drush;
}
@Override | public String getDrupalVersion() throws DSiteException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DDrushSite.java | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings; | extraOptions.remove("input");
String jsonResult = drush.computingCall("computing_create",
record.getApplication(),
record.getCommand(),
StringUtils.isBlank(record.getLabel()) ? "Process " + record.getCommand() : record.getLabel(),
record.getInput(), // this will get encoded in JSON regardless of whether it's null or not.
// handle more data here.
extraOptions
);
try {
return DUtils.Json.getInstance().fromJson(jsonResult, Long.class);
} catch (JsonSyntaxException e) {
throw new DSiteException("Cannot parse JSON result: " + jsonResult, e);
}
}
@Override
public DRecord loadRecord(long id) throws DSiteException {
String jsonResult = drush.computingCall("computing_load", id);
try {
return DRecord.fromJson(jsonResult);
} catch (JsonSyntaxException | IllegalArgumentException e) {
throw new DSiteException("Cannot parse JSON result: " + jsonResult, e);
}
}
@Override | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DDrushSite.java
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
extraOptions.remove("input");
String jsonResult = drush.computingCall("computing_create",
record.getApplication(),
record.getCommand(),
StringUtils.isBlank(record.getLabel()) ? "Process " + record.getCommand() : record.getLabel(),
record.getInput(), // this will get encoded in JSON regardless of whether it's null or not.
// handle more data here.
extraOptions
);
try {
return DUtils.Json.getInstance().fromJson(jsonResult, Long.class);
} catch (JsonSyntaxException e) {
throw new DSiteException("Cannot parse JSON result: " + jsonResult, e);
}
}
@Override
public DRecord loadRecord(long id) throws DSiteException {
String jsonResult = drush.computingCall("computing_load", id);
try {
return DRecord.fromJson(jsonResult);
} catch (JsonSyntaxException | IllegalArgumentException e) {
throw new DSiteException("Cannot parse JSON result: " + jsonResult, e);
}
}
@Override | public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DServicesSite.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List; | package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
| // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DServicesSite.java
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List;
package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
| public static DServicesSite loadDefault() throws DConfigException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DServicesSite.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List; | package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
public static DServicesSite loadDefault() throws DConfigException {
return new DServicesSite(DRestfulJsonServices.loadDefault());
}
public DRestfulJsonServices getServices() {
return services;
}
/**
* Connect to Drupal site with services.
* This will get called automatically if it's not getting called yet before doing any operations.
* @throws DSiteException
*/ | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DServicesSite.java
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List;
package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
public static DServicesSite loadDefault() throws DConfigException {
return new DServicesSite(DRestfulJsonServices.loadDefault());
}
public DRestfulJsonServices getServices() {
return services;
}
/**
* Connect to Drupal site with services.
* This will get called automatically if it's not getting called yet before doing any operations.
* @throws DSiteException
*/ | public void connect() throws DSiteException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DServicesSite.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List; | package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
public static DServicesSite loadDefault() throws DConfigException {
return new DServicesSite(DRestfulJsonServices.loadDefault());
}
public DRestfulJsonServices getServices() {
return services;
}
/**
* Connect to Drupal site with services.
* This will get called automatically if it's not getting called yet before doing any operations.
* @throws DSiteException
*/
public void connect() throws DSiteException {
if (!services.isAuthenticated()) {
services.userLogin();
}
}
/**
* Caller should explicitly call this function to close connection (basically logoff the drupal user).
*
* @throws DSiteException
*/
public void close() throws DSiteException {
if (services.isAuthenticated()) {
services.userLogout();
}
}
@Override | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DServicesSite.java
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.ArrayList;
import java.util.List;
package org.drupal.project.computing;
/**
* Uses Drupal Services REST Server to access Drupal. This class has connect() and close() which are not defined in
* DSite. The DApplication is responsible to connect() and close() the connection. However, here we try "connect()" for
* all operations that require user login.
*
* BUG: DApplication doesn't explicitly run "close()" for DServicesSite.
*/
public class DServicesSite extends DSite implements DSiteExtended {
protected DRestfulJsonServices services;
public DServicesSite(DRestfulJsonServices services) {
this.services = services;
}
public static DServicesSite loadDefault() throws DConfigException {
return new DServicesSite(DRestfulJsonServices.loadDefault());
}
public DRestfulJsonServices getServices() {
return services;
}
/**
* Connect to Drupal site with services.
* This will get called automatically if it's not getting called yet before doing any operations.
* @throws DSiteException
*/
public void connect() throws DSiteException {
if (!services.isAuthenticated()) {
services.userLogin();
}
}
/**
* Caller should explicitly call this function to close connection (basically logoff the drupal user).
*
* @throws DSiteException
*/
public void close() throws DSiteException {
if (services.isAuthenticated()) {
services.userLogout();
}
}
@Override | public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DSite.java | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/ | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DSite.java
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/ | abstract public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException; |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DSite.java | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/ | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DSite.java
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/ | abstract public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException; |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DSite.java | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/
abstract public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException;
/**
* After agent finishes computation, return the results to Drupal.
*
* @param record the record to mark as finished and send back results.
* @throws DSiteException
*/
abstract public void finishRecord(DRecord record) throws DSiteException;
/**
* Save the updated record in the database.
* @param record The computing record to be saved.
*/
abstract public void updateRecord(DRecord record) throws DSiteException;
/**
* Update only the specified field of the record.
*
* @param record The computing record to be updated.
* @param fieldName The field to be updated.
*/
abstract public void updateRecordField(DRecord record, String fieldName) throws DSiteException;
/**
* Save the new record Drupal using the data in the parameter.
*
* @param record The newly created record. record.isSave() has too be true.
* @return The database record ID of the newly created record.
*/
abstract public long createRecord(DRecord record) throws DSiteException;
/**
* Load one record according to its ID. This is expected to return a valid DRecord.
* If id is invalid, this function will throw an exception.
*
* @param id The id of computing record.
* @return the loaded DRecord.
*/
abstract public DRecord loadRecord(long id) throws DSiteException;
/**
* Check whether connection to Drupal site is established.
*
* @return true if the connection is valid. will not throw exceptions.
*/
public boolean checkConnection() {
try {
String drupalVersion = getDrupalVersion();
logger.info("Drupal version: " + drupalVersion);
return true;
} catch (DSiteException e) {
logger.warning("Cannot connect to Drupal site");
return false; | // Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DRuntimeException.java
// public class DRuntimeException extends RuntimeException {
//
// public DRuntimeException() {
// super();
// }
//
// public DRuntimeException(String s) {
// super(s);
// }
//
// public DRuntimeException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DRuntimeException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DSite.java
import org.drupal.project.computing.exception.DNotFoundException;
import org.drupal.project.computing.exception.DRuntimeException;
import org.drupal.project.computing.exception.DSiteException;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* <p>This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
* to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
* (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
* application read it and write results back to the output field in the record, and your Drupal module can read data
* back to the database.</p>
*
* <p>Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
* DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
* into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
* subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
* drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.</p>
*
* <p>Some sub-class implementations: DServicesSite, DDrushSite</p>
*/
abstract public class DSite {
protected Logger logger = DUtils.getInstance().getPackageLogger();
/**
* Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
* If there's no record to return, throw DNotFoundException.
*
* @param appName the Application name to claim a record.
* @return A computing record to handle, or NULL is none is found.
*/
abstract public DRecord claimRecord(String appName) throws DSiteException, DNotFoundException;
/**
* After agent finishes computation, return the results to Drupal.
*
* @param record the record to mark as finished and send back results.
* @throws DSiteException
*/
abstract public void finishRecord(DRecord record) throws DSiteException;
/**
* Save the updated record in the database.
* @param record The computing record to be saved.
*/
abstract public void updateRecord(DRecord record) throws DSiteException;
/**
* Update only the specified field of the record.
*
* @param record The computing record to be updated.
* @param fieldName The field to be updated.
*/
abstract public void updateRecordField(DRecord record, String fieldName) throws DSiteException;
/**
* Save the new record Drupal using the data in the parameter.
*
* @param record The newly created record. record.isSave() has too be true.
* @return The database record ID of the newly created record.
*/
abstract public long createRecord(DRecord record) throws DSiteException;
/**
* Load one record according to its ID. This is expected to return a valid DRecord.
* If id is invalid, this function will throw an exception.
*
* @param id The id of computing record.
* @return the loaded DRecord.
*/
abstract public DRecord loadRecord(long id) throws DSiteException;
/**
* Check whether connection to Drupal site is established.
*
* @return true if the connection is valid. will not throw exceptions.
*/
public boolean checkConnection() {
try {
String drupalVersion = getDrupalVersion();
logger.info("Drupal version: " + drupalVersion);
return true;
} catch (DSiteException e) {
logger.warning("Cannot connect to Drupal site");
return false; | } catch (DRuntimeException e) { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/common/EchoCommand.java | // Path: java/src/org/drupal/project/computing/DCommand.java
// abstract public class DCommand implements Runnable, Callable<Void> {
//
//
// /**
// * Prepare the command by taking data from "input" and set internal states.
// *
// * Design decisions:
// * 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
// * 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
// * 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
// * 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
// *
// * @param input data from DRecord.input.
// */
// abstract public void prepare(Bindings input) throws IllegalArgumentException;
//
//
// /**
// * This is the core of DCommand. Execute the command after fully initialized from Input data.
// * We expect execute() to run successfully. If an error occurs, throw an exception.
// *
// * Execution should also write to "message" and "result" to pass results back to DApplication.
// */
// abstract public void execute() throws DCommandExecutionException;
//
//
//
// /////////////////////////////////// default implementation or Runnable and Callable ////////////////////////
//
//
// @Override
// public void run() {
// try {
// execute();
// } catch (DCommandExecutionException e) {
// // the caller should catch this exception, and then get "e", which is the DCommandExecutionException.
// throw new DRuntimeException(e);
// }
// }
//
// @Override
// public Void call() throws DCommandExecutionException {
// execute();
// return null;
// }
//
//
// /////////////////////////////////////// other useful stuff /////////////////////////////////////////////////
//
//
//
//
// protected Logger logger = DUtils.getInstance().getPackageLogger();
//
// /**
// * Stores execution message to show to Drupal users.
// */
// protected StringBuffer message = new StringBuffer();
//
// /**
// * Write results back to this so it can be retrieved later.
// */
// protected Bindings result = new SimpleBindings();
//
// /**
// * This is how the caller function can get the execution mesesge.
// * @return
// */
// public String getMessage() {
// return message.toString();
// }
//
// /**
// * This is how the caller function can retrieve the execution results.
// * @return
// */
// public Bindings getResult() {
// return result;
// }
//
//
// // contextual data, usually you don't want to use them because all the required data to run the command should be passed in with Input.
// // however, we still provide the data just in case.
//
// /**
// * The site from which the command is created.
// */
// protected DSite site;
//
// /**
// * The DApplication object that execute the command.
// */
// protected DApplication application;
//
// /**
// * The record that issues the command
// */
// protected DRecord record;
//
// /**
// * Agent configuration.
// */
// protected DConfig config;
//
//
// /**
// * Set the contextual data.
// *
// * @param record the DRecord object that instantiate this DCommand object
// * @param site the Drupal site that's associated.
// * @param application the DApplication object that creates the DCommand object
// * @param config The configurations.
// */
// public void setContext(DRecord record, DSite site, DApplication application, DConfig config) {
// this.record = record;
// this.site = site;
// this.application = application;
// this.config = config;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
| import org.drupal.project.computing.DCommand;
import org.drupal.project.computing.exception.DCommandExecutionException;
import javax.script.Bindings; | package org.drupal.project.computing.common;
/**
* A simple DCommand implementation that echos the "input" string into "output".
*/
public class EchoCommand extends DCommand {
String pingString;
@Override
public void prepare(Bindings input) throws IllegalArgumentException {
try {
pingString = (String) input.get("ping");
} catch (NullPointerException | ClassCastException e) {
throw new IllegalArgumentException("Cannot get input parameter, the 'ping' string.");
}
}
@Override | // Path: java/src/org/drupal/project/computing/DCommand.java
// abstract public class DCommand implements Runnable, Callable<Void> {
//
//
// /**
// * Prepare the command by taking data from "input" and set internal states.
// *
// * Design decisions:
// * 1. There's no "abstract static method" in Java, so we can't use factory method pattern (unless we have a separate Factory class, which is not needed)
// * 2. There's no "abstract constructor" to force a constructor that takes Bindings as input.
// * 3. Therefore, we can only pass in Input Bindings in a regular abstract function, which means the object has to be initialized first, which means we can't have other types of constructors (except for the the default constructor).
// * 4. Therefore, this method "prepare" is the only entry to initialize an DCommand object.
// *
// * @param input data from DRecord.input.
// */
// abstract public void prepare(Bindings input) throws IllegalArgumentException;
//
//
// /**
// * This is the core of DCommand. Execute the command after fully initialized from Input data.
// * We expect execute() to run successfully. If an error occurs, throw an exception.
// *
// * Execution should also write to "message" and "result" to pass results back to DApplication.
// */
// abstract public void execute() throws DCommandExecutionException;
//
//
//
// /////////////////////////////////// default implementation or Runnable and Callable ////////////////////////
//
//
// @Override
// public void run() {
// try {
// execute();
// } catch (DCommandExecutionException e) {
// // the caller should catch this exception, and then get "e", which is the DCommandExecutionException.
// throw new DRuntimeException(e);
// }
// }
//
// @Override
// public Void call() throws DCommandExecutionException {
// execute();
// return null;
// }
//
//
// /////////////////////////////////////// other useful stuff /////////////////////////////////////////////////
//
//
//
//
// protected Logger logger = DUtils.getInstance().getPackageLogger();
//
// /**
// * Stores execution message to show to Drupal users.
// */
// protected StringBuffer message = new StringBuffer();
//
// /**
// * Write results back to this so it can be retrieved later.
// */
// protected Bindings result = new SimpleBindings();
//
// /**
// * This is how the caller function can get the execution mesesge.
// * @return
// */
// public String getMessage() {
// return message.toString();
// }
//
// /**
// * This is how the caller function can retrieve the execution results.
// * @return
// */
// public Bindings getResult() {
// return result;
// }
//
//
// // contextual data, usually you don't want to use them because all the required data to run the command should be passed in with Input.
// // however, we still provide the data just in case.
//
// /**
// * The site from which the command is created.
// */
// protected DSite site;
//
// /**
// * The DApplication object that execute the command.
// */
// protected DApplication application;
//
// /**
// * The record that issues the command
// */
// protected DRecord record;
//
// /**
// * Agent configuration.
// */
// protected DConfig config;
//
//
// /**
// * Set the contextual data.
// *
// * @param record the DRecord object that instantiate this DCommand object
// * @param site the Drupal site that's associated.
// * @param application the DApplication object that creates the DCommand object
// * @param config The configurations.
// */
// public void setContext(DRecord record, DSite site, DApplication application, DConfig config) {
// this.record = record;
// this.site = site;
// this.application = application;
// this.config = config;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DCommandExecutionException.java
// public class DCommandExecutionException extends Exception {
// public DCommandExecutionException() {
// super();
// }
//
// public DCommandExecutionException(String s) {
// super(s);
// }
//
// public DCommandExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DCommandExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/common/EchoCommand.java
import org.drupal.project.computing.DCommand;
import org.drupal.project.computing.exception.DCommandExecutionException;
import javax.script.Bindings;
package org.drupal.project.computing.common;
/**
* A simple DCommand implementation that echos the "input" string into "output".
*/
public class EchoCommand extends DCommand {
String pingString;
@Override
public void prepare(Bindings input) throws IllegalArgumentException {
try {
pingString = (String) input.get("ping");
} catch (NullPointerException | ClassCastException e) {
throw new IllegalArgumentException("Cannot get input parameter, the 'ping' string.");
}
}
@Override | public void execute() throws DCommandExecutionException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DRestfulJsonServices.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import com.google.gson.JsonParseException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.Properties;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* This class allows accessing Drupal using the services.module. It requires Drupal REST Sever module, and both HTTP
* Request and HTTP Response will use Content-Type = application/json. See Drupal Computing documentation about how to
* configure at the Drupal end.
*/
public class DRestfulJsonServices {
protected String baseUrl;
protected String endpoint;
protected String userName;
protected String userPass;
protected String httpUserAgent = "DrupalComputingAgent";
protected String httpContentType = "application/json";
protected URL servicesEndpoint;
protected String servicesSessionToken;
protected Logger logger = DUtils.getInstance().getPackageLogger();
public DRestfulJsonServices(String baseUrl, String endpoint, String userName, String userPass) throws IllegalArgumentException {
assert StringUtils.isNotBlank(baseUrl) && StringUtils.isNotBlank(endpoint) && StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(userPass);
this.baseUrl = baseUrl;
this.endpoint = endpoint;
this.userName = userName;
this.userPass = userPass;
try {
this.servicesEndpoint = new URL(new URL(baseUrl), endpoint);
} catch (MalformedURLException e) {
e.printStackTrace();
throw new IllegalArgumentException("Malformed URL: " + baseUrl + " and endpoint: " + endpoint, e);
}
// set cookie support.
// this is required to maintain sessions among different calls.
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
}
/**
* Use the settings in config file and create access to Drupal services.
*
* @return the DRestfulJsonServices object.
* @throws DConfigException
*/ | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DRestfulJsonServices.java
import com.google.gson.JsonParseException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.Properties;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* This class allows accessing Drupal using the services.module. It requires Drupal REST Sever module, and both HTTP
* Request and HTTP Response will use Content-Type = application/json. See Drupal Computing documentation about how to
* configure at the Drupal end.
*/
public class DRestfulJsonServices {
protected String baseUrl;
protected String endpoint;
protected String userName;
protected String userPass;
protected String httpUserAgent = "DrupalComputingAgent";
protected String httpContentType = "application/json";
protected URL servicesEndpoint;
protected String servicesSessionToken;
protected Logger logger = DUtils.getInstance().getPackageLogger();
public DRestfulJsonServices(String baseUrl, String endpoint, String userName, String userPass) throws IllegalArgumentException {
assert StringUtils.isNotBlank(baseUrl) && StringUtils.isNotBlank(endpoint) && StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(userPass);
this.baseUrl = baseUrl;
this.endpoint = endpoint;
this.userName = userName;
this.userPass = userPass;
try {
this.servicesEndpoint = new URL(new URL(baseUrl), endpoint);
} catch (MalformedURLException e) {
e.printStackTrace();
throw new IllegalArgumentException("Malformed URL: " + baseUrl + " and endpoint: " + endpoint, e);
}
// set cookie support.
// this is required to maintain sessions among different calls.
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
}
/**
* Use the settings in config file and create access to Drupal services.
*
* @return the DRestfulJsonServices object.
* @throws DConfigException
*/ | public static DRestfulJsonServices loadDefault() throws DConfigException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DRestfulJsonServices.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
| import com.google.gson.JsonParseException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.Properties;
import java.util.logging.Logger; | * @return the DRestfulJsonServices object.
* @throws DConfigException
*/
public static DRestfulJsonServices loadDefault() throws DConfigException {
DConfig config = DConfig.loadDefault();
String baseUrl = config.getProperty("dcomp.site.base_url", "");
String endpoint = config.getProperty("dcomp.services.endpoint", "");
String userName = config.getProperty("dcomp.services.user.name", "");
String userPass = config.getProperty("dcomp.services.user.pass", "");
if (StringUtils.isNotBlank(baseUrl) && StringUtils.isNotBlank(endpoint) && StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(userPass)) {
return new DRestfulJsonServices(baseUrl, endpoint, userName, userPass);
} else {
throw new DConfigException("Access Drupal Services configuration error.");
}
}
/**
* High level API to make HTTP request and get response in JSON.
*
* @param directive Services command, such as CRUD, Actions, Targeted Actions, etc.
* @param params Data to send in HTTP request.
* @param method HTTP Request method, e.g. GET, POST, DELETE, etc.
*
* @return arsed JSON object, either null, or a Primitive, or a List, or a Bindings.
* @throws IllegalArgumentException
* @throws DSiteException
* @see org.drupal.project.computing.DUtils.Json
*/ | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
// Path: java/src/org/drupal/project/computing/DRestfulJsonServices.java
import com.google.gson.JsonParseException;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DSiteException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.Properties;
import java.util.logging.Logger;
* @return the DRestfulJsonServices object.
* @throws DConfigException
*/
public static DRestfulJsonServices loadDefault() throws DConfigException {
DConfig config = DConfig.loadDefault();
String baseUrl = config.getProperty("dcomp.site.base_url", "");
String endpoint = config.getProperty("dcomp.services.endpoint", "");
String userName = config.getProperty("dcomp.services.user.name", "");
String userPass = config.getProperty("dcomp.services.user.pass", "");
if (StringUtils.isNotBlank(baseUrl) && StringUtils.isNotBlank(endpoint) && StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(userPass)) {
return new DRestfulJsonServices(baseUrl, endpoint, userName, userPass);
} else {
throw new DConfigException("Access Drupal Services configuration error.");
}
}
/**
* High level API to make HTTP request and get response in JSON.
*
* @param directive Services command, such as CRUD, Actions, Targeted Actions, etc.
* @param params Data to send in HTTP request.
* @param method HTTP Request method, e.g. GET, POST, DELETE, etc.
*
* @return arsed JSON object, either null, or a Primitive, or a List, or a Bindings.
* @throws IllegalArgumentException
* @throws DSiteException
* @see org.drupal.project.computing.DUtils.Json
*/ | public Object request(String directive, Bindings params, String method) throws IllegalArgumentException, DSiteException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DDrush.java | // Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
| import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* This is the utility class to run drush command. You need to specify "dcomp.drush.command" (default "drush") and
* "dcomp.drush.site" (default "@self") to be able to access Drush. This class interact with Drupal Computing drush
* "computing-call" and "computing-eval" to execute any Drupal functions.
*/
public class DDrush {
private String drushCommand;
private String drushSiteAlias;
private Logger logger = DUtils.getInstance().getPackageLogger();
//private Boolean computingEnabled;
/**
* This is the only initialization code. Need to specify drush command and siteAlias.
*
* @param drushCommand drush executable command
* @param drushSiteAlias drush site alias
*/
public DDrush(String drushCommand, String drushSiteAlias) {
assert StringUtils.isNotBlank(drushCommand) && StringUtils.isNotBlank(drushSiteAlias);
// TODO: check "drush cc" and existence of computing module.
this.drushCommand = drushCommand;
this.drushSiteAlias = drushSiteAlias;
}
/**
* Create a DDrush object using settings from config.properties.
*
* @return the DDrush object.
*/
public static DDrush loadDefault() {
// might need to check validity.
DConfig config = DConfig.loadDefault();
return new DDrush(config.getDrushCommand(), config.getDrushSiteAlias());
}
/**
* Execute Drush command, and returns STDOUT results.
* attention: here we use shell stdout to output results, which is problematic.
*
* possible problems are:
* 1) security concerns, where confidential info might get printed
* 2) encoding/decoding characters to byte streams, especially with non-english languages and serializd strings.
* 3) escaping problems
* 4) output might get messed up with other sub-processes.
*
* some other IPC approaches: 1) Apache Camel, 2) /tmp files, 3) message queue
* however, STDOUT is the simplest approach for now.
*
* @param command The drush command to execute, ignoring drush binary and site alias.
* @param input Input stream, could be null.
* @return STDOUT results.
* @throws org.drupal.project.computing.exception.DSiteException
*/ | // Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DDrush.java
import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* This is the utility class to run drush command. You need to specify "dcomp.drush.command" (default "drush") and
* "dcomp.drush.site" (default "@self") to be able to access Drush. This class interact with Drupal Computing drush
* "computing-call" and "computing-eval" to execute any Drupal functions.
*/
public class DDrush {
private String drushCommand;
private String drushSiteAlias;
private Logger logger = DUtils.getInstance().getPackageLogger();
//private Boolean computingEnabled;
/**
* This is the only initialization code. Need to specify drush command and siteAlias.
*
* @param drushCommand drush executable command
* @param drushSiteAlias drush site alias
*/
public DDrush(String drushCommand, String drushSiteAlias) {
assert StringUtils.isNotBlank(drushCommand) && StringUtils.isNotBlank(drushSiteAlias);
// TODO: check "drush cc" and existence of computing module.
this.drushCommand = drushCommand;
this.drushSiteAlias = drushSiteAlias;
}
/**
* Create a DDrush object using settings from config.properties.
*
* @return the DDrush object.
*/
public static DDrush loadDefault() {
// might need to check validity.
DConfig config = DConfig.loadDefault();
return new DDrush(config.getDrushCommand(), config.getDrushSiteAlias());
}
/**
* Execute Drush command, and returns STDOUT results.
* attention: here we use shell stdout to output results, which is problematic.
*
* possible problems are:
* 1) security concerns, where confidential info might get printed
* 2) encoding/decoding characters to byte streams, especially with non-english languages and serializd strings.
* 3) escaping problems
* 4) output might get messed up with other sub-processes.
*
* some other IPC approaches: 1) Apache Camel, 2) /tmp files, 3) message queue
* however, STDOUT is the simplest approach for now.
*
* @param command The drush command to execute, ignoring drush binary and site alias.
* @param input Input stream, could be null.
* @return STDOUT results.
* @throws org.drupal.project.computing.exception.DSiteException
*/ | public String execute(String[] command, String input) throws DSiteException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DDrush.java | // Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
| import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger; | package org.drupal.project.computing;
/**
* This is the utility class to run drush command. You need to specify "dcomp.drush.command" (default "drush") and
* "dcomp.drush.site" (default "@self") to be able to access Drush. This class interact with Drupal Computing drush
* "computing-call" and "computing-eval" to execute any Drupal functions.
*/
public class DDrush {
private String drushCommand;
private String drushSiteAlias;
private Logger logger = DUtils.getInstance().getPackageLogger();
//private Boolean computingEnabled;
/**
* This is the only initialization code. Need to specify drush command and siteAlias.
*
* @param drushCommand drush executable command
* @param drushSiteAlias drush site alias
*/
public DDrush(String drushCommand, String drushSiteAlias) {
assert StringUtils.isNotBlank(drushCommand) && StringUtils.isNotBlank(drushSiteAlias);
// TODO: check "drush cc" and existence of computing module.
this.drushCommand = drushCommand;
this.drushSiteAlias = drushSiteAlias;
}
/**
* Create a DDrush object using settings from config.properties.
*
* @return the DDrush object.
*/
public static DDrush loadDefault() {
// might need to check validity.
DConfig config = DConfig.loadDefault();
return new DDrush(config.getDrushCommand(), config.getDrushSiteAlias());
}
/**
* Execute Drush command, and returns STDOUT results.
* attention: here we use shell stdout to output results, which is problematic.
*
* possible problems are:
* 1) security concerns, where confidential info might get printed
* 2) encoding/decoding characters to byte streams, especially with non-english languages and serializd strings.
* 3) escaping problems
* 4) output might get messed up with other sub-processes.
*
* some other IPC approaches: 1) Apache Camel, 2) /tmp files, 3) message queue
* however, STDOUT is the simplest approach for now.
*
* @param command The drush command to execute, ignoring drush binary and site alias.
* @param input Input stream, could be null.
* @return STDOUT results.
* @throws org.drupal.project.computing.exception.DSiteException
*/
public String execute(String[] command, String input) throws DSiteException {
try {
// initialize command line
CommandLine cmdLine = new CommandLine(drushCommand);
cmdLine.addArgument(drushSiteAlias);
//CommandLine cmdLine = CommandLine.parse(drushExec);
// 2nd parameter is crucial. without it, there would be escaping problems.
// false means we didn't escape the params and we want CommandLine to escape for us.
cmdLine.addArguments(command, false);
//System.out.println(cmdLine.toString());
return DUtils.getInstance().executeShell(cmdLine, input);
| // Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
// public DSiteException() {
// super();
// }
//
// public DSiteException(String s) {
// super(s);
// }
//
// public DSiteException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSiteException(Throwable throwable) {
// super(throwable);
// }
//
// /**
// * The error code is arbitrary by the caller which sets it.
// */
// private int errorCode = 0;
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public void setErrorCode(int errorCode) {
// this.errorCode = errorCode;
// }
//
// }
//
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
// public DSystemExecutionException() {
// }
//
// public DSystemExecutionException(String s) {
// super(s);
// }
//
// public DSystemExecutionException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DSystemExecutionException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: java/src/org/drupal/project/computing/DDrush.java
import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger;
package org.drupal.project.computing;
/**
* This is the utility class to run drush command. You need to specify "dcomp.drush.command" (default "drush") and
* "dcomp.drush.site" (default "@self") to be able to access Drush. This class interact with Drupal Computing drush
* "computing-call" and "computing-eval" to execute any Drupal functions.
*/
public class DDrush {
private String drushCommand;
private String drushSiteAlias;
private Logger logger = DUtils.getInstance().getPackageLogger();
//private Boolean computingEnabled;
/**
* This is the only initialization code. Need to specify drush command and siteAlias.
*
* @param drushCommand drush executable command
* @param drushSiteAlias drush site alias
*/
public DDrush(String drushCommand, String drushSiteAlias) {
assert StringUtils.isNotBlank(drushCommand) && StringUtils.isNotBlank(drushSiteAlias);
// TODO: check "drush cc" and existence of computing module.
this.drushCommand = drushCommand;
this.drushSiteAlias = drushSiteAlias;
}
/**
* Create a DDrush object using settings from config.properties.
*
* @return the DDrush object.
*/
public static DDrush loadDefault() {
// might need to check validity.
DConfig config = DConfig.loadDefault();
return new DDrush(config.getDrushCommand(), config.getDrushSiteAlias());
}
/**
* Execute Drush command, and returns STDOUT results.
* attention: here we use shell stdout to output results, which is problematic.
*
* possible problems are:
* 1) security concerns, where confidential info might get printed
* 2) encoding/decoding characters to byte streams, especially with non-english languages and serializd strings.
* 3) escaping problems
* 4) output might get messed up with other sub-processes.
*
* some other IPC approaches: 1) Apache Camel, 2) /tmp files, 3) message queue
* however, STDOUT is the simplest approach for now.
*
* @param command The drush command to execute, ignoring drush binary and site alias.
* @param input Input stream, could be null.
* @return STDOUT results.
* @throws org.drupal.project.computing.exception.DSiteException
*/
public String execute(String[] command, String input) throws DSiteException {
try {
// initialize command line
CommandLine cmdLine = new CommandLine(drushCommand);
cmdLine.addArgument(drushSiteAlias);
//CommandLine cmdLine = CommandLine.parse(drushExec);
// 2nd parameter is crucial. without it, there would be escaping problems.
// false means we didn't escape the params and we want CommandLine to escape for us.
cmdLine.addArguments(command, false);
//System.out.println(cmdLine.toString());
return DUtils.getInstance().executeShell(cmdLine, input);
| } catch (DSystemExecutionException e) { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DConfig.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
| import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.logging.Logger; | return properties.getProperty(propertyName);
}
// 2. Java system property (not assuming it's already in system properties)
Properties systemProperties = System.getProperties();
if (systemProperties.containsKey(propertyName)) {
return systemProperties.getProperty(propertyName);
}
// 3.Property set in system ENV: replace '.' with '_' and lower case to upper case.
String envPropertyName = propertyName.replaceAll("\\.", "_").toUpperCase();
String envValue = System.getenv(envPropertyName);
return envValue == null ? defaultValue : envValue;
}
public void setProperty(String propertyName, String value) {
assert StringUtils.isNotBlank(propertyName);
properties.setProperty(propertyName, value);
}
/**
* Try to read "dcomp.database.url" in config.properties or system env. Throws exception if can't find.
*
* @return The database url string that can be used directly in JDBC connections.
* @throws DConfigException
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/ | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
// Path: java/src/org/drupal/project/computing/DConfig.java
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.logging.Logger;
return properties.getProperty(propertyName);
}
// 2. Java system property (not assuming it's already in system properties)
Properties systemProperties = System.getProperties();
if (systemProperties.containsKey(propertyName)) {
return systemProperties.getProperty(propertyName);
}
// 3.Property set in system ENV: replace '.' with '_' and lower case to upper case.
String envPropertyName = propertyName.replaceAll("\\.", "_").toUpperCase();
String envValue = System.getenv(envPropertyName);
return envValue == null ? defaultValue : envValue;
}
public void setProperty(String propertyName, String value) {
assert StringUtils.isNotBlank(propertyName);
properties.setProperty(propertyName, value);
}
/**
* Try to read "dcomp.database.url" in config.properties or system env. Throws exception if can't find.
*
* @return The database url string that can be used directly in JDBC connections.
* @throws DConfigException
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/ | public String getDatabaseUrl() throws DConfigException { |
danithaca/drupal-computing | java/src/org/drupal/project/computing/DConfig.java | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
| import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.logging.Logger; |
/**
* Try to read "dcomp.database.url" in config.properties or system env. Throws exception if can't find.
*
* @return The database url string that can be used directly in JDBC connections.
* @throws DConfigException
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/
public String getDatabaseUrl() throws DConfigException {
String url = getProperty("dcomp.database.url", "");
if (StringUtils.isNotBlank(url)) {
return url;
} else {
throw new DConfigException("Cannot find 'dcomp.database.url' settings.");
}
}
/**
* Try to read "dcomp.database.properties.*" in config.properties.
* Requires to have "driver", "database", "username", "password" and "host" to be considered as valid.
* See more about db settings in Drupal settings.php.
* Extra parameters will be passed to database connection too.
*
* @return The database properties as defined in dcomp.database.properties.*. Or throws DNotFoundException.
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/ | // Path: java/src/org/drupal/project/computing/exception/DConfigException.java
// public class DConfigException extends Exception {
// public DConfigException() {
// }
//
// public DConfigException(String s) {
// super(s);
// }
//
// public DConfigException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public DConfigException(Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: java/src/org/drupal/project/computing/exception/DNotFoundException.java
// public class DNotFoundException extends Exception {
// public DNotFoundException() {}
//
// public DNotFoundException(String s) {
// super(s);
// }
// }
// Path: java/src/org/drupal/project/computing/DConfig.java
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DConfigException;
import org.drupal.project.computing.exception.DNotFoundException;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.logging.Logger;
/**
* Try to read "dcomp.database.url" in config.properties or system env. Throws exception if can't find.
*
* @return The database url string that can be used directly in JDBC connections.
* @throws DConfigException
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/
public String getDatabaseUrl() throws DConfigException {
String url = getProperty("dcomp.database.url", "");
if (StringUtils.isNotBlank(url)) {
return url;
} else {
throw new DConfigException("Cannot find 'dcomp.database.url' settings.");
}
}
/**
* Try to read "dcomp.database.properties.*" in config.properties.
* Requires to have "driver", "database", "username", "password" and "host" to be considered as valid.
* See more about db settings in Drupal settings.php.
* Extra parameters will be passed to database connection too.
*
* @return The database properties as defined in dcomp.database.properties.*. Or throws DNotFoundException.
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html">Simple MySQL example</a>
* @see <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html">MySQL connection properties</a>
*/ | public Properties getDatabaseProperties() throws DNotFoundException { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/exporter/ExcelOutputStreamExporter.java | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
| import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.reports.model.ConvertConfiguration; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Stream出力エクスポーター
*
* @since 1.1
*/
public class ExcelOutputStreamExporter extends ExcelExporter {
/**
* 変換タイプ:EXCEL
*/
public static final String FORMAT_TYPE = "OUTPUT_STREAM_EXCEL";
/**
* ログ
*/
private static Log log = LogFactory.getLog( ExcelOutputStreamExporter.class);
/**
* 出力ストリーム
*/
private OutputStream outputStream;
/**
* コンストラクタ
*
* @param outputStream 出力ストリーム
*/
public ExcelOutputStreamExporter( OutputStream outputStream) {
this.outputStream = outputStream;
}
@Override
public String getExtention() {
return "";
}
@Override
public String getFormatType() {
return FORMAT_TYPE;
}
@Override | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/exporter/ExcelOutputStreamExporter.java
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.reports.model.ConvertConfiguration;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Stream出力エクスポーター
*
* @since 1.1
*/
public class ExcelOutputStreamExporter extends ExcelExporter {
/**
* 変換タイプ:EXCEL
*/
public static final String FORMAT_TYPE = "OUTPUT_STREAM_EXCEL";
/**
* ログ
*/
private static Log log = LogFactory.getLog( ExcelOutputStreamExporter.class);
/**
* 出力ストリーム
*/
private OutputStream outputStream;
/**
* コンストラクタ
*
* @param outputStream 出力ストリーム
*/
public ExcelOutputStreamExporter( OutputStream outputStream) {
this.outputStream = outputStream;
}
@Override
public String getExtention() {
return "";
}
@Override
public String getFormatType() {
return FORMAT_TYPE;
}
@Override | public void output( Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/exporter/XLSMExporter.java | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
* @since 1.0
*/
public class XLSMExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSMExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLSM";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xlsm";
/*
* (non-Javadoc)
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData,
* org.poireports.model.ConvertConfiguration)
*/
@Override | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/exporter/XLSMExporter.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
* @since 1.0
*/
public class XLSMExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSMExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLSM";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xlsm";
/*
* (non-Javadoc)
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData,
* org.poireports.model.ConvertConfiguration)
*/
@Override | public void output( Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/listener/RemoveAdapter.java | // Path: src/main/java/org/bbreak/excella/reports/tag/RemoveParamParser.java
// public class RemoveParamParser extends ReportsTagParser<Object> {
//
// /**
// * デフォルトタグ
// */
// public static final String DEFAULT_TAG = "$REMOVE";
//
// /**
// * コンストラクタ
// */
// public RemoveParamParser() {
// super( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public RemoveParamParser( String tag) {
// super( tag);
// }
//
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // 解析結果の生成
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
//
// Path: src/main/java/org/bbreak/excella/reports/tag/ReportsTagParser.java
// public abstract class ReportsTagParser<T> extends TagParser<ParsedReportInfo> {
//
// /*
// * (non-Javadoc)
// *
// * @see org.bbreak.excella.core.tag.TagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public abstract ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException;
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public ReportsTagParser( String tag) {
// super( tag);
// }
//
// /**
// * タグを制御行として扱うか否かを取得する。
// *
// * @return true:制御行として削除/false:置換
// */
// public abstract boolean useControlRow();
//
// /**
// * パラメータ情報よりパラメータ名で格納されている値を取得する。
// *
// * @param paramInfo パラメータ情報
// * @param paramName パラメータ名
// * @return 置換する値
// */
// @SuppressWarnings( "unchecked")
// public T getParamData( ParamInfo paramInfo, String paramName) {
// if ( paramInfo == null || paramName == null) {
// return null;
// }
// return ( T) paramInfo.getParam( getTag(), paramName);
// }
//
// }
| import org.bbreak.excella.core.tag.TagParser;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.core.util.TagUtil;
import org.bbreak.excella.reports.tag.RemoveParamParser;
import org.bbreak.excella.reports.tag.ReportsTagParser;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.listener;
/**
* シート解析後にセル・列・行・制御行を削除するアダプタ
*
* @since 1.0
*/
public class RemoveAdapter extends ReportProcessAdaptor {
/**
* 行
*/
public static final String ROW = "row";
/**
* 列
*/
public static final String COLUMN = "column";
/**
* セル
*/
public static final String CELL = "cell";
/**
* 左方向にシフト(デフォルト)
*/
public static final String LEFT = "left";
/**
* 上方向にシフト
*/
public static final String UP = "up";
/*
* (non-Javadoc)
*
* @see org.bbreak.excella.reports.listener.ReportProcessAdaptor#postParse(org.apache.poi.ss.usermodel.Sheet, org.bbreak.excella.core.SheetParser, org.bbreak.excella.core.SheetData)
*/
@Override
public void postParse( Sheet sheet, SheetParser sheetParser, SheetData sheetData) throws ParseException {
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
for ( int rowIndex = firstRowNum; rowIndex <= lastRowNum; rowIndex++) {
Row row = sheet.getRow( rowIndex);
if ( row != null) {
int firstColNum = row.getFirstCellNum();
int lastColNum = row.getLastCellNum() - 1;
boolean isRowFlag = false;
for ( int colIndex = firstColNum; colIndex <= lastColNum; colIndex++) {
Cell cell = row.getCell( colIndex);
if ( cell != null) { | // Path: src/main/java/org/bbreak/excella/reports/tag/RemoveParamParser.java
// public class RemoveParamParser extends ReportsTagParser<Object> {
//
// /**
// * デフォルトタグ
// */
// public static final String DEFAULT_TAG = "$REMOVE";
//
// /**
// * コンストラクタ
// */
// public RemoveParamParser() {
// super( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public RemoveParamParser( String tag) {
// super( tag);
// }
//
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // 解析結果の生成
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
//
// Path: src/main/java/org/bbreak/excella/reports/tag/ReportsTagParser.java
// public abstract class ReportsTagParser<T> extends TagParser<ParsedReportInfo> {
//
// /*
// * (non-Javadoc)
// *
// * @see org.bbreak.excella.core.tag.TagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public abstract ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException;
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public ReportsTagParser( String tag) {
// super( tag);
// }
//
// /**
// * タグを制御行として扱うか否かを取得する。
// *
// * @return true:制御行として削除/false:置換
// */
// public abstract boolean useControlRow();
//
// /**
// * パラメータ情報よりパラメータ名で格納されている値を取得する。
// *
// * @param paramInfo パラメータ情報
// * @param paramName パラメータ名
// * @return 置換する値
// */
// @SuppressWarnings( "unchecked")
// public T getParamData( ParamInfo paramInfo, String paramName) {
// if ( paramInfo == null || paramName == null) {
// return null;
// }
// return ( T) paramInfo.getParam( getTag(), paramName);
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/listener/RemoveAdapter.java
import org.bbreak.excella.core.tag.TagParser;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.core.util.TagUtil;
import org.bbreak.excella.reports.tag.RemoveParamParser;
import org.bbreak.excella.reports.tag.ReportsTagParser;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.listener;
/**
* シート解析後にセル・列・行・制御行を削除するアダプタ
*
* @since 1.0
*/
public class RemoveAdapter extends ReportProcessAdaptor {
/**
* 行
*/
public static final String ROW = "row";
/**
* 列
*/
public static final String COLUMN = "column";
/**
* セル
*/
public static final String CELL = "cell";
/**
* 左方向にシフト(デフォルト)
*/
public static final String LEFT = "left";
/**
* 上方向にシフト
*/
public static final String UP = "up";
/*
* (non-Javadoc)
*
* @see org.bbreak.excella.reports.listener.ReportProcessAdaptor#postParse(org.apache.poi.ss.usermodel.Sheet, org.bbreak.excella.core.SheetParser, org.bbreak.excella.core.SheetData)
*/
@Override
public void postParse( Sheet sheet, SheetParser sheetParser, SheetData sheetData) throws ParseException {
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
for ( int rowIndex = firstRowNum; rowIndex <= lastRowNum; rowIndex++) {
Row row = sheet.getRow( rowIndex);
if ( row != null) {
int firstColNum = row.getFirstCellNum();
int lastColNum = row.getLastCellNum() - 1;
boolean isRowFlag = false;
for ( int colIndex = firstColNum; colIndex <= lastColNum; colIndex++) {
Cell cell = row.getCell( colIndex);
if ( cell != null) { | if ( cell.getCellType() == CellType.STRING && cell.getStringCellValue().contains( RemoveParamParser.DEFAULT_TAG)) { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/listener/RemoveAdapter.java | // Path: src/main/java/org/bbreak/excella/reports/tag/RemoveParamParser.java
// public class RemoveParamParser extends ReportsTagParser<Object> {
//
// /**
// * デフォルトタグ
// */
// public static final String DEFAULT_TAG = "$REMOVE";
//
// /**
// * コンストラクタ
// */
// public RemoveParamParser() {
// super( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public RemoveParamParser( String tag) {
// super( tag);
// }
//
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // 解析結果の生成
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
//
// Path: src/main/java/org/bbreak/excella/reports/tag/ReportsTagParser.java
// public abstract class ReportsTagParser<T> extends TagParser<ParsedReportInfo> {
//
// /*
// * (non-Javadoc)
// *
// * @see org.bbreak.excella.core.tag.TagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public abstract ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException;
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public ReportsTagParser( String tag) {
// super( tag);
// }
//
// /**
// * タグを制御行として扱うか否かを取得する。
// *
// * @return true:制御行として削除/false:置換
// */
// public abstract boolean useControlRow();
//
// /**
// * パラメータ情報よりパラメータ名で格納されている値を取得する。
// *
// * @param paramInfo パラメータ情報
// * @param paramName パラメータ名
// * @return 置換する値
// */
// @SuppressWarnings( "unchecked")
// public T getParamData( ParamInfo paramInfo, String paramName) {
// if ( paramInfo == null || paramName == null) {
// return null;
// }
// return ( T) paramInfo.getParam( getTag(), paramName);
// }
//
// }
| import org.bbreak.excella.core.tag.TagParser;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.core.util.TagUtil;
import org.bbreak.excella.reports.tag.RemoveParamParser;
import org.bbreak.excella.reports.tag.ReportsTagParser;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException; | continue;
}
}
if ( removeColNum != -1) {
if ( region.getFirstColumn() > removeColNum || removeColNum > region.getLastColumn()) {
continue;
}
}
// 引数の結合INDEXに該当する結合を解除する
sheet.removeMergedRegion( i);
return;
}
}
/**
* 制御行の有無を返す。
*
* @param sheet
* @param sheetParser
* @param row
* @return
*/
private boolean isControlRow( Sheet sheet, SheetParser sheetParser, Row row, Cell cell) {
List<TagParser<?>> parsers = sheetParser.getTagParsers();
for ( TagParser<?> parser : parsers) {
try {
if ( parser.isParse( sheet, cell)) { | // Path: src/main/java/org/bbreak/excella/reports/tag/RemoveParamParser.java
// public class RemoveParamParser extends ReportsTagParser<Object> {
//
// /**
// * デフォルトタグ
// */
// public static final String DEFAULT_TAG = "$REMOVE";
//
// /**
// * コンストラクタ
// */
// public RemoveParamParser() {
// super( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public RemoveParamParser( String tag) {
// super( tag);
// }
//
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // 解析結果の生成
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
//
// Path: src/main/java/org/bbreak/excella/reports/tag/ReportsTagParser.java
// public abstract class ReportsTagParser<T> extends TagParser<ParsedReportInfo> {
//
// /*
// * (non-Javadoc)
// *
// * @see org.bbreak.excella.core.tag.TagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public abstract ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException;
//
// /**
// * コンストラクタ
// *
// * @param tag タグ
// */
// public ReportsTagParser( String tag) {
// super( tag);
// }
//
// /**
// * タグを制御行として扱うか否かを取得する。
// *
// * @return true:制御行として削除/false:置換
// */
// public abstract boolean useControlRow();
//
// /**
// * パラメータ情報よりパラメータ名で格納されている値を取得する。
// *
// * @param paramInfo パラメータ情報
// * @param paramName パラメータ名
// * @return 置換する値
// */
// @SuppressWarnings( "unchecked")
// public T getParamData( ParamInfo paramInfo, String paramName) {
// if ( paramInfo == null || paramName == null) {
// return null;
// }
// return ( T) paramInfo.getParam( getTag(), paramName);
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/listener/RemoveAdapter.java
import org.bbreak.excella.core.tag.TagParser;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.core.util.TagUtil;
import org.bbreak.excella.reports.tag.RemoveParamParser;
import org.bbreak.excella.reports.tag.ReportsTagParser;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException;
continue;
}
}
if ( removeColNum != -1) {
if ( region.getFirstColumn() > removeColNum || removeColNum > region.getLastColumn()) {
continue;
}
}
// 引数の結合INDEXに該当する結合を解除する
sheet.removeMergedRegion( i);
return;
}
}
/**
* 制御行の有無を返す。
*
* @param sheet
* @param sheetParser
* @param row
* @return
*/
private boolean isControlRow( Sheet sheet, SheetParser sheetParser, Row row, Cell cell) {
List<TagParser<?>> parsers = sheetParser.getTagParsers();
for ( TagParser<?> parser : parsers) {
try {
if ( parser.isParse( sheet, cell)) { | if ( parser instanceof ReportsTagParser) { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/exporter/XLSXExporter.java | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class XLSXExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSXExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLSX";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xlsx";
/*
* (non-Javadoc)
*
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/exporter/XLSXExporter.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class XLSXExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSXExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLSX";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xlsx";
/*
* (non-Javadoc)
*
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | public void output( Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/listener/BreakAdapter.java | // Path: src/main/java/org/bbreak/excella/reports/tag/BreakParamParser.java
// public class BreakParamParser extends ReportsTagParser<Object> {
//
// /** デフォルトタグ */
// public static final String DEFAULT_TAG = "$BREAK";
//
// /**
// * コンストラクタ
// */
// public BreakParamParser() {
// this( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag
// */
// public BreakParamParser( String tag) {
// super( tag);
// }
//
// /**
// * @see org.bbreak.excella.reports.tag.ReportsTagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // このタグは何も出力しない
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// /**
// * @see org.bbreak.excella.reports.tag.ReportsTagParser#useControlRow()
// */
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
| import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.tag.BreakParamParser;
| /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.listener;
/**
* 改ページの挿入
*
* @author T.Maruyama
* @version 1.8
*/
public class BreakAdapter extends ReportProcessAdaptor {
/**
* @see org.bbreak.excella.reports.listener.ReportProcessAdaptor#postParse(org.apache.poi.ss.usermodel.Sheet, org.bbreak.excella.core.SheetParser, org.bbreak.excella.core.SheetData)
*/
@Override
public void postParse( Sheet sheet, SheetParser sheetParser, SheetData sheetData) throws ParseException {
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
for ( int rowIndex = firstRowNum; rowIndex <= lastRowNum; rowIndex++) {
Row row = sheet.getRow( rowIndex);
if ( row != null) {
parseRow( sheet, sheetParser, sheetData, row, rowIndex);
}
}
}
/**
* 行単位で解析し、必要なら改ページを挿入する
*/
protected void parseRow( Sheet sheet, SheetParser sheetParser, SheetData sheetData, Row row, int rowIndex) {
int firstColNum = row.getFirstCellNum();
int lastColNum = row.getLastCellNum() - 1;
for ( int colIndex = firstColNum; colIndex <= lastColNum; colIndex++) {
Cell cell = row.getCell( colIndex);
if ( cell != null) {
| // Path: src/main/java/org/bbreak/excella/reports/tag/BreakParamParser.java
// public class BreakParamParser extends ReportsTagParser<Object> {
//
// /** デフォルトタグ */
// public static final String DEFAULT_TAG = "$BREAK";
//
// /**
// * コンストラクタ
// */
// public BreakParamParser() {
// this( DEFAULT_TAG);
// }
//
// /**
// * コンストラクタ
// *
// * @param tag
// */
// public BreakParamParser( String tag) {
// super( tag);
// }
//
// /**
// * @see org.bbreak.excella.reports.tag.ReportsTagParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)
// */
// @Override
// public ParsedReportInfo parse( Sheet sheet, Cell tagCell, Object data) throws ParseException {
// // このタグは何も出力しない
// ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
// parsedReportInfo.setRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());
// parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());
// parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());
// return parsedReportInfo;
// }
//
// /**
// * @see org.bbreak.excella.reports.tag.ReportsTagParser#useControlRow()
// */
// @Override
// public boolean useControlRow() {
// return false;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/listener/BreakAdapter.java
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.bbreak.excella.core.SheetData;
import org.bbreak.excella.core.SheetParser;
import org.bbreak.excella.core.exception.ParseException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.tag.BreakParamParser;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.listener;
/**
* 改ページの挿入
*
* @author T.Maruyama
* @version 1.8
*/
public class BreakAdapter extends ReportProcessAdaptor {
/**
* @see org.bbreak.excella.reports.listener.ReportProcessAdaptor#postParse(org.apache.poi.ss.usermodel.Sheet, org.bbreak.excella.core.SheetParser, org.bbreak.excella.core.SheetData)
*/
@Override
public void postParse( Sheet sheet, SheetParser sheetParser, SheetData sheetData) throws ParseException {
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
for ( int rowIndex = firstRowNum; rowIndex <= lastRowNum; rowIndex++) {
Row row = sheet.getRow( rowIndex);
if ( row != null) {
parseRow( sheet, sheetParser, sheetData, row, rowIndex);
}
}
}
/**
* 行単位で解析し、必要なら改ページを挿入する
*/
protected void parseRow( Sheet sheet, SheetParser sheetParser, SheetData sheetData, Row row, int rowIndex) {
int firstColNum = row.getFirstCellNum();
int lastColNum = row.getLastCellNum() - 1;
for ( int colIndex = firstColNum; colIndex <= lastColNum; colIndex++) {
Cell cell = row.getCell( colIndex);
if ( cell != null) {
| if ( cell.getCellType() == CellType.STRING && cell.getStringCellValue().contains( BreakParamParser.DEFAULT_TAG)) {
|
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({ | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({ | TagTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class, | UtilTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class, | ExporterTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class, | ProcessorTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class, | ModelTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class,
ModelTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class,
ModelTestSuite.class, | ListenerTestSuite.class, |
excella-core/excella-reports | src/test/java/org/bbreak/excella/reports/AllTestSuite.java | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
| import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class,
ModelTestSuite.class,
ListenerTestSuite.class, | // Path: src/test/java/org/bbreak/excella/reports/exporter/ExporterTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ExcelExporterTest.class,
// ReportBookExporterTest.class,
// XLSExporterTest.class,
// XLSXExporterTest.class,
// ExcelOutputStreamExporterTest.class,
// })
// public class ExporterTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/listener/ListenerTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// RemoveAdapterTest.class,
// BreakAdapterTest.class
// })
// public class ListenerTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/model/ModelTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ParamInfoTest.class,
// ConvertConfigurationTest.class,
// ReportBookTest.class,
// ReportSheetTest.class,
// ParsedReportInfoTest.class
// })
// public class ModelTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/others/OthersTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// PrintSettingCopyTest.class,
// ImageDisplayTest.class
// })
// public class OthersTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/processor/ProcessorTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportProcessorTest.class,
// ReportCreateHelperTest.class,
// ReportsParserInfoTest.class
// })
// public class ProcessorTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/tag/TagTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// SingleParamParserTest.class,
// ImageParamParserTest.class,
// RowRepeatParamParserTest.class,
// ColRepeatParamParserTest.class,
// RemoveParamParserTest.class,
// SumParamParserTest.class,
// BlockColRepeatParamParserTest.class,
// BlockRowRepeatParamParserTest.class,
// BreakParamParserTest.class
// })
// public class TagTestSuite {
//
// }
//
// Path: src/test/java/org/bbreak/excella/reports/util/UtilTestSuite.java
// @RunWith(Suite.class)
// @SuiteClasses({
// ReportsUtilTest.class
// })
// public class UtilTestSuite {
//
// }
// Path: src/test/java/org/bbreak/excella/reports/AllTestSuite.java
import org.bbreak.excella.reports.exporter.ExporterTestSuite;
import org.bbreak.excella.reports.listener.ListenerTestSuite;
import org.bbreak.excella.reports.model.ModelTestSuite;
import org.bbreak.excella.reports.others.OthersTestSuite;
import org.bbreak.excella.reports.processor.ProcessorTestSuite;
import org.bbreak.excella.reports.tag.TagTestSuite;
import org.bbreak.excella.reports.util.UtilTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports;
/**
* 全テスト実行用テストスイート
*
* @since 1.0
*/
@RunWith(Suite.class)
@SuiteClasses({
TagTestSuite.class,
UtilTestSuite.class,
ExporterTestSuite.class,
ProcessorTestSuite.class,
ModelTestSuite.class,
ListenerTestSuite.class, | OthersTestSuite.class |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/exporter/ExcelExporter.java | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.reports.model.ConvertConfiguration; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class ExcelExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( ExcelExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "EXCEL";
/**
* 拡張子:〜2003
*/
public static final String EXTENTION_XLS = ".xls";
/**
* 拡張子:2007
*/
public static final String EXTENTION_XLSX = ".xlsx";
/**
* 拡張子:2007マクロ有効
*/
public static final String EXTENTION_XLSM = ".xlsm";
/**
* マクロ有効か否か
*/
private boolean macroAvailable;
/* (non-Javadoc)
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/exporter/ExcelExporter.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.reports.model.ConvertConfiguration;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class ExcelExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( ExcelExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "EXCEL";
/**
* 拡張子:〜2003
*/
public static final String EXTENTION_XLS = ".xls";
/**
* 拡張子:2007
*/
public static final String EXTENTION_XLSX = ".xlsx";
/**
* 拡張子:2007マクロ有効
*/
public static final String EXTENTION_XLSM = ".xlsm";
/**
* マクロ有効か否か
*/
private boolean macroAvailable;
/* (non-Javadoc)
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | public void output( Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { |
excella-core/excella-reports | src/main/java/org/bbreak/excella/reports/exporter/XLSExporter.java | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration; | /*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class XLSExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLS";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xls";
/*
* (non-Javadoc)
*
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | // Path: src/main/java/org/bbreak/excella/reports/model/ConvertConfiguration.java
// @SuppressWarnings("serial")
// public class ConvertConfiguration implements Serializable{
//
// /**
// * フォーマット
// */
// private String formatType = null;
//
// /**
// * 出力オプション
// */
// private Map<String, Object> options = new HashMap<String, Object>();
//
// /**
// * デフォルトコンストラクタ
// */
// public ConvertConfiguration(){
// }
//
// /**
// * コンストラクタ
// *
// * @param formatType フォーマット
// */
// public ConvertConfiguration( String formatType) {
// this.formatType = formatType;
// }
//
// /**
// * オプションを追加する。
// *
// * @param property プロパティ
// * @param value 値
// */
// public void addOption( String property, Object value) {
// options.put( property, value);
// }
//
// /**
// * オプションを追加する。
// *
// * @param options オプション
// */
// public void addOptions( Map<String, Object> options) {
// this.options.putAll( options);
// }
//
// /**
// * オプションを初期化する。
// */
// public void clearOptions() {
// options.clear();
// }
//
// /**
// * オプションを削除する。
// *
// * @param property プロパティ
// */
// public void removeOption( String property) {
// options.remove( property);
// }
//
// /**
// * オプションプロパティ一覧の取得する。
// *
// * @return プロパティ一覧
// */
// public Set<String> getOptionsProperties() {
// return options.keySet();
// }
//
// /**
// * オプション設定値を取得する。
// *
// * @param property プロパティ
// * @return オプション設定値
// */
// public Object getOptionValue( String property) {
// return options.get( property);
// }
//
// /**
// * オプションを取得する。
// *
// * @return オプション
// */
// public Map<String, Object> getOptions() {
// return new HashMap<String, Object>( options);
// }
//
// /**
// * フォーマットを取得します。
// *
// * @return フォーマット
// */
// public String getFormatType() {
// return formatType;
// }
//
// /**
// * フォーマットを設定します。
// *
// * @param formatType フォーマット
// */
// public void setFormatType( String formatType) {
// this.formatType = formatType;
// }
//
// }
// Path: src/main/java/org/bbreak/excella/reports/exporter/XLSExporter.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.bbreak.excella.core.BookData;
import org.bbreak.excella.core.exception.ExportException;
import org.bbreak.excella.core.util.PoiUtil;
import org.bbreak.excella.reports.model.ConvertConfiguration;
/*-
* #%L
* excella-reports
* %%
* Copyright (C) 2009 - 2019 bBreak Systems and contributors
* %%
* 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.
* #L%
*/
package org.bbreak.excella.reports.exporter;
/**
* Excel出力エクスポーター
*
* @since 1.0
*/
public class XLSExporter extends ReportBookExporter {
/**
* ログ
*/
private static Log log = LogFactory.getLog( XLSExporter.class);
/**
* 変換タイプ:エクセル
*/
public static final String FORMAT_TYPE = "XLS";
/**
* 拡張子:2007
*/
public static final String EXTENTION = ".xls";
/*
* (non-Javadoc)
*
* @see org.poireports.exporter.ReportBookExporter#output(org.apache.poi.ss.usermodel.Workbook, org.excelparser.BookData, org.poireports.model.ConvertConfiguration)
*/
@Override | public void output( Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/utils/NetworkUtils.java | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
| import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import org.houxg.leamonax.Leamonax;
import org.houxg.leamonax.R; | package org.houxg.leamonax.utils;
public class NetworkUtils {
private static NetworkInfo getActiveNetworkInfo(Context context) {
if (context == null) {
return null;
}
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return null;
}
// note that this may return null if no network is currently active
return cm.getActiveNetworkInfo();
}
public static boolean isNetworkAvailable() { | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/utils/NetworkUtils.java
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import org.houxg.leamonax.Leamonax;
import org.houxg.leamonax.R;
package org.houxg.leamonax.utils;
public class NetworkUtils {
private static NetworkInfo getActiveNetworkInfo(Context context) {
if (context == null) {
return null;
}
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return null;
}
// note that this may return null if no network is currently active
return cm.getActiveNetworkInfo();
}
public static boolean isNetworkAvailable() { | NetworkInfo info = getActiveNetworkInfo(Leamonax.getContext()); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/utils/SharedPreferenceUtils.java | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.houxg.leamonax.Leamonax; | package org.houxg.leamonax.utils;
public class SharedPreferenceUtils {
public static final String CONFIG = "CONFIG";
public static SharedPreferences getSharedPreferences(String name) { | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/utils/SharedPreferenceUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import org.houxg.leamonax.Leamonax;
package org.houxg.leamonax.utils;
public class SharedPreferenceUtils {
public static final String CONFIG = "CONFIG";
public static SharedPreferences getSharedPreferences(String name) { | return Leamonax.getContext().getSharedPreferences(name, Context.MODE_PRIVATE); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/utils/DisplayUtils.java | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
| import org.houxg.leamonax.Leamonax; | package org.houxg.leamonax.utils;
public class DisplayUtils {
public static int dp2px(float dp) { | // Path: app/src/main/java/org/houxg/leamonax/Leamonax.java
// public class Leamonax extends Application {
//
// private static Context mContext;
//
// public static Context getContext() {
// return mContext;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this;
// XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
// if (!TextUtils.isEmpty(BuildConfig.BUGLY_KEY)) {
// initBugly();
// }
// BigImageViewer.initialize(GlideImageLoader.with(this));
// EventBus.builder()
// .logNoSubscriberMessages(false)
// .sendNoSubscriberEvent(false)
// .throwSubscriberException(true)
// .installDefaultEventBus();
// FlowManager.init(new FlowConfig.Builder(this).build());
// JodaTimeAndroid.init(this);
// if (BuildConfig.DEBUG) {
// Stetho.initializeWithDefaults(this);
// }
// }
//
// private void initBugly() {
// Beta.canShowUpgradeActs.add(MainActivity.class);
// Beta.upgradeCheckPeriod = 60 * 1000; // 1 minute
//
// Resources res = getResources();
// Beta.strToastYourAreTheLatestVersion =res.getString(R.string.your_are_the_latest_version);
// Beta.strToastCheckUpgradeError =res.getString(R.string.check_upgrade_error);
// Beta.strToastCheckingUpgrade =res.getString(R.string.checking_upgrade);
// Beta.strNotificationDownloading =res.getString(R.string.downloading);
// Beta.strNotificationClickToView =res.getString(R.string.click_to_view);
// Beta.strNotificationClickToInstall =res.getString(R.string.click_to_install);
// Beta.strNotificationClickToRetry =res.getString(R.string.click_to_retry);
// Beta.strNotificationClickToContinue =res.getString(R.string.continue_download);
// Beta.strNotificationDownloadSucc =res.getString(R.string.download_successful);
// Beta.strNotificationDownloadError =res.getString(R.string.download_error);
// Beta.strNotificationHaveNewVersion =res.getString(R.string.have_new_version);
// Beta.strNetworkTipsMessage =res.getString(R.string.should_continue_download);
// Beta.strNetworkTipsTitle =res.getString(R.string.network_prompt);
// Beta.strNetworkTipsConfirmBtn =res.getString(R.string.continue_download);
// Beta.strNetworkTipsCancelBtn =res.getString(R.string.cancel);
// Beta.strUpgradeDialogVersionLabel =res.getString(R.string.version);
// Beta.strUpgradeDialogFileSizeLabel =res.getString(R.string.file_size);
// Beta.strUpgradeDialogUpdateTimeLabel =res.getString(R.string.update_time);
// Beta.strUpgradeDialogFeatureLabel =res.getString(R.string.what_s_new);
// Beta.strUpgradeDialogUpgradeBtn =res.getString(R.string.upgrade_now);
// Beta.strUpgradeDialogInstallBtn =res.getString(R.string.install);
// Beta.strUpgradeDialogRetryBtn =res.getString(R.string.retry);
// Beta.strUpgradeDialogContinueBtn =res.getString(R.string.continue_text);
// Beta.strUpgradeDialogCancelBtn =res.getString(R.string.next_time);
//
// Bugly.init(this, BuildConfig.BUGLY_KEY, BuildConfig.DEBUG);
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/utils/DisplayUtils.java
import org.houxg.leamonax.Leamonax;
package org.houxg.leamonax.utils;
public class DisplayUtils {
public static int dp2px(float dp) { | final float scale = Leamonax.getContext().getResources().getDisplayMetrics().density; |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/editor/JsRunner.java | // Path: app/src/main/java/org/houxg/leamonax/utils/StringUtils.java
// public class StringUtils {
// public static String notNullStr(String str) {
// return str == null ? "" : str;
// }
//
// public static void find(String content, String tagExp, String targetExp, Finder finder, Object... extraData) {
// Pattern tagPattern = Pattern.compile(tagExp);
// Pattern targetPattern = Pattern.compile(targetExp);
// Matcher tagMather = tagPattern.matcher(content);
// while (tagMather.find()) {
// String tag = tagMather.group();
// Matcher targetMatcher = targetPattern.matcher(tag);
// if (!targetMatcher.find()) {
// continue;
// }
// String original = targetMatcher.group();
// finder.onFound(original);
// }
// }
//
// public static String replace(String content, String tagExp, String targetExp, Replacer replacer, Object... extraData) {
// Pattern tagPattern = Pattern.compile(tagExp);
// Pattern targetPattern = Pattern.compile(targetExp);
// Matcher tagMather = tagPattern.matcher(content);
// StringBuilder contentBuilder = new StringBuilder(content);
// int offset = 0;
// while (tagMather.find()) {
// String tag = tagMather.group();
// Matcher targetMatcher = targetPattern.matcher(tag);
// if (!targetMatcher.find()) {
// continue;
// }
// String original = targetMatcher.group();
// int originalLen = original.length();
// String modified = replacer.replaceWith(original, extraData);
// contentBuilder.replace(tagMather.start() + targetMatcher.start() + offset,
// tagMather.end() - (tag.length() - targetMatcher.end()) + offset,
// modified);
// offset += modified.length() - originalLen;
// }
// return contentBuilder.toString();
// }
//
// public interface Finder {
// void onFound(String original, Object... extraData);
// }
//
// public interface Replacer {
// String replaceWith(String original, Object... extraData);
// }
// }
| import android.os.Looper;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import com.elvishew.xlog.XLog;
import org.houxg.leamonax.utils.StringUtils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; | package org.houxg.leamonax.editor;
public class JsRunner implements ValueCallback<String> {
private static final String TAG = "JsRunner:";
private String mResult;
private CountDownLatch mLatch;
public String get(final WebView webView, final String script) {
if (Looper.myLooper() == Looper.getMainLooper()) {
XLog.w(TAG + "Call from main thread");
}
mLatch = new CountDownLatch(1);
webView.post(new Runnable() {
@Override
public void run() {
webView.evaluateJavascript(script, JsRunner.this);
}
});
try {
mLatch.await(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
mResult = null;
} | // Path: app/src/main/java/org/houxg/leamonax/utils/StringUtils.java
// public class StringUtils {
// public static String notNullStr(String str) {
// return str == null ? "" : str;
// }
//
// public static void find(String content, String tagExp, String targetExp, Finder finder, Object... extraData) {
// Pattern tagPattern = Pattern.compile(tagExp);
// Pattern targetPattern = Pattern.compile(targetExp);
// Matcher tagMather = tagPattern.matcher(content);
// while (tagMather.find()) {
// String tag = tagMather.group();
// Matcher targetMatcher = targetPattern.matcher(tag);
// if (!targetMatcher.find()) {
// continue;
// }
// String original = targetMatcher.group();
// finder.onFound(original);
// }
// }
//
// public static String replace(String content, String tagExp, String targetExp, Replacer replacer, Object... extraData) {
// Pattern tagPattern = Pattern.compile(tagExp);
// Pattern targetPattern = Pattern.compile(targetExp);
// Matcher tagMather = tagPattern.matcher(content);
// StringBuilder contentBuilder = new StringBuilder(content);
// int offset = 0;
// while (tagMather.find()) {
// String tag = tagMather.group();
// Matcher targetMatcher = targetPattern.matcher(tag);
// if (!targetMatcher.find()) {
// continue;
// }
// String original = targetMatcher.group();
// int originalLen = original.length();
// String modified = replacer.replaceWith(original, extraData);
// contentBuilder.replace(tagMather.start() + targetMatcher.start() + offset,
// tagMather.end() - (tag.length() - targetMatcher.end()) + offset,
// modified);
// offset += modified.length() - originalLen;
// }
// return contentBuilder.toString();
// }
//
// public interface Finder {
// void onFound(String original, Object... extraData);
// }
//
// public interface Replacer {
// String replaceWith(String original, Object... extraData);
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/editor/JsRunner.java
import android.os.Looper;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import com.elvishew.xlog.XLog;
import org.houxg.leamonax.utils.StringUtils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
package org.houxg.leamonax.editor;
public class JsRunner implements ValueCallback<String> {
private static final String TAG = "JsRunner:";
private String mResult;
private CountDownLatch mLatch;
public String get(final WebView webView, final String script) {
if (Looper.myLooper() == Looper.getMainLooper()) {
XLog.w(TAG + "Call from main thread");
}
mLatch = new CountDownLatch(1);
webView.post(new Runnable() {
@Override
public void run() {
webView.evaluateJavascript(script, JsRunner.this);
}
});
try {
mLatch.await(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
mResult = null;
} | return StringUtils.notNullStr(mResult); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/network/api/AuthApi.java | // Path: app/src/main/java/org/houxg/leamonax/model/BaseResponse.java
// public class BaseResponse {
//
// @SerializedName("Ok")
// public boolean isOk;
// @SerializedName("Msg")
// public String msg;
//
// public boolean isOk() {
// return isOk;
// }
//
// public String getMsg() {
// return msg;
// }
//
// @Override
// public String toString() {
// return "BaseResponse{" +
// "isOk=" + isOk +
// ", msg='" + msg + '\'' +
// '}';
// }
// }
| import org.houxg.leamonax.model.Authentication;
import org.houxg.leamonax.model.BaseResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query; | package org.houxg.leamonax.network.api;
public interface AuthApi {
@GET("auth/login")
Call<Authentication> login(@Query("email") String email, @Query("pwd") String password);
@GET("auth/logout") | // Path: app/src/main/java/org/houxg/leamonax/model/BaseResponse.java
// public class BaseResponse {
//
// @SerializedName("Ok")
// public boolean isOk;
// @SerializedName("Msg")
// public String msg;
//
// public boolean isOk() {
// return isOk;
// }
//
// public String getMsg() {
// return msg;
// }
//
// @Override
// public String toString() {
// return "BaseResponse{" +
// "isOk=" + isOk +
// ", msg='" + msg + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/network/api/AuthApi.java
import org.houxg.leamonax.model.Authentication;
import org.houxg.leamonax.model.BaseResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
package org.houxg.leamonax.network.api;
public interface AuthApi {
@GET("auth/login")
Call<Authentication> login(@Query("email") String email, @Query("pwd") String password);
@GET("auth/logout") | Call<BaseResponse> logout(@Query("token") String token); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/model/User.java | // Path: app/src/main/java/org/houxg/leamonax/service/AccountService.java
// public class AccountService {
//
// public static Observable<BaseResponse> register(String email, String password) {
// return RetrofitUtils.create(ApiProvider.getInstance().getAuthApi().register(email, password));
// }
//
// public static Observable<Authentication> login(String email, String password) {
// return RetrofitUtils.create(ApiProvider.getInstance().getAuthApi().login(email, password));
// }
//
// public static Observable<User> getInfo(String userId) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().getInfo(userId));
// }
//
// public static long saveToAccount(Authentication authentication, String host) {
// Account localAccount = AppDataBase.getAccount(authentication.getEmail(), host);
// if (localAccount == null) {
// localAccount = new Account();
// }
// localAccount.setHost(host);
// localAccount.setEmail(authentication.getEmail());
// localAccount.setAccessToken(authentication.getAccessToken());
// localAccount.setUserId(authentication.getUserId());
// localAccount.setUserName(authentication.getUserName());
// localAccount.save();
// return localAccount.getLocalUserId();
// }
//
// public static void saveToAccount(User user, String host) {
// Account localAccount = AppDataBase.getAccount(user.getEmail(), host);
// if (localAccount == null) {
// localAccount = new Account();
// }
// localAccount.setHost(host);
// localAccount.setEmail(user.getEmail());
// localAccount.setUserId(user.getUserId());
// localAccount.setUserName(user.getUserName());
// localAccount.setAvatar(user.getAvatar());
// localAccount.setVerified(user.isVerified());
// localAccount.save();
// }
//
// public static void logout() {
// Account account = getCurrent();
// account.setAccessToken("");
// account.update();
// }
//
// public static Observable<BaseResponse> changePassword(String oldPassword, String newPassword) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().updatePassword(oldPassword, newPassword));
// }
//
// public static Observable<BaseResponse> changeUserName(String userName) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().updateUsername(userName));
// }
//
// public static Account getCurrent() {
// return AppDataBase.getAccountWithToken();
// }
//
// public static List<Account> getAccountList() {
// return AppDataBase.getAccountListWithToken();
// }
//
// public static Account getAccountById(long id) {
// return new Select()
// .from(Account.class)
// .where(Account_Table.id.eq(id))
// .querySingle();
// }
//
// public static boolean isSignedIn() {
// return getCurrent() != null;
// }
// }
| import com.google.gson.annotations.SerializedName;
import com.raizlabs.android.dbflow.annotation.Column;
import org.houxg.leamonax.service.AccountService; | package org.houxg.leamonax.model;
public class User extends BaseResponse {
@SerializedName("UserId")
String userId = "";
@SerializedName("Username")
String userName = "";
@Column(name = "email")
@SerializedName("Email")
String email = "";
@SerializedName("Verified")
boolean isVerified;
@SerializedName("Logo")
String avatar = "";
public String getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
public String getEmail() {
return email;
}
public boolean isVerified() {
return isVerified;
}
public String getAvatar() { | // Path: app/src/main/java/org/houxg/leamonax/service/AccountService.java
// public class AccountService {
//
// public static Observable<BaseResponse> register(String email, String password) {
// return RetrofitUtils.create(ApiProvider.getInstance().getAuthApi().register(email, password));
// }
//
// public static Observable<Authentication> login(String email, String password) {
// return RetrofitUtils.create(ApiProvider.getInstance().getAuthApi().login(email, password));
// }
//
// public static Observable<User> getInfo(String userId) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().getInfo(userId));
// }
//
// public static long saveToAccount(Authentication authentication, String host) {
// Account localAccount = AppDataBase.getAccount(authentication.getEmail(), host);
// if (localAccount == null) {
// localAccount = new Account();
// }
// localAccount.setHost(host);
// localAccount.setEmail(authentication.getEmail());
// localAccount.setAccessToken(authentication.getAccessToken());
// localAccount.setUserId(authentication.getUserId());
// localAccount.setUserName(authentication.getUserName());
// localAccount.save();
// return localAccount.getLocalUserId();
// }
//
// public static void saveToAccount(User user, String host) {
// Account localAccount = AppDataBase.getAccount(user.getEmail(), host);
// if (localAccount == null) {
// localAccount = new Account();
// }
// localAccount.setHost(host);
// localAccount.setEmail(user.getEmail());
// localAccount.setUserId(user.getUserId());
// localAccount.setUserName(user.getUserName());
// localAccount.setAvatar(user.getAvatar());
// localAccount.setVerified(user.isVerified());
// localAccount.save();
// }
//
// public static void logout() {
// Account account = getCurrent();
// account.setAccessToken("");
// account.update();
// }
//
// public static Observable<BaseResponse> changePassword(String oldPassword, String newPassword) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().updatePassword(oldPassword, newPassword));
// }
//
// public static Observable<BaseResponse> changeUserName(String userName) {
// return RetrofitUtils.create(ApiProvider.getInstance().getUserApi().updateUsername(userName));
// }
//
// public static Account getCurrent() {
// return AppDataBase.getAccountWithToken();
// }
//
// public static List<Account> getAccountList() {
// return AppDataBase.getAccountListWithToken();
// }
//
// public static Account getAccountById(long id) {
// return new Select()
// .from(Account.class)
// .where(Account_Table.id.eq(id))
// .querySingle();
// }
//
// public static boolean isSignedIn() {
// return getCurrent() != null;
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/model/User.java
import com.google.gson.annotations.SerializedName;
import com.raizlabs.android.dbflow.annotation.Column;
import org.houxg.leamonax.service.AccountService;
package org.houxg.leamonax.model;
public class User extends BaseResponse {
@SerializedName("UserId")
String userId = "";
@SerializedName("Username")
String userName = "";
@Column(name = "email")
@SerializedName("Email")
String email = "";
@SerializedName("Verified")
boolean isVerified;
@SerializedName("Logo")
String avatar = "";
public String getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
public String getEmail() {
return email;
}
public boolean isVerified() {
return isVerified;
}
public String getAvatar() { | Account current = AccountService.getCurrent(); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/editor/Editor.java | // Path: app/src/main/java/org/houxg/leamonax/service/NoteFileService.java
// public class NoteFileService {
//
// private static final String TAG = "NoteFileService:";
//
// private static final String SCHEME = "file";
// private static final String IMAGE_PATH = "getImage";
// private static final String IMAGE_PATH_WITH_SLASH = "/getImage";
//
// public static String convertFromLocalIdToServerId(String localId) {
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// return noteFile == null ? null : noteFile.getServerId();
// }
//
// public static Uri createImageFile(long noteLocalId, String filePath) {
// NoteFile noteFile = new NoteFile();
// noteFile.setNoteId(noteLocalId);
// noteFile.setLocalId(new ObjectId().toString());
// noteFile.setLocalPath(filePath);
// noteFile.setIsAttach(false);
// noteFile.save();
// return getLocalImageUri(noteFile.getLocalId());
// }
//
// public static Uri getLocalImageUri(String localId) {
// return new Uri.Builder().scheme(SCHEME).path(IMAGE_PATH).appendQueryParameter("id", localId).build();
// }
//
// public static Uri getServerImageUri(String serverId) {
// Uri uri = Uri.parse(AccountService.getCurrent().getHost());
// return uri.buildUpon().appendEncodedPath("api/file/getImage").appendQueryParameter("fileId", serverId).build();
// }
//
// public static boolean isLocalImageUri(Uri uri) {
// return SCHEME.equals(uri.getScheme()) && IMAGE_PATH_WITH_SLASH.equals(uri.getPath());
// }
//
// public static String getImagePath(Uri uri) {
// String localId = uri.getQueryParameter("id");
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// if (noteFile == null) {
// return null;
// }
// if (!TextUtils.isEmpty(noteFile.getLocalPath())) {
// File file = new File(noteFile.getLocalPath());
// return file.isFile() ? noteFile.getLocalPath() : null;
// } else {
// return null;
// }
// }
//
// public static List<NoteFile> getRelatedNoteFiles(long noteLocalId) {
// return AppDataBase.getAllRelatedFile(noteLocalId);
// }
//
// public static InputStream getImage(String localId) {
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// if (noteFile == null) {
// return null;
// }
// String filePath = null;
// if (isLocalFileExist(noteFile.getLocalPath())) {
// filePath = noteFile.getLocalPath();
// XLog.i(TAG + "use local image, path=" + filePath);
// } else {
// String url = NoteFileService.getUrl(AccountService.getCurrent().getHost(), noteFile.getServerId(), AccountService.getCurrent().getAccessToken());
// XLog.i(TAG + "use server image, url=" + url);
// try {
// filePath = NoteFileService.getImageFromServer(Uri.parse(url), Leamonax.getContext().getCacheDir());
// noteFile.setLocalPath(filePath);
// XLog.i(TAG + "download finished, path=" + filePath);
// noteFile.save();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// FileInputStream inputStream = null;
// try {
// if (!TextUtils.isEmpty(filePath)) {
// inputStream = new FileInputStream(filePath);
// }
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// return inputStream;
// }
//
// private static String getImageFromServer(Uri targetUri, File parentDir) throws IOException {
// URI target = URI.create(targetUri.toString());
// String fileName = String.format(Locale.US, "leanote-%s.png", new ObjectId().toString());
// File file = new File(parentDir, fileName);
// // XLog.i(TAG + "target=" + target.toString() + ", file=" + file.getAbsolutePath());
//
// InputStream input = target.toURL().openStream();
// BufferedSource source = Okio.buffer(Okio.source(input));
// Sink output = Okio.sink(file);
// source.readAll(output);
// source.close();
// output.flush();
// output.close();
// return file.getAbsolutePath();
// }
//
// private static String getUrl(String baseUrl, String serverId, String token) {
// return String.format(Locale.US, "%s/api/file/getImage?fileId=%s&token=%s", baseUrl, serverId, token);
// }
//
// private static boolean isLocalFileExist(String path) {
// if (!TextUtils.isEmpty(path)) {
// File file = new File(path);
// return file.isFile();
// }
// return false;
// }
// }
| import android.net.Uri;
import android.webkit.ConsoleMessage;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.elvishew.xlog.XLog;
import org.houxg.leamonax.service.NoteFileService;
import java.util.Map; | public abstract void toggleItalic();
public abstract void toggleQuote();
public abstract void toggleHeading();
public void removeLink() {}
public String getSelection() {
return "";
}
public interface EditorListener {
void onPageLoaded();
void onClickedLink(String title, String url);
void onStyleChanged(Format style, boolean enabled);
void onFormatChanged(Map<Format, Object> enabledFormats);
void onCursorChanged(Map<Format, Object> enabledFormats);
void linkTo(String url);
void onClickedImage(String url);
}
protected class EditorClient extends WebViewClient {
private static final String TAG = "WebViewClient:";
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
Uri uri = Uri.parse(url);
XLog.i(TAG + "shouldInterceptRequest(), request=" + url + ", scheme=" + uri.getScheme() + ", authority=" + uri.getAuthority()); | // Path: app/src/main/java/org/houxg/leamonax/service/NoteFileService.java
// public class NoteFileService {
//
// private static final String TAG = "NoteFileService:";
//
// private static final String SCHEME = "file";
// private static final String IMAGE_PATH = "getImage";
// private static final String IMAGE_PATH_WITH_SLASH = "/getImage";
//
// public static String convertFromLocalIdToServerId(String localId) {
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// return noteFile == null ? null : noteFile.getServerId();
// }
//
// public static Uri createImageFile(long noteLocalId, String filePath) {
// NoteFile noteFile = new NoteFile();
// noteFile.setNoteId(noteLocalId);
// noteFile.setLocalId(new ObjectId().toString());
// noteFile.setLocalPath(filePath);
// noteFile.setIsAttach(false);
// noteFile.save();
// return getLocalImageUri(noteFile.getLocalId());
// }
//
// public static Uri getLocalImageUri(String localId) {
// return new Uri.Builder().scheme(SCHEME).path(IMAGE_PATH).appendQueryParameter("id", localId).build();
// }
//
// public static Uri getServerImageUri(String serverId) {
// Uri uri = Uri.parse(AccountService.getCurrent().getHost());
// return uri.buildUpon().appendEncodedPath("api/file/getImage").appendQueryParameter("fileId", serverId).build();
// }
//
// public static boolean isLocalImageUri(Uri uri) {
// return SCHEME.equals(uri.getScheme()) && IMAGE_PATH_WITH_SLASH.equals(uri.getPath());
// }
//
// public static String getImagePath(Uri uri) {
// String localId = uri.getQueryParameter("id");
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// if (noteFile == null) {
// return null;
// }
// if (!TextUtils.isEmpty(noteFile.getLocalPath())) {
// File file = new File(noteFile.getLocalPath());
// return file.isFile() ? noteFile.getLocalPath() : null;
// } else {
// return null;
// }
// }
//
// public static List<NoteFile> getRelatedNoteFiles(long noteLocalId) {
// return AppDataBase.getAllRelatedFile(noteLocalId);
// }
//
// public static InputStream getImage(String localId) {
// NoteFile noteFile = AppDataBase.getNoteFileByLocalId(localId);
// if (noteFile == null) {
// return null;
// }
// String filePath = null;
// if (isLocalFileExist(noteFile.getLocalPath())) {
// filePath = noteFile.getLocalPath();
// XLog.i(TAG + "use local image, path=" + filePath);
// } else {
// String url = NoteFileService.getUrl(AccountService.getCurrent().getHost(), noteFile.getServerId(), AccountService.getCurrent().getAccessToken());
// XLog.i(TAG + "use server image, url=" + url);
// try {
// filePath = NoteFileService.getImageFromServer(Uri.parse(url), Leamonax.getContext().getCacheDir());
// noteFile.setLocalPath(filePath);
// XLog.i(TAG + "download finished, path=" + filePath);
// noteFile.save();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// FileInputStream inputStream = null;
// try {
// if (!TextUtils.isEmpty(filePath)) {
// inputStream = new FileInputStream(filePath);
// }
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// return inputStream;
// }
//
// private static String getImageFromServer(Uri targetUri, File parentDir) throws IOException {
// URI target = URI.create(targetUri.toString());
// String fileName = String.format(Locale.US, "leanote-%s.png", new ObjectId().toString());
// File file = new File(parentDir, fileName);
// // XLog.i(TAG + "target=" + target.toString() + ", file=" + file.getAbsolutePath());
//
// InputStream input = target.toURL().openStream();
// BufferedSource source = Okio.buffer(Okio.source(input));
// Sink output = Okio.sink(file);
// source.readAll(output);
// source.close();
// output.flush();
// output.close();
// return file.getAbsolutePath();
// }
//
// private static String getUrl(String baseUrl, String serverId, String token) {
// return String.format(Locale.US, "%s/api/file/getImage?fileId=%s&token=%s", baseUrl, serverId, token);
// }
//
// private static boolean isLocalFileExist(String path) {
// if (!TextUtils.isEmpty(path)) {
// File file = new File(path);
// return file.isFile();
// }
// return false;
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/editor/Editor.java
import android.net.Uri;
import android.webkit.ConsoleMessage;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.elvishew.xlog.XLog;
import org.houxg.leamonax.service.NoteFileService;
import java.util.Map;
public abstract void toggleItalic();
public abstract void toggleQuote();
public abstract void toggleHeading();
public void removeLink() {}
public String getSelection() {
return "";
}
public interface EditorListener {
void onPageLoaded();
void onClickedLink(String title, String url);
void onStyleChanged(Format style, boolean enabled);
void onFormatChanged(Map<Format, Object> enabledFormats);
void onCursorChanged(Map<Format, Object> enabledFormats);
void linkTo(String url);
void onClickedImage(String url);
}
protected class EditorClient extends WebViewClient {
private static final String TAG = "WebViewClient:";
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
Uri uri = Uri.parse(url);
XLog.i(TAG + "shouldInterceptRequest(), request=" + url + ", scheme=" + uri.getScheme() + ", authority=" + uri.getAuthority()); | if (NoteFileService.isLocalImageUri(uri)) { |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/network/api/NotebookApi.java | // Path: app/src/main/java/org/houxg/leamonax/model/Notebook.java
// @Table(name = "Notebook", database = AppDataBase.class)
// public class Notebook extends BaseModel {
//
// @SerializedName("Ok")
// boolean isOk = true;
// @SerializedName("Msg")
// String msg;
//
// @Column(name = "id")
// @PrimaryKey(autoincrement = true)
// long id;
// @Column(name = "notebookId")
// @SerializedName("NotebookId")
// String notebookId;
// @Column(name = "parentNotebookId")
// @SerializedName("ParentNotebookId")
// String parentNotebookId;
// @Column(name = "userId")
// @SerializedName("UserId")
// String userId;
// @Column(name = "title")
// @SerializedName("Title")
// String title;
// String urlTitle;
// @Column(name = "seq")
// @SerializedName("Seq")
// int seq;
// @SerializedName("IsBlog")
// boolean isBlog;
// @Column(name = "createdTime")
// @SerializedName("CreatedTime")
// String createTime;
// @Column(name = "updatedTime")
// @SerializedName("UpdatedTime")
// String updateTime;
// @Column(name = "isDirty")
// boolean isDirty;
// @Column(name = "isDeletedOnServer")
// @SerializedName("IsDeleted")
// boolean isDeleted;
// @Column(name = "isTrash")
// boolean isTrash;
// @Column(name = "usn")
// @SerializedName("Usn")
// int usn;
//
// public String getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(String createTime) {
// this.createTime = createTime;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public boolean isBlog() {
// return isBlog;
// }
//
// public void setIsBlog(boolean isBlog) {
// this.isBlog = isBlog;
// }
//
// public boolean isDeleted() {
// return isDeleted;
// }
//
// public void setIsDeleted(boolean isDeleted) {
// this.isDeleted = isDeleted;
// }
//
// public boolean isDirty() {
// return isDirty;
// }
//
// public void setIsDirty(boolean isDirty) {
// this.isDirty = isDirty;
// }
//
// public String getNotebookId() {
// return notebookId;
// }
//
// public void setNotebookId(String notebookId) {
// this.notebookId = notebookId;
// }
//
// public int getSeq() {
// return seq;
// }
//
// public void setSeq(int seq) {
// this.seq = seq;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(String updateTime) {
// this.updateTime = updateTime;
// }
//
// public String getUrlTitle() {
// return urlTitle;
// }
//
// public void setUrlTitle(String urlTitle) {
// this.urlTitle = urlTitle;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public int getUsn() {
// return usn;
// }
//
// public void setUsn(int usn) {
// this.usn = usn;
// }
//
// public String getParentNotebookId() {
// return parentNotebookId;
// }
//
// public void setParentNotebookId(String parentNotebookId) {
// this.parentNotebookId = parentNotebookId;
// }
//
// public boolean isTrash() {
// return isTrash;
// }
//
// public void setIsTrash(boolean isTrash) {
// this.isTrash = isTrash;
// }
//
//
// public boolean isOk() {
// return isOk;
// }
//
// public String getMsg() {
// return msg;
// }
// }
| import org.houxg.leamonax.model.Notebook;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query; | package org.houxg.leamonax.network.api;
public interface NotebookApi {
@GET("notebook/getSyncNotebooks") | // Path: app/src/main/java/org/houxg/leamonax/model/Notebook.java
// @Table(name = "Notebook", database = AppDataBase.class)
// public class Notebook extends BaseModel {
//
// @SerializedName("Ok")
// boolean isOk = true;
// @SerializedName("Msg")
// String msg;
//
// @Column(name = "id")
// @PrimaryKey(autoincrement = true)
// long id;
// @Column(name = "notebookId")
// @SerializedName("NotebookId")
// String notebookId;
// @Column(name = "parentNotebookId")
// @SerializedName("ParentNotebookId")
// String parentNotebookId;
// @Column(name = "userId")
// @SerializedName("UserId")
// String userId;
// @Column(name = "title")
// @SerializedName("Title")
// String title;
// String urlTitle;
// @Column(name = "seq")
// @SerializedName("Seq")
// int seq;
// @SerializedName("IsBlog")
// boolean isBlog;
// @Column(name = "createdTime")
// @SerializedName("CreatedTime")
// String createTime;
// @Column(name = "updatedTime")
// @SerializedName("UpdatedTime")
// String updateTime;
// @Column(name = "isDirty")
// boolean isDirty;
// @Column(name = "isDeletedOnServer")
// @SerializedName("IsDeleted")
// boolean isDeleted;
// @Column(name = "isTrash")
// boolean isTrash;
// @Column(name = "usn")
// @SerializedName("Usn")
// int usn;
//
// public String getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(String createTime) {
// this.createTime = createTime;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public boolean isBlog() {
// return isBlog;
// }
//
// public void setIsBlog(boolean isBlog) {
// this.isBlog = isBlog;
// }
//
// public boolean isDeleted() {
// return isDeleted;
// }
//
// public void setIsDeleted(boolean isDeleted) {
// this.isDeleted = isDeleted;
// }
//
// public boolean isDirty() {
// return isDirty;
// }
//
// public void setIsDirty(boolean isDirty) {
// this.isDirty = isDirty;
// }
//
// public String getNotebookId() {
// return notebookId;
// }
//
// public void setNotebookId(String notebookId) {
// this.notebookId = notebookId;
// }
//
// public int getSeq() {
// return seq;
// }
//
// public void setSeq(int seq) {
// this.seq = seq;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(String updateTime) {
// this.updateTime = updateTime;
// }
//
// public String getUrlTitle() {
// return urlTitle;
// }
//
// public void setUrlTitle(String urlTitle) {
// this.urlTitle = urlTitle;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public int getUsn() {
// return usn;
// }
//
// public void setUsn(int usn) {
// this.usn = usn;
// }
//
// public String getParentNotebookId() {
// return parentNotebookId;
// }
//
// public void setParentNotebookId(String parentNotebookId) {
// this.parentNotebookId = parentNotebookId;
// }
//
// public boolean isTrash() {
// return isTrash;
// }
//
// public void setIsTrash(boolean isTrash) {
// this.isTrash = isTrash;
// }
//
//
// public boolean isOk() {
// return isOk;
// }
//
// public String getMsg() {
// return msg;
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/network/api/NotebookApi.java
import org.houxg.leamonax.model.Notebook;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
package org.houxg.leamonax.network.api;
public interface NotebookApi {
@GET("notebook/getSyncNotebooks") | Call<List<Notebook>> getSyncNotebooks(@Query("afterUsn") int afterUsn, @Query("maxEntry") int maxEntry); |
houxg/Leamonax | app/src/main/java/org/houxg/leamonax/widget/RoundedRectBackgroundSpan.java | // Path: app/src/main/java/org/houxg/leamonax/utils/DisplayUtils.java
// public class DisplayUtils {
// public static int dp2px(float dp) {
// final float scale = Leamonax.getContext().getResources().getDisplayMetrics().density;
// return (int) (dp * scale + 0.5f);
// }
//
// public static int px2dp(float px) {
// final float scale = Leamonax.getContext().getResources().getDisplayMetrics().density;
// return (int) (px / scale + 0.5f);
// }
// }
| import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.style.ReplacementSpan;
import org.houxg.leamonax.utils.DisplayUtils; | package org.houxg.leamonax.widget;
public class RoundedRectBackgroundSpan extends ReplacementSpan {
private int mColor;
private float mRadius;
private int padding = 10;
private RectF mTempRect = new RectF();
public RoundedRectBackgroundSpan(int color, float radius) {
this(color, radius, 0);
}
public RoundedRectBackgroundSpan(int mColor, float mRadius, int padding) {
this.mColor = mColor;
this.mRadius = mRadius;
this.padding = padding;
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
return Math.round(paint.measureText(text, start, end) + padding * 2);
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
mTempRect.set(x, top, x + paint.measureText(text, start, end) + padding * 2, bottom); | // Path: app/src/main/java/org/houxg/leamonax/utils/DisplayUtils.java
// public class DisplayUtils {
// public static int dp2px(float dp) {
// final float scale = Leamonax.getContext().getResources().getDisplayMetrics().density;
// return (int) (dp * scale + 0.5f);
// }
//
// public static int px2dp(float px) {
// final float scale = Leamonax.getContext().getResources().getDisplayMetrics().density;
// return (int) (px / scale + 0.5f);
// }
// }
// Path: app/src/main/java/org/houxg/leamonax/widget/RoundedRectBackgroundSpan.java
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.style.ReplacementSpan;
import org.houxg.leamonax.utils.DisplayUtils;
package org.houxg.leamonax.widget;
public class RoundedRectBackgroundSpan extends ReplacementSpan {
private int mColor;
private float mRadius;
private int padding = 10;
private RectF mTempRect = new RectF();
public RoundedRectBackgroundSpan(int color, float radius) {
this(color, radius, 0);
}
public RoundedRectBackgroundSpan(int mColor, float mRadius, int padding) {
this.mColor = mColor;
this.mRadius = mRadius;
this.padding = padding;
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
return Math.round(paint.measureText(text, start, end) + padding * 2);
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
mTempRect.set(x, top, x + paint.measureText(text, start, end) + padding * 2, bottom); | float offsetY = DisplayUtils.dp2px(2); |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractCombinationIteratorTest.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// public static final <E> List<E> list(final E... elements) {
// FastList<E> list = new FastList<E>();
// for (E element : elements) {
// list.add(element);
// }
// return list;
// }
| import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import static com.xiantrimble.combinatorics.Utils.list; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
public abstract class AbstractCombinationIteratorTest {
private static Integer ONE = 1;
private static Integer TWO = 2;
private static Integer THREE = 3;
private static Integer FOUR = 4;
private static Integer FIVE = 5;
@SuppressWarnings("unchecked")
@Test
public void threeChoseTwo() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// public static final <E> List<E> list(final E... elements) {
// FastList<E> list = new FastList<E>();
// for (E element : elements) {
// list.add(element);
// }
// return list;
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractCombinationIteratorTest.java
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import static com.xiantrimble.combinatorics.Utils.list;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
public abstract class AbstractCombinationIteratorTest {
private static Integer ONE = 1;
private static Integer TWO = 2;
private static Integer THREE = 3;
private static Integer FOUR = 4;
private static Integer FIVE = 5;
@SuppressWarnings("unchecked")
@Test
public void threeChoseTwo() { | List<List<Integer>> actual = createCombinations(list(ONE, TWO, THREE), 2); |
ctrimble/combinatorics | combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandCount.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "count", commandDescription = "Counts the elements of the combination or permutation of length k")
public class CommandCount
implements Runnable
{
@Parameter(names="-k", description="The length of the elements", required=true)
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
// Path: combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandCount.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "count", commandDescription = "Counts the elements of the combination or permutation of length k")
public class CommandCount
implements Runnable
{
@Parameter(names="-k", description="The length of the elements", required=true)
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | CombinatoricFactory factory = new CombinatoricFactoryImpl(); |
ctrimble/combinatorics | combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandCount.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "count", commandDescription = "Counts the elements of the combination or permutation of length k")
public class CommandCount
implements Runnable
{
@Parameter(names="-k", description="The length of the elements", required=true)
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
// Path: combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandCount.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "count", commandDescription = "Counts the elements of the combination or permutation of length k")
public class CommandCount
implements Runnable
{
@Parameter(names="-k", description="The length of the elements", required=true)
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | CombinatoricFactory factory = new CombinatoricFactoryImpl(); |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/PermutationsIndexOfTest.java | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
| import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.*; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class PermutationsIndexOfTest
extends AbstractIndexOfTest
{ | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/PermutationsIndexOfTest.java
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.*;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class PermutationsIndexOfTest
extends AbstractIndexOfTest
{ | public PermutationsIndexOfTest( Combinatoric<Element> combinatoric ) { |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/LeadingElementPerportionTest.java | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/LeadingElementPerportionTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE
// }
| import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.math.util.MathUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.LeadingElementPerportionTest.Element.*; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
/**
* This test verifies that for permutations of length k, containing two unique elements and k
* total elements, the percentage of the time that any element is at any position is equal
* to the percentage of the domain it represents.
*
* This fact has implications for computing the size of a permutation, when you know
* the size of some permutation near it.
*
* Let kP be a permutation with a known k (kK), known multiplicity (kM[]), and known size (kS).
* Let p be a permutation that varies from kP by type removal of some element from kM[i], with a known k (k=kK-1),
* a known multiplicity (m[]), and an undetermined size (s).
*
* Then, this will be true:
* s = ( kM[i] / total(kM) ) * kS
*
*
* @author Christian Trimble
*
*/
@RunWith(Parameterized.class)
public class LeadingElementPerportionTest { | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/LeadingElementPerportionTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/LeadingElementPerportionTest.java
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.math.util.MathUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.LeadingElementPerportionTest.Element.*;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
/**
* This test verifies that for permutations of length k, containing two unique elements and k
* total elements, the percentage of the time that any element is at any position is equal
* to the percentage of the domain it represents.
*
* This fact has implications for computing the size of a permutation, when you know
* the size of some permutation near it.
*
* Let kP be a permutation with a known k (kK), known multiplicity (kM[]), and known size (kS).
* Let p be a permutation that varies from kP by type removal of some element from kM[i], with a known k (k=kK-1),
* a known multiplicity (m[]), and an undetermined size (s).
*
* Then, this will be true:
* s = ( kM[i] / total(kM) ) * kS
*
*
* @author Christian Trimble
*
*/
@RunWith(Parameterized.class)
public class LeadingElementPerportionTest { | public static enum Element { |
ctrimble/combinatorics | combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
// Path: combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | CombinatoricFactory factory = new CombinatoricFactoryImpl(); |
ctrimble/combinatorics | combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
// Path: combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() { | CombinatoricFactory factory = new CombinatoricFactoryImpl(); |
ctrimble/combinatorics | combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() {
CombinatoricFactory factory = new CombinatoricFactoryImpl(); | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Combinatoric.java
// public interface Combinatoric<T> extends List<T[]> {
// /**
// * The number of elements in each combination or permutation.
// *
// * @return the number of elements in each combination or permutation.
// */
// public int getK();
//
// /**
// * The elements that are combined or permuted by this combinatoric collection.
// *
// * @return the elements that are combined or permuted by this combinatoric collection.
// */
// public GroupedDomain<T> getDomain();
//
// /**
// * The size of this combinatoric collection, as a long.
// *
// * @return the size of this combinatoric collection, as a long.
// */
// public long longSize();
//
// /**
// * Returns the index of an element in this combinatoric collection.
// */
// public int indexOf( T[] element );
//
// /**
// * Returns the index of an element in this combinatoric collection, as a long.
// */
// public long longIndexOf( T[] element );
//
// /**
// * The iterator for this combinatoric collection.
// *
// * @return the iterator for this combinatoric collection.
// */
// public CombinatoricIterator<T> iterator();
//
// public T[] get(long index);
//
// public Combinatoric<T> subList( long fromIndex, long toIndex );
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactory.java
// public interface CombinatoricFactory {
// public <T> Combinatoric<T> createCombinations(int k, T... domain);
// public <T> CombinatoricEngine<T> createCombinationsEngine(int k, T... domain);
// public <T> Combinatoric<T> createPermutations(int k, T... domain);
// public <T> CombinatoricEngine<T> createPermutationsEngine(int k, T...domain );
// public <T> GroupedDomain<T> createGroupedDomain(T... domain);
// public <T> GroupedDomain<T> createGroupedDomain(int maxElementK, T... domain);
// public CombMathUtils getMathUtils();
// }
//
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/CombinatoricFactoryImpl.java
// public class CombinatoricFactoryImpl
// implements CombinatoricFactory
// {
// private CombMathUtils mathUtils = new CombMathUtilsImpl();
//
// public CombinatoricFactoryImpl() {
//
// }
//
// public CombinatoricFactoryImpl( CombMathUtils mathUtils ) {
// this.mathUtils = mathUtils;
// }
//
// @Override
// public <T> Combinations<T> createCombinations(int k, T... domain) {
// return new Combinations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutations<T> createPermutations(int k, T... domain) {
// return new IndexBasedPermutations<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> GroupedDomain<T> createGroupedDomain(T... domain) {
// return new FastGroupedDomain<T>(domain);
// }
//
// @Override
// public <T> FastGroupedDomain<T> createGroupedDomain(int maxElementK, T... domain) {
// return new FastGroupedDomain<T>(maxElementK, domain);
// }
//
// @Override
// public CombMathUtils getMathUtils() {
// return mathUtils;
// }
//
// @Override
// public <T> CombinationsEngine<T> createCombinationsEngine(int k, T... domain) {
// return new CombinationsEngine<T>(k, domain, getMathUtils());
// }
//
// @Override
// public <T> IndexBasedPermutationsEngine<T> createPermutationsEngine(int k, T... domain) {
// return new IndexBasedPermutationsEngine<T>(k, domain, getMathUtils());
// }
//
// }
// Path: combinatorics-cli/src/main/java/com/xiantrimble/combinatorics/cli/CommandGenerate.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.xiantrimble.combinatorics.Combinatoric;
import com.xiantrimble.combinatorics.CombinatoricFactory;
import com.xiantrimble.combinatorics.CombinatoricFactoryImpl;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics.cli;
@Parameters(commandNames = "generate", commandDescription = "Generates combinations or permutations of length k")
public class CommandGenerate
implements Runnable
{
@Parameter(names="-k", description="The length of the elements")
public int k;
@ParametersDelegate
public TypeDelegate type = new TypeDelegate();
@Parameter(names="-d", description="The domain", variableArity=true)
public List<String> domain;
@Override
public void run() {
CombinatoricFactory factory = new CombinatoricFactoryImpl(); | Combinatoric<String> combinatoric = null; |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractPermutationsIteratorTest.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// public static final <E> List<E> list(final E... elements) {
// FastList<E> list = new FastList<E>();
// for (E element : elements) {
// list.add(element);
// }
// return list;
// }
| import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static com.xiantrimble.combinatorics.Utils.list; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
public abstract class AbstractPermutationsIteratorTest
{
protected static Integer ONE = 1;
protected static Integer TWO = 2;
protected static Integer THREE = 3;
protected static Integer FOUR = 4;
protected static Integer FIVE = 5;
protected static Integer SIX = 6;
protected static Integer SEVEN = 7;
protected static Integer EIGHT = 8;
@SuppressWarnings("unchecked")
@Test
public void threePermThree() { | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// public static final <E> List<E> list(final E... elements) {
// FastList<E> list = new FastList<E>();
// for (E element : elements) {
// list.add(element);
// }
// return list;
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractPermutationsIteratorTest.java
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static com.xiantrimble.combinatorics.Utils.list;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
public abstract class AbstractPermutationsIteratorTest
{
protected static Integer ONE = 1;
protected static Integer TWO = 2;
protected static Integer THREE = 3;
protected static Integer FOUR = 4;
protected static Integer FIVE = 5;
protected static Integer SIX = 6;
protected static Integer SEVEN = 7;
protected static Integer EIGHT = 8;
@SuppressWarnings("unchecked")
@Test
public void threePermThree() { | List<List<Integer>> actual = createPermutations(list(ONE, TWO, THREE), 3); |
ctrimble/combinatorics | combinatorics/src/main/java/com/xiantrimble/combinatorics/AbstractCombinatoric.java | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// @SuppressWarnings("unchecked")
// public static final <T> Class<T> getComponentType(final T[] array) {
// return (Class<T>)array.getClass().getComponentType();
// }
| import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import static com.xiantrimble.combinatorics.Utils.getComponentType; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
/**
* An abstract base class for combinatoric implementations.
*
* @author Christian Trimble
*
* @param <T> the type of the elements being combined or permuted.
*/
public abstract class AbstractCombinatoric<T> extends AbstractList<T[]>
implements Combinatoric<T> {
/** The length of each result. */
protected int k;
/** The domain being operated on. */
protected GroupedDomain<T> domain;
/** A view of the domain as a 2-dimensional array for fast lookups. */
protected T[][] domainValues;
/** A view of the domain multiplicity. */
protected int[] domainMultiplicity;
/** The length of this collection. */
protected long size;
/** The math utilities used to compute the length. */
protected CombMathUtils mathUtils;
/** The component type for the arrays that will be returned. */
protected Class<T> componentType;
/**
* @param k the length of the results.
* @param domain the domain being operated on.
* @param mathUtils the math utilities class used to compute the size of this collection.
*/
protected AbstractCombinatoric(int k, T[] domain, CombMathUtils mathUtils) {
this.k = k;
this.domain = new FastGroupedDomain<T>(k, domain);
this.mathUtils = mathUtils;
this.size = computeSize(this.k, this.domain); | // Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/Utils.java
// @SuppressWarnings("unchecked")
// public static final <T> Class<T> getComponentType(final T[] array) {
// return (Class<T>)array.getClass().getComponentType();
// }
// Path: combinatorics/src/main/java/com/xiantrimble/combinatorics/AbstractCombinatoric.java
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import static com.xiantrimble.combinatorics.Utils.getComponentType;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
/**
* An abstract base class for combinatoric implementations.
*
* @author Christian Trimble
*
* @param <T> the type of the elements being combined or permuted.
*/
public abstract class AbstractCombinatoric<T> extends AbstractList<T[]>
implements Combinatoric<T> {
/** The length of each result. */
protected int k;
/** The domain being operated on. */
protected GroupedDomain<T> domain;
/** A view of the domain as a 2-dimensional array for fast lookups. */
protected T[][] domainValues;
/** A view of the domain multiplicity. */
protected int[] domainMultiplicity;
/** The length of this collection. */
protected long size;
/** The math utilities used to compute the length. */
protected CombMathUtils mathUtils;
/** The component type for the arrays that will be returned. */
protected Class<T> componentType;
/**
* @param k the length of the results.
* @param domain the domain being operated on.
* @param mathUtils the math utilities class used to compute the size of this collection.
*/
protected AbstractCombinatoric(int k, T[] domain, CombMathUtils mathUtils) {
this.k = k;
this.domain = new FastGroupedDomain<T>(k, domain);
this.mathUtils = mathUtils;
this.size = computeSize(this.k, this.domain); | this.componentType = getComponentType(domain); |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationIndexOfTest.java | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
| import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.FOUR;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.ONE;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.THREE;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.TWO;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.xiantrimble.combinatorics.AbstractIndexOfTest.Element; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class CombinationIndexOfTest
extends AbstractIndexOfTest
{ | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/AbstractIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationIndexOfTest.java
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.FOUR;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.ONE;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.THREE;
import static com.xiantrimble.combinatorics.AbstractIndexOfTest.Element.TWO;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.xiantrimble.combinatorics.AbstractIndexOfTest.Element;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class CombinationIndexOfTest
extends AbstractIndexOfTest
{ | public CombinationIndexOfTest( Combinatoric<Element> combinatoric ) { |
ctrimble/combinatorics | combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationsIndexOfTest.java | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationsIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
| import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.CombinationsIndexOfTest.Element.*; | /**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class CombinationsIndexOfTest { | // Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationsIndexOfTest.java
// public static enum Element {
// ONE,
// TWO,
// THREE,
// FOUR,
// FIVE
// }
// Path: combinatorics/src/test/java/com/xiantrimble/combinatorics/CombinationsIndexOfTest.java
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static com.xiantrimble.combinatorics.CombinationsIndexOfTest.Element.*;
/**
* Copyright (C) 2012 Christian Trimble (xiantrimble@gmail.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.xiantrimble.combinatorics;
@RunWith(Parameterized.class)
public class CombinationsIndexOfTest { | public static enum Element { |
cognitect/transit-ruby | ext/com/cognitect/transit/ruby/unmarshaler/RubyArrayReader.java | // Path: ext/com/cognitect/transit/ruby/TransitTypeConverter.java
// public class TransitTypeConverter {
// private static final List<String> specialString = Arrays.asList("NaN", "Infinity", "-Infinity");
//
// public static boolean needsCostomConverter(Object o) {
// if ((o instanceof String) && specialString.contains((String)o)) {
// return true;
// } else {
// return false;
// }
// }
//
// public static IRubyObject convertStringToFloat(Ruby runtime, Object o) {
// String str = (String)o;
// if ("NaN".equals(str)) {
// return runtime.newFloat(Double.NaN);
// } else if ("Infinity".equals(str)) {
// return runtime.newFloat(Double.POSITIVE_INFINITY);
// } else if ("-Infinity".equals(str)) {
// return runtime.newFloat(Double.NEGATIVE_INFINITY);
// } else {
// return runtime.getNil();
// }
// }
// }
| import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
import com.cognitect.transit.ArrayReader;
import com.cognitect.transit.ruby.TransitTypeConverter; | // Copyright 2014 Cognitect. All Rights Reserved.
//
// 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.cognitect.transit.ruby.unmarshaler;
public class RubyArrayReader implements ArrayReader<RubyArray, IRubyObject, Object> {
private Ruby runtime;
public RubyArrayReader(Ruby runtime) {
this.runtime = runtime;
}
@Override
public RubyArray add(RubyArray array, Object item) {
IRubyObject value; | // Path: ext/com/cognitect/transit/ruby/TransitTypeConverter.java
// public class TransitTypeConverter {
// private static final List<String> specialString = Arrays.asList("NaN", "Infinity", "-Infinity");
//
// public static boolean needsCostomConverter(Object o) {
// if ((o instanceof String) && specialString.contains((String)o)) {
// return true;
// } else {
// return false;
// }
// }
//
// public static IRubyObject convertStringToFloat(Ruby runtime, Object o) {
// String str = (String)o;
// if ("NaN".equals(str)) {
// return runtime.newFloat(Double.NaN);
// } else if ("Infinity".equals(str)) {
// return runtime.newFloat(Double.POSITIVE_INFINITY);
// } else if ("-Infinity".equals(str)) {
// return runtime.newFloat(Double.NEGATIVE_INFINITY);
// } else {
// return runtime.getNil();
// }
// }
// }
// Path: ext/com/cognitect/transit/ruby/unmarshaler/RubyArrayReader.java
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
import com.cognitect.transit.ArrayReader;
import com.cognitect.transit.ruby.TransitTypeConverter;
// Copyright 2014 Cognitect. All Rights Reserved.
//
// 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.cognitect.transit.ruby.unmarshaler;
public class RubyArrayReader implements ArrayReader<RubyArray, IRubyObject, Object> {
private Ruby runtime;
public RubyArrayReader(Ruby runtime) {
this.runtime = runtime;
}
@Override
public RubyArray add(RubyArray array, Object item) {
IRubyObject value; | if (TransitTypeConverter.needsCostomConverter(item)) { |
cognitect/transit-ruby | ext/com/cognitect/transit/ruby/unmarshaler/RubyMapReader.java | // Path: ext/com/cognitect/transit/ruby/TransitTypeConverter.java
// public class TransitTypeConverter {
// private static final List<String> specialString = Arrays.asList("NaN", "Infinity", "-Infinity");
//
// public static boolean needsCostomConverter(Object o) {
// if ((o instanceof String) && specialString.contains((String)o)) {
// return true;
// } else {
// return false;
// }
// }
//
// public static IRubyObject convertStringToFloat(Ruby runtime, Object o) {
// String str = (String)o;
// if ("NaN".equals(str)) {
// return runtime.newFloat(Double.NaN);
// } else if ("Infinity".equals(str)) {
// return runtime.newFloat(Double.POSITIVE_INFINITY);
// } else if ("-Infinity".equals(str)) {
// return runtime.newFloat(Double.NEGATIVE_INFINITY);
// } else {
// return runtime.getNil();
// }
// }
// }
| import org.jruby.Ruby;
import org.jruby.RubyHash;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
import com.cognitect.transit.MapReader;
import com.cognitect.transit.ruby.TransitTypeConverter; | // Copyright 2014 Cognitect. All Rights Reserved.
//
// 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.cognitect.transit.ruby.unmarshaler;
public class RubyMapReader implements MapReader<RubyHash, RubyHash, Object, Object> {
private Ruby runtime;
public RubyMapReader(Ruby runtime) {
this.runtime = runtime;
}
@Override
public RubyHash add(RubyHash hash, Object key, Object value) {
IRubyObject ruby_key = convertJavaToRuby(key);
IRubyObject ruby_value = convertJavaToRuby(value);
IRubyObject[] args = new IRubyObject[]{ruby_key, ruby_value};
hash.callMethod(runtime.getCurrentContext(), "[]=", args);
return hash;
}
private IRubyObject convertJavaToRuby(Object o) { | // Path: ext/com/cognitect/transit/ruby/TransitTypeConverter.java
// public class TransitTypeConverter {
// private static final List<String> specialString = Arrays.asList("NaN", "Infinity", "-Infinity");
//
// public static boolean needsCostomConverter(Object o) {
// if ((o instanceof String) && specialString.contains((String)o)) {
// return true;
// } else {
// return false;
// }
// }
//
// public static IRubyObject convertStringToFloat(Ruby runtime, Object o) {
// String str = (String)o;
// if ("NaN".equals(str)) {
// return runtime.newFloat(Double.NaN);
// } else if ("Infinity".equals(str)) {
// return runtime.newFloat(Double.POSITIVE_INFINITY);
// } else if ("-Infinity".equals(str)) {
// return runtime.newFloat(Double.NEGATIVE_INFINITY);
// } else {
// return runtime.getNil();
// }
// }
// }
// Path: ext/com/cognitect/transit/ruby/unmarshaler/RubyMapReader.java
import org.jruby.Ruby;
import org.jruby.RubyHash;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
import com.cognitect.transit.MapReader;
import com.cognitect.transit.ruby.TransitTypeConverter;
// Copyright 2014 Cognitect. All Rights Reserved.
//
// 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.cognitect.transit.ruby.unmarshaler;
public class RubyMapReader implements MapReader<RubyHash, RubyHash, Object, Object> {
private Ruby runtime;
public RubyMapReader(Ruby runtime) {
this.runtime = runtime;
}
@Override
public RubyHash add(RubyHash hash, Object key, Object value) {
IRubyObject ruby_key = convertJavaToRuby(key);
IRubyObject ruby_value = convertJavaToRuby(value);
IRubyObject[] args = new IRubyObject[]{ruby_key, ruby_value};
hash.callMethod(runtime.getCurrentContext(), "[]=", args);
return hash;
}
private IRubyObject convertJavaToRuby(Object o) { | if (TransitTypeConverter.needsCostomConverter(o)) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/PrefixExpression.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
/**
* Tagging class for a prefix expression.
* @author kuehn
*/
public class PrefixExpression extends PStarExpression {
static public Operator NOT = new Operator("!");
// static public Operator INCREMENT = new Operator("++");
// static public Operator DECREMENT = new Operator("--");
static public Operator MINUS = new Operator("-");
static public Operator PLUS = new Operator("+");
static public Operator COMPLEMENT = new Operator("~");
public PrefixExpression() {
super();
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/PrefixExpression.java
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
/**
* Tagging class for a prefix expression.
* @author kuehn
*/
public class PrefixExpression extends PStarExpression {
static public Operator NOT = new Operator("!");
// static public Operator INCREMENT = new Operator("++");
// static public Operator DECREMENT = new Operator("--");
static public Operator MINUS = new Operator("-");
static public Operator PLUS = new Operator("+");
static public Operator COMPLEMENT = new Operator("~");
public PrefixExpression() {
super();
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/BreakStatement.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
public class BreakStatement extends LabeledJump {
public BreakStatement(String theLabel) {
super(theLabel);
}
public BreakStatement(Block block) {
super(block);
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/BreakStatement.java
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
public class BreakStatement extends LabeledJump {
public BreakStatement(String theLabel) {
super(theLabel);
}
public BreakStatement(Block block) {
super(block);
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/assembly/Unit.java | // Path: src/main/java/com/j2js/Log.java
// public class Log {
//
// public static Log logger;
//
// public static Log getLogger() {
// return logger;
// }
//
// private int state = INFO;
//
// /**
// * @return Returns the state.
// */
// public int getState() {
// return state;
// }
//
// /**
// * @param state The state to set.
// */
// public void setState(int state) {
// this.state = state;
// }
//
// public static final int DEBUG = 3;
// public static final int INFO = 2;
// public static final int WARN = 1;
// public static final int ERROR = 0;
//
// public void debug(CharSequence arg0, Throwable arg1) {
// if (isDebugEnabled()) {
// System.out.println("[DEBUG] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void debug(CharSequence arg0) {
// if (isDebugEnabled()) {
// System.out.println("[DEBUG] " + arg0);
// }
// }
//
// public void debug(Throwable arg0) {
// if (isDebugEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public void error(CharSequence arg0, Throwable arg1) {
// if (isErrorEnabled()) {
// System.out.println("[ERROR] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void error(CharSequence arg0) {
// if (isErrorEnabled()) {
// System.out.println("[ERROR] " + arg0);
// }
// }
//
// public void error(Throwable arg0) {
// if (isErrorEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public void info(CharSequence arg0, Throwable arg1) {
// if (isInfoEnabled()) {
// System.out.println("[INFO] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void info(CharSequence arg0) {
// if (isInfoEnabled()) {
// System.out.println("[INFO] " + arg0);
// }
// }
//
// public void info(Throwable arg0) {
// if (isInfoEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public boolean isDebugEnabled() {
// return state >= DEBUG;
// }
//
// public boolean isErrorEnabled() {
// return state >= ERROR;
// }
//
// public boolean isInfoEnabled() {
// return state >= INFO;
// }
//
// public boolean isWarnEnabled() {
// return state >= WARN;
// }
//
// public void warn(CharSequence arg0, Throwable arg1) {
// if (isWarnEnabled()) {
// System.out.println("[WARNING] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void warn(CharSequence arg0) {
// if (isWarnEnabled()) {
// System.out.println("[WARNING] " + arg0);
// }
// }
//
// public void warn(Throwable arg0) {
// if (isWarnEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// }
| import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import com.j2js.Log; | for (int i=0; i<depth; i++) indent += '\t';
}
return indent;
}
public String toString() {
return signature.toString();
}
public Signature getSignature() {
return signature;
}
void setSignature(Signature theSignature) {
signature = theSignature;
}
public String getData() {
return data;
}
public void setData(String theData) {
data = theData;
}
public boolean isTainted() {
return isTainted;
}
public void setTainted() { | // Path: src/main/java/com/j2js/Log.java
// public class Log {
//
// public static Log logger;
//
// public static Log getLogger() {
// return logger;
// }
//
// private int state = INFO;
//
// /**
// * @return Returns the state.
// */
// public int getState() {
// return state;
// }
//
// /**
// * @param state The state to set.
// */
// public void setState(int state) {
// this.state = state;
// }
//
// public static final int DEBUG = 3;
// public static final int INFO = 2;
// public static final int WARN = 1;
// public static final int ERROR = 0;
//
// public void debug(CharSequence arg0, Throwable arg1) {
// if (isDebugEnabled()) {
// System.out.println("[DEBUG] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void debug(CharSequence arg0) {
// if (isDebugEnabled()) {
// System.out.println("[DEBUG] " + arg0);
// }
// }
//
// public void debug(Throwable arg0) {
// if (isDebugEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public void error(CharSequence arg0, Throwable arg1) {
// if (isErrorEnabled()) {
// System.out.println("[ERROR] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void error(CharSequence arg0) {
// if (isErrorEnabled()) {
// System.out.println("[ERROR] " + arg0);
// }
// }
//
// public void error(Throwable arg0) {
// if (isErrorEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public void info(CharSequence arg0, Throwable arg1) {
// if (isInfoEnabled()) {
// System.out.println("[INFO] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void info(CharSequence arg0) {
// if (isInfoEnabled()) {
// System.out.println("[INFO] " + arg0);
// }
// }
//
// public void info(Throwable arg0) {
// if (isInfoEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// public boolean isDebugEnabled() {
// return state >= DEBUG;
// }
//
// public boolean isErrorEnabled() {
// return state >= ERROR;
// }
//
// public boolean isInfoEnabled() {
// return state >= INFO;
// }
//
// public boolean isWarnEnabled() {
// return state >= WARN;
// }
//
// public void warn(CharSequence arg0, Throwable arg1) {
// if (isWarnEnabled()) {
// System.out.println("[WARNING] " + arg0);
// arg1.printStackTrace();
// }
// }
//
// public void warn(CharSequence arg0) {
// if (isWarnEnabled()) {
// System.out.println("[WARNING] " + arg0);
// }
// }
//
// public void warn(Throwable arg0) {
// if (isWarnEnabled()) {
// arg0.printStackTrace();
// }
// }
//
// }
// Path: src/main/java/com/j2js/assembly/Unit.java
import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import com.j2js.Log;
for (int i=0; i<depth; i++) indent += '\t';
}
return indent;
}
public String toString() {
return signature.toString();
}
public Signature getSignature() {
return signature;
}
void setSignature(Signature theSignature) {
signature = theSignature;
}
public String getData() {
return data;
}
public void setData(String theData) {
data = theData;
}
public boolean isTainted() {
return isTainted;
}
public void setTainted() { | if (!isTainted) Log.getLogger().debug("Taint " + this); |
decatur/j2js-compiler | src/main/java/com/j2js/dom/NumberLiteral.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor; | } else if (theValue instanceof Float) {
type = Type.FLOAT;
} else if (theValue instanceof Double) {
type = Type.DOUBLE;
} else if (theValue instanceof Long) {
type = Type.LONG;
} else if (theValue instanceof Short) {
type = Type.SHORT;
} else
// TODO: Other types
throw new RuntimeException("Type not supported: " + theValue.getClass());
}
public static NumberLiteral create(int i) {
Number value;
if (i == 0) value = ZERO;
else if (i == 1) value = ONE;
else value = new Integer(i);
return new NumberLiteral(value);
}
public static NumberLiteral create(Number value) {
if (value instanceof Integer) {
Integer i = (Integer) value;
if (i.intValue()==0) value = ZERO;
else if (i.intValue()==1) value = ONE;
}
return new NumberLiteral(value);
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/NumberLiteral.java
import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor;
} else if (theValue instanceof Float) {
type = Type.FLOAT;
} else if (theValue instanceof Double) {
type = Type.DOUBLE;
} else if (theValue instanceof Long) {
type = Type.LONG;
} else if (theValue instanceof Short) {
type = Type.SHORT;
} else
// TODO: Other types
throw new RuntimeException("Type not supported: " + theValue.getClass());
}
public static NumberLiteral create(int i) {
Number value;
if (i == 0) value = ZERO;
else if (i == 1) value = ONE;
else value = new Integer(i);
return new NumberLiteral(value);
}
public static NumberLiteral create(Number value) {
if (value instanceof Integer) {
Integer i = (Integer) value;
if (i.intValue()==0) value = ZERO;
else if (i.intValue()==1) value = ONE;
}
return new NumberLiteral(value);
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/SwitchCase.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import java.util.List;
import com.j2js.visitors.AbstractVisitor; | /*
* Created on Oct 24, 2004
*/
package com.j2js.dom;
/**
* @author wolfgang
*/
public class SwitchCase extends Block {
private List<NumberLiteral> expressions;
public SwitchCase(int theBeginIndex) {
super(theBeginIndex);
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/SwitchCase.java
import java.util.List;
import com.j2js.visitors.AbstractVisitor;
/*
* Created on Oct 24, 2004
*/
package com.j2js.dom;
/**
* @author wolfgang
*/
public class SwitchCase extends Block {
private List<NumberLiteral> expressions;
public SwitchCase(int theBeginIndex) {
super(theBeginIndex);
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/ASTNode.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import com.j2js.visitors.AbstractVisitor; | sb.append("]");
}
return sb.toString();
}
/**
* @return Returns the parent.
*/
public ASTNode getParentNode() {
return parent;
}
public Block getParentBlock() {
return (Block) parent;
}
public Block getLogicalParentBlock() {
if (parent != null && parent.parent instanceof IfStatement) {
return (Block) parent.parent;
}
return (Block) parent;
}
/**
* @param theParent The parent to set.
*/
public void setParentNode(ASTNode theParent) {
parent = theParent;
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/ASTNode.java
import com.j2js.visitors.AbstractVisitor;
sb.append("]");
}
return sb.toString();
}
/**
* @return Returns the parent.
*/
public ASTNode getParentNode() {
return parent;
}
public Block getParentBlock() {
return (Block) parent;
}
public Block getLogicalParentBlock() {
if (parent != null && parent.parent instanceof IfStatement) {
return (Block) parent.parent;
}
return (Block) parent;
}
/**
* @param theParent The parent to set.
*/
public void setParentNode(ASTNode theParent) {
parent = theParent;
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/VariableBinding.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
/**
* @author wolfgang
*/
public class VariableBinding extends Expression implements Assignable {
private boolean field;
private VariableDeclaration decl;
private boolean isTemporary = false;
public static boolean isBoolean(Expression expr) {
if (expr == null || !(expr instanceof VariableBinding)) return false;
if (((VariableBinding) expr).getVariableDeclaration().getType() != Type.BOOLEAN) return false;
return true;
}
public VariableBinding(VariableDeclaration theDecl) {
super();
decl = theDecl;
decl.vbs.add(this);
setTypeBinding(theDecl.getType());
}
public Object clone() {
// TODO: Make cloning explicit.
VariableBinding other = (VariableBinding) super.clone();
decl.vbs.add(other);
return other;
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/VariableBinding.java
import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
/**
* @author wolfgang
*/
public class VariableBinding extends Expression implements Assignable {
private boolean field;
private VariableDeclaration decl;
private boolean isTemporary = false;
public static boolean isBoolean(Expression expr) {
if (expr == null || !(expr instanceof VariableBinding)) return false;
if (((VariableBinding) expr).getVariableDeclaration().getType() != Type.BOOLEAN) return false;
return true;
}
public VariableBinding(VariableDeclaration theDecl) {
super();
decl = theDecl;
decl.vbs.add(this);
setTypeBinding(theDecl.getType());
}
public Object clone() {
// TODO: Make cloning explicit.
VariableBinding other = (VariableBinding) super.clone();
decl.vbs.add(other);
return other;
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/MethodBinding.java | // Path: src/main/java/com/j2js/Utils.java
// public final class Utils {
//
// private static final String propertiesFile = "j2js.properties";
// private static final Properties properties;
//
// static {
// properties = new Properties();
// try {
// properties.load(Utils.class.getClassLoader().getResourceAsStream(propertiesFile));
// } catch (Exception e) {
// J2JSCompiler.errorCount++;
// Log.getLogger().error("Could not read from classpath: " + propertiesFile);
// throw new RuntimeException(e);
// }
// }
//
// private Utils() {}
//
// public static String generateExceptionMessage(MethodDeclaration methodDecl, ASTNode node) {
// String msg = null;
// if (node != null) {
// int line = methodDecl.getLineNumberCursor().getLineNumber(node);
// if (line != -1) {
// msg = "Error near line " + line;
// }
// }
// if (msg == null) {
// msg = "Error";
// }
//
// msg += " in " + methodDecl.getMethodBinding();
//
// return msg;
// }
//
// public static RuntimeException generateException(Throwable e, MethodDeclaration methodDecl, ASTNode node) {
// String msg = generateExceptionMessage(methodDecl, node);
// J2JSCompiler.errorCount++;
// Log.getLogger().error(msg);
// return new RuntimeException(msg, e);
// }
//
// public static String stackTraceToString(Throwable e) {
// StringWriter sw = new StringWriter();
// PrintWriter writer = new PrintWriter(sw);
// e.printStackTrace(writer);
// writer.close();
// return sw.getBuffer().toString();
// }
//
// public static String currentTimeStamp() {
// return DateFormat.getDateTimeInstance().format(new Date());
// }
//
// public static String getVersion() {
// return (String) properties.get("j2js.version");
// }
//
// public static String getProperty(String key) {
// return (String) properties.get(key);
// }
//
// public static String getSignature(Type type) {
// String signature;
//
// if (type instanceof ArrayType) {
// ArrayType aType = (ArrayType) type;
// signature = getSignature(aType.getBasicType());
// for (int i = 0; i<aType.getDimensions(); i++) {
// signature += "[]";
// }
// } else if (type instanceof ObjectType) {
// signature = ((ObjectType) type).getClassName();
// } else {
// if (!(type instanceof BasicType)) throw new RuntimeException();
// signature = type.toString();
// }
//
// return signature;
// }
//
// public static String escape(String str) {
// int len = str.length();
// StringBuffer buf = new StringBuffer(len + 5);
// char[] ch = str.toCharArray();
//
// for (int i = 0; i < len; i++) {
// switch (ch[i]) {
// case '\\' :
// buf.append("\\\\");
// break;
// case '\n' :
// buf.append("\\n");
// break;
// case '\r' :
// buf.append("\\r");
// break;
// case '\t' :
// buf.append("\\t");
// break;
// case '\b' :
// buf.append("\\b");
// break;
// case '"' :
// buf.append("\\\"");
// break;
// default :
// buf.append(ch[i]);
// }
// }
//
// return '"' + buf.toString() + '"';
// }
//
//
//
// // public static File[] resolvePackage(File[] classPath, String signature) {
// // File dir = resolve(classPath, signature.replaceAll("\\.", "/"));
// // if (!dir.isDirectory()) {
// // throw new RuntimeException("Package " + signature + " could not be resolved");
// // }
// // return dir.listFiles();
// // }
//
// /**
// * If path is absolute, returns the file with the given path. Otherwise returns
// * the file with path resolved against baseDir.
// */
// public static File resolve(File baseDir, String path) {
// File resolvedFile = new File(path);
// if (!resolvedFile.isAbsolute()) {
// resolvedFile = new File(baseDir, path);
// }
// return resolvedFile;
// }
//
// }
| import java.util.HashMap;
import java.util.Map;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.ConstantCP;
import org.apache.bcel.classfile.ConstantNameAndType;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.Type;
import com.j2js.Utils; | return parameterTypes;
}
/**
* Returns the binding for the return type of this method.
*/
public Type getReturnType() {
return returnType;
}
/**
* Returns whether this binding is for a constructor or a method.
*/
public boolean isConstructor() {
return "<init>".equals(name);
}
public String getSignature() {
return signature;
}
public String toString() {
return getDeclaringClass().getClassName() + "#" + getRelativeSignature();
}
public String getRelativeSignature() {
String signature = getName() + "(";
String sep = "";
for (int i = 0; i < getParameterTypes().length; i++) {
Type type = getParameterTypes()[i]; | // Path: src/main/java/com/j2js/Utils.java
// public final class Utils {
//
// private static final String propertiesFile = "j2js.properties";
// private static final Properties properties;
//
// static {
// properties = new Properties();
// try {
// properties.load(Utils.class.getClassLoader().getResourceAsStream(propertiesFile));
// } catch (Exception e) {
// J2JSCompiler.errorCount++;
// Log.getLogger().error("Could not read from classpath: " + propertiesFile);
// throw new RuntimeException(e);
// }
// }
//
// private Utils() {}
//
// public static String generateExceptionMessage(MethodDeclaration methodDecl, ASTNode node) {
// String msg = null;
// if (node != null) {
// int line = methodDecl.getLineNumberCursor().getLineNumber(node);
// if (line != -1) {
// msg = "Error near line " + line;
// }
// }
// if (msg == null) {
// msg = "Error";
// }
//
// msg += " in " + methodDecl.getMethodBinding();
//
// return msg;
// }
//
// public static RuntimeException generateException(Throwable e, MethodDeclaration methodDecl, ASTNode node) {
// String msg = generateExceptionMessage(methodDecl, node);
// J2JSCompiler.errorCount++;
// Log.getLogger().error(msg);
// return new RuntimeException(msg, e);
// }
//
// public static String stackTraceToString(Throwable e) {
// StringWriter sw = new StringWriter();
// PrintWriter writer = new PrintWriter(sw);
// e.printStackTrace(writer);
// writer.close();
// return sw.getBuffer().toString();
// }
//
// public static String currentTimeStamp() {
// return DateFormat.getDateTimeInstance().format(new Date());
// }
//
// public static String getVersion() {
// return (String) properties.get("j2js.version");
// }
//
// public static String getProperty(String key) {
// return (String) properties.get(key);
// }
//
// public static String getSignature(Type type) {
// String signature;
//
// if (type instanceof ArrayType) {
// ArrayType aType = (ArrayType) type;
// signature = getSignature(aType.getBasicType());
// for (int i = 0; i<aType.getDimensions(); i++) {
// signature += "[]";
// }
// } else if (type instanceof ObjectType) {
// signature = ((ObjectType) type).getClassName();
// } else {
// if (!(type instanceof BasicType)) throw new RuntimeException();
// signature = type.toString();
// }
//
// return signature;
// }
//
// public static String escape(String str) {
// int len = str.length();
// StringBuffer buf = new StringBuffer(len + 5);
// char[] ch = str.toCharArray();
//
// for (int i = 0; i < len; i++) {
// switch (ch[i]) {
// case '\\' :
// buf.append("\\\\");
// break;
// case '\n' :
// buf.append("\\n");
// break;
// case '\r' :
// buf.append("\\r");
// break;
// case '\t' :
// buf.append("\\t");
// break;
// case '\b' :
// buf.append("\\b");
// break;
// case '"' :
// buf.append("\\\"");
// break;
// default :
// buf.append(ch[i]);
// }
// }
//
// return '"' + buf.toString() + '"';
// }
//
//
//
// // public static File[] resolvePackage(File[] classPath, String signature) {
// // File dir = resolve(classPath, signature.replaceAll("\\.", "/"));
// // if (!dir.isDirectory()) {
// // throw new RuntimeException("Package " + signature + " could not be resolved");
// // }
// // return dir.listFiles();
// // }
//
// /**
// * If path is absolute, returns the file with the given path. Otherwise returns
// * the file with path resolved against baseDir.
// */
// public static File resolve(File baseDir, String path) {
// File resolvedFile = new File(path);
// if (!resolvedFile.isAbsolute()) {
// resolvedFile = new File(baseDir, path);
// }
// return resolvedFile;
// }
//
// }
// Path: src/main/java/com/j2js/dom/MethodBinding.java
import java.util.HashMap;
import java.util.Map;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.ConstantCP;
import org.apache.bcel.classfile.ConstantNameAndType;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.Type;
import com.j2js.Utils;
return parameterTypes;
}
/**
* Returns the binding for the return type of this method.
*/
public Type getReturnType() {
return returnType;
}
/**
* Returns whether this binding is for a constructor or a method.
*/
public boolean isConstructor() {
return "<init>".equals(name);
}
public String getSignature() {
return signature;
}
public String toString() {
return getDeclaringClass().getClassName() + "#" + getRelativeSignature();
}
public String getRelativeSignature() {
String signature = getName() + "(";
String sep = "";
for (int i = 0; i < getParameterTypes().length; i++) {
Type type = getParameterTypes()[i]; | signature += sep + Utils.getSignature(type); |
decatur/j2js-compiler | src/main/java/com/j2js/dom/WhileStatement.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
/*
* WhileStatement.java
*
* Created on 21. Mai 2004, 17:30
*/
/**
*
* @author kuehn
*/
public class WhileStatement extends LoopStatement {
public WhileStatement() {
super();
}
public WhileStatement(int theBeginIndex) {
super(theBeginIndex);
}
/** Creates a new instance of WhileStatement */
public WhileStatement(int theBeginIndex, int theEndIndex) {
super(theBeginIndex, theEndIndex);
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/WhileStatement.java
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
/*
* WhileStatement.java
*
* Created on 21. Mai 2004, 17:30
*/
/**
*
* @author kuehn
*/
public class WhileStatement extends LoopStatement {
public WhileStatement() {
super();
}
public WhileStatement(int theBeginIndex) {
super(theBeginIndex);
}
/** Creates a new instance of WhileStatement */
public WhileStatement(int theBeginIndex, int theEndIndex) {
super(theBeginIndex, theEndIndex);
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/ThisExpression.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
/**
* @author kuehn
*/
public class ThisExpression extends VariableBinding {
private static VariableDeclaration vd;
static {
vd = new VariableDeclaration(VariableDeclaration.NON_LOCAL);
vd.setName("this");
vd.setType(Type.OBJECT);
}
public ThisExpression() {
super(vd);
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/ThisExpression.java
import org.apache.bcel.generic.Type;
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
/**
* @author kuehn
*/
public class ThisExpression extends VariableBinding {
private static VariableDeclaration vd;
static {
vd = new VariableDeclaration(VariableDeclaration.NON_LOCAL);
vd.setName("this");
vd.setType(Type.OBJECT);
}
public ThisExpression() {
super(vd);
}
| public void visit(AbstractVisitor visitor) { |
decatur/j2js-compiler | src/main/java/com/j2js/dom/PostfixExpression.java | // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
| import com.j2js.visitors.AbstractVisitor; | package com.j2js.dom;
/**
* Tagging class for a postfix expression.
* @author kuehn
*/
public class PostfixExpression extends PStarExpression {
public PostfixExpression() {
super();
}
| // Path: src/main/java/com/j2js/visitors/AbstractVisitor.java
// public abstract class AbstractVisitor {
//
//
// public abstract void visit(ASTNode node);
//
// public void visit(TypeDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(DoStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(WhileStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(IfStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(TryStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Block node) {
// visit((ASTNode) node);
// }
//
// public void visit(InfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrefixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(PostfixExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(SwitchCase node) {
// visit((ASTNode) node);
// }
//
// public void visit(CatchClause node) {
// visit((ASTNode) node);
// }
//
// public void visit(ReturnStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Assignment node) {
// visit((ASTNode) node);
// }
//
// public void visit(NumberLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(StringLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(NullLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(MethodInvocation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ClassInstanceCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayInitializer node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayCreation node) {
// visit((ASTNode) node);
// }
//
// public void visit(ArrayAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableDeclaration node) {
// visit((ASTNode) node);
// }
//
// public void visit(VariableBinding node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThisExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(FieldAccess node) {
// visit((ASTNode) node);
// }
//
// public void visit(BreakStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(ContinueStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(CastExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(BooleanLiteral node) {
// visit((ASTNode) node);
// }
//
// public void visit(ThrowStatement node) {
// visit((ASTNode) node);
// }
//
// public void visit(Name node) {
// visit((ASTNode) node);
// }
//
// public void visit(InstanceofExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(ConditionalExpression node) {
// visit((ASTNode) node);
// }
//
// public void visit(SynchronizedBlock node) {
// visit((ASTNode) node);
// }
//
// public void visit(PrimitiveCast node) {
// visit((ASTNode) node);
// }
//
// }
// Path: src/main/java/com/j2js/dom/PostfixExpression.java
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom;
/**
* Tagging class for a postfix expression.
* @author kuehn
*/
public class PostfixExpression extends PStarExpression {
public PostfixExpression() {
super();
}
| public void visit(AbstractVisitor visitor) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.