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
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginComponent.java // @Subcomponent(modules = LoginModule.class) // public interface LoginComponent { // LoginActivity inject(LoginActivity loginActivity); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java // @Module // public class LoginModule { // private final LoginView loginView; // // public LoginModule(LoginView loginView) { // this.loginView = loginView; // } // // @Provides // LoginView provideLoginView() { // return loginView; // } // // // @Provides // LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) { // return new LoginPresenter(loginView,apiManager,preferencesManager); // } // }
import com.zhy.authproject.module.login.LoginComponent; import com.zhy.authproject.module.login.LoginModule; import javax.inject.Singleton; import dagger.Component;
package com.zhy.authproject.di; /** * Created by zhanghaoye on 10/24/16. */ @Singleton @Component(modules = {AppModule.class, ApiModule.class}) public interface AppComponent {
// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginComponent.java // @Subcomponent(modules = LoginModule.class) // public interface LoginComponent { // LoginActivity inject(LoginActivity loginActivity); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginModule.java // @Module // public class LoginModule { // private final LoginView loginView; // // public LoginModule(LoginView loginView) { // this.loginView = loginView; // } // // @Provides // LoginView provideLoginView() { // return loginView; // } // // // @Provides // LoginPresenter provideLoginPresenter(ApiManager apiManager, PreferencesManager preferencesManager) { // return new LoginPresenter(loginView,apiManager,preferencesManager); // } // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java import com.zhy.authproject.module.login.LoginComponent; import com.zhy.authproject.module.login.LoginModule; import javax.inject.Singleton; import dagger.Component; package com.zhy.authproject.di; /** * Created by zhanghaoye on 10/24/16. */ @Singleton @Component(modules = {AppModule.class, ApiModule.class}) public interface AppComponent {
LoginComponent plus(LoginModule loginModule);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录
public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password)
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password)
.flatMap(new BaseResponseFunc<User>())
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password) .flatMap(new BaseResponseFunc<User>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); } //获取活动列表
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password) .flatMap(new BaseResponseFunc<User>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); } //获取活动列表
public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password) .flatMap(new BaseResponseFunc<User>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); } //获取活动列表 public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ apiService.getActivityInfo(id,user_id,access_token) .flatMap(new BaseResponseFunc<ActivityInfo>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); } //修改活动信息
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponseFunc.java // public class BaseResponseFunc<T> implements Func1<BaseResponse<T>, Observable<T>> { // // // @Override // public Observable<T> call(BaseResponse<T> tBaseResponse) { // //遇到非200错误统一处理,将BaseResponse转换成您想要的对象 // if (tBaseResponse.getStatus_code() != 200) { // return Observable.error(new Throwable(tBaseResponse.getStatus_msg())); // }else{ // return Observable.just(tBaseResponse.getData()); // } // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java import android.app.Application; import android.content.Context; import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponseFunc; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/24/16. */ public class ApiManager { private final ApiService apiService; private final Application application; public ApiManager(ApiService apiService, Application application) { this.apiService = apiService; this.application = application; } //登录 public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ apiService.login(username,password) .flatMap(new BaseResponseFunc<User>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); } //获取活动列表 public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ apiService.getActivityInfo(id,user_id,access_token) .flatMap(new BaseResponseFunc<ActivityInfo>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); } //修改活动信息
public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/di/AppModule.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // }
import android.app.Application; import com.zhy.authproject.data.local.PreferencesManager; import javax.inject.Singleton; import dagger.Module; import dagger.Provides;
package com.zhy.authproject.di; /** * Created by zhanghaoye on 10/24/16. */ @Module public class AppModule { private final Application application; public AppModule(Application application) { this.application = application; } @Provides @Singleton public Application provideApplication() { return application; } @Provides @Singleton
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppModule.java import android.app.Application; import com.zhy.authproject.data.local.PreferencesManager; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; package com.zhy.authproject.di; /** * Created by zhanghaoye on 10/24/16. */ @Module public class AppModule { private final Application application; public AppModule(Application application) { this.application = application; } @Provides @Singleton public Application provideApplication() { return application; } @Provides @Singleton
public PreferencesManager provideSharedPreferences(){
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginActivity.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/AuthApplication.java // public class AuthApplication extends Application{ // private AppComponent appComponent; // // public static AuthApplication get(Context context){ // return (AuthApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // // public AppComponent getAppComponent(){ // return appComponent; // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity{ // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupActivityComponent(); // } // public abstract void setupActivityComponent(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.app.LoaderManager.LoaderCallbacks; import android.content.CursorLoader; import android.content.Loader; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.zhy.authproject.AuthApplication; import com.zhy.authproject.R; import com.zhy.authproject.module.base.BaseActivity; import java.util.ArrayList; import java.util.List; import static android.Manifest.permission.READ_CONTACTS;
// Set up the login form. mEmailView = (AutoCompleteTextView) findViewById(R.id.email); populateAutoComplete(); mPasswordView = (EditText) findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.login || id == EditorInfo.IME_NULL) { attemptLogin(); return true; } return false; } }); Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button); mEmailSignInButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { attemptLogin(); } }); mLoginFormView = findViewById(R.id.login_form); mProgressView = findViewById(R.id.login_progress); } @Override public void setupActivityComponent() {
// Path: AuthProject/app/src/main/java/com/zhy/authproject/AuthApplication.java // public class AuthApplication extends Application{ // private AppComponent appComponent; // // public static AuthApplication get(Context context){ // return (AuthApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); // } // // // public AppComponent getAppComponent(){ // return appComponent; // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity{ // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupActivityComponent(); // } // public abstract void setupActivityComponent(); // // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginActivity.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.app.LoaderManager.LoaderCallbacks; import android.content.CursorLoader; import android.content.Loader; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.zhy.authproject.AuthApplication; import com.zhy.authproject.R; import com.zhy.authproject.module.base.BaseActivity; import java.util.ArrayList; import java.util.List; import static android.Manifest.permission.READ_CONTACTS; // Set up the login form. mEmailView = (AutoCompleteTextView) findViewById(R.id.email); populateAutoComplete(); mPasswordView = (EditText) findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.login || id == EditorInfo.IME_NULL) { attemptLogin(); return true; } return false; } }); Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button); mEmailSignInButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { attemptLogin(); } }); mLoginFormView = findViewById(R.id.login_form); mProgressView = findViewById(R.id.login_progress); } @Override public void setupActivityComponent() {
AuthApplication.get(this).getAppComponent().plus(new LoginModule(this)).inject(this);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login")
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login")
Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login")
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login")
Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login") Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password); @FormUrlEncoded @POST("/api/v1/authproject/{id}/modify_activity")
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login") Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password); @FormUrlEncoded @POST("/api/v1/authproject/{id}/modify_activity")
Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login") Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password); @FormUrlEncoded @POST("/api/v1/authproject/{id}/modify_activity") Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token); @GET("/api/v1/authproject/{id}")
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/ActivityInfo.java // public class ActivityInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/BaseResponse.java // public class BaseResponse<T> { // // private int status_code; // private String status_msg; // private T data; // // // public int getStatus_code() { // return status_code; // } // // public void setStatus_code(int status_code) { // this.status_code = status_code; // } // // public String getStatus_msg() { // return status_msg; // } // // public void setStatus_msg(String status_msg) { // this.status_msg = status_msg; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/CommonInfo.java // public class CommonInfo { // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java import com.zhy.authproject.data.remote.model.ActivityInfo; import com.zhy.authproject.data.remote.model.BaseResponse; import com.zhy.authproject.data.remote.model.CommonInfo; import com.zhy.authproject.data.remote.model.User; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; package com.zhy.authproject.data.remote; /** * Created by zhanghaoye on 10/29/16. */ public interface ApiService { String SERVER_URL = "http://127.0.0.1:3000/"; @FormUrlEncoded @POST("/api/v1/authproject/login") Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password); @FormUrlEncoded @POST("/api/v1/authproject/{id}/modify_activity") Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token); @GET("/api/v1/authproject/{id}")
Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User;
package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView;
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User; package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView;
private final ApiManager apiManager;
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User;
package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager;
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User; package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager;
private final PreferencesManager preferencesManager;
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User;
package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager; private final PreferencesManager preferencesManager; public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) { this.loginView = loginView; this.apiManager = apiManager; this.preferencesManager = preferencesManager; } public void login(final String username, final String password) {
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User; package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager; private final PreferencesManager preferencesManager; public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) { this.loginView = loginView; this.apiManager = apiManager; this.preferencesManager = preferencesManager; } public void login(final String username, final String password) {
apiManager.login((Activity) loginView, username, password, new SimpleCallback<User>() {
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // }
import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User;
package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager; private final PreferencesManager preferencesManager; public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) { this.loginView = loginView; this.apiManager = apiManager; this.preferencesManager = preferencesManager; } public void login(final String username, final String password) {
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java // public class PreferencesManager { // public static final String PREFERENCES_NAME = "androidarchitecture"; // private SharedPreferences sharedPreferences; // // // public PreferencesManager(Application application){ // sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE); // } // // public void saveLoginInfo(String username,String password){ // SharedPreferences.Editor editor = sharedPreferences.edit(); // editor.putString("username",username); // editor.putString("password",password); // editor.commit(); // } // // // // public String getUserName(){ // return sharedPreferences.getString("username",""); // } // // public String getPassword(){ // return sharedPreferences.getString("password",""); // } // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java // public class ApiManager { // private final ApiService apiService; // // private final Application application; // // public ApiManager(ApiService apiService, Application application) { // this.apiService = apiService; // this.application = application; // } // // //登录 // public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){ // apiService.login(username,password) // .flatMap(new BaseResponseFunc<User>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow)); // } // // //获取活动列表 // public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){ // apiService.getActivityInfo(id,user_id,access_token) // .flatMap(new BaseResponseFunc<ActivityInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context)); // } // // //修改活动信息 // public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){ // apiService.modifyActivity(activity_id,user_id,access_token) // .flatMap(new BaseResponseFunc<CommonInfo>()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context)); // } // // // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/SimpleCallback.java // public interface SimpleCallback<T> { // void onStart(); // void onNext(T t); // void onComplete(); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java // public class User { // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java import android.app.Activity; import com.zhy.authproject.data.local.PreferencesManager; import com.zhy.authproject.data.remote.ApiManager; import com.zhy.authproject.data.remote.SimpleCallback; import com.zhy.authproject.data.remote.model.User; package com.zhy.authproject.module.login; /** * Created by zhanghaoye on 10/21/16. */ public class LoginPresenter { private final LoginView loginView; private final ApiManager apiManager; private final PreferencesManager preferencesManager; public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) { this.loginView = loginView; this.apiManager = apiManager; this.preferencesManager = preferencesManager; } public void login(final String username, final String password) {
apiManager.login((Activity) loginView, username, password, new SimpleCallback<User>() {
xzwc/AndroidProject
AuthProject/app/src/main/java/com/zhy/authproject/AuthApplication.java
// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java // @Singleton // @Component(modules = {AppModule.class, ApiModule.class}) // public interface AppComponent { // LoginComponent plus(LoginModule loginModule); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppModule.java // @Module // public class AppModule { // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @Singleton // public Application provideApplication() { // return application; // } // // @Provides // @Singleton // public PreferencesManager provideSharedPreferences(){ // return new PreferencesManager(application); // } // // }
import android.app.Application; import android.content.Context; import com.zhy.authproject.di.AppComponent; import com.zhy.authproject.di.AppModule; import com.zhy.authproject.di.DaggerAppComponent;
package com.zhy.authproject; /** * Created by zhanghaoye on 10/21/16. */ public class AuthApplication extends Application{ private AppComponent appComponent; public static AuthApplication get(Context context){ return (AuthApplication) context.getApplicationContext(); } @Override public void onCreate() { super.onCreate();
// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppComponent.java // @Singleton // @Component(modules = {AppModule.class, ApiModule.class}) // public interface AppComponent { // LoginComponent plus(LoginModule loginModule); // } // // Path: AuthProject/app/src/main/java/com/zhy/authproject/di/AppModule.java // @Module // public class AppModule { // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @Singleton // public Application provideApplication() { // return application; // } // // @Provides // @Singleton // public PreferencesManager provideSharedPreferences(){ // return new PreferencesManager(application); // } // // } // Path: AuthProject/app/src/main/java/com/zhy/authproject/AuthApplication.java import android.app.Application; import android.content.Context; import com.zhy.authproject.di.AppComponent; import com.zhy.authproject.di.AppModule; import com.zhy.authproject.di.DaggerAppComponent; package com.zhy.authproject; /** * Created by zhanghaoye on 10/21/16. */ public class AuthApplication extends Application{ private AppComponent appComponent; public static AuthApplication get(Context context){ return (AuthApplication) context.getApplicationContext(); } @Override public void onCreate() { super.onCreate();
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
swookiee/com.swookiee.runtime
com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/auth/BasicAuthHttpContext.java
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AuthenticationService.java // public interface AuthenticationService { // // boolean validateUserCredentials(String username, String password); // // }
import java.io.IOException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.bind.DatatypeConverter; import org.osgi.service.http.HttpContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.swookiee.runtime.authentication.AuthenticationService;
/******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt, Tobias Ullrich and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation * Tobias Ullrich - Send correct header for basic auth *******************************************************************************/ package com.swookiee.runtime.ewok.auth; /** * This HttpContext provides a simple Basic-Auth mechanism. It is using {@link AuthenticationService} to validate user * credentials. * */ public class BasicAuthHttpContext implements HttpContext { private static final Logger logger = LoggerFactory.getLogger(BasicAuthHttpContext.class);
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AuthenticationService.java // public interface AuthenticationService { // // boolean validateUserCredentials(String username, String password); // // } // Path: com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/auth/BasicAuthHttpContext.java import java.io.IOException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.bind.DatatypeConverter; import org.osgi.service.http.HttpContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.swookiee.runtime.authentication.AuthenticationService; /******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt, Tobias Ullrich and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation * Tobias Ullrich - Send correct header for basic auth *******************************************************************************/ package com.swookiee.runtime.ewok.auth; /** * This HttpContext provides a simple Basic-Auth mechanism. It is using {@link AuthenticationService} to validate user * credentials. * */ public class BasicAuthHttpContext implements HttpContext { private static final Logger logger = LoggerFactory.getLogger(BasicAuthHttpContext.class);
private final AuthenticationService authenticationService;
swookiee/com.swookiee.runtime
com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/util/ServletUtil.java
// Path: com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/representation/ServiceRepresenation.java // public class ServiceRepresenation { // // Map<String, Object> properties = new HashMap<>(); // String bundle; // List<String> usingBundles = new ArrayList<>(); // // public ServiceRepresenation() { // } // // public Map<String, Object> getProperties() { // return properties; // } // // public void setProperties(final Map<String, Object> properties) { // this.properties = properties; // } // // public void addProperty(final String key, final Object value) { // properties.put(key, value); // } // // public String getBundle() { // return bundle; // } // // public void setBundle(final String bundle) { // this.bundle = bundle; // } // // public List<String> getUsingBundles() { // return usingBundles; // } // // public void setUsingBundles(final List<String> usingBundles) { // this.usingBundles = usingBundles; // } // // public void addUsingBundle(final String usingBundle) { // usingBundles.add(usingBundle); // } // // }
import java.io.IOException; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.ewok.representation.ServiceRepresenation;
public static <T> void jsonResponse(final HttpServletResponse response, final T toJson) throws IOException { final String jsonResponse = mapper.writeValueAsString(toJson); response.setContentType(APPLICATION_JSON); response.getWriter().println(jsonResponse); } public static long getId(final HttpServletRequest request) throws HttpErrorException { return ServletUtil.idExtractor.getId(request.getPathInfo()); } public static Bundle checkAndGetBundle(final BundleContext bundleContext, final long bundleId) throws HttpErrorException { final Bundle bundle = bundleContext.getBundle(bundleId); if (bundle == null) { throw new HttpErrorException(String.format("Could not find Bundle %d", bundleId), HttpServletResponse.SC_NOT_FOUND); } return bundle; } public static Map<String, String> transformToMapAndCleanUp(final Dictionary<String, String> source) { final Map<String, String> result = new HashMap<>(); for (final Enumeration<String> keys = source.keys(); keys.hasMoreElements();) { final String key = keys.nextElement(); result.put(key, source.get(key).replaceAll("[\u0000-\u001f]", "")); } return result; }
// Path: com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/representation/ServiceRepresenation.java // public class ServiceRepresenation { // // Map<String, Object> properties = new HashMap<>(); // String bundle; // List<String> usingBundles = new ArrayList<>(); // // public ServiceRepresenation() { // } // // public Map<String, Object> getProperties() { // return properties; // } // // public void setProperties(final Map<String, Object> properties) { // this.properties = properties; // } // // public void addProperty(final String key, final Object value) { // properties.put(key, value); // } // // public String getBundle() { // return bundle; // } // // public void setBundle(final String bundle) { // this.bundle = bundle; // } // // public List<String> getUsingBundles() { // return usingBundles; // } // // public void setUsingBundles(final List<String> usingBundles) { // this.usingBundles = usingBundles; // } // // public void addUsingBundle(final String usingBundle) { // usingBundles.add(usingBundle); // } // // } // Path: com.swookiee.runtime.ewok/src/main/java/com/swookiee/runtime/ewok/util/ServletUtil.java import java.io.IOException; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.ewok.representation.ServiceRepresenation; public static <T> void jsonResponse(final HttpServletResponse response, final T toJson) throws IOException { final String jsonResponse = mapper.writeValueAsString(toJson); response.setContentType(APPLICATION_JSON); response.getWriter().println(jsonResponse); } public static long getId(final HttpServletRequest request) throws HttpErrorException { return ServletUtil.idExtractor.getId(request.getPathInfo()); } public static Bundle checkAndGetBundle(final BundleContext bundleContext, final long bundleId) throws HttpErrorException { final Bundle bundle = bundleContext.getBundle(bundleId); if (bundle == null) { throw new HttpErrorException(String.format("Could not find Bundle %d", bundleId), HttpServletResponse.SC_NOT_FOUND); } return bundle; } public static Map<String, String> transformToMapAndCleanUp(final Dictionary<String, String> source) { final Map<String, String> result = new HashMap<>(); for (final Enumeration<String> keys = source.keys(); keys.hasMoreElements();) { final String key = keys.nextElement(); result.put(key, source.get(key).replaceAll("[\u0000-\u001f]", "")); } return result; }
public static void addServiceProperties(final ServiceReference<?> serviceReference, final ServiceRepresenation represenation) {
swookiee/com.swookiee.runtime
com.swookiee.runtime.metrics.prometheus/src/main/java/com/swookiee/runtime/metrics/prometheus/servlet/MetricsService.java
// Path: com.swookiee.runtime.metrics.prometheus/src/main/java/com/swookiee/runtime/metrics/prometheus/CollectorRegistryInventory.java // @Component(service = {CollectorRegistryInventory.class}) // public class CollectorRegistryInventory implements BundleListener { // // private static final Logger logger = LoggerFactory.getLogger(CollectorRegistryInventory.class); // private static final String BUNDLE_ID = "service.bundleid"; // private BundleContext bundleContext; // // private Map<String, CollectorRegistry> registeredRegistries = new ConcurrentHashMap<>(); // // @Activate // public void activate(final BundleContext bundleContext) { // this.bundleContext = bundleContext; // this.bundleContext.addBundleListener(this); // logger.info("Activated metric collector!"); // } // // @Deactivate // public void deactivate() { // for (CollectorRegistry registry : registeredRegistries.values()) { // registry.clear(); // } // registeredRegistries.clear(); // this.bundleContext.removeBundleListener(this); // logger.info("Deactivated metric collector!"); // } // // @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) // public void registerCollection(CollectorCollection collectorCollection, Map<String, Object> properties) { // CollectorRegistry registry = getRegistry(properties); // for (Collector collector : collectorCollection.getCollectors()) { // registry.register(collector); // } // } // // public void unregisterCollection(CollectorCollection collectorCollection, Map<String, Object> properties) { // CollectorRegistry registry = getRegistry(properties); // for (Collector collector : collectorCollection.getCollectors()) { // registry.unregister(collector); // } // } // // @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) // public void registerCollector(Collector metricsCollection, Map<String, Object> properties) { // getRegistry(properties).register(metricsCollection); // } // // public void unregisterCollector(Collector metricsCollection, Map<String, Object> properties) { // getRegistry(properties).unregister(metricsCollection); // } // // public CollectorRegistry getCollectorRegistry(String bundle) { // return registeredRegistries.get(bundle); // } // // public Set<String> getRegisteredBundles() { // return registeredRegistries.keySet(); // } // // @Override // public void bundleChanged(BundleEvent event) { // if (BundleEvent.STOPPED != event.getType()) { // return; // } // remove(event.getBundle().getSymbolicName()); // } // // private void remove(String bundle) { // if (!registeredRegistries.containsKey(bundle)) { // return; // } // // CollectorRegistry registry = registeredRegistries.get(bundle); // registry.clear(); // registeredRegistries.remove(bundle); // logger.debug("Removed bundle {} from MetricRegistry", bundle); // } // // private CollectorRegistry getRegistry(Map<String, ?> properties) { // String bundle = getBundleName(properties); // return computeRegistryIfAbsent(bundle); // } // // private CollectorRegistry computeRegistryIfAbsent(String bundle) { // CollectorRegistry registry = registeredRegistries.get(bundle); // if (registry == null) { // registry = new CollectorRegistry(); // registeredRegistries.put(bundle, registry); // } // return registry; // } // // private String getBundleName(Map<String, ?> properties) { // long bundleId = (long) properties.get(BUNDLE_ID); // Bundle bundle = bundleContext.getBundle(bundleId); // return bundle.getSymbolicName(); // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.metrics.prometheus.CollectorRegistryInventory; import io.prometheus.client.CollectorRegistry; import io.prometheus.client.exporter.common.TextFormat; import java.io.IOException; import java.io.StringWriter; import java.util.Iterator; import java.util.Set; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality;
/** * ***************************************************************************** * Copyright (c) 2014 Lars Pfannenschmidt and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Tobias Ullrich - initial implementation * Frank Wisniewski - single endpoint for each bundle registering a metric * - endpoint listing bundles containing metrics * ***************************************************************************** */ package com.swookiee.runtime.metrics.prometheus.servlet; @Component public class MetricsService implements Metrics { private static final Logger logger = LoggerFactory.getLogger(MetricsService.class); private static final ObjectMapper mapper = new ObjectMapper();
// Path: com.swookiee.runtime.metrics.prometheus/src/main/java/com/swookiee/runtime/metrics/prometheus/CollectorRegistryInventory.java // @Component(service = {CollectorRegistryInventory.class}) // public class CollectorRegistryInventory implements BundleListener { // // private static final Logger logger = LoggerFactory.getLogger(CollectorRegistryInventory.class); // private static final String BUNDLE_ID = "service.bundleid"; // private BundleContext bundleContext; // // private Map<String, CollectorRegistry> registeredRegistries = new ConcurrentHashMap<>(); // // @Activate // public void activate(final BundleContext bundleContext) { // this.bundleContext = bundleContext; // this.bundleContext.addBundleListener(this); // logger.info("Activated metric collector!"); // } // // @Deactivate // public void deactivate() { // for (CollectorRegistry registry : registeredRegistries.values()) { // registry.clear(); // } // registeredRegistries.clear(); // this.bundleContext.removeBundleListener(this); // logger.info("Deactivated metric collector!"); // } // // @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) // public void registerCollection(CollectorCollection collectorCollection, Map<String, Object> properties) { // CollectorRegistry registry = getRegistry(properties); // for (Collector collector : collectorCollection.getCollectors()) { // registry.register(collector); // } // } // // public void unregisterCollection(CollectorCollection collectorCollection, Map<String, Object> properties) { // CollectorRegistry registry = getRegistry(properties); // for (Collector collector : collectorCollection.getCollectors()) { // registry.unregister(collector); // } // } // // @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) // public void registerCollector(Collector metricsCollection, Map<String, Object> properties) { // getRegistry(properties).register(metricsCollection); // } // // public void unregisterCollector(Collector metricsCollection, Map<String, Object> properties) { // getRegistry(properties).unregister(metricsCollection); // } // // public CollectorRegistry getCollectorRegistry(String bundle) { // return registeredRegistries.get(bundle); // } // // public Set<String> getRegisteredBundles() { // return registeredRegistries.keySet(); // } // // @Override // public void bundleChanged(BundleEvent event) { // if (BundleEvent.STOPPED != event.getType()) { // return; // } // remove(event.getBundle().getSymbolicName()); // } // // private void remove(String bundle) { // if (!registeredRegistries.containsKey(bundle)) { // return; // } // // CollectorRegistry registry = registeredRegistries.get(bundle); // registry.clear(); // registeredRegistries.remove(bundle); // logger.debug("Removed bundle {} from MetricRegistry", bundle); // } // // private CollectorRegistry getRegistry(Map<String, ?> properties) { // String bundle = getBundleName(properties); // return computeRegistryIfAbsent(bundle); // } // // private CollectorRegistry computeRegistryIfAbsent(String bundle) { // CollectorRegistry registry = registeredRegistries.get(bundle); // if (registry == null) { // registry = new CollectorRegistry(); // registeredRegistries.put(bundle, registry); // } // return registry; // } // // private String getBundleName(Map<String, ?> properties) { // long bundleId = (long) properties.get(BUNDLE_ID); // Bundle bundle = bundleContext.getBundle(bundleId); // return bundle.getSymbolicName(); // } // } // Path: com.swookiee.runtime.metrics.prometheus/src/main/java/com/swookiee/runtime/metrics/prometheus/servlet/MetricsService.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.metrics.prometheus.CollectorRegistryInventory; import io.prometheus.client.CollectorRegistry; import io.prometheus.client.exporter.common.TextFormat; import java.io.IOException; import java.io.StringWriter; import java.util.Iterator; import java.util.Set; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; /** * ***************************************************************************** * Copyright (c) 2014 Lars Pfannenschmidt and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Tobias Ullrich - initial implementation * Frank Wisniewski - single endpoint for each bundle registering a metric * - endpoint listing bundles containing metrics * ***************************************************************************** */ package com.swookiee.runtime.metrics.prometheus.servlet; @Component public class MetricsService implements Metrics { private static final Logger logger = LoggerFactory.getLogger(MetricsService.class); private static final ObjectMapper mapper = new ObjectMapper();
private CollectorRegistryInventory inventory;
swookiee/com.swookiee.runtime
com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/internal/SwookieeWebConsoleSecurityProvider.java
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AuthenticationService.java // public interface AuthenticationService { // // boolean validateUserCredentials(String username, String password); // // }
import com.swookiee.runtime.authentication.AuthenticationService; import org.apache.felix.webconsole.WebConsoleSecurityProvider; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference;
/******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.runtime.authentication.internal; @Component public class SwookieeWebConsoleSecurityProvider implements WebConsoleSecurityProvider {
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AuthenticationService.java // public interface AuthenticationService { // // boolean validateUserCredentials(String username, String password); // // } // Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/internal/SwookieeWebConsoleSecurityProvider.java import com.swookiee.runtime.authentication.AuthenticationService; import org.apache.felix.webconsole.WebConsoleSecurityProvider; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.runtime.authentication.internal; @Component public class SwookieeWebConsoleSecurityProvider implements WebConsoleSecurityProvider {
private AuthenticationService authenticationService;
swookiee/com.swookiee.runtime
com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/internal/AdminUserManagementSerice.java
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AdminUserConfiguration.java // public class AdminUserConfiguration implements Configuration { // // public static final String pid = "com.swookiee.runtime.authentication"; // // public String username; // // public String password; // // @Override // public String getPid() { // return pid; // } // } // // Path: com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/configuration/ConfigurationConsumer.java // public final class ConfigurationConsumer<T> { // // private final ObjectMapper mapper = new ObjectMapper(); // // private final Map<String, Object> configuration = new ConcurrentHashMap<>(); // { // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // } // // private ConfigurationConsumer() { // } // // @SuppressWarnings({"unchecked", "rawtypes"}) // private ConfigurationConsumer(final T defaultConfig) { // final Hashtable defaultValues = mapper.convertValue(defaultConfig, Hashtable.class); // configuration.putAll(defaultValues); // } // // public static <T> ConfigurationConsumer<T> withDefaultConfiguration(final T defaultConfig) { // return new ConfigurationConsumer<T>(defaultConfig); // } // // public static <T> ConfigurationConsumer<T> newConsumer() { // return new ConfigurationConsumer<T>(); // } // // public ConfigurationConsumer<T> applyConfiguration(final Map<String, ?> configuration) { // this.configuration.putAll(configuration); // return this; // } // // public T getConfiguration(final Class<T> clazz) { // return mapper.convertValue(configuration, clazz); // } // }
import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Map; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.ConfigurationPolicy; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Modified; import org.osgi.service.component.annotations.Reference; import org.osgi.service.useradmin.Role; import org.osgi.service.useradmin.User; import org.osgi.service.useradmin.UserAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.swookiee.runtime.authentication.AdminUserConfiguration; import com.swookiee.runtime.util.configuration.ConfigurationConsumer;
/******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.runtime.authentication.internal; @Component(configurationPolicy = ConfigurationPolicy.OPTIONAL, configurationPid = AdminUserConfiguration.pid) public class AdminUserManagementSerice { private static final Logger logger = LoggerFactory.getLogger(AdminUserManagementSerice.class); private static final String DEFAULT_ADMIN_USERNAME = "admin"; private static final String DEFAULT_ADMIN_PASSWORD = "admin123"; private static final String USER_ADMIN_USERNAME_PROPERTY = "username"; private static final String USER_ADMIN_PASSWORD_PROPERTY = "password";
// Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/AdminUserConfiguration.java // public class AdminUserConfiguration implements Configuration { // // public static final String pid = "com.swookiee.runtime.authentication"; // // public String username; // // public String password; // // @Override // public String getPid() { // return pid; // } // } // // Path: com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/configuration/ConfigurationConsumer.java // public final class ConfigurationConsumer<T> { // // private final ObjectMapper mapper = new ObjectMapper(); // // private final Map<String, Object> configuration = new ConcurrentHashMap<>(); // { // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // } // // private ConfigurationConsumer() { // } // // @SuppressWarnings({"unchecked", "rawtypes"}) // private ConfigurationConsumer(final T defaultConfig) { // final Hashtable defaultValues = mapper.convertValue(defaultConfig, Hashtable.class); // configuration.putAll(defaultValues); // } // // public static <T> ConfigurationConsumer<T> withDefaultConfiguration(final T defaultConfig) { // return new ConfigurationConsumer<T>(defaultConfig); // } // // public static <T> ConfigurationConsumer<T> newConsumer() { // return new ConfigurationConsumer<T>(); // } // // public ConfigurationConsumer<T> applyConfiguration(final Map<String, ?> configuration) { // this.configuration.putAll(configuration); // return this; // } // // public T getConfiguration(final Class<T> clazz) { // return mapper.convertValue(configuration, clazz); // } // } // Path: com.swookiee.runtime.authentication/src/main/java/com/swookiee/runtime/authentication/internal/AdminUserManagementSerice.java import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Map; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.ConfigurationPolicy; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Modified; import org.osgi.service.component.annotations.Reference; import org.osgi.service.useradmin.Role; import org.osgi.service.useradmin.User; import org.osgi.service.useradmin.UserAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.swookiee.runtime.authentication.AdminUserConfiguration; import com.swookiee.runtime.util.configuration.ConfigurationConsumer; /******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.runtime.authentication.internal; @Component(configurationPolicy = ConfigurationPolicy.OPTIONAL, configurationPid = AdminUserConfiguration.pid) public class AdminUserManagementSerice { private static final Logger logger = LoggerFactory.getLogger(AdminUserManagementSerice.class); private static final String DEFAULT_ADMIN_USERNAME = "admin"; private static final String DEFAULT_ADMIN_PASSWORD = "admin123"; private static final String USER_ADMIN_USERNAME_PROPERTY = "username"; private static final String USER_ADMIN_PASSWORD_PROPERTY = "password";
private ConfigurationConsumer<AdminUserConfiguration> configurationConsumer;
swookiee/com.swookiee.runtime
com.swookiee.runtime.core.test/src/main/groovy/com/swookiee/core/internal/logging/FullJsonLayoutTest.java
// Path: com.swookiee.runtime.core/src/main/java/com/swookiee/runtime/core/internal/logging/FullJsonLayout.java // public class FullJsonLayout extends JsonLayout { // // private static final ISO8601DateFormat ISO_FORMATTER = new ISO8601DateFormat(); // // @Override // protected Map<String, Object> toJsonMap(final ILoggingEvent event) { // @SuppressWarnings("unchecked") // Map<String, Object> jsonMap = super.toJsonMap(event); // jsonMap.put("ts", ISO_FORMATTER.format(new Date())); // // if (isMeantToBeLoggedAsFullJson(event)) { // jsonMap.put("message", event.getArgumentArray()[0]); // } // // return jsonMap; // } // // private boolean isMeantToBeLoggedAsFullJson(final ILoggingEvent event) { // Object[] args = event.getArgumentArray(); // return event.getMessage().equals("{}") && args.length == 1 && args[0] instanceof Map; // } // }
import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.contrib.jackson.JacksonJsonFormatter; import ch.qos.logback.core.OutputStreamAppender; import ch.qos.logback.core.encoder.LayoutWrappingEncoder; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.core.internal.logging.FullJsonLayout;
/******************************************************************************* * Copyright (c) 2014 Thorsten Krüger and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Thorsten Krüger - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.core.internal.logging; public class FullJsonLayoutTest { private ByteArrayOutputStream outputStream; private Logger logger; private ObjectMapper mapper = new ObjectMapper(); @Before public void prepareLogger() { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final LayoutWrappingEncoder<ILoggingEvent> wrappingEncoder = new LayoutWrappingEncoder<>();
// Path: com.swookiee.runtime.core/src/main/java/com/swookiee/runtime/core/internal/logging/FullJsonLayout.java // public class FullJsonLayout extends JsonLayout { // // private static final ISO8601DateFormat ISO_FORMATTER = new ISO8601DateFormat(); // // @Override // protected Map<String, Object> toJsonMap(final ILoggingEvent event) { // @SuppressWarnings("unchecked") // Map<String, Object> jsonMap = super.toJsonMap(event); // jsonMap.put("ts", ISO_FORMATTER.format(new Date())); // // if (isMeantToBeLoggedAsFullJson(event)) { // jsonMap.put("message", event.getArgumentArray()[0]); // } // // return jsonMap; // } // // private boolean isMeantToBeLoggedAsFullJson(final ILoggingEvent event) { // Object[] args = event.getArgumentArray(); // return event.getMessage().equals("{}") && args.length == 1 && args[0] instanceof Map; // } // } // Path: com.swookiee.runtime.core.test/src/main/groovy/com/swookiee/core/internal/logging/FullJsonLayoutTest.java import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.contrib.jackson.JacksonJsonFormatter; import ch.qos.logback.core.OutputStreamAppender; import ch.qos.logback.core.encoder.LayoutWrappingEncoder; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.swookiee.runtime.core.internal.logging.FullJsonLayout; /******************************************************************************* * Copyright (c) 2014 Thorsten Krüger and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Thorsten Krüger - initial API and implementation, ongoing development and documentation *******************************************************************************/ package com.swookiee.core.internal.logging; public class FullJsonLayoutTest { private ByteArrayOutputStream outputStream; private Logger logger; private ObjectMapper mapper = new ObjectMapper(); @Before public void prepareLogger() { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final LayoutWrappingEncoder<ILoggingEvent> wrappingEncoder = new LayoutWrappingEncoder<>();
FullJsonLayout jsonLayout = new FullJsonLayout();
swookiee/com.swookiee.runtime
com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/configuration/ConfigurationUtils.java
// Path: com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/GuardAgainst.java // public final class GuardAgainst { // // private GuardAgainst() { // } // // public static <T> T nullValue(T value) { // if (value == null) { // throw new IllegalArgumentException(); // } // return value; // } // // public static <T> T nullValue(T value, String message) { // if (value == null) { // throw new IllegalArgumentException(message); // } // return value; // } // }
import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import java.util.*; import org.osgi.service.cm.ConfigurationAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.swookiee.runtime.util.GuardAgainst;
/******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt, Thorsten Krüger and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation * Thorsten Krüger - provide better error message on invalid configuration field types *******************************************************************************/ package com.swookiee.runtime.util.configuration; /** * This utility class can be used to bridge your configuration information out of your YAML and POJO pair to the * ConfigurationAdmin and thereby to the providers of {@link Configuration} implementations. * <p> * Example: * * <pre> * YourConfigPojo { * public AdminUserConfiguration adminUserConfiguration; * } * </pre> * * <p> * Corresponding YAML file * * <pre> * adminUserConfiguration: * username: "admin" * password: "admin123" * </pre> * * */ public final class ConfigurationUtils { private static final Logger logger = LoggerFactory.getLogger(ConfigurationUtils.class); private final static ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); private ConfigurationUtils() { //Making sure nobody creates a new instance. } /** * * @param <T> Class of your configuration pojo. * @param clazz * Configuration POJO {@link Class} * @param configurationFile * URL to your YAML configuration * @param configurationAdmin * {@link ConfigurationAdmin} instance */ public static <T> void applyConfiguration(final Class<T> clazz, final URL configurationFile, final ConfigurationAdmin configurationAdmin) { try {
// Path: com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/GuardAgainst.java // public final class GuardAgainst { // // private GuardAgainst() { // } // // public static <T> T nullValue(T value) { // if (value == null) { // throw new IllegalArgumentException(); // } // return value; // } // // public static <T> T nullValue(T value, String message) { // if (value == null) { // throw new IllegalArgumentException(message); // } // return value; // } // } // Path: com.swookiee.runtime.util/src/main/java/com/swookiee/runtime/util/configuration/ConfigurationUtils.java import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import java.util.*; import org.osgi.service.cm.ConfigurationAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.swookiee.runtime.util.GuardAgainst; /******************************************************************************* * Copyright (c) 2014 Lars Pfannenschmidt, Thorsten Krüger and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Lars Pfannenschmidt - initial API and implementation, ongoing development and documentation * Thorsten Krüger - provide better error message on invalid configuration field types *******************************************************************************/ package com.swookiee.runtime.util.configuration; /** * This utility class can be used to bridge your configuration information out of your YAML and POJO pair to the * ConfigurationAdmin and thereby to the providers of {@link Configuration} implementations. * <p> * Example: * * <pre> * YourConfigPojo { * public AdminUserConfiguration adminUserConfiguration; * } * </pre> * * <p> * Corresponding YAML file * * <pre> * adminUserConfiguration: * username: "admin" * password: "admin123" * </pre> * * */ public final class ConfigurationUtils { private static final Logger logger = LoggerFactory.getLogger(ConfigurationUtils.class); private final static ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); private ConfigurationUtils() { //Making sure nobody creates a new instance. } /** * * @param <T> Class of your configuration pojo. * @param clazz * Configuration POJO {@link Class} * @param configurationFile * URL to your YAML configuration * @param configurationAdmin * {@link ConfigurationAdmin} instance */ public static <T> void applyConfiguration(final Class<T> clazz, final URL configurationFile, final ConfigurationAdmin configurationAdmin) { try {
GuardAgainst.nullValue(clazz, "Class type can not be null");
confluentinc/common
config/src/main/java/io/confluent/common/config/ConfigDef.java
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // }
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import io.confluent.common.config.types.Password;
private Object parseType(String name, Object value, Type type) { try { String trimmed = null; if (value instanceof String) { trimmed = ((String) value).trim(); } switch (type) { case BOOLEAN: if (value instanceof String) { if (trimmed.equalsIgnoreCase("true")) { return true; } else if (trimmed.equalsIgnoreCase("false")) { return false; } else { throw new ConfigException(name, value, "Expected value to be either true or false"); } } else if (value instanceof Boolean) { return value; } else { throw new ConfigException(name, value, "Expected value to be either true or false"); } case STRING: if (value instanceof String) { return trimmed; } else { throw new ConfigException(name, value, "Expected value to be a string, but it was a " + value .getClass().getName()); } case PASSWORD:
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // } // Path: config/src/main/java/io/confluent/common/config/ConfigDef.java import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import io.confluent.common.config.types.Password; private Object parseType(String name, Object value, Type type) { try { String trimmed = null; if (value instanceof String) { trimmed = ((String) value).trim(); } switch (type) { case BOOLEAN: if (value instanceof String) { if (trimmed.equalsIgnoreCase("true")) { return true; } else if (trimmed.equalsIgnoreCase("false")) { return false; } else { throw new ConfigException(name, value, "Expected value to be either true or false"); } } else if (value instanceof Boolean) { return value; } else { throw new ConfigException(name, value, "Expected value to be either true or false"); } case STRING: if (value instanceof String) { return trimmed; } else { throw new ConfigException(name, value, "Expected value to be a string, but it was a " + value .getClass().getName()); } case PASSWORD:
if (value instanceof Password)
confluentinc/common
log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer;
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // } // Path: log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer;
private final Supplier<LogRecordBuilder<Struct>> logRecordStructBuilderFactory;
confluentinc/common
log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer; private final Supplier<LogRecordBuilder<Struct>> logRecordStructBuilderFactory; public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // } // Path: log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer; private final Supplier<LogRecordBuilder<Struct>> logRecordStructBuilderFactory; public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1
|| !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) {
confluentinc/common
log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer; private final Supplier<LogRecordBuilder<Struct>> logRecordStructBuilderFactory; public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } public String getContentType() { return "bytes"; } public byte[] toSerializable(final LogEvent event) { return toByteArray(event); } StructuredLayout(final Function<Struct, byte[]> serializer) {
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStructBuilder.java // public final class LogRecordStructBuilder implements LogRecordBuilder<Struct> { // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private SchemaAndValue messageWithSchema = null; // // @Override // public LogRecordStructBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStructBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStructBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStructBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // this.messageWithSchema = messageWithSchema; // return this; // } // // @Override // public LogRecordBuilder<Struct> withMessageJson(String message) { // throw new RuntimeException("not implemented"); // } // // public Struct build() { // final Schema logRecordSchema = LogRecordBuilder.baseSchemaBuilder() // .field(FIELD_MESSAGE, messageWithSchema.schema()) // .build(); // final Struct logRecord = new Struct(logRecordSchema); // logRecord.put(FIELD_LOGGER, loggerName); // logRecord.put(FIELD_LEVEL, level); // logRecord.put(FIELD_TIME, timeMs); // logRecord.put(FIELD_MESSAGE, messageWithSchema.value()); // return logRecord; // } // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // } // Path: log4j2-extensions/src/main/java/io/confluent/common/logging/log4j2/StructuredLayout.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStructBuilder; import org.apache.kafka.connect.data.Struct; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.AbstractLayout; import io.confluent.common.logging.StructuredLogMessage; import java.util.function.Function; import java.util.function.Supplier; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; final class StructuredLayout extends AbstractLayout<byte[]> { private static final byte[] EMPTY_BYTES = new byte[0]; private final Function<Struct, byte[]> serializer; private final Supplier<LogRecordBuilder<Struct>> logRecordStructBuilderFactory; public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } public String getContentType() { return "bytes"; } public byte[] toSerializable(final LogEvent event) { return toByteArray(event); } StructuredLayout(final Function<Struct, byte[]> serializer) {
this(serializer, LogRecordStructBuilder::new);
confluentinc/common
metrics/src/main/java/io/confluent/common/metrics/KafkaMetric.java
// Path: utils/src/main/java/io/confluent/common/utils/Time.java // public interface Time { // // /** // * The current time in milliseconds // */ // public long milliseconds(); // // /** // * The current time in nanoseconds // */ // public long nanoseconds(); // // /** // * Sleep for the given number of milliseconds // */ // public void sleep(long ms); // // }
import io.confluent.common.utils.Time;
/** * Copyright 2015 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ /** * Original license: * * 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 io.confluent.common.metrics; @Deprecated public final class KafkaMetric implements Metric { private MetricName metricName; private final Object lock;
// Path: utils/src/main/java/io/confluent/common/utils/Time.java // public interface Time { // // /** // * The current time in milliseconds // */ // public long milliseconds(); // // /** // * The current time in nanoseconds // */ // public long nanoseconds(); // // /** // * Sleep for the given number of milliseconds // */ // public void sleep(long ms); // // } // Path: metrics/src/main/java/io/confluent/common/metrics/KafkaMetric.java import io.confluent.common.utils.Time; /** * Copyright 2015 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ /** * Original license: * * 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 io.confluent.common.metrics; @Deprecated public final class KafkaMetric implements Metric { private MetricName metricName; private final Object lock;
private final Time time;
confluentinc/common
log4j-extensions/src/test/java/io/confluent/common/logging/log4j/StructuredJsonLayoutTest.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // }
import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import io.confluent.common.logging.LogRecordBuilder; import org.apache.log4j.Category; import org.apache.log4j.Level; import org.apache.log4j.spi.LoggingEvent; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j; public class StructuredJsonLayoutTest { private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final String STRUCTURED_MSG = "msg"; private static final String SERIALIZED_MSG = "serialized"; @Mock
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // Path: log4j-extensions/src/test/java/io/confluent/common/logging/log4j/StructuredJsonLayoutTest.java import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import io.confluent.common.logging.LogRecordBuilder; import org.apache.log4j.Category; import org.apache.log4j.Level; import org.apache.log4j.spi.LoggingEvent; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j; public class StructuredJsonLayoutTest { private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final String STRUCTURED_MSG = "msg"; private static final String SERIALIZED_MSG = "serialized"; @Mock
private LogRecordBuilder<String> builder;
confluentinc/common
log4j2-extensions/src/test/java/io/confluent/common/logging/log4j2/StructuredLayoutTest.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.StructuredLogMessage; import org.apache.kafka.connect.data.Schema; import org.apache.kafka.connect.data.SchemaAndValue; import org.apache.kafka.connect.data.Struct; import org.apache.kafka.connect.storage.Converter; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.message.Message; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer; import java.util.function.Function; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; public class StructuredLayoutTest { private static final String TOPIC = "topic"; private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final byte[] SERIALIZED_MSG = "serialized".getBytes(); @Mock private Function<Struct, byte[]> converter; @Mock private LogEvent logEvent; @Mock private Message log4jMessage; @Mock
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // } // Path: log4j2-extensions/src/test/java/io/confluent/common/logging/log4j2/StructuredLayoutTest.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.StructuredLogMessage; import org.apache.kafka.connect.data.Schema; import org.apache.kafka.connect.data.SchemaAndValue; import org.apache.kafka.connect.data.Struct; import org.apache.kafka.connect.storage.Converter; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.message.Message; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer; import java.util.function.Function; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; public class StructuredLayoutTest { private static final String TOPIC = "topic"; private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final byte[] SERIALIZED_MSG = "serialized".getBytes(); @Mock private Function<Struct, byte[]> converter; @Mock private LogEvent logEvent; @Mock private Message log4jMessage; @Mock
private LogRecordBuilder<Struct> builder;
confluentinc/common
log4j2-extensions/src/test/java/io/confluent/common/logging/log4j2/StructuredLayoutTest.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.StructuredLogMessage; import org.apache.kafka.connect.data.Schema; import org.apache.kafka.connect.data.SchemaAndValue; import org.apache.kafka.connect.data.Struct; import org.apache.kafka.connect.storage.Converter; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.message.Message; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer; import java.util.function.Function; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; public class StructuredLayoutTest { private static final String TOPIC = "topic"; private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final byte[] SERIALIZED_MSG = "serialized".getBytes(); @Mock private Function<Struct, byte[]> converter; @Mock private LogEvent logEvent; @Mock private Message log4jMessage; @Mock private LogRecordBuilder<Struct> builder; @Mock
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/StructuredLogMessage.java // public interface StructuredLogMessage { // SchemaAndValue getMessage(); // } // Path: log4j2-extensions/src/test/java/io/confluent/common/logging/log4j2/StructuredLayoutTest.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.StructuredLogMessage; import org.apache.kafka.connect.data.Schema; import org.apache.kafka.connect.data.SchemaAndValue; import org.apache.kafka.connect.data.Struct; import org.apache.kafka.connect.storage.Converter; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.message.Message; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.function.Consumer; import java.util.function.Function; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j2; public class StructuredLayoutTest { private static final String TOPIC = "topic"; private static final Level LOG_LEVEL = Level.INFO; private static final String LOGGER_NAME = "foo.bar"; private static final long LOG_TIME_MS = 123456L; private static final byte[] SERIALIZED_MSG = "serialized".getBytes(); @Mock private Function<Struct, byte[]> converter; @Mock private LogEvent logEvent; @Mock private Message log4jMessage; @Mock private LogRecordBuilder<Struct> builder; @Mock
private StructuredLogMessage logMessage;
confluentinc/common
log4j-extensions/src/main/java/io/confluent/common/logging/log4j/StructuredJsonLayout.java
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStringBuilder.java // public final class LogRecordStringBuilder implements LogRecordBuilder<String> { // private static final ObjectMapper mapper = new ObjectMapper(); // // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private String message = null; // // private static class LogRecord { // @JsonProperty(FIELD_LEVEL) String level; // @JsonProperty(FIELD_LOGGER) String logger; // @JsonProperty(FIELD_TIME) Long timeMs; // // @JsonProperty(FIELD_MESSAGE) // @JsonRawValue // String message; // // public LogRecord( // final String level, // final String logger, // final Long timeMs, // final String message) { // this.level = level; // this.logger = logger; // this.timeMs = timeMs; // this.message = message; // } // } // // @Override // public LogRecordStringBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStringBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStringBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStringBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // throw new RuntimeException("not implemented"); // } // // @Override // public LogRecordBuilder<String> withMessageJson(final String message) { // this.message = message; // return this; // } // // public String build() { // try { // return mapper.writeValueAsString( // new LogRecord(level, loggerName, timeMs, message)); // } catch (final JsonProcessingException e) { // throw new RuntimeException(e); // } // } // }
import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStringBuilder; import org.apache.log4j.Layout; import org.apache.log4j.spi.LoggingEvent; import java.util.function.Supplier;
/* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j; public class StructuredJsonLayout extends Layout { final Supplier<LogRecordBuilder<String>> logRecordBuilderFactory; @Override public String format(LoggingEvent loggingEvent) { final LogRecordBuilder<String> recordBuilder = logRecordBuilderFactory.get(); return recordBuilder.withLevel(loggingEvent.getLevel().toString()) .withLoggerName(loggingEvent.getLoggerName()) .withTimeMs(loggingEvent.getTimeStamp()) .withMessageJson(loggingEvent.getRenderedMessage()) .build(); } @Override public boolean ignoresThrowable() { return true; } @Override public void activateOptions() { } public StructuredJsonLayout() {
// Path: logging/src/main/java/io/confluent/common/logging/LogRecordBuilder.java // public interface LogRecordBuilder<T> { // String FIELD_LOGGER = "logger"; // String FIELD_LEVEL = "level"; // String FIELD_TIME = "time"; // String FIELD_MESSAGE = "message"; // // String NAMESPACE = "io.confluent.common.logging."; // // static SchemaBuilder baseSchemaBuilder() { // return SchemaBuilder.struct() // .name(NAMESPACE + "StructuredLogRecord") // .field(FIELD_LOGGER, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_LEVEL, Schema.OPTIONAL_STRING_SCHEMA) // .field(FIELD_TIME, Schema.OPTIONAL_INT64_SCHEMA); // } // // LogRecordBuilder<T> withLevel(final String level); // // LogRecordBuilder<T> withTimeMs(final long timeMs); // // LogRecordBuilder<T> withLoggerName(final String loggerName); // // LogRecordBuilder<T> withMessageSchemaAndValue(final SchemaAndValue message); // // LogRecordBuilder<T> withMessageJson(final String message); // // public T build(); // } // // Path: logging/src/main/java/io/confluent/common/logging/LogRecordStringBuilder.java // public final class LogRecordStringBuilder implements LogRecordBuilder<String> { // private static final ObjectMapper mapper = new ObjectMapper(); // // private String level = null; // private Long timeMs = null; // private String loggerName = null; // private String message = null; // // private static class LogRecord { // @JsonProperty(FIELD_LEVEL) String level; // @JsonProperty(FIELD_LOGGER) String logger; // @JsonProperty(FIELD_TIME) Long timeMs; // // @JsonProperty(FIELD_MESSAGE) // @JsonRawValue // String message; // // public LogRecord( // final String level, // final String logger, // final Long timeMs, // final String message) { // this.level = level; // this.logger = logger; // this.timeMs = timeMs; // this.message = message; // } // } // // @Override // public LogRecordStringBuilder withLevel(final String level) { // this.level = level; // return this; // } // // @Override // public LogRecordStringBuilder withTimeMs(final long timeMs) { // this.timeMs = timeMs; // return this; // } // // @Override // public LogRecordStringBuilder withLoggerName(final String loggerName) { // this.loggerName = loggerName; // return this; // } // // @Override // public LogRecordStringBuilder withMessageSchemaAndValue(final SchemaAndValue messageWithSchema) { // throw new RuntimeException("not implemented"); // } // // @Override // public LogRecordBuilder<String> withMessageJson(final String message) { // this.message = message; // return this; // } // // public String build() { // try { // return mapper.writeValueAsString( // new LogRecord(level, loggerName, timeMs, message)); // } catch (final JsonProcessingException e) { // throw new RuntimeException(e); // } // } // } // Path: log4j-extensions/src/main/java/io/confluent/common/logging/log4j/StructuredJsonLayout.java import io.confluent.common.logging.LogRecordBuilder; import io.confluent.common.logging.LogRecordStringBuilder; import org.apache.log4j.Layout; import org.apache.log4j.spi.LoggingEvent; import java.util.function.Supplier; /* * Copyright 2018 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.confluent.common.logging.log4j; public class StructuredJsonLayout extends Layout { final Supplier<LogRecordBuilder<String>> logRecordBuilderFactory; @Override public String format(LoggingEvent loggingEvent) { final LogRecordBuilder<String> recordBuilder = logRecordBuilderFactory.get(); return recordBuilder.withLevel(loggingEvent.getLevel().toString()) .withLoggerName(loggingEvent.getLoggerName()) .withTimeMs(loggingEvent.getTimeStamp()) .withMessageJson(loggingEvent.getRenderedMessage()) .build(); } @Override public boolean ignoresThrowable() { return true; } @Override public void activateOptions() { } public StructuredJsonLayout() {
this(LogRecordStringBuilder::new);
confluentinc/common
metrics/src/main/java/io/confluent/common/metrics/stats/Percentiles.java
// Path: metrics/src/main/java/io/confluent/common/metrics/CompoundStat.java // @Deprecated // public interface CompoundStat extends Stat { // // public List<NamedMeasurable> stats(); // // public static class NamedMeasurable { // // private final MetricName name; // private final Measurable stat; // // public NamedMeasurable(MetricName name, Measurable stat) { // super(); // this.name = name; // this.stat = stat; // } // // public MetricName name() { // return name; // } // // public Measurable stat() { // return stat; // } // // } // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/Measurable.java // @Deprecated // public interface Measurable { // // /** // * Measure this quantity and return the result as a double // * // * @param config The configuration for this metric // * @param now The POSIX time in milliseconds the measurement is being taken // * @return The measured value // */ // public double measure(MetricConfig config, long now); // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/MetricConfig.java // @Deprecated // public class MetricConfig { // // private Quota quota; // private int samples; // private long eventWindow; // private long timeWindowMs; // private TimeUnit unit; // // public MetricConfig() { // super(); // this.quota = null; // this.samples = 2; // this.eventWindow = Long.MAX_VALUE; // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS); // this.unit = TimeUnit.SECONDS; // } // // public Quota quota() { // return this.quota; // } // // public MetricConfig quota(Quota quota) { // this.quota = quota; // return this; // } // // public long eventWindow() { // return eventWindow; // } // // public MetricConfig eventWindow(long window) { // this.eventWindow = window; // return this; // } // // public long timeWindowMs() { // return timeWindowMs; // } // // public MetricConfig timeWindow(long window, TimeUnit unit) { // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(window, unit); // return this; // } // // public int samples() { // return this.samples; // } // // public MetricConfig samples(int samples) { // if (samples < 1) { // throw new IllegalArgumentException("The number of samples must be at least 1."); // } // this.samples = samples; // return this; // } // // public TimeUnit timeUnit() { // return unit; // } // // public MetricConfig timeUnit(TimeUnit unit) { // this.unit = unit; // return this; // } // }
import java.util.ArrayList; import java.util.List; import io.confluent.common.metrics.CompoundStat; import io.confluent.common.metrics.Measurable; import io.confluent.common.metrics.MetricConfig;
/** * Copyright 2015 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ /** * Original license: * * 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 io.confluent.common.metrics.stats; /** * A compound stat that reports one or more percentiles */ public class Percentiles extends SampledStat implements CompoundStat { private final int buckets; private final Percentile[] percentiles; private final Histogram.BinScheme binScheme; public Percentiles(int sizeInBytes, double max, BucketSizing bucketing, Percentile... percentiles) { this(sizeInBytes, 0.0, max, bucketing, percentiles); } public Percentiles(int sizeInBytes, double min, double max, BucketSizing bucketing, Percentile... percentiles) { super(0.0); this.percentiles = percentiles; this.buckets = sizeInBytes / 4; if (bucketing == BucketSizing.CONSTANT) { this.binScheme = new Histogram.ConstantBinScheme(buckets, min, max); } else if (bucketing == BucketSizing.LINEAR) { if (min != 0.0d) { throw new IllegalArgumentException("Linear bucket sizing requires min to be 0.0."); } this.binScheme = new Histogram.LinearBinScheme(buckets, max); } else { throw new IllegalArgumentException("Unknown bucket type: " + bucketing); } } @Override public List<CompoundStat.NamedMeasurable> stats() { List<NamedMeasurable> ms = new ArrayList<NamedMeasurable>(this.percentiles.length); for (Percentile percentile : this.percentiles) { final double pct = percentile.percentile();
// Path: metrics/src/main/java/io/confluent/common/metrics/CompoundStat.java // @Deprecated // public interface CompoundStat extends Stat { // // public List<NamedMeasurable> stats(); // // public static class NamedMeasurable { // // private final MetricName name; // private final Measurable stat; // // public NamedMeasurable(MetricName name, Measurable stat) { // super(); // this.name = name; // this.stat = stat; // } // // public MetricName name() { // return name; // } // // public Measurable stat() { // return stat; // } // // } // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/Measurable.java // @Deprecated // public interface Measurable { // // /** // * Measure this quantity and return the result as a double // * // * @param config The configuration for this metric // * @param now The POSIX time in milliseconds the measurement is being taken // * @return The measured value // */ // public double measure(MetricConfig config, long now); // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/MetricConfig.java // @Deprecated // public class MetricConfig { // // private Quota quota; // private int samples; // private long eventWindow; // private long timeWindowMs; // private TimeUnit unit; // // public MetricConfig() { // super(); // this.quota = null; // this.samples = 2; // this.eventWindow = Long.MAX_VALUE; // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS); // this.unit = TimeUnit.SECONDS; // } // // public Quota quota() { // return this.quota; // } // // public MetricConfig quota(Quota quota) { // this.quota = quota; // return this; // } // // public long eventWindow() { // return eventWindow; // } // // public MetricConfig eventWindow(long window) { // this.eventWindow = window; // return this; // } // // public long timeWindowMs() { // return timeWindowMs; // } // // public MetricConfig timeWindow(long window, TimeUnit unit) { // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(window, unit); // return this; // } // // public int samples() { // return this.samples; // } // // public MetricConfig samples(int samples) { // if (samples < 1) { // throw new IllegalArgumentException("The number of samples must be at least 1."); // } // this.samples = samples; // return this; // } // // public TimeUnit timeUnit() { // return unit; // } // // public MetricConfig timeUnit(TimeUnit unit) { // this.unit = unit; // return this; // } // } // Path: metrics/src/main/java/io/confluent/common/metrics/stats/Percentiles.java import java.util.ArrayList; import java.util.List; import io.confluent.common.metrics.CompoundStat; import io.confluent.common.metrics.Measurable; import io.confluent.common.metrics.MetricConfig; /** * Copyright 2015 Confluent Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ /** * Original license: * * 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 io.confluent.common.metrics.stats; /** * A compound stat that reports one or more percentiles */ public class Percentiles extends SampledStat implements CompoundStat { private final int buckets; private final Percentile[] percentiles; private final Histogram.BinScheme binScheme; public Percentiles(int sizeInBytes, double max, BucketSizing bucketing, Percentile... percentiles) { this(sizeInBytes, 0.0, max, bucketing, percentiles); } public Percentiles(int sizeInBytes, double min, double max, BucketSizing bucketing, Percentile... percentiles) { super(0.0); this.percentiles = percentiles; this.buckets = sizeInBytes / 4; if (bucketing == BucketSizing.CONSTANT) { this.binScheme = new Histogram.ConstantBinScheme(buckets, min, max); } else if (bucketing == BucketSizing.LINEAR) { if (min != 0.0d) { throw new IllegalArgumentException("Linear bucket sizing requires min to be 0.0."); } this.binScheme = new Histogram.LinearBinScheme(buckets, max); } else { throw new IllegalArgumentException("Unknown bucket type: " + bucketing); } } @Override public List<CompoundStat.NamedMeasurable> stats() { List<NamedMeasurable> ms = new ArrayList<NamedMeasurable>(this.percentiles.length); for (Percentile percentile : this.percentiles) { final double pct = percentile.percentile();
ms.add(new NamedMeasurable(percentile.name(), new Measurable() {
confluentinc/common
metrics/src/main/java/io/confluent/common/metrics/stats/Percentiles.java
// Path: metrics/src/main/java/io/confluent/common/metrics/CompoundStat.java // @Deprecated // public interface CompoundStat extends Stat { // // public List<NamedMeasurable> stats(); // // public static class NamedMeasurable { // // private final MetricName name; // private final Measurable stat; // // public NamedMeasurable(MetricName name, Measurable stat) { // super(); // this.name = name; // this.stat = stat; // } // // public MetricName name() { // return name; // } // // public Measurable stat() { // return stat; // } // // } // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/Measurable.java // @Deprecated // public interface Measurable { // // /** // * Measure this quantity and return the result as a double // * // * @param config The configuration for this metric // * @param now The POSIX time in milliseconds the measurement is being taken // * @return The measured value // */ // public double measure(MetricConfig config, long now); // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/MetricConfig.java // @Deprecated // public class MetricConfig { // // private Quota quota; // private int samples; // private long eventWindow; // private long timeWindowMs; // private TimeUnit unit; // // public MetricConfig() { // super(); // this.quota = null; // this.samples = 2; // this.eventWindow = Long.MAX_VALUE; // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS); // this.unit = TimeUnit.SECONDS; // } // // public Quota quota() { // return this.quota; // } // // public MetricConfig quota(Quota quota) { // this.quota = quota; // return this; // } // // public long eventWindow() { // return eventWindow; // } // // public MetricConfig eventWindow(long window) { // this.eventWindow = window; // return this; // } // // public long timeWindowMs() { // return timeWindowMs; // } // // public MetricConfig timeWindow(long window, TimeUnit unit) { // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(window, unit); // return this; // } // // public int samples() { // return this.samples; // } // // public MetricConfig samples(int samples) { // if (samples < 1) { // throw new IllegalArgumentException("The number of samples must be at least 1."); // } // this.samples = samples; // return this; // } // // public TimeUnit timeUnit() { // return unit; // } // // public MetricConfig timeUnit(TimeUnit unit) { // this.unit = unit; // return this; // } // }
import java.util.ArrayList; import java.util.List; import io.confluent.common.metrics.CompoundStat; import io.confluent.common.metrics.Measurable; import io.confluent.common.metrics.MetricConfig;
private final Histogram.BinScheme binScheme; public Percentiles(int sizeInBytes, double max, BucketSizing bucketing, Percentile... percentiles) { this(sizeInBytes, 0.0, max, bucketing, percentiles); } public Percentiles(int sizeInBytes, double min, double max, BucketSizing bucketing, Percentile... percentiles) { super(0.0); this.percentiles = percentiles; this.buckets = sizeInBytes / 4; if (bucketing == BucketSizing.CONSTANT) { this.binScheme = new Histogram.ConstantBinScheme(buckets, min, max); } else if (bucketing == BucketSizing.LINEAR) { if (min != 0.0d) { throw new IllegalArgumentException("Linear bucket sizing requires min to be 0.0."); } this.binScheme = new Histogram.LinearBinScheme(buckets, max); } else { throw new IllegalArgumentException("Unknown bucket type: " + bucketing); } } @Override public List<CompoundStat.NamedMeasurable> stats() { List<NamedMeasurable> ms = new ArrayList<NamedMeasurable>(this.percentiles.length); for (Percentile percentile : this.percentiles) { final double pct = percentile.percentile(); ms.add(new NamedMeasurable(percentile.name(), new Measurable() {
// Path: metrics/src/main/java/io/confluent/common/metrics/CompoundStat.java // @Deprecated // public interface CompoundStat extends Stat { // // public List<NamedMeasurable> stats(); // // public static class NamedMeasurable { // // private final MetricName name; // private final Measurable stat; // // public NamedMeasurable(MetricName name, Measurable stat) { // super(); // this.name = name; // this.stat = stat; // } // // public MetricName name() { // return name; // } // // public Measurable stat() { // return stat; // } // // } // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/Measurable.java // @Deprecated // public interface Measurable { // // /** // * Measure this quantity and return the result as a double // * // * @param config The configuration for this metric // * @param now The POSIX time in milliseconds the measurement is being taken // * @return The measured value // */ // public double measure(MetricConfig config, long now); // // } // // Path: metrics/src/main/java/io/confluent/common/metrics/MetricConfig.java // @Deprecated // public class MetricConfig { // // private Quota quota; // private int samples; // private long eventWindow; // private long timeWindowMs; // private TimeUnit unit; // // public MetricConfig() { // super(); // this.quota = null; // this.samples = 2; // this.eventWindow = Long.MAX_VALUE; // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS); // this.unit = TimeUnit.SECONDS; // } // // public Quota quota() { // return this.quota; // } // // public MetricConfig quota(Quota quota) { // this.quota = quota; // return this; // } // // public long eventWindow() { // return eventWindow; // } // // public MetricConfig eventWindow(long window) { // this.eventWindow = window; // return this; // } // // public long timeWindowMs() { // return timeWindowMs; // } // // public MetricConfig timeWindow(long window, TimeUnit unit) { // this.timeWindowMs = TimeUnit.MILLISECONDS.convert(window, unit); // return this; // } // // public int samples() { // return this.samples; // } // // public MetricConfig samples(int samples) { // if (samples < 1) { // throw new IllegalArgumentException("The number of samples must be at least 1."); // } // this.samples = samples; // return this; // } // // public TimeUnit timeUnit() { // return unit; // } // // public MetricConfig timeUnit(TimeUnit unit) { // this.unit = unit; // return this; // } // } // Path: metrics/src/main/java/io/confluent/common/metrics/stats/Percentiles.java import java.util.ArrayList; import java.util.List; import io.confluent.common.metrics.CompoundStat; import io.confluent.common.metrics.Measurable; import io.confluent.common.metrics.MetricConfig; private final Histogram.BinScheme binScheme; public Percentiles(int sizeInBytes, double max, BucketSizing bucketing, Percentile... percentiles) { this(sizeInBytes, 0.0, max, bucketing, percentiles); } public Percentiles(int sizeInBytes, double min, double max, BucketSizing bucketing, Percentile... percentiles) { super(0.0); this.percentiles = percentiles; this.buckets = sizeInBytes / 4; if (bucketing == BucketSizing.CONSTANT) { this.binScheme = new Histogram.ConstantBinScheme(buckets, min, max); } else if (bucketing == BucketSizing.LINEAR) { if (min != 0.0d) { throw new IllegalArgumentException("Linear bucket sizing requires min to be 0.0."); } this.binScheme = new Histogram.LinearBinScheme(buckets, max); } else { throw new IllegalArgumentException("Unknown bucket type: " + bucketing); } } @Override public List<CompoundStat.NamedMeasurable> stats() { List<NamedMeasurable> ms = new ArrayList<NamedMeasurable>(this.percentiles.length); for (Percentile percentile : this.percentiles) { final double pct = percentile.percentile(); ms.add(new NamedMeasurable(percentile.name(), new Measurable() {
public double measure(MetricConfig config, long now) {
confluentinc/common
config/src/test/java/io/confluent/common/config/ConfigDefTest.java
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // } // // Path: config/src/main/java/io/confluent/common/config/ConfigDef.java // public enum Type { // BOOLEAN, STRING, INT, LONG, DOUBLE, LIST, CLASS, PASSWORD, MAP // }
import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import io.confluent.common.config.types.Password; import javax.xml.bind.DatatypeConverter; import static io.confluent.common.config.ConfigDef.Type; import static io.confluent.common.config.ConfigDef.Type.BOOLEAN; import static io.confluent.common.config.ConfigDef.Type.CLASS; import static io.confluent.common.config.ConfigDef.Type.DOUBLE; import static io.confluent.common.config.ConfigDef.Type.INT; import static io.confluent.common.config.ConfigDef.Type.LIST; import static io.confluent.common.config.ConfigDef.Type.LONG; import static io.confluent.common.config.ConfigDef.Type.STRING; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail;
Properties props = new Properties(); props.put("a", "5"); props.put("b", "foo"); props.put("c", "true"); // Ensure the copied ConfigDef contains all the definitions of the original Map<String, Object> originalParsedProps = original.parse(props); Map<String, Object> copyParsedProps = copy.parse(props); assertEquals(originalParsedProps, copyParsedProps); assertFalse(copyParsedProps.containsKey("c")); copy.define("c", BOOLEAN, ConfigDef.Importance.MEDIUM, "docs"); // Ensure that mutating the copied ConfigDef doesn't also mutate the original originalParsedProps = original.parse(props); copyParsedProps = copy.parse(props); assertNotEquals(originalParsedProps, copyParsedProps); assertEquals(true, copyParsedProps.get("c")); } @Test public void testBasicTypes() { ConfigDef def = new ConfigDef().define("a", INT, 5, ConfigDef.Range .between(0, 14), ConfigDef.Importance.HIGH, "docs") .define("b", LONG, ConfigDef.Importance.HIGH, "docs") .define("c", STRING, "hello", ConfigDef.Importance.HIGH, "docs") .define("d", LIST, ConfigDef.Importance.HIGH, "docs") .define("e", DOUBLE, ConfigDef.Importance.HIGH, "docs") .define("f", CLASS, ConfigDef.Importance.HIGH, "docs") .define("g", BOOLEAN, ConfigDef.Importance.HIGH, "docs")
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // } // // Path: config/src/main/java/io/confluent/common/config/ConfigDef.java // public enum Type { // BOOLEAN, STRING, INT, LONG, DOUBLE, LIST, CLASS, PASSWORD, MAP // } // Path: config/src/test/java/io/confluent/common/config/ConfigDefTest.java import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import io.confluent.common.config.types.Password; import javax.xml.bind.DatatypeConverter; import static io.confluent.common.config.ConfigDef.Type; import static io.confluent.common.config.ConfigDef.Type.BOOLEAN; import static io.confluent.common.config.ConfigDef.Type.CLASS; import static io.confluent.common.config.ConfigDef.Type.DOUBLE; import static io.confluent.common.config.ConfigDef.Type.INT; import static io.confluent.common.config.ConfigDef.Type.LIST; import static io.confluent.common.config.ConfigDef.Type.LONG; import static io.confluent.common.config.ConfigDef.Type.STRING; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; Properties props = new Properties(); props.put("a", "5"); props.put("b", "foo"); props.put("c", "true"); // Ensure the copied ConfigDef contains all the definitions of the original Map<String, Object> originalParsedProps = original.parse(props); Map<String, Object> copyParsedProps = copy.parse(props); assertEquals(originalParsedProps, copyParsedProps); assertFalse(copyParsedProps.containsKey("c")); copy.define("c", BOOLEAN, ConfigDef.Importance.MEDIUM, "docs"); // Ensure that mutating the copied ConfigDef doesn't also mutate the original originalParsedProps = original.parse(props); copyParsedProps = copy.parse(props); assertNotEquals(originalParsedProps, copyParsedProps); assertEquals(true, copyParsedProps.get("c")); } @Test public void testBasicTypes() { ConfigDef def = new ConfigDef().define("a", INT, 5, ConfigDef.Range .between(0, 14), ConfigDef.Importance.HIGH, "docs") .define("b", LONG, ConfigDef.Importance.HIGH, "docs") .define("c", STRING, "hello", ConfigDef.Importance.HIGH, "docs") .define("d", LIST, ConfigDef.Importance.HIGH, "docs") .define("e", DOUBLE, ConfigDef.Importance.HIGH, "docs") .define("f", CLASS, ConfigDef.Importance.HIGH, "docs") .define("g", BOOLEAN, ConfigDef.Importance.HIGH, "docs")
.define("h", Type.BOOLEAN, ConfigDef.Importance.HIGH, "docs")
confluentinc/common
config/src/test/java/io/confluent/common/config/ConfigDefTest.java
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // } // // Path: config/src/main/java/io/confluent/common/config/ConfigDef.java // public enum Type { // BOOLEAN, STRING, INT, LONG, DOUBLE, LIST, CLASS, PASSWORD, MAP // }
import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import io.confluent.common.config.types.Password; import javax.xml.bind.DatatypeConverter; import static io.confluent.common.config.ConfigDef.Type; import static io.confluent.common.config.ConfigDef.Type.BOOLEAN; import static io.confluent.common.config.ConfigDef.Type.CLASS; import static io.confluent.common.config.ConfigDef.Type.DOUBLE; import static io.confluent.common.config.ConfigDef.Type.INT; import static io.confluent.common.config.ConfigDef.Type.LIST; import static io.confluent.common.config.ConfigDef.Type.LONG; import static io.confluent.common.config.ConfigDef.Type.STRING; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail;
.define("g", BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("h", Type.BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("i", Type.BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("j", Type.PASSWORD, ConfigDef.Importance.HIGH, "docs") .define("k", Type.MAP, ConfigDef.Importance.HIGH, "docs") .define("l", Type.MAP, ConfigDef.Importance.HIGH, "docs"); Properties props = new Properties(); props.put("a", "1 "); props.put("b", 2); props.put("d", " a , b, c"); props.put("e", 42.5d); props.put("f", String.class.getName()); props.put("g", "true"); props.put("h", "FalSE"); props.put("i", "TRUE"); props.put("j", "password"); props.put("k", "k1:v1,k2:v2"); props.put("l", "k1:v1"); Map<String, Object> vals = def.parse(props); assertEquals(1, vals.get("a")); assertEquals(2L, vals.get("b")); assertEquals("hello", vals.get("c")); assertEquals(asList("a", "b", "c"), vals.get("d")); assertEquals(42.5d, vals.get("e")); assertEquals(String.class, vals.get("f")); assertEquals(true, vals.get("g")); assertEquals(false, vals.get("h")); assertEquals(true, vals.get("i"));
// Path: config/src/main/java/io/confluent/common/config/types/Password.java // public class Password { // // public static final String HIDDEN = "[hidden]"; // // private final String value; // // /** // * Construct a new Password object // * @param value The value of a password // */ // public Password(String value) { // this.value = value; // } // // @Override // public int hashCode() { // return value.hashCode(); // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Password)) // return false; // Password other = (Password) obj; // return value.equals(other.value); // } // // /** // * Returns hidden password string // * // * @return hidden password string // */ // @Override // public String toString() { // return HIDDEN; // } // // /** // * Returns real password string // * // * @return real password string // */ // public String value() { // return value; // } // } // // Path: config/src/main/java/io/confluent/common/config/ConfigDef.java // public enum Type { // BOOLEAN, STRING, INT, LONG, DOUBLE, LIST, CLASS, PASSWORD, MAP // } // Path: config/src/test/java/io/confluent/common/config/ConfigDefTest.java import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import io.confluent.common.config.types.Password; import javax.xml.bind.DatatypeConverter; import static io.confluent.common.config.ConfigDef.Type; import static io.confluent.common.config.ConfigDef.Type.BOOLEAN; import static io.confluent.common.config.ConfigDef.Type.CLASS; import static io.confluent.common.config.ConfigDef.Type.DOUBLE; import static io.confluent.common.config.ConfigDef.Type.INT; import static io.confluent.common.config.ConfigDef.Type.LIST; import static io.confluent.common.config.ConfigDef.Type.LONG; import static io.confluent.common.config.ConfigDef.Type.STRING; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; .define("g", BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("h", Type.BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("i", Type.BOOLEAN, ConfigDef.Importance.HIGH, "docs") .define("j", Type.PASSWORD, ConfigDef.Importance.HIGH, "docs") .define("k", Type.MAP, ConfigDef.Importance.HIGH, "docs") .define("l", Type.MAP, ConfigDef.Importance.HIGH, "docs"); Properties props = new Properties(); props.put("a", "1 "); props.put("b", 2); props.put("d", " a , b, c"); props.put("e", 42.5d); props.put("f", String.class.getName()); props.put("g", "true"); props.put("h", "FalSE"); props.put("i", "TRUE"); props.put("j", "password"); props.put("k", "k1:v1,k2:v2"); props.put("l", "k1:v1"); Map<String, Object> vals = def.parse(props); assertEquals(1, vals.get("a")); assertEquals(2L, vals.get("b")); assertEquals("hello", vals.get("c")); assertEquals(asList("a", "b", "c"), vals.get("d")); assertEquals(42.5d, vals.get("e")); assertEquals(String.class, vals.get("f")); assertEquals(true, vals.get("g")); assertEquals(false, vals.get("h")); assertEquals(true, vals.get("i"));
assertEquals(new Password("password"), vals.get("j"));
Nightonke/TimeFleeting
src/com/timefleeting/app/EditPastActivity.java
// Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToBottomListener { // public void onScrollBottomListener(boolean isBottom); // } // // Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToTopListener { // public void onScrollTopListener(boolean isTop); // }
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; import com.fourmob.datetimepicker.date.DatePickerDialog; import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToBottomListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToTopListener; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; import android.text.style.ReplacementSpan; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.TextureView; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationSet; import android.view.animation.TranslateAnimation; import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast;
} } saveId = getIntent().getIntExtra("ID", -1); dateTextView.setText(dateTextView.getText().toString().substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(getIntent().getStringExtra("RemindTime")))); ((TextView)findViewById(R.id.past_edit_top_title)).setText(Language.getEditPastTitleLayoutText(isOld)); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(infoRemainTextView); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(editLogo); } else { dateString = createTimeString; dateTextView.setText(dateString.substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(dateString))); infoLinearLayout.getLayoutParams().height = 0; saveId = -1; } if (scrollView == null) { Log.d("TimeFleeting", "ISNULL"); } else {
// Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToBottomListener { // public void onScrollBottomListener(boolean isBottom); // } // // Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToTopListener { // public void onScrollTopListener(boolean isTop); // } // Path: src/com/timefleeting/app/EditPastActivity.java import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; import com.fourmob.datetimepicker.date.DatePickerDialog; import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToBottomListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToTopListener; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; import android.text.style.ReplacementSpan; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.TextureView; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationSet; import android.view.animation.TranslateAnimation; import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; } } saveId = getIntent().getIntExtra("ID", -1); dateTextView.setText(dateTextView.getText().toString().substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(getIntent().getStringExtra("RemindTime")))); ((TextView)findViewById(R.id.past_edit_top_title)).setText(Language.getEditPastTitleLayoutText(isOld)); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(infoRemainTextView); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(editLogo); } else { dateString = createTimeString; dateTextView.setText(dateString.substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(dateString))); infoLinearLayout.getLayoutParams().height = 0; saveId = -1; } if (scrollView == null) { Log.d("TimeFleeting", "ISNULL"); } else {
scrollView.setOnScrollToBottomLintener(new OnScrollToBottomListener() {
Nightonke/TimeFleeting
src/com/timefleeting/app/EditPastActivity.java
// Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToBottomListener { // public void onScrollBottomListener(boolean isBottom); // } // // Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToTopListener { // public void onScrollTopListener(boolean isTop); // }
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; import com.fourmob.datetimepicker.date.DatePickerDialog; import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToBottomListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToTopListener; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; import android.text.style.ReplacementSpan; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.TextureView; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationSet; import android.view.animation.TranslateAnimation; import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast;
.duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(infoRemainTextView); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(editLogo); } else { dateString = createTimeString; dateTextView.setText(dateString.substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(dateString))); infoLinearLayout.getLayoutParams().height = 0; saveId = -1; } if (scrollView == null) { Log.d("TimeFleeting", "ISNULL"); } else { scrollView.setOnScrollToBottomLintener(new OnScrollToBottomListener() { @Override public void onScrollBottomListener(boolean isBottom) { YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(check); } });
// Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToBottomListener { // public void onScrollBottomListener(boolean isBottom); // } // // Path: src/com/timefleeting/app/TopBottomScrollView.java // public interface OnScrollToTopListener { // public void onScrollTopListener(boolean isTop); // } // Path: src/com/timefleeting/app/EditPastActivity.java import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; import com.fourmob.datetimepicker.date.DatePickerDialog; import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToBottomListener; import com.timefleeting.app.TopBottomScrollView.OnScrollToTopListener; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; import android.text.style.ReplacementSpan; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.TextureView; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationSet; import android.view.animation.TranslateAnimation; import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(infoRemainTextView); YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(editLogo); } else { dateString = createTimeString; dateTextView.setText(dateString.substring(0, 10) + " " + Language.getDayOfWeekText(calDayOfWeek(dateString))); infoLinearLayout.getLayoutParams().height = 0; saveId = -1; } if (scrollView == null) { Log.d("TimeFleeting", "ISNULL"); } else { scrollView.setOnScrollToBottomLintener(new OnScrollToBottomListener() { @Override public void onScrollBottomListener(boolean isBottom) { YoYo.with(Techniques.Shake) .duration(2000) .delay(GlobalSettings.TIP_ANIMATION_DELAY) .playOn(check); } });
scrollView.setOnScrollToTopLintener(new OnScrollToTopListener() {
noear/Snacks
java/Snacks/src/main/java/noear/snacks/ONode.java
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // }
import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map;
package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // } // Path: java/Snacks/src/main/java/noear/snacks/ONode.java import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map; package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/
public ONode exp(Act1<ONode> expr){
noear/Snacks
java/Snacks/src/main/java/noear/snacks/ONode.java
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // }
import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map;
package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/ public ONode exp(Act1<ONode> expr){ expr.run(this); return this; }
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // } // Path: java/Snacks/src/main/java/noear/snacks/ONode.java import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map; package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/ public ONode exp(Act1<ONode> expr){ expr.run(this); return this; }
public <T> T map(T t, Act3<T,String,ONode> hander){
noear/Snacks
java/Snacks/src/main/java/noear/snacks/ONode.java
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // }
import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map;
package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/ public ONode exp(Act1<ONode> expr){ expr.run(this); return this; } public <T> T map(T t, Act3<T,String,ONode> hander){ if(isObject()){ _object.members.forEach((k,v)->{ hander.run(t,k,v); }); } if(isArray()){ _array.elements.forEach(v->{ hander.run(t,null,v); }); } return t; } public <T> void val(T val){ valSet(val); } //返回自己(重新设置基础类型的值)//不适合做为公有的 protected <T> ONode valSet(T val){ tryInitValue(); _value.set(val); return this; } public ONode(int value){ tryInitValue(); _value.set(value); } public ONode(long value){ tryInitValue(); _value.set(value); } public ONode(double value){ tryInitValue(); _value.set(value); } public ONode(String value){ tryInitValue(); _value.set(value); } public ONode(boolean value){ tryInitValue(); _value.set(value); } public ONode(Date value){ tryInitValue(); _value.set(value); } public boolean contains(String key) { if (_object == null || _type != ONodeType.Object) return false; else return _object.contains(key); } public int count() { if(isObject()) return _object.count(); if(isArray()) return _array.count(); return 0; } //======================== public double getDouble() { if (_value == null) return 0; else return _value.getDouble(); } public double getDouble(int scale) { double temp = getDouble(); if(temp==0) return 0; else return new BigDecimal(temp) .setScale(scale,BigDecimal.ROUND_HALF_UP) .doubleValue(); } public int getInt() { if (_value == null) return 0; else return _value.getInt(); } public boolean getBoolean() { if (_value == null) return false; else return _value.getBoolean(); } public Date getDate() { if (_value == null) return null; else return _value.getDate(); } public long getLong() { if (_value == null) return 0; else return _value.getLong(); } public String getString() { if (_value == null) { if(isObject()){ return toJson(); } if(isArray()){ return toJson(); } return ""; } else { return _value.getString(); } } public <T> T getModel(Class<T> cls){ return (T)OMapper.map(this,cls); } //============= //返回结果节点 public ONode get(int index) { tryInitArray(); if (_array.elements.size() > index) return _array.elements.get(index); else return null; } //返回结果节点,如果不存在则自动创建 public ONode get(String key) { tryInitObject(); if (_object.contains(key)) return _object.get(key); else { ONode temp = new ONode(); _object.set(key, temp); return temp; } } //返回自己 public ONode add(ONode value) { tryInitArray(); _array.add(value); return this; } //返回自己 public ONode addAll(ONode ary) { tryInitArray(); if (ary != null && ary.isArray()) { _array.elements.addAll(ary._array.elements); } return this; } //返回自己 public <T> ONode addAll(Iterable<T> ary){ tryInitArray(); if(ary!=null) { ary.forEach(m -> add(m)); } return this; } //返回自己
// Path: java/Snacks/src/main/java/noear/snacks/exts/Act1.java // public interface Act1<T> { // void run(T t); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act2.java // public interface Act2<T1,T2> { // void run(T1 t1,T2 t2); // } // // Path: java/Snacks/src/main/java/noear/snacks/exts/Act3.java // public interface Act3<T1,T2,T3> { // void run(T1 t1, T2 t2, T3 t3); // } // Path: java/Snacks/src/main/java/noear/snacks/ONode.java import noear.snacks.exts.Act1; import noear.snacks.exts.Act2; import noear.snacks.exts.Act3; import java.math.BigDecimal; import java.util.Date; import java.util.Map; package noear.snacks; /** * Created by noear on 14-6-11. */ public class ONode extends ONodeBase { public static String NULL_DEFAULT="null"; public static boolean BOOL_USE01=false; public static FormatHanlder TIME_FORMAT_ACTION=(date)->{ if (date == null) return "null"; else return "\"" + date.toString() + "\""; }; public static final ONode NULL = new ONode().asNull(); //============= public ONode(){ } /**输出自己,以供消费*/ public ONode exp(Act1<ONode> expr){ expr.run(this); return this; } public <T> T map(T t, Act3<T,String,ONode> hander){ if(isObject()){ _object.members.forEach((k,v)->{ hander.run(t,k,v); }); } if(isArray()){ _array.elements.forEach(v->{ hander.run(t,null,v); }); } return t; } public <T> void val(T val){ valSet(val); } //返回自己(重新设置基础类型的值)//不适合做为公有的 protected <T> ONode valSet(T val){ tryInitValue(); _value.set(val); return this; } public ONode(int value){ tryInitValue(); _value.set(value); } public ONode(long value){ tryInitValue(); _value.set(value); } public ONode(double value){ tryInitValue(); _value.set(value); } public ONode(String value){ tryInitValue(); _value.set(value); } public ONode(boolean value){ tryInitValue(); _value.set(value); } public ONode(Date value){ tryInitValue(); _value.set(value); } public boolean contains(String key) { if (_object == null || _type != ONodeType.Object) return false; else return _object.contains(key); } public int count() { if(isObject()) return _object.count(); if(isArray()) return _array.count(); return 0; } //======================== public double getDouble() { if (_value == null) return 0; else return _value.getDouble(); } public double getDouble(int scale) { double temp = getDouble(); if(temp==0) return 0; else return new BigDecimal(temp) .setScale(scale,BigDecimal.ROUND_HALF_UP) .doubleValue(); } public int getInt() { if (_value == null) return 0; else return _value.getInt(); } public boolean getBoolean() { if (_value == null) return false; else return _value.getBoolean(); } public Date getDate() { if (_value == null) return null; else return _value.getDate(); } public long getLong() { if (_value == null) return 0; else return _value.getLong(); } public String getString() { if (_value == null) { if(isObject()){ return toJson(); } if(isArray()){ return toJson(); } return ""; } else { return _value.getString(); } } public <T> T getModel(Class<T> cls){ return (T)OMapper.map(this,cls); } //============= //返回结果节点 public ONode get(int index) { tryInitArray(); if (_array.elements.size() > index) return _array.elements.get(index); else return null; } //返回结果节点,如果不存在则自动创建 public ONode get(String key) { tryInitObject(); if (_object.contains(key)) return _object.get(key); else { ONode temp = new ONode(); _object.set(key, temp); return temp; } } //返回自己 public ONode add(ONode value) { tryInitArray(); _array.add(value); return this; } //返回自己 public ONode addAll(ONode ary) { tryInitArray(); if (ary != null && ary.isArray()) { _array.elements.addAll(ary._array.elements); } return this; } //返回自己 public <T> ONode addAll(Iterable<T> ary){ tryInitArray(); if(ary!=null) { ary.forEach(m -> add(m)); } return this; } //返回自己
public <T> ONode addAll(Iterable<T> ary, Act2<ONode,T> handler) {
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/ScreenUtils.java // public class ScreenUtils // { // // // public static int[] getScreenSize(Context context, boolean useDeviceSize) // { // // int[] size = new int[2]; // // WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display d = w.getDefaultDisplay(); // DisplayMetrics metrics = new DisplayMetrics(); // d.getMetrics(metrics); // // since SDK_INT = 1; // int widthPixels = metrics.widthPixels; // int heightPixels = metrics.heightPixels; // // if (!useDeviceSize) // { // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) // try // { // widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); // heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); // } catch (Exception ignored) // { // } // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 17) // try // { // Point realSize = new Point(); // Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); // widthPixels = realSize.x; // heightPixels = realSize.y; // } catch (Exception ignored) // { // } // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // }
import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import com.desperado.customerlib.view.autolayout.utils.L; import com.desperado.customerlib.view.autolayout.utils.ScreenUtils;
{ return sIntance; } public int getScreenWidth() { return mScreenWidth; } public int getScreenHeight() { return mScreenHeight; } public int getDesignWidth() { return mDesignWidth; } public int getDesignHeight() { return mDesignHeight; } public void init(Context context) { getMetaData(context);
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/ScreenUtils.java // public class ScreenUtils // { // // // public static int[] getScreenSize(Context context, boolean useDeviceSize) // { // // int[] size = new int[2]; // // WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display d = w.getDefaultDisplay(); // DisplayMetrics metrics = new DisplayMetrics(); // d.getMetrics(metrics); // // since SDK_INT = 1; // int widthPixels = metrics.widthPixels; // int heightPixels = metrics.heightPixels; // // if (!useDeviceSize) // { // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) // try // { // widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); // heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); // } catch (Exception ignored) // { // } // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 17) // try // { // Point realSize = new Point(); // Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); // widthPixels = realSize.x; // heightPixels = realSize.y; // } catch (Exception ignored) // { // } // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import com.desperado.customerlib.view.autolayout.utils.L; import com.desperado.customerlib.view.autolayout.utils.ScreenUtils; { return sIntance; } public int getScreenWidth() { return mScreenWidth; } public int getScreenHeight() { return mScreenHeight; } public int getDesignWidth() { return mDesignWidth; } public int getDesignHeight() { return mDesignHeight; } public void init(Context context) { getMetaData(context);
int[] screenSize = ScreenUtils.getScreenSize(context, useDeviceSize);
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/ScreenUtils.java // public class ScreenUtils // { // // // public static int[] getScreenSize(Context context, boolean useDeviceSize) // { // // int[] size = new int[2]; // // WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display d = w.getDefaultDisplay(); // DisplayMetrics metrics = new DisplayMetrics(); // d.getMetrics(metrics); // // since SDK_INT = 1; // int widthPixels = metrics.widthPixels; // int heightPixels = metrics.heightPixels; // // if (!useDeviceSize) // { // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) // try // { // widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); // heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); // } catch (Exception ignored) // { // } // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 17) // try // { // Point realSize = new Point(); // Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); // widthPixels = realSize.x; // heightPixels = realSize.y; // } catch (Exception ignored) // { // } // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // }
import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import com.desperado.customerlib.view.autolayout.utils.L; import com.desperado.customerlib.view.autolayout.utils.ScreenUtils;
public int getScreenWidth() { return mScreenWidth; } public int getScreenHeight() { return mScreenHeight; } public int getDesignWidth() { return mDesignWidth; } public int getDesignHeight() { return mDesignHeight; } public void init(Context context) { getMetaData(context); int[] screenSize = ScreenUtils.getScreenSize(context, useDeviceSize); mScreenWidth = screenSize[0]; mScreenHeight = screenSize[1];
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/ScreenUtils.java // public class ScreenUtils // { // // // public static int[] getScreenSize(Context context, boolean useDeviceSize) // { // // int[] size = new int[2]; // // WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display d = w.getDefaultDisplay(); // DisplayMetrics metrics = new DisplayMetrics(); // d.getMetrics(metrics); // // since SDK_INT = 1; // int widthPixels = metrics.widthPixels; // int heightPixels = metrics.heightPixels; // // if (!useDeviceSize) // { // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) // try // { // widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); // heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); // } catch (Exception ignored) // { // } // // includes window decorations (statusbar bar/menu bar) // if (Build.VERSION.SDK_INT >= 17) // try // { // Point realSize = new Point(); // Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); // widthPixels = realSize.x; // heightPixels = realSize.y; // } catch (Exception ignored) // { // } // size[0] = widthPixels; // size[1] = heightPixels; // return size; // } // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import com.desperado.customerlib.view.autolayout.utils.L; import com.desperado.customerlib.view.autolayout.utils.ScreenUtils; public int getScreenWidth() { return mScreenWidth; } public int getScreenHeight() { return mScreenHeight; } public int getDesignWidth() { return mDesignWidth; } public int getDesignHeight() { return mDesignHeight; } public void init(Context context) { getMetaData(context); int[] screenSize = ScreenUtils.getScreenSize(context, useDeviceSize); mScreenWidth = screenSize[0]; mScreenHeight = screenSize[1];
L.e(" screenWidth =" + mScreenWidth + " ,screenHeight = " + mScreenHeight);
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // }
import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List;
package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表
private OnItemSelectedListener onItemSelectedListener = null;//选择事件接口
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // }
import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List;
package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表 private OnItemSelectedListener onItemSelectedListener = null;//选择事件接口
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表 private OnItemSelectedListener onItemSelectedListener = null;//选择事件接口
private OnLoopViewTouchListener onLoopViewTouchListener = null;//选择事件接口
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // }
import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List;
package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表 private OnItemSelectedListener onItemSelectedListener = null;//选择事件接口 private OnLoopViewTouchListener onLoopViewTouchListener = null;//选择事件接口
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoRelativeLayout.java // public class AutoRelativeLayout extends RelativeLayout // { // private final AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoRelativeLayout(Context context) // { // super(context); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs) // { // super(context, attrs); // } // // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyle) // { // super(context, attrs, defStyle); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // @Override // protected void onLayout(boolean changed, int left, int top, int right, int bottom) // { // super.onLayout(changed, left, top, right, bottom); // } // // // public static class LayoutParams extends RelativeLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // public LayoutParams(int width, int height) // { // super(width, height); // } // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemClickListener.java // public interface OnItemClickListener { // void onItemClick(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnItemSelectedListener.java // public interface OnItemSelectedListener { // void selected(int item, View view); // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/listener/OnLoopViewTouchListener.java // public interface OnLoopViewTouchListener { // void onTouch(MotionEvent event); // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/looprotaryswitchview/view/LoopRotarySwitchView.java import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import com.desperado.customerlib.view.autolayout.AutoRelativeLayout; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemClickListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnItemSelectedListener; import com.desperado.customerlib.view.looprotaryswitchview.listener.OnLoopViewTouchListener; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; package com.desperado.customerlib.view.looprotaryswitchview.view; /*** * 水平旋转轮播控件 */ public class LoopRotarySwitchView extends AutoRelativeLayout { private final static int LoopR = 200; private Context con; private ValueAnimator restAnimator = null;//回位动画 private ValueAnimator rAnimation = null;//半径动画 private GestureDetector mGestureDetector = null;//手势类 private int selectItem = 0;//当前选择项 private int size = 0;//个数 private float r = LoopR;//半径 private float BEISHU = 2.5f;//倍数 private float distance = BEISHU * r;//camera和观察的旋转物体距离, 距离越长,最大物体和最小物体比例越不明显 private float angle = 0;//角度 private float last_angle = 0; private boolean autoRotation = false;//自动旋转 private boolean touching = false;//正在触摸 private List<View> views = new ArrayList<View>();//子view引用列表 private OnItemSelectedListener onItemSelectedListener = null;//选择事件接口 private OnLoopViewTouchListener onLoopViewTouchListener = null;//选择事件接口
private OnItemClickListener onItemClickListener = null;//被点击的回调
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/verticalnoticationscrollbar/SwitchViewGroup.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoLinearLayout.java // public class AutoLinearLayout extends LinearLayout // { // // private AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoLinearLayout(Context context) { // super(context); // } // // public AutoLinearLayout(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public AutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // // @Override // protected void onLayout(boolean changed, int l, int t, int r, int b) // { // super.onLayout(changed, l, t, r, b); // } // // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // // public static class LayoutParams extends LinearLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // public LayoutParams(int width, int height) // { // super(width, height); // } // // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // } // // }
import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Scroller; import android.widget.TextView; import com.desperado.customerlib.R; import com.desperado.customerlib.view.autolayout.AutoLinearLayout; import java.util.ArrayList; import java.util.List;
package com.desperado.customerlib.view.verticalnoticationscrollbar; /* * * * 版 权 :@Copyright 北京优多鲜道科技有限公司版权所有 * * 作 者 :desperado * * 版 本 :1.0 * * 创建日期 :2016/5/26 15:51 * * 描 述 :垂直滚动条 * * 修订日期 : */ public class SwitchViewGroup extends RelativeLayout { private static final int DURATION = 10000;
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoLinearLayout.java // public class AutoLinearLayout extends LinearLayout // { // // private AutoLayoutHelper mHelper = new AutoLayoutHelper(this); // // public AutoLinearLayout(Context context) { // super(context); // } // // public AutoLinearLayout(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public AutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public AutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) // { // if (!isInEditMode()) // mHelper.adjustChildren(); // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // // // @Override // protected void onLayout(boolean changed, int l, int t, int r, int b) // { // super.onLayout(changed, l, t, r, b); // } // // // @Override // public LayoutParams generateLayoutParams(AttributeSet attrs) // { // return new LayoutParams(getContext(), attrs); // } // // // public static class LayoutParams extends LinearLayout.LayoutParams // implements AutoLayoutHelper.AutoLayoutParams // { // private AutoLayoutInfo mAutoLayoutInfo; // // public LayoutParams(Context c, AttributeSet attrs) // { // super(c, attrs); // mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs); // } // // @Override // public AutoLayoutInfo getAutoLayoutInfo() // { // return mAutoLayoutInfo; // } // // // public LayoutParams(int width, int height) // { // super(width, height); // } // // // public LayoutParams(ViewGroup.LayoutParams source) // { // super(source); // } // // public LayoutParams(MarginLayoutParams source) // { // super(source); // } // // } // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/verticalnoticationscrollbar/SwitchViewGroup.java import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Scroller; import android.widget.TextView; import com.desperado.customerlib.R; import com.desperado.customerlib.view.autolayout.AutoLinearLayout; import java.util.ArrayList; import java.util.List; package com.desperado.customerlib.view.verticalnoticationscrollbar; /* * * * 版 权 :@Copyright 北京优多鲜道科技有限公司版权所有 * * 作 者 :desperado * * 版 本 :1.0 * * 创建日期 :2016/5/26 15:51 * * 描 述 :垂直滚动条 * * 修订日期 : */ public class SwitchViewGroup extends RelativeLayout { private static final int DURATION = 10000;
private final AutoLinearLayout al_vertical_view_group_second;
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java // public class AutoUtils // { // // /** // * 会直接将view的LayoutParams上设置的width,height直接进行百分比处理 // * // * @param view // */ // public static void auto(View view) // { // autoSize(view); // autoPadding(view); // autoMargin(view); // } // // public static void autoMargin(View view) // { // if (!(view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) // return; // // ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_margin); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_margin, "Just Identify"); // // lp.leftMargin = getPercentWidthSize(lp.leftMargin); // lp.topMargin = getPercentHeightSize(lp.topMargin); // lp.rightMargin = getPercentWidthSize(lp.rightMargin); // lp.bottomMargin = getPercentHeightSize(lp.bottomMargin); // // } // // public static void autoPadding(View view) // { // Object tag = view.getTag(R.id.id_tag_autolayout_padding); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); // // int l = view.getPaddingLeft(); // int t = view.getPaddingTop(); // int r = view.getPaddingRight(); // int b = view.getPaddingBottom(); // // l = getPercentWidthSize(l); // t = getPercentHeightSize(t); // r = getPercentWidthSize(r); // b = getPercentHeightSize(b); // // view.setPadding(l, t, r, b); // } // // public static void autoSize(View view) // { // ViewGroup.LayoutParams lp = view.getLayoutParams(); // // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_size); // if (tag != null) return; // // view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); // // if (lp.width > 0) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // lp.width = (int) (lp.width * 1.0f / designWidth * screenWidth); // } // // if (lp.height > 0) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // lp.height = (int) (lp.height * 1.0f / designHeight * screenHeight); // } // } // // public static int getPercentWidthSize(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // return (int) (val * 1.0f / designWidth * screenWidth); // } // // // public static int getPercentWidthSizeBigger(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // int res = val * screenWidth; // if (res % designWidth == 0) // { // return res / designWidth; // } else // { // return res / designWidth + 1; // } // // } // // public static int getPercentHeightSizeBigger(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // int res = val * screenHeight; // if (res % designHeight == 0) // { // return res / designHeight; // } else // { // return res / designHeight + 1; // } // } // // public static int getPercentHeightSize(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // return (int) (val * 1.0f / designHeight * screenHeight); // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // }
import android.view.View; import com.desperado.customerlib.view.autolayout.utils.AutoUtils; import com.desperado.customerlib.view.autolayout.utils.L;
package com.desperado.customerlib.view.autolayout.attr; /** * Created by zhy on 15/12/4. */ public abstract class AutoAttr { protected int pxVal; protected int baseWidth; protected int baseHeight; /* protected boolean isBaseWidth; protected boolean isBaseDefault; public AutoAttr(int pxVal) { this.pxVal = pxVal; isBaseDefault = true; } public AutoAttr(int pxVal, boolean isBaseWidth) { this.pxVal = pxVal; this.isBaseWidth = isBaseWidth; } */ public AutoAttr(int pxVal, int baseWidth, int baseHeight) { this.pxVal = pxVal; this.baseWidth = baseWidth; this.baseHeight = baseHeight; } public void apply(View view) { boolean log = view.getTag() != null && view.getTag().toString().equals("auto"); if (log) {
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java // public class AutoUtils // { // // /** // * 会直接将view的LayoutParams上设置的width,height直接进行百分比处理 // * // * @param view // */ // public static void auto(View view) // { // autoSize(view); // autoPadding(view); // autoMargin(view); // } // // public static void autoMargin(View view) // { // if (!(view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) // return; // // ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_margin); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_margin, "Just Identify"); // // lp.leftMargin = getPercentWidthSize(lp.leftMargin); // lp.topMargin = getPercentHeightSize(lp.topMargin); // lp.rightMargin = getPercentWidthSize(lp.rightMargin); // lp.bottomMargin = getPercentHeightSize(lp.bottomMargin); // // } // // public static void autoPadding(View view) // { // Object tag = view.getTag(R.id.id_tag_autolayout_padding); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); // // int l = view.getPaddingLeft(); // int t = view.getPaddingTop(); // int r = view.getPaddingRight(); // int b = view.getPaddingBottom(); // // l = getPercentWidthSize(l); // t = getPercentHeightSize(t); // r = getPercentWidthSize(r); // b = getPercentHeightSize(b); // // view.setPadding(l, t, r, b); // } // // public static void autoSize(View view) // { // ViewGroup.LayoutParams lp = view.getLayoutParams(); // // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_size); // if (tag != null) return; // // view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); // // if (lp.width > 0) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // lp.width = (int) (lp.width * 1.0f / designWidth * screenWidth); // } // // if (lp.height > 0) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // lp.height = (int) (lp.height * 1.0f / designHeight * screenHeight); // } // } // // public static int getPercentWidthSize(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // return (int) (val * 1.0f / designWidth * screenWidth); // } // // // public static int getPercentWidthSizeBigger(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // int res = val * screenWidth; // if (res % designWidth == 0) // { // return res / designWidth; // } else // { // return res / designWidth + 1; // } // // } // // public static int getPercentHeightSizeBigger(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // int res = val * screenHeight; // if (res % designHeight == 0) // { // return res / designHeight; // } else // { // return res / designHeight + 1; // } // } // // public static int getPercentHeightSize(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // return (int) (val * 1.0f / designHeight * screenHeight); // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java import android.view.View; import com.desperado.customerlib.view.autolayout.utils.AutoUtils; import com.desperado.customerlib.view.autolayout.utils.L; package com.desperado.customerlib.view.autolayout.attr; /** * Created by zhy on 15/12/4. */ public abstract class AutoAttr { protected int pxVal; protected int baseWidth; protected int baseHeight; /* protected boolean isBaseWidth; protected boolean isBaseDefault; public AutoAttr(int pxVal) { this.pxVal = pxVal; isBaseDefault = true; } public AutoAttr(int pxVal, boolean isBaseWidth) { this.pxVal = pxVal; this.isBaseWidth = isBaseWidth; } */ public AutoAttr(int pxVal, int baseWidth, int baseHeight) { this.pxVal = pxVal; this.baseWidth = baseWidth; this.baseHeight = baseHeight; } public void apply(View view) { boolean log = view.getTag() != null && view.getTag().toString().equals("auto"); if (log) {
L.e(" pxVal = " + pxVal + " ," + this.getClass().getSimpleName());
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java // public class AutoUtils // { // // /** // * 会直接将view的LayoutParams上设置的width,height直接进行百分比处理 // * // * @param view // */ // public static void auto(View view) // { // autoSize(view); // autoPadding(view); // autoMargin(view); // } // // public static void autoMargin(View view) // { // if (!(view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) // return; // // ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_margin); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_margin, "Just Identify"); // // lp.leftMargin = getPercentWidthSize(lp.leftMargin); // lp.topMargin = getPercentHeightSize(lp.topMargin); // lp.rightMargin = getPercentWidthSize(lp.rightMargin); // lp.bottomMargin = getPercentHeightSize(lp.bottomMargin); // // } // // public static void autoPadding(View view) // { // Object tag = view.getTag(R.id.id_tag_autolayout_padding); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); // // int l = view.getPaddingLeft(); // int t = view.getPaddingTop(); // int r = view.getPaddingRight(); // int b = view.getPaddingBottom(); // // l = getPercentWidthSize(l); // t = getPercentHeightSize(t); // r = getPercentWidthSize(r); // b = getPercentHeightSize(b); // // view.setPadding(l, t, r, b); // } // // public static void autoSize(View view) // { // ViewGroup.LayoutParams lp = view.getLayoutParams(); // // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_size); // if (tag != null) return; // // view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); // // if (lp.width > 0) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // lp.width = (int) (lp.width * 1.0f / designWidth * screenWidth); // } // // if (lp.height > 0) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // lp.height = (int) (lp.height * 1.0f / designHeight * screenHeight); // } // } // // public static int getPercentWidthSize(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // return (int) (val * 1.0f / designWidth * screenWidth); // } // // // public static int getPercentWidthSizeBigger(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // int res = val * screenWidth; // if (res % designWidth == 0) // { // return res / designWidth; // } else // { // return res / designWidth + 1; // } // // } // // public static int getPercentHeightSizeBigger(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // int res = val * screenHeight; // if (res % designHeight == 0) // { // return res / designHeight; // } else // { // return res / designHeight + 1; // } // } // // public static int getPercentHeightSize(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // return (int) (val * 1.0f / designHeight * screenHeight); // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // }
import android.view.View; import com.desperado.customerlib.view.autolayout.utils.AutoUtils; import com.desperado.customerlib.view.autolayout.utils.L;
int val; if (useDefault()) { val = defaultBaseWidth() ? getPercentWidthSize() : getPercentHeightSize(); if (log) { L.e(" useDefault val= " + val); } } else if (baseWidth()) { val = getPercentWidthSize(); if (log) { L.e(" baseWidth val= " + val); } } else { val = getPercentHeightSize(); if (log) { L.e(" baseHeight val= " + val); } } val = Math.max(val, 1);//for very thin divider execute(view, val); } protected int getPercentWidthSize() {
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java // public class AutoUtils // { // // /** // * 会直接将view的LayoutParams上设置的width,height直接进行百分比处理 // * // * @param view // */ // public static void auto(View view) // { // autoSize(view); // autoPadding(view); // autoMargin(view); // } // // public static void autoMargin(View view) // { // if (!(view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) // return; // // ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_margin); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_margin, "Just Identify"); // // lp.leftMargin = getPercentWidthSize(lp.leftMargin); // lp.topMargin = getPercentHeightSize(lp.topMargin); // lp.rightMargin = getPercentWidthSize(lp.rightMargin); // lp.bottomMargin = getPercentHeightSize(lp.bottomMargin); // // } // // public static void autoPadding(View view) // { // Object tag = view.getTag(R.id.id_tag_autolayout_padding); // if (tag != null) return; // view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); // // int l = view.getPaddingLeft(); // int t = view.getPaddingTop(); // int r = view.getPaddingRight(); // int b = view.getPaddingBottom(); // // l = getPercentWidthSize(l); // t = getPercentHeightSize(t); // r = getPercentWidthSize(r); // b = getPercentHeightSize(b); // // view.setPadding(l, t, r, b); // } // // public static void autoSize(View view) // { // ViewGroup.LayoutParams lp = view.getLayoutParams(); // // if (lp == null) return; // // Object tag = view.getTag(R.id.id_tag_autolayout_size); // if (tag != null) return; // // view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); // // if (lp.width > 0) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // lp.width = (int) (lp.width * 1.0f / designWidth * screenWidth); // } // // if (lp.height > 0) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // lp.height = (int) (lp.height * 1.0f / designHeight * screenHeight); // } // } // // public static int getPercentWidthSize(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // return (int) (val * 1.0f / designWidth * screenWidth); // } // // // public static int getPercentWidthSizeBigger(int val) // { // int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth(); // int designWidth = AutoLayoutConifg.getInstance().getDesignWidth(); // // int res = val * screenWidth; // if (res % designWidth == 0) // { // return res / designWidth; // } else // { // return res / designWidth + 1; // } // // } // // public static int getPercentHeightSizeBigger(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // int res = val * screenHeight; // if (res % designHeight == 0) // { // return res / designHeight; // } else // { // return res / designHeight + 1; // } // } // // public static int getPercentHeightSize(int val) // { // int screenHeight = AutoLayoutConifg.getInstance().getScreenHeight(); // int designHeight = AutoLayoutConifg.getInstance().getDesignHeight(); // // return (int) (val * 1.0f / designHeight * screenHeight); // } // } // // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/L.java // public class L // { // public static boolean debug = false; // private static final String TAG = "AUTO_LAYOUT"; // // public static void e(String msg) // { // if (debug) // { // Log.e(TAG, msg); // } // } // // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java import android.view.View; import com.desperado.customerlib.view.autolayout.utils.AutoUtils; import com.desperado.customerlib.view.autolayout.utils.L; int val; if (useDefault()) { val = defaultBaseWidth() ? getPercentWidthSize() : getPercentHeightSize(); if (log) { L.e(" useDefault val= " + val); } } else if (baseWidth()) { val = getPercentWidthSize(); if (log) { L.e(" baseWidth val= " + val); } } else { val = getPercentHeightSize(); if (log) { L.e(" baseHeight val= " + val); } } val = Math.max(val, 1);//for very thin divider execute(view, val); } protected int getPercentWidthSize() {
return AutoUtils.getPercentWidthSizeBigger(pxVal);
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoLayoutInfo.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java // public abstract class AutoAttr // { // protected int pxVal; // protected int baseWidth; // protected int baseHeight; // // /* // protected boolean isBaseWidth; // protected boolean isBaseDefault; // // public AutoAttr(int pxVal) // { // this.pxVal = pxVal; // isBaseDefault = true; // } // // public AutoAttr(int pxVal, boolean isBaseWidth) // { // this.pxVal = pxVal; // this.isBaseWidth = isBaseWidth; // } // */ // // public AutoAttr(int pxVal, int baseWidth, int baseHeight) // { // this.pxVal = pxVal; // this.baseWidth = baseWidth; // this.baseHeight = baseHeight; // } // // public void apply(View view) // { // // boolean log = view.getTag() != null && view.getTag().toString().equals("auto"); // // if (log) // { // L.e(" pxVal = " + pxVal + " ," + this.getClass().getSimpleName()); // } // int val; // if (useDefault()) // { // val = defaultBaseWidth() ? getPercentWidthSize() : getPercentHeightSize(); // if (log) // { // L.e(" useDefault val= " + val); // } // } else if (baseWidth()) // { // val = getPercentWidthSize(); // if (log) // { // L.e(" baseWidth val= " + val); // } // } else // { // val = getPercentHeightSize(); // if (log) // { // L.e(" baseHeight val= " + val); // } // } // // val = Math.max(val, 1);//for very thin divider // execute(view, val); // } // // protected int getPercentWidthSize() // { // return AutoUtils.getPercentWidthSizeBigger(pxVal); // } // // protected int getPercentHeightSize() // { // return AutoUtils.getPercentHeightSizeBigger(pxVal); // } // // // protected boolean baseWidth() // { // return contains(baseWidth, attrVal()); // } // // protected boolean useDefault() // { // return !contains(baseHeight, attrVal()) && !contains(baseWidth, attrVal()); // } // // protected boolean contains(int baseVal, int flag) // { // return (baseVal & flag) != 0; // } // // protected abstract int attrVal(); // // protected abstract boolean defaultBaseWidth(); // // protected abstract void execute(View view, int val); // // @Override // public String toString() // { // return "AutoAttr{" + // "pxVal=" + pxVal + // ", baseWidth=" + baseWidth() + // ", defaultBaseWidth=" + defaultBaseWidth() + // '}'; // } // }
import android.view.View; import com.desperado.customerlib.view.autolayout.attr.AutoAttr; import java.util.ArrayList; import java.util.List;
package com.desperado.customerlib.view.autolayout; public class AutoLayoutInfo {
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/attr/AutoAttr.java // public abstract class AutoAttr // { // protected int pxVal; // protected int baseWidth; // protected int baseHeight; // // /* // protected boolean isBaseWidth; // protected boolean isBaseDefault; // // public AutoAttr(int pxVal) // { // this.pxVal = pxVal; // isBaseDefault = true; // } // // public AutoAttr(int pxVal, boolean isBaseWidth) // { // this.pxVal = pxVal; // this.isBaseWidth = isBaseWidth; // } // */ // // public AutoAttr(int pxVal, int baseWidth, int baseHeight) // { // this.pxVal = pxVal; // this.baseWidth = baseWidth; // this.baseHeight = baseHeight; // } // // public void apply(View view) // { // // boolean log = view.getTag() != null && view.getTag().toString().equals("auto"); // // if (log) // { // L.e(" pxVal = " + pxVal + " ," + this.getClass().getSimpleName()); // } // int val; // if (useDefault()) // { // val = defaultBaseWidth() ? getPercentWidthSize() : getPercentHeightSize(); // if (log) // { // L.e(" useDefault val= " + val); // } // } else if (baseWidth()) // { // val = getPercentWidthSize(); // if (log) // { // L.e(" baseWidth val= " + val); // } // } else // { // val = getPercentHeightSize(); // if (log) // { // L.e(" baseHeight val= " + val); // } // } // // val = Math.max(val, 1);//for very thin divider // execute(view, val); // } // // protected int getPercentWidthSize() // { // return AutoUtils.getPercentWidthSizeBigger(pxVal); // } // // protected int getPercentHeightSize() // { // return AutoUtils.getPercentHeightSizeBigger(pxVal); // } // // // protected boolean baseWidth() // { // return contains(baseWidth, attrVal()); // } // // protected boolean useDefault() // { // return !contains(baseHeight, attrVal()) && !contains(baseWidth, attrVal()); // } // // protected boolean contains(int baseVal, int flag) // { // return (baseVal & flag) != 0; // } // // protected abstract int attrVal(); // // protected abstract boolean defaultBaseWidth(); // // protected abstract void execute(View view, int val); // // @Override // public String toString() // { // return "AutoAttr{" + // "pxVal=" + pxVal + // ", baseWidth=" + baseWidth() + // ", defaultBaseWidth=" + defaultBaseWidth() + // '}'; // } // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/AutoLayoutInfo.java import android.view.View; import com.desperado.customerlib.view.autolayout.attr.AutoAttr; import java.util.ArrayList; import java.util.List; package com.desperado.customerlib.view.autolayout; public class AutoLayoutInfo {
private List<AutoAttr> autoAttrs = new ArrayList<>();
foreverxiongtao/CustomerLib
customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java // public class AutoLayoutConifg // { // // private static AutoLayoutConifg sIntance = new AutoLayoutConifg(); // // // private static final String KEY_DESIGN_WIDTH = "design_width"; // private static final String KEY_DESIGN_HEIGHT = "design_height"; // // private int mScreenWidth; // private int mScreenHeight; // // private int mDesignWidth; // private int mDesignHeight; // // private boolean useDeviceSize; // // // private AutoLayoutConifg() // { // } // // public void checkParams() // { // if (mDesignHeight <= 0 || mDesignWidth <= 0) // { // throw new RuntimeException( // "you must set " + KEY_DESIGN_WIDTH + " and " + KEY_DESIGN_HEIGHT + " in your manifest file."); // } // } // // public AutoLayoutConifg useDeviceSize() // { // useDeviceSize = true; // return this; // } // // // public static AutoLayoutConifg getInstance() // { // return sIntance; // } // // // public int getScreenWidth() // { // return mScreenWidth; // } // // public int getScreenHeight() // { // return mScreenHeight; // } // // public int getDesignWidth() // { // return mDesignWidth; // } // // public int getDesignHeight() // { // return mDesignHeight; // } // // // public void init(Context context) // { // getMetaData(context); // // int[] screenSize = ScreenUtils.getScreenSize(context, useDeviceSize); // mScreenWidth = screenSize[0]; // mScreenHeight = screenSize[1]; // L.e(" screenWidth =" + mScreenWidth + " ,screenHeight = " + mScreenHeight); // } // // private void getMetaData(Context context) // { // PackageManager packageManager = context.getPackageManager(); // ApplicationInfo applicationInfo; // try // { // applicationInfo = packageManager.getApplicationInfo(context // .getPackageName(), PackageManager.GET_META_DATA); // if (applicationInfo != null && applicationInfo.metaData != null) // { // mDesignWidth = (int) applicationInfo.metaData.get(KEY_DESIGN_WIDTH); // mDesignHeight = (int) applicationInfo.metaData.get(KEY_DESIGN_HEIGHT); // } // } catch (PackageManager.NameNotFoundException e) // { // throw new RuntimeException( // "you must set " + KEY_DESIGN_WIDTH + " and " + KEY_DESIGN_HEIGHT + " in your manifest file.", e); // } // // L.e(" designWidth =" + mDesignWidth + " , designHeight = " + mDesignHeight); // } // // // }
import android.view.View; import android.view.ViewGroup; import com.desperado.customerlib.R; import com.desperado.customerlib.view.autolayout.config.AutoLayoutConifg;
Object tag = view.getTag(R.id.id_tag_autolayout_padding); if (tag != null) return; view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); int l = view.getPaddingLeft(); int t = view.getPaddingTop(); int r = view.getPaddingRight(); int b = view.getPaddingBottom(); l = getPercentWidthSize(l); t = getPercentHeightSize(t); r = getPercentWidthSize(r); b = getPercentHeightSize(b); view.setPadding(l, t, r, b); } public static void autoSize(View view) { ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp == null) return; Object tag = view.getTag(R.id.id_tag_autolayout_size); if (tag != null) return; view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); if (lp.width > 0) {
// Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/config/AutoLayoutConifg.java // public class AutoLayoutConifg // { // // private static AutoLayoutConifg sIntance = new AutoLayoutConifg(); // // // private static final String KEY_DESIGN_WIDTH = "design_width"; // private static final String KEY_DESIGN_HEIGHT = "design_height"; // // private int mScreenWidth; // private int mScreenHeight; // // private int mDesignWidth; // private int mDesignHeight; // // private boolean useDeviceSize; // // // private AutoLayoutConifg() // { // } // // public void checkParams() // { // if (mDesignHeight <= 0 || mDesignWidth <= 0) // { // throw new RuntimeException( // "you must set " + KEY_DESIGN_WIDTH + " and " + KEY_DESIGN_HEIGHT + " in your manifest file."); // } // } // // public AutoLayoutConifg useDeviceSize() // { // useDeviceSize = true; // return this; // } // // // public static AutoLayoutConifg getInstance() // { // return sIntance; // } // // // public int getScreenWidth() // { // return mScreenWidth; // } // // public int getScreenHeight() // { // return mScreenHeight; // } // // public int getDesignWidth() // { // return mDesignWidth; // } // // public int getDesignHeight() // { // return mDesignHeight; // } // // // public void init(Context context) // { // getMetaData(context); // // int[] screenSize = ScreenUtils.getScreenSize(context, useDeviceSize); // mScreenWidth = screenSize[0]; // mScreenHeight = screenSize[1]; // L.e(" screenWidth =" + mScreenWidth + " ,screenHeight = " + mScreenHeight); // } // // private void getMetaData(Context context) // { // PackageManager packageManager = context.getPackageManager(); // ApplicationInfo applicationInfo; // try // { // applicationInfo = packageManager.getApplicationInfo(context // .getPackageName(), PackageManager.GET_META_DATA); // if (applicationInfo != null && applicationInfo.metaData != null) // { // mDesignWidth = (int) applicationInfo.metaData.get(KEY_DESIGN_WIDTH); // mDesignHeight = (int) applicationInfo.metaData.get(KEY_DESIGN_HEIGHT); // } // } catch (PackageManager.NameNotFoundException e) // { // throw new RuntimeException( // "you must set " + KEY_DESIGN_WIDTH + " and " + KEY_DESIGN_HEIGHT + " in your manifest file.", e); // } // // L.e(" designWidth =" + mDesignWidth + " , designHeight = " + mDesignHeight); // } // // // } // Path: customerlib/src/main/java/com/desperado/customerlib/view/autolayout/utils/AutoUtils.java import android.view.View; import android.view.ViewGroup; import com.desperado.customerlib.R; import com.desperado.customerlib.view.autolayout.config.AutoLayoutConifg; Object tag = view.getTag(R.id.id_tag_autolayout_padding); if (tag != null) return; view.setTag(R.id.id_tag_autolayout_padding, "Just Identify"); int l = view.getPaddingLeft(); int t = view.getPaddingTop(); int r = view.getPaddingRight(); int b = view.getPaddingBottom(); l = getPercentWidthSize(l); t = getPercentHeightSize(t); r = getPercentWidthSize(r); b = getPercentHeightSize(b); view.setPadding(l, t, r, b); } public static void autoSize(View view) { ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp == null) return; Object tag = view.getTag(R.id.id_tag_autolayout_size); if (tag != null) return; view.setTag(R.id.id_tag_autolayout_size, "Just Identify"); if (lp.width > 0) {
int screenWidth = AutoLayoutConifg.getInstance().getScreenWidth();
richmartin/detox
src/test/java/com/moozvine/detox/BuilderCopyConstructorTest.java
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // }
import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.SimpleTypeBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals;
package com.moozvine.detox; public class BuilderCopyConstructorTest { @Rule public ExpectedException expected = ExpectedException.none(); @Test public void simpleTypeCopyModifyingFirstField() {
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // Path: src/test/java/com/moozvine/detox/BuilderCopyConstructorTest.java import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.SimpleTypeBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals; package com.moozvine.detox; public class BuilderCopyConstructorTest { @Rule public ExpectedException expected = ExpectedException.none(); @Test public void simpleTypeCopyModifyingFirstField() {
final SimpleType toCopy = SimpleTypeBuilder.newBuilder()
richmartin/detox
src/main/java/com/moozvine/detox/processor/Util.java
// Path: src/main/java/com/moozvine/detox/Serializable.java // public interface Serializable { // }
import com.moozvine.detox.Serializable; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; import java.util.Set;
public static boolean isClassOrInterface(final TypeMirror value) { return value.getKind().equals(TypeKind.DECLARED); } static boolean hasValueOfMethod(final TypeMirror value) { if (!isClassOrInterface(value)) { return false; } final DeclaredType declared = (DeclaredType) value; final TypeElement typeElement = (TypeElement) declared.asElement(); for (final Element element : typeElement.getEnclosedElements()) { if (element.getKind().equals(ElementKind.METHOD)) { final ExecutableElement executableElement = (ExecutableElement) element; if (executableElement.getSimpleName().toString().equals("valueOf") && executableElement.getReturnType().toString().equals(value.toString()) && executableElement.getParameters().size() == 1 && executableElement.getParameters().get(0).asType().toString().equals("java.lang.String")) { return true; } } } return false; } static boolean isSerializable(final TypeMirror value) { if (!value.getKind().equals(TypeKind.DECLARED)) { return false; } for (final DeclaredType anInterface : allInterfacesOf((DeclaredType) value)) {
// Path: src/main/java/com/moozvine/detox/Serializable.java // public interface Serializable { // } // Path: src/main/java/com/moozvine/detox/processor/Util.java import com.moozvine.detox.Serializable; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; import java.util.Set; public static boolean isClassOrInterface(final TypeMirror value) { return value.getKind().equals(TypeKind.DECLARED); } static boolean hasValueOfMethod(final TypeMirror value) { if (!isClassOrInterface(value)) { return false; } final DeclaredType declared = (DeclaredType) value; final TypeElement typeElement = (TypeElement) declared.asElement(); for (final Element element : typeElement.getEnclosedElements()) { if (element.getKind().equals(ElementKind.METHOD)) { final ExecutableElement executableElement = (ExecutableElement) element; if (executableElement.getSimpleName().toString().equals("valueOf") && executableElement.getReturnType().toString().equals(value.toString()) && executableElement.getParameters().size() == 1 && executableElement.getParameters().get(0).asType().toString().equals("java.lang.String")) { return true; } } } return false; } static boolean isSerializable(final TypeMirror value) { if (!value.getKind().equals(TypeKind.DECLARED)) { return false; } for (final DeclaredType anInterface : allInterfacesOf((DeclaredType) value)) {
if (String.valueOf(anInterface).equals(Serializable.class.getName())) {
richmartin/detox
src/test/java/com/moozvine/detox/BuildlerToStringTest.java
// Path: src/test/java/com/moozvine/detox/testtypes/withids/SimpleTypeWithACompoundId.java // @GenerateDTO // public interface SimpleTypeWithACompoundId extends Serializable { // @Id int getIntegerId(); // @Id String getStringId(); // String getNotId(); // }
import com.google.common.collect.ImmutableSet; import com.moozvine.detox.testtypes.*; import com.moozvine.detox.testtypes.withids.SimpleTypeWithACompoundId; import com.moozvine.detox.testtypes.withids.SimpleTypeWithACompoundIdBuilder; import org.junit.Test; import java.util.Date; import java.util.Set; import static org.junit.Assert.assertEquals;
.withAnInt(2) .build(); final String expected = "{\n" + " \"serializedType\": \"com.moozvine.detox.testtypes.SimpleType\",\n" + " \"someString\": \"one\",\n" + " \"anInt\": 2\n" + "}"; assertEquivalent(expected, built.toString()); } @Test public void copiedTypeShouldRenderToString() { final SimpleType toCopy = SimpleTypeBuilder.newBuilder() .withSomeString("one") .withAnInt(2) .build(); final SimpleType copied = SimpleTypeBuilder.copyOf(toCopy).build(); final String expected = "{\n" + " \"serializedType\": \"com.moozvine.detox.testtypes.SimpleType\",\n" + " \"someString\": \"one\",\n" + " \"anInt\": 2\n" + "}"; assertEquivalent(expected, copied.toString()); } @Test public void typeWithIDShouldRenderToString() {
// Path: src/test/java/com/moozvine/detox/testtypes/withids/SimpleTypeWithACompoundId.java // @GenerateDTO // public interface SimpleTypeWithACompoundId extends Serializable { // @Id int getIntegerId(); // @Id String getStringId(); // String getNotId(); // } // Path: src/test/java/com/moozvine/detox/BuildlerToStringTest.java import com.google.common.collect.ImmutableSet; import com.moozvine.detox.testtypes.*; import com.moozvine.detox.testtypes.withids.SimpleTypeWithACompoundId; import com.moozvine.detox.testtypes.withids.SimpleTypeWithACompoundIdBuilder; import org.junit.Test; import java.util.Date; import java.util.Set; import static org.junit.Assert.assertEquals; .withAnInt(2) .build(); final String expected = "{\n" + " \"serializedType\": \"com.moozvine.detox.testtypes.SimpleType\",\n" + " \"someString\": \"one\",\n" + " \"anInt\": 2\n" + "}"; assertEquivalent(expected, built.toString()); } @Test public void copiedTypeShouldRenderToString() { final SimpleType toCopy = SimpleTypeBuilder.newBuilder() .withSomeString("one") .withAnInt(2) .build(); final SimpleType copied = SimpleTypeBuilder.copyOf(toCopy).build(); final String expected = "{\n" + " \"serializedType\": \"com.moozvine.detox.testtypes.SimpleType\",\n" + " \"someString\": \"one\",\n" + " \"anInt\": 2\n" + "}"; assertEquivalent(expected, copied.toString()); } @Test public void typeWithIDShouldRenderToString() {
final SimpleTypeWithACompoundId built = SimpleTypeWithACompoundIdBuilder.newBuilder()
richmartin/detox
src/main/java/com/moozvine/detox/processor/DtoSynthesiser.java
// Path: src/main/java/com/moozvine/detox/processor/Util.java // static boolean hasValueOfMethod(final TypeMirror value) { // if (!isClassOrInterface(value)) { // return false; // } // final DeclaredType declared = (DeclaredType) value; // final TypeElement typeElement = (TypeElement) declared.asElement(); // for (final Element element : typeElement.getEnclosedElements()) { // if (element.getKind().equals(ElementKind.METHOD)) { // final ExecutableElement executableElement = (ExecutableElement) element; // if (executableElement.getSimpleName().toString().equals("valueOf") // && executableElement.getReturnType().toString().equals(value.toString()) // && executableElement.getParameters().size() == 1 // && executableElement.getParameters().get(0).asType().toString().equals("java.lang.String")) { // return true; // } // } // } // return false; // }
import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.DeclaredType; import javax.tools.JavaFileObject; import java.io.BufferedWriter; import java.io.IOException; import java.util.List; import static com.moozvine.detox.processor.Util.hasValueOfMethod;
case COLLECTION: // TODO: Support collections of collections. throw new IllegalArgumentException("StringMaps of collections are not yet supported. Field: " + member.getFieldName()); default: throw new IllegalArgumentException("Cannot have a Map<String,T> with T of type " + mapMemberType + ". Field: " + member.getFieldName()); } w.append(String.format("" + " Map<%1$s, %2$s> %3$sBuilder = new HashMap<>(); \n" + " if(json.has(\"%7$s\")) { \n" + " JSONObject %3$sObj = json.getJSONObject(\"%7$s\"); \n" + " for(String key : (Set<String>)%3$sObj.keySet()) { \n" + " %3$sBuilder.put(%4$s, \n" + " %3$sObj.isNull(key) ? null : %6$s); \n" + " } \n" + " } \n" + " %3$s = Collections.unmodifiableMap(%3$sBuilder); \n" + " \n", stringMapType.getKeyType(), // 1 mapMemberDeclaredType, // 2 member.getFieldName(), // 3 keyFromStringConverter, // 4 "unused", // 5 elementConverter, // 6 member.getJsonFieldName() // 7 ));
// Path: src/main/java/com/moozvine/detox/processor/Util.java // static boolean hasValueOfMethod(final TypeMirror value) { // if (!isClassOrInterface(value)) { // return false; // } // final DeclaredType declared = (DeclaredType) value; // final TypeElement typeElement = (TypeElement) declared.asElement(); // for (final Element element : typeElement.getEnclosedElements()) { // if (element.getKind().equals(ElementKind.METHOD)) { // final ExecutableElement executableElement = (ExecutableElement) element; // if (executableElement.getSimpleName().toString().equals("valueOf") // && executableElement.getReturnType().toString().equals(value.toString()) // && executableElement.getParameters().size() == 1 // && executableElement.getParameters().get(0).asType().toString().equals("java.lang.String")) { // return true; // } // } // } // return false; // } // Path: src/main/java/com/moozvine/detox/processor/DtoSynthesiser.java import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.DeclaredType; import javax.tools.JavaFileObject; import java.io.BufferedWriter; import java.io.IOException; import java.util.List; import static com.moozvine.detox.processor.Util.hasValueOfMethod; case COLLECTION: // TODO: Support collections of collections. throw new IllegalArgumentException("StringMaps of collections are not yet supported. Field: " + member.getFieldName()); default: throw new IllegalArgumentException("Cannot have a Map<String,T> with T of type " + mapMemberType + ". Field: " + member.getFieldName()); } w.append(String.format("" + " Map<%1$s, %2$s> %3$sBuilder = new HashMap<>(); \n" + " if(json.has(\"%7$s\")) { \n" + " JSONObject %3$sObj = json.getJSONObject(\"%7$s\"); \n" + " for(String key : (Set<String>)%3$sObj.keySet()) { \n" + " %3$sBuilder.put(%4$s, \n" + " %3$sObj.isNull(key) ? null : %6$s); \n" + " } \n" + " } \n" + " %3$s = Collections.unmodifiableMap(%3$sBuilder); \n" + " \n", stringMapType.getKeyType(), // 1 mapMemberDeclaredType, // 2 member.getFieldName(), // 3 keyFromStringConverter, // 4 "unused", // 5 elementConverter, // 6 member.getJsonFieldName() // 7 ));
} else if (hasValueOfMethod(member.getTypeMirror())) {
richmartin/detox
src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // }
import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence;
package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception {
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // } // Path: src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence; package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception {
final SimpleType simpleType = generator.generate(SimpleType.class);
richmartin/detox
src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // }
import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence;
package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception { final SimpleType simpleType = generator.generate(SimpleType.class);
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // } // Path: src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence; package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception { final SimpleType simpleType = generator.generate(SimpleType.class);
assertJsonEquivalence(
richmartin/detox
src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // }
import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence;
package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception { final SimpleType simpleType = generator.generate(SimpleType.class); assertJsonEquivalence( "{\"serializedType\":\"com.moozvine.detox.testtypes.SimpleType\",\"someString\":\"some string\",\"anInt\":1234}", serializationService.serialize(simpleType)); } @Test public void withAddedValueGeneratorForClass() throws Exception { generator.setValueGeneratorForClass(Date.class, new ValueGenerator<Date>() { @Nullable @Override public Date apply(final String input) { return new Date(0); } });
// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java // @GenerateDTO // public interface TypeWithOptionalFields extends Serializable { // String getFirstRequiredField(); // Date getSecondRequiredField(); // @Nullable Integer getFirstOptionalField(); // @Nullable Float getSecondOptionalField(); // } // // Path: src/test/java/com/moozvine/detox/JsonTestUtil.java // public static void assertJsonEquivalence(final String left, final String right) { // final JSONObject leftObj = new JSONObject(left); // final JSONObject rightObj = new JSONObject(right); // assertJsonEquivalence(leftObj, rightObj, null); // } // Path: src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.TypeWithOptionalFields; import org.junit.Test; import javax.annotation.Nullable; import java.util.Date; import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence; package com.moozvine.detox; public class TestInstanceGeneratorTest { private final TestInstanceGenerator generator = new TestInstanceGenerator(); private final SerializationService serializationService = new AbstractSerializationService() { { registerSerializer(new StringSerializer<Date>(Date.class) { @Override public Date fromString(final String value) throws DeserializationException { return new Date(Long.parseLong(value)); } @Override public String toJson(final Date value) { return String.valueOf(value.getTime()); } }); } }; @Test public void simpleTest() throws Exception { final SimpleType simpleType = generator.generate(SimpleType.class); assertJsonEquivalence( "{\"serializedType\":\"com.moozvine.detox.testtypes.SimpleType\",\"someString\":\"some string\",\"anInt\":1234}", serializationService.serialize(simpleType)); } @Test public void withAddedValueGeneratorForClass() throws Exception { generator.setValueGeneratorForClass(Date.class, new ValueGenerator<Date>() { @Nullable @Override public Date apply(final String input) { return new Date(0); } });
final TypeWithOptionalFields object = generator.generate(TypeWithOptionalFields.class);
richmartin/detox
src/test/java/com/moozvine/detox/SerializationServiceWithComplexHierarchies.java
// Path: src/test/java/com/moozvine/detox/testtypes/AnotherSimpleType.java // @GenerateDTO // public interface AnotherSimpleType extends Serializable { // String getSomeOtherString(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // }
import com.google.common.collect.ImmutableList; import com.moozvine.detox.testtypes.AnotherSimpleType; import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.complexhierarchies.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
.withValue("user value") .build()) .build(); final String serializedUser = service.serialize(userToSerialize); final User deserializedUser = (User) service.deserialize(serializedUser); assertEquals(userToSerialize.getToken().getValue(), deserializedUser.getToken().getValue()); final FooUser fooUserToSerialize = FooUserBuilder.newBuilder() .withToken(FooTokenBuilder.newBuilder() .withValue("foo user value") .withFooCount(2) .build()) .build(); final String serializedFooUser = service.serialize(fooUserToSerialize, FooUser.class); assertThat(serializedFooUser, containsString(FooUser.class.getName())); final FooUser deserializedFooUser = (FooUser) service.deserialize(serializedFooUser); assertEquals(fooUserToSerialize.getToken().getFooCount(), deserializedFooUser.getToken().getFooCount()); assertEquals(fooUserToSerialize.getToken().getValue(), deserializedFooUser.getToken().getValue()); } /** * Compare with {@link FailureTests#serializingAnObjectWithMultipleGenerateDTOInterfacesToUnspecifiedInterface()} */ @Test public void serializingAnObjectWithMultipleGenerateDTOInterfacesToSpecifiedInterface() throws Exception {
// Path: src/test/java/com/moozvine/detox/testtypes/AnotherSimpleType.java // @GenerateDTO // public interface AnotherSimpleType extends Serializable { // String getSomeOtherString(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // Path: src/test/java/com/moozvine/detox/SerializationServiceWithComplexHierarchies.java import com.google.common.collect.ImmutableList; import com.moozvine.detox.testtypes.AnotherSimpleType; import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.complexhierarchies.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; .withValue("user value") .build()) .build(); final String serializedUser = service.serialize(userToSerialize); final User deserializedUser = (User) service.deserialize(serializedUser); assertEquals(userToSerialize.getToken().getValue(), deserializedUser.getToken().getValue()); final FooUser fooUserToSerialize = FooUserBuilder.newBuilder() .withToken(FooTokenBuilder.newBuilder() .withValue("foo user value") .withFooCount(2) .build()) .build(); final String serializedFooUser = service.serialize(fooUserToSerialize, FooUser.class); assertThat(serializedFooUser, containsString(FooUser.class.getName())); final FooUser deserializedFooUser = (FooUser) service.deserialize(serializedFooUser); assertEquals(fooUserToSerialize.getToken().getFooCount(), deserializedFooUser.getToken().getFooCount()); assertEquals(fooUserToSerialize.getToken().getValue(), deserializedFooUser.getToken().getValue()); } /** * Compare with {@link FailureTests#serializingAnObjectWithMultipleGenerateDTOInterfacesToUnspecifiedInterface()} */ @Test public void serializingAnObjectWithMultipleGenerateDTOInterfacesToSpecifiedInterface() throws Exception {
class MultipleGenerateDTOs implements SimpleType, AnotherSimpleType {
richmartin/detox
src/test/java/com/moozvine/detox/SerializationServiceWithComplexHierarchies.java
// Path: src/test/java/com/moozvine/detox/testtypes/AnotherSimpleType.java // @GenerateDTO // public interface AnotherSimpleType extends Serializable { // String getSomeOtherString(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // }
import com.google.common.collect.ImmutableList; import com.moozvine.detox.testtypes.AnotherSimpleType; import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.complexhierarchies.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
.withValue("user value") .build()) .build(); final String serializedUser = service.serialize(userToSerialize); final User deserializedUser = (User) service.deserialize(serializedUser); assertEquals(userToSerialize.getToken().getValue(), deserializedUser.getToken().getValue()); final FooUser fooUserToSerialize = FooUserBuilder.newBuilder() .withToken(FooTokenBuilder.newBuilder() .withValue("foo user value") .withFooCount(2) .build()) .build(); final String serializedFooUser = service.serialize(fooUserToSerialize, FooUser.class); assertThat(serializedFooUser, containsString(FooUser.class.getName())); final FooUser deserializedFooUser = (FooUser) service.deserialize(serializedFooUser); assertEquals(fooUserToSerialize.getToken().getFooCount(), deserializedFooUser.getToken().getFooCount()); assertEquals(fooUserToSerialize.getToken().getValue(), deserializedFooUser.getToken().getValue()); } /** * Compare with {@link FailureTests#serializingAnObjectWithMultipleGenerateDTOInterfacesToUnspecifiedInterface()} */ @Test public void serializingAnObjectWithMultipleGenerateDTOInterfacesToSpecifiedInterface() throws Exception {
// Path: src/test/java/com/moozvine/detox/testtypes/AnotherSimpleType.java // @GenerateDTO // public interface AnotherSimpleType extends Serializable { // String getSomeOtherString(); // } // // Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java // @GenerateDTO // public interface SimpleType extends Serializable { // String getSomeString(); // int getAnInt(); // } // Path: src/test/java/com/moozvine/detox/SerializationServiceWithComplexHierarchies.java import com.google.common.collect.ImmutableList; import com.moozvine.detox.testtypes.AnotherSimpleType; import com.moozvine.detox.testtypes.SimpleType; import com.moozvine.detox.testtypes.complexhierarchies.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; .withValue("user value") .build()) .build(); final String serializedUser = service.serialize(userToSerialize); final User deserializedUser = (User) service.deserialize(serializedUser); assertEquals(userToSerialize.getToken().getValue(), deserializedUser.getToken().getValue()); final FooUser fooUserToSerialize = FooUserBuilder.newBuilder() .withToken(FooTokenBuilder.newBuilder() .withValue("foo user value") .withFooCount(2) .build()) .build(); final String serializedFooUser = service.serialize(fooUserToSerialize, FooUser.class); assertThat(serializedFooUser, containsString(FooUser.class.getName())); final FooUser deserializedFooUser = (FooUser) service.deserialize(serializedFooUser); assertEquals(fooUserToSerialize.getToken().getFooCount(), deserializedFooUser.getToken().getFooCount()); assertEquals(fooUserToSerialize.getToken().getValue(), deserializedFooUser.getToken().getValue()); } /** * Compare with {@link FailureTests#serializingAnObjectWithMultipleGenerateDTOInterfacesToUnspecifiedInterface()} */ @Test public void serializingAnObjectWithMultipleGenerateDTOInterfacesToSpecifiedInterface() throws Exception {
class MultipleGenerateDTOs implements SimpleType, AnotherSimpleType {
richmartin/detox
src/test/java/com/moozvine/detox/testtypes/Types.java
// Path: src/main/java/com/moozvine/detox/Serializable.java // public interface Serializable { // }
import com.moozvine.detox.GenerateDTO; import com.moozvine.detox.Serializable; import javax.mail.internet.InternetAddress; import java.math.BigDecimal; import java.math.BigInteger; import java.util.List; import java.util.Map;
package com.moozvine.detox.testtypes; public class Types { @GenerateDTO
// Path: src/main/java/com/moozvine/detox/Serializable.java // public interface Serializable { // } // Path: src/test/java/com/moozvine/detox/testtypes/Types.java import com.moozvine.detox.GenerateDTO; import com.moozvine.detox.Serializable; import javax.mail.internet.InternetAddress; import java.math.BigDecimal; import java.math.BigInteger; import java.util.List; import java.util.Map; package com.moozvine.detox.testtypes; public class Types { @GenerateDTO
public interface SerializableWithIntegerMember extends Serializable {
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusinessBean.java
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // }
import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.logging.Logger; import com.idega.block.process.data.CaseCode; import com.idega.business.IBOServiceBean; import com.idega.data.IDOLookup; import com.idega.util.IWTimestamp; import com.idega.util.database.ConnectionBroker;
/* * $Id$ Created on Dec 18, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.business; public class AgressoBusinessBean extends IBOServiceBean implements AgressoBusiness { static Logger log = Logger.getLogger(AgressoBusinessBean.class.getName()); public void executeAfterSchoolCareUpdate() { log.info("Starting Agresso after school care update"); Connection conn = ConnectionBroker.getConnection(); int prevTransactionLevel = Connection.TRANSACTION_SERIALIZABLE; boolean prevAutoComm = true; try { prevTransactionLevel = conn.getTransactionIsolation(); prevAutoComm = conn.getAutoCommit(); } catch (SQLException e1) { e1.printStackTrace(); } AccountingEntry entry; try { String tableName = "RRVK_AGRESSO"; conn.setAutoCommit(false); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); Statement stmt1 = conn.createStatement(); stmt1.executeUpdate("delete from " + tableName); stmt1.close();
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusinessBean.java import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.logging.Logger; import com.idega.block.process.data.CaseCode; import com.idega.business.IBOServiceBean; import com.idega.data.IDOLookup; import com.idega.util.IWTimestamp; import com.idega.util.database.ConnectionBroker; /* * $Id$ Created on Dec 18, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.business; public class AgressoBusinessBean extends IBOServiceBean implements AgressoBusiness { static Logger log = Logger.getLogger(AgressoBusinessBean.class.getName()); public void executeAfterSchoolCareUpdate() { log.info("Starting Agresso after school care update"); Connection conn = ConnectionBroker.getConnection(); int prevTransactionLevel = Connection.TRANSACTION_SERIALIZABLE; boolean prevAutoComm = true; try { prevTransactionLevel = conn.getTransactionIsolation(); prevAutoComm = conn.getAutoCommit(); } catch (SQLException e1) { e1.printStackTrace(); } AccountingEntry entry; try { String tableName = "RRVK_AGRESSO"; conn.setAutoCommit(false); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); Statement stmt1 = conn.createStatement(); stmt1.executeUpdate("delete from " + tableName); stmt1.close();
CaseCodeAccountingKeyHome ccah = (CaseCodeAccountingKeyHome) IDOLookup.getHome(CaseCodeAccountingKey.class);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusinessBean.java
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // }
import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.logging.Logger; import com.idega.block.process.data.CaseCode; import com.idega.business.IBOServiceBean; import com.idega.data.IDOLookup; import com.idega.util.IWTimestamp; import com.idega.util.database.ConnectionBroker;
/* * $Id$ Created on Dec 18, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.business; public class AgressoBusinessBean extends IBOServiceBean implements AgressoBusiness { static Logger log = Logger.getLogger(AgressoBusinessBean.class.getName()); public void executeAfterSchoolCareUpdate() { log.info("Starting Agresso after school care update"); Connection conn = ConnectionBroker.getConnection(); int prevTransactionLevel = Connection.TRANSACTION_SERIALIZABLE; boolean prevAutoComm = true; try { prevTransactionLevel = conn.getTransactionIsolation(); prevAutoComm = conn.getAutoCommit(); } catch (SQLException e1) { e1.printStackTrace(); } AccountingEntry entry; try { String tableName = "RRVK_AGRESSO"; conn.setAutoCommit(false); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); Statement stmt1 = conn.createStatement(); stmt1.executeUpdate("delete from " + tableName); stmt1.close();
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusinessBean.java import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.logging.Logger; import com.idega.block.process.data.CaseCode; import com.idega.business.IBOServiceBean; import com.idega.data.IDOLookup; import com.idega.util.IWTimestamp; import com.idega.util.database.ConnectionBroker; /* * $Id$ Created on Dec 18, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.business; public class AgressoBusinessBean extends IBOServiceBean implements AgressoBusiness { static Logger log = Logger.getLogger(AgressoBusinessBean.class.getName()); public void executeAfterSchoolCareUpdate() { log.info("Starting Agresso after school care update"); Connection conn = ConnectionBroker.getConnection(); int prevTransactionLevel = Connection.TRANSACTION_SERIALIZABLE; boolean prevAutoComm = true; try { prevTransactionLevel = conn.getTransactionIsolation(); prevAutoComm = conn.getAutoCommit(); } catch (SQLException e1) { e1.printStackTrace(); } AccountingEntry entry; try { String tableName = "RRVK_AGRESSO"; conn.setAutoCommit(false); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); Statement stmt1 = conn.createStatement(); stmt1.executeUpdate("delete from " + tableName); stmt1.close();
CaseCodeAccountingKeyHome ccah = (CaseCodeAccountingKeyHome) IDOLookup.getHome(CaseCodeAccountingKey.class);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingEntryFetcher.java
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/AccountingFiles.java // public interface AccountingFiles extends IDOEntity { // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getFile // */ // public ICFile getFile(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCreatedDate // */ // public Timestamp getCreatedDate(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getMonth // */ // public Date getMonth(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setFile // */ // public void setFile(ICFile file); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCreatedDate // */ // public void setCreatedDate(Timestamp createdDate); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setMonth // */ // public void setMonth(Date month); // }
import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.data.AccountingFiles; import java.rmi.RemoteException; import java.util.Collection; import java.util.Iterator; import com.idega.business.IBORuntimeException; import com.idega.core.file.data.ICFile; import com.idega.presentation.IWContext; import com.idega.presentation.Layer; import com.idega.presentation.Table2; import com.idega.presentation.TableCell2; import com.idega.presentation.TableRow; import com.idega.presentation.TableRowGroup; import com.idega.presentation.text.Link; import com.idega.presentation.text.Text; import com.idega.presentation.ui.DateInput; import com.idega.presentation.ui.Form; import com.idega.presentation.ui.Label; import com.idega.presentation.ui.SubmitButton; import com.idega.util.IWTimestamp; import com.idega.util.PresentationUtil;
/* * $Id$ Created on 7.8.2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.presentation; public class AccountingEntryFetcher extends AccountingBlock { private final static String PARAMETER_DATE_FROM = "prm_date_from"; private final static String PARAMETER_DATE_TO = "prm_date_to"; private static final String PARAMETER_ACCOUNTING_FILE_PK = "prm_accounting_file_pk"; private String caseCode = null; private void parse(IWContext iwc) throws RemoteException { if (iwc.isParameterSet(PARAMETER_DATE_FROM)) { IWTimestamp month = new IWTimestamp(iwc.getParameter(PARAMETER_DATE_FROM)); if (iwc.isParameterSet(PARAMETER_DATE_TO)) { IWTimestamp to = new IWTimestamp(iwc.getParameter(PARAMETER_DATE_TO)); getAccountingKeyBusiness(iwc).createAccountingFile(this.caseCode, month.getDate(), to.getDate()); } else { getAccountingKeyBusiness(iwc).createAccountingFile(this.caseCode, month.getDate()); } } if (iwc.isParameterSet(PARAMETER_ACCOUNTING_FILE_PK)) { getAccountingKeyBusiness(iwc).removeAccountingFile(iwc.getParameter(PARAMETER_ACCOUNTING_FILE_PK)); } } protected void present(IWContext iwc) { try { parse(iwc); PresentationUtil.addStyleSheetToHeader(iwc, iwc.getIWMainApplication().getBundle("is.idega.idegaweb.egov.application").getVirtualPathWithFileNameString("style/application.css")); if (this.caseCode == null) { add(new Text("Please set the case code")); return; }
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/AccountingFiles.java // public interface AccountingFiles extends IDOEntity { // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getFile // */ // public ICFile getFile(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCreatedDate // */ // public Timestamp getCreatedDate(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getMonth // */ // public Date getMonth(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setFile // */ // public void setFile(ICFile file); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCreatedDate // */ // public void setCreatedDate(Timestamp createdDate); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setMonth // */ // public void setMonth(Date month); // } // Path: src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingEntryFetcher.java import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.data.AccountingFiles; import java.rmi.RemoteException; import java.util.Collection; import java.util.Iterator; import com.idega.business.IBORuntimeException; import com.idega.core.file.data.ICFile; import com.idega.presentation.IWContext; import com.idega.presentation.Layer; import com.idega.presentation.Table2; import com.idega.presentation.TableCell2; import com.idega.presentation.TableRow; import com.idega.presentation.TableRowGroup; import com.idega.presentation.text.Link; import com.idega.presentation.text.Text; import com.idega.presentation.ui.DateInput; import com.idega.presentation.ui.Form; import com.idega.presentation.ui.Label; import com.idega.presentation.ui.SubmitButton; import com.idega.util.IWTimestamp; import com.idega.util.PresentationUtil; /* * $Id$ Created on 7.8.2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. Use is subject to * license terms. */ package is.idega.idegaweb.egov.accounting.presentation; public class AccountingEntryFetcher extends AccountingBlock { private final static String PARAMETER_DATE_FROM = "prm_date_from"; private final static String PARAMETER_DATE_TO = "prm_date_to"; private static final String PARAMETER_ACCOUNTING_FILE_PK = "prm_accounting_file_pk"; private String caseCode = null; private void parse(IWContext iwc) throws RemoteException { if (iwc.isParameterSet(PARAMETER_DATE_FROM)) { IWTimestamp month = new IWTimestamp(iwc.getParameter(PARAMETER_DATE_FROM)); if (iwc.isParameterSet(PARAMETER_DATE_TO)) { IWTimestamp to = new IWTimestamp(iwc.getParameter(PARAMETER_DATE_TO)); getAccountingKeyBusiness(iwc).createAccountingFile(this.caseCode, month.getDate(), to.getDate()); } else { getAccountingKeyBusiness(iwc).createAccountingFile(this.caseCode, month.getDate()); } } if (iwc.isParameterSet(PARAMETER_ACCOUNTING_FILE_PK)) { getAccountingKeyBusiness(iwc).removeAccountingFile(iwc.getParameter(PARAMETER_ACCOUNTING_FILE_PK)); } } protected void present(IWContext iwc) { try { parse(iwc); PresentationUtil.addStyleSheetToHeader(iwc, iwc.getIWMainApplication().getBundle("is.idega.idegaweb.egov.application").getVirtualPathWithFileNameString("style/application.css")); if (this.caseCode == null) { add(new Text("Please set the case code")); return; }
boolean showFullInputs = iwc.getApplicationSettings().getBoolean(AccountingConstants.PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS, false);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingEntryFetcher.java
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/AccountingFiles.java // public interface AccountingFiles extends IDOEntity { // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getFile // */ // public ICFile getFile(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCreatedDate // */ // public Timestamp getCreatedDate(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getMonth // */ // public Date getMonth(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setFile // */ // public void setFile(ICFile file); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCreatedDate // */ // public void setCreatedDate(Timestamp createdDate); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setMonth // */ // public void setMonth(Date month); // }
import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.data.AccountingFiles; import java.rmi.RemoteException; import java.util.Collection; import java.util.Iterator; import com.idega.business.IBORuntimeException; import com.idega.core.file.data.ICFile; import com.idega.presentation.IWContext; import com.idega.presentation.Layer; import com.idega.presentation.Table2; import com.idega.presentation.TableCell2; import com.idega.presentation.TableRow; import com.idega.presentation.TableRowGroup; import com.idega.presentation.text.Link; import com.idega.presentation.text.Text; import com.idega.presentation.ui.DateInput; import com.idega.presentation.ui.Form; import com.idega.presentation.ui.Label; import com.idega.presentation.ui.SubmitButton; import com.idega.util.IWTimestamp; import com.idega.util.PresentationUtil;
table.setCellspacing(0); table.setStyleClass("ruler"); table.setStyleClass("adminTable"); TableRowGroup group = table.createHeaderRowGroup(); TableRow row = group.createRow(); TableCell2 cell = row.createHeaderCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("fileName"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.file_name", "File name"))); cell = row.createHeaderCell(); cell.setStyleClass("createdDate"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.created_date", "Created date"))); cell = row.createHeaderCell(); cell.setStyleClass("month"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.month", "Month"))); cell = row.createHeaderCell(); cell.setStyleClass("remove"); cell.setStyleClass("lastColumn"); cell.add(Text.getNonBrakingSpace()); group = table.createBodyRowGroup(); int iRow = 1; Collection files = getAccountingKeyBusiness(iwc).getAccountingFiles(this.caseCode); Iterator iter = files.iterator(); while (iter.hasNext()) {
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/AccountingFiles.java // public interface AccountingFiles extends IDOEntity { // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getFile // */ // public ICFile getFile(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getCreatedDate // */ // public Timestamp getCreatedDate(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#getMonth // */ // public Date getMonth(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setFile // */ // public void setFile(ICFile file); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setCreatedDate // */ // public void setCreatedDate(Timestamp createdDate); // // /** // * @see is.idega.idegaweb.egov.accounting.data.AccountingFilesBMPBean#setMonth // */ // public void setMonth(Date month); // } // Path: src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingEntryFetcher.java import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.data.AccountingFiles; import java.rmi.RemoteException; import java.util.Collection; import java.util.Iterator; import com.idega.business.IBORuntimeException; import com.idega.core.file.data.ICFile; import com.idega.presentation.IWContext; import com.idega.presentation.Layer; import com.idega.presentation.Table2; import com.idega.presentation.TableCell2; import com.idega.presentation.TableRow; import com.idega.presentation.TableRowGroup; import com.idega.presentation.text.Link; import com.idega.presentation.text.Text; import com.idega.presentation.ui.DateInput; import com.idega.presentation.ui.Form; import com.idega.presentation.ui.Label; import com.idega.presentation.ui.SubmitButton; import com.idega.util.IWTimestamp; import com.idega.util.PresentationUtil; table.setCellspacing(0); table.setStyleClass("ruler"); table.setStyleClass("adminTable"); TableRowGroup group = table.createHeaderRowGroup(); TableRow row = group.createRow(); TableCell2 cell = row.createHeaderCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("fileName"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.file_name", "File name"))); cell = row.createHeaderCell(); cell.setStyleClass("createdDate"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.created_date", "Created date"))); cell = row.createHeaderCell(); cell.setStyleClass("month"); cell.add(new Text(this.iwrb.getLocalizedString("accounting_fetcher.month", "Month"))); cell = row.createHeaderCell(); cell.setStyleClass("remove"); cell.setStyleClass("lastColumn"); cell.add(Text.getNonBrakingSpace()); group = table.createBodyRowGroup(); int iRow = 1; Collection files = getAccountingKeyBusiness(iwc).getAccountingFiles(this.caseCode); Iterator iter = files.iterator(); while (iter.hasNext()) {
AccountingFiles file = (AccountingFiles) iter.next();
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/business/NavisionXMLStringResult.java
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // }
import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import java.text.NumberFormat; import com.idega.idegaweb.IWApplicationContext; import com.idega.util.IWCalendar; import com.idega.util.IWTimestamp;
/* * $Id: NavisionXMLStringResult.java,v 1.3 2006/11/22 14:13:06 eiki Exp $ * Created on Oct 9, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. * Use is subject to license terms. */ package is.idega.idegaweb.egov.accounting.business; /** * Writes one accountentry as an xml string. In the format: <Parameters> � <Customer_No>2402624449</Customer_No> � <HeaderDescription>Idegaweb eGov</HeaderDescription> � <Posting_Date>01.11.06</Posting_Date> � <Child_No>0805952639</Child_No> � <Item_No>FOOD</Item_No> � <Quantity>20</Quantity> � <Unit_Price>235</Unit_Price> � <Customer_Invoice>BREAD</Customer_Invoice> � <Date_To>31.10.2006</Date_To> � <Date_From>01.10.2006</Date_From> � <School_No>04-211</School_No> � <Card_No>1111222233334444</Card_No> <Card_Expire_Month>2</Card_Expire_Month> <Card_Expire_Year>2006</Card_Expire_Year> � <Payment_Method_Code>V</Payment_Method_Code> � <Duration_Month>10</Duration_Month> <Duration_Day>31</Duration_Day> </Parameters> * Last modified: $Date: 2006/11/22 14:13:06 $ by $Author: eiki $ * * @author <a href="mailto:eiki@idega.com">eiki</a> * @version $Revision: 1.3 $ */ public class NavisionXMLStringResult implements AccountingStringResult { protected static final String DURATION_DAY = "Duration_Day"; protected static final String DURATION_MONTH = "Duration_Month"; protected static final String PARAMETERS = "Parameters"; protected static final String CARD_EXPIRE_YEAR = "Card_Expire_Year"; protected static final String CARD_EXPIRE_MONTH = "Card_Expire_Month"; protected static final String PAYMENT_METHOD_CODE = "Payment_Method_Code"; protected static final String CARD_NO = "Card_No"; protected static final String SCHOOL_NO = "School_No"; protected static final String DATE_FROM = "Date_From"; protected static final String DATE_TO = "Date_To"; protected static final String CUSTOMER_INVOICE = "Customer_Invoice"; protected static final String UNIT_PRICE = "Unit_Price"; protected static final String QUANTITY = "Quantity"; protected static final String ITEM_NO = "Item_No"; protected static final String CHILD_NO = "Child_No"; protected static final String POSTING_DATE = "Posting_Date"; protected static final String HEADER_DESCRIPTION = "HeaderDescription"; protected static final String CUSTOMER_NO = "Customer_No"; private static final String DATE_FORMAT_DD_MM_YYYY = "dd.MM.yyyy";
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // Path: src/java/is/idega/idegaweb/egov/accounting/business/NavisionXMLStringResult.java import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import java.text.NumberFormat; import com.idega.idegaweb.IWApplicationContext; import com.idega.util.IWCalendar; import com.idega.util.IWTimestamp; /* * $Id: NavisionXMLStringResult.java,v 1.3 2006/11/22 14:13:06 eiki Exp $ * Created on Oct 9, 2006 * * Copyright (C) 2006 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. * Use is subject to license terms. */ package is.idega.idegaweb.egov.accounting.business; /** * Writes one accountentry as an xml string. In the format: <Parameters> � <Customer_No>2402624449</Customer_No> � <HeaderDescription>Idegaweb eGov</HeaderDescription> � <Posting_Date>01.11.06</Posting_Date> � <Child_No>0805952639</Child_No> � <Item_No>FOOD</Item_No> � <Quantity>20</Quantity> � <Unit_Price>235</Unit_Price> � <Customer_Invoice>BREAD</Customer_Invoice> � <Date_To>31.10.2006</Date_To> � <Date_From>01.10.2006</Date_From> � <School_No>04-211</School_No> � <Card_No>1111222233334444</Card_No> <Card_Expire_Month>2</Card_Expire_Month> <Card_Expire_Year>2006</Card_Expire_Year> � <Payment_Method_Code>V</Payment_Method_Code> � <Duration_Month>10</Duration_Month> <Duration_Day>31</Duration_Day> </Parameters> * Last modified: $Date: 2006/11/22 14:13:06 $ by $Author: eiki $ * * @author <a href="mailto:eiki@idega.com">eiki</a> * @version $Revision: 1.3 $ */ public class NavisionXMLStringResult implements AccountingStringResult { protected static final String DURATION_DAY = "Duration_Day"; protected static final String DURATION_MONTH = "Duration_Month"; protected static final String PARAMETERS = "Parameters"; protected static final String CARD_EXPIRE_YEAR = "Card_Expire_Year"; protected static final String CARD_EXPIRE_MONTH = "Card_Expire_Month"; protected static final String PAYMENT_METHOD_CODE = "Payment_Method_Code"; protected static final String CARD_NO = "Card_No"; protected static final String SCHOOL_NO = "School_No"; protected static final String DATE_FROM = "Date_From"; protected static final String DATE_TO = "Date_To"; protected static final String CUSTOMER_INVOICE = "Customer_Invoice"; protected static final String UNIT_PRICE = "Unit_Price"; protected static final String QUANTITY = "Quantity"; protected static final String ITEM_NO = "Item_No"; protected static final String CHILD_NO = "Child_No"; protected static final String POSTING_DATE = "Posting_Date"; protected static final String HEADER_DESCRIPTION = "HeaderDescription"; protected static final String CUSTOMER_NO = "Customer_No"; private static final String DATE_FORMAT_DD_MM_YYYY = "dd.MM.yyyy";
public String toString(IWApplicationContext iwac, AccountingEntry entry, CaseCodeAccountingKey key, IWTimestamp fromStamp, IWTimestamp toStamp) {
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/AccountingViewManager.java
// Path: src/java/is/idega/idegaweb/egov/accounting/presentation/UpdateAgresso.java // public class UpdateAgresso extends IWBaseComponent { // // /* // * (non-Javadoc) // * // * @see com.idega.presentation.IWBaseComponent#initializeComponent(javax.faces.context.FacesContext) // */ // protected void initializeComponent(FacesContext context) { // // TODO Auto-generated method stub // // setId(getParent().getId() + "_updateagresso"); // // super.initializeComponent(context); // // MethodBinding binding = WFUtil.createMethodBinding("#{AgressoBusinessBean.executeAfterSchoolCareUpdate}", null); // // HtmlCommandButton button = new HtmlCommandButton(); // button.setId(this.getId() + "_agressoafterschoolcareupdatebutton"); // button.setAction(binding); // button.setValue("Update after school care"); // // add(button); // // binding = WFUtil.createMethodBinding("#{AgressoBusinessBean.executeCourseUpdate}", null); // // button = new HtmlCommandButton(); // button.setId(this.getId() + "_agressocourseupdatebutton"); // button.setAction(binding); // button.setValue("Update course"); // // add(button); // } // }
import is.idega.idegaweb.egov.accounting.presentation.UpdateAgresso; import java.util.ArrayList; import java.util.Collection; import com.idega.core.view.DefaultViewNode; import com.idega.core.view.ViewManager; import com.idega.core.view.ViewNode; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWMainApplication; import com.idega.workspace.view.WorkspaceApplicationNode; import com.idega.workspace.view.WorkspaceClassViewNode;
public ViewNode getAccountingViewNode(){ IWBundle iwb = this.iwma.getBundle("is.idega.idegaweb.egov.accounting"); if(this.accountingViewNode==null){ this.accountingViewNode = initalizeAccountingNode(iwb); } return this.accountingViewNode; } /** * <p> * TODO tryggvil describe method initalizeSchoolNode * </p> * @param iwb * @return */ private ViewNode initalizeAccountingNode(IWBundle iwb) { ViewManager viewManager = ViewManager.getInstance(this.iwma); ViewNode workspace = viewManager.getWorkspaceRoot(); Collection roles = new ArrayList(); roles.add("accounting_admin"); DefaultViewNode accountingNode = new WorkspaceApplicationNode("accounting",workspace,roles); accountingNode.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['accounting']}"); DefaultViewNode agressoNode = new WorkspaceClassViewNode("agresso",accountingNode); agressoNode.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['agresso']}"); WorkspaceClassViewNode seasons = new WorkspaceClassViewNode("updateagresso",agressoNode); seasons.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['manual_update_agresso']}");
// Path: src/java/is/idega/idegaweb/egov/accounting/presentation/UpdateAgresso.java // public class UpdateAgresso extends IWBaseComponent { // // /* // * (non-Javadoc) // * // * @see com.idega.presentation.IWBaseComponent#initializeComponent(javax.faces.context.FacesContext) // */ // protected void initializeComponent(FacesContext context) { // // TODO Auto-generated method stub // // setId(getParent().getId() + "_updateagresso"); // // super.initializeComponent(context); // // MethodBinding binding = WFUtil.createMethodBinding("#{AgressoBusinessBean.executeAfterSchoolCareUpdate}", null); // // HtmlCommandButton button = new HtmlCommandButton(); // button.setId(this.getId() + "_agressoafterschoolcareupdatebutton"); // button.setAction(binding); // button.setValue("Update after school care"); // // add(button); // // binding = WFUtil.createMethodBinding("#{AgressoBusinessBean.executeCourseUpdate}", null); // // button = new HtmlCommandButton(); // button.setId(this.getId() + "_agressocourseupdatebutton"); // button.setAction(binding); // button.setValue("Update course"); // // add(button); // } // } // Path: src/java/is/idega/idegaweb/egov/AccountingViewManager.java import is.idega.idegaweb.egov.accounting.presentation.UpdateAgresso; import java.util.ArrayList; import java.util.Collection; import com.idega.core.view.DefaultViewNode; import com.idega.core.view.ViewManager; import com.idega.core.view.ViewNode; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWMainApplication; import com.idega.workspace.view.WorkspaceApplicationNode; import com.idega.workspace.view.WorkspaceClassViewNode; public ViewNode getAccountingViewNode(){ IWBundle iwb = this.iwma.getBundle("is.idega.idegaweb.egov.accounting"); if(this.accountingViewNode==null){ this.accountingViewNode = initalizeAccountingNode(iwb); } return this.accountingViewNode; } /** * <p> * TODO tryggvil describe method initalizeSchoolNode * </p> * @param iwb * @return */ private ViewNode initalizeAccountingNode(IWBundle iwb) { ViewManager viewManager = ViewManager.getInstance(this.iwma); ViewNode workspace = viewManager.getWorkspaceRoot(); Collection roles = new ArrayList(); roles.add("accounting_admin"); DefaultViewNode accountingNode = new WorkspaceApplicationNode("accounting",workspace,roles); accountingNode.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['accounting']}"); DefaultViewNode agressoNode = new WorkspaceClassViewNode("agresso",accountingNode); agressoNode.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['agresso']}"); WorkspaceClassViewNode seasons = new WorkspaceClassViewNode("updateagresso",agressoNode); seasons.setName("#{localizedStrings['is.idega.idegaweb.egov.accounting']['manual_update_agresso']}");
seasons.setComponentClass(UpdateAgresso.class);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/wsimpl/AccountingServiceSOAPImpl.java
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // }
import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingBusinessManager; import is.idega.idegaweb.egov.accounting.business.AccountingEntry; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.rmi.RemoteException; import java.util.Date; import javax.ejb.FinderException; import com.idega.block.process.data.CaseCode; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.IWTimestamp;
/** * AccountingServiceSOAPImpl.java * * This file was auto-generated from WSDL by the Apache Axis 1.3 Oct 05, 2005 * (05:23:37 EDT) WSDL2Java emitter. */ package is.idega.idegaweb.egov.accounting.wsimpl; public class AccountingServiceSOAPImpl implements is.idega.idegaweb.egov.accounting.wsimpl.AccountingService_PortType { public BillingEntry[] getBillingEntries(is.idega.idegaweb.egov.accounting.wsimpl.BillingEntriesRequest getBillingEntriesRequest) throws java.rmi.RemoteException { try {
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/wsimpl/AccountingServiceSOAPImpl.java import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingBusinessManager; import is.idega.idegaweb.egov.accounting.business.AccountingEntry; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.rmi.RemoteException; import java.util.Date; import javax.ejb.FinderException; import com.idega.block.process.data.CaseCode; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.IWTimestamp; /** * AccountingServiceSOAPImpl.java * * This file was auto-generated from WSDL by the Apache Axis 1.3 Oct 05, 2005 * (05:23:37 EDT) WSDL2Java emitter. */ package is.idega.idegaweb.egov.accounting.wsimpl; public class AccountingServiceSOAPImpl implements is.idega.idegaweb.egov.accounting.wsimpl.AccountingService_PortType { public BillingEntry[] getBillingEntries(is.idega.idegaweb.egov.accounting.wsimpl.BillingEntriesRequest getBillingEntriesRequest) throws java.rmi.RemoteException { try {
CaseCodeAccountingKeyHome home = (CaseCodeAccountingKeyHome) IDOLookup.getHome(CaseCodeAccountingKey.class);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/wsimpl/AccountingServiceSOAPImpl.java
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // }
import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingBusinessManager; import is.idega.idegaweb.egov.accounting.business.AccountingEntry; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.rmi.RemoteException; import java.util.Date; import javax.ejb.FinderException; import com.idega.block.process.data.CaseCode; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.IWTimestamp;
/** * AccountingServiceSOAPImpl.java * * This file was auto-generated from WSDL by the Apache Axis 1.3 Oct 05, 2005 * (05:23:37 EDT) WSDL2Java emitter. */ package is.idega.idegaweb.egov.accounting.wsimpl; public class AccountingServiceSOAPImpl implements is.idega.idegaweb.egov.accounting.wsimpl.AccountingService_PortType { public BillingEntry[] getBillingEntries(is.idega.idegaweb.egov.accounting.wsimpl.BillingEntriesRequest getBillingEntriesRequest) throws java.rmi.RemoteException { try {
// Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKey.java // public interface CaseCodeAccountingKey extends IDOEntity { // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getPrimaryKeyClass // */ // public Class getPrimaryKeyClass(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCode // */ // public CaseCode getCaseCode(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getCaseCodeString // */ // public String getCaseCodeString(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getAccountingKey // */ // public String getAccountingKey(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#getDescription // */ // public String getDescription(); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setCaseCode // */ // public void setCaseCode(CaseCode code); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setAccountingKey // */ // public void setAccountingKey(String key); // // /** // * @see is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyBMPBean#setDescription // */ // public void setDescription(String description); // } // // Path: src/java/is/idega/idegaweb/egov/accounting/data/CaseCodeAccountingKeyHome.java // public interface CaseCodeAccountingKeyHome extends IDOHome { // // public CaseCodeAccountingKey create() throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(Object pk) throws FinderException; // // public CaseCodeAccountingKey create(CaseCode code) throws CreateException; // // public CaseCodeAccountingKey findByPrimaryKey(CaseCode code) throws FinderException; // // public CaseCodeAccountingKey findByAccountingKey(String accountingKey) throws FinderException; // // public Collection findAllCaseCodeAccountingKeys() throws FinderException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/wsimpl/AccountingServiceSOAPImpl.java import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingBusinessManager; import is.idega.idegaweb.egov.accounting.business.AccountingEntry; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKey; import is.idega.idegaweb.egov.accounting.data.CaseCodeAccountingKeyHome; import java.rmi.RemoteException; import java.util.Date; import javax.ejb.FinderException; import com.idega.block.process.data.CaseCode; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.IWTimestamp; /** * AccountingServiceSOAPImpl.java * * This file was auto-generated from WSDL by the Apache Axis 1.3 Oct 05, 2005 * (05:23:37 EDT) WSDL2Java emitter. */ package is.idega.idegaweb.egov.accounting.wsimpl; public class AccountingServiceSOAPImpl implements is.idega.idegaweb.egov.accounting.wsimpl.AccountingService_PortType { public BillingEntry[] getBillingEntries(is.idega.idegaweb.egov.accounting.wsimpl.BillingEntriesRequest getBillingEntriesRequest) throws java.rmi.RemoteException { try {
CaseCodeAccountingKeyHome home = (CaseCodeAccountingKeyHome) IDOLookup.getHome(CaseCodeAccountingKey.class);
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/timer/AgressoUpdateTimer.java
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusiness.java // public interface AgressoBusiness extends IBOService { // // /** // * @see is.idega.idegaweb.egov.accounting.business.AgressoBusinessBean#executeAfterSchoolCareUpdate // */ // public void executeAfterSchoolCareUpdate() throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AgressoBusinessBean#executeCourseUpdate // */ // public void executeCourseUpdate() throws RemoteException; // }
import is.idega.idegaweb.egov.accounting.business.AgressoBusiness; import java.rmi.RemoteException; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.timer.TimerEntry; import com.idega.util.timer.TimerListener;
package is.idega.idegaweb.egov.accounting.timer; public class AgressoUpdateTimer implements TimerListener { private IWMainApplication iwma; public AgressoUpdateTimer(IWMainApplication iwma) { super(); this.iwma = iwma; } @Override public void handleTimer(TimerEntry entry) { try {
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AgressoBusiness.java // public interface AgressoBusiness extends IBOService { // // /** // * @see is.idega.idegaweb.egov.accounting.business.AgressoBusinessBean#executeAfterSchoolCareUpdate // */ // public void executeAfterSchoolCareUpdate() throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AgressoBusinessBean#executeCourseUpdate // */ // public void executeCourseUpdate() throws RemoteException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/timer/AgressoUpdateTimer.java import is.idega.idegaweb.egov.accounting.business.AgressoBusiness; import java.rmi.RemoteException; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.idegaweb.IWMainApplication; import com.idega.util.timer.TimerEntry; import com.idega.util.timer.TimerListener; package is.idega.idegaweb.egov.accounting.timer; public class AgressoUpdateTimer implements TimerListener { private IWMainApplication iwma; public AgressoUpdateTimer(IWMainApplication iwma) { super(); this.iwma = iwma; } @Override public void handleTimer(TimerEntry entry) { try {
AgressoBusiness business = (AgressoBusiness) IBOLookup
idega/is.idega.idegaweb.egov.accounting
src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingBlock.java
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingKeyBusiness.java // public interface AccountingKeyBusiness extends IBOService { // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingKey // */ // public CaseCodeAccountingKey getAccountingKey(CaseCode code) throws FinderException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingFiles // */ // public Collection getAccountingFiles(String caseCode) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#removeAccountingFile // */ // public void removeAccountingFile(Object accountingFilePK) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getProductKeyMap // */ // public Map getProductKeyMap(CaseCode code) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolProductKeyMap // */ // public Map getSchoolProductKeyMap() throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#storeSchoolCode // */ // public void storeSchoolCode(Object schoolPK, Object typePK, String accountingKey) throws CreateException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#storeSchoolCode // */ // public void storeSchoolCode(School school, SchoolType type, String accountingKey) throws CreateException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolCodes // */ // public Collection getSchoolCodes(School school) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolCode // */ // public SchoolCode getSchoolCode(School school, SchoolType type) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#createAccountingFile // */ // public void createAccountingFile(String caseCode, Date month) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(String caseCode, Date month, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#createAccountingFile // */ // public void createAccountingFile(String caseCode, Date from, Date to) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(String caseCode, Date from, Date to, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(CaseCode code, Date month, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(CaseCode code, Date from, Date to, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingEntries // */ // public AccountingEntry[] getAccountingEntries(CaseCode code, Date from, Date to) throws FinderException, RemoteException; // }
import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.business.AccountingKeyBusiness; import com.idega.block.process.data.CaseCode; import com.idega.block.process.data.CaseCodeHome; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.Block; import com.idega.presentation.IWContext;
package is.idega.idegaweb.egov.accounting.presentation; public abstract class AccountingBlock extends Block { protected IWResourceBundle iwrb = null; protected IWBundle iwb = null; public String getBundleIdentifier() {
// Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingConstants.java // public class AccountingConstants { // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.accounting"; // // public static final String ACCOUNTING_SYSTEM_NAVISION = "NAVISION"; // public static final String ACCOUNTING_SYSTEM_NAVISION_XML = "NAVISIONXML"; // public static final String ACCOUNTING_SYSTEM_SFS = "SFS"; // // public static final String PROPERTY_ACCOUNTING_SYSTEM = "egov.external.accounting.system"; // public static final String PROPERTY_ACCOUNTING_FETCHER_SHOW_INPUTS = "egov.accounting.show.all.inputs"; // public static final String PROPERTY_ACCOUNTING_SHOW_AGRESSO_VIEW = "egov.accounting.show.agresso.view"; // // public static final String SESSION_PRODUCT_MAP = "accounting_product_map"; // public static final String SESSION_PAYMENT_METHOD_MAP = "accounting_payment_method_map"; // // } // // Path: src/java/is/idega/idegaweb/egov/accounting/business/AccountingKeyBusiness.java // public interface AccountingKeyBusiness extends IBOService { // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingKey // */ // public CaseCodeAccountingKey getAccountingKey(CaseCode code) throws FinderException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingFiles // */ // public Collection getAccountingFiles(String caseCode) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#removeAccountingFile // */ // public void removeAccountingFile(Object accountingFilePK) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getProductKeyMap // */ // public Map getProductKeyMap(CaseCode code) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolProductKeyMap // */ // public Map getSchoolProductKeyMap() throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#storeSchoolCode // */ // public void storeSchoolCode(Object schoolPK, Object typePK, String accountingKey) throws CreateException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#storeSchoolCode // */ // public void storeSchoolCode(School school, SchoolType type, String accountingKey) throws CreateException, RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolCodes // */ // public Collection getSchoolCodes(School school) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getSchoolCode // */ // public SchoolCode getSchoolCode(School school, SchoolType type) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#createAccountingFile // */ // public void createAccountingFile(String caseCode, Date month) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(String caseCode, Date month, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#createAccountingFile // */ // public void createAccountingFile(String caseCode, Date from, Date to) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(String caseCode, Date from, Date to, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(CaseCode code, Date month, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#generateAccountingString // */ // public void generateAccountingString(CaseCode code, Date from, Date to, boolean createFile) throws RemoteException; // // /** // * @see is.idega.idegaweb.egov.accounting.business.AccountingKeyBusinessBean#getAccountingEntries // */ // public AccountingEntry[] getAccountingEntries(CaseCode code, Date from, Date to) throws FinderException, RemoteException; // } // Path: src/java/is/idega/idegaweb/egov/accounting/presentation/AccountingBlock.java import is.idega.idegaweb.egov.accounting.business.AccountingBusiness; import is.idega.idegaweb.egov.accounting.business.AccountingConstants; import is.idega.idegaweb.egov.accounting.business.AccountingKeyBusiness; import com.idega.block.process.data.CaseCode; import com.idega.block.process.data.CaseCodeHome; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.data.IDOLookup; import com.idega.data.IDOLookupException; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.Block; import com.idega.presentation.IWContext; package is.idega.idegaweb.egov.accounting.presentation; public abstract class AccountingBlock extends Block { protected IWResourceBundle iwrb = null; protected IWBundle iwb = null; public String getBundleIdentifier() {
return AccountingConstants.IW_BUNDLE_IDENTIFIER;
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplaceVisitor.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Element.java // public interface N3Element { // // static public interface Verb { // // public String getGlobalName(); // } // // static public interface Subject { // // } // // static public interface Object { // String toReadableString(); // // } // // static public interface Statement { // } // // public <T> T accept(IN3ElementVisitor<T> b); // // public Iterable<? extends N3Element> getChildern(); // // void replace(N3Element n, N3Element replace); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // }
import ch.ethz.inf.vs.semantics.parser.elements.N3Element; import ch.ethz.inf.vs.semantics.parser.elements.Prefix;
package ch.ethz.inf.vs.semantics.parser.visitors; public class ReplaceVisitor extends N3BaseElementVisitor<Void> { private N3Element original; private N3Element replace; public ReplaceVisitor(N3Element original, N3Element replace) {
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Element.java // public interface N3Element { // // static public interface Verb { // // public String getGlobalName(); // } // // static public interface Subject { // // } // // static public interface Object { // String toReadableString(); // // } // // static public interface Statement { // } // // public <T> T accept(IN3ElementVisitor<T> b); // // public Iterable<? extends N3Element> getChildern(); // // void replace(N3Element n, N3Element replace); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplaceVisitor.java import ch.ethz.inf.vs.semantics.parser.elements.N3Element; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; package ch.ethz.inf.vs.semantics.parser.visitors; public class ReplaceVisitor extends N3BaseElementVisitor<Void> { private N3Element original; private N3Element replace; public ReplaceVisitor(N3Element original, N3Element replace) {
if (replace instanceof Prefix || original instanceof Prefix) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Classification.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; import java.util.ArrayList;
package ch.ethz.inf.vs.semantics.parser.elements; public class Classification implements N3Element.Statement, N3Element, Serializable { private String classification; private N3Element.Object objects; private Statements statements; public Classification(String classification, N3Element.Object objects, Statements statements) { this.classification = classification; this.objects = objects; this.statements = statements; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Classification.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; import java.util.ArrayList; package ch.ethz.inf.vs.semantics.parser.elements; public class Classification implements N3Element.Statement, N3Element, Serializable { private String classification; private N3Element.Object objects; private Statements statements; public Classification(String classification, N3Element.Object objects, Statements statements) { this.classification = classification; this.objects = objects; this.statements = statements; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/domain/Device.java
// Path: reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/semantics/SemanticDescription.java // public class SemanticDescription { // private static final Logger logger = LogManager.getLogger(); // private final String endpoint; // private final String uri; // private final File temp; // private boolean fetching; // private String file; // boolean loaded; // private String content; // private String originalContent; // // public SemanticDescription(String endpoint, String uri, Path fileContainer) { // this.fetching = true; // this.endpoint = endpoint; // this.uri = uri; // File file = null; // try { // file = File.createTempFile("temp-file-name", ".n3", fileContainer.toFile()); // } catch (IOException e) { // e.printStackTrace(); // } // temp = file; // this.file = temp != null ? temp.getAbsolutePath() : null; // loaded = false; // } // // public void setFetching(boolean fetching) { // this.fetching = fetching; // } // // public boolean isFetching() { // return fetching; // } // // public String processFile(String n3file) { // originalContent = n3file; // // Parse and adjust namespace. // N3Document doc = N3Utils.parseN3Document(n3file); // String oldPrefix = "local:"; // Prefix localprefix = doc.getPrefixByUri("local#"); // if (localprefix != null) { // oldPrefix = localprefix.getName(); // } else { // n3file = "@prefix local: <local#>.\n" + n3file; // } // String newPrefix = "device_" + endpoint + ":"; // String namespace = "device_" + endpoint + "#"; // URI parsedUri; // try { // parsedUri = new URI(uri); // } catch (URISyntaxException e) { // throw new RuntimeException("Invalid uri"); // } // String host = parsedUri.getHost(); // if (host.equals("127.0.1.1")) { // host = "127.0.0.1"; // } // n3file += "\n" + "\"coap://" + host + ":" + parsedUri.getPort() + "\" a local:url."; // String newFile = N3Utils.replaceN3Prefix(n3file, oldPrefix, newPrefix, namespace); // loadFile(newFile); // return newFile; // } // // private void loadFile(String newFile) { // try { // content = newFile; // FileUtils.writeStringToFile(temp, newFile); // loaded = true; // } catch (IOException e) { // logger.catching(e); // } // setFetching(false); // } // // public boolean isLoaded() { // return loaded; // } // // public String getFilePath() { // return file; // } // // public String getEndpoint() { // return endpoint; // } // // public String getContent() { // return content == null ? "" : content; // } // // public String getOriginalContent() { // return originalContent == null ? "" : originalContent; // } // // public void setOriginalContent(String originalContent) { // this.originalContent = originalContent; // } // }
import ch.ethz.inf.vs.semantics.server.semantics.SemanticDescription; import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.ArrayList;
package ch.ethz.inf.vs.semantics.ide.domain; public class Device { private int id; private String name; private String semantics; private String url; private boolean remote; private boolean disabled; private ArrayList<SemanticsErrors> errors; @JsonIgnore
// Path: reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/semantics/SemanticDescription.java // public class SemanticDescription { // private static final Logger logger = LogManager.getLogger(); // private final String endpoint; // private final String uri; // private final File temp; // private boolean fetching; // private String file; // boolean loaded; // private String content; // private String originalContent; // // public SemanticDescription(String endpoint, String uri, Path fileContainer) { // this.fetching = true; // this.endpoint = endpoint; // this.uri = uri; // File file = null; // try { // file = File.createTempFile("temp-file-name", ".n3", fileContainer.toFile()); // } catch (IOException e) { // e.printStackTrace(); // } // temp = file; // this.file = temp != null ? temp.getAbsolutePath() : null; // loaded = false; // } // // public void setFetching(boolean fetching) { // this.fetching = fetching; // } // // public boolean isFetching() { // return fetching; // } // // public String processFile(String n3file) { // originalContent = n3file; // // Parse and adjust namespace. // N3Document doc = N3Utils.parseN3Document(n3file); // String oldPrefix = "local:"; // Prefix localprefix = doc.getPrefixByUri("local#"); // if (localprefix != null) { // oldPrefix = localprefix.getName(); // } else { // n3file = "@prefix local: <local#>.\n" + n3file; // } // String newPrefix = "device_" + endpoint + ":"; // String namespace = "device_" + endpoint + "#"; // URI parsedUri; // try { // parsedUri = new URI(uri); // } catch (URISyntaxException e) { // throw new RuntimeException("Invalid uri"); // } // String host = parsedUri.getHost(); // if (host.equals("127.0.1.1")) { // host = "127.0.0.1"; // } // n3file += "\n" + "\"coap://" + host + ":" + parsedUri.getPort() + "\" a local:url."; // String newFile = N3Utils.replaceN3Prefix(n3file, oldPrefix, newPrefix, namespace); // loadFile(newFile); // return newFile; // } // // private void loadFile(String newFile) { // try { // content = newFile; // FileUtils.writeStringToFile(temp, newFile); // loaded = true; // } catch (IOException e) { // logger.catching(e); // } // setFetching(false); // } // // public boolean isLoaded() { // return loaded; // } // // public String getFilePath() { // return file; // } // // public String getEndpoint() { // return endpoint; // } // // public String getContent() { // return content == null ? "" : content; // } // // public String getOriginalContent() { // return originalContent == null ? "" : originalContent; // } // // public void setOriginalContent(String originalContent) { // this.originalContent = originalContent; // } // } // Path: semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/domain/Device.java import ch.ethz.inf.vs.semantics.server.semantics.SemanticDescription; import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.ArrayList; package ch.ethz.inf.vs.semantics.ide.domain; public class Device { private int id; private String name; private String semantics; private String url; private boolean remote; private boolean disabled; private ArrayList<SemanticsErrors> errors; @JsonIgnore
private SemanticDescription semanticDescription;
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Exvar.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class Exvar implements N3Element.Statement, N3Element.Object, N3Element.Subject, N3Element, Serializable { private final String text; public Exvar(String text) { this.text = text; assert (text.startsWith("?")); } @Override public String toString() { return text; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Exvar.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class Exvar implements N3Element.Statement, N3Element.Object, N3Element.Subject, N3Element, Serializable { private final String text; public Exvar(String text) { this.text = text; assert (text.startsWith("?")); } @Override public String toString() { return text; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // }
import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix;
package ch.ethz.inf.vs.semantics.parser.visitors; public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { private Prefix original; private Prefix replace; public ReplacePrefixVisitor(Prefix original, Prefix replace) { this.original = original; this.replace = replace; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; package ch.ethz.inf.vs.semantics.parser.visitors; public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { private Prefix original; private Prefix replace; public ReplacePrefixVisitor(Prefix original, Prefix replace) { this.original = original; this.replace = replace; } @Override
public Void visitIri(Iri iri) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/HintsVisitor.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // }
import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.Set;
package ch.ethz.inf.vs.semantics.parser.visitors; public class HintsVisitor extends N3BaseElementVisitor<Void> { private Set<String> hints; public HintsVisitor(Set<String> hints) { this.hints = hints; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/HintsVisitor.java import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.Set; package ch.ethz.inf.vs.semantics.parser.visitors; public class HintsVisitor extends N3BaseElementVisitor<Void> { private Set<String> hints; public HintsVisitor(Set<String> hints) { this.hints = hints; } @Override
public Void visitPrefix(Prefix p) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/HintsVisitor.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // }
import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.Set;
package ch.ethz.inf.vs.semantics.parser.visitors; public class HintsVisitor extends N3BaseElementVisitor<Void> { private Set<String> hints; public HintsVisitor(Set<String> hints) { this.hints = hints; } @Override public Void visitPrefix(Prefix p) { try { hints.add(p.toString()); } catch (Exception e) { } return null; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/HintsVisitor.java import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.Set; package ch.ethz.inf.vs.semantics.parser.visitors; public class HintsVisitor extends N3BaseElementVisitor<Void> { private Set<String> hints; public HintsVisitor(Set<String> hints) { this.hints = hints; } @Override public Void visitPrefix(Prefix p) { try { hints.add(p.toString()); } catch (Exception e) { } return null; } @Override
public Void visitIri(Iri iri) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Literal.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import org.apache.commons.lang3.StringEscapeUtils; import java.io.Serializable;
this(text, false); } public Literal(String text, boolean makeString) { if (!makeString) { if (text.startsWith("\"") && text.endsWith("\"")) { string = true; text = text.substring(1, text.length() - 1); this.text = StringEscapeUtils.unescapeJava(text); } else { string = false; this.text = text; } } else { string = true; this.text = text; } } @Override public String toString() { if (string) { return "\"" + StringEscapeUtils.escapeJava(text) + "\""; } else { return text; } } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Literal.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import org.apache.commons.lang3.StringEscapeUtils; import java.io.Serializable; this(text, false); } public Literal(String text, boolean makeString) { if (!makeString) { if (text.startsWith("\"") && text.endsWith("\"")) { string = true; text = text.substring(1, text.length() - 1); this.text = StringEscapeUtils.unescapeJava(text); } else { string = false; this.text = text; } } else { string = true; this.text = text; } } @Override public String toString() { if (string) { return "\"" + StringEscapeUtils.escapeJava(text) + "\""; } else { return text; } } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/BooleanLiteral.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class BooleanLiteral implements N3Element.Object, N3Element.Subject, N3Element.Statement, N3Element, Serializable { private final String text; public BooleanLiteral(String text) { this.text = text; } @Override public String toString() { return text; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/BooleanLiteral.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class BooleanLiteral implements N3Element.Object, N3Element.Subject, N3Element.Statement, N3Element, Serializable { private final String text; public BooleanLiteral(String text) { this.text = text; } @Override public String toString() { return text; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Verb.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class Verb implements N3Element.Verb, N3Element, Serializable { private final String text; public Verb(String text) { this.text = text; } @Override public String toString() { return text; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Verb.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class Verb implements N3Element.Verb, N3Element, Serializable { private final String text; public Verb(String text) { this.text = text; } @Override public String toString() { return text; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/workspace/WorkspaceManager.java
// Path: semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/domain/WorkspaceInfo.java // public class WorkspaceInfo { // // private int id; // private String name; // private Backup backup; // private String type; // private String url; // // public WorkspaceInfo() { // } // // public WorkspaceInfo(int id, String name, String type, String url) { // this.id = id; // this.name = name; // this.type = type; // this.url = url; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public Backup getBackup() { // return backup; // } // // public void setBackup(Backup backup) { // this.backup = backup; // } // }
import ch.ethz.inf.vs.semantics.ide.domain.WorkspaceInfo; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map;
package ch.ethz.inf.vs.semantics.ide.workspace; public class WorkspaceManager { private static volatile WorkspaceManager instance = null; private static File persistenceFolder; private static Object lock = new Object(); private Map<Integer, Workspace> workspaces; private int ID; private WorkspaceManager() { workspaces = new HashMap<>(); ID = 1; for (File ws : getFolder().listFiles()) { ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally try {
// Path: semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/domain/WorkspaceInfo.java // public class WorkspaceInfo { // // private int id; // private String name; // private Backup backup; // private String type; // private String url; // // public WorkspaceInfo() { // } // // public WorkspaceInfo(int id, String name, String type, String url) { // this.id = id; // this.name = name; // this.type = type; // this.url = url; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public Backup getBackup() { // return backup; // } // // public void setBackup(Backup backup) { // this.backup = backup; // } // } // Path: semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/workspace/WorkspaceManager.java import ch.ethz.inf.vs.semantics.ide.domain.WorkspaceInfo; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; package ch.ethz.inf.vs.semantics.ide.workspace; public class WorkspaceManager { private static volatile WorkspaceManager instance = null; private static File persistenceFolder; private static Object lock = new Object(); private Map<Integer, Workspace> workspaces; private int ID; private WorkspaceManager() { workspaces = new HashMap<>(); ID = 1; for (File ws : getFolder().listFiles()) { ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally try {
WorkspaceInfo workspaceinfo = mapper.readValue(ws, WorkspaceInfo.class);
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Formula.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class Formula extends Statements implements N3Element.Object, N3Element.Subject, N3Element, Serializable { public RDFResource get(String name) { return tripleMap.get(name); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); for (N3Element.Statement s : this) { sb.append(s.toString()); sb.append(". "); } sb.append("}"); return sb.toString(); } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Formula.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class Formula extends Statements implements N3Element.Object, N3Element.Subject, N3Element, Serializable { public RDFResource get(String name) { return tripleMap.get(name); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); for (N3Element.Statement s : this) { sb.append(s.toString()); sb.append(". "); } sb.append("}"); return sb.toString(); } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/semantics/ResourceDirectorySynchronizationService.java
// Path: reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/SemanticsServer.java // public class SemanticsServer extends CoapServer { // // private static final Logger logger = LogManager.getLogger(); // // // exit codes for runtime errors // private static final int ERR_INIT_FAILED = 1; // // public static void main(String[] args) { // try { // SemanticsServer server = new SemanticsServer(); // server.addEndpoint(new CoapEndpoint(new InetSocketAddress("2001:0470:cafe::38b2:cf50", 5681))); // server.start(); // // logger.info("Semantics-Server listening on port {}.\n", server.getEndpoints().get(0).getAddress().getPort()); // } catch (Throwable t) { // logger.catching(t); // System.exit(ERR_INIT_FAILED); // } // } // // SemanticsServer(int... ports) { // super(ports); // try { // SemanticDataContainer semanticContainer = new SemanticDataContainer(); // new ResourceDirectorySynchronizationService(this, semanticContainer); // // add resources to the server // add(new SRResource(semanticContainer)); // add(new Answer(semanticContainer)); // add(new Debug(semanticContainer)); // } catch (IOException e) { // logger.catching(e); // } // } // // }
import ch.ethz.inf.vs.semantics.server.SemanticsServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.californium.core.*; import org.eclipse.californium.core.coap.LinkFormat; import org.eclipse.californium.core.coap.MediaTypeRegistry; import org.eclipse.californium.core.network.Endpoint; import org.eclipse.californium.core.server.resources.Resource; import java.util.*;
package ch.ethz.inf.vs.semantics.server.semantics; public class ResourceDirectorySynchronizationService { public static final String DEMO_IP = "[2001:470:cafe::38b2:cf50]"; private static final Logger logger = LogManager.getLogger(); private final CoapServer server; private final String id = UUID.randomUUID().toString(); private boolean registered = false; private String rdLookupURI; SemanticDataContainer semanticDataContainer;
// Path: reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/SemanticsServer.java // public class SemanticsServer extends CoapServer { // // private static final Logger logger = LogManager.getLogger(); // // // exit codes for runtime errors // private static final int ERR_INIT_FAILED = 1; // // public static void main(String[] args) { // try { // SemanticsServer server = new SemanticsServer(); // server.addEndpoint(new CoapEndpoint(new InetSocketAddress("2001:0470:cafe::38b2:cf50", 5681))); // server.start(); // // logger.info("Semantics-Server listening on port {}.\n", server.getEndpoints().get(0).getAddress().getPort()); // } catch (Throwable t) { // logger.catching(t); // System.exit(ERR_INIT_FAILED); // } // } // // SemanticsServer(int... ports) { // super(ports); // try { // SemanticDataContainer semanticContainer = new SemanticDataContainer(); // new ResourceDirectorySynchronizationService(this, semanticContainer); // // add resources to the server // add(new SRResource(semanticContainer)); // add(new Answer(semanticContainer)); // add(new Debug(semanticContainer)); // } catch (IOException e) { // logger.catching(e); // } // } // // } // Path: reasoning-server/src/main/java/ch/ethz/inf/vs/semantics/server/semantics/ResourceDirectorySynchronizationService.java import ch.ethz.inf.vs.semantics.server.SemanticsServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.californium.core.*; import org.eclipse.californium.core.coap.LinkFormat; import org.eclipse.californium.core.coap.MediaTypeRegistry; import org.eclipse.californium.core.network.Endpoint; import org.eclipse.californium.core.server.resources.Resource; import java.util.*; package ch.ethz.inf.vs.semantics.server.semantics; public class ResourceDirectorySynchronizationService { public static final String DEMO_IP = "[2001:470:cafe::38b2:cf50]"; private static final Logger logger = LogManager.getLogger(); private final CoapServer server; private final String id = UUID.randomUUID().toString(); private boolean registered = false; private String rdLookupURI; SemanticDataContainer semanticDataContainer;
public ResourceDirectorySynchronizationService(SemanticsServer server, SemanticDataContainer semanticDataContainer) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/VerbObject.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; import java.util.ArrayList;
package ch.ethz.inf.vs.semantics.parser.elements; public class VerbObject implements N3Element, Serializable { public N3Element.Verb verb; public N3Element.Object object; public VerbObject(N3Element.Verb v, N3Element.Object o) { verb = v; object = o; } @Override public String toString() { return verb.toString() + " " + object.toString(); } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/VerbObject.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; import java.util.ArrayList; package ch.ethz.inf.vs.semantics.parser.elements; public class VerbObject implements N3Element, Serializable { public N3Element.Verb verb; public N3Element.Object object; public VerbObject(N3Element.Verb v, N3Element.Object o) { verb = v; object = o; } @Override public String toString() { return verb.toString() + " " + object.toString(); } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Element.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor;
package ch.ethz.inf.vs.semantics.parser.elements; public interface N3Element { static public interface Verb { public String getGlobalName(); } static public interface Subject { } static public interface Object { String toReadableString(); } static public interface Statement { }
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Element.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; package ch.ethz.inf.vs.semantics.parser.elements; public interface N3Element { static public interface Verb { public String getGlobalName(); } static public interface Subject { } static public interface Object { String toReadableString(); } static public interface Statement { }
public <T> T accept(IN3ElementVisitor<T> b);
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
if (text.startsWith("<") && text.endsWith(">")) { uriref = true; this.text = text.substring(1, text.length() - 1); } else { uriref = false; assert (text.split(":").length == 2); String[] parts = text.split(":"); this.prefix = doc.getPrefix(parts[0]); assert (this.prefix != null); this.text = parts[1]; } } @Override public String toString() { if (uriref) { return "<" + text + ">"; } return this.prefix.getName() + text; } public String getGlobalName() { if (uriref) { return "<" + text + ">"; } return this.prefix.getUri() + text; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; if (text.startsWith("<") && text.endsWith(">")) { uriref = true; this.text = text.substring(1, text.length() - 1); } else { uriref = false; assert (text.split(":").length == 2); String[] parts = text.split(":"); this.prefix = doc.getPrefix(parts[0]); assert (this.prefix != null); this.text = parts[1]; } } @Override public String toString() { if (uriref) { return "<" + text + ">"; } return this.prefix.getName() + text; } public String getGlobalName() { if (uriref) { return "<" + text + ">"; } return this.prefix.getUri() + text; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
package ch.ethz.inf.vs.semantics.parser.elements; public class N3Document implements N3Element, Serializable { public final HashMap<String, Prefix> prefixes; public final HashMap<String, Prefix> prefixes_uri; public Statements statements; public N3Document() { this.statements = new Statements(); this.prefixes = new HashMap<String, Prefix>(); this.prefixes_uri = new HashMap<String, Prefix>(); } public void importStatements(Statements s) { s = importToDocument(s); this.statements.addAll(s); } public Prefix getPrefixByUri(String uri) { return prefixes_uri.get(uri); } public <T extends N3Element> T importToDocument(T s) { s = deepCopy(s);
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; package ch.ethz.inf.vs.semantics.parser.elements; public class N3Document implements N3Element, Serializable { public final HashMap<String, Prefix> prefixes; public final HashMap<String, Prefix> prefixes_uri; public Statements statements; public N3Document() { this.statements = new Statements(); this.prefixes = new HashMap<String, Prefix>(); this.prefixes_uri = new HashMap<String, Prefix>(); } public void importStatements(Statements s) { s = importToDocument(s); this.statements.addAll(s); } public Prefix getPrefixByUri(String uri) { return prefixes_uri.get(uri); } public <T extends N3Element> T importToDocument(T s) { s = deepCopy(s);
Set<Prefix> usedPrefixes = s.accept(new UsedPrefixesElementVisitor());
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
package ch.ethz.inf.vs.semantics.parser.elements; public class N3Document implements N3Element, Serializable { public final HashMap<String, Prefix> prefixes; public final HashMap<String, Prefix> prefixes_uri; public Statements statements; public N3Document() { this.statements = new Statements(); this.prefixes = new HashMap<String, Prefix>(); this.prefixes_uri = new HashMap<String, Prefix>(); } public void importStatements(Statements s) { s = importToDocument(s); this.statements.addAll(s); } public Prefix getPrefixByUri(String uri) { return prefixes_uri.get(uri); } public <T extends N3Element> T importToDocument(T s) { s = deepCopy(s); Set<Prefix> usedPrefixes = s.accept(new UsedPrefixesElementVisitor()); for (Prefix prefix : usedPrefixes) { // Prefix with same uri exists if (prefixes_uri.containsKey(prefix.getUri())) { // replace prefix with existing prefix Prefix other = prefixes_uri.get(prefix.getUri());
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; package ch.ethz.inf.vs.semantics.parser.elements; public class N3Document implements N3Element, Serializable { public final HashMap<String, Prefix> prefixes; public final HashMap<String, Prefix> prefixes_uri; public Statements statements; public N3Document() { this.statements = new Statements(); this.prefixes = new HashMap<String, Prefix>(); this.prefixes_uri = new HashMap<String, Prefix>(); } public void importStatements(Statements s) { s = importToDocument(s); this.statements.addAll(s); } public Prefix getPrefixByUri(String uri) { return prefixes_uri.get(uri); } public <T extends N3Element> T importToDocument(T s) { s = deepCopy(s); Set<Prefix> usedPrefixes = s.accept(new UsedPrefixesElementVisitor()); for (Prefix prefix : usedPrefixes) { // Prefix with same uri exists if (prefixes_uri.containsKey(prefix.getUri())) { // replace prefix with existing prefix Prefix other = prefixes_uri.get(prefix.getUri());
s.accept(new ReplacePrefixVisitor(prefix, other));
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
ByteArrayInputStream bais = new ByteArrayInputStream(byteData); return (T) new ObjectInputStream(bais).readObject(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } throw new RuntimeException("Can not copy objects"); } @Override public String toString() { StringBuilder sb = new StringBuilder(); for (Prefix prefix : prefixes.values()) { sb.append("@prefix "); sb.append(prefix.getName()); sb.append(" <"); sb.append(prefix.getUri()); sb.append(">.\n"); } sb.append("\n"); for (N3Element.Statement s : statements) { sb.append(s.toString()); sb.append(".\n\n"); } return sb.toString(); } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/ReplacePrefixVisitor.java // public class ReplacePrefixVisitor extends N3BaseElementVisitor<Void> { // // private Prefix original; // private Prefix replace; // // public ReplacePrefixVisitor(Prefix original, Prefix replace) { // this.original = original; // this.replace = replace; // } // // @Override // public Void visitIri(Iri iri) { // Prefix p = iri.getPrefix(); // if (p == original) { // iri.setPrefix(replace); // } // return null; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java // public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { // @Override // public Set<Prefix> defaultResult() { // return new HashSet<Prefix>(); // } // // @Override // public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { // if (cResult != null) { // result.addAll(cResult); // } // return result; // } // // @Override // public Set<Prefix> visitIri(Iri iri) { // HashSet<Prefix> list = new HashSet<Prefix>(); // Prefix p = iri.getPrefix(); // if (p != null) { // list.add(p); // } // return list; // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/N3Document.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.ReplacePrefixVisitor; import ch.ethz.inf.vs.semantics.parser.visitors.UsedPrefixesElementVisitor; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; ByteArrayInputStream bais = new ByteArrayInputStream(byteData); return (T) new ObjectInputStream(bais).readObject(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } throw new RuntimeException("Can not copy objects"); } @Override public String toString() { StringBuilder sb = new StringBuilder(); for (Prefix prefix : prefixes.values()) { sb.append("@prefix "); sb.append(prefix.getName()); sb.append(" <"); sb.append(prefix.getUri()); sb.append(">.\n"); } sb.append("\n"); for (N3Element.Statement s : statements) { sb.append(s.toString()); sb.append(".\n\n"); } return sb.toString(); } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // }
import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.HashSet; import java.util.Set;
package ch.ethz.inf.vs.semantics.parser.visitors; public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { @Override public Set<Prefix> defaultResult() { return new HashSet<Prefix>(); } @Override public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { if (cResult != null) { result.addAll(cResult); } return result; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Iri.java // public class Iri implements N3Element.Object, N3Element.Verb, N3Element.Subject, N3Element, Serializable { // public final boolean uriref; // private Prefix prefix; // public String text; // // public Iri(N3Document doc, String text) { // // if (text.startsWith("<") && text.endsWith(">")) { // uriref = true; // this.text = text.substring(1, text.length() - 1); // } else { // uriref = false; // assert (text.split(":").length == 2); // String[] parts = text.split(":"); // this.prefix = doc.getPrefix(parts[0]); // assert (this.prefix != null); // this.text = parts[1]; // } // // } // // @Override // public String toString() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getName() + text; // } // // public String getGlobalName() { // if (uriref) { // return "<" + text + ">"; // } // return this.prefix.getUri() + text; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitIri(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // @Override // public String toReadableString() { // return text; // } // // public Prefix getPrefix() { // return prefix; // } // // public void setPrefix(Prefix prefix) { // this.prefix = prefix; // } // } // // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java // public class Prefix implements N3Element, Serializable { // private String name; // private String uri; // // public Prefix(String name, String uri) { // this.name = name; // this.uri = uri.substring(1, uri.length() - 1); // } // // public String getName() { // return name; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // @Override // public <T> T accept(IN3ElementVisitor<T> b) { // return b.visitPrefix(this); // } // // @Override // public Iterable<? extends N3Element> getChildern() { // return null; // } // // @Override // public void replace(N3Element n, N3Element replace) { // throw new RuntimeException("Unexpected call"); // } // // public void setName(String name) { // this.name = name; // } // // @Override // public String toString() { // // StringBuilder sb = new StringBuilder(); // sb.append("@prefix "); // sb.append(getName()); // sb.append(" <"); // sb.append(getUri()); // sb.append(">."); // return sb.toString(); // } // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/UsedPrefixesElementVisitor.java import ch.ethz.inf.vs.semantics.parser.elements.Iri; import ch.ethz.inf.vs.semantics.parser.elements.Prefix; import java.util.HashSet; import java.util.Set; package ch.ethz.inf.vs.semantics.parser.visitors; public class UsedPrefixesElementVisitor extends N3BaseElementVisitor<Set<Prefix>> { @Override public Set<Prefix> defaultResult() { return new HashSet<Prefix>(); } @Override public Set<Prefix> aggregateResult(Set<Prefix> result, Set<Prefix> cResult) { if (cResult != null) { result.addAll(cResult); } return result; } @Override
public Set<Prefix> visitIri(Iri iri) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class Prefix implements N3Element, Serializable { private String name; private String uri; public Prefix(String name, String uri) { this.name = name; this.uri = uri.substring(1, uri.length() - 1); } public String getName() { return name; } public String getUri() { return uri; } public void setUri(String uri) { this.uri = uri; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/Prefix.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class Prefix implements N3Element, Serializable { private String name; private String uri; public Prefix(String name, String uri) { this.name = name; this.uri = uri.substring(1, uri.length() - 1); } public String getName() { return name; } public String getUri() { return uri; } public void setUri(String uri) { this.uri = uri; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
mkovatsc/iot-semantics
parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/BlankNode.java
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // }
import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable;
package ch.ethz.inf.vs.semantics.parser.elements; public class BlankNode implements N3Element.Object, N3Element.Subject, N3Element, Serializable { private final String text; public BlankNode(String text) { this.text = text; } @Override public String toString() { return text; } @Override
// Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/visitors/IN3ElementVisitor.java // public interface IN3ElementVisitor<T> { // public T visitBlankNode(BlankNode blankNode); // // T visitBlankNodePropertyList(BlankNodePropertyList verbObjects); // // T visitBooleanLiteral(BooleanLiteral booleanLiteral); // // T vistClassification(Classification classification); // // T vistExvar(Exvar exvar); // // T vistFormula(Formula statements); // // T visitIri(Iri iri); // // T visitLiteral(Literal literal); // // T visitObjectCollection(ObjectCollection objects); // // T visitObjectList(ObjectList objects); // // T visitStatements(Statements statements); // // T visitRDFResource(RDFResource RDFResource); // // T visitVerb(Verb verb); // // T visitVerbObject(VerbObject verbObject); // // T visitN3Document(N3Document n3Document); // // T visitPrefix(Prefix p); // } // Path: parser/src/main/java/ch/ethz/inf/vs/semantics/parser/elements/BlankNode.java import ch.ethz.inf.vs.semantics.parser.visitors.IN3ElementVisitor; import java.io.Serializable; package ch.ethz.inf.vs.semantics.parser.elements; public class BlankNode implements N3Element.Object, N3Element.Subject, N3Element, Serializable { private final String text; public BlankNode(String text) { this.text = text; } @Override public String toString() { return text; } @Override
public <T> T accept(IN3ElementVisitor<T> b) {
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/ProgressDialogFragment.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.app.Dialog; import android.app.ProgressDialog; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import ca.rmen.android.scrumchatter.util.Log; import android.widget.ProgressBar; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R;
/* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Implements a dialog fragment with a ProgressDialog with a message. */ public class ProgressDialogFragment extends DialogFragment { private static final String TAG = Constants.TAG + "/" + ProgressDialogFragment.class.getSimpleName(); public ProgressDialogFragment() { super(); } /** * @return an indeterminate, non-cancelable, ProgressDialog with a message. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ProgressDialogFragment.java import android.app.Dialog; import android.app.ProgressDialog; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import ca.rmen.android.scrumchatter.util.Log; import android.widget.ProgressBar; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R; /* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Implements a dialog fragment with a ProgressDialog with a message. */ public class ProgressDialogFragment extends DialogFragment { private static final String TAG = Constants.TAG + "/" + ProgressDialogFragment.class.getSimpleName(); public ProgressDialogFragment() { super(); } /** * @return an indeterminate, non-cancelable, ProgressDialog with a message. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/export/Export.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // }
import ca.rmen.android.scrumchatter.BuildConfig; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.util.Log; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; import android.support.annotation.Nullable; import android.support.v4.content.FileProvider; import java.io.File; import java.util.List;
/* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; class Export { private static final String TAG = Constants.TAG + "/" + Export.class.getSimpleName(); private static final String EXPORT_FOLDER_PATH = "export"; /** * @return File in the share folder that we can write to before sharing. */ @Nullable static File getExportFile(Context context, String filename) { File exportFolder = new File(context.getFilesDir(), EXPORT_FOLDER_PATH); if (!exportFolder.exists() && !exportFolder.mkdirs()) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/export/Export.java import ca.rmen.android.scrumchatter.BuildConfig; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.util.Log; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; import android.support.annotation.Nullable; import android.support.v4.content.FileProvider; import java.io.File; import java.util.List; /* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; class Export { private static final String TAG = Constants.TAG + "/" + Export.class.getSimpleName(); private static final String EXPORT_FOLDER_PATH = "export"; /** * @return File in the share folder that we can write to before sharing. */ @Nullable static File getExportFile(Context context, String filename) { File exportFolder = new File(context.getFilesDir(), EXPORT_FOLDER_PATH); if (!exportFolder.exists() && !exportFolder.mkdirs()) {
Log.v(TAG, "Couldn't find or create export folder " + exportFolder);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/InfoDialogFragment.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants;
/* * Copyright 2013 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Shows a dialog with a title, message, and a single button to dismiss the dialog. */ public class InfoDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + InfoDialogFragment.class.getSimpleName(); public InfoDialogFragment() { super(); } /** * @return an AlertDialog with a title, message, and single button to dismiss the dialog. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/InfoDialogFragment.java import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; /* * Copyright 2013 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Shows a dialog with a title, message, and a single button to dismiss the dialog. */ public class InfoDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + InfoDialogFragment.class.getSimpleName(); public InfoDialogFragment() { super(); } /** * @return an AlertDialog with a title, message, and single button to dismiss the dialog. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/export/FileExport.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; import java.io.File; import android.content.Context;
/* * Copyright 2013-2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; /** * Base class for sharing a file using an intent chooser. The base classes must provide a mime-type (used to determine which apps can share the file) and must * override {@link #createFile()} to provide a file to share. */ public abstract class FileExport { private static final String TAG = Constants.TAG + "/" + FileExport.class.getSimpleName(); final Context mContext; private final String mMimeType; /** * @param mimeType will be used to show a list of applications which can share the file created by {@link #createFile()}. */ FileExport(Context context, String mimeType) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/export/FileExport.java import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; import java.io.File; import android.content.Context; /* * Copyright 2013-2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; /** * Base class for sharing a file using an intent chooser. The base classes must provide a mime-type (used to determine which apps can share the file) and must * override {@link #createFile()} to provide a file to share. */ public abstract class FileExport { private static final String TAG = Constants.TAG + "/" + FileExport.class.getSimpleName(); final Context mContext; private final String mMimeType; /** * @param mimeType will be used to show a list of applications which can share the file created by {@link #createFile()}. */ FileExport(Context context, String mimeType) {
Log.v(TAG, "Constructor: mimeType=" + mimeType);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/provider/ScrumChatterDatabase.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // }
import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.R;
private static final String SQL_DROP_TABLE_MEETING_TEMP = "DROP TABLE " + MeetingColumns.TABLE_NAME + TEMP_SUFFIX; private static final String SQL_CREATE_VIEW_MEMBER_STATS = "CREATE VIEW " + MemberStatsColumns.VIEW_NAME + " AS " + " SELECT " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + " AS " + MemberColumns._ID + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.NAME + " AS " + MemberColumns.NAME + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.DELETED + " AS " + MemberColumns.DELETED + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.TEAM_ID + " AS " + MemberStatsColumns.TEAM_ID + ", " + " SUM(" + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + ") AS " + MemberStatsColumns.SUM_DURATION + "," + " AVG(" + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + ") AS " + MemberStatsColumns.AVG_DURATION + " FROM " + MemberColumns.TABLE_NAME + " LEFT OUTER JOIN " + MeetingMemberColumns.TABLE_NAME + " ON " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + " = " + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.MEMBER_ID + " AND " + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + "> 0" + " GROUP BY " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.NAME + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.DELETED + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.TEAM_ID; private static final String SQL_DROP_VIEW_MEMBER_STATS = "DROP VIEW " + MemberStatsColumns.VIEW_NAME; private final Context mContext; ScrumChatterDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); mContext = context; } @Override public void onCreate(SQLiteDatabase db) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/ScrumChatterDatabase.java import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.R; private static final String SQL_DROP_TABLE_MEETING_TEMP = "DROP TABLE " + MeetingColumns.TABLE_NAME + TEMP_SUFFIX; private static final String SQL_CREATE_VIEW_MEMBER_STATS = "CREATE VIEW " + MemberStatsColumns.VIEW_NAME + " AS " + " SELECT " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + " AS " + MemberColumns._ID + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.NAME + " AS " + MemberColumns.NAME + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.DELETED + " AS " + MemberColumns.DELETED + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.TEAM_ID + " AS " + MemberStatsColumns.TEAM_ID + ", " + " SUM(" + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + ") AS " + MemberStatsColumns.SUM_DURATION + "," + " AVG(" + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + ") AS " + MemberStatsColumns.AVG_DURATION + " FROM " + MemberColumns.TABLE_NAME + " LEFT OUTER JOIN " + MeetingMemberColumns.TABLE_NAME + " ON " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + " = " + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.MEMBER_ID + " AND " + MeetingMemberColumns.TABLE_NAME + "." + MeetingMemberColumns.DURATION + "> 0" + " GROUP BY " + MemberColumns.TABLE_NAME + "." + MemberColumns._ID + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.NAME + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.DELETED + ", " + MemberColumns.TABLE_NAME + "." + MemberColumns.TEAM_ID; private static final String SQL_DROP_VIEW_MEMBER_STATS = "DROP VIEW " + MemberStatsColumns.VIEW_NAME; private final Context mContext; ScrumChatterDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); mContext = context; } @Override public void onCreate(SQLiteDatabase db) {
Log.d(TAG, "onCreate");
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/export/BitmapExport.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // }
import android.content.Context; import android.graphics.Bitmap; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log;
/* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; /** * Export a bitmap as a png file. */ public class BitmapExport { private static final String TAG = Constants.TAG + "/" + BitmapExport.class.getSimpleName(); private static final String FILE = "scrumchatter.png"; private static final String MIME_TYPE = "image/png"; private final Context mContext; private final Bitmap mBitmap; public BitmapExport(Context context, Bitmap bitmap) { mBitmap = bitmap; mContext = context; } /** * Create and return a bitmap of our view. * * @see FileExport#createFile() */ private File createFile() {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/export/BitmapExport.java import android.content.Context; import android.graphics.Bitmap; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; /* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.export; /** * Export a bitmap as a png file. */ public class BitmapExport { private static final String TAG = Constants.TAG + "/" + BitmapExport.class.getSimpleName(); private static final String FILE = "scrumchatter.png"; private static final String MIME_TYPE = "image/png"; private final Context mContext; private final Bitmap mBitmap; public BitmapExport(Context context, Bitmap bitmap) { mBitmap = bitmap; mContext = context; } /** * Create and return a bitmap of our view. * * @see FileExport#createFile() */ private File createFile() {
Log.v(TAG, "export");
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/ChoiceDialogFragment.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.app.Dialog; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants;
/* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with a list of choices. */ public class ChoiceDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + ChoiceDialogFragment.class.getSimpleName(); /** * An activity which contains a choice dialog fragment should implement this interface. */ public interface DialogItemListener { void onItemSelected(int actionId, CharSequence[] choices, int which); } public ChoiceDialogFragment() { super(); } /** * @return an AlertDialog with a list of items, one of them possibly pre-selected. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ChoiceDialogFragment.java import android.app.Dialog; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; /* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with a list of choices. */ public class ChoiceDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + ChoiceDialogFragment.class.getSimpleName(); /** * An activity which contains a choice dialog fragment should implement this interface. */ public interface DialogItemListener { void onItemSelected(int actionId, CharSequence[] choices, int which); } public ChoiceDialogFragment() { super(); } /** * @return an AlertDialog with a list of items, one of them possibly pre-selected. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);