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 |
|---|---|---|---|---|---|---|
apptik/MultiView | scrollers/src/main/java/io/apptik/multiview/scrollers/FlexiSmoothScroller.java | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
| import android.content.Context;
import android.graphics.PointF;
import android.support.v7.widget.RecyclerView;
import io.apptik.multiview.common.Log; | public void setAfterScrollAction(Runnable afterScrollAction) {
this.afterScrollAction = afterScrollAction;
}
public Runnable getBeforeScrollAction() {
return beforeScrollAction;
}
public void setBeforeScrollAction(Runnable beforeScrollAction) {
this.beforeScrollAction = beforeScrollAction;
}
@Override
protected void onStop() {
if(afterScrollAction!=null) {
afterScrollAction.run();
}
super.onStop();
}
@Override
protected void onStart() {
if(beforeScrollAction!=null) {
beforeScrollAction.run();
}
super.onStart();
}
@Override
public PointF computeScrollVectorForPosition(int targetPosition) { | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
// Path: scrollers/src/main/java/io/apptik/multiview/scrollers/FlexiSmoothScroller.java
import android.content.Context;
import android.graphics.PointF;
import android.support.v7.widget.RecyclerView;
import io.apptik.multiview.common.Log;
public void setAfterScrollAction(Runnable afterScrollAction) {
this.afterScrollAction = afterScrollAction;
}
public Runnable getBeforeScrollAction() {
return beforeScrollAction;
}
public void setBeforeScrollAction(Runnable beforeScrollAction) {
this.beforeScrollAction = beforeScrollAction;
}
@Override
protected void onStop() {
if(afterScrollAction!=null) {
afterScrollAction.run();
}
super.onStop();
}
@Override
protected void onStart() {
if(beforeScrollAction!=null) {
beforeScrollAction.run();
}
super.onStart();
}
@Override
public PointF computeScrollVectorForPosition(int targetPosition) { | Log.d("computeScrollVectorForPosition"); |
apptik/MultiView | galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/gestures/CupcakeGestureDetector.java | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
| import android.content.Context;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import io.apptik.multiview.common.Log; | mTouchSlop = configuration.getScaledTouchSlop();
}
private VelocityTracker mVelocityTracker;
private boolean mIsDragging;
float getActiveX(MotionEvent ev) {
return ev.getX();
}
float getActiveY(MotionEvent ev) {
return ev.getY();
}
public boolean isScaling() {
return false;
}
public boolean isDragging() {
return mIsDragging;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
mVelocityTracker = VelocityTracker.obtain();
if (null != mVelocityTracker) {
mVelocityTracker.addMovement(ev);
} else { | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
// Path: galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/gestures/CupcakeGestureDetector.java
import android.content.Context;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import io.apptik.multiview.common.Log;
mTouchSlop = configuration.getScaledTouchSlop();
}
private VelocityTracker mVelocityTracker;
private boolean mIsDragging;
float getActiveX(MotionEvent ev) {
return ev.getX();
}
float getActiveY(MotionEvent ev) {
return ev.getY();
}
public boolean isScaling() {
return false;
}
public boolean isDragging() {
return mIsDragging;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
mVelocityTracker = VelocityTracker.obtain();
if (null != mVelocityTracker) {
mVelocityTracker.addMovement(ev);
} else { | Log.i("Velocity tracker is null"); |
apptik/MultiView | galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/gestures/EclairGestureDetector.java | // Path: galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/Compat.java
// public class Compat {
//
// private static final int SIXTY_FPS_INTERVAL = 1000 / 60;
//
// public static void postOnAnimation(View view, Runnable runnable) {
// if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
// postOnAnimationJellyBean(view, runnable);
// } else {
// view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
// }
// }
//
// @TargetApi(16)
// private static void postOnAnimationJellyBean(View view, Runnable runnable) {
// view.postOnAnimation(runnable);
// }
//
// public static int getPointerIndex(int action) {
// if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB)
// return getPointerIndexHoneyComb(action);
// else
// return getPointerIndexEclair(action);
// }
//
// @SuppressWarnings("deprecation")
// @TargetApi(Build.VERSION_CODES.ECLAIR)
// private static int getPointerIndexEclair(int action) {
// return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// private static int getPointerIndexHoneyComb(int action) {
// return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
// }
//
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.view.MotionEvent;
import io.apptik.multiview.galleryview.scaleimage.Compat; | return ev.getX(mActivePointerIndex);
} catch (Exception e) {
return ev.getX();
}
}
@Override
float getActiveY(MotionEvent ev) {
try {
return ev.getY(mActivePointerIndex);
} catch (Exception e) {
return ev.getY();
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = ev.getPointerId(0);
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
mActivePointerId = INVALID_POINTER_ID;
break;
case MotionEvent.ACTION_POINTER_UP:
// Ignore deprecation, ACTION_POINTER_ID_MASK and
// ACTION_POINTER_ID_SHIFT has same value and are deprecated
// You can have either deprecation or lint target api warning | // Path: galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/Compat.java
// public class Compat {
//
// private static final int SIXTY_FPS_INTERVAL = 1000 / 60;
//
// public static void postOnAnimation(View view, Runnable runnable) {
// if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
// postOnAnimationJellyBean(view, runnable);
// } else {
// view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
// }
// }
//
// @TargetApi(16)
// private static void postOnAnimationJellyBean(View view, Runnable runnable) {
// view.postOnAnimation(runnable);
// }
//
// public static int getPointerIndex(int action) {
// if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB)
// return getPointerIndexHoneyComb(action);
// else
// return getPointerIndexEclair(action);
// }
//
// @SuppressWarnings("deprecation")
// @TargetApi(Build.VERSION_CODES.ECLAIR)
// private static int getPointerIndexEclair(int action) {
// return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// private static int getPointerIndexHoneyComb(int action) {
// return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
// }
//
// }
// Path: galleryview/src/main/java/io/apptik/multiview/galleryview/scaleimage/gestures/EclairGestureDetector.java
import android.annotation.TargetApi;
import android.content.Context;
import android.view.MotionEvent;
import io.apptik.multiview.galleryview.scaleimage.Compat;
return ev.getX(mActivePointerIndex);
} catch (Exception e) {
return ev.getX();
}
}
@Override
float getActiveY(MotionEvent ev) {
try {
return ev.getY(mActivePointerIndex);
} catch (Exception e) {
return ev.getY();
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = ev.getPointerId(0);
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
mActivePointerId = INVALID_POINTER_ID;
break;
case MotionEvent.ACTION_POINTER_UP:
// Ignore deprecation, ACTION_POINTER_ID_MASK and
// ACTION_POINTER_ID_SHIFT has same value and are deprecated
// You can have either deprecation or lint target api warning | final int pointerIndex = Compat.getPointerIndex(ev.getAction()); |
apptik/MultiView | layoutmanagers/src/main/java/io/apptik/multiview/layoutmanagers/AbstractPagerLLM.java | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import io.apptik.multiview.common.Log; | }
public View getCurrentPageView() {
if (getChildCount() == 1) {
return getChildAt(0);
} else {
return getCenterItem();
}
}
@Override
protected void onPositionChanging(int currPos, int newPos) {
if (pageChangeListener != null) {
pageChangeListener.onPageChanging(currPos, newPos);
}
super.onPositionChanging(currPos, newPos);
}
@Override
protected void onPositionChanged(int prevPos, int newPos) {
if (pageChangeListener != null) {
pageChangeListener.onPageChanged(prevPos, newPos);
}
super.onPositionChanged(prevPos, newPos);
}
@Override
public void onScrollStateChanged(int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
isIdle = false; | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
// Path: layoutmanagers/src/main/java/io/apptik/multiview/layoutmanagers/AbstractPagerLLM.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import io.apptik.multiview.common.Log;
}
public View getCurrentPageView() {
if (getChildCount() == 1) {
return getChildAt(0);
} else {
return getCenterItem();
}
}
@Override
protected void onPositionChanging(int currPos, int newPos) {
if (pageChangeListener != null) {
pageChangeListener.onPageChanging(currPos, newPos);
}
super.onPositionChanging(currPos, newPos);
}
@Override
protected void onPositionChanged(int prevPos, int newPos) {
if (pageChangeListener != null) {
pageChangeListener.onPageChanged(prevPos, newPos);
}
super.onPositionChanged(prevPos, newPos);
}
@Override
public void onScrollStateChanged(int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
isIdle = false; | Log.d("onScrollStateChanged DRAGGING"); |
apptik/MultiView | scrollers/src/main/java/io/apptik/multiview/scrollers/BaseSmoothScroller.java | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
| import android.content.Context;
import android.graphics.PointF;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import io.apptik.multiview.common.Log; | }
public BaseSmoothScroller setVerticalSnapPreference(int verticalSnapPreference) {
this.mVerticalSnapPreference = verticalSnapPreference;
return this;
}
public Interpolator getSearchingTargetInterpolator() {
return mSearchingTargetInterpolator;
}
public BaseSmoothScroller setSearchingTargetInterpolator(Interpolator searchingTargetInterpolator) {
this.mSearchingTargetInterpolator = searchingTargetInterpolator;
return this;
}
public Interpolator getFoundTargetInterpolator() {
return mFoundTargetInterpolator;
}
public BaseSmoothScroller setFoundTargetInterpolator(Interpolator foundTargetInterpolator) {
this.mFoundTargetInterpolator = foundTargetInterpolator;
return this;
}
/**
* {@inheritDoc}
*/
@Override
protected void onStart() { | // Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
// Path: scrollers/src/main/java/io/apptik/multiview/scrollers/BaseSmoothScroller.java
import android.content.Context;
import android.graphics.PointF;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import io.apptik.multiview.common.Log;
}
public BaseSmoothScroller setVerticalSnapPreference(int verticalSnapPreference) {
this.mVerticalSnapPreference = verticalSnapPreference;
return this;
}
public Interpolator getSearchingTargetInterpolator() {
return mSearchingTargetInterpolator;
}
public BaseSmoothScroller setSearchingTargetInterpolator(Interpolator searchingTargetInterpolator) {
this.mSearchingTargetInterpolator = searchingTargetInterpolator;
return this;
}
public Interpolator getFoundTargetInterpolator() {
return mFoundTargetInterpolator;
}
public BaseSmoothScroller setFoundTargetInterpolator(Interpolator foundTargetInterpolator) {
this.mFoundTargetInterpolator = foundTargetInterpolator;
return this;
}
/**
* {@inheritDoc}
*/
@Override
protected void onStart() { | Log.d("onStart"); |
apptik/MultiView | app/src/main/java/io/apptik/multiview/SampleApp.java | // Path: app/src/main/java/io/apptik/multiview/common/BitmapLruCache.java
// public class BitmapLruCache extends LruCache<Uri, Bitmap> {
//
// private static BitmapLruCache inst;
//
// public static BitmapLruCache get() {
// if(inst==null) {
// inst = new BitmapLruCache();
// }
// return inst;
// }
//
// public BitmapLruCache(int maxSize) {
// super(maxSize);
// }
//
//
// public static int getDefaultLruCacheSize() {
// final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
// final int cacheSize = maxMemory / 8;
// return cacheSize;
// }
//
// public BitmapLruCache() {
// this(getDefaultLruCacheSize());
// }
//
// @Override
// protected int sizeOf(Uri key, Bitmap value) {
// return value.getByteCount() / 1024;
// }
//
//
// public Bitmap getBitmap(Uri uri, Context ctx, int maxW, int maxH) {
// Bitmap res = get(uri);
// if (res == null) {
// InputStream stream = null;
// try {
// stream = ctx.getContentResolver().openInputStream(uri);
//
// res = DecodeUtils.decode(ctx, uri, maxW, maxH);
// } catch (Exception e) {
// Log.w("BitmapLruCache", "Unable to open content: " + uri, e);
// } finally {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// Log.w("BitmapLruCache", "Unable to close content: " + uri, e);
// }
// }
// }
//
// putBitmap(uri, res);
// }
// return res;
// }
//
//
// public void putBitmap(Uri url, Bitmap bitmap) {
// if(url==null || bitmap==null) return;
// put(url, bitmap);
// }
//
//
// }
//
// Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
| import android.app.Application;
import io.apptik.multiview.common.BitmapLruCache;
import io.apptik.multiview.common.Log; | /*
* Copyright (C) 2015 AppTik Project
*
* 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.apptik.multiview;
public class SampleApp extends Application {
BitmapLruCache bitmapLruCache;
@Override
public void onCreate() {
super.onCreate(); | // Path: app/src/main/java/io/apptik/multiview/common/BitmapLruCache.java
// public class BitmapLruCache extends LruCache<Uri, Bitmap> {
//
// private static BitmapLruCache inst;
//
// public static BitmapLruCache get() {
// if(inst==null) {
// inst = new BitmapLruCache();
// }
// return inst;
// }
//
// public BitmapLruCache(int maxSize) {
// super(maxSize);
// }
//
//
// public static int getDefaultLruCacheSize() {
// final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
// final int cacheSize = maxMemory / 8;
// return cacheSize;
// }
//
// public BitmapLruCache() {
// this(getDefaultLruCacheSize());
// }
//
// @Override
// protected int sizeOf(Uri key, Bitmap value) {
// return value.getByteCount() / 1024;
// }
//
//
// public Bitmap getBitmap(Uri uri, Context ctx, int maxW, int maxH) {
// Bitmap res = get(uri);
// if (res == null) {
// InputStream stream = null;
// try {
// stream = ctx.getContentResolver().openInputStream(uri);
//
// res = DecodeUtils.decode(ctx, uri, maxW, maxH);
// } catch (Exception e) {
// Log.w("BitmapLruCache", "Unable to open content: " + uri, e);
// } finally {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// Log.w("BitmapLruCache", "Unable to close content: " + uri, e);
// }
// }
// }
//
// putBitmap(uri, res);
// }
// return res;
// }
//
//
// public void putBitmap(Uri url, Bitmap bitmap) {
// if(url==null || bitmap==null) return;
// put(url, bitmap);
// }
//
//
// }
//
// Path: common/src/main/java/io/apptik/multiview/common/Log.java
// public class Log {
//
// private static final int CALL_STACK_INDEX = 5;
// private static final Pattern ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$");
// private static boolean DEBUG = false;
//
// public static void on() {
// DEBUG = true;
// }
// public static void off() {
// DEBUG = false;
// }
// public static void v(String msg) {
// if(DEBUG) {
// android.util.Log.v(getTag(), msg);
// }
// }
//
// public static void d(String msg) {
// if(DEBUG) {
// android.util.Log.d(getTag(), msg);
// }
// }
//
// public static void i(String msg) {
// if(DEBUG) {
// android.util.Log.i(getTag(), msg);
// }
// }
//
// public static void w(String msg) {
// if(DEBUG) {
// android.util.Log.w(getTag(), msg);
// }
// }
//
// public static void e(String msg) {
// if(DEBUG) {
// android.util.Log.e(getTag(), msg);
// }
// }
//
// public static void wtf(String msg) {
// if(DEBUG) {
// android.util.Log.wtf(getTag(), msg);
// }
// }
//
// private static String getTag() {
// StackTraceElement[] stackTrace = new Throwable().getStackTrace();
// if (stackTrace.length <= CALL_STACK_INDEX) {
// throw new IllegalStateException(
// "Synthetic stacktrace didn't have enough elements: are you using proguard?");
// }
// return createStackElementTag(stackTrace[CALL_STACK_INDEX]);
// }
//
// protected static String createStackElementTag(StackTraceElement element) {
// String tag = element.getClassName();
// Matcher m = ANONYMOUS_CLASS.matcher(tag);
// if (m.find()) {
// tag = m.replaceAll("");
// }
// return tag.substring(tag.lastIndexOf('.') + 1);
// }
// }
// Path: app/src/main/java/io/apptik/multiview/SampleApp.java
import android.app.Application;
import io.apptik.multiview.common.BitmapLruCache;
import io.apptik.multiview.common.Log;
/*
* Copyright (C) 2015 AppTik Project
*
* 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.apptik.multiview;
public class SampleApp extends Application {
BitmapLruCache bitmapLruCache;
@Override
public void onCreate() {
super.onCreate(); | Log.on(); |
tagsys/tagbeat | src/main/java/org/tagsys/tagbeat/WebSocketServer.java | // Path: src/main/java/org/tagsys/tagbeat/cr/Signal.java
// public class Signal{
//
// public static final int CODE_NO_ERROR = 0;
//
// public static final int CODE_NO_VIBRATION = 1;
//
// protected int code;
//
// protected boolean[] timeIndicator;
//
// protected RealMatrix phaseSeries;
//
// protected RealMatrix phi;
//
// protected RealMatrix recoveredSeries;
//
// protected double frequency;//the fundamental frequency
//
//
// public boolean[] getTimeIndicator() {
// return timeIndicator;
// }
//
// public void setTimeIndicator(boolean[] timeIndicator) {
// this.timeIndicator = timeIndicator;
// }
//
// public RealMatrix getPhaseSeries() {
// return phaseSeries;
// }
//
// public void setPhaseSeries(RealMatrix phaseSeries) {
// this.phaseSeries = phaseSeries;
// }
//
// public RealMatrix getPhi() {
// return phi;
// }
//
// public void setPhi(RealMatrix phi) {
// this.phi = phi;
// }
//
// public RealMatrix getRecoveredSeries() {
// return recoveredSeries;
// }
//
// public void setRecoveredSeries(RealMatrix recoveredSeries) {
// this.recoveredSeries = recoveredSeries;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double frequency) {
// this.frequency = frequency;
// }
//
//
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.tagsys.tagbeat.cr.Signal;
import com.google.gson.Gson; | package org.tagsys.tagbeat;
/**
* Handler the messages needed to broadcast to browsers.
*
* @author Young
*
*/
@WebSocket
public class WebSocketServer {
private static List<Session> sessions = new ArrayList<Session>();
protected static WebSocketServer instance;
public static WebSocketServer getInstance(){
return instance;
}
public WebSocketServer(){
instance = this;
}
@OnWebSocketConnect
public void onConnect(Session session) throws Exception {
System.out.println("on connect");
sessions.add(session);
}
@OnWebSocketClose
public void onClose(Session session, int statusCode, String reason) {
sessions.remove(session);
}
@OnWebSocketMessage
public void onMessage(Session session, String message) {
//keep nothing, we don't need receive any message from browser.
}
| // Path: src/main/java/org/tagsys/tagbeat/cr/Signal.java
// public class Signal{
//
// public static final int CODE_NO_ERROR = 0;
//
// public static final int CODE_NO_VIBRATION = 1;
//
// protected int code;
//
// protected boolean[] timeIndicator;
//
// protected RealMatrix phaseSeries;
//
// protected RealMatrix phi;
//
// protected RealMatrix recoveredSeries;
//
// protected double frequency;//the fundamental frequency
//
//
// public boolean[] getTimeIndicator() {
// return timeIndicator;
// }
//
// public void setTimeIndicator(boolean[] timeIndicator) {
// this.timeIndicator = timeIndicator;
// }
//
// public RealMatrix getPhaseSeries() {
// return phaseSeries;
// }
//
// public void setPhaseSeries(RealMatrix phaseSeries) {
// this.phaseSeries = phaseSeries;
// }
//
// public RealMatrix getPhi() {
// return phi;
// }
//
// public void setPhi(RealMatrix phi) {
// this.phi = phi;
// }
//
// public RealMatrix getRecoveredSeries() {
// return recoveredSeries;
// }
//
// public void setRecoveredSeries(RealMatrix recoveredSeries) {
// this.recoveredSeries = recoveredSeries;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double frequency) {
// this.frequency = frequency;
// }
//
//
//
// }
// Path: src/main/java/org/tagsys/tagbeat/WebSocketServer.java
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.tagsys.tagbeat.cr.Signal;
import com.google.gson.Gson;
package org.tagsys.tagbeat;
/**
* Handler the messages needed to broadcast to browsers.
*
* @author Young
*
*/
@WebSocket
public class WebSocketServer {
private static List<Session> sessions = new ArrayList<Session>();
protected static WebSocketServer instance;
public static WebSocketServer getInstance(){
return instance;
}
public WebSocketServer(){
instance = this;
}
@OnWebSocketConnect
public void onConnect(Session session) throws Exception {
System.out.println("on connect");
sessions.add(session);
}
@OnWebSocketClose
public void onClose(Session session, int statusCode, String reason) {
sessions.remove(session);
}
@OnWebSocketMessage
public void onMessage(Session session, String message) {
//keep nothing, we don't need receive any message from browser.
}
| public void broadcast(String epc, Signal signal){ |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/Menus/menuMain.java | // Path: app/src/main/java/org/bobstuff/bobball/Preferences.java
// public class Preferences extends Application {
//
// private static SharedPreferences sharedPreferences;
// private static Context appContext;
//
// public static void setContext (Context context)
// {
// appContext = context;
// sharedPreferences = context.getSharedPreferences("sharedPreferences", Context.MODE_PRIVATE);
// }
//
// public static Context getContext () {
// return appContext;
// }
//
// public static String loadValue (String filename, String defaultValue) {
// return sharedPreferences.getString (filename, defaultValue);
// }
//
// public static void saveValue (String filename, String value) {
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString(filename, value);
// editor.commit();
// }
// }
| import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import org.bobstuff.bobball.Preferences;
import org.bobstuff.bobball.R; | package org.bobstuff.bobball.Menus;
public class menuMain extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.menu_main);
}
public void onResume() {
super.onResume(); | // Path: app/src/main/java/org/bobstuff/bobball/Preferences.java
// public class Preferences extends Application {
//
// private static SharedPreferences sharedPreferences;
// private static Context appContext;
//
// public static void setContext (Context context)
// {
// appContext = context;
// sharedPreferences = context.getSharedPreferences("sharedPreferences", Context.MODE_PRIVATE);
// }
//
// public static Context getContext () {
// return appContext;
// }
//
// public static String loadValue (String filename, String defaultValue) {
// return sharedPreferences.getString (filename, defaultValue);
// }
//
// public static void saveValue (String filename, String value) {
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString(filename, value);
// editor.commit();
// }
// }
// Path: app/src/main/java/org/bobstuff/bobball/Menus/menuMain.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import org.bobstuff.bobball.Preferences;
import org.bobstuff.bobball.R;
package org.bobstuff.bobball.Menus;
public class menuMain extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.menu_main);
}
public void onResume() {
super.onResume(); | Preferences.setContext(getApplicationContext()); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventChat.java | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
| import android.os.Parcel;
import org.bobstuff.bobball.Player; | package org.bobstuff.bobball.GameLogic;
public class GameEventChat extends GameEvent {
public static final Creator<GameEventChat> CREATOR = new Creator<GameEventChat>() {
@Override
public GameEventChat createFromParcel(Parcel in) {
return new GameEventChat(in);
}
@Override
public GameEventChat[] newArray(int size) {
return new GameEventChat[size];
}
};
private String msg = null;
private final int playerId;
public GameEventChat(final int time, final String msg, int playerId) {
super(time);
this.msg = msg;
this.playerId = playerId;
}
//implement parcelable
protected GameEventChat(Parcel in) {
super(in);
msg = in.readString();
playerId = in.readInt();
}
@Override
public void apply(GameState gs) { | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventChat.java
import android.os.Parcel;
import org.bobstuff.bobball.Player;
package org.bobstuff.bobball.GameLogic;
public class GameEventChat extends GameEvent {
public static final Creator<GameEventChat> CREATOR = new Creator<GameEventChat>() {
@Override
public GameEventChat createFromParcel(Parcel in) {
return new GameEventChat(in);
}
@Override
public GameEventChat[] newArray(int size) {
return new GameEventChat[size];
}
};
private String msg = null;
private final int playerId;
public GameEventChat(final int time, final String msg, int playerId) {
super(time);
this.msg = msg;
this.playerId = playerId;
}
//implement parcelable
protected GameEventChat(Parcel in) {
super(in);
msg = in.readString();
playerId = in.readInt();
}
@Override
public void apply(GameState gs) { | Player player = gs.getPlayer(playerId); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/Player.java | // Path: app/src/main/java/org/bobstuff/bobball/GameLogic/Bar.java
// public class Bar implements Parcelable {
// private float speed;
// private BarSection sectionOne = null;
// private BarSection sectionTwo = null;
//
// public Bar(float speed) {
// this.speed = speed;
// }
//
// public Bar(Bar other) {
// this.speed = other.speed;
// if (other.sectionOne != null)
// this.sectionOne = new BarSection(other.sectionOne);
// if (other.sectionTwo != null)
// this.sectionTwo = new BarSection(other.sectionTwo);
// }
//
// public BarSection getSectionOne() {
// return sectionOne;
// }
//
// public BarSection getSectionTwo() {
// return sectionTwo;
// }
//
// public void tryStartHalfbar(final Direction barDirection, final RectF gridSquareFrame) {
//
// if ((sectionOne != null) && (sectionTwo != null))
// return;
//
// float x2 = gridSquareFrame.right;
// float y2 = gridSquareFrame.bottom;
//
// if (barDirection == Direction.UP)
// y2 = gridSquareFrame.top;
// if (barDirection == Direction.LEFT)
// x2 = gridSquareFrame.left;
//
// BarSection bs = new BarSection(
// gridSquareFrame.left,
// gridSquareFrame.top,
// x2,
// y2,
// barDirection,
// speed);
//
// if (sectionOne == null) {
// sectionOne = bs;
// return;
// }
//
// if (sectionTwo == null) {
// sectionTwo = bs;
// return;
// }
//
// }
//
// public void start(final Direction barDirection, final RectF gridSquareFrame) {
// switch (barDirection) {
// case LEFT:
// tryStartHalfbar(Direction.LEFT, gridSquareFrame);
// tryStartHalfbar(Direction.RIGHT, gridSquareFrame);
// break;
// case RIGHT:
// tryStartHalfbar(Direction.RIGHT, gridSquareFrame);
// tryStartHalfbar(Direction.LEFT, gridSquareFrame);
// break;
// case UP:
// tryStartHalfbar(Direction.UP, gridSquareFrame);
// tryStartHalfbar(Direction.DOWN, gridSquareFrame);
// break;
// case DOWN:
// tryStartHalfbar(Direction.DOWN, gridSquareFrame);
// tryStartHalfbar(Direction.UP, gridSquareFrame);
// break;
// }
// }
//
// public void move() {
// if (sectionOne != null) {
// sectionOne.move();
// }
//
// if (sectionTwo != null) {
// sectionTwo.move();
// }
//
// }
//
// public boolean collide(final Ball ball) {
//
// if (sectionOne != null && ball.collide(sectionOne.getFrame())) {
// sectionOne = null;
// return true;
// }
// if (sectionTwo != null && ball.collide(sectionTwo.getFrame())) {
// sectionTwo = null;
// return true;
// }
//
// return false;
// }
//
// public List<RectF> collide(final List<RectF> collisionRects) {
// boolean sectionOneCollision = false;
// boolean sectionTwoCollision = false;
//
// for (int i = 0; i < collisionRects.size(); ++i) {
// RectF collisionRect = collisionRects.get(i);
// if (sectionOne != null && !sectionOneCollision &&
// RectF.intersects(sectionOne.getFrame(), collisionRect)) {
// sectionOneCollision = true;
// }
// if (sectionTwo != null && !sectionTwoCollision &&
// RectF.intersects(sectionTwo.getFrame(), collisionRect)) {
// sectionTwoCollision = true;
// }
// }
//
// if (!sectionOneCollision && !sectionTwoCollision) {
// return null;
// }
//
// List<RectF> sectionCollisionRects = new ArrayList<>(2);
// if (sectionOneCollision) {
// sectionCollisionRects.add(sectionOne.getFrame());
// sectionOne = null;
// }
// if (sectionTwoCollision) {
// sectionCollisionRects.add(sectionTwo.getFrame());
// sectionTwo = null;
// }
//
// return sectionCollisionRects;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeFloat(speed);
//
// dest.writeParcelable(sectionOne, 0);
// dest.writeParcelable(sectionTwo, 0);
// }
//
// public static final Parcelable.Creator<Bar> CREATOR
// = new Parcelable.Creator<Bar>() {
// public Bar createFromParcel(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
//
// float speed = in.readFloat();
//
// Bar bar = new Bar(speed);
// bar.sectionOne = in.readParcelable(classLoader);
// bar.sectionTwo = in.readParcelable(classLoader);
//
// return bar;
// }
//
// public Bar[] newArray(int size) {
// return new Bar[size];
// }
//
// };
//
// }
| import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.GameLogic.Bar;
import android.graphics.Color; | /*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball;
public class Player implements Parcelable {
private int score; | // Path: app/src/main/java/org/bobstuff/bobball/GameLogic/Bar.java
// public class Bar implements Parcelable {
// private float speed;
// private BarSection sectionOne = null;
// private BarSection sectionTwo = null;
//
// public Bar(float speed) {
// this.speed = speed;
// }
//
// public Bar(Bar other) {
// this.speed = other.speed;
// if (other.sectionOne != null)
// this.sectionOne = new BarSection(other.sectionOne);
// if (other.sectionTwo != null)
// this.sectionTwo = new BarSection(other.sectionTwo);
// }
//
// public BarSection getSectionOne() {
// return sectionOne;
// }
//
// public BarSection getSectionTwo() {
// return sectionTwo;
// }
//
// public void tryStartHalfbar(final Direction barDirection, final RectF gridSquareFrame) {
//
// if ((sectionOne != null) && (sectionTwo != null))
// return;
//
// float x2 = gridSquareFrame.right;
// float y2 = gridSquareFrame.bottom;
//
// if (barDirection == Direction.UP)
// y2 = gridSquareFrame.top;
// if (barDirection == Direction.LEFT)
// x2 = gridSquareFrame.left;
//
// BarSection bs = new BarSection(
// gridSquareFrame.left,
// gridSquareFrame.top,
// x2,
// y2,
// barDirection,
// speed);
//
// if (sectionOne == null) {
// sectionOne = bs;
// return;
// }
//
// if (sectionTwo == null) {
// sectionTwo = bs;
// return;
// }
//
// }
//
// public void start(final Direction barDirection, final RectF gridSquareFrame) {
// switch (barDirection) {
// case LEFT:
// tryStartHalfbar(Direction.LEFT, gridSquareFrame);
// tryStartHalfbar(Direction.RIGHT, gridSquareFrame);
// break;
// case RIGHT:
// tryStartHalfbar(Direction.RIGHT, gridSquareFrame);
// tryStartHalfbar(Direction.LEFT, gridSquareFrame);
// break;
// case UP:
// tryStartHalfbar(Direction.UP, gridSquareFrame);
// tryStartHalfbar(Direction.DOWN, gridSquareFrame);
// break;
// case DOWN:
// tryStartHalfbar(Direction.DOWN, gridSquareFrame);
// tryStartHalfbar(Direction.UP, gridSquareFrame);
// break;
// }
// }
//
// public void move() {
// if (sectionOne != null) {
// sectionOne.move();
// }
//
// if (sectionTwo != null) {
// sectionTwo.move();
// }
//
// }
//
// public boolean collide(final Ball ball) {
//
// if (sectionOne != null && ball.collide(sectionOne.getFrame())) {
// sectionOne = null;
// return true;
// }
// if (sectionTwo != null && ball.collide(sectionTwo.getFrame())) {
// sectionTwo = null;
// return true;
// }
//
// return false;
// }
//
// public List<RectF> collide(final List<RectF> collisionRects) {
// boolean sectionOneCollision = false;
// boolean sectionTwoCollision = false;
//
// for (int i = 0; i < collisionRects.size(); ++i) {
// RectF collisionRect = collisionRects.get(i);
// if (sectionOne != null && !sectionOneCollision &&
// RectF.intersects(sectionOne.getFrame(), collisionRect)) {
// sectionOneCollision = true;
// }
// if (sectionTwo != null && !sectionTwoCollision &&
// RectF.intersects(sectionTwo.getFrame(), collisionRect)) {
// sectionTwoCollision = true;
// }
// }
//
// if (!sectionOneCollision && !sectionTwoCollision) {
// return null;
// }
//
// List<RectF> sectionCollisionRects = new ArrayList<>(2);
// if (sectionOneCollision) {
// sectionCollisionRects.add(sectionOne.getFrame());
// sectionOne = null;
// }
// if (sectionTwoCollision) {
// sectionCollisionRects.add(sectionTwo.getFrame());
// sectionTwo = null;
// }
//
// return sectionCollisionRects;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeFloat(speed);
//
// dest.writeParcelable(sectionOne, 0);
// dest.writeParcelable(sectionTwo, 0);
// }
//
// public static final Parcelable.Creator<Bar> CREATOR
// = new Parcelable.Creator<Bar>() {
// public Bar createFromParcel(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
//
// float speed = in.readFloat();
//
// Bar bar = new Bar(speed);
// bar.sectionOne = in.readParcelable(classLoader);
// bar.sectionTwo = in.readParcelable(classLoader);
//
// return bar;
// }
//
// public Bar[] newArray(int size) {
// return new Bar[size];
// }
//
// };
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/Player.java
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.GameLogic.Bar;
import android.graphics.Color;
/*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball;
public class Player implements Parcelable {
private int score; | public Bar bar; |
bobthekingofegypt/BobBall | srv/Server.java | // Path: app/src/main/java/org/bobstuff/bobball/Network/NetworkIP.java
// public class NetworkIP extends NetworkDispatcher {
//
// public static final int BOBBALL_SRV_PORT = 8477;
//
// private ServerSocket srvSock;
//
// public NetworkIP(int uniqueID) {
// super(uniqueID);
// }
//
// public void startServer() {
// startServer(BOBBALL_SRV_PORT);
// }
//
// public void startServer(final int port) {
// if (this.srvSock != null)
// throw new IllegalArgumentException();
//
// this.threadpool.execute(new Runnable() {
// @Override
// public void run() {
//
// try {
// srvSock = new ServerSocket(port);
//
// } catch (IOException e) {
// //Log.d("xx", "IOException ---");
// e.printStackTrace();
// return;
// }
//
// while (true) {
// try {
// Socket s = srvSock.accept();
// addConnection(s.getInputStream(), s.getOutputStream());
// } catch (IOException e) {
// //Log.d("xx", "IOException --zz-");
// e.printStackTrace();
// }
// }
// }
// });
//
// }
//
// public void clientConnect(final String dstName, final int dstPort) {
// this.threadpool.execute(new Runnable() {
// @Override
// public void run() {
// try {
// Socket cliSock = new Socket(dstName, dstPort);
// addConnection(cliSock.getInputStream(), cliSock.getOutputStream());
// } catch (IOException e) {
// e.printStackTrace();
// //Log.d("xx", "IOException --cli-");
// }
// }
// });
// }
//
// }
| import org.bobstuff.bobball.Network.NetworkIP;
import java.lang.Integer;
import java.lang.System;
import java.util.Timer; |
public class Server {
public static void main(String[] args) {
int port = 0;
if (args.length >= 1) {
port = Integer.valueOf(args[0]);
}
System.out.println("Started server on port " + port); | // Path: app/src/main/java/org/bobstuff/bobball/Network/NetworkIP.java
// public class NetworkIP extends NetworkDispatcher {
//
// public static final int BOBBALL_SRV_PORT = 8477;
//
// private ServerSocket srvSock;
//
// public NetworkIP(int uniqueID) {
// super(uniqueID);
// }
//
// public void startServer() {
// startServer(BOBBALL_SRV_PORT);
// }
//
// public void startServer(final int port) {
// if (this.srvSock != null)
// throw new IllegalArgumentException();
//
// this.threadpool.execute(new Runnable() {
// @Override
// public void run() {
//
// try {
// srvSock = new ServerSocket(port);
//
// } catch (IOException e) {
// //Log.d("xx", "IOException ---");
// e.printStackTrace();
// return;
// }
//
// while (true) {
// try {
// Socket s = srvSock.accept();
// addConnection(s.getInputStream(), s.getOutputStream());
// } catch (IOException e) {
// //Log.d("xx", "IOException --zz-");
// e.printStackTrace();
// }
// }
// }
// });
//
// }
//
// public void clientConnect(final String dstName, final int dstPort) {
// this.threadpool.execute(new Runnable() {
// @Override
// public void run() {
// try {
// Socket cliSock = new Socket(dstName, dstPort);
// addConnection(cliSock.getInputStream(), cliSock.getOutputStream());
// } catch (IOException e) {
// e.printStackTrace();
// //Log.d("xx", "IOException --cli-");
// }
// }
// });
// }
//
// }
// Path: srv/Server.java
import org.bobstuff.bobball.Network.NetworkIP;
import java.lang.Integer;
import java.lang.System;
import java.util.Timer;
public class Server {
public static void main(String[] args) {
int port = 0;
if (args.length >= 1) {
port = Integer.valueOf(args[0]);
}
System.out.println("Started server on port " + port); | final NetworkIP nw = new NetworkIP((int) System.currentTimeMillis()); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/BarSection.java | // Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
| import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Direction;
import android.graphics.RectF; | /*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball.GameLogic;
public class BarSection implements Parcelable {
private float speed;
private RectF frame; | // Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/BarSection.java
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Direction;
import android.graphics.RectF;
/*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball.GameLogic;
public class BarSection implements Parcelable {
private float speed;
private RectF frame; | private Direction direction; |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/Bar.java | // Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Direction; | /*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball.GameLogic;
public class Bar implements Parcelable {
private float speed;
private BarSection sectionOne = null;
private BarSection sectionTwo = null;
public Bar(float speed) {
this.speed = speed;
}
public Bar(Bar other) {
this.speed = other.speed;
if (other.sectionOne != null)
this.sectionOne = new BarSection(other.sectionOne);
if (other.sectionTwo != null)
this.sectionTwo = new BarSection(other.sectionTwo);
}
public BarSection getSectionOne() {
return sectionOne;
}
public BarSection getSectionTwo() {
return sectionTwo;
}
| // Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/Bar.java
import java.util.ArrayList;
import java.util.List;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Direction;
/*
Copyright (c) 2012 Richard Martin. All rights reserved.
Licensed under the terms of the BSD License, see LICENSE.txt
*/
package org.bobstuff.bobball.GameLogic;
public class Bar implements Parcelable {
private float speed;
private BarSection sectionOne = null;
private BarSection sectionTwo = null;
public Bar(float speed) {
this.speed = speed;
}
public Bar(Bar other) {
this.speed = other.speed;
if (other.sectionOne != null)
this.sectionOne = new BarSection(other.sectionOne);
if (other.sectionTwo != null)
this.sectionTwo = new BarSection(other.sectionTwo);
}
public BarSection getSectionOne() {
return sectionOne;
}
public BarSection getSectionTwo() {
return sectionTwo;
}
| public void tryStartHalfbar(final Direction barDirection, final RectF gridSquareFrame) { |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventStartBar.java | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
| import android.graphics.PointF;
import android.os.Parcel;
import org.bobstuff.bobball.Player;
import org.bobstuff.bobball.Direction; | package org.bobstuff.bobball.GameLogic;
public class GameEventStartBar extends GameEvent {
public static final Creator<GameEventStartBar> CREATOR = new Creator<GameEventStartBar>() {
@Override
public GameEventStartBar createFromParcel(Parcel in) {
return new GameEventStartBar(in);
}
@Override
public GameEventStartBar[] newArray(int size) {
return new GameEventStartBar[size];
}
};
private final PointF origin; | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventStartBar.java
import android.graphics.PointF;
import android.os.Parcel;
import org.bobstuff.bobball.Player;
import org.bobstuff.bobball.Direction;
package org.bobstuff.bobball.GameLogic;
public class GameEventStartBar extends GameEvent {
public static final Creator<GameEventStartBar> CREATOR = new Creator<GameEventStartBar>() {
@Override
public GameEventStartBar createFromParcel(Parcel in) {
return new GameEventStartBar(in);
}
@Override
public GameEventStartBar[] newArray(int size) {
return new GameEventStartBar[size];
}
};
private final PointF origin; | private final Direction dir; |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventStartBar.java | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
| import android.graphics.PointF;
import android.os.Parcel;
import org.bobstuff.bobball.Player;
import org.bobstuff.bobball.Direction; | @Override
public GameEventStartBar[] newArray(int size) {
return new GameEventStartBar[size];
}
};
private final PointF origin;
private final Direction dir;
private final int playerId;
public GameEventStartBar(final int time, final PointF origin,
final Direction dir, int playerId) {
super(time);
this.origin = origin;
this.dir = dir;
this.playerId = playerId;
}
//implement parcelable
protected GameEventStartBar(Parcel in) {
super(in);
ClassLoader classLoader = getClass().getClassLoader();
origin = in.readParcelable(classLoader);
dir = in.readParcelable(classLoader);
playerId = in.readInt();
}
@Override
public void apply(GameState gs) { | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Direction.java
// public enum Direction implements Parcelable{
// LEFT,
// RIGHT,
// UP,
// DOWN;
//
//
// public static Direction getRandom(Random randomGenerator) {
// return Direction.values()[randomGenerator.nextInt(Direction.values().length)];
// }
//
// //implement parcelable
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(ordinal());
// }
//
//
// public static final Parcelable.Creator<Direction> CREATOR = new Parcelable.Creator<Direction>() {
//
// public Direction createFromParcel(Parcel in) {
// return Direction.values()[in.readInt()];
// }
//
// public Direction[] newArray(int size) {
// return new Direction[size];
// }
//
// };
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventStartBar.java
import android.graphics.PointF;
import android.os.Parcel;
import org.bobstuff.bobball.Player;
import org.bobstuff.bobball.Direction;
@Override
public GameEventStartBar[] newArray(int size) {
return new GameEventStartBar[size];
}
};
private final PointF origin;
private final Direction dir;
private final int playerId;
public GameEventStartBar(final int time, final PointF origin,
final Direction dir, int playerId) {
super(time);
this.origin = origin;
this.dir = dir;
this.playerId = playerId;
}
//implement parcelable
protected GameEventStartBar(Parcel in) {
super(in);
ClassLoader classLoader = getClass().getClassLoader();
origin = in.readParcelable(classLoader);
dir = in.readParcelable(classLoader);
playerId = in.readInt();
}
@Override
public void apply(GameState gs) { | Player player = gs.getPlayer(playerId); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/GameState.java | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
| import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Player;
import java.util.ArrayList;
import java.util.List; | package org.bobstuff.bobball.GameLogic;
public class GameState implements Comparable<GameState>, Parcelable {
private Grid grid; | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/GameState.java
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Player;
import java.util.ArrayList;
import java.util.List;
package org.bobstuff.bobball.GameLogic;
public class GameState implements Comparable<GameState>, Parcelable {
private Grid grid; | private List<Player> players; |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/Menus/menuStatistics.java | // Path: app/src/main/java/org/bobstuff/bobball/Statistics.java
// public class Statistics {
//
// // Highest Level reached
// public static void setHighestLevel (int numPlayers, int levelReached) {
// String valueName = "level";
//
// if (numPlayers > 1){
// valueName = "levelBotMode";
// }
//
// Preferences.saveValue(valueName, "" + levelReached);
// }
//
// public static int getHighestLevel(int numPlayers) {
// String valueName = "level";
//
// if (numPlayers > 1){
// valueName = "levelBotMode";
// }
//
// return Integer.parseInt(Preferences.loadValue(valueName,"1"));
// }
//
// public static int getTopLevel () {
// int topLevel = 1;
// for (int i = 1; i <= 3; i++) {
// int tmp_level = getHighestLevel(i);
// if (topLevel < tmp_level){
// topLevel = tmp_level;
// }
// }
//
// return topLevel;
// }
//
// public static void saveHighestLevel (int numPlayers, int levelReached) {
// int topLevel = getHighestLevel(numPlayers);
//
// if (topLevel < levelReached) {
// setHighestLevel(numPlayers, levelReached);
// }
// }
//
// // Played Games Counter
// public static void setPlayedGames (int playedGames) {
// Preferences.saveValue("playedGames", "" + playedGames);
// }
//
// public static int getPlayedGames () {
// return Integer.parseInt(Preferences.loadValue("playedGames","0"));
// }
//
// public static void increasePlayedGames (){
// setPlayedGames(getPlayedGames() + 1);
// }
//
// // Highest number of levels played in a row without loosing
// public static void setLongestSeries (int longestSeries) {
// Preferences.saveValue("longestSeries", "" + longestSeries);
// }
//
// public static int getLongestSeries (){
// return Integer.parseInt(Preferences.loadValue("longestSeries", "0"));
// }
//
// public static void saveLongestSeries (int longestSeries) {
// int currentLongestSeries = getLongestSeries();
//
// if (currentLongestSeries < longestSeries)
// {
// setLongestSeries(longestSeries);
// }
// }
//
//
// // highest score in a single level
// public static void setHighestLevelScore (int highestLevelScore){
// Preferences.saveValue("highestLevelScore","" + highestLevelScore);
// }
//
// public static int getHighestLevelScore (){
// return Integer.parseInt(Preferences.loadValue("highestLevelScore","0"));
// }
//
// public static void saveHighestLevelScore (int highestLevelScore) {
// int currentHighestLevelScore = getHighestLevelScore();
//
// if (currentHighestLevelScore < highestLevelScore){
// setHighestLevelScore(highestLevelScore);
// }
// }
//
// public static int getTopScore () {
// int topScore = 0;
//
// for (int i = 1; i <= 3; i++){
// Scores scores = new Scores (i);
// scores.loadScores();
// int bestScore = scores.getBestScore();
//
// if (topScore < bestScore){
// topScore = bestScore;
// }
// }
//
// return topScore;
// }
//
// // most time left after finishing a level
//
// public static void setTimeLeftRecord(int timeLeft){
// Preferences.saveValue("timeLeftRecord","" + timeLeft);
// }
//
// public static int getTimeLeftRecord(){
// return Integer.parseInt(Preferences.loadValue("timeLeftRecord","0"));
// }
//
// public static void saveTimeLeftRecord (int timeLeft){
// int currentRecord = getTimeLeftRecord();
//
// if (currentRecord < timeLeft){
// setTimeLeftRecord(timeLeft);
// }
// }
//
// // highest percentage cleared for one level
//
// public static void setPercentageClearedRecord(float percentageCleared){
// Preferences.saveValue("percentageCleared","" + percentageCleared);
// }
//
// public static float getPercentageClearedRecord(){
// return Float.parseFloat(Preferences.loadValue("percentageCleared","0"));
// }
//
// public static void savePercentageClearedRecord (float percentageCleared){
// float currentRecord = getPercentageClearedRecord();
//
// if (currentRecord < percentageCleared){
// setPercentageClearedRecord(percentageCleared);
// }
// }
//
// // most lives left after one level
//
// public static void setLivesLeftRecord(int livesLeft){
// Preferences.saveValue("livesLeft","" + livesLeft);
// }
//
// public static int getLivesLeftRecord(){
// return Integer.parseInt(Preferences.loadValue("livesLeft","0"));
// }
//
// public static void saveLivesLeftRecord(int livesLeft){
// int currentRecord = getLivesLeftRecord();
//
// if (currentRecord < livesLeft){
// setLivesLeftRecord(livesLeft);
// }
// }
//
// // least time left after a single level
//
// public static void setLeastTimeLeft (int timeLeft){
// Preferences.saveValue("leastTimeLeft","" + timeLeft);
// }
//
// public static int getLeastTimeLeft (){
// return Integer.parseInt(Preferences.loadValue("leastTimeLeft","1000000"));
// }
//
// public static void saveLeastTimeLeft (int timeLeft){
// int currentRecord = getLeastTimeLeft();
//
// if (currentRecord > timeLeft){
// setLeastTimeLeft(timeLeft);
// }
// }
// }
| import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Statistics; | package org.bobstuff.bobball.Menus;
public class menuStatistics extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.menu_statistics);
| // Path: app/src/main/java/org/bobstuff/bobball/Statistics.java
// public class Statistics {
//
// // Highest Level reached
// public static void setHighestLevel (int numPlayers, int levelReached) {
// String valueName = "level";
//
// if (numPlayers > 1){
// valueName = "levelBotMode";
// }
//
// Preferences.saveValue(valueName, "" + levelReached);
// }
//
// public static int getHighestLevel(int numPlayers) {
// String valueName = "level";
//
// if (numPlayers > 1){
// valueName = "levelBotMode";
// }
//
// return Integer.parseInt(Preferences.loadValue(valueName,"1"));
// }
//
// public static int getTopLevel () {
// int topLevel = 1;
// for (int i = 1; i <= 3; i++) {
// int tmp_level = getHighestLevel(i);
// if (topLevel < tmp_level){
// topLevel = tmp_level;
// }
// }
//
// return topLevel;
// }
//
// public static void saveHighestLevel (int numPlayers, int levelReached) {
// int topLevel = getHighestLevel(numPlayers);
//
// if (topLevel < levelReached) {
// setHighestLevel(numPlayers, levelReached);
// }
// }
//
// // Played Games Counter
// public static void setPlayedGames (int playedGames) {
// Preferences.saveValue("playedGames", "" + playedGames);
// }
//
// public static int getPlayedGames () {
// return Integer.parseInt(Preferences.loadValue("playedGames","0"));
// }
//
// public static void increasePlayedGames (){
// setPlayedGames(getPlayedGames() + 1);
// }
//
// // Highest number of levels played in a row without loosing
// public static void setLongestSeries (int longestSeries) {
// Preferences.saveValue("longestSeries", "" + longestSeries);
// }
//
// public static int getLongestSeries (){
// return Integer.parseInt(Preferences.loadValue("longestSeries", "0"));
// }
//
// public static void saveLongestSeries (int longestSeries) {
// int currentLongestSeries = getLongestSeries();
//
// if (currentLongestSeries < longestSeries)
// {
// setLongestSeries(longestSeries);
// }
// }
//
//
// // highest score in a single level
// public static void setHighestLevelScore (int highestLevelScore){
// Preferences.saveValue("highestLevelScore","" + highestLevelScore);
// }
//
// public static int getHighestLevelScore (){
// return Integer.parseInt(Preferences.loadValue("highestLevelScore","0"));
// }
//
// public static void saveHighestLevelScore (int highestLevelScore) {
// int currentHighestLevelScore = getHighestLevelScore();
//
// if (currentHighestLevelScore < highestLevelScore){
// setHighestLevelScore(highestLevelScore);
// }
// }
//
// public static int getTopScore () {
// int topScore = 0;
//
// for (int i = 1; i <= 3; i++){
// Scores scores = new Scores (i);
// scores.loadScores();
// int bestScore = scores.getBestScore();
//
// if (topScore < bestScore){
// topScore = bestScore;
// }
// }
//
// return topScore;
// }
//
// // most time left after finishing a level
//
// public static void setTimeLeftRecord(int timeLeft){
// Preferences.saveValue("timeLeftRecord","" + timeLeft);
// }
//
// public static int getTimeLeftRecord(){
// return Integer.parseInt(Preferences.loadValue("timeLeftRecord","0"));
// }
//
// public static void saveTimeLeftRecord (int timeLeft){
// int currentRecord = getTimeLeftRecord();
//
// if (currentRecord < timeLeft){
// setTimeLeftRecord(timeLeft);
// }
// }
//
// // highest percentage cleared for one level
//
// public static void setPercentageClearedRecord(float percentageCleared){
// Preferences.saveValue("percentageCleared","" + percentageCleared);
// }
//
// public static float getPercentageClearedRecord(){
// return Float.parseFloat(Preferences.loadValue("percentageCleared","0"));
// }
//
// public static void savePercentageClearedRecord (float percentageCleared){
// float currentRecord = getPercentageClearedRecord();
//
// if (currentRecord < percentageCleared){
// setPercentageClearedRecord(percentageCleared);
// }
// }
//
// // most lives left after one level
//
// public static void setLivesLeftRecord(int livesLeft){
// Preferences.saveValue("livesLeft","" + livesLeft);
// }
//
// public static int getLivesLeftRecord(){
// return Integer.parseInt(Preferences.loadValue("livesLeft","0"));
// }
//
// public static void saveLivesLeftRecord(int livesLeft){
// int currentRecord = getLivesLeftRecord();
//
// if (currentRecord < livesLeft){
// setLivesLeftRecord(livesLeft);
// }
// }
//
// // least time left after a single level
//
// public static void setLeastTimeLeft (int timeLeft){
// Preferences.saveValue("leastTimeLeft","" + timeLeft);
// }
//
// public static int getLeastTimeLeft (){
// return Integer.parseInt(Preferences.loadValue("leastTimeLeft","1000000"));
// }
//
// public static void saveLeastTimeLeft (int timeLeft){
// int currentRecord = getLeastTimeLeft();
//
// if (currentRecord > timeLeft){
// setLeastTimeLeft(timeLeft);
// }
// }
// }
// Path: app/src/main/java/org/bobstuff/bobball/Menus/menuStatistics.java
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Statistics;
package org.bobstuff.bobball.Menus;
public class menuStatistics extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.menu_statistics);
| String gamesPlayedText = getString(R.string.gamesPlayedText, Statistics.getPlayedGames()); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventNewGame.java | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
| import android.os.Parcel;
import org.bobstuff.bobball.Player;
import java.util.List;
import java.util.Random; | private int cols;
private float ballspeed;
private float barspeed;
private int seed;
public GameEventNewGame(int time, int level, int seed, int rows, int cols, float ballspeed, float barspeed) {
super(time);
this.level = level;
this.rows = rows;
this.cols = cols;
this.ballspeed = ballspeed;
this.barspeed = barspeed;
this.seed = seed;
}
//implement parcelable
protected GameEventNewGame(Parcel in) {
super(in);
level = in.readInt();
rows = in.readInt();
cols = in.readInt();
ballspeed = in.readFloat();
barspeed = in.readFloat();
seed = in.readInt();
}
@Override
public void apply(GameState gs) { | // Path: app/src/main/java/org/bobstuff/bobball/Player.java
// public class Player implements Parcelable {
//
// private int score;
// public Bar bar;
// private int lives;
// public int level;
// private int playerId;
//
// public Player(int playerId) {
// this.score = 0;
// this.bar = null;
// this.lives = 0;
// this.level = 0;
// this.playerId = playerId;
// }
//
// public Player(Player other) {
// this.score = other.score;
// if (other.bar != null)
// this.bar = new Bar(other.bar);
// this.lives = other.lives;
// this.level = other.level;
// this.playerId = other.playerId;
//
// }
//
// public int getPlayerId() {
// return playerId;
// }
//
// public int getLives() {
// return lives;
// }
//
// public void setLives(int lives) {
// this.lives = lives;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// //implement parcelable
//
// public int describeContents() {
// return 0;
// }
//
// public int getColor() {
// float hue = playerId * 36;
// return Color.HSVToColor(new float[]{hue, 1, 1});
// }
//
//
// protected Player(Parcel in) {
// ClassLoader classLoader = getClass().getClassLoader();
// playerId = in.readInt();
// level = in.readInt();
// score = in.readInt();
// bar = in.readParcelable(classLoader);
// lives = in.readInt();
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(playerId);
// dest.writeInt(level);
// dest.writeInt(score);
// dest.writeParcelable(bar, flags);
// dest.writeInt(lives);
// }
//
//
// public static final Parcelable.Creator<Player> CREATOR
// = new Parcelable.Creator<Player>() {
// public Player createFromParcel(Parcel in) {
// return new Player(in);
// }
//
// public Player[] newArray(int size) {
// return new Player[size];
// }
//
// };
//
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/GameEventNewGame.java
import android.os.Parcel;
import org.bobstuff.bobball.Player;
import java.util.List;
import java.util.Random;
private int cols;
private float ballspeed;
private float barspeed;
private int seed;
public GameEventNewGame(int time, int level, int seed, int rows, int cols, float ballspeed, float barspeed) {
super(time);
this.level = level;
this.rows = rows;
this.cols = cols;
this.ballspeed = ballspeed;
this.barspeed = barspeed;
this.seed = seed;
}
//implement parcelable
protected GameEventNewGame(Parcel in) {
super(in);
level = in.readInt();
rows = in.readInt();
cols = in.readInt();
ballspeed = in.readFloat();
barspeed = in.readFloat();
seed = in.readInt();
}
@Override
public void apply(GameState gs) { | List<Player> players = gs.getPlayers(); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/Menus/menuOptions.java | // Path: app/src/main/java/org/bobstuff/bobball/Settings.java
// public class Settings {
//
// public static void setDefaultName (String defaultName){
// Preferences.saveValue("defaultName",defaultName);
// }
//
// public static String getDefaultName (){
// Context context = Preferences.getContext();
// return Preferences.loadValue("defaultName",context.getString(R.string.defaultName));
// }
//
// public static void setNumPlayers (int numPlayers) {
// Preferences.saveValue("numPlayers", "" + numPlayers);
// }
//
// public static int getNumPlayers (){
// return Integer.parseInt(Preferences.loadValue("numPlayers","1"));
// }
//
//
// public static void setLevelSelectionType (int type) {
// Preferences.saveValue("levelSelectionType", "" + type);
// }
//
// public static int getLevelSelectionType (){
// return Integer.parseInt(Preferences.loadValue("levelSelectionType", "0"));
// }
//
//
// public static void setSelectedLevel (int level) {
// Preferences.saveValue("selectedLevel","" + level);
// }
//
// public static int getSelectLevel (){
// return Integer.parseInt(Preferences.loadValue("selectedLevel", "1"));
// }
//
//
// public static void setLastLevelFailed (int lastLevel){
// Preferences.saveValue("lastLevelFailed","" + lastLevel);
// }
//
// public static int getLastLevelFailed (){
// return Integer.parseInt(Preferences.loadValue("lastLevelFailed","0"));
// }
//
//
// public static void setRetryAction (int retryAction){
// Preferences.saveValue("retryAction","" + retryAction);
// }
//
// public static int getRetryAction (){
// return Integer.parseInt(Preferences.loadValue("retryAction","0"));
// }
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
| import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Settings;
import org.bobstuff.bobball.Utilities; | package org.bobstuff.bobball.Menus;
public class menuOptions extends Activity {
private EditText defaultNameInput;
private Spinner levelSelectSettings;
private Spinner retryActionSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setContentView(R.layout.menu_options);
defaultNameInput = (EditText) findViewById(R.id.defaultName); | // Path: app/src/main/java/org/bobstuff/bobball/Settings.java
// public class Settings {
//
// public static void setDefaultName (String defaultName){
// Preferences.saveValue("defaultName",defaultName);
// }
//
// public static String getDefaultName (){
// Context context = Preferences.getContext();
// return Preferences.loadValue("defaultName",context.getString(R.string.defaultName));
// }
//
// public static void setNumPlayers (int numPlayers) {
// Preferences.saveValue("numPlayers", "" + numPlayers);
// }
//
// public static int getNumPlayers (){
// return Integer.parseInt(Preferences.loadValue("numPlayers","1"));
// }
//
//
// public static void setLevelSelectionType (int type) {
// Preferences.saveValue("levelSelectionType", "" + type);
// }
//
// public static int getLevelSelectionType (){
// return Integer.parseInt(Preferences.loadValue("levelSelectionType", "0"));
// }
//
//
// public static void setSelectedLevel (int level) {
// Preferences.saveValue("selectedLevel","" + level);
// }
//
// public static int getSelectLevel (){
// return Integer.parseInt(Preferences.loadValue("selectedLevel", "1"));
// }
//
//
// public static void setLastLevelFailed (int lastLevel){
// Preferences.saveValue("lastLevelFailed","" + lastLevel);
// }
//
// public static int getLastLevelFailed (){
// return Integer.parseInt(Preferences.loadValue("lastLevelFailed","0"));
// }
//
//
// public static void setRetryAction (int retryAction){
// Preferences.saveValue("retryAction","" + retryAction);
// }
//
// public static int getRetryAction (){
// return Integer.parseInt(Preferences.loadValue("retryAction","0"));
// }
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
// Path: app/src/main/java/org/bobstuff/bobball/Menus/menuOptions.java
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Settings;
import org.bobstuff.bobball.Utilities;
package org.bobstuff.bobball.Menus;
public class menuOptions extends Activity {
private EditText defaultNameInput;
private Spinner levelSelectSettings;
private Spinner retryActionSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setContentView(R.layout.menu_options);
defaultNameInput = (EditText) findViewById(R.id.defaultName); | defaultNameInput.setHint(Settings.getDefaultName()); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/Menus/menuOptions.java | // Path: app/src/main/java/org/bobstuff/bobball/Settings.java
// public class Settings {
//
// public static void setDefaultName (String defaultName){
// Preferences.saveValue("defaultName",defaultName);
// }
//
// public static String getDefaultName (){
// Context context = Preferences.getContext();
// return Preferences.loadValue("defaultName",context.getString(R.string.defaultName));
// }
//
// public static void setNumPlayers (int numPlayers) {
// Preferences.saveValue("numPlayers", "" + numPlayers);
// }
//
// public static int getNumPlayers (){
// return Integer.parseInt(Preferences.loadValue("numPlayers","1"));
// }
//
//
// public static void setLevelSelectionType (int type) {
// Preferences.saveValue("levelSelectionType", "" + type);
// }
//
// public static int getLevelSelectionType (){
// return Integer.parseInt(Preferences.loadValue("levelSelectionType", "0"));
// }
//
//
// public static void setSelectedLevel (int level) {
// Preferences.saveValue("selectedLevel","" + level);
// }
//
// public static int getSelectLevel (){
// return Integer.parseInt(Preferences.loadValue("selectedLevel", "1"));
// }
//
//
// public static void setLastLevelFailed (int lastLevel){
// Preferences.saveValue("lastLevelFailed","" + lastLevel);
// }
//
// public static int getLastLevelFailed (){
// return Integer.parseInt(Preferences.loadValue("lastLevelFailed","0"));
// }
//
//
// public static void setRetryAction (int retryAction){
// Preferences.saveValue("retryAction","" + retryAction);
// }
//
// public static int getRetryAction (){
// return Integer.parseInt(Preferences.loadValue("retryAction","0"));
// }
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
| import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Settings;
import org.bobstuff.bobball.Utilities; | package org.bobstuff.bobball.Menus;
public class menuOptions extends Activity {
private EditText defaultNameInput;
private Spinner levelSelectSettings;
private Spinner retryActionSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setContentView(R.layout.menu_options);
defaultNameInput = (EditText) findViewById(R.id.defaultName);
defaultNameInput.setHint(Settings.getDefaultName());
levelSelectSettings = (Spinner) findViewById(R.id.spinnerLevelSelect);
retryActionSettings = (Spinner) findViewById(R.id.spinnerRetryAction);
| // Path: app/src/main/java/org/bobstuff/bobball/Settings.java
// public class Settings {
//
// public static void setDefaultName (String defaultName){
// Preferences.saveValue("defaultName",defaultName);
// }
//
// public static String getDefaultName (){
// Context context = Preferences.getContext();
// return Preferences.loadValue("defaultName",context.getString(R.string.defaultName));
// }
//
// public static void setNumPlayers (int numPlayers) {
// Preferences.saveValue("numPlayers", "" + numPlayers);
// }
//
// public static int getNumPlayers (){
// return Integer.parseInt(Preferences.loadValue("numPlayers","1"));
// }
//
//
// public static void setLevelSelectionType (int type) {
// Preferences.saveValue("levelSelectionType", "" + type);
// }
//
// public static int getLevelSelectionType (){
// return Integer.parseInt(Preferences.loadValue("levelSelectionType", "0"));
// }
//
//
// public static void setSelectedLevel (int level) {
// Preferences.saveValue("selectedLevel","" + level);
// }
//
// public static int getSelectLevel (){
// return Integer.parseInt(Preferences.loadValue("selectedLevel", "1"));
// }
//
//
// public static void setLastLevelFailed (int lastLevel){
// Preferences.saveValue("lastLevelFailed","" + lastLevel);
// }
//
// public static int getLastLevelFailed (){
// return Integer.parseInt(Preferences.loadValue("lastLevelFailed","0"));
// }
//
//
// public static void setRetryAction (int retryAction){
// Preferences.saveValue("retryAction","" + retryAction);
// }
//
// public static int getRetryAction (){
// return Integer.parseInt(Preferences.loadValue("retryAction","0"));
// }
// }
//
// Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
// Path: app/src/main/java/org/bobstuff/bobball/Menus/menuOptions.java
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
import org.bobstuff.bobball.R;
import org.bobstuff.bobball.Settings;
import org.bobstuff.bobball.Utilities;
package org.bobstuff.bobball.Menus;
public class menuOptions extends Activity {
private EditText defaultNameInput;
private Spinner levelSelectSettings;
private Spinner retryActionSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setContentView(R.layout.menu_options);
defaultNameInput = (EditText) findViewById(R.id.defaultName);
defaultNameInput.setHint(Settings.getDefaultName());
levelSelectSettings = (Spinner) findViewById(R.id.spinnerLevelSelect);
retryActionSettings = (Spinner) findViewById(R.id.spinnerRetryAction);
| levelSelectSettings.setAdapter(Utilities.createDropdownFromStrings(this,R.array.levelSelectSettings)); |
bobthekingofegypt/BobBall | app/src/main/java/org/bobstuff/bobball/GameLogic/Grid.java | // Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
| import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Utilities; | public void addBox(RectF rect, int playerId) {
int x1 = getGridX(rect.left);
int y1 = getGridY(rect.top);
int x2 = getGridX(rect.right);
int y2 = getGridY(rect.bottom);
for (int x = x1; x < x2; ++x) {
for (int y = y1; y < y2; ++y) {
if (x >= 0 && x < maxX && y >= 0 && y < maxY && gridSquares[x][y] == GRID_SQUARE_CLEAR) {
gridSquares[x][y] = GRID_SQUARE_FILLED + playerId;
}
}
}
perPlayer.get(playerId).collisionRects.add(rect);
}
public RectF collide(RectF rect) {
for (GridPerPlayer gp : perPlayer) {
for (RectF collisionRect : gp.collisionRects) {
if (RectF.intersects(rect, collisionRect)) {
return collisionRect;
}
}
}
return null;
}
// collapse clear areas if they do not contain a ball
// the newly filled squares are accounted to player playerid
public void checkEmptyAreas(List<Ball> balls, int playerid) {
| // Path: app/src/main/java/org/bobstuff/bobball/Utilities.java
// public class Utilities extends Activity {
//
// public static void arrayCopy(int[][] source,int[][] destination) {
// for (int a=0; a < source.length; ++a) {
// System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
// }
// }
//
// public static ArrayAdapter createDropdown (Context context, int count) {
// List<String> dropdownItems = new ArrayList<>();
//
// for (int i = 1; i <= count; i++) { dropdownItems.add("" + i); }
//
// ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, dropdownItems);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//
// return adapter;
// }
//
// public static ArrayAdapter createDropdownFromStrings (Context context, int stringsId){
// ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, stringsId, android.R.layout.simple_spinner_item);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// return adapter;
// }
// }
// Path: app/src/main/java/org/bobstuff/bobball/GameLogic/Grid.java
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import org.bobstuff.bobball.Utilities;
public void addBox(RectF rect, int playerId) {
int x1 = getGridX(rect.left);
int y1 = getGridY(rect.top);
int x2 = getGridX(rect.right);
int y2 = getGridY(rect.bottom);
for (int x = x1; x < x2; ++x) {
for (int y = y1; y < y2; ++y) {
if (x >= 0 && x < maxX && y >= 0 && y < maxY && gridSquares[x][y] == GRID_SQUARE_CLEAR) {
gridSquares[x][y] = GRID_SQUARE_FILLED + playerId;
}
}
}
perPlayer.get(playerId).collisionRects.add(rect);
}
public RectF collide(RectF rect) {
for (GridPerPlayer gp : perPlayer) {
for (RectF collisionRect : gp.collisionRects) {
if (RectF.intersects(rect, collisionRect)) {
return collisionRect;
}
}
}
return null;
}
// collapse clear areas if they do not contain a ball
// the newly filled squares are accounted to player playerid
public void checkEmptyAreas(List<Ball> balls, int playerid) {
| Utilities.arrayCopy(gridSquares, tempGridSquares); |
ds84182/OpenGX | src/main/java/ds/mods/opengx/util/MonitorDiscovery.java | // Path: src/main/java/ds/mods/opengx/component/ComponentMonitor.java
// public class ComponentMonitor extends Component implements ManagedEnvironment {
//
// public static final WeakHashMap<World,HashMap<UUID,ComponentMonitor>> serverCGX = new WeakHashMap<World,HashMap<UUID,ComponentMonitor>>();
// public static final WeakHashMap<World,HashMap<UUID,ComponentMonitor>> clientCGX = new WeakHashMap<World,HashMap<UUID,ComponentMonitor>>();
//
// public static ComponentMonitor get(UUID uuid, World w, int tier)
// {
// WeakHashMap<World,HashMap<UUID,ComponentMonitor>> cgxm = w.isRemote ? clientCGX : serverCGX;
// if (!cgxm.containsKey(w))
// {
// cgxm.put(w, new HashMap<UUID,ComponentMonitor>());
// }
// HashMap<UUID,ComponentMonitor> m = cgxm.get(w);
// if (!m.containsKey(uuid))
// {
// m.put(uuid, new ComponentMonitor(uuid, w, tier));
// }
// return m.get(uuid);
// }
//
// Node node = Network.newNode(this, Visibility.Network).withComponent("gxmonitor").create();
//
// @SideOnly(Side.CLIENT)
// public GXFramebuffer fb;
// public boolean isInRenderList = false;
//
// public ComponentGX owner;
// public int width = 128;
// public int height = 96;
//
// public int countdown = 100;
//
// public Runnable changed;
//
// public ComponentMonitor(UUID uui, World world, int t) {
// super(uui, world, t);
// }
//
// @Override
// public Node node() {
// return node;
// }
//
// @Override
// public void onConnect(Node node) {
//
// }
//
// @Override
// public void onDisconnect(Node node) {
// System.out.println("Dis");
// if (owner != null && owner.node() == node)
// {
// setOwner(null);
// }
// }
//
// @Override
// public void onMessage(Message message) {
// if (message.name().equals("monitor_discovery") && owner == null)
// {
// ((MonitorDiscovery)message.data()[0]).foundMonitors.add(this);
// }
// }
//
// @Override
// public void load(NBTTagCompound nbt) {
// if (node != null)
// node.load(nbt);
// width = nbt.getInteger("width");
// height = nbt.getInteger("height");
// onChanged();
// }
//
// @Override
// public void save(NBTTagCompound nbt) {
// node.save(nbt);
// nbt.setInteger("width", width);
// nbt.setInteger("height", height);
// }
//
// public void setOwner(ComponentGX gx)
// {
// if (owner != null)
// owner.monitor = null;
// owner = gx;
// MonitorOwnMessage m = new MonitorOwnMessage();
// m.muuid = uuid;
//
// if (gx != null)
// {
// m.hasOwner = true;
// m.uuid = gx.uuid;
// m.tier = gx.tier;
// gx.monitor = this;
//
// if (gx.gx != null)
// gx.gx.requestRerender();
// }
//
// System.out.println("set owner of "+uuid);
// OpenGX.network.sendToAllAround(m, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
// }
//
// @Override
// public boolean canUpdate() {
// return true;
// }
//
// @Override
// public void update() {
// if (width<=0) width=128;
// if (height<=0) height=96;
// if (countdown-- == 0)
// {
// countdown = 100;
// MonitorSizeMessage msm = new MonitorSizeMessage();
// msm.uuid = uuid;
// msm.w = width;
// msm.h = height;
// OpenGX.network.sendToAllAround(msm, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
// }
// }
//
// public void onChanged()
// {
// countdown = 0;
// if (changed != null)
// changed.run();
// }
//
// @Callback(direct=true)
// public Object[] getSize(Context context, Arguments arguments)
// {
// return new Object[]{width, height};
// }
//
// @Callback(limit=1)
// public Object[] setSize(Context context, Arguments arguments)
// {
// int w = arguments.checkInteger(0), h = arguments.checkInteger(1);
// if (w<1 || h<1 || w>512 || h>512)
// return new Object[]{false, "Size out of bounds (<0 or >512)"};
// width = w;
// height = h;
// onChanged();
// return new Object[]{true};
// }
// }
| import java.util.ArrayList;
import java.util.Random;
import li.cil.oc.api.network.ManagedEnvironment;
import ds.mods.opengx.component.ComponentMonitor; | package ds.mods.opengx.util;
public class MonitorDiscovery {
public ManagedEnvironment gx;
public long id; | // Path: src/main/java/ds/mods/opengx/component/ComponentMonitor.java
// public class ComponentMonitor extends Component implements ManagedEnvironment {
//
// public static final WeakHashMap<World,HashMap<UUID,ComponentMonitor>> serverCGX = new WeakHashMap<World,HashMap<UUID,ComponentMonitor>>();
// public static final WeakHashMap<World,HashMap<UUID,ComponentMonitor>> clientCGX = new WeakHashMap<World,HashMap<UUID,ComponentMonitor>>();
//
// public static ComponentMonitor get(UUID uuid, World w, int tier)
// {
// WeakHashMap<World,HashMap<UUID,ComponentMonitor>> cgxm = w.isRemote ? clientCGX : serverCGX;
// if (!cgxm.containsKey(w))
// {
// cgxm.put(w, new HashMap<UUID,ComponentMonitor>());
// }
// HashMap<UUID,ComponentMonitor> m = cgxm.get(w);
// if (!m.containsKey(uuid))
// {
// m.put(uuid, new ComponentMonitor(uuid, w, tier));
// }
// return m.get(uuid);
// }
//
// Node node = Network.newNode(this, Visibility.Network).withComponent("gxmonitor").create();
//
// @SideOnly(Side.CLIENT)
// public GXFramebuffer fb;
// public boolean isInRenderList = false;
//
// public ComponentGX owner;
// public int width = 128;
// public int height = 96;
//
// public int countdown = 100;
//
// public Runnable changed;
//
// public ComponentMonitor(UUID uui, World world, int t) {
// super(uui, world, t);
// }
//
// @Override
// public Node node() {
// return node;
// }
//
// @Override
// public void onConnect(Node node) {
//
// }
//
// @Override
// public void onDisconnect(Node node) {
// System.out.println("Dis");
// if (owner != null && owner.node() == node)
// {
// setOwner(null);
// }
// }
//
// @Override
// public void onMessage(Message message) {
// if (message.name().equals("monitor_discovery") && owner == null)
// {
// ((MonitorDiscovery)message.data()[0]).foundMonitors.add(this);
// }
// }
//
// @Override
// public void load(NBTTagCompound nbt) {
// if (node != null)
// node.load(nbt);
// width = nbt.getInteger("width");
// height = nbt.getInteger("height");
// onChanged();
// }
//
// @Override
// public void save(NBTTagCompound nbt) {
// node.save(nbt);
// nbt.setInteger("width", width);
// nbt.setInteger("height", height);
// }
//
// public void setOwner(ComponentGX gx)
// {
// if (owner != null)
// owner.monitor = null;
// owner = gx;
// MonitorOwnMessage m = new MonitorOwnMessage();
// m.muuid = uuid;
//
// if (gx != null)
// {
// m.hasOwner = true;
// m.uuid = gx.uuid;
// m.tier = gx.tier;
// gx.monitor = this;
//
// if (gx.gx != null)
// gx.gx.requestRerender();
// }
//
// System.out.println("set owner of "+uuid);
// OpenGX.network.sendToAllAround(m, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
// }
//
// @Override
// public boolean canUpdate() {
// return true;
// }
//
// @Override
// public void update() {
// if (width<=0) width=128;
// if (height<=0) height=96;
// if (countdown-- == 0)
// {
// countdown = 100;
// MonitorSizeMessage msm = new MonitorSizeMessage();
// msm.uuid = uuid;
// msm.w = width;
// msm.h = height;
// OpenGX.network.sendToAllAround(msm, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
// }
// }
//
// public void onChanged()
// {
// countdown = 0;
// if (changed != null)
// changed.run();
// }
//
// @Callback(direct=true)
// public Object[] getSize(Context context, Arguments arguments)
// {
// return new Object[]{width, height};
// }
//
// @Callback(limit=1)
// public Object[] setSize(Context context, Arguments arguments)
// {
// int w = arguments.checkInteger(0), h = arguments.checkInteger(1);
// if (w<1 || h<1 || w>512 || h>512)
// return new Object[]{false, "Size out of bounds (<0 or >512)"};
// width = w;
// height = h;
// onChanged();
// return new Object[]{true};
// }
// }
// Path: src/main/java/ds/mods/opengx/util/MonitorDiscovery.java
import java.util.ArrayList;
import java.util.Random;
import li.cil.oc.api.network.ManagedEnvironment;
import ds.mods.opengx.component.ComponentMonitor;
package ds.mods.opengx.util;
public class MonitorDiscovery {
public ManagedEnvironment gx;
public long id; | public ArrayList<ComponentMonitor> foundMonitors = new ArrayList<ComponentMonitor>(); |
ds84182/OpenGX | src/main/java/ds/mods/opengx/component/ComponentButton.java | // Path: src/main/java/ds/mods/opengx/network/GlassesButtonEventMessage.java
// public static enum Button {
// ONOFF,
// SCREENPOWER,
// ACTION1,
// ACTION2,
// ACTIONM
// }
| import java.util.EnumSet;
import java.util.HashMap;
import java.util.UUID;
import java.util.WeakHashMap;
import li.cil.oc.api.Network;
import li.cil.oc.api.network.Arguments;
import li.cil.oc.api.network.Callback;
import li.cil.oc.api.network.Context;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.Visibility;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import ds.mods.opengx.network.GlassesButtonEventMessage.Button; | package ds.mods.opengx.component;
public class ComponentButton extends Component implements ManagedEnvironment {
public static final WeakHashMap<World,HashMap<UUID,ComponentButton>> serverCGX = new WeakHashMap<World,HashMap<UUID,ComponentButton>>();
public static final WeakHashMap<World,HashMap<UUID,ComponentButton>> clientCGX = new WeakHashMap<World,HashMap<UUID,ComponentButton>>();
public static ComponentButton get(UUID uuid, World w, int tier)
{
WeakHashMap<World,HashMap<UUID,ComponentButton>> cgxm = w.isRemote ? clientCGX : serverCGX;
if (!cgxm.containsKey(w))
{
cgxm.put(w, new HashMap<UUID,ComponentButton>());
}
HashMap<UUID,ComponentButton> m = cgxm.get(w);
if (!m.containsKey(uuid))
{
m.put(uuid, new ComponentButton(uuid, w, tier));
}
return m.get(uuid);
}
Node node = Network.newNode(this, Visibility.Neighbors).withComponent("buttons").create(); | // Path: src/main/java/ds/mods/opengx/network/GlassesButtonEventMessage.java
// public static enum Button {
// ONOFF,
// SCREENPOWER,
// ACTION1,
// ACTION2,
// ACTIONM
// }
// Path: src/main/java/ds/mods/opengx/component/ComponentButton.java
import java.util.EnumSet;
import java.util.HashMap;
import java.util.UUID;
import java.util.WeakHashMap;
import li.cil.oc.api.Network;
import li.cil.oc.api.network.Arguments;
import li.cil.oc.api.network.Callback;
import li.cil.oc.api.network.Context;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.Visibility;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import ds.mods.opengx.network.GlassesButtonEventMessage.Button;
package ds.mods.opengx.component;
public class ComponentButton extends Component implements ManagedEnvironment {
public static final WeakHashMap<World,HashMap<UUID,ComponentButton>> serverCGX = new WeakHashMap<World,HashMap<UUID,ComponentButton>>();
public static final WeakHashMap<World,HashMap<UUID,ComponentButton>> clientCGX = new WeakHashMap<World,HashMap<UUID,ComponentButton>>();
public static ComponentButton get(UUID uuid, World w, int tier)
{
WeakHashMap<World,HashMap<UUID,ComponentButton>> cgxm = w.isRemote ? clientCGX : serverCGX;
if (!cgxm.containsKey(w))
{
cgxm.put(w, new HashMap<UUID,ComponentButton>());
}
HashMap<UUID,ComponentButton> m = cgxm.get(w);
if (!m.containsKey(uuid))
{
m.put(uuid, new ComponentButton(uuid, w, tier));
}
return m.get(uuid);
}
Node node = Network.newNode(this, Visibility.Neighbors).withComponent("buttons").create(); | public EnumSet<Button> downButtons = EnumSet.noneOf(Button.class); |
ds84182/OpenGX | src/main/java/ds/mods/opengx/Events.java | // Path: src/main/java/ds/mods/opengx/tileentity/TileEntityGX.java
// public class TileEntityGX extends TileEntityEnvironment {
// public boolean initd = false;
//
// public int tier;
// public int metadataUpdateCountdown = 0;
// public ComponentGX component;
// public UUID uuid = UUID.randomUUID();
//
// public void init()
// {
// System.out.println("INIT "+tier);
// initd = true;
// component = null;
// //tier = worldObj.getBlockMetadata(xCoord, yCoord, zCoord)+1;
// }
//
// private double distance(TileEntity te)
// {
// double dx = xCoord+te.xCoord;
// double dy = yCoord+te.yCoord;
// double dz = zCoord+te.zCoord;
//
// return Math.sqrt(dx*dx + dy*dy + dz*dz);
// }
//
// @Override
// public void updateEntity()
// {
// if (!initd)
// init();
// if (component == null)
// {
// component = ComponentGX.get(uuid, worldObj, tier);
// node = component.node();
// component.own = new Owner()
// {
//
// @Override
// public Node node() {
// return component.node();
// }
//
// @Override
// public boolean canInteract(String player) {
// return true;
// }
//
// @Override
// public boolean isRunning() {
// return false;
// }
//
// @Override
// public boolean isPaused() {
// return false;
// }
//
// @Override
// public boolean start() {
// return false;
// }
//
// @Override
// public boolean pause(double seconds) {
// return false;
// }
//
// @Override
// public boolean stop() {
// return false;
// }
//
// @Override
// public boolean signal(String name, Object... args) {
// return false;
// }
//
// @Override
// public int x() {
// return xCoord;
// }
//
// @Override
// public int y() {
// return yCoord;
// }
//
// @Override
// public int z() {
// return zCoord;
// }
//
// @Override
// public World world() {
// return worldObj;
// }
//
// @Override
// public int installedMemory() {
// return 0;
// }
//
// @Override
// public int maxComponents() {
// return 0;
// }
//
// @Override
// public void markAsChanged() {
//
// }
//
// @Override
// public void onMachineConnect(Node node) {
//
// }
//
// @Override
// public void onMachineDisconnect(Node node) {
//
// }
//
// };
// }
// super.updateEntity();
// component.update();
// if (metadataUpdateCountdown-- == 0)
// {
// metadataUpdateCountdown = 100;
// tier = this.getBlockMetadata()+1;
// component.tier = tier;
// }
// }
//
// @Override
// public void readFromNBT(NBTTagCompound nbt) {
// super.readFromNBT(nbt);
// uuid = new UUID(nbt.getLong("msb"),nbt.getLong("lsb"));
// init();
// }
//
// @Override
// public void writeToNBT(NBTTagCompound nbt) {
// super.writeToNBT(nbt);
// if (!initd)
// init();
// nbt.setLong("lsb", uuid.getLeastSignificantBits());
// nbt.setLong("msb", uuid.getMostSignificantBits());
// }
//
// public Packet getDescriptionPacket()
// {
// NBTTagCompound nbttagcompound = new NBTTagCompound();
// this.writeToNBT(nbttagcompound);
// return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 3, nbttagcompound);
// }
//
// @Override
// public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
// if (worldObj.isRemote)
// readFromNBT(pkt.func_148857_g());
// }
// }
| import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.world.ChunkWatchEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ds.mods.opengx.tileentity.TileEntityGX; | package ds.mods.opengx;
public class Events {
@SubscribeEvent
public void onChunkWatchedByPlayer(ChunkWatchEvent event)
{
if (!event.player.worldObj.isRemote)
{
//get all the TileEntities in the chunk
Chunk c = event.player.worldObj.getChunkFromChunkCoords(event.chunk.chunkXPos, event.chunk.chunkZPos);
int nt = 0;
for (Object t : c.chunkTileEntityMap.values())
{ | // Path: src/main/java/ds/mods/opengx/tileentity/TileEntityGX.java
// public class TileEntityGX extends TileEntityEnvironment {
// public boolean initd = false;
//
// public int tier;
// public int metadataUpdateCountdown = 0;
// public ComponentGX component;
// public UUID uuid = UUID.randomUUID();
//
// public void init()
// {
// System.out.println("INIT "+tier);
// initd = true;
// component = null;
// //tier = worldObj.getBlockMetadata(xCoord, yCoord, zCoord)+1;
// }
//
// private double distance(TileEntity te)
// {
// double dx = xCoord+te.xCoord;
// double dy = yCoord+te.yCoord;
// double dz = zCoord+te.zCoord;
//
// return Math.sqrt(dx*dx + dy*dy + dz*dz);
// }
//
// @Override
// public void updateEntity()
// {
// if (!initd)
// init();
// if (component == null)
// {
// component = ComponentGX.get(uuid, worldObj, tier);
// node = component.node();
// component.own = new Owner()
// {
//
// @Override
// public Node node() {
// return component.node();
// }
//
// @Override
// public boolean canInteract(String player) {
// return true;
// }
//
// @Override
// public boolean isRunning() {
// return false;
// }
//
// @Override
// public boolean isPaused() {
// return false;
// }
//
// @Override
// public boolean start() {
// return false;
// }
//
// @Override
// public boolean pause(double seconds) {
// return false;
// }
//
// @Override
// public boolean stop() {
// return false;
// }
//
// @Override
// public boolean signal(String name, Object... args) {
// return false;
// }
//
// @Override
// public int x() {
// return xCoord;
// }
//
// @Override
// public int y() {
// return yCoord;
// }
//
// @Override
// public int z() {
// return zCoord;
// }
//
// @Override
// public World world() {
// return worldObj;
// }
//
// @Override
// public int installedMemory() {
// return 0;
// }
//
// @Override
// public int maxComponents() {
// return 0;
// }
//
// @Override
// public void markAsChanged() {
//
// }
//
// @Override
// public void onMachineConnect(Node node) {
//
// }
//
// @Override
// public void onMachineDisconnect(Node node) {
//
// }
//
// };
// }
// super.updateEntity();
// component.update();
// if (metadataUpdateCountdown-- == 0)
// {
// metadataUpdateCountdown = 100;
// tier = this.getBlockMetadata()+1;
// component.tier = tier;
// }
// }
//
// @Override
// public void readFromNBT(NBTTagCompound nbt) {
// super.readFromNBT(nbt);
// uuid = new UUID(nbt.getLong("msb"),nbt.getLong("lsb"));
// init();
// }
//
// @Override
// public void writeToNBT(NBTTagCompound nbt) {
// super.writeToNBT(nbt);
// if (!initd)
// init();
// nbt.setLong("lsb", uuid.getLeastSignificantBits());
// nbt.setLong("msb", uuid.getMostSignificantBits());
// }
//
// public Packet getDescriptionPacket()
// {
// NBTTagCompound nbttagcompound = new NBTTagCompound();
// this.writeToNBT(nbttagcompound);
// return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 3, nbttagcompound);
// }
//
// @Override
// public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
// if (worldObj.isRemote)
// readFromNBT(pkt.func_148857_g());
// }
// }
// Path: src/main/java/ds/mods/opengx/Events.java
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.world.ChunkWatchEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ds.mods.opengx.tileentity.TileEntityGX;
package ds.mods.opengx;
public class Events {
@SubscribeEvent
public void onChunkWatchedByPlayer(ChunkWatchEvent event)
{
if (!event.player.worldObj.isRemote)
{
//get all the TileEntities in the chunk
Chunk c = event.player.worldObj.getChunkFromChunkCoords(event.chunk.chunkXPos, event.chunk.chunkZPos);
int nt = 0;
for (Object t : c.chunkTileEntityMap.values())
{ | if (t instanceof TileEntityGX) |
anyremote/anyremote-android-client | java/anyremote/client/android/anyRemote.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.TreeMap;
import java.util.Vector;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R; | }
if (finishFlag) {
return; // on destroy
}
if (currForm == which) {
_log("setCurrentView TRY TO SWITCH TO THE SAME FORM ???");
//if (currForm != SEARCH_FORM) {
_log("setCurrentView SKIP SWITCH TO THE SAME FORM ???");
return;
//}
}
prevForm = currForm;
currForm = which;
if (currForm != prevForm) {
// finish current form
switch (prevForm) {
case SEARCH_FORM:
_log("[AR] setCurrentView mess SEARCH_FORM with some other");
break;
case CONTROL_FORM:
case LIST_FORM:
case TEXT_FORM:
case WMAN_FORM:
_log("setCurrentView stop "+prevForm); | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/anyRemote.java
import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.TreeMap;
import java.util.Vector;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
}
if (finishFlag) {
return; // on destroy
}
if (currForm == which) {
_log("setCurrentView TRY TO SWITCH TO THE SAME FORM ???");
//if (currForm != SEARCH_FORM) {
_log("setCurrentView SKIP SWITCH TO THE SAME FORM ???");
return;
//}
}
prevForm = currForm;
currForm = which;
if (currForm != prevForm) {
// finish current form
switch (prevForm) {
case SEARCH_FORM:
_log("[AR] setCurrentView mess SEARCH_FORM with some other");
break;
case CONTROL_FORM:
case LIST_FORM:
case TEXT_FORM:
case WMAN_FORM:
_log("setCurrentView stop "+prevForm); | protocol.sendToActivity(prevForm, Dispatcher.CMD_CLOSE,ProtocolMessage.FULL); |
anyremote/anyremote-android-client | java/anyremote/client/android/anyRemote.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.TreeMap;
import java.util.Vector;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R; |
String alert = res.getString(R.string.connection_failed);
if (((String) msg.obj).length() > 0) {
alert += "\n"+(String) msg.obj;
}
Toast.makeText(this, alert, Toast.LENGTH_LONG).show();
}
protocol.disconnected(true);
handleEvent(DISCONNECTED);
break;
case LOSTFOCUS:
anyRemote._log("handleMessage: LOST FOCUS");
protocol.disconnected(false);
handleEvent(LOSTFOCUS);
break;
case anyRemote.COMMAND:
anyRemote._log("handleMessage: COMMAND");
protocol.handleCommand((ProtocolMessage) msg.obj);
break;
case anyRemote.DO_CONNECT:
anyRemote._log("handleMessage: DO_CONNECT");
if (msg.obj != null ) { | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/anyRemote.java
import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.TreeMap;
import java.util.Vector;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
String alert = res.getString(R.string.connection_failed);
if (((String) msg.obj).length() > 0) {
alert += "\n"+(String) msg.obj;
}
Toast.makeText(this, alert, Toast.LENGTH_LONG).show();
}
protocol.disconnected(true);
handleEvent(DISCONNECTED);
break;
case LOSTFOCUS:
anyRemote._log("handleMessage: LOST FOCUS");
protocol.disconnected(false);
handleEvent(LOSTFOCUS);
break;
case anyRemote.COMMAND:
anyRemote._log("handleMessage: COMMAND");
protocol.handleCommand((ProtocolMessage) msg.obj);
break;
case anyRemote.DO_CONNECT:
anyRemote._log("handleMessage: DO_CONNECT");
if (msg.obj != null ) { | Address conn = (Address) msg.obj; |
anyremote/anyremote-android-client | java/anyremote/client/android/Connection.java | // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
| import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException; | //
// anyRemote android client
// a bluetooth/wi-fi remote control for Linux.
//
// Copyright (C) 2011-2018 Mikhail Fedotov <anyremote@mail.ru>
//
// This program 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
package anyremote.client.android;
/**
* A connection sets up a connection to the server and handles receiving and
* sending of messages from/to the server.
*/
public final class Connection implements Runnable {
static final int BUFFER_SIZE = 4096;
static final int ENDS_AT_CEND = 1;
static final int ENDS_AT_COMMA = 3;
static final int ENDS_AT_NOMORE = 5;
static final int READ_NO = 0;
static final int READ_CMDID = 1;
static final int READ_PART = 3;
static final int QUEUE_CAPACITY = 2048;
boolean charMode;
byte[] bArray;
int curCmdId;
int readingEndsAt;
int readStage;
int wasRead;
int btoRead;
Vector cmdTokens;
Integer runSignal;
Vector cmdQueue;
StringBuilder dataQueue;
private boolean closed = false;
private final Dispatcher connectionListener;
private boolean connectionListenerNotifiedAboutError = false;
private final DataInputStream dis;
private final DataOutputStream dos;
| // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
// Path: java/anyremote/client/android/Connection.java
import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
//
// anyRemote android client
// a bluetooth/wi-fi remote control for Linux.
//
// Copyright (C) 2011-2018 Mikhail Fedotov <anyremote@mail.ru>
//
// This program 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
package anyremote.client.android;
/**
* A connection sets up a connection to the server and handles receiving and
* sending of messages from/to the server.
*/
public final class Connection implements Runnable {
static final int BUFFER_SIZE = 4096;
static final int ENDS_AT_CEND = 1;
static final int ENDS_AT_COMMA = 3;
static final int ENDS_AT_NOMORE = 5;
static final int READ_NO = 0;
static final int READ_CMDID = 1;
static final int READ_PART = 3;
static final int QUEUE_CAPACITY = 2048;
boolean charMode;
byte[] bArray;
int curCmdId;
int readingEndsAt;
int readStage;
int wasRead;
int btoRead;
Vector cmdTokens;
Integer runSignal;
Vector cmdQueue;
StringBuilder dataQueue;
private boolean closed = false;
private final Dispatcher connectionListener;
private boolean connectionListenerNotifiedAboutError = false;
private final DataInputStream dis;
private final DataOutputStream dos;
| private final ISocket sock; |
anyremote/anyremote-android-client | java/anyremote/client/android/Connection.java | // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
| import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException; | *
* @param m
* The message to send. Content does not get changed.
*/
public void send(String m) {
synchronized (dos) {
if (closed)
return;
try {
sendPrivate(m);
} catch (IOException e) {
downPrivate();
notifyDisconnected("Connection broken", "IO Error while sending data", e);
} catch (Exception e) {
downPrivate();
anyRemote._log("Connection", " Exception " + e.toString());
notifyDisconnected("Connection broken", "Exception", e);
}
}
}
private void downPrivate() {
sock.close();
closed = true;
anyRemote._log("Connection", "socket closed");
}
/** See {@link #notifyDisconnected(UserException)}. */
private void notifyDisconnected(String error, String details, Exception e) { | // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
// Path: java/anyremote/client/android/Connection.java
import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
*
* @param m
* The message to send. Content does not get changed.
*/
public void send(String m) {
synchronized (dos) {
if (closed)
return;
try {
sendPrivate(m);
} catch (IOException e) {
downPrivate();
notifyDisconnected("Connection broken", "IO Error while sending data", e);
} catch (Exception e) {
downPrivate();
anyRemote._log("Connection", " Exception " + e.toString());
notifyDisconnected("Connection broken", "Exception", e);
}
}
}
private void downPrivate() {
sock.close();
closed = true;
anyRemote._log("Connection", "socket closed");
}
/** See {@link #notifyDisconnected(UserException)}. */
private void notifyDisconnected(String error, String details, Exception e) { | notifyDisconnected(new UserException(error, details, e)); |
anyremote/anyremote-android-client | java/anyremote/client/android/Connection.java | // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
| import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException; |
if (id == Dispatcher.CMD_NO) {
anyRemote._log("Connection", "Incorrect command "
+ aWord);
getWord(false); // skip until ");" or until end of
// available bytes
readStage = READ_NO;
curCmdId = Dispatcher.CMD_NO;
continue;
}
readStage = READ_CMDID;
if (id == Dispatcher.CMD_IMAGE || id == Dispatcher.CMD_COVER) {
charMode = false;
// btoRead = 0; // in binary mode we will read full
// image
}
curCmdId = id;
cmdTokens.addElement(new Integer(id));
} else {
cmdTokens.addElement(aWord);
}
if (readingEndsAt == ENDS_AT_CEND) { // command was read fully
| // Path: java/anyremote/client/android/util/ISocket.java
// public interface ISocket {
// public void close();
// // public boolean isConnected(); BluetoothSocket API level 14 or higher
// public InputStream getInputStream();
// public OutputStream getOutputStream();
//
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
//
// Path: java/anyremote/client/android/util/UserException.java
// public class UserException extends Exception {
// private String error, details;
//
// static final long serialVersionUID = 1232123;
//
// public UserException(String error, String details) {
//
// this(error, details, null);
// }
//
// public UserException(String error, String details, Exception ex) {
//
// this.error = error;
//
// if (details == null) {
// if (ex != null && ex.getMessage() != null) {
// this.details = ex.getMessage();
// } else {
// this.details = "";
// }
// } else {
// if (ex != null && ex.getMessage() != null) {
// if (details.endsWith(".")) {
// details = details.substring(0, details.length() - 1);
// }
// this.details = details + " (" + ex.getMessage() + ").";
// } else {
// this.details = details;
// }
// }
//
// }
//
// // Get the error details
// public String getDetails() {
// return details;
// }
//
// // Get the error title
// public String getError() {
// return error;
// }
// }
// Path: java/anyremote/client/android/Connection.java
import java.util.Vector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import anyremote.client.android.util.ISocket;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.util.UserException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
if (id == Dispatcher.CMD_NO) {
anyRemote._log("Connection", "Incorrect command "
+ aWord);
getWord(false); // skip until ");" or until end of
// available bytes
readStage = READ_NO;
curCmdId = Dispatcher.CMD_NO;
continue;
}
readStage = READ_CMDID;
if (id == Dispatcher.CMD_IMAGE || id == Dispatcher.CMD_COVER) {
charMode = false;
// btoRead = 0; // in binary mode we will read full
// image
}
curCmdId = id;
cmdTokens.addElement(new Integer(id));
} else {
cmdTokens.addElement(aWord);
}
if (readingEndsAt == ENDS_AT_CEND) { // command was read fully
| int stage = (readStage == READ_PART ? ProtocolMessage.LAST |
anyremote/anyremote-android-client | java/anyremote/client/android/arActivity.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
| import android.view.Menu;
import anyremote.client.android.util.InfoMessage;
import java.util.Vector;
import android.app.Activity;
import android.app.Dialog;
import android.os.Handler;
import android.os.Message;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.KeyEvent; | //
// anyRemote android client
// a bluetooth/wi-fi remote control for Linux.
//
// Copyright (C) 2011-2016 Mikhail Fedotov <anyremote@mail.ru>
//
// This program 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
package anyremote.client.android;
public class arActivity extends Activity
implements DialogInterface.OnDismissListener,
DialogInterface.OnCancelListener,
Handler.Callback {
protected String prefix = "";
private boolean skipDismissEditDialog = false;
protected boolean exiting = false;
protected boolean longPress = false;
protected int privateMenu = anyRemote.NO_FORM;
public boolean handleMessage(Message msg) { | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
// Path: java/anyremote/client/android/arActivity.java
import android.view.Menu;
import anyremote.client.android.util.InfoMessage;
import java.util.Vector;
import android.app.Activity;
import android.app.Dialog;
import android.os.Handler;
import android.os.Message;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.KeyEvent;
//
// anyRemote android client
// a bluetooth/wi-fi remote control for Linux.
//
// Copyright (C) 2011-2016 Mikhail Fedotov <anyremote@mail.ru>
//
// This program 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
package anyremote.client.android;
public class arActivity extends Activity
implements DialogInterface.OnDismissListener,
DialogInterface.OnCancelListener,
Handler.Callback {
protected String prefix = "";
private boolean skipDismissEditDialog = false;
protected boolean exiting = false;
protected boolean longPress = false;
protected int privateMenu = anyRemote.NO_FORM;
public boolean handleMessage(Message msg) { | handleEvent((InfoMessage) msg.obj); |
anyremote/anyremote-android-client | java/anyremote/client/android/WinManager.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.widget.ImageButton;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.MotionEvent; | anyRemote.protocol.disconnect(false);
}
}
@Override
protected void doFinish(String action) {
log("doFinish");
exiting = true;
finish();
}
@Override
public void onBackPressed() {
commandAction(anyRemote.protocol.context.getString(R.string.back_item));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
commandAction(item.getTitle().toString());
return true;
}
public void commandAction(String command) {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/WinManager.java
import android.widget.ImageButton;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.MotionEvent;
anyRemote.protocol.disconnect(false);
}
}
@Override
protected void doFinish(String action) {
log("doFinish");
exiting = true;
finish();
}
@Override
public void onBackPressed() {
commandAction(anyRemote.protocol.context.getString(R.string.back_item));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
commandAction(item.getTitle().toString());
return true;
}
public void commandAction(String command) {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
| public void handleEvent(InfoMessage data) { |
anyremote/anyremote-android-client | java/anyremote/client/android/WinManager.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.widget.ImageButton;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.MotionEvent; |
log("doFinish");
exiting = true;
finish();
}
@Override
public void onBackPressed() {
commandAction(anyRemote.protocol.context.getString(R.string.back_item));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
commandAction(item.getTitle().toString());
return true;
}
public void commandAction(String command) {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id) + " " + data.stage);
checkPopup();
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/WinManager.java
import android.widget.ImageButton;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.MotionEvent;
log("doFinish");
exiting = true;
finish();
}
@Override
public void onBackPressed() {
commandAction(anyRemote.protocol.context.getString(R.string.back_item));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
commandAction(item.getTitle().toString());
return true;
}
public void commandAction(String command) {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id) + " " + data.stage);
checkPopup();
| if (data.stage == ProtocolMessage.FULL || data.stage == ProtocolMessage.FIRST) { |
anyremote/anyremote-android-client | java/anyremote/client/android/Dispatcher.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager; | private String currentConnPass = "";
boolean fullscreen = false;
// Control Screen stuff
private Vector<String> cfMenu = new Vector<String>();
int cfSkin;
boolean cfUseJoystick;
String cfTitle;
String cfStatus;
String cfCaption;
String [] cfIcons;
private String [] cfHints;
String cfUpEvent;
String cfDownEvent;
int cfInitFocus;
int cfFrgr;
int cfBkgr;
Bitmap cfCover;
String cfNamedCover;
float cfFSize;
Typeface cfTFace;
String cfVolume;
int cfPadding;
int cfIconSize;
int cfIconSizeOverride;
// List Screen stuff
String listTitle;
int listSelectPos = -1;
private Vector<String> listMenu = new Vector<String>(); | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/Dispatcher.java
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
private String currentConnPass = "";
boolean fullscreen = false;
// Control Screen stuff
private Vector<String> cfMenu = new Vector<String>();
int cfSkin;
boolean cfUseJoystick;
String cfTitle;
String cfStatus;
String cfCaption;
String [] cfIcons;
private String [] cfHints;
String cfUpEvent;
String cfDownEvent;
int cfInitFocus;
int cfFrgr;
int cfBkgr;
Bitmap cfCover;
String cfNamedCover;
float cfFSize;
Typeface cfTFace;
String cfVolume;
int cfPadding;
int cfIconSize;
int cfIconSizeOverride;
// List Screen stuff
String listTitle;
int listSelectPos = -1;
private Vector<String> listMenu = new Vector<String>(); | ArrayList<ListItem> listContent = null; |
anyremote/anyremote-android-client | java/anyremote/client/android/Dispatcher.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager; | case CMD_GETPING: return "Get(ping)";
case CMD_GETICSIZE: return "Get(icon_size)";
case CMD_GETPADDING: return "Get(icon_padding)";
case CMD_CLOSECONN: return "CMD_CLOSECONN";
//case CMD_EXIT: return "CMD_EXIT";
case CMD_EDIT_FORM_IP: return "CMD_EDIT_FORM_IP"; // used for logging only ?
case CMD_EDIT_FORM_BT: return "CMD_EDIT_FORM_BT";
case CMD_LIST_UPDATE: return "CMD_LIST_UPDATE";
case CMD_SEARCH_DIALOG: return "CMD_SEARCH_DIALOG";
case CMD_SENSOR_DIALOG: return "CMD_SENSOR_DIALOG";
case CMD_CLOSE: return "CMD_CLOSE";
}
return "UNKNOWN";
}
private void handleGetCoverSizeCmd() {
Display d = context.getWindowManager().getDefaultDisplay();
queueCommand("CoverSize("+(d.getWidth()*2)/3+",)");
}
private void handleGetScreeenSizeCmd() {
Display display = context.getWindowManager().getDefaultDisplay();
boolean rotated = (display.getOrientation() == Surface.ROTATION_90 ||
display.getOrientation() == Surface.ROTATION_270);
String ori = (rotated ? "R" : "");
queueCommand("SizeX("+display.getWidth() +","+ori+")");
queueCommand("SizeY("+display.getHeight()+","+ori+")");
}
| // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/Dispatcher.java
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
case CMD_GETPING: return "Get(ping)";
case CMD_GETICSIZE: return "Get(icon_size)";
case CMD_GETPADDING: return "Get(icon_padding)";
case CMD_CLOSECONN: return "CMD_CLOSECONN";
//case CMD_EXIT: return "CMD_EXIT";
case CMD_EDIT_FORM_IP: return "CMD_EDIT_FORM_IP"; // used for logging only ?
case CMD_EDIT_FORM_BT: return "CMD_EDIT_FORM_BT";
case CMD_LIST_UPDATE: return "CMD_LIST_UPDATE";
case CMD_SEARCH_DIALOG: return "CMD_SEARCH_DIALOG";
case CMD_SENSOR_DIALOG: return "CMD_SENSOR_DIALOG";
case CMD_CLOSE: return "CMD_CLOSE";
}
return "UNKNOWN";
}
private void handleGetCoverSizeCmd() {
Display d = context.getWindowManager().getDefaultDisplay();
queueCommand("CoverSize("+(d.getWidth()*2)/3+",)");
}
private void handleGetScreeenSizeCmd() {
Display display = context.getWindowManager().getDefaultDisplay();
boolean rotated = (display.getOrientation() == Surface.ROTATION_90 ||
display.getOrientation() == Surface.ROTATION_270);
String ori = (rotated ? "R" : "");
queueCommand("SizeX("+display.getWidth() +","+ori+")");
queueCommand("SizeY("+display.getHeight()+","+ori+")");
}
| public void handleCommand(ProtocolMessage msg) { |
anyremote/anyremote-android-client | java/anyremote/client/android/Dispatcher.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager; | return msgQueue.size();
}
}
private synchronized void processMessageQueue() {
final Iterator<QueueMessage> msgItr = msgQueue.iterator();
while (msgItr.hasNext()) {
final QueueMessage pm = msgItr.next();
boolean sent = false;
synchronized (syncObj) {
final Iterator<ArHandler> itr = actHandlers.iterator();
log("processMessageQueue MSG " + cmdStr(pm.id) + " handlers #" + actHandlers.size());
while (itr.hasNext()) {
try {
final ArHandler handler = itr.next();
if (pm.activity < 0 || // send to all
handler.actId == pm.activity) {
log("processMessageQueue MSG " + cmdStr(pm.id) +
" to " + anyRemote.getScreenStr(pm.activity) +
" SENT (attempt " + pm.attemptsToSend + ") to "+
anyRemote.getScreenStr(handler.actId));
| // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/Dispatcher.java
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
return msgQueue.size();
}
}
private synchronized void processMessageQueue() {
final Iterator<QueueMessage> msgItr = msgQueue.iterator();
while (msgItr.hasNext()) {
final QueueMessage pm = msgItr.next();
boolean sent = false;
synchronized (syncObj) {
final Iterator<ArHandler> itr = actHandlers.iterator();
log("processMessageQueue MSG " + cmdStr(pm.id) + " handlers #" + actHandlers.size());
while (itr.hasNext()) {
try {
final ArHandler handler = itr.next();
if (pm.activity < 0 || // send to all
handler.actId == pm.activity) {
log("processMessageQueue MSG " + cmdStr(pm.id) +
" to " + anyRemote.getScreenStr(pm.activity) +
" SENT (attempt " + pm.attemptsToSend + ") to "+
anyRemote.getScreenStr(handler.actId));
| InfoMessage im = new InfoMessage(); |
anyremote/anyremote-android-client | java/anyremote/client/android/Dispatcher.java | // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager; | if (keepaliveCounter == 0) {
log("keepaliveTask seems connection is lost, do disconnect");
disconnect(true);
} else {
keepaliveCounter = 0;
scheduleKeepaliveTask();
}
}
}
public void handleEditFieldResult(int id, String button, String value) {
if (id == Dispatcher.CMD_GETPASS) {
queueCommand("_PASSWORD_(,"+value+")");
setPassForConnection(value);
} else {
queueCommand(button + "(0," + value + ")");
}
}
private void setPassForConnection(String pass) {
SharedPreferences preference = context.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preference.edit();
String UP = currentConnection + "\n" + pass;
editor.putString(currentConnName, UP);
editor.commit();
}
| // Path: java/anyremote/client/android/util/Address.java
// public class Address {
// public String name;
// public String URL;
// public String pass;
// public boolean autoconnect;
// }
//
// Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ListItem.java
// public class ListItem {
// public String text;
// public String icon;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/Dispatcher.java
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.TimerTask;
import java.util.Vector;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import anyremote.client.android.util.Address;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ListItem;
import anyremote.client.android.util.ProtocolMessage;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
if (keepaliveCounter == 0) {
log("keepaliveTask seems connection is lost, do disconnect");
disconnect(true);
} else {
keepaliveCounter = 0;
scheduleKeepaliveTask();
}
}
}
public void handleEditFieldResult(int id, String button, String value) {
if (id == Dispatcher.CMD_GETPASS) {
queueCommand("_PASSWORD_(,"+value+")");
setPassForConnection(value);
} else {
queueCommand(button + "(0," + value + ")");
}
}
private void setPassForConnection(String pass) {
SharedPreferences preference = context.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preference.edit();
String UP = currentConnection + "\n" + pass;
editor.putString(currentConnName, UP);
editor.commit();
}
| public Vector<Address> loadPrefs() { |
anyremote/anyremote-android-client | java/anyremote/client/android/TextScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.view.KeyEvent;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.widget.TextView;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View; | //doFinish("log"); // just close Log form
doFinish("");
} else if (command.equals(anyRemote.protocol.context.getString(R.string.clear_log_item))) {
anyRemote.logData.delete(0,anyRemote.logData.length());
text.setText("");
} else if (command.equals(anyRemote.protocol.context.getString(R.string.report_bug_item))) {
Intent mailIntent = new Intent(Intent.ACTION_SEND);
mailIntent.setType("text/plain");
mailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "anyremote@mail.ru" });
mailIntent.putExtra(Intent.EXTRA_SUBJECT, "anyRemote android client bugreport");
mailIntent.putExtra(Intent.EXTRA_TEXT, anyRemote.logData.toString());
startActivity(Intent.createChooser(mailIntent, "Bug report"));
}
} else {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
}
// Set(text,add,title,_text_) 3+text
// Set(text,replace,title,_text_) 3+text
// Set(text,fg|bg,r,g,b) 6
// Set(text,font,small|medium|large) 3
// Set(text,close[,clear]) 2 or 3
// Set(text,wrap,on|off) 3
// Set(text,show) 2 | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/TextScreen.java
import android.view.KeyEvent;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.widget.TextView;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
//doFinish("log"); // just close Log form
doFinish("");
} else if (command.equals(anyRemote.protocol.context.getString(R.string.clear_log_item))) {
anyRemote.logData.delete(0,anyRemote.logData.length());
text.setText("");
} else if (command.equals(anyRemote.protocol.context.getString(R.string.report_bug_item))) {
Intent mailIntent = new Intent(Intent.ACTION_SEND);
mailIntent.setType("text/plain");
mailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "anyremote@mail.ru" });
mailIntent.putExtra(Intent.EXTRA_SUBJECT, "anyRemote android client bugreport");
mailIntent.putExtra(Intent.EXTRA_TEXT, anyRemote.logData.toString());
startActivity(Intent.createChooser(mailIntent, "Bug report"));
}
} else {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
}
// Set(text,add,title,_text_) 3+text
// Set(text,replace,title,_text_) 3+text
// Set(text,fg|bg,r,g,b) 6
// Set(text,font,small|medium|large) 3
// Set(text,close[,clear]) 2 or 3
// Set(text,wrap,on|off) 3
// Set(text,show) 2 | public void handleEvent(InfoMessage data) { |
anyremote/anyremote-android-client | java/anyremote/client/android/TextScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.view.KeyEvent;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.widget.TextView;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View; | mailIntent.putExtra(Intent.EXTRA_TEXT, anyRemote.logData.toString());
startActivity(Intent.createChooser(mailIntent, "Bug report"));
}
} else {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
}
// Set(text,add,title,_text_) 3+text
// Set(text,replace,title,_text_) 3+text
// Set(text,fg|bg,r,g,b) 6
// Set(text,font,small|medium|large) 3
// Set(text,close[,clear]) 2 or 3
// Set(text,wrap,on|off) 3
// Set(text,show) 2
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id) + " " + data.stage);
if (isLog) {
if (data.id == Dispatcher.CMD_CLOSE) {
doFinish("");
return;
}
}
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/TextScreen.java
import android.view.KeyEvent;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.widget.TextView;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
import anyremote.client.android.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
mailIntent.putExtra(Intent.EXTRA_TEXT, anyRemote.logData.toString());
startActivity(Intent.createChooser(mailIntent, "Bug report"));
}
} else {
if (command.equals(anyRemote.protocol.context.getString(R.string.back_item))) {
command = "Back"; // avoid national alphabets
}
anyRemote.protocol.queueCommand(command);
}
}
// Set(text,add,title,_text_) 3+text
// Set(text,replace,title,_text_) 3+text
// Set(text,fg|bg,r,g,b) 6
// Set(text,font,small|medium|large) 3
// Set(text,close[,clear]) 2 or 3
// Set(text,wrap,on|off) 3
// Set(text,show) 2
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id) + " " + data.stage);
if (isLog) {
if (data.id == Dispatcher.CMD_CLOSE) {
doFinish("");
return;
}
}
| if (data.stage == ProtocolMessage.FULL || data.stage == ProtocolMessage.FIRST) { |
anyremote/anyremote-android-client | java/anyremote/client/android/KeyboardScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage; | //imm.toggleSoftInputFromWindow(kView.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}
);*/
}
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/KeyboardScreen.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
//imm.toggleSoftInputFromWindow(kView.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}
);*/
}
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
| public void handleEvent(InfoMessage data) { |
anyremote/anyremote-android-client | java/anyremote/client/android/KeyboardScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage; | }
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id));
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/KeyboardScreen.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
}
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id));
| if (data.stage != ProtocolMessage.FULL && // process only full commands |
anyremote/anyremote-android-client | java/anyremote/client/android/ControlScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.Display;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.KeyEvent;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage; |
redraw();
exiting = false;
}
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!switchedToPrivateScreen && !exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/ControlScreen.java
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.Display;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.KeyEvent;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
redraw();
exiting = false;
}
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!switchedToPrivateScreen && !exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
| public void handleEvent(InfoMessage data) { |
anyremote/anyremote-android-client | java/anyremote/client/android/ControlScreen.java | // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
| import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.Display;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.KeyEvent;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage; | @Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!switchedToPrivateScreen && !exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id));
// checkPopup();
| // Path: java/anyremote/client/android/util/InfoMessage.java
// public class InfoMessage {
// public int id;
// public int stage;
// }
//
// Path: java/anyremote/client/android/util/ProtocolMessage.java
// public class ProtocolMessage {
// public static final int FULL = 0;
// public static final int FIRST = 1;
// public static final int INTERMED = 2;
// public static final int LAST = 3;
//
// public int id;
// public int stage;
// public Vector tokens;
// }
// Path: java/anyremote/client/android/ControlScreen.java
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector;
import android.view.Display;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.KeyEvent;
import anyremote.client.android.util.InfoMessage;
import anyremote.client.android.util.ProtocolMessage;
@Override
protected void onStop() {
log("onStop");
super.onStop();
}
@Override
protected void onDestroy() {
log("onDestroy");
anyRemote.protocol.removeMessageHandler(hdlLocalCopy);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
log("onUserLeaveHint");
// no time to sending events
// commandAction(anyRemote.protocol.context.getString(R.string.disconnect_item));
if (!switchedToPrivateScreen && !exiting && anyRemote.protocol.messageQueueSize() == 0) {
log("onUserLeaveHint - make disconnect");
anyRemote.protocol.disconnect(false);
}
}
public void handleEvent(InfoMessage data) {
log("handleEvent " + Dispatcher.cmdStr(data.id));
// checkPopup();
| if (data.stage != ProtocolMessage.FULL && // process only full commands |
ResearchStack/SampleApp | app/src/main/java/org/researchstack/sampleapp/SampleResearchStack.java | // Path: app/src/main/java/org/researchstack/sampleapp/bridge/BridgeEncryptedDatabase.java
// public class BridgeEncryptedDatabase extends SqlCipherDatabaseHelper implements UploadQueue
// {
// public BridgeEncryptedDatabase(Context context, String name, SQLiteDatabase.CursorFactory cursorFactory, int version, UpdatablePassphraseProvider passphraseProvider)
// {
// super(context, name, cursorFactory, version, passphraseProvider);
// }
//
// @Override
// public void onCreate(SQLiteDatabase sqLiteDatabase)
// {
// super.onCreate(sqLiteDatabase);
// try
// {
// TableUtils.createTables(new SQLiteDatabaseImpl(sqLiteDatabase), UploadRequest.class);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
// {
// super.onUpgrade(sqLiteDatabase, oldVersion, newVersion);
// // handle future db upgrades here
// }
//
// public void saveUploadRequest(UploadRequest uploadRequest)
// {
// LogExt.d(this.getClass(), "saveUploadRequest() id: " + uploadRequest.id);
//
// try
// {
// this.getDao(UploadRequest.class).createOrUpdate(uploadRequest);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// public List<UploadRequest> loadUploadRequests()
// {
// try
// {
// return this.getDao(UploadRequest.class).queryForAll().orderBy("id DESC").list();
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// public void deleteUploadRequest(UploadRequest request)
// {
//
// LogExt.d(this.getClass(), "deleteUploadRequest() id: " + request.id);
//
// try
// {
// this.getDao(UploadRequest.class).delete(request);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
// }
| import android.content.Context;
import net.sqlcipher.database.SQLiteDatabase;
import org.researchstack.backbone.storage.database.AppDatabase;
import org.researchstack.backbone.storage.database.sqlite.SqlCipherDatabaseHelper;
import org.researchstack.backbone.storage.database.sqlite.UpdatablePassphraseProvider;
import org.researchstack.backbone.storage.file.EncryptionProvider;
import org.researchstack.backbone.storage.file.FileAccess;
import org.researchstack.backbone.storage.file.PinCodeConfig;
import org.researchstack.backbone.storage.file.SimpleFileAccess;
import org.researchstack.backbone.storage.file.aes.AesProvider;
import org.researchstack.sampleapp.bridge.BridgeEncryptedDatabase;
import org.researchstack.skin.AppPrefs;
import org.researchstack.skin.DataProvider;
import org.researchstack.skin.PermissionRequestManager;
import org.researchstack.skin.ResearchStack;
import org.researchstack.skin.ResourceManager;
import org.researchstack.skin.TaskProvider;
import org.researchstack.skin.UiManager;
import org.researchstack.skin.notification.NotificationConfig;
import org.researchstack.skin.notification.SimpleNotificationConfig; | package org.researchstack.sampleapp;
public class SampleResearchStack extends ResearchStack
{
@Override
protected AppDatabase createAppDatabaseImplementation(Context context)
{
SQLiteDatabase.loadLibs(context); | // Path: app/src/main/java/org/researchstack/sampleapp/bridge/BridgeEncryptedDatabase.java
// public class BridgeEncryptedDatabase extends SqlCipherDatabaseHelper implements UploadQueue
// {
// public BridgeEncryptedDatabase(Context context, String name, SQLiteDatabase.CursorFactory cursorFactory, int version, UpdatablePassphraseProvider passphraseProvider)
// {
// super(context, name, cursorFactory, version, passphraseProvider);
// }
//
// @Override
// public void onCreate(SQLiteDatabase sqLiteDatabase)
// {
// super.onCreate(sqLiteDatabase);
// try
// {
// TableUtils.createTables(new SQLiteDatabaseImpl(sqLiteDatabase), UploadRequest.class);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
// {
// super.onUpgrade(sqLiteDatabase, oldVersion, newVersion);
// // handle future db upgrades here
// }
//
// public void saveUploadRequest(UploadRequest uploadRequest)
// {
// LogExt.d(this.getClass(), "saveUploadRequest() id: " + uploadRequest.id);
//
// try
// {
// this.getDao(UploadRequest.class).createOrUpdate(uploadRequest);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// public List<UploadRequest> loadUploadRequests()
// {
// try
// {
// return this.getDao(UploadRequest.class).queryForAll().orderBy("id DESC").list();
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
//
// public void deleteUploadRequest(UploadRequest request)
// {
//
// LogExt.d(this.getClass(), "deleteUploadRequest() id: " + request.id);
//
// try
// {
// this.getDao(UploadRequest.class).delete(request);
// }
// catch(SQLException e)
// {
// throw new RuntimeException(e);
// }
// }
// }
// Path: app/src/main/java/org/researchstack/sampleapp/SampleResearchStack.java
import android.content.Context;
import net.sqlcipher.database.SQLiteDatabase;
import org.researchstack.backbone.storage.database.AppDatabase;
import org.researchstack.backbone.storage.database.sqlite.SqlCipherDatabaseHelper;
import org.researchstack.backbone.storage.database.sqlite.UpdatablePassphraseProvider;
import org.researchstack.backbone.storage.file.EncryptionProvider;
import org.researchstack.backbone.storage.file.FileAccess;
import org.researchstack.backbone.storage.file.PinCodeConfig;
import org.researchstack.backbone.storage.file.SimpleFileAccess;
import org.researchstack.backbone.storage.file.aes.AesProvider;
import org.researchstack.sampleapp.bridge.BridgeEncryptedDatabase;
import org.researchstack.skin.AppPrefs;
import org.researchstack.skin.DataProvider;
import org.researchstack.skin.PermissionRequestManager;
import org.researchstack.skin.ResearchStack;
import org.researchstack.skin.ResourceManager;
import org.researchstack.skin.TaskProvider;
import org.researchstack.skin.UiManager;
import org.researchstack.skin.notification.NotificationConfig;
import org.researchstack.skin.notification.SimpleNotificationConfig;
package org.researchstack.sampleapp;
public class SampleResearchStack extends ResearchStack
{
@Override
protected AppDatabase createAppDatabaseImplementation(Context context)
{
SQLiteDatabase.loadLibs(context); | return new BridgeEncryptedDatabase(context, |
tcking/GiraffePlayer2 | giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/DefaultMediaController.java | // Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/trackselector/TrackSelectorFragment.java
// public class TrackSelectorFragment extends DialogFragment{
// private ViewQuery $;
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
// View view = inflater.inflate(R.layout.giraffe_track_selector, container, false);
// $ = new ViewQuery(view);
// return view;
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// ExpandableListView list = $.id(R.id.app_video_track_list).view();
//
// $.id(R.id.app_video_track_close).clicked(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// dismissAllowingStateLoss();
// // getFragmentManager().beginTransaction().remove(TrackSelectorFragment.this).commit();
// }
// });
//
// final TracksAdapter tracksAdapter = new TracksAdapter();
// list.setGroupIndicator(null);
// list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
// @Override
// public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
// return true;
// }
// });
// list.setAdapter(tracksAdapter);
// tracksAdapter.load(getArguments().getString("fingerprint"));
// int count = tracksAdapter.getGroupCount();
// for ( int i = 0; i < count; i++ ) {
// list.expandGroup(i);
// }
// }
// }
| import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.github.tcking.giraffeplayer2.R;
import java.util.Locale;
import tcking.github.com.giraffeplayer2.trackselector.TrackSelectorFragment;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkTimedText; | protected final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
GiraffePlayer player = videoView.getPlayer();
if (v.getId() == R.id.app_video_fullscreen) {
player.toggleFullScreen();
} else if (v.getId() == R.id.app_video_play) {
if (player.isPlaying()) {
player.pause();
} else {
player.start();
}
} else if (v.getId() == R.id.app_video_replay_icon) {
player.seekTo(0);
player.start();
// videoView.seekTo(0);
// videoView.start();
// doPauseResume();
} else if (v.getId() == R.id.app_video_finish) {
if (!player.onBackPressed()) {
((Activity) videoView.getContext()).finish();
}
} else if (v.getId() == R.id.app_video_float_close) {
player.stop();
player.setDisplayModel(GiraffePlayer.DISPLAY_NORMAL);
} else if (v.getId() == R.id.app_video_float_full) {
player.setDisplayModel(GiraffePlayer.DISPLAY_FULL_WINDOW);
} else if (v.getId() == R.id.app_video_clarity) {
Activity activity = (Activity) videoView.getContext();
if (activity instanceof AppCompatActivity) { | // Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/trackselector/TrackSelectorFragment.java
// public class TrackSelectorFragment extends DialogFragment{
// private ViewQuery $;
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
// View view = inflater.inflate(R.layout.giraffe_track_selector, container, false);
// $ = new ViewQuery(view);
// return view;
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// ExpandableListView list = $.id(R.id.app_video_track_list).view();
//
// $.id(R.id.app_video_track_close).clicked(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// dismissAllowingStateLoss();
// // getFragmentManager().beginTransaction().remove(TrackSelectorFragment.this).commit();
// }
// });
//
// final TracksAdapter tracksAdapter = new TracksAdapter();
// list.setGroupIndicator(null);
// list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
// @Override
// public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
// return true;
// }
// });
// list.setAdapter(tracksAdapter);
// tracksAdapter.load(getArguments().getString("fingerprint"));
// int count = tracksAdapter.getGroupCount();
// for ( int i = 0; i < count; i++ ) {
// list.expandGroup(i);
// }
// }
// }
// Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/DefaultMediaController.java
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.github.tcking.giraffeplayer2.R;
import java.util.Locale;
import tcking.github.com.giraffeplayer2.trackselector.TrackSelectorFragment;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkTimedText;
protected final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
GiraffePlayer player = videoView.getPlayer();
if (v.getId() == R.id.app_video_fullscreen) {
player.toggleFullScreen();
} else if (v.getId() == R.id.app_video_play) {
if (player.isPlaying()) {
player.pause();
} else {
player.start();
}
} else if (v.getId() == R.id.app_video_replay_icon) {
player.seekTo(0);
player.start();
// videoView.seekTo(0);
// videoView.start();
// doPauseResume();
} else if (v.getId() == R.id.app_video_finish) {
if (!player.onBackPressed()) {
((Activity) videoView.getContext()).finish();
}
} else if (v.getId() == R.id.app_video_float_close) {
player.stop();
player.setDisplayModel(GiraffePlayer.DISPLAY_NORMAL);
} else if (v.getId() == R.id.app_video_float_full) {
player.setDisplayModel(GiraffePlayer.DISPLAY_FULL_WINDOW);
} else if (v.getId() == R.id.app_video_clarity) {
Activity activity = (Activity) videoView.getContext();
if (activity instanceof AppCompatActivity) { | TrackSelectorFragment trackSelectorFragment = new TrackSelectorFragment(); |
apache/commons-dbutils | src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java | // Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
| import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbutils.RowProcessor; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* <p>
* {@code ResultSetHandler} implementation that returns a Map of Beans.
* {@code ResultSet} rows are converted into Beans which are then stored in
* a Map under the given key.
* </p>
* <p>
* If you had a Person table with a primary key column called ID, you could
* retrieve rows from the table like this:
*
* <pre>
* ResultSetHandler<Map<Long, Person>> h = new BeanMapHandler<Long, Person>(Person.class, "id");
* Map<Long, Person> found = queryRunner.query("select id, name, age from person", h);
* Person jane = found.get(1L); // jane's id is 1
* String janesName = jane.getName();
* Integer janesAge = jane.getAge();
* </pre>
*
* Note that the "id" passed to BeanMapHandler can be in any case. The data type
* returned for id is dependent upon how your JDBC driver converts SQL column
* types from the Person table into Java types. The "name" and "age" columns are
* converted according to their property descriptors by DbUtils.
* </p>
* <p>
* This class is thread safe.
* </p>
*
* @param <K>
* the type of keys maintained by the returned map
* @param <V>
* the type of the bean
* @see org.apache.commons.dbutils.ResultSetHandler
* @since DbUtils 1.5
*/
public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
/**
* The Class of beans produced by this handler.
*/
private final Class<V> type;
/**
* The RowProcessor implementation to use when converting rows into Objects.
*/ | // Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
// Path: src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbutils.RowProcessor;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* <p>
* {@code ResultSetHandler} implementation that returns a Map of Beans.
* {@code ResultSet} rows are converted into Beans which are then stored in
* a Map under the given key.
* </p>
* <p>
* If you had a Person table with a primary key column called ID, you could
* retrieve rows from the table like this:
*
* <pre>
* ResultSetHandler<Map<Long, Person>> h = new BeanMapHandler<Long, Person>(Person.class, "id");
* Map<Long, Person> found = queryRunner.query("select id, name, age from person", h);
* Person jane = found.get(1L); // jane's id is 1
* String janesName = jane.getName();
* Integer janesAge = jane.getAge();
* </pre>
*
* Note that the "id" passed to BeanMapHandler can be in any case. The data type
* returned for id is dependent upon how your JDBC driver converts SQL column
* types from the Person table into Java types. The "name" and "age" columns are
* converted according to their property descriptors by DbUtils.
* </p>
* <p>
* This class is thread safe.
* </p>
*
* @param <K>
* the type of keys maintained by the returned map
* @param <V>
* the type of the bean
* @see org.apache.commons.dbutils.ResultSetHandler
* @since DbUtils 1.5
*/
public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
/**
* The Class of beans produced by this handler.
*/
private final Class<V> type;
/**
* The RowProcessor implementation to use when converting rows into Objects.
*/ | private final RowProcessor convert; |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/columns/ColumnHandlerTestBase.java | // Path: src/main/java/org/apache/commons/dbutils/ColumnHandler.java
// public interface ColumnHandler {
// /**
// * Test whether this {@code ColumnHandler} wants to handle a column targeted for a value type matching
// * {@code propType}.
// *
// * @param propType The type of the target parameter.
// * @return true is this property handler can/wants to handle this value; false otherwise.
// */
// boolean match(Class<?> propType);
//
// /**
// * Do the work required to retrieve and store a column from {@code ResultSet} into something of type
// * {@code propType}. This method is called only if this handler responded {@code true} after a call to
// * {@link #match(Class)}.
// *
// * @param rs The result set to get data from. This should be moved to the correct row already.
// * @param columnIndex The position of the column to retrieve.
// * @return The converted value or the original value if something doesn't work out.
// * @throws SQLException if the columnIndex is not valid; if a database access error occurs or this method is
// * called on a closed result set
// */
// Object apply(ResultSet rs, int columnIndex) throws SQLException;
// }
| import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.sql.ResultSet;
import org.apache.commons.dbutils.ColumnHandler;
import org.junit.Test;
import org.mockito.Mock; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers.columns;
public abstract class ColumnHandlerTestBase {
@Mock
protected ResultSet rs; | // Path: src/main/java/org/apache/commons/dbutils/ColumnHandler.java
// public interface ColumnHandler {
// /**
// * Test whether this {@code ColumnHandler} wants to handle a column targeted for a value type matching
// * {@code propType}.
// *
// * @param propType The type of the target parameter.
// * @return true is this property handler can/wants to handle this value; false otherwise.
// */
// boolean match(Class<?> propType);
//
// /**
// * Do the work required to retrieve and store a column from {@code ResultSet} into something of type
// * {@code propType}. This method is called only if this handler responded {@code true} after a call to
// * {@link #match(Class)}.
// *
// * @param rs The result set to get data from. This should be moved to the correct row already.
// * @param columnIndex The position of the column to retrieve.
// * @return The converted value or the original value if something doesn't work out.
// * @throws SQLException if the columnIndex is not valid; if a database access error occurs or this method is
// * called on a closed result set
// */
// Object apply(ResultSet rs, int columnIndex) throws SQLException;
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/columns/ColumnHandlerTestBase.java
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.sql.ResultSet;
import org.apache.commons.dbutils.ColumnHandler;
import org.junit.Test;
import org.mockito.Mock;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers.columns;
public abstract class ColumnHandlerTestBase {
@Mock
protected ResultSet rs; | protected final ColumnHandler handler; |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ColumnListHandlerTest
*/
public class ColumnListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ColumnListHandlerTest
*/
public class ColumnListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<List<String>> h = new ColumnListHandler<>(); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
| import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanListHandlerTest
*/
public class BeanListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanListHandlerTest
*/
public class BeanListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
| import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanListHandlerTest
*/
public class BeanListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanListHandlerTest
*/
public class BeanListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
| import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanHandlerTest
*/
public class BeanHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanHandlerTest
*/
public class BeanHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
| import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanHandlerTest
*/
public class BeanHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/test/java/org/apache/commons/dbutils/TestBean.java
// public class TestBean {
//
// public enum Ordinal {
//
// THREE, SIX;
//
// }
//
// private String one = null;
//
// private String two = null;
//
// private Ordinal three = null;
//
// private int intTest = 0;
//
// private Integer integerTest = Integer.valueOf(0);
//
// // UNUSED private Timestamp timestamp = null;
//
// private String doNotSet = "not set";
//
// /**
// * toBean() should set primitive fields to their defaults (ie. 0) when
// * null is returned from the ResultSet.
// */
// private int nullPrimitiveTest = 7;
//
// /**
// * toBean() should set Object fields to null when null is returned from the
// * ResultSet
// */
// private Object nullObjectTest = "overwrite";
//
// /**
// * A Date will be returned from the ResultSet but the property is a String.
// * BeanProcessor should create a String from the Date and set this property.
// */
// private String notDate = "not a date";
//
// /**
// * The ResultSet will have a BigDecimal in this column and the
// * BasicColumnProcessor should convert that to a double and store the value
// * in this property.
// */
// private double columnProcessorDoubleTest = -1;
//
// /**
// * Constructor for TestBean.
// */
// public TestBean() {
// }
//
// public String getOne() {
// return one;
// }
//
// public Ordinal getThree() {
// return three;
// }
//
// public String getTwo() {
// return two;
// }
//
// public void setOne(final String string) {
// one = string;
// }
//
// public void setThree(final Ordinal ordinal) {
// three = ordinal;
// }
//
// public void setTwo(final String string) {
// two = string;
// }
//
// public String getDoNotSet() {
// return doNotSet;
// }
//
// public void setDoNotSet(final String string) {
// doNotSet = string;
// }
//
// public Integer getIntegerTest() {
// return integerTest;
// }
//
// public int getIntTest() {
// return intTest;
// }
//
// public void setIntegerTest(final Integer integer) {
// integerTest = integer;
// }
//
// public void setIntTest(final int i) {
// intTest = i;
// }
//
// public Object getNullObjectTest() {
// return nullObjectTest;
// }
//
// public int getNullPrimitiveTest() {
// return nullPrimitiveTest;
// }
//
// public void setNullObjectTest(final Object object) {
// nullObjectTest = object;
// }
//
// public void setNullPrimitiveTest(final int i) {
// nullPrimitiveTest = i;
// }
//
// public String getNotDate() {
// return notDate;
// }
//
// public void setNotDate(final String string) {
// notDate = string;
// }
//
// public double getColumnProcessorDoubleTest() {
// return columnProcessorDoubleTest;
// }
//
// public void setColumnProcessorDoubleTest(final double d) {
// columnProcessorDoubleTest = d;
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.TestBean;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* BeanHandlerTest
*/
public class BeanHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class); |
apache/commons-dbutils | src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
| import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* {@code ResultSetHandler} implementation that converts a
* {@code ResultSet} into a {@code List} of beans. This class is
* thread safe.
*
* @param <T> the target bean type
* @see org.apache.commons.dbutils.ResultSetHandler
*/
public class BeanListHandler<T> implements ResultSetHandler<List<T>> {
/**
* The Class of beans produced by this handler.
*/
private final Class<? extends T> type;
/**
* The RowProcessor implementation to use when converting rows
* into beans.
*/ | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
// Path: src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* {@code ResultSetHandler} implementation that converts a
* {@code ResultSet} into a {@code List} of beans. This class is
* thread safe.
*
* @param <T> the target bean type
* @see org.apache.commons.dbutils.ResultSetHandler
*/
public class BeanListHandler<T> implements ResultSetHandler<List<T>> {
/**
* The Class of beans produced by this handler.
*/
private final Class<? extends T> type;
/**
* The RowProcessor implementation to use when converting rows
* into beans.
*/ | private final RowProcessor convert; |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* MapListHandlerTest
*/
public class MapListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* MapListHandlerTest
*/
public class MapListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler(); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ArrayHandlerTest
*/
public class ArrayHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ArrayHandlerTest
*/
public class ArrayHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<Object[]> h = new ArrayHandler(); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java | // Path: src/test/java/org/apache/commons/dbutils/handlers/columns/TestColumnHandler.java
// public class TestColumnHandler implements ColumnHandler {
//
// @Override
// public boolean match(final Class<?> propType) {
// return false;
// }
//
// @Override
// public Object apply(final ResultSet rs, final int columnIndex) throws SQLException {
// return null;
// }
// }
//
// Path: src/test/java/org/apache/commons/dbutils/handlers/properties/TestPropertyHandler.java
// public class TestPropertyHandler implements PropertyHandler {
//
// @Override
// public boolean match(final Class<?> parameter, final Object value) {
// return false;
// }
//
// @Override
// public Object apply(final Class<?> parameter, final Object value) {
// return null;
// }
// }
| import static org.junit.Assert.assertTrue;
import java.util.ServiceLoader;
import org.apache.commons.dbutils.handlers.columns.TestColumnHandler;
import org.apache.commons.dbutils.handlers.properties.TestPropertyHandler;
import org.junit.Before;
import org.junit.Test; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
public class ServiceLoaderTest {
private ServiceLoader<ColumnHandler> columns;
private ServiceLoader<PropertyHandler> properties;
@Before
public void setUp() {
columns = ServiceLoader.load(ColumnHandler.class);
properties = ServiceLoader.load(PropertyHandler.class);
}
@Test
public void testFindsLocalColumnHandler() {
boolean found = false;
for (final ColumnHandler handler : columns) {
// this class is defined outside of the main classes in dbutils | // Path: src/test/java/org/apache/commons/dbutils/handlers/columns/TestColumnHandler.java
// public class TestColumnHandler implements ColumnHandler {
//
// @Override
// public boolean match(final Class<?> propType) {
// return false;
// }
//
// @Override
// public Object apply(final ResultSet rs, final int columnIndex) throws SQLException {
// return null;
// }
// }
//
// Path: src/test/java/org/apache/commons/dbutils/handlers/properties/TestPropertyHandler.java
// public class TestPropertyHandler implements PropertyHandler {
//
// @Override
// public boolean match(final Class<?> parameter, final Object value) {
// return false;
// }
//
// @Override
// public Object apply(final Class<?> parameter, final Object value) {
// return null;
// }
// }
// Path: src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
import static org.junit.Assert.assertTrue;
import java.util.ServiceLoader;
import org.apache.commons.dbutils.handlers.columns.TestColumnHandler;
import org.apache.commons.dbutils.handlers.properties.TestPropertyHandler;
import org.junit.Before;
import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
public class ServiceLoaderTest {
private ServiceLoader<ColumnHandler> columns;
private ServiceLoader<PropertyHandler> properties;
@Before
public void setUp() {
columns = ServiceLoader.load(ColumnHandler.class);
properties = ServiceLoader.load(PropertyHandler.class);
}
@Test
public void testFindsLocalColumnHandler() {
boolean found = false;
for (final ColumnHandler handler : columns) {
// this class is defined outside of the main classes in dbutils | if (handler instanceof TestColumnHandler) { |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java | // Path: src/test/java/org/apache/commons/dbutils/handlers/columns/TestColumnHandler.java
// public class TestColumnHandler implements ColumnHandler {
//
// @Override
// public boolean match(final Class<?> propType) {
// return false;
// }
//
// @Override
// public Object apply(final ResultSet rs, final int columnIndex) throws SQLException {
// return null;
// }
// }
//
// Path: src/test/java/org/apache/commons/dbutils/handlers/properties/TestPropertyHandler.java
// public class TestPropertyHandler implements PropertyHandler {
//
// @Override
// public boolean match(final Class<?> parameter, final Object value) {
// return false;
// }
//
// @Override
// public Object apply(final Class<?> parameter, final Object value) {
// return null;
// }
// }
| import static org.junit.Assert.assertTrue;
import java.util.ServiceLoader;
import org.apache.commons.dbutils.handlers.columns.TestColumnHandler;
import org.apache.commons.dbutils.handlers.properties.TestPropertyHandler;
import org.junit.Before;
import org.junit.Test; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
public class ServiceLoaderTest {
private ServiceLoader<ColumnHandler> columns;
private ServiceLoader<PropertyHandler> properties;
@Before
public void setUp() {
columns = ServiceLoader.load(ColumnHandler.class);
properties = ServiceLoader.load(PropertyHandler.class);
}
@Test
public void testFindsLocalColumnHandler() {
boolean found = false;
for (final ColumnHandler handler : columns) {
// this class is defined outside of the main classes in dbutils
if (handler instanceof TestColumnHandler) {
found = true;
}
}
assertTrue(found);
}
@Test
public void testFindsLocalPropertyHandler() {
boolean found = false;
for (final PropertyHandler handler : properties) {
// this class is defined outside of the main classes in dbutils | // Path: src/test/java/org/apache/commons/dbutils/handlers/columns/TestColumnHandler.java
// public class TestColumnHandler implements ColumnHandler {
//
// @Override
// public boolean match(final Class<?> propType) {
// return false;
// }
//
// @Override
// public Object apply(final ResultSet rs, final int columnIndex) throws SQLException {
// return null;
// }
// }
//
// Path: src/test/java/org/apache/commons/dbutils/handlers/properties/TestPropertyHandler.java
// public class TestPropertyHandler implements PropertyHandler {
//
// @Override
// public boolean match(final Class<?> parameter, final Object value) {
// return false;
// }
//
// @Override
// public Object apply(final Class<?> parameter, final Object value) {
// return null;
// }
// }
// Path: src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
import static org.junit.Assert.assertTrue;
import java.util.ServiceLoader;
import org.apache.commons.dbutils.handlers.columns.TestColumnHandler;
import org.apache.commons.dbutils.handlers.properties.TestPropertyHandler;
import org.junit.Before;
import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
public class ServiceLoaderTest {
private ServiceLoader<ColumnHandler> columns;
private ServiceLoader<PropertyHandler> properties;
@Before
public void setUp() {
columns = ServiceLoader.load(ColumnHandler.class);
properties = ServiceLoader.load(PropertyHandler.class);
}
@Test
public void testFindsLocalColumnHandler() {
boolean found = false;
for (final ColumnHandler handler : columns) {
// this class is defined outside of the main classes in dbutils
if (handler instanceof TestColumnHandler) {
found = true;
}
}
assertTrue(found);
}
@Test
public void testFindsLocalPropertyHandler() {
boolean found = false;
for (final PropertyHandler handler : properties) {
// this class is defined outside of the main classes in dbutils | if (handler instanceof TestPropertyHandler) { |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java | // Path: src/main/java/org/apache/commons/dbutils/ProxyFactory.java
// public class ProxyFactory {
//
// /**
// * The Singleton instance of this class.
// */
// private static final ProxyFactory instance = new ProxyFactory();
//
// /**
// * Returns the Singleton instance of this class.
// *
// * @return singleton instance
// */
// public static ProxyFactory instance() {
// return instance;
// }
//
// /**
// * Protected constructor for ProxyFactory subclasses to use.
// */
// protected ProxyFactory() {
// }
//
// /**
// * Convenience method to generate a single-interface proxy using the handler's classloader
// *
// * @param <T> The type of object to proxy
// * @param type The type of object to proxy
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied object
// */
// public <T> T newProxyInstance(final Class<T> type, final InvocationHandler handler) {
// return type.cast(Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class<?>[] {type}, handler));
// }
//
// /**
// * Creates a new proxy {@code CallableStatement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied CallableStatement
// */
// public CallableStatement createCallableStatement(final InvocationHandler handler) {
// return newProxyInstance(CallableStatement.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Connection} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Connection
// */
// public Connection createConnection(final InvocationHandler handler) {
// return newProxyInstance(Connection.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Driver} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Driver
// */
// public Driver createDriver(final InvocationHandler handler) {
// return newProxyInstance(Driver.class, handler);
// }
//
// /**
// * Creates a new proxy {@code PreparedStatement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied PreparedStatement
// */
// public PreparedStatement createPreparedStatement(final InvocationHandler handler) {
// return newProxyInstance(PreparedStatement.class, handler);
// }
//
// /**
// * Creates a new proxy {@code ResultSet} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied ResultSet
// */
// public ResultSet createResultSet(final InvocationHandler handler) {
// return newProxyInstance(ResultSet.class, handler);
// }
//
// /**
// * Creates a new proxy {@code ResultSetMetaData} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied ResultSetMetaData
// */
// public ResultSetMetaData createResultSetMetaData(final InvocationHandler handler) {
// return newProxyInstance(ResultSetMetaData.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Statement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Statement
// */
// public Statement createStatement(final InvocationHandler handler) {
// return newProxyInstance(Statement.class, handler);
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ProxyFactory;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.wrappers;
/**
* Test cases for {@code SqlNullCheckedResultSet} class.
*/
public class SqlNullCheckedResultSetTest extends BaseTestCase {
private SqlNullCheckedResultSet rs2 = null;
/**
* Sets up instance variables required by this test case.
*/
@Override
public void setUp() throws Exception {
super.setUp();
rs2 =
new SqlNullCheckedResultSet( | // Path: src/main/java/org/apache/commons/dbutils/ProxyFactory.java
// public class ProxyFactory {
//
// /**
// * The Singleton instance of this class.
// */
// private static final ProxyFactory instance = new ProxyFactory();
//
// /**
// * Returns the Singleton instance of this class.
// *
// * @return singleton instance
// */
// public static ProxyFactory instance() {
// return instance;
// }
//
// /**
// * Protected constructor for ProxyFactory subclasses to use.
// */
// protected ProxyFactory() {
// }
//
// /**
// * Convenience method to generate a single-interface proxy using the handler's classloader
// *
// * @param <T> The type of object to proxy
// * @param type The type of object to proxy
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied object
// */
// public <T> T newProxyInstance(final Class<T> type, final InvocationHandler handler) {
// return type.cast(Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class<?>[] {type}, handler));
// }
//
// /**
// * Creates a new proxy {@code CallableStatement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied CallableStatement
// */
// public CallableStatement createCallableStatement(final InvocationHandler handler) {
// return newProxyInstance(CallableStatement.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Connection} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Connection
// */
// public Connection createConnection(final InvocationHandler handler) {
// return newProxyInstance(Connection.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Driver} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Driver
// */
// public Driver createDriver(final InvocationHandler handler) {
// return newProxyInstance(Driver.class, handler);
// }
//
// /**
// * Creates a new proxy {@code PreparedStatement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied PreparedStatement
// */
// public PreparedStatement createPreparedStatement(final InvocationHandler handler) {
// return newProxyInstance(PreparedStatement.class, handler);
// }
//
// /**
// * Creates a new proxy {@code ResultSet} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied ResultSet
// */
// public ResultSet createResultSet(final InvocationHandler handler) {
// return newProxyInstance(ResultSet.class, handler);
// }
//
// /**
// * Creates a new proxy {@code ResultSetMetaData} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied ResultSetMetaData
// */
// public ResultSetMetaData createResultSetMetaData(final InvocationHandler handler) {
// return newProxyInstance(ResultSetMetaData.class, handler);
// }
//
// /**
// * Creates a new proxy {@code Statement} object.
// * @param handler The handler that intercepts/overrides method calls.
// * @return proxied Statement
// */
// public Statement createStatement(final InvocationHandler handler) {
// return newProxyInstance(Statement.class, handler);
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ProxyFactory;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.wrappers;
/**
* Test cases for {@code SqlNullCheckedResultSet} class.
*/
public class SqlNullCheckedResultSetTest extends BaseTestCase {
private SqlNullCheckedResultSet rs2 = null;
/**
* Sets up instance variables required by this test case.
*/
@Override
public void setUp() throws Exception {
super.setUp();
rs2 =
new SqlNullCheckedResultSet( | ProxyFactory.instance().createResultSet( |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class ScalarHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
import java.sql.SQLException;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class ScalarHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<String> h = new ScalarHandler<>(); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
import static org.mockito.Mockito.mock; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class KeyedHandlerTest extends BaseTestCase {
public void testInjectedRowProcess() throws Exception { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
import java.sql.SQLException;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
import static org.mockito.Mockito.mock;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class KeyedHandlerTest extends BaseTestCase {
public void testInjectedRowProcess() throws Exception { | final RowProcessor mockProc = mock(RowProcessor.class); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
import static org.mockito.Mockito.mock; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class KeyedHandlerTest extends BaseTestCase {
public void testInjectedRowProcess() throws Exception {
final RowProcessor mockProc = mock(RowProcessor.class); | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
import java.sql.SQLException;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
import static org.mockito.Mockito.mock;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
public class KeyedHandlerTest extends BaseTestCase {
public void testInjectedRowProcess() throws Exception {
final RowProcessor mockProc = mock(RowProcessor.class); | final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>(mockProc); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java | // Path: src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
// public class ArrayHandler implements ResultSetHandler<Object[]> {
//
// /**
// * Singleton processor instance that handlers share to save memory. Notice
// * the default scoping to allow only classes in this package to use this
// * instance.
// */
// static final RowProcessor ROW_PROCESSOR = new BasicRowProcessor();
//
// /**
// * An empty array to return when no more rows are available in the ResultSet.
// */
// private static final Object[] EMPTY_ARRAY = new Object[0];
//
// /**
// * The RowProcessor implementation to use when converting rows
// * into arrays.
// */
// private final RowProcessor convert;
//
// /**
// * Creates a new instance of ArrayHandler using a
// * {@code BasicRowProcessor} for conversion.
// */
// public ArrayHandler() {
// this(ROW_PROCESSOR);
// }
//
// /**
// * Creates a new instance of ArrayHandler.
// *
// * @param convert The {@code RowProcessor} implementation
// * to use when converting rows into arrays.
// */
// public ArrayHandler(final RowProcessor convert) {
// this.convert = convert;
// }
//
// /**
// * Places the column values from the first row in an {@code Object[]}.
// * @param rs {@code ResultSet} to process.
// * @return An Object[]. If there are no rows in the {@code ResultSet}
// * an empty array will be returned.
// *
// * @throws SQLException if a database access error occurs
// * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
// */
// @Override
// public Object[] handle(final ResultSet rs) throws SQLException {
// return rs.next() ? this.convert.toArray(rs) : EMPTY_ARRAY;
// }
//
// }
| import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.sql.Connection;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.sql.DataSource;
import org.apache.commons.dbutils.handlers.ArrayHandler;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
@SuppressWarnings("boxing") // test code
public class AsyncQueryRunnerTest {
AsyncQueryRunner runner; | // Path: src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
// public class ArrayHandler implements ResultSetHandler<Object[]> {
//
// /**
// * Singleton processor instance that handlers share to save memory. Notice
// * the default scoping to allow only classes in this package to use this
// * instance.
// */
// static final RowProcessor ROW_PROCESSOR = new BasicRowProcessor();
//
// /**
// * An empty array to return when no more rows are available in the ResultSet.
// */
// private static final Object[] EMPTY_ARRAY = new Object[0];
//
// /**
// * The RowProcessor implementation to use when converting rows
// * into arrays.
// */
// private final RowProcessor convert;
//
// /**
// * Creates a new instance of ArrayHandler using a
// * {@code BasicRowProcessor} for conversion.
// */
// public ArrayHandler() {
// this(ROW_PROCESSOR);
// }
//
// /**
// * Creates a new instance of ArrayHandler.
// *
// * @param convert The {@code RowProcessor} implementation
// * to use when converting rows into arrays.
// */
// public ArrayHandler(final RowProcessor convert) {
// this.convert = convert;
// }
//
// /**
// * Places the column values from the first row in an {@code Object[]}.
// * @param rs {@code ResultSet} to process.
// * @return An Object[]. If there are no rows in the {@code ResultSet}
// * an empty array will be returned.
// *
// * @throws SQLException if a database access error occurs
// * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
// */
// @Override
// public Object[] handle(final ResultSet rs) throws SQLException {
// return rs.next() ? this.convert.toArray(rs) : EMPTY_ARRAY;
// }
//
// }
// Path: src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.sql.Connection;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.sql.DataSource;
import org.apache.commons.dbutils.handlers.ArrayHandler;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils;
@SuppressWarnings("boxing") // test code
public class AsyncQueryRunnerTest {
AsyncQueryRunner runner; | ArrayHandler handler; |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* MapHandlerTest
*/
public class MapHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
import java.sql.SQLException;
import java.util.Map;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* MapHandlerTest
*/
public class MapHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<Map<String,Object>> h = new MapHandler(); |
apache/commons-dbutils | src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
| import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ArrayListHandlerTest
*/
public class ArrayListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
// Path: src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.dbutils.BaseTestCase;
import org.apache.commons.dbutils.ResultSetHandler;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* ArrayListHandlerTest
*/
public class ArrayListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException { | final ResultSetHandler<List<Object[]>> h = new ArrayListHandler(); |
apache/commons-dbutils | src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
| import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor; | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* {@code ResultSetHandler} implementation that converts the first
* {@code ResultSet} row into a JavaBean. This class is thread safe.
*
* @param <T> the target bean type
* @see org.apache.commons.dbutils.ResultSetHandler
*/
public class BeanHandler<T> implements ResultSetHandler<T> {
/**
* The Class of beans produced by this handler.
*/
private final Class<? extends T> type;
/**
* The RowProcessor implementation to use when converting rows
* into beans.
*/ | // Path: src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
// public interface ResultSetHandler<T> {
//
// /**
// * Turn the {@code ResultSet} into an Object.
// *
// * @param rs The {@code ResultSet} to handle. It has not been touched
// * before being passed to this method.
// *
// * @return An Object initialized with {@code ResultSet} data. It is
// * legal for implementations to return {@code null} if the
// * {@code ResultSet} contained 0 rows.
// *
// * @throws SQLException if a database access error occurs
// */
// T handle(ResultSet rs) throws SQLException;
//
// }
//
// Path: src/main/java/org/apache/commons/dbutils/RowProcessor.java
// public interface RowProcessor {
//
// /**
// * Create an {@code Object[]} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before passing it to this method.
// * Implementations of this method must not alter the row position of
// * the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the array data
// * @throws SQLException if a database access error occurs
// * @return the newly created array
// */
// Object[] toArray(ResultSet rs) throws SQLException;
//
// /**
// * Create a JavaBean from the column values in one {@code ResultSet}
// * row. The {@code ResultSet} should be positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return the newly created bean
// */
// <T> T toBean(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code List} of JavaBeans from the column values in all
// * {@code ResultSet} rows. {@code ResultSet.next()} should
// * <strong>not</strong> be called before passing it to this method.
// * @param <T> The type of bean to create
// * @param rs ResultSet that supplies the bean data
// * @param type Class from which to create the bean instance
// * @throws SQLException if a database access error occurs
// * @return A {@code List} of beans with the given type in the order
// * they were returned by the {@code ResultSet}.
// */
// <T> List<T> toBeanList(ResultSet rs, Class<? extends T> type) throws SQLException;
//
// /**
// * Create a {@code Map} from the column values in one
// * {@code ResultSet} row. The {@code ResultSet} should be
// * positioned on a valid row before
// * passing it to this method. Implementations of this method must not
// * alter the row position of the {@code ResultSet}.
// *
// * @param rs ResultSet that supplies the map data
// * @throws SQLException if a database access error occurs
// * @return the newly created Map
// */
// Map<String, Object> toMap(ResultSet rs) throws SQLException;
//
// }
// Path: src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.RowProcessor;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbutils.handlers;
/**
* {@code ResultSetHandler} implementation that converts the first
* {@code ResultSet} row into a JavaBean. This class is thread safe.
*
* @param <T> the target bean type
* @see org.apache.commons.dbutils.ResultSetHandler
*/
public class BeanHandler<T> implements ResultSetHandler<T> {
/**
* The Class of beans produced by this handler.
*/
private final Class<? extends T> type;
/**
* The RowProcessor implementation to use when converting rows
* into beans.
*/ | private final RowProcessor convert; |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/publish/APICaller.java | // Path: src/main/java/ch/cyclops/publish/ParseQueryResult.java
// public class ParseQueryResult {
//
//
// public static List map(List<Map> list, Class clazz) {
// List<Object> mapped = new ArrayList<>();
//
// // iterate and map those objects
// if (list != null) {
// for (Map map : list) {
// try {
// Object bean = clazz.newInstance();
//
// // map HashMap to POJO
// BeanUtils.populate(bean, map);
//
// // add it to list of mapped CDRs
// mapped.add(bean);
//
// } catch (Exception ignored) {
// return null;
// }
// }
// }
//
// return mapped;
// }
// }
| import ch.cyclops.publish.ParseQueryResult;
import com.google.gson.Gson;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import java.net.URL;
import java.util.List;
import java.util.Map; | package ch.cyclops.publish;
/*
* Copyright (c) 2016. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* Author: Skoviera
* Created: 29/07/16
* Description: Call API endpoint
*/
public class APICaller {
public class Response {
private String object;
public Response(String obj) {
object = obj;
}
public String getAsString() throws Exception {
return object;
}
public List getAsList() throws Exception {
return new Gson().fromJson(object, List.class);
}
public Map getAsMap() throws Exception {
return new Gson().fromJson(object, Map.class);
}
public Object getAsClass(Class clazz) throws Exception {
return new Gson().fromJson(object, clazz);
}
public List getAsListOfType(Class clazz) throws Exception {
List<Map> list = new Gson().fromJson(object, List.class); | // Path: src/main/java/ch/cyclops/publish/ParseQueryResult.java
// public class ParseQueryResult {
//
//
// public static List map(List<Map> list, Class clazz) {
// List<Object> mapped = new ArrayList<>();
//
// // iterate and map those objects
// if (list != null) {
// for (Map map : list) {
// try {
// Object bean = clazz.newInstance();
//
// // map HashMap to POJO
// BeanUtils.populate(bean, map);
//
// // add it to list of mapped CDRs
// mapped.add(bean);
//
// } catch (Exception ignored) {
// return null;
// }
// }
// }
//
// return mapped;
// }
// }
// Path: src/main/java/ch/cyclops/publish/APICaller.java
import ch.cyclops.publish.ParseQueryResult;
import com.google.gson.Gson;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import java.net.URL;
import java.util.List;
import java.util.Map;
package ch.cyclops.publish;
/*
* Copyright (c) 2016. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* Author: Skoviera
* Created: 29/07/16
* Description: Call API endpoint
*/
public class APICaller {
public class Response {
private String object;
public Response(String obj) {
object = obj;
}
public String getAsString() throws Exception {
return object;
}
public List getAsList() throws Exception {
return new Gson().fromJson(object, List.class);
}
public Map getAsMap() throws Exception {
return new Gson().fromJson(object, Map.class);
}
public Object getAsClass(Class clazz) throws Exception {
return new Gson().fromJson(object, clazz);
}
public List getAsListOfType(Class clazz) throws Exception {
List<Map> list = new Gson().fromJson(object, List.class); | return ParseQueryResult.map(list, clazz); |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/model/Data/CdrMeasurement.java | // Path: src/main/java/ch/cyclops/model/Cyclops/CDR.java
// public class CDR {
// private List<GenericChargeData> data;
// private String _class;
// private String account;
// private Long time;
// private Long from;
// private Long to;
// private Double charge;
// private Boolean stateful;
//
// public Long getFrom() {
// return from;
// }
//
// public void setFrom(Long from) {
// this.from = from;
// }
//
// public Long getTo() {
// return to;
// }
//
// public void setTo(Long to) {
// this.to = to;
// }
//
// public Double getCharge() {
// return charge;
// }
//
// public void setCharge(Double charge) {
// this.charge = charge;
// }
//
// public Boolean getStateful() {
// return stateful;
// }
//
// public void setStateful(Boolean stateful) {
// this.stateful = stateful;
// }
//
// public String get_class() {
// return _class;
// }
//
// public void set_class(String _class) {
// this._class = _class;
// }
//
// public String getAccount() {
// return account;
// }
//
// public void setAccount(String account) {
// this.account = account;
// }
//
// public Long getTime() {
// return time;
// }
//
// public void setTime(Long time) {
// this.time = time;
// }
//
// public List<GenericChargeData> getData() {
// return data;
// }
//
// public void setData(List<GenericChargeData> data) {
// this.data = data;
// }
// }
| import ch.cyclops.model.Cyclops.CDR;
import java.util.List; | package ch.cyclops.model.Data;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 05/08/16.
*/
public class CdrMeasurement implements IMeasurement {
private String measurement; | // Path: src/main/java/ch/cyclops/model/Cyclops/CDR.java
// public class CDR {
// private List<GenericChargeData> data;
// private String _class;
// private String account;
// private Long time;
// private Long from;
// private Long to;
// private Double charge;
// private Boolean stateful;
//
// public Long getFrom() {
// return from;
// }
//
// public void setFrom(Long from) {
// this.from = from;
// }
//
// public Long getTo() {
// return to;
// }
//
// public void setTo(Long to) {
// this.to = to;
// }
//
// public Double getCharge() {
// return charge;
// }
//
// public void setCharge(Double charge) {
// this.charge = charge;
// }
//
// public Boolean getStateful() {
// return stateful;
// }
//
// public void setStateful(Boolean stateful) {
// this.stateful = stateful;
// }
//
// public String get_class() {
// return _class;
// }
//
// public void set_class(String _class) {
// this._class = _class;
// }
//
// public String getAccount() {
// return account;
// }
//
// public void setAccount(String account) {
// this.account = account;
// }
//
// public Long getTime() {
// return time;
// }
//
// public void setTime(Long time) {
// this.time = time;
// }
//
// public List<GenericChargeData> getData() {
// return data;
// }
//
// public void setData(List<GenericChargeData> data) {
// this.data = data;
// }
// }
// Path: src/main/java/ch/cyclops/model/Data/CdrMeasurement.java
import ch.cyclops.model.Cyclops.CDR;
import java.util.List;
package ch.cyclops.model.Data;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 05/08/16.
*/
public class CdrMeasurement implements IMeasurement {
private String measurement; | private List<CDR> data; |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/Application.java | // Path: src/main/java/ch/cyclops/load/Loader.java
// public class Loader {
// // final static Logger logger = LogManager.getLogger(Loader.class.getName());
//
// // singleton pattern
// private static Loader singleton;
//
// // loaded settings and environment
// private Settings settings;
//
// /**
// * Constructor has to be private, as we are using singleton
// */
// private Loader(String path) throws Exception {
// // only if object is created by createInstance (which gives it context)
// if (!path.isEmpty()) {
// // start with loading config file
// Properties properties = loadAndParseConfigurationFile(path);
//
// if (properties == null) {
// throw new Exception();
// }
//
// settings = new Settings(properties);
// }
// }
//
// /**
// * When creating instance, we need it to have context
// * @param path for the configuration file
// */
// public static void createInstance(String path) throws Exception {
// if (singleton == null) {
// singleton = new Loader(path);
// }
// }
//
// /**
// * Access settings from Loader class
// * @return settings object or null
// */
// public static Settings getSettings() {
// if (singleton.settings != null) {
// return singleton.settings;
// } else {
// return null;
// }
// }
//
// /**
// * Load and parse configuration file
// * @return null or property object
// */
// private Properties loadAndParseConfigurationFile(String path) {
// // store everything into property variable
// Properties prop = new Properties();
//
// try {
// // load file
// InputStream input = new FileInputStream(path);
//
// // now feed input file to property loader
// prop.load(input);
//
// return prop;
//
// } catch (FileNotFoundException e) {
// // logger.error("Configuration file doesn't exist or cannot be loaded: " + e.getMessage());
// return null;
// } catch (IOException e) {
// // logger.error("Couldn't load configuration file: " + e.getMessage());
// return null;
// }
// }
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import ch.cyclops.load.Loader; | String log = "A configuration file path has to be provided (as argument), otherwise UDR micro service cannot be properly loaded";
// logger.error(log);
System.err.println(log);
System.exit(ERR_PARAMS);
}
outputProgressBar();
}
/**
* Check whether parameter was help
* @param param to be examined
*/
private static void checkHelp(String param) {
if (param.equals("-h") || param.equals("--help")) {
System.out.println(helpMessage);
System.exit(OK_HELP);
System.exit(0);
}
// outputProgressBar();
}
/**
* Make sure configuration file is valid
* @param param path
*/
private static void checkConfigurationFile(String param) {
try {
// create and parse configuration settings | // Path: src/main/java/ch/cyclops/load/Loader.java
// public class Loader {
// // final static Logger logger = LogManager.getLogger(Loader.class.getName());
//
// // singleton pattern
// private static Loader singleton;
//
// // loaded settings and environment
// private Settings settings;
//
// /**
// * Constructor has to be private, as we are using singleton
// */
// private Loader(String path) throws Exception {
// // only if object is created by createInstance (which gives it context)
// if (!path.isEmpty()) {
// // start with loading config file
// Properties properties = loadAndParseConfigurationFile(path);
//
// if (properties == null) {
// throw new Exception();
// }
//
// settings = new Settings(properties);
// }
// }
//
// /**
// * When creating instance, we need it to have context
// * @param path for the configuration file
// */
// public static void createInstance(String path) throws Exception {
// if (singleton == null) {
// singleton = new Loader(path);
// }
// }
//
// /**
// * Access settings from Loader class
// * @return settings object or null
// */
// public static Settings getSettings() {
// if (singleton.settings != null) {
// return singleton.settings;
// } else {
// return null;
// }
// }
//
// /**
// * Load and parse configuration file
// * @return null or property object
// */
// private Properties loadAndParseConfigurationFile(String path) {
// // store everything into property variable
// Properties prop = new Properties();
//
// try {
// // load file
// InputStream input = new FileInputStream(path);
//
// // now feed input file to property loader
// prop.load(input);
//
// return prop;
//
// } catch (FileNotFoundException e) {
// // logger.error("Configuration file doesn't exist or cannot be loaded: " + e.getMessage());
// return null;
// } catch (IOException e) {
// // logger.error("Couldn't load configuration file: " + e.getMessage());
// return null;
// }
// }
// }
// Path: src/main/java/ch/cyclops/Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import ch.cyclops.load.Loader;
String log = "A configuration file path has to be provided (as argument), otherwise UDR micro service cannot be properly loaded";
// logger.error(log);
System.err.println(log);
System.exit(ERR_PARAMS);
}
outputProgressBar();
}
/**
* Check whether parameter was help
* @param param to be examined
*/
private static void checkHelp(String param) {
if (param.equals("-h") || param.equals("--help")) {
System.out.println(helpMessage);
System.exit(OK_HELP);
System.exit(0);
}
// outputProgressBar();
}
/**
* Make sure configuration file is valid
* @param param path
*/
private static void checkConfigurationFile(String param) {
try {
// create and parse configuration settings | Loader.createInstance(param); |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/load/Settings.java | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
| import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties; | /*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
// Path: src/main/java/ch/cyclops/load/Settings.java
import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties;
/*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file | protected OpenStackCredentials openStackCredentials; |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/load/Settings.java | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
| import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties; | /*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file
protected OpenStackCredentials openStackCredentials; | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
// Path: src/main/java/ch/cyclops/load/Settings.java
import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties;
/*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file
protected OpenStackCredentials openStackCredentials; | protected CyclopsSettings cyclopsSettings; |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/load/Settings.java | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
| import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties; | /*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file
protected OpenStackCredentials openStackCredentials;
protected CyclopsSettings cyclopsSettings; | // Path: src/main/java/ch/cyclops/load/model/CyclopsSettings.java
// public class CyclopsSettings {
// private String udrDataUrl;
// private String billingUrl;
// private String cdrDataUrl;
// private String billType;
//
// public String getBillType() {
// return billType;
// }
//
// public void setBillType(String billType) {
// this.billType = billType;
// }
//
// public String getCdrDataUrl() {
// return cdrDataUrl;
// }
//
// public void setCdrDataUrl(String cdrDataUrl) {
// this.cdrDataUrl = cdrDataUrl;
// }
//
// public String getUdrDataUrl() {
// return udrDataUrl;
// }
//
// public void setUdrDataUrl(String udrDataUrl) {
// this.udrDataUrl = udrDataUrl;
// }
//
// public String getBillingUrl() {
// return billingUrl;
// }
//
// public void setBillingUrl(String billingUrl) {
// this.billingUrl = billingUrl;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/OpenStackCredentials.java
// public class OpenStackCredentials {
// private String keystoneUrl;
// private String keystoneAdminUrl;
// private String keystoneAccount;
// private String keystonePassword;
// private String keystoneTenant;
// private String keystoneAdminRole;
//
// public String getKeystoneAdminRole() {
// return keystoneAdminRole;
// }
//
// public void setKeystoneAdminRole(String keystoneAdminRole) {
// this.keystoneAdminRole = keystoneAdminRole;
// }
//
// public String getKeystoneAdminUrl() {
// return keystoneAdminUrl;
// }
//
// public void setKeystoneAdminUrl(String keystoneAdminUrl) {
// this.keystoneAdminUrl = keystoneAdminUrl;
// }
//
// public String getKeystoneUrl() {
// return keystoneUrl;
// }
//
// public void setKeystoneUrl(String keystoneUrl) {
// this.keystoneUrl = keystoneUrl;
// }
//
// public String getKeystoneAccount() {
// return keystoneAccount;
// }
//
// public void setKeystoneAccount(String keystoneAccount) {
// this.keystoneAccount = keystoneAccount;
// }
//
// public String getKeystonePassword() {
// return keystonePassword;
// }
//
// public void setKeystonePassword(String keystonePassword) {
// this.keystonePassword = keystonePassword;
// }
//
// public String getKeystoneTenant() {
// return keystoneTenant;
// }
//
// public void setKeystoneTenant(String keystoneTenant) {
// this.keystoneTenant = keystoneTenant;
// }
// }
//
// Path: src/main/java/ch/cyclops/load/model/RepresentationSettings.java
// public class RepresentationSettings {
// private int timeSlices;
//
// public int getTimeSlices() {
// return timeSlices;
// }
//
// public void setTimeSlices(int timeSlices) {
// this.timeSlices = timeSlices;
// }
// }
// Path: src/main/java/ch/cyclops/load/Settings.java
import ch.cyclops.load.model.CyclopsSettings;
import ch.cyclops.load.model.OpenStackCredentials;
import ch.cyclops.load.model.RepresentationSettings;
import java.util.Properties;
/*
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package ch.cyclops.load;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 28/07/16.
*/
public class Settings {
// Object for reading and accessing configuration properties
private Properties properties;
// List of different settings that are being loaded from configuration file
protected OpenStackCredentials openStackCredentials;
protected CyclopsSettings cyclopsSettings; | protected RepresentationSettings representationSettings; |
icclab/cyclops-dashboard | src/main/java/ch/cyclops/model/Data/UdrMeasurement.java | // Path: src/main/java/ch/cyclops/model/Cyclops/UDR.java
// public class UDR {
// private List<GenericUsageData> data;
// private String _class;
// private String account;
// private Long time;
//
// public String get_class() {
// return _class;
// }
//
// public void set_class(String _class) {
// this._class = _class;
// }
//
// public String getAccount() {
// return account;
// }
//
// public void setAccount(String account) {
// this.account = account;
// }
//
// public Long getTime() {
// return time;
// }
//
// public void setTime(Long time) {
// this.time = time;
// }
//
// public List<GenericUsageData> getData() {
// return data;
// }
//
// public void setData(List<GenericUsageData> data) {
// this.data = data;
// }
// }
| import ch.cyclops.model.Cyclops.UDR;
import java.util.List; | package ch.cyclops.model.Data;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 05/08/16.
*/
public class UdrMeasurement implements IMeasurement{
private String measurement; | // Path: src/main/java/ch/cyclops/model/Cyclops/UDR.java
// public class UDR {
// private List<GenericUsageData> data;
// private String _class;
// private String account;
// private Long time;
//
// public String get_class() {
// return _class;
// }
//
// public void set_class(String _class) {
// this._class = _class;
// }
//
// public String getAccount() {
// return account;
// }
//
// public void setAccount(String account) {
// this.account = account;
// }
//
// public Long getTime() {
// return time;
// }
//
// public void setTime(Long time) {
// this.time = time;
// }
//
// public List<GenericUsageData> getData() {
// return data;
// }
//
// public void setData(List<GenericUsageData> data) {
// this.data = data;
// }
// }
// Path: src/main/java/ch/cyclops/model/Data/UdrMeasurement.java
import ch.cyclops.model.Cyclops.UDR;
import java.util.List;
package ch.cyclops.model.Data;
/**
* Copyright (c) 2015. Zuercher Hochschule fuer Angewandte Wissenschaften
* All Rights Reserved.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created by Manu Perez on 05/08/16.
*/
public class UdrMeasurement implements IMeasurement{
private String measurement; | private List<UDR> data; |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
| import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(), | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java
import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(), | new SchemaProviderModule(), // Part of Rejoiner framework (Provides `@Schema |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
| import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(),
new SchemaProviderModule(), // Part of Rejoiner framework (Provides `@Schema
// GraphQLSchema`) | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java
import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(),
new SchemaProviderModule(), // Part of Rejoiner framework (Provides `@Schema
// GraphQLSchema`) | new ClientModule(), // Installs all of the client modules |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
| import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(),
new SchemaProviderModule(), // Part of Rejoiner framework (Provides `@Schema
// GraphQLSchema`)
new ClientModule(), // Installs all of the client modules | // Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/client/ClientModule.java
// public final class ClientModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookClientModule());
// install(new ShelfClientModule());
// }
// }
//
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/schema/SchemaModule.java
// public final class SchemaModule extends AbstractModule {
// @Override
// protected void configure() {
// install(new BookSchemaModule()); // Creates queries and mutations for the Book service
// install(new ShelfSchemaModule()); // Creates queries and mutations for the Shelf service
// install(new LibrarySchemaModule()); // Joins together Shelf and Book services
// install(new SeedLibrarySchemaModule()); // Fills the Shelf and Book services with data
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServer.java
import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import com.google.api.graphql.examples.library.graphqlserver.client.ClientModule;
import com.google.api.graphql.examples.library.graphqlserver.schema.SchemaModule;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import java.io.File;
import java.util.EnumSet;
import java.util.logging.Logger;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
public class GraphQlServer {
private static final int HTTP_PORT = 8080;
private static final Logger logger = Logger.getLogger(GraphQlServer.class.getName());
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS);
context.addEventListener(
new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
return Guice.createInjector(
new ServletModule() {
@Override
protected void configureServlets() {
serve("/graphql").with(GraphQlServlet.class);
}
},
new DataLoaderModule(),
new SchemaProviderModule(), // Part of Rejoiner framework (Provides `@Schema
// GraphQLSchema`)
new ClientModule(), // Installs all of the client modules | new SchemaModule() // Installs all of the schema modules |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServlet.java | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
| import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import org.dataloader.DataLoaderRegistry;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Logger; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
@Singleton
final class GraphQlServlet extends HttpServlet {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final Logger logger = Logger.getLogger(GraphQlServlet.class.getName());
@Inject @Schema GraphQLSchema schema;
@Inject Provider<DataLoaderRegistry> registryProvider;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
DataLoaderRegistry dataLoaderRegistry = registryProvider.get();
Instrumentation instrumentation =
new ChainedInstrumentation(
Arrays.asList( | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/library/graphqlserver/GraphQlServlet.java
import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import org.dataloader.DataLoaderRegistry;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Logger;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.library.graphqlserver;
@Singleton
final class GraphQlServlet extends HttpServlet {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final Logger logger = Logger.getLogger(GraphQlServlet.class.getName());
@Inject @Schema GraphQLSchema schema;
@Inject Provider<DataLoaderRegistry> registryProvider;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
DataLoaderRegistry dataLoaderRegistry = registryProvider.get();
Instrumentation instrumentation =
new ChainedInstrumentation(
Arrays.asList( | GuavaListenableFutureSupport.listenableFutureInstrumentation(), |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/helloworld/graphqlserver/GraphQlHandler.java | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
| import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Guice;
import com.google.inject.Key;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.helloworld.graphqlserver;
public class GraphQlHandler extends AbstractHandler {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final GraphQLSchema SCHEMA =
Guice.createInjector( | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/helloworld/graphqlserver/GraphQlHandler.java
import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Guice;
import com.google.inject.Key;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.helloworld.graphqlserver;
public class GraphQlHandler extends AbstractHandler {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final GraphQLSchema SCHEMA =
Guice.createInjector( | new SchemaProviderModule(), |
google/rejoiner | examples-gradle/src/main/java/com/google/api/graphql/examples/helloworld/graphqlserver/GraphQlHandler.java | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
| import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Guice;
import com.google.inject.Key;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler; | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.helloworld.graphqlserver;
public class GraphQlHandler extends AbstractHandler {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final GraphQLSchema SCHEMA =
Guice.createInjector(
new SchemaProviderModule(),
new HelloWorldClientModule(),
new HelloWorldSchemaModule())
.getInstance(Key.get(GraphQLSchema.class, Schema.class));
private static final Instrumentation INSTRUMENTATION =
new ChainedInstrumentation(
Arrays.asList( | // Path: rejoiner/src/main/java/com/google/api/graphql/execution/GuavaListenableFutureSupport.java
// public final class GuavaListenableFutureSupport {
// private GuavaListenableFutureSupport() {}
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation() {
// return listenableFutureInstrumentation(MoreExecutors.directExecutor());
// }
//
// /**
// * Converts a {@link ListenableFuture} to a Java8 {@link java.util.concurrent.CompletableFuture}.
// *
// * <p>{@see CompletableFuture} is supported by the provided {@link
// * graphql.execution.AsyncExecutionStrategy}.
// *
// * <p>Note: This should be installed before any other instrumentation.
// */
// public static Instrumentation listenableFutureInstrumentation(Executor executor) {
// return new SimpleInstrumentation() {
// @Override
// public DataFetcher<?> instrumentDataFetcher(
// DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
// return (DataFetcher<Object>)
// dataFetchingEnvironment -> {
// Object data = dataFetcher.get(dataFetchingEnvironment);
// if (data instanceof ListenableFuture) {
// ListenableFuture<Object> listenableFuture = (ListenableFuture<Object>) data;
// CompletableFuture<Object> completableFuture = new CompletableFuture<>();
// Futures.addCallback(
// listenableFuture,
// new FutureCallback<Object>() {
// @Override
// public void onSuccess(Object result) {
// completableFuture.complete(result);
// }
//
// @Override
// public void onFailure(Throwable t) {
// completableFuture.completeExceptionally(t);
// }
// },
// executor);
// return completableFuture;
// }
// return data;
// };
// }
// };
// }
// }
//
// Path: rejoiner-guice/src/main/java/com/google/api/graphql/rejoiner/SchemaProviderModule.java
// public final class SchemaProviderModule extends AbstractModule {
//
// static class SchemaImpl implements Provider<GraphQLSchema> {
//
// private final Provider<Set<SchemaBundle>> schemaBundleProviders;
//
// @Inject
// public SchemaImpl(@Annotations.SchemaBundles Provider<Set<SchemaBundle>> schemaBundles) {
// this.schemaBundleProviders = schemaBundles;
// }
//
// @Override
// public GraphQLSchema get() {
// SchemaBundle schemaBundle = SchemaBundle.combine(schemaBundleProviders.get());
// return schemaBundle.toSchema();
// }
// }
//
// @Override
// protected void configure() {
// bind(GraphQLSchema.class)
// .annotatedWith(Schema.class)
// .toProvider(SchemaImpl.class)
// .in(Singleton.class);
// }
// }
// Path: examples-gradle/src/main/java/com/google/api/graphql/examples/helloworld/graphqlserver/GraphQlHandler.java
import com.google.api.graphql.execution.GuavaListenableFutureSupport;
import com.google.api.graphql.rejoiner.Schema;
import com.google.api.graphql.rejoiner.SchemaProviderModule;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Guice;
import com.google.inject.Key;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import graphql.schema.GraphQLSchema;
import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.graphql.examples.helloworld.graphqlserver;
public class GraphQlHandler extends AbstractHandler {
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final TypeToken<Map<String, Object>> MAP_TYPE_TOKEN =
new TypeToken<Map<String, Object>>() {};
private static final GraphQLSchema SCHEMA =
Guice.createInjector(
new SchemaProviderModule(),
new HelloWorldClientModule(),
new HelloWorldSchemaModule())
.getInstance(Key.get(GraphQLSchema.class, Schema.class));
private static final Instrumentation INSTRUMENTATION =
new ChainedInstrumentation(
Arrays.asList( | GuavaListenableFutureSupport.listenableFutureInstrumentation(), |
Nike-Inc/wingtips | wingtips-spring-boot/src/test/java/com/nike/wingtips/springboot/WingtipsSpringBootPropertiesTest.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
// public enum SpanLoggingRepresentation {
// /**
// * Causes spans to be output in the logs using {@link Span#toJSON()}.
// */
// JSON,
// /**
// * Causes spans to be output in the logs using {@link Span#toKeyValueString()}.
// */
// KEY_VALUE
// }
| import com.nike.wingtips.Tracer.SpanLoggingRepresentation;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat; | "fAlSe | false",
" | false",
"junk | false",
"null | false",
}, splitBy = "\\|")
@Test
public void wingtipsDisabled_getter_and_setter_works_as_expected(
String propValueAsStringForSetter, boolean expectedGetterResult
) {
// when
props.setWingtipsDisabled(propValueAsStringForSetter);
// then
assertThat(props.isWingtipsDisabled()).isEqualTo(expectedGetterResult);
}
@Test
public void exercise_standard_getters_and_setters() {
// userIdHeaderKeys getter/setter
{
String nonNullKey = UUID.randomUUID().toString();
props.setUserIdHeaderKeys(nonNullKey);
assertThat(props.getUserIdHeaderKeys()).isEqualTo(nonNullKey);
props.setUserIdHeaderKeys(null);
assertThat(props.getUserIdHeaderKeys()).isNull();
}
// spanLoggingFormat getter/setter
{ | // Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
// public enum SpanLoggingRepresentation {
// /**
// * Causes spans to be output in the logs using {@link Span#toJSON()}.
// */
// JSON,
// /**
// * Causes spans to be output in the logs using {@link Span#toKeyValueString()}.
// */
// KEY_VALUE
// }
// Path: wingtips-spring-boot/src/test/java/com/nike/wingtips/springboot/WingtipsSpringBootPropertiesTest.java
import com.nike.wingtips.Tracer.SpanLoggingRepresentation;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
"fAlSe | false",
" | false",
"junk | false",
"null | false",
}, splitBy = "\\|")
@Test
public void wingtipsDisabled_getter_and_setter_works_as_expected(
String propValueAsStringForSetter, boolean expectedGetterResult
) {
// when
props.setWingtipsDisabled(propValueAsStringForSetter);
// then
assertThat(props.isWingtipsDisabled()).isEqualTo(expectedGetterResult);
}
@Test
public void exercise_standard_getters_and_setters() {
// userIdHeaderKeys getter/setter
{
String nonNullKey = UUID.randomUUID().toString();
props.setUserIdHeaderKeys(nonNullKey);
assertThat(props.getUserIdHeaderKeys()).isEqualTo(nonNullKey);
props.setUserIdHeaderKeys(null);
assertThat(props.getUserIdHeaderKeys()).isNull();
}
// spanLoggingFormat getter/setter
{ | for (SpanLoggingRepresentation format : SpanLoggingRepresentation.values()) { |
Nike-Inc/wingtips | wingtips-core/src/main/java/com/nike/wingtips/Tracer.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/lifecyclelistener/SpanLifecycleListener.java
// public interface SpanLifecycleListener {
//
// /**
// * This will be called when the given {@link Span} is created/started, and will be called whether or not the span is sampled.
// */
// void spanStarted(Span span);
//
// /**
// * This will be called when the given {@link Span} is determined to be sampleable - if this is called for a given span it will be called
// * immediately after {@link #spanStarted(Span)} is called.
// */
// void spanSampled(Span span);
//
// /**
// * This will be called when the given {@link Span} is completed, and will be called whether or not the span is sampled.
// */
// void spanCompleted(Span span);
//
// }
//
// Path: wingtips-core/src/main/java/com/nike/wingtips/sampling/SampleAllTheThingsStrategy.java
// public class SampleAllTheThingsStrategy implements RootSpanSamplingStrategy {
//
// @Override
// public boolean isNextRootSpanSampleable() {
// return true;
// }
// }
| import com.nike.wingtips.Span.SpanPurpose;
import com.nike.wingtips.http.HttpRequestTracingUtils;
import com.nike.wingtips.lifecyclelistener.SpanLifecycleListener;
import com.nike.wingtips.sampling.RootSpanSamplingStrategy;
import com.nike.wingtips.sampling.SampleAllTheThingsStrategy;
import com.nike.wingtips.util.TracerManagedSpanStatus;
import com.nike.wingtips.util.TracingState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import static com.nike.wingtips.http.HttpRequestTracingUtils.CHILD_OF_SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY; | return span.getParentSpanId();
case FULL_SPAN_JSON:
return span.toJSON();
default:
throw new IllegalStateException("Unhandled SpanFieldForLoggerMdc type: " + this);
}
}
}
private static final String VALID_WINGTIPS_SPAN_LOGGER_NAME = "VALID_WINGTIPS_SPANS";
private static final String INVALID_WINGTIPS_SPAN_LOGGER_NAME = "INVALID_WINGTIPS_SPANS";
private static final Logger classLogger = LoggerFactory.getLogger(Tracer.class);
private static final Logger validSpanLogger = LoggerFactory.getLogger(VALID_WINGTIPS_SPAN_LOGGER_NAME);
private static final Logger invalidSpanLogger = LoggerFactory.getLogger(INVALID_WINGTIPS_SPAN_LOGGER_NAME);
/**
* ThreadLocal that keeps track of the stack of {@link Span} objects associated with the thread. This is treated as a LIFO stack.
*/
private static final ThreadLocal<Deque<Span>> currentSpanStackThreadLocal = new ThreadLocal<>();
/**
* The singleton instance for this class.
*/
private static final Tracer INSTANCE = new Tracer();
/**
* The sampling strategy this instance will use. Default to sampling everything. Never allow this field to be set to null.
*/ | // Path: wingtips-core/src/main/java/com/nike/wingtips/lifecyclelistener/SpanLifecycleListener.java
// public interface SpanLifecycleListener {
//
// /**
// * This will be called when the given {@link Span} is created/started, and will be called whether or not the span is sampled.
// */
// void spanStarted(Span span);
//
// /**
// * This will be called when the given {@link Span} is determined to be sampleable - if this is called for a given span it will be called
// * immediately after {@link #spanStarted(Span)} is called.
// */
// void spanSampled(Span span);
//
// /**
// * This will be called when the given {@link Span} is completed, and will be called whether or not the span is sampled.
// */
// void spanCompleted(Span span);
//
// }
//
// Path: wingtips-core/src/main/java/com/nike/wingtips/sampling/SampleAllTheThingsStrategy.java
// public class SampleAllTheThingsStrategy implements RootSpanSamplingStrategy {
//
// @Override
// public boolean isNextRootSpanSampleable() {
// return true;
// }
// }
// Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
import com.nike.wingtips.Span.SpanPurpose;
import com.nike.wingtips.http.HttpRequestTracingUtils;
import com.nike.wingtips.lifecyclelistener.SpanLifecycleListener;
import com.nike.wingtips.sampling.RootSpanSamplingStrategy;
import com.nike.wingtips.sampling.SampleAllTheThingsStrategy;
import com.nike.wingtips.util.TracerManagedSpanStatus;
import com.nike.wingtips.util.TracingState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import static com.nike.wingtips.http.HttpRequestTracingUtils.CHILD_OF_SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY;
return span.getParentSpanId();
case FULL_SPAN_JSON:
return span.toJSON();
default:
throw new IllegalStateException("Unhandled SpanFieldForLoggerMdc type: " + this);
}
}
}
private static final String VALID_WINGTIPS_SPAN_LOGGER_NAME = "VALID_WINGTIPS_SPANS";
private static final String INVALID_WINGTIPS_SPAN_LOGGER_NAME = "INVALID_WINGTIPS_SPANS";
private static final Logger classLogger = LoggerFactory.getLogger(Tracer.class);
private static final Logger validSpanLogger = LoggerFactory.getLogger(VALID_WINGTIPS_SPAN_LOGGER_NAME);
private static final Logger invalidSpanLogger = LoggerFactory.getLogger(INVALID_WINGTIPS_SPAN_LOGGER_NAME);
/**
* ThreadLocal that keeps track of the stack of {@link Span} objects associated with the thread. This is treated as a LIFO stack.
*/
private static final ThreadLocal<Deque<Span>> currentSpanStackThreadLocal = new ThreadLocal<>();
/**
* The singleton instance for this class.
*/
private static final Tracer INSTANCE = new Tracer();
/**
* The sampling strategy this instance will use. Default to sampling everything. Never allow this field to be set to null.
*/ | private RootSpanSamplingStrategy rootSpanSamplingStrategy = new SampleAllTheThingsStrategy(); |
Nike-Inc/wingtips | wingtips-core/src/main/java/com/nike/wingtips/Tracer.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/lifecyclelistener/SpanLifecycleListener.java
// public interface SpanLifecycleListener {
//
// /**
// * This will be called when the given {@link Span} is created/started, and will be called whether or not the span is sampled.
// */
// void spanStarted(Span span);
//
// /**
// * This will be called when the given {@link Span} is determined to be sampleable - if this is called for a given span it will be called
// * immediately after {@link #spanStarted(Span)} is called.
// */
// void spanSampled(Span span);
//
// /**
// * This will be called when the given {@link Span} is completed, and will be called whether or not the span is sampled.
// */
// void spanCompleted(Span span);
//
// }
//
// Path: wingtips-core/src/main/java/com/nike/wingtips/sampling/SampleAllTheThingsStrategy.java
// public class SampleAllTheThingsStrategy implements RootSpanSamplingStrategy {
//
// @Override
// public boolean isNextRootSpanSampleable() {
// return true;
// }
// }
| import com.nike.wingtips.Span.SpanPurpose;
import com.nike.wingtips.http.HttpRequestTracingUtils;
import com.nike.wingtips.lifecyclelistener.SpanLifecycleListener;
import com.nike.wingtips.sampling.RootSpanSamplingStrategy;
import com.nike.wingtips.sampling.SampleAllTheThingsStrategy;
import com.nike.wingtips.util.TracerManagedSpanStatus;
import com.nike.wingtips.util.TracingState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import static com.nike.wingtips.http.HttpRequestTracingUtils.CHILD_OF_SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY; |
private static final String VALID_WINGTIPS_SPAN_LOGGER_NAME = "VALID_WINGTIPS_SPANS";
private static final String INVALID_WINGTIPS_SPAN_LOGGER_NAME = "INVALID_WINGTIPS_SPANS";
private static final Logger classLogger = LoggerFactory.getLogger(Tracer.class);
private static final Logger validSpanLogger = LoggerFactory.getLogger(VALID_WINGTIPS_SPAN_LOGGER_NAME);
private static final Logger invalidSpanLogger = LoggerFactory.getLogger(INVALID_WINGTIPS_SPAN_LOGGER_NAME);
/**
* ThreadLocal that keeps track of the stack of {@link Span} objects associated with the thread. This is treated as a LIFO stack.
*/
private static final ThreadLocal<Deque<Span>> currentSpanStackThreadLocal = new ThreadLocal<>();
/**
* The singleton instance for this class.
*/
private static final Tracer INSTANCE = new Tracer();
/**
* The sampling strategy this instance will use. Default to sampling everything. Never allow this field to be set to null.
*/
private RootSpanSamplingStrategy rootSpanSamplingStrategy = new SampleAllTheThingsStrategy();
/**
* The list of span lifecycle listeners that should be notified when span lifecycle events occur.
* Note that we use a {@link CopyOnWriteArrayList} to prevent {@link java.util.ConcurrentModificationException}s
* from occurring if spans are being started/completed/etc while this list is being changed. This is deemed
* acceptable since iterations over this list happens frequently, but changes to the list should be rare.
*/ | // Path: wingtips-core/src/main/java/com/nike/wingtips/lifecyclelistener/SpanLifecycleListener.java
// public interface SpanLifecycleListener {
//
// /**
// * This will be called when the given {@link Span} is created/started, and will be called whether or not the span is sampled.
// */
// void spanStarted(Span span);
//
// /**
// * This will be called when the given {@link Span} is determined to be sampleable - if this is called for a given span it will be called
// * immediately after {@link #spanStarted(Span)} is called.
// */
// void spanSampled(Span span);
//
// /**
// * This will be called when the given {@link Span} is completed, and will be called whether or not the span is sampled.
// */
// void spanCompleted(Span span);
//
// }
//
// Path: wingtips-core/src/main/java/com/nike/wingtips/sampling/SampleAllTheThingsStrategy.java
// public class SampleAllTheThingsStrategy implements RootSpanSamplingStrategy {
//
// @Override
// public boolean isNextRootSpanSampleable() {
// return true;
// }
// }
// Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
import com.nike.wingtips.Span.SpanPurpose;
import com.nike.wingtips.http.HttpRequestTracingUtils;
import com.nike.wingtips.lifecyclelistener.SpanLifecycleListener;
import com.nike.wingtips.sampling.RootSpanSamplingStrategy;
import com.nike.wingtips.sampling.SampleAllTheThingsStrategy;
import com.nike.wingtips.util.TracerManagedSpanStatus;
import com.nike.wingtips.util.TracingState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import static com.nike.wingtips.http.HttpRequestTracingUtils.CHILD_OF_SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY;
private static final String VALID_WINGTIPS_SPAN_LOGGER_NAME = "VALID_WINGTIPS_SPANS";
private static final String INVALID_WINGTIPS_SPAN_LOGGER_NAME = "INVALID_WINGTIPS_SPANS";
private static final Logger classLogger = LoggerFactory.getLogger(Tracer.class);
private static final Logger validSpanLogger = LoggerFactory.getLogger(VALID_WINGTIPS_SPAN_LOGGER_NAME);
private static final Logger invalidSpanLogger = LoggerFactory.getLogger(INVALID_WINGTIPS_SPAN_LOGGER_NAME);
/**
* ThreadLocal that keeps track of the stack of {@link Span} objects associated with the thread. This is treated as a LIFO stack.
*/
private static final ThreadLocal<Deque<Span>> currentSpanStackThreadLocal = new ThreadLocal<>();
/**
* The singleton instance for this class.
*/
private static final Tracer INSTANCE = new Tracer();
/**
* The sampling strategy this instance will use. Default to sampling everything. Never allow this field to be set to null.
*/
private RootSpanSamplingStrategy rootSpanSamplingStrategy = new SampleAllTheThingsStrategy();
/**
* The list of span lifecycle listeners that should be notified when span lifecycle events occur.
* Note that we use a {@link CopyOnWriteArrayList} to prevent {@link java.util.ConcurrentModificationException}s
* from occurring if spans are being started/completed/etc while this list is being changed. This is deemed
* acceptable since iterations over this list happens frequently, but changes to the list should be rare.
*/ | private final List<SpanLifecycleListener> spanLifecycleListeners = new CopyOnWriteArrayList<>(); |
Nike-Inc/wingtips | wingtips-java8/src/test/java/com/nike/wingtips/util/spantagger/DefaultErrorSpanTaggerTest.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/tags/KnownZipkinTags.java
// public class KnownZipkinTags {
//
// // Private constructor so it can't be instantiated.
// private KnownZipkinTags() {}
//
// /**
// * When an annotation value, this indicates when an error occurred. When a
// * binary annotation key, the value is a human readable message associated
// * with an error.
// *
// * Due to transient errors, an ERROR annotation should not be interpreted
// * as a span failure, even the annotation might explain additional latency.
// * Instrumentation should add the ERROR binary annotation when the operation
// * failed and couldn't be recovered.
// *
// * Here's an example: A span has an ERROR annotation, added when a WIRE_SEND
// * failed. Another WIRE_SEND succeeded, so there's no ERROR binary annotation
// * on the span because the overall operation succeeded.
// *
// * Note that RPC spans often include both client and server hosts: It is
// * possible that only one side perceived the error.
// */
// public static final String ERROR = "error";
//
// /**
// * The domain portion of the URL or host header. Ex. "mybucket.s3.amazonaws.com"
// *
// * Used to filter by host as opposed to ip address.
// */
// public static final String HTTP_HOST = "http.host";
//
// /**
// * The HTTP method, or verb, such as "GET" or "POST".
// *
// * Used to filter against an http route.
// */
// public static final String HTTP_METHOD = "http.method";
//
// /**
// * he absolute http path, without any query parameters. Ex. "/objects/abcd-ff"
// *
// * Used as a filter or to clarify the request path for a given route. For example, the path for
// * a route "/objects/:objectId" could be "/objects/abdc-ff". This does not limit cardinality like
// * HTTP_ROUTE("http.route") can, so is not a good input to a span name.
// *
// * The Zipkin query api only supports equals filters. Dropping query parameters makes the number
// * of distinct URIs less. For example, one can query for the same resource, regardless of signing
// * parameters encoded in the query line. Dropping query parameters also limits the security impact
// * of this tag.
// *
// * Historical note: This was commonly expressed as "http.uri" in zipkin, even though it was most
// */
// public static final String HTTP_PATH = "http.path";
//
// /**
// * The route which a request matched or "" (empty string) if routing is supported, but there was no
// * match. Ex "/users/{userId}"
// *
// * Unlike HTTP_PATH("http.path"), this value is fixed cardinality, so is a safe input to a span
// * name function or a metrics dimension. Different formats are possible. For example, the following
// * are all valid route templates: "/users" "/users/:userId" "/users/*"
// *
// * Route-based span name generation often uses other tags, such as HTTP_METHOD("http.method") and
// * HTTP_STATUS_CODE("http.status_code"). Route-based names can look like "get /users/{userId}",
// * "post /users", "get not_found" or "get redirected".
// */
// public static final String HTTP_ROUTE = "http.route";
//
// /**
// * The entire URL, including the scheme, host and query parameters if available. Ex.
// * "https://mybucket.s3.amazonaws.com/objects/abcd-ff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Algorithm=AWS4-HMAC-SHA256..."
// *
// * Combined with HTTP_METHOD, you can understand the fully-qualified request line.
// *
// * This is optional as it may include private data or be of considerable length.
// */
// public static final String HTTP_URL = "http.url";
//
// /**
// * The HTTP status code, when not in 2xx range. Ex. "503"
// *
// * Used to filter for error status.
// */
// public static final String HTTP_STATUS_CODE = "http.status_code";
//
// /**
// * The size of the non-empty HTTP request body, in bytes. Ex. "16384"
// *
// * Large uploads can exceed limits or contribute directly to latency.
// */
// public static final String HTTP_REQUEST_SIZE = "http.request.size";
//
// /**
// * The size of the non-empty HTTP response body, in bytes. Ex. "16384"
// *
// * Large downloads can exceed limits or contribute directly to latency.
// */
// public static final String HTTP_RESPONSE_SIZE = "http.response.size";
//
// }
| import com.nike.wingtips.Span;
import com.nike.wingtips.tags.KnownZipkinTags;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions; | package com.nike.wingtips.util.spantagger;
/**
* Tests the functionality of {@link DefaultErrorSpanTagger}.
*/
@RunWith(DataProviderRunner.class)
public class DefaultErrorSpanTaggerTest {
@DataProvider(value = {
"false | false | true",
"true | false | false",
"false | true | false",
"true | true | false",
}, splitBy = "\\|")
@Test
@SuppressWarnings("ConstantConditions")
public void tagSpanForError_works_as_expected(boolean spanIsNull, boolean errorIsNull, boolean expectErrorTag) {
// given
DefaultErrorSpanTagger tagger = new DefaultErrorSpanTagger();
Span span = (spanIsNull) ? null : mock(Span.class);
Throwable error = (errorIsNull)
? null
: new Exception("Intentional test exception: " + UUID.randomUUID().toString());
// when
tagger.tagSpanForError(span, error);
// then
if (expectErrorTag) { | // Path: wingtips-core/src/main/java/com/nike/wingtips/tags/KnownZipkinTags.java
// public class KnownZipkinTags {
//
// // Private constructor so it can't be instantiated.
// private KnownZipkinTags() {}
//
// /**
// * When an annotation value, this indicates when an error occurred. When a
// * binary annotation key, the value is a human readable message associated
// * with an error.
// *
// * Due to transient errors, an ERROR annotation should not be interpreted
// * as a span failure, even the annotation might explain additional latency.
// * Instrumentation should add the ERROR binary annotation when the operation
// * failed and couldn't be recovered.
// *
// * Here's an example: A span has an ERROR annotation, added when a WIRE_SEND
// * failed. Another WIRE_SEND succeeded, so there's no ERROR binary annotation
// * on the span because the overall operation succeeded.
// *
// * Note that RPC spans often include both client and server hosts: It is
// * possible that only one side perceived the error.
// */
// public static final String ERROR = "error";
//
// /**
// * The domain portion of the URL or host header. Ex. "mybucket.s3.amazonaws.com"
// *
// * Used to filter by host as opposed to ip address.
// */
// public static final String HTTP_HOST = "http.host";
//
// /**
// * The HTTP method, or verb, such as "GET" or "POST".
// *
// * Used to filter against an http route.
// */
// public static final String HTTP_METHOD = "http.method";
//
// /**
// * he absolute http path, without any query parameters. Ex. "/objects/abcd-ff"
// *
// * Used as a filter or to clarify the request path for a given route. For example, the path for
// * a route "/objects/:objectId" could be "/objects/abdc-ff". This does not limit cardinality like
// * HTTP_ROUTE("http.route") can, so is not a good input to a span name.
// *
// * The Zipkin query api only supports equals filters. Dropping query parameters makes the number
// * of distinct URIs less. For example, one can query for the same resource, regardless of signing
// * parameters encoded in the query line. Dropping query parameters also limits the security impact
// * of this tag.
// *
// * Historical note: This was commonly expressed as "http.uri" in zipkin, even though it was most
// */
// public static final String HTTP_PATH = "http.path";
//
// /**
// * The route which a request matched or "" (empty string) if routing is supported, but there was no
// * match. Ex "/users/{userId}"
// *
// * Unlike HTTP_PATH("http.path"), this value is fixed cardinality, so is a safe input to a span
// * name function or a metrics dimension. Different formats are possible. For example, the following
// * are all valid route templates: "/users" "/users/:userId" "/users/*"
// *
// * Route-based span name generation often uses other tags, such as HTTP_METHOD("http.method") and
// * HTTP_STATUS_CODE("http.status_code"). Route-based names can look like "get /users/{userId}",
// * "post /users", "get not_found" or "get redirected".
// */
// public static final String HTTP_ROUTE = "http.route";
//
// /**
// * The entire URL, including the scheme, host and query parameters if available. Ex.
// * "https://mybucket.s3.amazonaws.com/objects/abcd-ff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Algorithm=AWS4-HMAC-SHA256..."
// *
// * Combined with HTTP_METHOD, you can understand the fully-qualified request line.
// *
// * This is optional as it may include private data or be of considerable length.
// */
// public static final String HTTP_URL = "http.url";
//
// /**
// * The HTTP status code, when not in 2xx range. Ex. "503"
// *
// * Used to filter for error status.
// */
// public static final String HTTP_STATUS_CODE = "http.status_code";
//
// /**
// * The size of the non-empty HTTP request body, in bytes. Ex. "16384"
// *
// * Large uploads can exceed limits or contribute directly to latency.
// */
// public static final String HTTP_REQUEST_SIZE = "http.request.size";
//
// /**
// * The size of the non-empty HTTP response body, in bytes. Ex. "16384"
// *
// * Large downloads can exceed limits or contribute directly to latency.
// */
// public static final String HTTP_RESPONSE_SIZE = "http.response.size";
//
// }
// Path: wingtips-java8/src/test/java/com/nike/wingtips/util/spantagger/DefaultErrorSpanTaggerTest.java
import com.nike.wingtips.Span;
import com.nike.wingtips.tags.KnownZipkinTags;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
package com.nike.wingtips.util.spantagger;
/**
* Tests the functionality of {@link DefaultErrorSpanTagger}.
*/
@RunWith(DataProviderRunner.class)
public class DefaultErrorSpanTaggerTest {
@DataProvider(value = {
"false | false | true",
"true | false | false",
"false | true | false",
"true | true | false",
}, splitBy = "\\|")
@Test
@SuppressWarnings("ConstantConditions")
public void tagSpanForError_works_as_expected(boolean spanIsNull, boolean errorIsNull, boolean expectErrorTag) {
// given
DefaultErrorSpanTagger tagger = new DefaultErrorSpanTagger();
Span span = (spanIsNull) ? null : mock(Span.class);
Throwable error = (errorIsNull)
? null
: new Exception("Intentional test exception: " + UUID.randomUUID().toString());
// when
tagger.tagSpanForError(span, error);
// then
if (expectErrorTag) { | verify(span).putTag(KnownZipkinTags.ERROR, error.toString()); |
Nike-Inc/wingtips | samples/sample-jersey2/src/main/java/com/nike/wingtips/jersey2sample/resource/SampleResource.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/util/AsyncWingtipsHelperJava7.java
// @Deprecated
// public static Runnable runnableWithTracing(Runnable runnable) {
// return new RunnableWithTracing(runnable);
// }
| import com.nike.wingtips.servlet.RequestTracingFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import static com.nike.wingtips.util.AsyncWingtipsHelperJava7.runnableWithTracing; | public String getBlocking() {
logger.info("Blocking endpoint hit");
sleepThread(SLEEP_TIME_MILLIS);
return BLOCKING_RESULT;
}
@GET
@Path(PATH_PARAM_ENDPOINT_PATH_PREFIX + "/{somePathParam}")
public String getPathParam(@PathParam("somePathParam") String somePathParam) {
logger.info("Path param endpoint hit - somePathParam: {}", somePathParam);
sleepThread(SLEEP_TIME_MILLIS);
return PATH_PARAM_ENDPOINT_RESULT;
}
@GET
@Path(WILDCARD_PATH_PREFIX + "/{restOfPath:.+}")
public String getWildcard() {
logger.info("Wildcard endpoint hit");
sleepThread(SLEEP_TIME_MILLIS);
return WILDCARD_RESULT;
}
@GET
@Path(ASYNC_PATH)
public void getAsync(@Suspended AsyncResponse asyncResponse) {
logger.info("Async endpoint hit");
| // Path: wingtips-core/src/main/java/com/nike/wingtips/util/AsyncWingtipsHelperJava7.java
// @Deprecated
// public static Runnable runnableWithTracing(Runnable runnable) {
// return new RunnableWithTracing(runnable);
// }
// Path: samples/sample-jersey2/src/main/java/com/nike/wingtips/jersey2sample/resource/SampleResource.java
import com.nike.wingtips.servlet.RequestTracingFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import static com.nike.wingtips.util.AsyncWingtipsHelperJava7.runnableWithTracing;
public String getBlocking() {
logger.info("Blocking endpoint hit");
sleepThread(SLEEP_TIME_MILLIS);
return BLOCKING_RESULT;
}
@GET
@Path(PATH_PARAM_ENDPOINT_PATH_PREFIX + "/{somePathParam}")
public String getPathParam(@PathParam("somePathParam") String somePathParam) {
logger.info("Path param endpoint hit - somePathParam: {}", somePathParam);
sleepThread(SLEEP_TIME_MILLIS);
return PATH_PARAM_ENDPOINT_RESULT;
}
@GET
@Path(WILDCARD_PATH_PREFIX + "/{restOfPath:.+}")
public String getWildcard() {
logger.info("Wildcard endpoint hit");
sleepThread(SLEEP_TIME_MILLIS);
return WILDCARD_RESULT;
}
@GET
@Path(ASYNC_PATH)
public void getAsync(@Suspended AsyncResponse asyncResponse) {
logger.info("Async endpoint hit");
| executor.execute(runnableWithTracing(() -> { |
Nike-Inc/wingtips | wingtips-spring-boot2-webflux/src/test/java/com/nike/wingtips/springboot2/webflux/WingtipsSpringBoot2WebfluxPropertiesTest.java | // Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
// public enum SpanLoggingRepresentation {
// /**
// * Causes spans to be output in the logs using {@link Span#toJSON()}.
// */
// JSON,
// /**
// * Causes spans to be output in the logs using {@link Span#toKeyValueString()}.
// */
// KEY_VALUE
// }
| import com.nike.wingtips.Tracer.SpanLoggingRepresentation;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat; | "fAlSe | false",
" | false",
"junk | false",
"null | false",
}, splitBy = "\\|")
@Test
public void wingtipsDisabled_getter_and_setter_works_as_expected(
String propValueAsStringForSetter, boolean expectedGetterResult
) {
// when
props.setWingtipsDisabled(propValueAsStringForSetter);
// then
assertThat(props.isWingtipsDisabled()).isEqualTo(expectedGetterResult);
}
@Test
public void exercise_standard_getters_and_setters() {
// userIdHeaderKeys getter/setter
{
String nonNullKey = UUID.randomUUID().toString();
props.setUserIdHeaderKeys(nonNullKey);
assertThat(props.getUserIdHeaderKeys()).isEqualTo(nonNullKey);
props.setUserIdHeaderKeys(null);
assertThat(props.getUserIdHeaderKeys()).isNull();
}
// spanLoggingFormat getter/setter
{ | // Path: wingtips-core/src/main/java/com/nike/wingtips/Tracer.java
// public enum SpanLoggingRepresentation {
// /**
// * Causes spans to be output in the logs using {@link Span#toJSON()}.
// */
// JSON,
// /**
// * Causes spans to be output in the logs using {@link Span#toKeyValueString()}.
// */
// KEY_VALUE
// }
// Path: wingtips-spring-boot2-webflux/src/test/java/com/nike/wingtips/springboot2/webflux/WingtipsSpringBoot2WebfluxPropertiesTest.java
import com.nike.wingtips.Tracer.SpanLoggingRepresentation;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
"fAlSe | false",
" | false",
"junk | false",
"null | false",
}, splitBy = "\\|")
@Test
public void wingtipsDisabled_getter_and_setter_works_as_expected(
String propValueAsStringForSetter, boolean expectedGetterResult
) {
// when
props.setWingtipsDisabled(propValueAsStringForSetter);
// then
assertThat(props.isWingtipsDisabled()).isEqualTo(expectedGetterResult);
}
@Test
public void exercise_standard_getters_and_setters() {
// userIdHeaderKeys getter/setter
{
String nonNullKey = UUID.randomUUID().toString();
props.setUserIdHeaderKeys(nonNullKey);
assertThat(props.getUserIdHeaderKeys()).isEqualTo(nonNullKey);
props.setUserIdHeaderKeys(null);
assertThat(props.getUserIdHeaderKeys()).isNull();
}
// spanLoggingFormat getter/setter
{ | for (SpanLoggingRepresentation format : SpanLoggingRepresentation.values()) { |
Nike-Inc/wingtips | wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java | // Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridedefaultreporter/ComponentTestMainWithReporterOverride.java
// @SpringBootApplication
// @Import(WingtipsWithZipkinSpringBootConfiguration.class)
// public class ComponentTestMainWithReporterOverride {
//
// public static final Reporter<zipkin2.Span> CUSTOM_REPORTER_INSTANCE = mock(Reporter.class);
//
// @Bean
// public Reporter<zipkin2.Span> customZipkinReporter() {
// return CUSTOM_REPORTER_INSTANCE;
// }
//
// }
//
// Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
| import com.nike.wingtips.springboot.zipkin2.WingtipsWithZipkinSpringBootConfiguration;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import zipkin2.reporter.Reporter; | package com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBootConfiguration.class)
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() { | // Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridedefaultreporter/ComponentTestMainWithReporterOverride.java
// @SpringBootApplication
// @Import(WingtipsWithZipkinSpringBootConfiguration.class)
// public class ComponentTestMainWithReporterOverride {
//
// public static final Reporter<zipkin2.Span> CUSTOM_REPORTER_INSTANCE = mock(Reporter.class);
//
// @Bean
// public Reporter<zipkin2.Span> customZipkinReporter() {
// return CUSTOM_REPORTER_INSTANCE;
// }
//
// }
//
// Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
// Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java
import com.nike.wingtips.springboot.zipkin2.WingtipsWithZipkinSpringBootConfiguration;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import zipkin2.reporter.Reporter;
package com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBootConfiguration.class)
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() { | return ComponentTestMainWithReporterOverride.CUSTOM_REPORTER_INSTANCE; |
Nike-Inc/wingtips | wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java | // Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridedefaultreporter/ComponentTestMainWithReporterOverride.java
// @SpringBootApplication
// @Import(WingtipsWithZipkinSpringBootConfiguration.class)
// public class ComponentTestMainWithReporterOverride {
//
// public static final Reporter<zipkin2.Span> CUSTOM_REPORTER_INSTANCE = mock(Reporter.class);
//
// @Bean
// public Reporter<zipkin2.Span> customZipkinReporter() {
// return CUSTOM_REPORTER_INSTANCE;
// }
//
// }
//
// Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
| import com.nike.wingtips.springboot.zipkin2.WingtipsWithZipkinSpringBootConfiguration;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import zipkin2.reporter.Reporter; | package com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBootConfiguration.class)
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() {
return ComponentTestMainWithReporterOverride.CUSTOM_REPORTER_INSTANCE;
}
@Bean | // Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridedefaultreporter/ComponentTestMainWithReporterOverride.java
// @SpringBootApplication
// @Import(WingtipsWithZipkinSpringBootConfiguration.class)
// public class ComponentTestMainWithReporterOverride {
//
// public static final Reporter<zipkin2.Span> CUSTOM_REPORTER_INSTANCE = mock(Reporter.class);
//
// @Bean
// public Reporter<zipkin2.Span> customZipkinReporter() {
// return CUSTOM_REPORTER_INSTANCE;
// }
//
// }
//
// Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
// Path: wingtips-zipkin2-spring-boot/src/test/java/com/nike/wingtips/springboot/zipkin2/componenttest/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java
import com.nike.wingtips.springboot.zipkin2.WingtipsWithZipkinSpringBootConfiguration;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import zipkin2.reporter.Reporter;
package com.nike.wingtips.springboot.zipkin2.componenttest.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBootConfiguration.class)
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() {
return ComponentTestMainWithReporterOverride.CUSTOM_REPORTER_INSTANCE;
}
@Bean | public WingtipsToZipkinSpanConverter customConverter() { |
Nike-Inc/wingtips | wingtips-zipkin2-spring-boot2-webflux/src/test/java/notcomponentscanned/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java | // Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
| import com.nike.wingtips.springboot2.webflux.zipkin2.WingtipsWithZipkinSpringBoot2WebfluxConfiguration;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import notcomponentscanned.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import notcomponentscanned.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import zipkin2.reporter.Reporter; | package notcomponentscanned.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBoot2WebfluxConfiguration.class)
@SuppressWarnings("unused")
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() {
return ComponentTestMainWithReporterOverride.CUSTOM_REPORTER_INSTANCE;
}
@Bean | // Path: wingtips-zipkin2/src/main/java/com/nike/wingtips/zipkin2/util/WingtipsToZipkinSpanConverter.java
// public interface WingtipsToZipkinSpanConverter {
//
// /**
// * @param wingtipsSpan The Wingtips span to convert.
// * @param zipkinEndpoint The Zipkin {@link Endpoint} associated with the current service. This is often a singleton
// * that gets reused throughout the life of the service. It tells Zipkin which service generated the span.
// * @return The given Wingtips {@link Span} after it has been converted to a {@link zipkin2.Span}.
// */
// zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);
//
// }
// Path: wingtips-zipkin2-spring-boot2-webflux/src/test/java/notcomponentscanned/componenttestoverridebothreporterandconverter/ComponentTestMainWithReporterAndConverterOverrides.java
import com.nike.wingtips.springboot2.webflux.zipkin2.WingtipsWithZipkinSpringBoot2WebfluxConfiguration;
import com.nike.wingtips.zipkin2.util.WingtipsToZipkinSpanConverter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import notcomponentscanned.componenttestoverridedefaultconverter.ComponentTestMainWithConverterOverride;
import notcomponentscanned.componenttestoverridedefaultreporter.ComponentTestMainWithReporterOverride;
import zipkin2.reporter.Reporter;
package notcomponentscanned.componenttestoverridebothreporterandconverter;
@SpringBootApplication
@Import(WingtipsWithZipkinSpringBoot2WebfluxConfiguration.class)
@SuppressWarnings("unused")
public class ComponentTestMainWithReporterAndConverterOverrides {
@Bean
public Reporter<zipkin2.Span> customZipkinReporter() {
return ComponentTestMainWithReporterOverride.CUSTOM_REPORTER_INSTANCE;
}
@Bean | public WingtipsToZipkinSpanConverter customConverter() { |
mcxiaoke/Android-Next | func/src/main/java/com/mcxiaoke/next/func/Fn.java | // Path: func/src/main/java/com/mcxiaoke/next/func/functions/Func1.java
// public interface Func1<T, R> extends Function {
//
// R call(T t);
//
//
// }
//
// Path: func/src/main/java/com/mcxiaoke/next/func/functions/Predicate.java
// public interface Predicate<T> {
//
// /**
// * Evaluates this predicate on the given argument.
// *
// * @param t the input argument
// * @return {@code true} if the input argument matches the predicate,
// * otherwise {@code false}
// */
// boolean accept(T t);
// }
| import com.mcxiaoke.next.func.functions.Action1;
import com.mcxiaoke.next.func.functions.Func1;
import com.mcxiaoke.next.func.functions.Func2;
import com.mcxiaoke.next.func.functions.Predicate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set; | return Collections.max(collection);
}
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> collection) {
return Collections.min(collection);
}
public static <T> T max(Comparator<? super T> cmp, Collection<? extends T> collection) {
return Collections.max(collection, cmp);
}
public static <T> T min(Comparator<? super T> cmp, Collection<? extends T> collection) {
return Collections.min(collection, cmp);
}
// ==================================================================
// ==================================================================
// Conditional Operators
// ==================================================================
// ==================================================================
public static <T> Collection<T> distinct(Collection<? extends T> collection) {
return new HashSet<T>(collection);
}
public static <T> List<T> distinct(List<? extends T> list) {
return new ArrayList<T>(new HashSet<T>(list));
}
| // Path: func/src/main/java/com/mcxiaoke/next/func/functions/Func1.java
// public interface Func1<T, R> extends Function {
//
// R call(T t);
//
//
// }
//
// Path: func/src/main/java/com/mcxiaoke/next/func/functions/Predicate.java
// public interface Predicate<T> {
//
// /**
// * Evaluates this predicate on the given argument.
// *
// * @param t the input argument
// * @return {@code true} if the input argument matches the predicate,
// * otherwise {@code false}
// */
// boolean accept(T t);
// }
// Path: func/src/main/java/com/mcxiaoke/next/func/Fn.java
import com.mcxiaoke.next.func.functions.Action1;
import com.mcxiaoke.next.func.functions.Func1;
import com.mcxiaoke.next.func.functions.Func2;
import com.mcxiaoke.next.func.functions.Predicate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
return Collections.max(collection);
}
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> collection) {
return Collections.min(collection);
}
public static <T> T max(Comparator<? super T> cmp, Collection<? extends T> collection) {
return Collections.max(collection, cmp);
}
public static <T> T min(Comparator<? super T> cmp, Collection<? extends T> collection) {
return Collections.min(collection, cmp);
}
// ==================================================================
// ==================================================================
// Conditional Operators
// ==================================================================
// ==================================================================
public static <T> Collection<T> distinct(Collection<? extends T> collection) {
return new HashSet<T>(collection);
}
public static <T> List<T> distinct(List<? extends T> list) {
return new ArrayList<T>(new HashSet<T>(list));
}
| public static <T> Collection<T> filter(Predicate<? super T> p, |
mcxiaoke/Android-Next | func/src/main/java/com/mcxiaoke/next/func/Fn.java | // Path: func/src/main/java/com/mcxiaoke/next/func/functions/Func1.java
// public interface Func1<T, R> extends Function {
//
// R call(T t);
//
//
// }
//
// Path: func/src/main/java/com/mcxiaoke/next/func/functions/Predicate.java
// public interface Predicate<T> {
//
// /**
// * Evaluates this predicate on the given argument.
// *
// * @param t the input argument
// * @return {@code true} if the input argument matches the predicate,
// * otherwise {@code false}
// */
// boolean accept(T t);
// }
| import com.mcxiaoke.next.func.functions.Action1;
import com.mcxiaoke.next.func.functions.Func1;
import com.mcxiaoke.next.func.functions.Func2;
import com.mcxiaoke.next.func.functions.Predicate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set; | }
}
return zipped;
}
public static <T, R> R reduce(final Func2<R, ? super T, R> func2,
final Iterable<? extends T> iterable,
final R initializer) {
R r = initializer;
final Iterator<? extends T> it = iterable.iterator();
while (it.hasNext()) {
r = func2.call(r, it.next());
}
return r;
}
@SuppressWarnings("unchecked")
public static <T, R> R reduce(final Func2<R, ? super T, R> func2,
final Iterable<? extends T> iterable) {
R r = null;
final Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
r = (R) it.next();
while (it.hasNext()) {
r = func2.call(r, it.next());
}
}
return r;
}
| // Path: func/src/main/java/com/mcxiaoke/next/func/functions/Func1.java
// public interface Func1<T, R> extends Function {
//
// R call(T t);
//
//
// }
//
// Path: func/src/main/java/com/mcxiaoke/next/func/functions/Predicate.java
// public interface Predicate<T> {
//
// /**
// * Evaluates this predicate on the given argument.
// *
// * @param t the input argument
// * @return {@code true} if the input argument matches the predicate,
// * otherwise {@code false}
// */
// boolean accept(T t);
// }
// Path: func/src/main/java/com/mcxiaoke/next/func/Fn.java
import com.mcxiaoke.next.func.functions.Action1;
import com.mcxiaoke.next.func.functions.Func1;
import com.mcxiaoke.next.func.functions.Func2;
import com.mcxiaoke.next.func.functions.Predicate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
}
}
return zipped;
}
public static <T, R> R reduce(final Func2<R, ? super T, R> func2,
final Iterable<? extends T> iterable,
final R initializer) {
R r = initializer;
final Iterator<? extends T> it = iterable.iterator();
while (it.hasNext()) {
r = func2.call(r, it.next());
}
return r;
}
@SuppressWarnings("unchecked")
public static <T, R> R reduce(final Func2<R, ? super T, R> func2,
final Iterable<? extends T> iterable) {
R r = null;
final Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
r = (R) it.next();
while (it.hasNext()) {
r = func2.call(r, it.next());
}
}
return r;
}
| public static <T, R> void map(Func1<? super T, ? extends R> func, Collection<T> from, Collection<R> to) { |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/NextClient.java | // Path: http/src/main/java/com/mcxiaoke/next/http/transformer/HttpTransformer.java
// public interface HttpTransformer<T> {
//
// T transform(NextResponse response) throws IOException;
// }
| import android.util.Log;
import com.mcxiaoke.next.http.transformer.HttpTransformer;
import com.mcxiaoke.next.utils.AssertUtils;
import com.mcxiaoke.next.utils.LogUtils;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.Map; | }
public NextResponse post(final String url, final NextParams params) throws IOException {
return request(HttpMethod.POST, url, params);
}
public NextResponse put(final String url, final NextParams params) throws IOException {
return request(HttpMethod.PUT, url, params);
}
public NextResponse request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms)
throws IOException {
return request(method, url, queries, forms, null);
}
public NextResponse request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms,
final Map<String, String> headers)
throws IOException {
return executeInternal(createRequest(method, url,
queries, forms, headers));
}
public <T> T request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms,
final Map<String, String> headers, | // Path: http/src/main/java/com/mcxiaoke/next/http/transformer/HttpTransformer.java
// public interface HttpTransformer<T> {
//
// T transform(NextResponse response) throws IOException;
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/NextClient.java
import android.util.Log;
import com.mcxiaoke.next.http.transformer.HttpTransformer;
import com.mcxiaoke.next.utils.AssertUtils;
import com.mcxiaoke.next.utils.LogUtils;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.Map;
}
public NextResponse post(final String url, final NextParams params) throws IOException {
return request(HttpMethod.POST, url, params);
}
public NextResponse put(final String url, final NextParams params) throws IOException {
return request(HttpMethod.PUT, url, params);
}
public NextResponse request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms)
throws IOException {
return request(method, url, queries, forms, null);
}
public NextResponse request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms,
final Map<String, String> headers)
throws IOException {
return executeInternal(createRequest(method, url,
queries, forms, headers));
}
public <T> T request(final HttpMethod method, final String url,
final Map<String, String> queries,
final Map<String, String> forms,
final Map<String, String> headers, | final HttpTransformer<T> converter) |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/transformer/GsonTransformer.java | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
| import com.google.gson.Gson;
import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException;
import java.lang.reflect.Type; | package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 12:42
*/
public class GsonTransformer<T> implements HttpTransformer<T> {
private Gson gson;
private Type type;
public GsonTransformer(final Gson gson, final Class<T> clazz) {
this.gson = gson;
this.type = clazz;
}
public GsonTransformer(final Gson gson, final Type type) {
this.gson = gson;
this.type = type;
}
@SuppressWarnings("unchecked")
@Override | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/transformer/GsonTransformer.java
import com.google.gson.Gson;
import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException;
import java.lang.reflect.Type;
package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 12:42
*/
public class GsonTransformer<T> implements HttpTransformer<T> {
private Gson gson;
private Type type;
public GsonTransformer(final Gson gson, final Class<T> clazz) {
this.gson = gson;
this.type = clazz;
}
public GsonTransformer(final Gson gson, final Type type) {
this.gson = gson;
this.type = type;
}
@SuppressWarnings("unchecked")
@Override | public T transform(final NextResponse response) throws IOException { |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/transformer/FileTransformer.java | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
| import com.mcxiaoke.next.http.NextResponse;
import java.io.File;
import java.io.IOException; | package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 14:46
*/
public class FileTransformer implements HttpTransformer<File> {
private File file;
public FileTransformer(final File file) {
this.file = file;
}
@Override | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/transformer/FileTransformer.java
import com.mcxiaoke.next.http.NextResponse;
import java.io.File;
import java.io.IOException;
package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 14:46
*/
public class FileTransformer implements HttpTransformer<File> {
private File file;
public FileTransformer(final File file) {
this.file = file;
}
@Override | public File transform(final NextResponse response) throws IOException { |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java | // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
| import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map; | package com.mcxiaoke.next.http;
/**
* User: mcxiaoke
* Date: 16/1/11
* Time: 11:42
*/
public final class HttpAsync {
private HttpAsync() {
throw new RuntimeException("Can't create new instance");
}
private static HttpQueue sHttpQueue = null;
public static void setHttpQueue(final HttpQueue httpQueue) {
sHttpQueue = httpQueue;
}
private synchronized static HttpQueue getHttpQueue() {
if (sHttpQueue == null) {
sHttpQueue = HttpQueue.getDefault();
}
return sHttpQueue;
}
private static Map<String, String> emptyMap() {
return Collections.emptyMap();
}
| // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java
import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map;
package com.mcxiaoke.next.http;
/**
* User: mcxiaoke
* Date: 16/1/11
* Time: 11:42
*/
public final class HttpAsync {
private HttpAsync() {
throw new RuntimeException("Can't create new instance");
}
private static HttpQueue sHttpQueue = null;
public static void setHttpQueue(final HttpQueue httpQueue) {
sHttpQueue = httpQueue;
}
private synchronized static HttpQueue getHttpQueue() {
if (sHttpQueue == null) {
sHttpQueue = HttpQueue.getDefault();
}
return sHttpQueue;
}
private static Map<String, String> emptyMap() {
return Collections.emptyMap();
}
| public static String head(final String url, final ResponseCallback callback, |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java | // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
| import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map; |
public static String head(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.HEAD, url, queries, null, callback, caller);
}
public static String head(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.HEAD, url, params, callback, caller);
}
public static String get(final String url, final ResponseCallback callback,
Object caller) {
return get(url, emptyMap(), callback, caller);
}
public static String get(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
| // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java
import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map;
public static String head(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.HEAD, url, queries, null, callback, caller);
}
public static String head(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.HEAD, url, params, callback, caller);
}
public static String get(final String url, final ResponseCallback callback,
Object caller) {
return get(url, emptyMap(), callback, caller);
}
public static String get(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
| public static String get(final String url, final StringCallback callback, |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java | // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
| import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map; | public static String get(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
public static String get(final String url, final StringCallback callback,
Object caller) {
return get(url, emptyMap(), callback, caller);
}
public static String get(final String url, final Map<String, String> queries,
final StringCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final StringCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
public static <T> String get(final String url, | // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java
import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map;
public static String get(final String url, final Map<String, String> queries,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final ResponseCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
public static String get(final String url, final StringCallback callback,
Object caller) {
return get(url, emptyMap(), callback, caller);
}
public static String get(final String url, final Map<String, String> queries,
final StringCallback callback,
Object caller) {
return add(HttpMethod.GET, url, queries, null, callback, caller);
}
public static String get(final String url, final NextParams params,
final StringCallback callback,
Object caller) {
return add(HttpMethod.GET, url, params, callback, caller);
}
public static <T> String get(final String url, | final GsonCallback<T> callback, |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java | // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
| import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map; | public static String put(final String url, final Map<String, String> forms,
final StringCallback callback,
Object caller) {
return add(HttpMethod.PUT, url, null, forms, callback, caller);
}
public static String put(final String url, final NextParams params,
final StringCallback callback,
Object caller) {
return add(HttpMethod.PUT, url, params, callback, caller);
}
public static <T> String put(final String url, final GsonCallback<T> callback,
Object caller) {
return put(url, emptyMap(), callback, caller);
}
public static <T> String put(final String url, final Map<String, String> forms,
final GsonCallback<T> callback,
Object caller) {
return add(HttpMethod.PUT, url, null, forms, callback, caller);
}
public static <T> String put(final String url, final NextParams params,
final GsonCallback<T> callback,
Object caller) {
return add(HttpMethod.PUT, url, params, callback, caller);
}
| // Path: http/src/main/java/com/mcxiaoke/next/http/callback/FileCallback.java
// public interface FileCallback extends HttpCallback<File> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/GsonCallback.java
// public abstract class GsonCallback<T> implements HttpCallback<T> {
// public final Type type;
// public final Gson gson;
//
// public GsonCallback(final Class<T> clazz) {
// this(clazz, null);
// }
//
// public GsonCallback(final Class<T> clazz, final Gson gson) {
// this.type = clazz;
// this.gson = gson;
// }
//
// public GsonCallback(final Type type) {
// this(type, null);
// }
//
// public GsonCallback(Type type, final Gson gson) {
// this.type = type;
// this.gson = gson;
// }
//
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/ResponseCallback.java
// public interface ResponseCallback extends HttpCallback<NextResponse> {
// }
//
// Path: http/src/main/java/com/mcxiaoke/next/http/callback/StringCallback.java
// public interface StringCallback extends HttpCallback<String> {
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/HttpAsync.java
import com.mcxiaoke.next.http.callback.FileCallback;
import com.mcxiaoke.next.http.callback.GsonCallback;
import com.mcxiaoke.next.http.callback.ResponseCallback;
import com.mcxiaoke.next.http.callback.StringCallback;
import java.io.File;
import java.util.Collections;
import java.util.Map;
public static String put(final String url, final Map<String, String> forms,
final StringCallback callback,
Object caller) {
return add(HttpMethod.PUT, url, null, forms, callback, caller);
}
public static String put(final String url, final NextParams params,
final StringCallback callback,
Object caller) {
return add(HttpMethod.PUT, url, params, callback, caller);
}
public static <T> String put(final String url, final GsonCallback<T> callback,
Object caller) {
return put(url, emptyMap(), callback, caller);
}
public static <T> String put(final String url, final Map<String, String> forms,
final GsonCallback<T> callback,
Object caller) {
return add(HttpMethod.PUT, url, null, forms, callback, caller);
}
public static <T> String put(final String url, final NextParams params,
final GsonCallback<T> callback,
Object caller) {
return add(HttpMethod.PUT, url, params, callback, caller);
}
| public static String download(final String url, final File file, final FileCallback callback, |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/transformer/BitmapTransformer.java | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
| import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException; | package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 16/1/11
* Time: 14:29
*/
public class BitmapTransformer implements HttpTransformer<Bitmap> {
@Override | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/transformer/BitmapTransformer.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException;
package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 16/1/11
* Time: 14:29
*/
public class BitmapTransformer implements HttpTransformer<Bitmap> {
@Override | public Bitmap transform(final NextResponse response) throws IOException { |
mcxiaoke/Android-Next | http/src/main/java/com/mcxiaoke/next/http/transformer/StringTransformer.java | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
| import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException; | package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 12:25
*/
public class StringTransformer implements HttpTransformer<String> {
@Override | // Path: http/src/main/java/com/mcxiaoke/next/http/NextResponse.java
// public class NextResponse {
// public static final String TAG = NextResponse.class.getSimpleName();
//
// private Response mResponse;
// private int mStatusCode;
// private String mMessage;
// private Date mCreatedAt;
//
// NextResponse(final Response response) {
// mResponse = response;
// mStatusCode = response.code();
// mMessage = response.message();
// mCreatedAt = new Date();
// }
//
// public Response raw() {
// return mResponse;
// }
//
// public Date createdAt() {
// return mCreatedAt;
// }
//
// public boolean successful() {
// return mResponse.isSuccessful();
// }
//
// public boolean redirect() {
// return mResponse.isRedirect();
// }
//
// public int code() {
// return mStatusCode;
// }
//
// public String message() {
// return mMessage;
// }
//
// public String description() {
// return mStatusCode + ":" + mMessage;
// }
//
// public long contentLength() {
// return mResponse.body().contentLength();
// }
//
// public String contentType() {
// return mResponse.body().contentType().toString();
// }
//
// public Charset charset() {
// return mResponse.body().contentType().charset();
// }
//
// public Headers headers() {
// return mResponse.headers();
// }
//
// public String header(String name) {
// return mResponse.headers().get(name);
// }
//
// public String location() {
// return header(HttpConsts.LOCATION);
// }
//
// public InputStream stream() {
// return mResponse.body().byteStream();
// }
//
// public byte[] bytes() throws IOException {
// return mResponse.body().bytes();
// }
//
// public Reader reader() {
// return mResponse.body().charStream();
// }
//
// public String string() throws IOException {
// return mResponse.body().string();
// }
//
// public int writeTo(OutputStream os) throws IOException {
// return IOUtils.copy(stream(), os);
// }
//
// public boolean writeTo(File file) throws IOException {
// return IOUtils.writeStream(file, stream());
// }
//
// public void close() {
// mResponse.body().close();
// }
//
// public String dumpBody() {
// try {
// char[] buffer = new char[512];
// reader().read(buffer);
// return new String(buffer);
// } catch (IOException e) {
// return e.getMessage();
// }
// }
//
// public String dumpHeaders() {
// return mResponse.headers().toString();
// }
//
// public static String prettyPrintJson(final String rawJson) {
// final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(new JsonParser().parse(rawJson));
// }
//
// @Override
// public String toString() {
// return String.valueOf(mResponse);
// }
// }
// Path: http/src/main/java/com/mcxiaoke/next/http/transformer/StringTransformer.java
import com.mcxiaoke.next.http.NextResponse;
import java.io.IOException;
package com.mcxiaoke.next.http.transformer;
/**
* User: mcxiaoke
* Date: 15/8/21
* Time: 12:25
*/
public class StringTransformer implements HttpTransformer<String> {
@Override | public String transform(final NextResponse response) throws IOException { |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java | // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
| import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List; | }
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
| // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java
import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List;
}
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
| private ViewHolderCreator<ItemViewHolder> mHeaderCreator = |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java | // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
| import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List; | }
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
| // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java
import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List;
}
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
| private ViewHolderCreator<ItemViewHolder> mHeaderCreator = |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java | // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
| import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List; |
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
private ViewHolderCreator<ItemViewHolder> mHeaderCreator = | // Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class ItemViewHolder extends RecyclerView.ViewHolder {
//
// public ItemViewHolder(final View itemView) {
// super(itemView);
// }
//
// public void bind(final int position) {
//
// }
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public interface ViewHolderCreator<VH extends ViewHolder> {
//
// VH create(final ViewGroup parent);
//
// void bind(final VH holder, final int position);
// }
//
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerView.java
// public static class SimpleViewHolderCreator implements ViewHolderCreator<ItemViewHolder> {
// @LayoutRes
// private int layoutRes;
//
// public SimpleViewHolderCreator(@LayoutRes final int layoutRes) {
// this.layoutRes = layoutRes;
// }
//
// @Override
// public ItemViewHolder create(final ViewGroup parent) {
// LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// View view = inflater.inflate(layoutRes, parent, false);
// return new ItemViewHolder(view);
// }
//
// @Override
// public void bind(final ItemViewHolder holder, final int position) {
// holder.bind(position);
// }
// }
// Path: recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerAdapter.java
import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ItemViewHolder;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.ViewHolderCreator;
import com.mcxiaoke.next.recycler.AdvancedRecyclerView.SimpleViewHolderCreator;
import java.util.ArrayList;
import java.util.List;
@Override
public void onItemRangeMoved(final int fromPosition, final int toPosition, final int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
Log.v(TAG, "onItemRangeMoved() start=" + fromPosition + " count=" + itemCount);
notifyItemRangeChanged(fromPosition, itemCount);
}
@Override
public void onItemRangeInserted(final int positionStart, final int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
Log.v(TAG, "onItemRangeInserted() start=" + positionStart + " count=" + itemCount);
notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(final int positionStart, final int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
Log.v(TAG, "onItemRangeChanged() start=" + positionStart + " count=" + itemCount);
notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void onChanged() {
super.onChanged();
notifyDataSetChanged();
}
};
private ViewHolderCreator<ItemViewHolder> mHeaderCreator = | new SimpleViewHolderCreator(DEFAULT_LOADING_HEADER_LAYOUT); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.