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
LuckyJayce/EventBus-Apt
eventbus-compiler/src/main/java/com/shizhefei/eventbus/plugin/EventProxyBuilder.java
// Path: eventbus-annotation/src/main/java/com/shizhefei/eventbus/EventProxyNameBuilder.java // public class EventProxyNameBuilder { // // public static String getProxyClassName(Class<? extends IEvent> eventClass) { // return getProxyClassName(eventClass.getPackage().getName(), eventClass.getName()); // } // // public static String getProxyClassName(String packageName, String interfaceEventClassName) { // return packageName + "." + getProxySimpleClassName(packageName, interfaceEventClassName); // } // // public static String getProxySimpleClassName(String packageName, String interfaceEventClassName) { // String withoutPackageClassName = interfaceEventClassName.substring(packageName.length() + 1); // withoutPackageClassName = withoutPackageClassName.replaceAll("\\$", "_"); // withoutPackageClassName = withoutPackageClassName.replaceAll("\\.", "_"); // String name = withoutPackageClassName + "Proxy"; // return name; // } // // public static String getRemoteClassParamName() { // return "eventClassName"; // } // }
import com.shizhefei.eventbus.EventProxyNameBuilder; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.annotation.processing.Messager; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeParameterElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import javax.tools.Diagnostic; import static javax.lang.model.element.Modifier.PUBLIC;
package com.shizhefei.eventbus.plugin; /** * Created by LuckyJayce on 2017/4/29. */ public class EventProxyBuilder { private Messager messager; public EventProxyBuilder(Messager messager) { this.messager = messager; } public JavaFile build(boolean isRemoteEvent, TypeElement typeElement) { PackageElement packageElement = getPackage(typeElement); String eventImpPackageName = packageElement.getQualifiedName().toString();
// Path: eventbus-annotation/src/main/java/com/shizhefei/eventbus/EventProxyNameBuilder.java // public class EventProxyNameBuilder { // // public static String getProxyClassName(Class<? extends IEvent> eventClass) { // return getProxyClassName(eventClass.getPackage().getName(), eventClass.getName()); // } // // public static String getProxyClassName(String packageName, String interfaceEventClassName) { // return packageName + "." + getProxySimpleClassName(packageName, interfaceEventClassName); // } // // public static String getProxySimpleClassName(String packageName, String interfaceEventClassName) { // String withoutPackageClassName = interfaceEventClassName.substring(packageName.length() + 1); // withoutPackageClassName = withoutPackageClassName.replaceAll("\\$", "_"); // withoutPackageClassName = withoutPackageClassName.replaceAll("\\.", "_"); // String name = withoutPackageClassName + "Proxy"; // return name; // } // // public static String getRemoteClassParamName() { // return "eventClassName"; // } // } // Path: eventbus-compiler/src/main/java/com/shizhefei/eventbus/plugin/EventProxyBuilder.java import com.shizhefei.eventbus.EventProxyNameBuilder; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.annotation.processing.Messager; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeParameterElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import javax.tools.Diagnostic; import static javax.lang.model.element.Modifier.PUBLIC; package com.shizhefei.eventbus.plugin; /** * Created by LuckyJayce on 2017/4/29. */ public class EventProxyBuilder { private Messager messager; public EventProxyBuilder(Messager messager) { this.messager = messager; } public JavaFile build(boolean isRemoteEvent, TypeElement typeElement) { PackageElement packageElement = getPackage(typeElement); String eventImpPackageName = packageElement.getQualifiedName().toString();
String proxySimpleClassName = EventProxyNameBuilder.getProxySimpleClassName(eventImpPackageName, typeElement.getQualifiedName().toString());
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent;
package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis();
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent; package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis();
EventBus.post(IMessageEvent.class).onReceiverMessage(messageId++, s);
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent;
package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis();
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent; package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis();
EventBus.post(IMessageEvent.class).onReceiverMessage(messageId++, s);
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent;
package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis(); EventBus.post(IMessageEvent.class).onReceiverMessage(messageId++, s); Log.d("SenderFragment", " time:" + (System.currentTimeMillis() - time)); editText.setText(""); } else if (v == logoutButton) {
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/SenderFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent; package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ public class SenderFragment extends Fragment { private Button sendButton; private EditText editText; private int messageId = 0; private Button logoutButton; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sender, container, false); sendButton = (Button) view.findViewById(R.id.button); editText = (EditText) view.findViewById(R.id.editText); logoutButton = (Button) view.findViewById(R.id.logout_button); sendButton.setOnClickListener(onClickListener); logoutButton.setOnClickListener(onClickListener); return view; } private View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (v == sendButton) { String s = editText.getText().toString(); long time = System.currentTimeMillis(); EventBus.post(IMessageEvent.class).onReceiverMessage(messageId++, s); Log.d("SenderFragment", " time:" + (System.currentTimeMillis() - time)); editText.setText(""); } else if (v == logoutButton) {
EventBus.postMain(IAccountEventHAHAHAHAHHALLLLL.class).logout();
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/ReceiverFragment.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Subscribe; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent;
package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ @Subscribe(receiveThreadMode = Subscribe.MAIN) public class ReceiverFragment extends Fragment implements IMessageEvent, IAccountEventHAHAHAHAHHALLLLL { private TextView textView; private StringBuilder stringBuilder = new StringBuilder(); private IMessageEvent iMessageEvent_main = new MyIMessageEvent(); private IMessageEvent iMessageEvent_posting = new MyIMessageEvent2(); private IMessageEvent iMessageEvent_background = new MyIMessageEvent3(); private IMessageEvent iMessageEvent_async = new MyIMessageEvent4(); @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_receiver, container, false); textView = (TextView) view.findViewById(R.id.textView);
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IAccountEventHAHAHAHAHHALLLLL.java // @Event // public interface IAccountEventHAHAHAHAHHALLLLL extends IEvent { // void logout(); // void login(); // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/IMessageEvent.java // @Event // public interface IMessageEvent extends IRemoteEvent { // void onReceiverMessage(int messageId, String message); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/ReceiverFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Subscribe; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.IAccountEventHAHAHAHAHHALLLLL; import com.shizhefei.eventbusdemo.events.IMessageEvent; package com.shizhefei.eventbusdemo; /** * Created by LuckyJayce on 2017/3/20. */ @Subscribe(receiveThreadMode = Subscribe.MAIN) public class ReceiverFragment extends Fragment implements IMessageEvent, IAccountEventHAHAHAHAHHALLLLL { private TextView textView; private StringBuilder stringBuilder = new StringBuilder(); private IMessageEvent iMessageEvent_main = new MyIMessageEvent(); private IMessageEvent iMessageEvent_posting = new MyIMessageEvent2(); private IMessageEvent iMessageEvent_background = new MyIMessageEvent3(); private IMessageEvent iMessageEvent_async = new MyIMessageEvent4(); @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_receiver, container, false); textView = (TextView) view.findViewById(R.id.textView);
EventBus.register(iMessageEvent_main);
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent;
package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent; package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
EventBus.postMain(TestFilterEvent.class).onWrite(null, "aaaaa");
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent;
package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent; package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
EventBus.postMain(TestFilterEvent.class).onWrite(null, "aaaaa");
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent;
package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EventBus.postMain(TestFilterEvent.class).onWrite(null, "aaaaa"); } }); findViewById(R.id.sendButton2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java // public class EventBus { // // private static EventProcessHandler defaultEventHandler; // private static WeakHashMap<Activity, EventHandler> eventHandlerMap; // private static EventHandler emptyEventHandler = new EventHandler(); // private static Context staticContext; // private static boolean staticHasRemoteEvent; // volatile static IEventProxyFactory staticEventProxyFactory; // // public static void init(Context context, boolean hasRemoteEvent) { // staticContext = context.getApplicationContext(); // staticHasRemoteEvent = hasRemoteEvent; // eventHandlerMap = new WeakHashMap<>(); // defaultEventHandler = new EventProcessHandler(hasRemoteEvent); // staticEventProxyFactory = new EventProxyAptFactory(); // } // // public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){ // staticEventProxyFactory = eventProxyFactory; // } // // static IEventProxyFactory getEventProxyFactory(){ // return staticEventProxyFactory; // } // // static Context getContext() { // return staticContext; // } // // static boolean isHasRemoteEvent() { // return staticHasRemoteEvent; // } // // public static void register(IEvent iEvent) { // checkInit(); // defaultEventHandler.register(iEvent); // } // // public static void unregister(IEvent iEvent) { // checkInit(); // defaultEventHandler.unregister(iEvent); // } // // public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.postMain(eventInterface); // } // // public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) { // checkInit(); // return defaultEventHandler.post(eventInterface); // } // // public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) { // checkInit(); // return defaultEventHandler.postRemote(eventInterface, processName); // } // // // public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // // // public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) { // // return withActivity(activity).postMain(eventInterface); // // } // // public static synchronized IEventHandler withActivity(Activity activity) { // checkInit(); // if (activity == null) { // return emptyEventHandler; // } // EventHandler eventBusImp = eventHandlerMap.get(activity); // if (eventBusImp == null) { // eventBusImp = new EventHandler(); // eventHandlerMap.put(activity, eventBusImp); // } // return eventBusImp; // } // // private static void checkInit() { // if (staticContext == null) { // throw new RuntimeException("请在Application调用EventBus.init方法进行初始化"); // } // } // } // // Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java // public class Filters { // // public static IEvent.Filter deliver(final IEvent... registers) { // if (registers == null) { // return acceptAll(); // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() != event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return !iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter contains(final IEvent... registers) { // if (registers == null) { // return NONE; // } // if (registers.length == 1) { // final WeakReference<IEvent> reference = new WeakReference<>(registers[0]); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return reference.get() == event; // } // }; // } else { // final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length)); // Collections.addAll(iEvents, registers); // return new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return iEvents.contains(event); // } // }; // } // } // // public static IEvent.Filter acceptAll() { // return ALL; // } // // private static final IEvent.Filter ALL = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // // private static final IEvent.Filter NONE = new IEvent.Filter() { // @Override // public boolean accept(IEvent event) { // return true; // } // }; // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java // @Event // public interface TestFilterEvent extends IEvent { // void onWrite(Filter filter, String text); // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Toast; import com.shizhefei.eventbus.EventBus; import com.shizhefei.eventbus.Filters; import com.shizhefei.eventbus.demo.R; import com.shizhefei.eventbusdemo.events.TestFilterEvent; package com.shizhefei.eventbusdemo; public class TestFilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_filter); findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EventBus.postMain(TestFilterEvent.class).onWrite(null, "aaaaa"); } }); findViewById(R.id.sendButton2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
EventBus.postMain(TestFilterEvent.class).onWrite(Filters.deliver(eventReceiver1), "aaaaa");
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/events/ITest2.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/IRemoteEvent.java // public interface IRemoteEvent extends IEvent { // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Person.java // public class Person extends Student{ // private int age; // private String name; // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Person(int age, String name) { // this.age = age; // this.name = name; // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Point.java // public class Point implements Parcelable{ // protected Point(Parcel in) { // } // // public static final Creator<Point> CREATOR = new Creator<Point>() { // @Override // public Point createFromParcel(Parcel in) { // return new Point(in); // } // // @Override // public Point[] newArray(int size) { // return new Point[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // } // }
import android.os.Bundle; import android.os.Parcelable; import com.shizhefei.eventbus.IRemoteEvent; import com.shizhefei.eventbusdemo.Person; import com.shizhefei.eventbusdemo.Point; import com.shizhefei.eventbus.annotation.Event;
package com.shizhefei.eventbusdemo.events; /** * Created by LuckyJayce on 2017/5/6. */ @Event public interface ITest2 extends IRemoteEvent { void write(int[] ids, String[] message, float[] prices, byte[] data);
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/IRemoteEvent.java // public interface IRemoteEvent extends IEvent { // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Person.java // public class Person extends Student{ // private int age; // private String name; // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Person(int age, String name) { // this.age = age; // this.name = name; // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Point.java // public class Point implements Parcelable{ // protected Point(Parcel in) { // } // // public static final Creator<Point> CREATOR = new Creator<Point>() { // @Override // public Point createFromParcel(Parcel in) { // return new Point(in); // } // // @Override // public Point[] newArray(int size) { // return new Point[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // } // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/ITest2.java import android.os.Bundle; import android.os.Parcelable; import com.shizhefei.eventbus.IRemoteEvent; import com.shizhefei.eventbusdemo.Person; import com.shizhefei.eventbusdemo.Point; import com.shizhefei.eventbus.annotation.Event; package com.shizhefei.eventbusdemo.events; /** * Created by LuckyJayce on 2017/5/6. */ @Event public interface ITest2 extends IRemoteEvent { void write(int[] ids, String[] message, float[] prices, byte[] data);
void onTest(int messageId, String message, Bundle data, Parcelable parcelable, Parcelable[] parcelables, Point[] name, Point point, Person person, Person[] persons);
LuckyJayce/EventBus-Apt
app/src/main/java/com/shizhefei/eventbusdemo/events/ITest2.java
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/IRemoteEvent.java // public interface IRemoteEvent extends IEvent { // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Person.java // public class Person extends Student{ // private int age; // private String name; // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Person(int age, String name) { // this.age = age; // this.name = name; // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Point.java // public class Point implements Parcelable{ // protected Point(Parcel in) { // } // // public static final Creator<Point> CREATOR = new Creator<Point>() { // @Override // public Point createFromParcel(Parcel in) { // return new Point(in); // } // // @Override // public Point[] newArray(int size) { // return new Point[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // } // }
import android.os.Bundle; import android.os.Parcelable; import com.shizhefei.eventbus.IRemoteEvent; import com.shizhefei.eventbusdemo.Person; import com.shizhefei.eventbusdemo.Point; import com.shizhefei.eventbus.annotation.Event;
package com.shizhefei.eventbusdemo.events; /** * Created by LuckyJayce on 2017/5/6. */ @Event public interface ITest2 extends IRemoteEvent { void write(int[] ids, String[] message, float[] prices, byte[] data);
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/IRemoteEvent.java // public interface IRemoteEvent extends IEvent { // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Person.java // public class Person extends Student{ // private int age; // private String name; // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Person(int age, String name) { // this.age = age; // this.name = name; // } // } // // Path: app/src/main/java/com/shizhefei/eventbusdemo/Point.java // public class Point implements Parcelable{ // protected Point(Parcel in) { // } // // public static final Creator<Point> CREATOR = new Creator<Point>() { // @Override // public Point createFromParcel(Parcel in) { // return new Point(in); // } // // @Override // public Point[] newArray(int size) { // return new Point[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // } // } // Path: app/src/main/java/com/shizhefei/eventbusdemo/events/ITest2.java import android.os.Bundle; import android.os.Parcelable; import com.shizhefei.eventbus.IRemoteEvent; import com.shizhefei.eventbusdemo.Person; import com.shizhefei.eventbusdemo.Point; import com.shizhefei.eventbus.annotation.Event; package com.shizhefei.eventbusdemo.events; /** * Created by LuckyJayce on 2017/5/6. */ @Event public interface ITest2 extends IRemoteEvent { void write(int[] ids, String[] message, float[] prices, byte[] data);
void onTest(int messageId, String message, Bundle data, Parcelable parcelable, Parcelable[] parcelables, Point[] name, Point point, Person person, Person[] persons);
SumoLogic/sumologic-jenkins-plugin
src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/sender/TimestampingOutputStream.java
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final FastDateFormat DATETIME_FORMATTER // = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss,SSS ZZZZ");
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.console.LineTransformationOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Date; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.DATETIME_FORMATTER;
package com.sumologic.jenkins.jenkinssumologicplugin.sender; /** * OutputStream decorator that for each new line in the stream additionally adds a consistent timestamp * and forwards the rest of the stream line without modifications. * <p> * Created by lukasz on 3/21/17. */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public class TimestampingOutputStream extends LineTransformationOutputStream { private final OutputStream wrappedStream; public TimestampingOutputStream(OutputStream stream) { super(); wrappedStream = stream; } /** * Heuristic used for determining multiline log messages, e.g. stack traces. * For Sumo Logic purposes only lines prefixed with timestamp will be considered a beginning of new log message. * * @param bytes - byte array containing single log line * @param i - log line length (can be less that bytes.length) * @return false if line starts with whitespace, true otherwise */ public static boolean shouldPutTimestamp(byte[] bytes, int i) { String prefix = new String(bytes, 0, Math.min(i, 4), StandardCharsets.UTF_8); return prefix.length() > 0 && !Character.isWhitespace(prefix.charAt(0)); } public static byte[] getTimestampAsByteArray(String jobName, String jobNumber) {
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final FastDateFormat DATETIME_FORMATTER // = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss,SSS ZZZZ"); // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/sender/TimestampingOutputStream.java import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.console.LineTransformationOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Date; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.DATETIME_FORMATTER; package com.sumologic.jenkins.jenkinssumologicplugin.sender; /** * OutputStream decorator that for each new line in the stream additionally adds a consistent timestamp * and forwards the rest of the stream line without modifications. * <p> * Created by lukasz on 3/21/17. */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public class TimestampingOutputStream extends LineTransformationOutputStream { private final OutputStream wrappedStream; public TimestampingOutputStream(OutputStream stream) { super(); wrappedStream = stream; } /** * Heuristic used for determining multiline log messages, e.g. stack traces. * For Sumo Logic purposes only lines prefixed with timestamp will be considered a beginning of new log message. * * @param bytes - byte array containing single log line * @param i - log line length (can be less that bytes.length) * @return false if line starts with whitespace, true otherwise */ public static boolean shouldPutTimestamp(byte[] bytes, int i) { String prefix = new String(bytes, 0, Math.min(i, 4), StandardCharsets.UTF_8); return prefix.length() > 0 && !Character.isWhitespace(prefix.charAt(0)); } public static byte[] getTimestampAsByteArray(String jobName, String jobNumber) {
String timeStampStr = "[" + DATETIME_FORMATTER.format(new Date()) + "] " + " " + jobName + "#" + jobNumber + " ";
SumoLogic/sumologic-jenkins-plugin
src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/utility/SumoPipelineLogCollection.java
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/sender/LogListener.java // @Extension(ordinal = -1) // public class LogListener extends ConsoleLogFilter implements Serializable { // // private static final long serialVersionUID = -131194971357180671L; // // private transient Run run; // // // public LogListener() { // super(); // } // // public LogListener(Run build) { // this(); // this.run = build; // //build.addAction(new SearchAction(build)); // } // // @Override // public OutputStream decorateLogger(Run build, OutputStream outputStream) { // /*try { // PluginDescriptorImpl pluginDescriptor = PluginDescriptorImpl.getInstance(); // if (!pluginDescriptor.isJobConsoleLogEnabled()) { // if (build != null) { // build.addAction(new SearchAction(build)); // return new SumologicOutputStream(outputStream, build, pluginDescriptor, streamState); // } else { // return new SumologicOutputStream(outputStream, run, pluginDescriptor, streamState); // } // } // } catch (Exception e) { // String errorMessage = CONSOLE_ERROR + Arrays.toString(e.getStackTrace()); // LOG.log(Level.WARNING, errorMessage); // outputStream.write(errorMessage.getBytes()); // }*/ // return outputStream; // } // // @Override // public OutputStream decorateLogger(@Nonnull Computer computer, OutputStream logger) { // return logger; // } // }
import com.sumologic.jenkins.jenkinssumologicplugin.sender.LogListener; import hudson.Extension; import hudson.console.ConsoleLogFilter; import hudson.model.Run; import org.jenkinsci.plugins.workflow.steps.*; import org.kohsuke.stapler.DataBoundConstructor; import javax.annotation.Nonnull; import java.io.IOException; import java.util.HashSet; import java.util.Set;
package com.sumologic.jenkins.jenkinssumologicplugin.utility; /** * Custom plugin extension step that can be used without a node and build wrapper. * <p> * Created by - Sourabh Jain 5/2019 */ public class SumoPipelineLogCollection extends Step { @DataBoundConstructor public SumoPipelineLogCollection() { } @Override public StepExecution start(StepContext context) { return new Execution(context); } /** * Execution for {@link SumoPipelineLogCollection}. */ public static class Execution extends StepExecution { private static final long serialVersionUID = 731578971545010547L; protected Execution(StepContext context) { super(context); } @Override public void onResume() { } /** * {@inheritDoc} */ @Override public boolean start() throws Exception { StepContext context = getContext(); context.newBodyInvoker(). withContext(createConsoleLogFilter(context)). withCallback(BodyExecutionCallback.wrap(context)). start(); return false; } private ConsoleLogFilter createConsoleLogFilter(StepContext context) throws IOException, InterruptedException { ConsoleLogFilter original = context.get(ConsoleLogFilter.class); Run build = context.get(Run.class);
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/sender/LogListener.java // @Extension(ordinal = -1) // public class LogListener extends ConsoleLogFilter implements Serializable { // // private static final long serialVersionUID = -131194971357180671L; // // private transient Run run; // // // public LogListener() { // super(); // } // // public LogListener(Run build) { // this(); // this.run = build; // //build.addAction(new SearchAction(build)); // } // // @Override // public OutputStream decorateLogger(Run build, OutputStream outputStream) { // /*try { // PluginDescriptorImpl pluginDescriptor = PluginDescriptorImpl.getInstance(); // if (!pluginDescriptor.isJobConsoleLogEnabled()) { // if (build != null) { // build.addAction(new SearchAction(build)); // return new SumologicOutputStream(outputStream, build, pluginDescriptor, streamState); // } else { // return new SumologicOutputStream(outputStream, run, pluginDescriptor, streamState); // } // } // } catch (Exception e) { // String errorMessage = CONSOLE_ERROR + Arrays.toString(e.getStackTrace()); // LOG.log(Level.WARNING, errorMessage); // outputStream.write(errorMessage.getBytes()); // }*/ // return outputStream; // } // // @Override // public OutputStream decorateLogger(@Nonnull Computer computer, OutputStream logger) { // return logger; // } // } // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/utility/SumoPipelineLogCollection.java import com.sumologic.jenkins.jenkinssumologicplugin.sender.LogListener; import hudson.Extension; import hudson.console.ConsoleLogFilter; import hudson.model.Run; import org.jenkinsci.plugins.workflow.steps.*; import org.kohsuke.stapler.DataBoundConstructor; import javax.annotation.Nonnull; import java.io.IOException; import java.util.HashSet; import java.util.Set; package com.sumologic.jenkins.jenkinssumologicplugin.utility; /** * Custom plugin extension step that can be used without a node and build wrapper. * <p> * Created by - Sourabh Jain 5/2019 */ public class SumoPipelineLogCollection extends Step { @DataBoundConstructor public SumoPipelineLogCollection() { } @Override public StepExecution start(StepContext context) { return new Execution(context); } /** * Execution for {@link SumoPipelineLogCollection}. */ public static class Execution extends StepExecution { private static final long serialVersionUID = 731578971545010547L; protected Execution(StepContext context) { super(context); } @Override public void onResume() { } /** * {@inheritDoc} */ @Override public boolean start() throws Exception { StepContext context = getContext(); context.newBodyInvoker(). withContext(createConsoleLogFilter(context)). withCallback(BodyExecutionCallback.wrap(context)). start(); return false; } private ConsoleLogFilter createConsoleLogFilter(StepContext context) throws IOException, InterruptedException { ConsoleLogFilter original = context.get(ConsoleLogFilter.class); Run build = context.get(Run.class);
ConsoleLogFilter subsequent = new LogListener(build);
SumoLogic/sumologic-jenkins-plugin
src/test/java/com/sumologic/jenkins/jenkinssumologicplugin/ModelFactoryTest.java
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/model/ModelFactory.java // public class ModelFactory { // // public static JenkinsModel createJenkinsModel(Jenkins jenkins) { // Queue queue = jenkins.getQueue(); // final Queue.Item[] items = queue.getItems(); // long maxwait = 0, now = System.currentTimeMillis(); // for (Queue.Item item : items) { // long waiting = now - item.getInQueueSince(); // maxwait = Math.max(maxwait, waiting); // } // // QueueModel queueModel = new QueueModel(); // // int numFreeExecutors = 0; // // for (Computer computer : jenkins.getComputers()) { // if (computer.isOnline()) { // numFreeExecutors += computer.countIdle(); // } // // } // AgentModel agentModel = new AgentModel(jenkins.getNumExecutors(), numFreeExecutors); // // return new JenkinsModel(queueModel, agentModel, jenkins.getDescription()); // } // // public static BuildModel createBuildModel(Run build, PluginDescriptorImpl pluginDescriptor) { // BuildModel buildModel; // if (build instanceof MavenModuleSetBuild) { // MavenModuleSetBuildModel mBuildModel = new MavenModuleSetBuildModel(); // CommonModelFactory.populateGeneric(mBuildModel, build, pluginDescriptor, false); // MavenModuleSetBuild mbuild = (MavenModuleSetBuild) build; // SurefireAggregatedReport surefireAggregatedReport = mbuild.getAction(SurefireAggregatedReport.class); // if (surefireAggregatedReport != null) { // mBuildModel.setTotalTestCount(surefireAggregatedReport.getTotalCount()); // mBuildModel.setFailedTestCount(surefireAggregatedReport.getFailCount()); // mBuildModel.setSkippedTestCount(surefireAggregatedReport.getSkipCount()); // for (TestResult result : surefireAggregatedReport.getFailedTests()) { // mBuildModel.addFailedTest(result.getDisplayName()); // } // } // Map<MavenModule, MavenBuild> modules = mbuild.getModuleLastBuilds(); // // for (MavenBuild module : modules.values()) { // mBuildModel.addModule((MavenModuleBuildModel) createBuildModel(module, pluginDescriptor)); // } // buildModel = mBuildModel; // } else if (build instanceof MavenBuild) { // MavenBuild mbuild = (MavenBuild) build; // MavenModuleBuildModel mBuildModel = new MavenModuleBuildModel(); // CommonModelFactory.populateGeneric(mBuildModel, mbuild, pluginDescriptor, false); // buildModel = mBuildModel; // } else { // buildModel = new BuildModel(); // CommonModelFactory.populateGeneric(buildModel, build, pluginDescriptor, false); // } // return buildModel; // } // }
import com.sumologic.jenkins.jenkinssumologicplugin.model.ModelFactory; import hudson.model.FreeStyleBuild; import hudson.model.FreeStyleProject; import hudson.model.Hudson; import hudson.model.Result; import org.hamcrest.MatcherAssert; import org.hamcrest.core.StringContains; import org.junit.Test; import java.util.GregorianCalendar;
package com.sumologic.jenkins.jenkinssumologicplugin; public class ModelFactoryTest extends BaseTest { @Test public void testGenerateBuildModelForAbstractBuild() throws Exception { final String name = "MockJob"; GregorianCalendar c = new GregorianCalendar(); final int number = 101; Result result = Result.SUCCESS; FreeStyleProject project = j.createFreeStyleProject(name); project.getPublishersList().add(new SumoBuildNotifier()); FreeStyleBuild build = project.scheduleBuild2(0).get(); String jsonExpected = "\"result\":\"SUCCESS\",\"number\":1,"; String replace = jsonExpected.replace("?", Hudson.getVersion().toString());
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/model/ModelFactory.java // public class ModelFactory { // // public static JenkinsModel createJenkinsModel(Jenkins jenkins) { // Queue queue = jenkins.getQueue(); // final Queue.Item[] items = queue.getItems(); // long maxwait = 0, now = System.currentTimeMillis(); // for (Queue.Item item : items) { // long waiting = now - item.getInQueueSince(); // maxwait = Math.max(maxwait, waiting); // } // // QueueModel queueModel = new QueueModel(); // // int numFreeExecutors = 0; // // for (Computer computer : jenkins.getComputers()) { // if (computer.isOnline()) { // numFreeExecutors += computer.countIdle(); // } // // } // AgentModel agentModel = new AgentModel(jenkins.getNumExecutors(), numFreeExecutors); // // return new JenkinsModel(queueModel, agentModel, jenkins.getDescription()); // } // // public static BuildModel createBuildModel(Run build, PluginDescriptorImpl pluginDescriptor) { // BuildModel buildModel; // if (build instanceof MavenModuleSetBuild) { // MavenModuleSetBuildModel mBuildModel = new MavenModuleSetBuildModel(); // CommonModelFactory.populateGeneric(mBuildModel, build, pluginDescriptor, false); // MavenModuleSetBuild mbuild = (MavenModuleSetBuild) build; // SurefireAggregatedReport surefireAggregatedReport = mbuild.getAction(SurefireAggregatedReport.class); // if (surefireAggregatedReport != null) { // mBuildModel.setTotalTestCount(surefireAggregatedReport.getTotalCount()); // mBuildModel.setFailedTestCount(surefireAggregatedReport.getFailCount()); // mBuildModel.setSkippedTestCount(surefireAggregatedReport.getSkipCount()); // for (TestResult result : surefireAggregatedReport.getFailedTests()) { // mBuildModel.addFailedTest(result.getDisplayName()); // } // } // Map<MavenModule, MavenBuild> modules = mbuild.getModuleLastBuilds(); // // for (MavenBuild module : modules.values()) { // mBuildModel.addModule((MavenModuleBuildModel) createBuildModel(module, pluginDescriptor)); // } // buildModel = mBuildModel; // } else if (build instanceof MavenBuild) { // MavenBuild mbuild = (MavenBuild) build; // MavenModuleBuildModel mBuildModel = new MavenModuleBuildModel(); // CommonModelFactory.populateGeneric(mBuildModel, mbuild, pluginDescriptor, false); // buildModel = mBuildModel; // } else { // buildModel = new BuildModel(); // CommonModelFactory.populateGeneric(buildModel, build, pluginDescriptor, false); // } // return buildModel; // } // } // Path: src/test/java/com/sumologic/jenkins/jenkinssumologicplugin/ModelFactoryTest.java import com.sumologic.jenkins.jenkinssumologicplugin.model.ModelFactory; import hudson.model.FreeStyleBuild; import hudson.model.FreeStyleProject; import hudson.model.Hudson; import hudson.model.Result; import org.hamcrest.MatcherAssert; import org.hamcrest.core.StringContains; import org.junit.Test; import java.util.GregorianCalendar; package com.sumologic.jenkins.jenkinssumologicplugin; public class ModelFactoryTest extends BaseTest { @Test public void testGenerateBuildModelForAbstractBuild() throws Exception { final String name = "MockJob"; GregorianCalendar c = new GregorianCalendar(); final int number = 101; Result result = Result.SUCCESS; FreeStyleProject project = j.createFreeStyleProject(name); project.getPublishersList().add(new SumoBuildNotifier()); FreeStyleBuild build = project.scheduleBuild2(0).get(); String jsonExpected = "\"result\":\"SUCCESS\",\"number\":1,"; String replace = jsonExpected.replace("?", Hudson.getVersion().toString());
String json = ModelFactory.createBuildModel(build, (PluginDescriptorImpl) j.getInstance().getDescriptor(SumoBuildNotifier.class)).toJson();
SumoLogic/sumologic-jenkins-plugin
src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/pipeline/ExecutionNodeExtractor.java
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/ParallelNodeTypeEnum.java // public enum ParallelNodeTypeEnum { // NORMAL, // PARALLEL_START, // PARALLEL_END, // PARALLEL_BRANCH_START, // PARALLEL_BRANCH_END, // } // // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final String JENKINS_MAIN = "(master)";
import com.cloudbees.workflow.rest.external.ChunkVisitor; import com.sumologic.jenkins.jenkinssumologicplugin.constants.ParallelNodeTypeEnum; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.actions.WorkspaceAction; import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode; import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode; import org.jenkinsci.plugins.workflow.graph.FlowNode; import org.jenkinsci.plugins.workflow.graph.FlowStartNode; import org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.JENKINS_MAIN;
} Map<String, String> getWorkspaceNodes() { return workspaceNodes; } Map<String, Set<String>> getParallelNodes() { return parallelNodes; } @Override public void atomNode(@CheckForNull FlowNode before, @Nonnull FlowNode atomNode, @CheckForNull FlowNode after, @Nonnull ForkScanner scan) { try { findWhereCurrentNodeIsExecuting(atomNode); findParallelNode(scan, atomNode); } catch (Exception ex) { LOG.log(Level.WARNING, "failed to extract plugin extension info", ex); } super.atomNode(before, atomNode, after, scan); } private void findWhereCurrentNodeIsExecuting(FlowNode atomNode) { if (execNodeName == null) { StepStartNode nodeStep = getPipelineBlockBoundaryStartNode(atomNode); if (nodeStep != null) { WorkspaceAction workspaceAction = nodeStep.getPersistentAction(WorkspaceAction.class); if (workspaceAction != null) { execNodeName = workspaceAction.getNode(); execNodeStartId = nodeStep.getId(); if (StringUtils.isEmpty(execNodeName)) {
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/ParallelNodeTypeEnum.java // public enum ParallelNodeTypeEnum { // NORMAL, // PARALLEL_START, // PARALLEL_END, // PARALLEL_BRANCH_START, // PARALLEL_BRANCH_END, // } // // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final String JENKINS_MAIN = "(master)"; // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/pipeline/ExecutionNodeExtractor.java import com.cloudbees.workflow.rest.external.ChunkVisitor; import com.sumologic.jenkins.jenkinssumologicplugin.constants.ParallelNodeTypeEnum; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.actions.WorkspaceAction; import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode; import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode; import org.jenkinsci.plugins.workflow.graph.FlowNode; import org.jenkinsci.plugins.workflow.graph.FlowStartNode; import org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.JENKINS_MAIN; } Map<String, String> getWorkspaceNodes() { return workspaceNodes; } Map<String, Set<String>> getParallelNodes() { return parallelNodes; } @Override public void atomNode(@CheckForNull FlowNode before, @Nonnull FlowNode atomNode, @CheckForNull FlowNode after, @Nonnull ForkScanner scan) { try { findWhereCurrentNodeIsExecuting(atomNode); findParallelNode(scan, atomNode); } catch (Exception ex) { LOG.log(Level.WARNING, "failed to extract plugin extension info", ex); } super.atomNode(before, atomNode, after, scan); } private void findWhereCurrentNodeIsExecuting(FlowNode atomNode) { if (execNodeName == null) { StepStartNode nodeStep = getPipelineBlockBoundaryStartNode(atomNode); if (nodeStep != null) { WorkspaceAction workspaceAction = nodeStep.getPersistentAction(WorkspaceAction.class); if (workspaceAction != null) { execNodeName = workspaceAction.getNode(); execNodeStartId = nodeStep.getId(); if (StringUtils.isEmpty(execNodeName)) {
execNodeName = JENKINS_MAIN;
SumoLogic/sumologic-jenkins-plugin
src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/pipeline/ExecutionNodeExtractor.java
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/ParallelNodeTypeEnum.java // public enum ParallelNodeTypeEnum { // NORMAL, // PARALLEL_START, // PARALLEL_END, // PARALLEL_BRANCH_START, // PARALLEL_BRANCH_END, // } // // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final String JENKINS_MAIN = "(master)";
import com.cloudbees.workflow.rest.external.ChunkVisitor; import com.sumologic.jenkins.jenkinssumologicplugin.constants.ParallelNodeTypeEnum; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.actions.WorkspaceAction; import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode; import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode; import org.jenkinsci.plugins.workflow.graph.FlowNode; import org.jenkinsci.plugins.workflow.graph.FlowStartNode; import org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.JENKINS_MAIN;
findWhereCurrentNodeIsExecuting(atomNode); findParallelNode(scan, atomNode); } catch (Exception ex) { LOG.log(Level.WARNING, "failed to extract plugin extension info", ex); } super.atomNode(before, atomNode, after, scan); } private void findWhereCurrentNodeIsExecuting(FlowNode atomNode) { if (execNodeName == null) { StepStartNode nodeStep = getPipelineBlockBoundaryStartNode(atomNode); if (nodeStep != null) { WorkspaceAction workspaceAction = nodeStep.getPersistentAction(WorkspaceAction.class); if (workspaceAction != null) { execNodeName = workspaceAction.getNode(); execNodeStartId = nodeStep.getId(); if (StringUtils.isEmpty(execNodeName)) { execNodeName = JENKINS_MAIN; } } } } else if (atomNode instanceof StepStartNode && atomNode.getId().equals(execNodeStartId)) { execNodeName = null; } if (execNodeName != null) { workspaceNodes.put(atomNode.getId(), execNodeName); } } private void findParallelNode(@Nonnull ForkScanner scan, FlowNode atomNode) {
// Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/ParallelNodeTypeEnum.java // public enum ParallelNodeTypeEnum { // NORMAL, // PARALLEL_START, // PARALLEL_END, // PARALLEL_BRANCH_START, // PARALLEL_BRANCH_END, // } // // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/constants/SumoConstants.java // public static final String JENKINS_MAIN = "(master)"; // Path: src/main/java/com/sumologic/jenkins/jenkinssumologicplugin/pipeline/ExecutionNodeExtractor.java import com.cloudbees.workflow.rest.external.ChunkVisitor; import com.sumologic.jenkins.jenkinssumologicplugin.constants.ParallelNodeTypeEnum; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.actions.WorkspaceAction; import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode; import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode; import org.jenkinsci.plugins.workflow.graph.FlowNode; import org.jenkinsci.plugins.workflow.graph.FlowStartNode; import org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import static com.sumologic.jenkins.jenkinssumologicplugin.constants.SumoConstants.JENKINS_MAIN; findWhereCurrentNodeIsExecuting(atomNode); findParallelNode(scan, atomNode); } catch (Exception ex) { LOG.log(Level.WARNING, "failed to extract plugin extension info", ex); } super.atomNode(before, atomNode, after, scan); } private void findWhereCurrentNodeIsExecuting(FlowNode atomNode) { if (execNodeName == null) { StepStartNode nodeStep = getPipelineBlockBoundaryStartNode(atomNode); if (nodeStep != null) { WorkspaceAction workspaceAction = nodeStep.getPersistentAction(WorkspaceAction.class); if (workspaceAction != null) { execNodeName = workspaceAction.getNode(); execNodeStartId = nodeStep.getId(); if (StringUtils.isEmpty(execNodeName)) { execNodeName = JENKINS_MAIN; } } } } else if (atomNode instanceof StepStartNode && atomNode.getId().equals(execNodeStartId)) { execNodeName = null; } if (execNodeName != null) { workspaceNodes.put(atomNode.getId(), execNodeName); } } private void findParallelNode(@Nonnull ForkScanner scan, FlowNode atomNode) {
if (ParallelNodeTypeEnum.NORMAL.toString().equals(String.valueOf(scan.getCurrentType()))
ryft/NetVis
workspace/netvis/src/netvis/visualisations/gameengine/Node.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // }
import java.awt.event.MouseEvent; import javax.media.opengl.GL2; import netvis.data.model.Packet;
package netvis.visualisations.gameengine; public abstract class Node { private String name = null; public String GetName() {return name;} public void SetName(String n) {name = n;} public Node(String nam) { name = nam; } public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); } Node parent; public Node GetParent() { return parent; } public void SetParent (Node par) { parent = par; } // Defaultly a node is a singular hexagon public int getDimenstion () {return 1;} public int getCapacity () {return 1;} public Node GetNode (String name) {return null;} public void DetachNode (Node n) {}; public Node GetClickedNode (int base, Position deltacoord) { if (deltacoord.x == 0 && deltacoord.y == 0) return this; else return null; } public boolean AddNode (String name, Node n) {return false;}
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java import java.awt.event.MouseEvent; import javax.media.opengl.GL2; import netvis.data.model.Packet; package netvis.visualisations.gameengine; public abstract class Node { private String name = null; public String GetName() {return name;} public void SetName(String n) {name = n;} public Node(String nam) { name = nam; } public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); } Node parent; public Node GetParent() { return parent; } public void SetParent (Node par) { parent = par; } // Defaultly a node is a singular hexagon public int getDimenstion () {return 1;} public int getCapacity () {return 1;} public Node GetNode (String name) {return null;} public void DetachNode (Node n) {}; public Node GetClickedNode (int base, Position deltacoord) { if (deltacoord.x == 0 && deltacoord.y == 0) return this; else return null; } public boolean AddNode (String name, Node n) {return false;}
public abstract void UpdateWithData (Packet pp);
ryft/NetVis
workspace/netvis/src/netvis/data/filters/NormalisationFilter.java
// Path: workspace/netvis/src/netvis/data/NormaliseFactory.java // public abstract class Normaliser { // double lowerBound = 0, upperBound = 1; // NormalisationFilter myFilter = null; // protected abstract double normaliseFunction(Packet p); // protected abstract String denormaliseFunction (double v); // public abstract String name(); // public double normalise(Packet p){ // double v = this.normaliseFunction(p); // v = (v - lowerBound)/(upperBound - lowerBound); // //System.out.println(lowerBound); // //System.out.println(v); // // return v; // } // public String denormalise(double v){ // v = v * (upperBound - lowerBound); // v += lowerBound; // return denormaliseFunction(v); // } // public void filter(double lowerBound, double upperBound){ // double interval = this.upperBound - this.lowerBound; // this.upperBound = this.lowerBound + upperBound*interval; // if (this.upperBound > 1) this.upperBound = 1; // this.lowerBound += lowerBound*interval; // if (this.lowerBound < 0) this.lowerBound = 0; // if (myFilter != null) // dataController.removeFilter(myFilter); // myFilter = new NormalisationFilter(this); // dataController.addFilter(myFilter); // } // public void clearFilter() { // this.lowerBound = 0; // this.upperBound = 1; // dataController.removeFilter(myFilter); // myFilter = null; // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // }
import netvis.data.NormaliseFactory.Normaliser; import netvis.data.model.Packet;
package netvis.data.filters; public class NormalisationFilter extends FixedFilter{ private final Normaliser norm; public NormalisationFilter(Normaliser norm){ super("<html>" + norm.name() + ":<br>" + String.valueOf(norm.denormalise(0)) + "-" + String.valueOf(norm.denormalise(1))+ "</html>"); this.norm = norm; } @Override
// Path: workspace/netvis/src/netvis/data/NormaliseFactory.java // public abstract class Normaliser { // double lowerBound = 0, upperBound = 1; // NormalisationFilter myFilter = null; // protected abstract double normaliseFunction(Packet p); // protected abstract String denormaliseFunction (double v); // public abstract String name(); // public double normalise(Packet p){ // double v = this.normaliseFunction(p); // v = (v - lowerBound)/(upperBound - lowerBound); // //System.out.println(lowerBound); // //System.out.println(v); // // return v; // } // public String denormalise(double v){ // v = v * (upperBound - lowerBound); // v += lowerBound; // return denormaliseFunction(v); // } // public void filter(double lowerBound, double upperBound){ // double interval = this.upperBound - this.lowerBound; // this.upperBound = this.lowerBound + upperBound*interval; // if (this.upperBound > 1) this.upperBound = 1; // this.lowerBound += lowerBound*interval; // if (this.lowerBound < 0) this.lowerBound = 0; // if (myFilter != null) // dataController.removeFilter(myFilter); // myFilter = new NormalisationFilter(this); // dataController.addFilter(myFilter); // } // public void clearFilter() { // this.lowerBound = 0; // this.upperBound = 1; // dataController.removeFilter(myFilter); // myFilter = null; // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // Path: workspace/netvis/src/netvis/data/filters/NormalisationFilter.java import netvis.data.NormaliseFactory.Normaliser; import netvis.data.model.Packet; package netvis.data.filters; public class NormalisationFilter extends FixedFilter{ private final Normaliser norm; public NormalisationFilter(Normaliser norm){ super("<html>" + norm.name() + ":<br>" + String.valueOf(norm.denormalise(0)) + "-" + String.valueOf(norm.denormalise(1))+ "</html>"); this.norm = norm; } @Override
public boolean filter(Packet packet) {
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/Candidate.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // }
import java.util.ArrayList; import netvis.data.model.Packet;
package netvis.visualisations.comets; public class Candidate { // How close the client is to the internal network 0-closest 10-furthest public int proximity; // How much data it send throughout the last interval public int datasize; // Source and destination public String sip, dip;
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // Path: workspace/netvis/src/netvis/visualisations/comets/Candidate.java import java.util.ArrayList; import netvis.data.model.Packet; package netvis.visualisations.comets; public class Candidate { // How close the client is to the internal network 0-closest 10-furthest public int proximity; // How much data it send throughout the last interval public int datasize; // Source and destination public String sip, dip;
private ArrayList<Packet> plist;
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/HeatNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter;
long maxVal = 0; public String maxProto = ""; public HeatNode (String tname, String nname) { super (nname); // Cumulating time cumultime = 0; // How much data was transferred data = 0; tex = tname; bgColor = new double[3]; opacity = 1.0; // Set the background color bgColor[0] = 0.5; bgColor[1] = 1.0; bgColor[2] = 0.7; warning = 0; selected = false; protocollengths = new HashMap<String, Long> (); } @Override
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/HeatNode.java import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter; long maxVal = 0; public String maxProto = ""; public HeatNode (String tname, String nname) { super (nname); // Cumulating time cumultime = 0; // How much data was transferred data = 0; tex = tname; bgColor = new double[3]; opacity = 1.0; // Set the background color bgColor[0] = 0.5; bgColor[1] = 1.0; bgColor[2] = 0.7; warning = 0; selected = false; protocollengths = new HashMap<String, Long> (); } @Override
public void Draw(int base, NodePainter painter, GL2 gl) {
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/HeatNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter;
super (nname); // Cumulating time cumultime = 0; // How much data was transferred data = 0; tex = tname; bgColor = new double[3]; opacity = 1.0; // Set the background color bgColor[0] = 0.5; bgColor[1] = 1.0; bgColor[2] = 0.7; warning = 0; selected = false; protocollengths = new HashMap<String, Long> (); } @Override public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); } @Override
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/HeatNode.java import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter; super (nname); // Cumulating time cumultime = 0; // How much data was transferred data = 0; tex = tname; bgColor = new double[3]; opacity = 1.0; // Set the background color bgColor[0] = 0.5; bgColor[1] = 1.0; bgColor[2] = 0.7; warning = 0; selected = false; protocollengths = new HashMap<String, Long> (); } @Override public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); } @Override
public void UpdateWithData(Packet pp) {
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/CometHeatNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.Collection; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.NodePainter;
package netvis.visualisations.comets; public class CometHeatNode extends HeatNode { HashMap<String, Comet> entities; public Collection<Comet> getEntities() { return entities.values(); } boolean changed = true; public CometHeatNode(String texturename, String nodename) { super (texturename, nodename); entities = new HashMap<String, Comet>(); }
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/CometHeatNode.java import java.awt.event.MouseEvent; import java.util.Collection; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.NodePainter; package netvis.visualisations.comets; public class CometHeatNode extends HeatNode { HashMap<String, Comet> entities; public Collection<Comet> getEntities() { return entities.values(); } boolean changed = true; public CometHeatNode(String texturename, String nodename) { super (texturename, nodename); entities = new HashMap<String, Comet>(); }
public void Draw(int base, NodePainter painter, GL2 gl) {
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/CometHeatNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.Collection; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.NodePainter;
package netvis.visualisations.comets; public class CometHeatNode extends HeatNode { HashMap<String, Comet> entities; public Collection<Comet> getEntities() { return entities.values(); } boolean changed = true; public CometHeatNode(String texturename, String nodename) { super (texturename, nodename); entities = new HashMap<String, Comet>(); } public void Draw(int base, NodePainter painter, GL2 gl) { // Draw one on top of the other painter.DrawNode(base, (HeatNode) this, gl); painter.DrawNode(base, (CometHeatNode) this, gl); }
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/CometHeatNode.java import java.awt.event.MouseEvent; import java.util.Collection; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.NodePainter; package netvis.visualisations.comets; public class CometHeatNode extends HeatNode { HashMap<String, Comet> entities; public Collection<Comet> getEntities() { return entities.values(); } boolean changed = true; public CometHeatNode(String texturename, String nodename) { super (texturename, nodename); entities = new HashMap<String, Comet>(); } public void Draw(int base, NodePainter painter, GL2 gl) { // Draw one on top of the other painter.DrawNode(base, (HeatNode) this, gl); painter.DrawNode(base, (CometHeatNode) this, gl); }
public void UpdateWithData(Packet pp) {
ryft/NetVis
workspace/netvis/src/netvis/ui/OpenGLPanel.java
// Path: workspace/netvis/src/netvis/visualisations/Visualisation.java // public abstract class Visualisation extends GLJPanel implements DataControllerListener, // GLEventListener { // // private static final long serialVersionUID = 1L; // final List<Packet> listOfPackets; // List<Packet> newPackets; // final OpenGLPanel joglPanel; // final DataController dataController; // // FPSAnimator fpskeep; // // boolean allDataChanged; // JPanel visControls; // final VisControlsContainer visContainer; // // public Visualisation(DataController dataController, OpenGLPanel joglPanel, // VisControlsContainer visControlsContainer) { // // super(CreateCapabilities()); // // this.setPreferredSize(new Dimension(800, 500)); // this.setSize(800, 500); // this.setFocusable(true); // // this.addGLEventListener(this); // // dataController.addListener(this); // this.listOfPackets = dataController.getPackets(); // this.newPackets = new ArrayList<Packet>(); // this.dataController = dataController; // this.joglPanel = joglPanel; // this.visControls = this.createControls(); // this.visContainer = visControlsContainer; // // // Create the timer that will keep the FPS - don't start it yet // this.fpskeep = new FPSAnimator(this, 600); // } // // private static GLCapabilitiesImmutable CreateCapabilities() { // GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); // //caps.setSampleBuffers (true); // //caps.setNumSamples (2); // // return caps; // } // // protected abstract JPanel createControls(); // // @Override // public void allDataChanged(List<Packet> allPackets, int updateInterval, int intervalsComplete) { // if (joglPanel.getVis() == this) { // this.newPackets = allPackets; // this.allDataChanged = true; // //this.display(); // } // } // // @Override // public void newPacketsArrived(List<Packet> newPackets) { // if (joglPanel.getVis() == this) { // this.newPackets = newPackets; // } // } // // public void activate() { // joglPanel.setVis(this); // visContainer.setVisControl(visControls); // this.newPackets = this.listOfPackets; // allDataChanged = true; // // // Start the FPSAnimator to keep the framerate around 120 // System.setProperty("sun.awt.noerasebackground", "true"); // // // this.fpskeep.add(this); // this.fpskeep.start(); // } // // public void deactivate() { // this.fpskeep.stop(); // } // // protected void render() { // this.display(); // allDataChanged = false; // } // // public abstract String getName(); // // public abstract String getDescription(); // // public void everythingEnds() { // this.destroy(); // this.fpskeep.stop(); // } // // public void setState(int insideI) {} // }
import javax.swing.JPanel; import netvis.visualisations.Visualisation;
package netvis.ui; public class OpenGLPanel extends JPanel { private static final long serialVersionUID = 1L;
// Path: workspace/netvis/src/netvis/visualisations/Visualisation.java // public abstract class Visualisation extends GLJPanel implements DataControllerListener, // GLEventListener { // // private static final long serialVersionUID = 1L; // final List<Packet> listOfPackets; // List<Packet> newPackets; // final OpenGLPanel joglPanel; // final DataController dataController; // // FPSAnimator fpskeep; // // boolean allDataChanged; // JPanel visControls; // final VisControlsContainer visContainer; // // public Visualisation(DataController dataController, OpenGLPanel joglPanel, // VisControlsContainer visControlsContainer) { // // super(CreateCapabilities()); // // this.setPreferredSize(new Dimension(800, 500)); // this.setSize(800, 500); // this.setFocusable(true); // // this.addGLEventListener(this); // // dataController.addListener(this); // this.listOfPackets = dataController.getPackets(); // this.newPackets = new ArrayList<Packet>(); // this.dataController = dataController; // this.joglPanel = joglPanel; // this.visControls = this.createControls(); // this.visContainer = visControlsContainer; // // // Create the timer that will keep the FPS - don't start it yet // this.fpskeep = new FPSAnimator(this, 600); // } // // private static GLCapabilitiesImmutable CreateCapabilities() { // GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); // //caps.setSampleBuffers (true); // //caps.setNumSamples (2); // // return caps; // } // // protected abstract JPanel createControls(); // // @Override // public void allDataChanged(List<Packet> allPackets, int updateInterval, int intervalsComplete) { // if (joglPanel.getVis() == this) { // this.newPackets = allPackets; // this.allDataChanged = true; // //this.display(); // } // } // // @Override // public void newPacketsArrived(List<Packet> newPackets) { // if (joglPanel.getVis() == this) { // this.newPackets = newPackets; // } // } // // public void activate() { // joglPanel.setVis(this); // visContainer.setVisControl(visControls); // this.newPackets = this.listOfPackets; // allDataChanged = true; // // // Start the FPSAnimator to keep the framerate around 120 // System.setProperty("sun.awt.noerasebackground", "true"); // // // this.fpskeep.add(this); // this.fpskeep.start(); // } // // public void deactivate() { // this.fpskeep.stop(); // } // // protected void render() { // this.display(); // allDataChanged = false; // } // // public abstract String getName(); // // public abstract String getDescription(); // // public void everythingEnds() { // this.destroy(); // this.fpskeep.stop(); // } // // public void setState(int insideI) {} // } // Path: workspace/netvis/src/netvis/ui/OpenGLPanel.java import javax.swing.JPanel; import netvis.visualisations.Visualisation; package netvis.ui; public class OpenGLPanel extends JPanel { private static final long serialVersionUID = 1L;
private Visualisation currentVis;
ryft/NetVis
workspace/netvis/src/netvis/data/NormaliseFactory.java
// Path: workspace/netvis/src/netvis/data/filters/NormalisationFilter.java // public class NormalisationFilter extends FixedFilter{ // // private final Normaliser norm; // public NormalisationFilter(Normaliser norm){ // super("<html>" + norm.name() + ":<br>" + // String.valueOf(norm.denormalise(0)) + "-" + // String.valueOf(norm.denormalise(1))+ "</html>"); // // this.norm = norm; // } // @Override // public boolean filter(Packet packet) { // double v = norm.normalise(packet); // return (v <= 1 && v >= 0); // } // @Override // protected void clearFilter() { // this.norm.clearFilter(); // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // }
import java.util.ArrayList; import java.util.List; import netvis.data.filters.NormalisationFilter; import netvis.data.model.Packet;
package netvis.data; /** * A helper function that creates classes which return a certain normalised * parameter of the packet */ public class NormaliseFactory { public static final NormaliseFactory INSTANCE = new NormaliseFactory(); List<Normaliser> normalisers; private DataController dataController; private NormaliseFactory() { normalisers = new ArrayList<Normaliser>(); normalisers.add(new SourceMACNorm()); normalisers.add(new SourceIPNorm()); normalisers.add(new SourcePortNorm()); normalisers.add(new DestinationPortNorm()); normalisers.add(new DestinationIPNorm()); normalisers.add(new DestinationMACNorm()); normalisers.add(new ProtocolNorm()); } public List<Normaliser> getNormalisers() { return normalisers; } public int getIndex(Normaliser n){ return normalisers.lastIndexOf(n); } public Normaliser getNormaliser(int norm_id) { if (norm_id < normalisers.size()) return normalisers.get(norm_id); else return null; } public abstract class Normaliser { double lowerBound = 0, upperBound = 1;
// Path: workspace/netvis/src/netvis/data/filters/NormalisationFilter.java // public class NormalisationFilter extends FixedFilter{ // // private final Normaliser norm; // public NormalisationFilter(Normaliser norm){ // super("<html>" + norm.name() + ":<br>" + // String.valueOf(norm.denormalise(0)) + "-" + // String.valueOf(norm.denormalise(1))+ "</html>"); // // this.norm = norm; // } // @Override // public boolean filter(Packet packet) { // double v = norm.normalise(packet); // return (v <= 1 && v >= 0); // } // @Override // protected void clearFilter() { // this.norm.clearFilter(); // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // Path: workspace/netvis/src/netvis/data/NormaliseFactory.java import java.util.ArrayList; import java.util.List; import netvis.data.filters.NormalisationFilter; import netvis.data.model.Packet; package netvis.data; /** * A helper function that creates classes which return a certain normalised * parameter of the packet */ public class NormaliseFactory { public static final NormaliseFactory INSTANCE = new NormaliseFactory(); List<Normaliser> normalisers; private DataController dataController; private NormaliseFactory() { normalisers = new ArrayList<Normaliser>(); normalisers.add(new SourceMACNorm()); normalisers.add(new SourceIPNorm()); normalisers.add(new SourcePortNorm()); normalisers.add(new DestinationPortNorm()); normalisers.add(new DestinationIPNorm()); normalisers.add(new DestinationMACNorm()); normalisers.add(new ProtocolNorm()); } public List<Normaliser> getNormalisers() { return normalisers; } public int getIndex(Normaliser n){ return normalisers.lastIndexOf(n); } public Normaliser getNormaliser(int norm_id) { if (norm_id < normalisers.size()) return normalisers.get(norm_id); else return null; } public abstract class Normaliser { double lowerBound = 0, upperBound = 1;
NormalisationFilter myFilter = null;
ryft/NetVis
workspace/netvis/src/netvis/data/NormaliseFactory.java
// Path: workspace/netvis/src/netvis/data/filters/NormalisationFilter.java // public class NormalisationFilter extends FixedFilter{ // // private final Normaliser norm; // public NormalisationFilter(Normaliser norm){ // super("<html>" + norm.name() + ":<br>" + // String.valueOf(norm.denormalise(0)) + "-" + // String.valueOf(norm.denormalise(1))+ "</html>"); // // this.norm = norm; // } // @Override // public boolean filter(Packet packet) { // double v = norm.normalise(packet); // return (v <= 1 && v >= 0); // } // @Override // protected void clearFilter() { // this.norm.clearFilter(); // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // }
import java.util.ArrayList; import java.util.List; import netvis.data.filters.NormalisationFilter; import netvis.data.model.Packet;
package netvis.data; /** * A helper function that creates classes which return a certain normalised * parameter of the packet */ public class NormaliseFactory { public static final NormaliseFactory INSTANCE = new NormaliseFactory(); List<Normaliser> normalisers; private DataController dataController; private NormaliseFactory() { normalisers = new ArrayList<Normaliser>(); normalisers.add(new SourceMACNorm()); normalisers.add(new SourceIPNorm()); normalisers.add(new SourcePortNorm()); normalisers.add(new DestinationPortNorm()); normalisers.add(new DestinationIPNorm()); normalisers.add(new DestinationMACNorm()); normalisers.add(new ProtocolNorm()); } public List<Normaliser> getNormalisers() { return normalisers; } public int getIndex(Normaliser n){ return normalisers.lastIndexOf(n); } public Normaliser getNormaliser(int norm_id) { if (norm_id < normalisers.size()) return normalisers.get(norm_id); else return null; } public abstract class Normaliser { double lowerBound = 0, upperBound = 1; NormalisationFilter myFilter = null;
// Path: workspace/netvis/src/netvis/data/filters/NormalisationFilter.java // public class NormalisationFilter extends FixedFilter{ // // private final Normaliser norm; // public NormalisationFilter(Normaliser norm){ // super("<html>" + norm.name() + ":<br>" + // String.valueOf(norm.denormalise(0)) + "-" + // String.valueOf(norm.denormalise(1))+ "</html>"); // // this.norm = norm; // } // @Override // public boolean filter(Packet packet) { // double v = norm.normalise(packet); // return (v <= 1 && v >= 0); // } // @Override // protected void clearFilter() { // this.norm.clearFilter(); // } // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // Path: workspace/netvis/src/netvis/data/NormaliseFactory.java import java.util.ArrayList; import java.util.List; import netvis.data.filters.NormalisationFilter; import netvis.data.model.Packet; package netvis.data; /** * A helper function that creates classes which return a certain normalised * parameter of the packet */ public class NormaliseFactory { public static final NormaliseFactory INSTANCE = new NormaliseFactory(); List<Normaliser> normalisers; private DataController dataController; private NormaliseFactory() { normalisers = new ArrayList<Normaliser>(); normalisers.add(new SourceMACNorm()); normalisers.add(new SourceIPNorm()); normalisers.add(new SourcePortNorm()); normalisers.add(new DestinationPortNorm()); normalisers.add(new DestinationIPNorm()); normalisers.add(new DestinationMACNorm()); normalisers.add(new ProtocolNorm()); } public List<Normaliser> getNormalisers() { return normalisers; } public int getIndex(Normaliser n){ return normalisers.lastIndexOf(n); } public Normaliser getNormaliser(int norm_id) { if (norm_id < normalisers.size()) return normalisers.get(norm_id); else return null; } public abstract class Normaliser { double lowerBound = 0, upperBound = 1; NormalisationFilter myFilter = null;
protected abstract double normaliseFunction(Packet p);
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/GraphNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter;
package netvis.visualisations.comets; public class GraphNode extends Node { public HashMap<String, Long> protocollengths; public long maxVal = 0; public GraphNode(String n) { super(n); protocollengths = new HashMap<String, Long> (); }
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/GraphNode.java import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter; package netvis.visualisations.comets; public class GraphNode extends Node { public HashMap<String, Long> protocollengths; public long maxVal = 0; public GraphNode(String n) { super(n); protocollengths = new HashMap<String, Long> (); }
public void Draw(int base, NodePainter painter, GL2 gl) {
ryft/NetVis
workspace/netvis/src/netvis/visualisations/comets/GraphNode.java
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // }
import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter;
package netvis.visualisations.comets; public class GraphNode extends Node { public HashMap<String, Long> protocollengths; public long maxVal = 0; public GraphNode(String n) { super(n); protocollengths = new HashMap<String, Long> (); } public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); }
// Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/Node.java // public abstract class Node { // // private String name = null; // public String GetName() {return name;} // public void SetName(String n) {name = n;} // // public Node(String nam) { // name = nam; // } // // public void Draw(int base, NodePainter painter, GL2 gl) { // painter.DrawNode(base, this, gl); // } // // Node parent; // public Node GetParent() { // return parent; // } // public void SetParent (Node par) { // parent = par; // } // // // Defaultly a node is a singular hexagon // public int getDimenstion () {return 1;} // public int getCapacity () {return 1;} // // public Node GetNode (String name) {return null;} // public void DetachNode (Node n) {}; // // // public Node GetClickedNode (int base, Position deltacoord) { // if (deltacoord.x == 0 && deltacoord.y == 0) // return this; // else // return null; // } // // public boolean AddNode (String name, Node n) {return false;} // // public abstract void UpdateWithData (Packet pp); // // public abstract void UpdateAnimation(long time); // // public abstract int Priority(); // // public abstract void MouseClick (MouseEvent e); // } // // Path: workspace/netvis/src/netvis/visualisations/gameengine/NodePainter.java // public interface NodePainter { // // public void DrawNode(int base, HeatNode node, GL2 gl); // // public void DrawNode(int base, CometHeatNode node, GL2 gl); // // public void DrawNode(int base, FlipNode node, GL2 gl); // // public void DrawNode(int base, GraphNode node, GL2 gl); // // public void DrawNode(int base, Node node, GL2 gl); // } // Path: workspace/netvis/src/netvis/visualisations/comets/GraphNode.java import java.awt.event.MouseEvent; import java.util.HashMap; import javax.media.opengl.GL2; import netvis.data.model.Packet; import netvis.visualisations.gameengine.Node; import netvis.visualisations.gameengine.NodePainter; package netvis.visualisations.comets; public class GraphNode extends Node { public HashMap<String, Long> protocollengths; public long maxVal = 0; public GraphNode(String n) { super(n); protocollengths = new HashMap<String, Long> (); } public void Draw(int base, NodePainter painter, GL2 gl) { painter.DrawNode(base, this, gl); }
public void UpdateWithData(Packet pp) {
ryft/NetVis
workspace/netvis/src/netvis/data/DataController.java
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // }
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter;
package netvis.data; public class DataController implements ActionListener { DataFeeder dataFeeder; Timer timer; final List<DataControllerListener> listeners;
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // } // Path: workspace/netvis/src/netvis/data/DataController.java import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter; package netvis.data; public class DataController implements ActionListener { DataFeeder dataFeeder; Timer timer; final List<DataControllerListener> listeners;
final List<PacketFilter> filters;
ryft/NetVis
workspace/netvis/src/netvis/data/DataController.java
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // }
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter;
package netvis.data; public class DataController implements ActionListener { DataFeeder dataFeeder; Timer timer; final List<DataControllerListener> listeners; final List<PacketFilter> filters;
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // } // Path: workspace/netvis/src/netvis/data/DataController.java import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter; package netvis.data; public class DataController implements ActionListener { DataFeeder dataFeeder; Timer timer; final List<DataControllerListener> listeners; final List<PacketFilter> filters;
final List<Packet> allPackets;
ryft/NetVis
workspace/netvis/src/netvis/data/DataController.java
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // }
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter;
public DataController(DataFeeder dataFeeder, int updateInterval) { this.dataFeeder = dataFeeder; listeners = new ArrayList<DataControllerListener>(); filters = new ArrayList<PacketFilter>(); filteredPackets = new ArrayList<Packet>(); allPackets = new ArrayList<Packet>(); timer = new Timer(updateInterval, this); filterPanel = new JPanel(); NormaliseFactory.INSTANCE.setDataController(this); filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.Y_AXIS)); filterPanel.add(Box.createVerticalGlue()); timer.start(); } public void FinishEverything() { this.timer.stop(); for (DataControllerListener l : listeners) l.everythingEnds(); } public void addListener(DataControllerListener listener) { listeners.add(listener); } public void removeListener(DataControllerListener listener) { listeners.remove(listener); } public void addFilter(PacketFilter packetFilter) { filters.add(packetFilter);
// Path: workspace/netvis/src/netvis/data/filters/FixedFilter.java // public abstract class FixedFilter implements PacketFilter{ // // protected final JPanel panel; // protected final JLabel filterText; // protected final JButton closeButton; // protected FixedFilter(String text){ // panel = new JPanel(); // filterText = new JLabel(text); // // closeButton = new JButton("X"); // closeButton.addActionListener(new ActionListener(){ // @Override // public void actionPerformed(ActionEvent e) { // clearFilter(); // } // }); // // Box box = Box.createHorizontalBox(); // box.add(filterText); // box.add(closeButton); // panel.add(box); // panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); // } // protected abstract void clearFilter(); // @Override // public void actionPerformed(ActionEvent arg0) {} // @Override // public String description() { // return null; // } // // @Override // public JComponent getPanel() { // return panel; // } // // } // // Path: workspace/netvis/src/netvis/data/model/Packet.java // public class Packet { // public final int no, sport, dport, length; // public final double time; // public final String smac, dmac, info, protocol, sip, dip; // // /** // * // * @param no // * Packet number // * @param time // * Time elapsed since first packet (seconds) // * @param sip // * Source IPv4/6 address // * @param smac // * Source hardware (MAC) address // * @param sport // * Source Port // * @param dip // * Destination IPv4/6 address // * @param dmac // * Destination hardware (MAC) address // * @param dport // * Destination Port // * @param protocol // * Communication protocol // * @param length // * Packet Length(Bytes) // * @param info // * Detected description of packet purpose // */ // public Packet(int no, double time, String sip, String smac, int sport, String dip, String dmac, // int dport, String protocol, int length, String info) { // this.no = no; // this.time = time; // this.sip = sip; // this.smac = smac; // this.sport = sport; // this.dip = dip; // this.dmac = dmac; // this.dport = dport; // this.protocol = protocol; // this.length = length; // this.info = info; // } // // } // // Path: workspace/netvis/src/netvis/data/model/PacketFilter.java // public interface PacketFilter extends ActionListener { // // /** // * Returns TRUE if packet passes the filter test // */ // public boolean filter(Packet packet); // // /** // * @return Description of this filter. May be used in the GUI Eg. Source // * Port: Between 8000 and 9000 or Protocols: HTTP/HTTPS // */ // public String description(); // // /** // * // * @return The JComponent that controls this filter. This class should also // * act as a controller for the JComponent // */ // public JComponent getPanel(); // } // Path: workspace/netvis/src/netvis/data/DataController.java import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.Timer; import netvis.data.filters.FixedFilter; import netvis.data.model.Packet; import netvis.data.model.PacketFilter; public DataController(DataFeeder dataFeeder, int updateInterval) { this.dataFeeder = dataFeeder; listeners = new ArrayList<DataControllerListener>(); filters = new ArrayList<PacketFilter>(); filteredPackets = new ArrayList<Packet>(); allPackets = new ArrayList<Packet>(); timer = new Timer(updateInterval, this); filterPanel = new JPanel(); NormaliseFactory.INSTANCE.setDataController(this); filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.Y_AXIS)); filterPanel.add(Box.createVerticalGlue()); timer.start(); } public void FinishEverything() { this.timer.stop(); for (DataControllerListener l : listeners) l.everythingEnds(); } public void addListener(DataControllerListener listener) { listeners.add(listener); } public void removeListener(DataControllerListener listener) { listeners.remove(listener); } public void addFilter(PacketFilter packetFilter) { filters.add(packetFilter);
if (packetFilter instanceof FixedFilter) {
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/ui/alertdialog/EnumInputAlertDialog.java
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java // public class UAVTalkMissingObjectException extends Exception { // private int mInstance; // private boolean mIsSettings; // private String mObjectName; // // public int getInstance() { // return mInstance; // } // // public void setInstance(int instance) { // this.mInstance = instance; // } // // public String getObjectname() { // return mObjectName; // } // // public void setObjectname(String objectname) { // this.mObjectName = objectname; // } // // public boolean isSettings() { // return mIsSettings; // } // // public void setIsSettings(boolean isSettings) { // this.mIsSettings = isSettings; // } // } // // Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java // public class SingleToast { // // private static Toast mToast; // // public static void show(Context context, String text, int duration) { // VisualLog.i("Toast", text); // if (mToast != null) { // mToast.cancel(); // } // try { // mToast = Toast.makeText(context, text, duration); // } catch (RuntimeException e) { // VisualLog.e("SINGLETOAST", e.getMessage(), e); // } // mToast.show(); // } // // public static void show(Context context, int text, int duration) { // VisualLog.i("Toast", context.getString(text)); // if (mToast != null) { // mToast.cancel(); // } // mToast = Toast.makeText(context, text, duration); // mToast.show(); // } // // public static void show(Context context, String text) { // show(context, text, Toast.LENGTH_LONG); // } // }
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; import org.librepilot.lp2go.R; import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException; import org.librepilot.lp2go.ui.SingleToast;
/* * @file EnumInputAlertDialog.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.ui.alertdialog; public class EnumInputAlertDialog extends InputAlertDialog { private int mChoice = -1; public EnumInputAlertDialog(Context parent) { super(parent); } public void show() { if (mFcDevice == null) {
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java // public class UAVTalkMissingObjectException extends Exception { // private int mInstance; // private boolean mIsSettings; // private String mObjectName; // // public int getInstance() { // return mInstance; // } // // public void setInstance(int instance) { // this.mInstance = instance; // } // // public String getObjectname() { // return mObjectName; // } // // public void setObjectname(String objectname) { // this.mObjectName = objectname; // } // // public boolean isSettings() { // return mIsSettings; // } // // public void setIsSettings(boolean isSettings) { // this.mIsSettings = isSettings; // } // } // // Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java // public class SingleToast { // // private static Toast mToast; // // public static void show(Context context, String text, int duration) { // VisualLog.i("Toast", text); // if (mToast != null) { // mToast.cancel(); // } // try { // mToast = Toast.makeText(context, text, duration); // } catch (RuntimeException e) { // VisualLog.e("SINGLETOAST", e.getMessage(), e); // } // mToast.show(); // } // // public static void show(Context context, int text, int duration) { // VisualLog.i("Toast", context.getString(text)); // if (mToast != null) { // mToast.cancel(); // } // mToast = Toast.makeText(context, text, duration); // mToast.show(); // } // // public static void show(Context context, String text) { // show(context, text, Toast.LENGTH_LONG); // } // } // Path: app/src/main/java/org/librepilot/lp2go/ui/alertdialog/EnumInputAlertDialog.java import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; import org.librepilot.lp2go.R; import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException; import org.librepilot.lp2go.ui.SingleToast; /* * @file EnumInputAlertDialog.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.ui.alertdialog; public class EnumInputAlertDialog extends InputAlertDialog { private int mChoice = -1; public EnumInputAlertDialog(Context parent) { super(parent); } public void show() { if (mFcDevice == null) {
SingleToast.show(getContext(), getContext().getString(R.string.NOT_CONNECTED),
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/ui/alertdialog/EnumInputAlertDialog.java
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java // public class UAVTalkMissingObjectException extends Exception { // private int mInstance; // private boolean mIsSettings; // private String mObjectName; // // public int getInstance() { // return mInstance; // } // // public void setInstance(int instance) { // this.mInstance = instance; // } // // public String getObjectname() { // return mObjectName; // } // // public void setObjectname(String objectname) { // this.mObjectName = objectname; // } // // public boolean isSettings() { // return mIsSettings; // } // // public void setIsSettings(boolean isSettings) { // this.mIsSettings = isSettings; // } // } // // Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java // public class SingleToast { // // private static Toast mToast; // // public static void show(Context context, String text, int duration) { // VisualLog.i("Toast", text); // if (mToast != null) { // mToast.cancel(); // } // try { // mToast = Toast.makeText(context, text, duration); // } catch (RuntimeException e) { // VisualLog.e("SINGLETOAST", e.getMessage(), e); // } // mToast.show(); // } // // public static void show(Context context, int text, int duration) { // VisualLog.i("Toast", context.getString(text)); // if (mToast != null) { // mToast.cancel(); // } // mToast = Toast.makeText(context, text, duration); // mToast.show(); // } // // public static void show(Context context, String text) { // show(context, text, Toast.LENGTH_LONG); // } // }
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; import org.librepilot.lp2go.R; import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException; import org.librepilot.lp2go.ui.SingleToast;
if (mFcDevice == null) { SingleToast.show(getContext(), getContext().getString(R.string.NOT_CONNECTED), Toast.LENGTH_SHORT); return; } AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()); dialogBuilder.setTitle(mTitle); String[] types; try { types = mFcDevice.getObjectTree().getXmlObjects().get(mObject).getFields() .get(mField).getOptions(); } catch (NullPointerException e) { types = null; } int current = 0; try { String type = mFcDevice.getObjectTree().getData(mObject, 0, mField, mElement).toString(); if (type != null && types != null) { for (String t : types) { if (t.equals(type)) { break; } current++; } }
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMissingObjectException.java // public class UAVTalkMissingObjectException extends Exception { // private int mInstance; // private boolean mIsSettings; // private String mObjectName; // // public int getInstance() { // return mInstance; // } // // public void setInstance(int instance) { // this.mInstance = instance; // } // // public String getObjectname() { // return mObjectName; // } // // public void setObjectname(String objectname) { // this.mObjectName = objectname; // } // // public boolean isSettings() { // return mIsSettings; // } // // public void setIsSettings(boolean isSettings) { // this.mIsSettings = isSettings; // } // } // // Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java // public class SingleToast { // // private static Toast mToast; // // public static void show(Context context, String text, int duration) { // VisualLog.i("Toast", text); // if (mToast != null) { // mToast.cancel(); // } // try { // mToast = Toast.makeText(context, text, duration); // } catch (RuntimeException e) { // VisualLog.e("SINGLETOAST", e.getMessage(), e); // } // mToast.show(); // } // // public static void show(Context context, int text, int duration) { // VisualLog.i("Toast", context.getString(text)); // if (mToast != null) { // mToast.cancel(); // } // mToast = Toast.makeText(context, text, duration); // mToast.show(); // } // // public static void show(Context context, String text) { // show(context, text, Toast.LENGTH_LONG); // } // } // Path: app/src/main/java/org/librepilot/lp2go/ui/alertdialog/EnumInputAlertDialog.java import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; import org.librepilot.lp2go.R; import org.librepilot.lp2go.uavtalk.UAVTalkMissingObjectException; import org.librepilot.lp2go.ui.SingleToast; if (mFcDevice == null) { SingleToast.show(getContext(), getContext().getString(R.string.NOT_CONNECTED), Toast.LENGTH_SHORT); return; } AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()); dialogBuilder.setTitle(mTitle); String[] types; try { types = mFcDevice.getObjectTree().getXmlObjects().get(mObject).getFields() .get(mField).getOptions(); } catch (NullPointerException e) { types = null; } int current = 0; try { String type = mFcDevice.getObjectTree().getData(mObject, 0, mField, mElement).toString(); if (type != null && types != null) { for (String t : types) { if (t.equals(type)) { break; } current++; } }
} catch (UAVTalkMissingObjectException | NumberFormatException | NullPointerException ignored) {
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkDeviceHelper.java
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // }
import org.librepilot.lp2go.VisualLog; import android.support.annotation.Nullable;
/* * @file UAVTalkDeviceHelper.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.uavtalk; public class UAVTalkDeviceHelper { private static final String TAG = UAVTalkDeviceHelper.class.getSimpleName(); public static byte[] updateSettingsObject( UAVTalkObjectTree oTree, String objectName, int instance, String fieldName, String elementName, byte[] newFieldData) { try { return updateSettingsObject( oTree, objectName, instance, fieldName, oTree.getElementIndex(objectName, fieldName, elementName), newFieldData); } catch (NullPointerException e) {
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // } // Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkDeviceHelper.java import org.librepilot.lp2go.VisualLog; import android.support.annotation.Nullable; /* * @file UAVTalkDeviceHelper.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.uavtalk; public class UAVTalkDeviceHelper { private static final String TAG = UAVTalkDeviceHelper.class.getSimpleName(); public static byte[] updateSettingsObject( UAVTalkObjectTree oTree, String objectName, int instance, String fieldName, String elementName, byte[] newFieldData) { try { return updateSettingsObject( oTree, objectName, instance, fieldName, oTree.getElementIndex(objectName, fieldName, elementName), newFieldData); } catch (NullPointerException e) {
VisualLog.e(TAG, e.getMessage());
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // }
import android.content.Context; import android.widget.Toast; import org.librepilot.lp2go.VisualLog;
/* * @file SingleToast.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* This file incorporates work covered by the following copyright and * permission notice: */ /* * Copyright (C) 2011 The Android Open Source 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 org.librepilot.lp2go.ui; public class SingleToast { private static Toast mToast; public static void show(Context context, String text, int duration) {
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // } // Path: app/src/main/java/org/librepilot/lp2go/ui/SingleToast.java import android.content.Context; import android.widget.Toast; import org.librepilot.lp2go.VisualLog; /* * @file SingleToast.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* This file incorporates work covered by the following copyright and * permission notice: */ /* * Copyright (C) 2011 The Android Open Source 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 org.librepilot.lp2go.ui; public class SingleToast { private static Toast mToast; public static void show(Context context, String text, int duration) {
VisualLog.i("Toast", text);
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/helper/ellipsoidFit/FitPoints.java
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // }
import org.apache.commons.math3.exception.NotStrictlyPositiveException; import org.apache.commons.math3.linear.Array2DRowRealMatrix; import org.apache.commons.math3.linear.ArrayRealVector; import org.apache.commons.math3.linear.DecompositionSolver; import org.apache.commons.math3.linear.EigenDecomposition; import org.apache.commons.math3.linear.MatrixUtils; import org.apache.commons.math3.linear.RealMatrix; import org.apache.commons.math3.linear.RealVector; import org.apache.commons.math3.linear.SingularValueDecomposition; import org.librepilot.lp2go.VisualLog; import java.util.Arrays; import java.util.List;
// Get the eigenvalues and eigenvectors. EigenDecomposition ed = new EigenDecomposition(subr, 0); evals = ed.getRealEigenvalues(); evecs = ed.getEigenvector(0); evecs1 = ed.getEigenvector(1); evecs2 = ed.getEigenvector(2); // Find the radii of the ellipsoid. radii = findRadii(evals); return true; } /** * Solve the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz + 2Fyz + * 2Gx + 2Hy + 2Iz from the provided points. * * @param points the points that will be fit to the polynomial expression. * @return the solution vector to the polynomial expression. */ private RealVector solveSystem(List<? extends ThreeSpacePoint> points) { // determine the number of points int numPoints = points.size(); // the design matrix // size: numPoints x 9 RealMatrix d = null; try { d = new Array2DRowRealMatrix(numPoints, 9); } catch (NotStrictlyPositiveException e) {
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // } // Path: app/src/main/java/org/librepilot/lp2go/helper/ellipsoidFit/FitPoints.java import org.apache.commons.math3.exception.NotStrictlyPositiveException; import org.apache.commons.math3.linear.Array2DRowRealMatrix; import org.apache.commons.math3.linear.ArrayRealVector; import org.apache.commons.math3.linear.DecompositionSolver; import org.apache.commons.math3.linear.EigenDecomposition; import org.apache.commons.math3.linear.MatrixUtils; import org.apache.commons.math3.linear.RealMatrix; import org.apache.commons.math3.linear.RealVector; import org.apache.commons.math3.linear.SingularValueDecomposition; import org.librepilot.lp2go.VisualLog; import java.util.Arrays; import java.util.List; // Get the eigenvalues and eigenvectors. EigenDecomposition ed = new EigenDecomposition(subr, 0); evals = ed.getRealEigenvalues(); evecs = ed.getEigenvector(0); evecs1 = ed.getEigenvector(1); evecs2 = ed.getEigenvector(2); // Find the radii of the ellipsoid. radii = findRadii(evals); return true; } /** * Solve the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz + 2Fyz + * 2Gx + 2Hy + 2Iz from the provided points. * * @param points the points that will be fit to the polynomial expression. * @return the solution vector to the polynomial expression. */ private RealVector solveSystem(List<? extends ThreeSpacePoint> points) { // determine the number of points int numPoints = points.size(); // the design matrix // size: numPoints x 9 RealMatrix d = null; try { d = new Array2DRowRealMatrix(numPoints, 9); } catch (NotStrictlyPositiveException e) {
VisualLog.e("FitPoints", e.getMessage(), e);
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/helper/H.java
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // }
import com.google.android.gms.maps.model.LatLng; import org.librepilot.lp2go.VisualLog; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.util.DisplayMetrics;
byte[] c = new byte[aLen + bLen]; System.arraycopy(a, 0, c, 0, aLen); System.arraycopy(b, 0, c, aLen, bLen); return c; } public static String k(String s) { /*if(s.length() >3) { return s.substring(0,s.length()-3) + "k"; } else { return s; }*/ return s; } public static byte[] floatToByteArrayRev(float value) { return H.reverse4bytes(floatToByteArray(value)); } public static byte[] floatToByteArray(float value) { return ByteBuffer.allocate(4).putFloat(value).array(); } public static float stringToFloat(String s) { if (s == null || s.equals("")) { return .0f; } try { return Float.parseFloat(s); } catch (NumberFormatException e) {
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java // public class VisualLog { // // //private static Activity activity; // private static String nullstring = "null"; // //private static TextView txtDebugLog; // // static private String checkNull(String msg) { // return msg == null ? nullstring : msg; // } // // static public void d(String tag, String msg) { // Log.d(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String msg) { // e(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String msg) { // d(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void d(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void w(String tag, String msg) { // Log.w(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void w(String msg) { // w(new Exception().getStackTrace()[1].getClassName(), msg); // } // // static public void e(String tag, String msg) { // Log.e(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void e(String tag, String msg, Throwable tr) { // Log.e(tag, checkNull(msg), tr); // printToDebug(tag, checkNull(msg)); // printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr)); // } // // static public void e(String msg, Throwable tr) { // e(new Exception().getStackTrace()[1].getClassName(), msg, tr); // } // // static public void e(Throwable tr) { // VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr); // } // // static public void i(String tag, String msg) { // Log.i(tag, checkNull(msg)); // printToDebug(tag, checkNull(msg)); // } // // static public void i(String msg) { // i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg)); // // } // // static private void printToDebug(final String t, final String s) { // /* // activity.runOnUiThread(new Runnable() { // @Override // public void run() { // if (txtDebugLog != null) { // txtDebugLog.append(t + " " + s + "\n"); // } // } // }); // */ // } // // public static void setActivity(Activity activity) { // //VisualLog.activity = activity; // //VisualLog.nullstring = activity.getString(R.string.NULL); // } // // public static void setDebugLogTextView(TextView txtDebugLog) { // //VisualLog.txtDebugLog = txtDebugLog; // } // } // Path: app/src/main/java/org/librepilot/lp2go/helper/H.java import com.google.android.gms.maps.model.LatLng; import org.librepilot.lp2go.VisualLog; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.util.DisplayMetrics; byte[] c = new byte[aLen + bLen]; System.arraycopy(a, 0, c, 0, aLen); System.arraycopy(b, 0, c, aLen, bLen); return c; } public static String k(String s) { /*if(s.length() >3) { return s.substring(0,s.length()-3) + "k"; } else { return s; }*/ return s; } public static byte[] floatToByteArrayRev(float value) { return H.reverse4bytes(floatToByteArray(value)); } public static byte[] floatToByteArray(float value) { return ByteBuffer.allocate(4).putFloat(value).array(); } public static float stringToFloat(String s) { if (s == null || s.equals("")) { return .0f; } try { return Float.parseFloat(s); } catch (NumberFormatException e) {
VisualLog.d("stringToFloat", "Fallback to Numberformat");
MarcProe/lp2go
app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMessage.java
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/device/FcWaiterThread.java // public abstract class FcWaiterThread extends Thread { // public final static byte MASK_TIMESTAMP = (byte) 0x80; // final FcDevice mDevice; // FcDevice.GuiEventListener mGuiEventListener; // // FcWaiterThread(FcDevice device) { // this.mDevice = device; // } // // public void setGuiEventListener(FcDevice.GuiEventListener gel) { // mGuiEventListener = gel; // } // // protected abstract void stopThread(); // // final boolean handleMessageType(byte msgType, UAVTalkObject obj) { // switch (msgType) { // case (byte) 0x20: // case (byte) 0xa0: // //handle default package, nothing to do // break; // case (byte) 0x21: // case (byte) 0xa1: // //handle request message, nobody should request from LP2Go (so we don't implement this) // VisualLog // .e("UAVTalk", "Received Object Request, but won't send any " + obj.getId()); // break; // case (byte) 0x22: // case (byte) 0xa2: // //handle object with ACK REQ, means send ACK // mDevice.sendAck(obj.getId(), 0); // VisualLog.d("UAVTalk", "Received Object with ACK Request " + obj.getId()); // break; // case (byte) 0x23: // case (byte) 0xa3: // //handle received ACK, e.g. save in Object that it has been acknowledged // VisualLog.d("UAVTalk", "Received ACK Object " + obj.getId()); // break; // case (byte) 0x24: // case (byte) 0xa4: // //handle NACK, show warning and add to request blacklist // mDevice.nackedObjects.add(obj.getId()); // mDevice.mActivity.incRxObjectsBad(); // VisualLog.w("UAVTalk", "Received NACK Object " + obj.getId()); // break; // default: // mDevice.mActivity.incRxObjectsBad(); // byte[] b = new byte[1]; // b[0] = msgType; // VisualLog.w("UAVTalk", "Received bad Object Type " + H.bytesToHex(b)); // return false; // } // return true; // } // }
import org.librepilot.lp2go.uavtalk.device.FcWaiterThread;
/* * @file UAVTalkMessage.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.uavtalk; public class UAVTalkMessage { private byte[] mData; private int mInstanceId; private int mLength; private int mObjectId; private byte[] mRaw; private int mTimestamp; private byte mType; public UAVTalkMessage(byte[] bytes, int offset) { this.mRaw = bytes; int tsoffset = 0; if (bytes.length >= 10 + offset) { this.mType = bytes[1 + offset]; int lb1 = bytes[3 + offset] & 0x000000ff; int lb2 = bytes[2 + offset] & 0x000000ff; this.mLength = lb1 << 8 | lb2; int ob1 = bytes[7 + offset] & 0x000000ff; int ob2 = bytes[6 + offset] & 0x000000ff; int ob3 = bytes[5 + offset] & 0x000000ff; int ob4 = bytes[4 + offset] & 0x000000ff; this.mObjectId = ob1 << 24 | ob2 << 16 | ob3 << 8 | ob4; int ib1 = bytes[9 + offset] & 0x000000ff; int ib2 = bytes[8 + offset] & 0x000000ff; this.mInstanceId = ib1 << 8 | ib2;
// Path: app/src/main/java/org/librepilot/lp2go/uavtalk/device/FcWaiterThread.java // public abstract class FcWaiterThread extends Thread { // public final static byte MASK_TIMESTAMP = (byte) 0x80; // final FcDevice mDevice; // FcDevice.GuiEventListener mGuiEventListener; // // FcWaiterThread(FcDevice device) { // this.mDevice = device; // } // // public void setGuiEventListener(FcDevice.GuiEventListener gel) { // mGuiEventListener = gel; // } // // protected abstract void stopThread(); // // final boolean handleMessageType(byte msgType, UAVTalkObject obj) { // switch (msgType) { // case (byte) 0x20: // case (byte) 0xa0: // //handle default package, nothing to do // break; // case (byte) 0x21: // case (byte) 0xa1: // //handle request message, nobody should request from LP2Go (so we don't implement this) // VisualLog // .e("UAVTalk", "Received Object Request, but won't send any " + obj.getId()); // break; // case (byte) 0x22: // case (byte) 0xa2: // //handle object with ACK REQ, means send ACK // mDevice.sendAck(obj.getId(), 0); // VisualLog.d("UAVTalk", "Received Object with ACK Request " + obj.getId()); // break; // case (byte) 0x23: // case (byte) 0xa3: // //handle received ACK, e.g. save in Object that it has been acknowledged // VisualLog.d("UAVTalk", "Received ACK Object " + obj.getId()); // break; // case (byte) 0x24: // case (byte) 0xa4: // //handle NACK, show warning and add to request blacklist // mDevice.nackedObjects.add(obj.getId()); // mDevice.mActivity.incRxObjectsBad(); // VisualLog.w("UAVTalk", "Received NACK Object " + obj.getId()); // break; // default: // mDevice.mActivity.incRxObjectsBad(); // byte[] b = new byte[1]; // b[0] = msgType; // VisualLog.w("UAVTalk", "Received bad Object Type " + H.bytesToHex(b)); // return false; // } // return true; // } // } // Path: app/src/main/java/org/librepilot/lp2go/uavtalk/UAVTalkMessage.java import org.librepilot.lp2go.uavtalk.device.FcWaiterThread; /* * @file UAVTalkMessage.java * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. * @see The GNU Public License (GPL) Version 3 * * 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., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.librepilot.lp2go.uavtalk; public class UAVTalkMessage { private byte[] mData; private int mInstanceId; private int mLength; private int mObjectId; private byte[] mRaw; private int mTimestamp; private byte mType; public UAVTalkMessage(byte[] bytes, int offset) { this.mRaw = bytes; int tsoffset = 0; if (bytes.length >= 10 + offset) { this.mType = bytes[1 + offset]; int lb1 = bytes[3 + offset] & 0x000000ff; int lb2 = bytes[2 + offset] & 0x000000ff; this.mLength = lb1 << 8 | lb2; int ob1 = bytes[7 + offset] & 0x000000ff; int ob2 = bytes[6 + offset] & 0x000000ff; int ob3 = bytes[5 + offset] & 0x000000ff; int ob4 = bytes[4 + offset] & 0x000000ff; this.mObjectId = ob1 << 24 | ob2 << 16 | ob3 << 8 | ob4; int ib1 = bytes[9 + offset] & 0x000000ff; int ib2 = bytes[8 + offset] & 0x000000ff; this.mInstanceId = ib1 << 8 | ib2;
if ((FcWaiterThread.MASK_TIMESTAMP & this.mType) == FcWaiterThread.MASK_TIMESTAMP) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/SearchPlacesAndCategoriesView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/SearchGroup.java // public interface SearchGroup { // // int getId(); // // String getName(); // // Type getType(); // // enum Type {CATEGORY, PLACE, TITLE} // // }
import com.github.gfx.android.orma.exception.InvalidStatementException; import android.content.Context; import android.databinding.DataBindingUtil; import android.databinding.ViewDataBinding; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.FrameLayout; import java.util.ArrayList; import java.util.List; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ItemSearchCategoryBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchPlaceBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchTitleBinding; import io.github.droidkaigi.confsched.databinding.ViewSearchPlacesAndCategoriesBinding; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.SearchGroup; import io.github.droidkaigi.confsched.widget.itemdecoration.DividerItemDecoration;
package io.github.droidkaigi.confsched.widget; public class SearchPlacesAndCategoriesView extends FrameLayout { public interface OnClickSearchGroup {
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/SearchGroup.java // public interface SearchGroup { // // int getId(); // // String getName(); // // Type getType(); // // enum Type {CATEGORY, PLACE, TITLE} // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/SearchPlacesAndCategoriesView.java import com.github.gfx.android.orma.exception.InvalidStatementException; import android.content.Context; import android.databinding.DataBindingUtil; import android.databinding.ViewDataBinding; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.FrameLayout; import java.util.ArrayList; import java.util.List; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ItemSearchCategoryBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchPlaceBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchTitleBinding; import io.github.droidkaigi.confsched.databinding.ViewSearchPlacesAndCategoriesBinding; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.SearchGroup; import io.github.droidkaigi.confsched.widget.itemdecoration.DividerItemDecoration; package io.github.droidkaigi.confsched.widget; public class SearchPlacesAndCategoriesView extends FrameLayout { public interface OnClickSearchGroup {
void onClickSearchGroup(SearchGroup searchGroup);
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/SearchPlacesAndCategoriesView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/SearchGroup.java // public interface SearchGroup { // // int getId(); // // String getName(); // // Type getType(); // // enum Type {CATEGORY, PLACE, TITLE} // // }
import com.github.gfx.android.orma.exception.InvalidStatementException; import android.content.Context; import android.databinding.DataBindingUtil; import android.databinding.ViewDataBinding; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.FrameLayout; import java.util.ArrayList; import java.util.List; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ItemSearchCategoryBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchPlaceBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchTitleBinding; import io.github.droidkaigi.confsched.databinding.ViewSearchPlacesAndCategoriesBinding; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.SearchGroup; import io.github.droidkaigi.confsched.widget.itemdecoration.DividerItemDecoration;
package io.github.droidkaigi.confsched.widget; public class SearchPlacesAndCategoriesView extends FrameLayout { public interface OnClickSearchGroup { void onClickSearchGroup(SearchGroup searchGroup); } private ViewSearchPlacesAndCategoriesBinding binding; private SearchGroupsAdapter adapter; public SearchPlacesAndCategoriesView(Context context) { this(context, null); } public SearchPlacesAndCategoriesView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SearchPlacesAndCategoriesView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_search_places_and_categories, this, true); initRecyclerView(); } public void addPlaces(List<Place> places) { adapter.addItem(new SearchTitle(getContext().getString(R.string.search_by_place))); adapter.addAll(new ArrayList<>(places)); }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/SearchGroup.java // public interface SearchGroup { // // int getId(); // // String getName(); // // Type getType(); // // enum Type {CATEGORY, PLACE, TITLE} // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/SearchPlacesAndCategoriesView.java import com.github.gfx.android.orma.exception.InvalidStatementException; import android.content.Context; import android.databinding.DataBindingUtil; import android.databinding.ViewDataBinding; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.FrameLayout; import java.util.ArrayList; import java.util.List; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ItemSearchCategoryBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchPlaceBinding; import io.github.droidkaigi.confsched.databinding.ItemSearchTitleBinding; import io.github.droidkaigi.confsched.databinding.ViewSearchPlacesAndCategoriesBinding; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.SearchGroup; import io.github.droidkaigi.confsched.widget.itemdecoration.DividerItemDecoration; package io.github.droidkaigi.confsched.widget; public class SearchPlacesAndCategoriesView extends FrameLayout { public interface OnClickSearchGroup { void onClickSearchGroup(SearchGroup searchGroup); } private ViewSearchPlacesAndCategoriesBinding binding; private SearchGroupsAdapter adapter; public SearchPlacesAndCategoriesView(Context context) { this(context, null); } public SearchPlacesAndCategoriesView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SearchPlacesAndCategoriesView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_search_places_and_categories, this, true); initRecyclerView(); } public void addPlaces(List<Place> places) { adapter.addItem(new SearchTitle(getContext().getString(R.string.search_by_place))); adapter.addAll(new ArrayList<>(places)); }
public void addCategories(List<Category> categories) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/di/AppModule.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/api/RequestInterceptor.java // @Singleton // public class RequestInterceptor implements Interceptor { // // final ConnectivityManager connectivityManager; // // @Inject // public RequestInterceptor(ConnectivityManager connectivityManager) { // this.connectivityManager = connectivityManager; // } // // @Override // public Response intercept(Chain chain) throws IOException { // Request.Builder r = chain.request().newBuilder(); // if (isConnected()) { // int maxAge = 2 * 60; // r.addHeader("cache-control", "public, max-age=" + maxAge); // } else { // int maxStale = 30 * 24 * 60 * 60; // 30 days // r.addHeader("cache-control", "public, only-if-cached, max-stale=" + maxStale); // } // // return chain.proceed(r.build()); // } // // protected boolean isConnected() { // NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); // return networkInfo != null && networkInfo.isConnectedOrConnecting(); // } // // }
import com.google.android.gms.analytics.GoogleAnalytics; import com.google.android.gms.analytics.Tracker; import com.github.gfx.android.orma.AccessThreadConstraint; import com.github.gfx.android.orma.migration.ManualStepMigration; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.support.annotation.NonNull; import java.io.File; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import io.github.droidkaigi.confsched.BuildConfig; import io.github.droidkaigi.confsched.activity.ActivityNavigator; import io.github.droidkaigi.confsched.api.RequestInterceptor; import io.github.droidkaigi.confsched.model.OrmaDatabase; import okhttp3.Cache; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import rx.subscriptions.CompositeSubscription;
@Singleton @Provides public Tracker provideGoogleAnalyticsTracker(Context context) { GoogleAnalytics ga = GoogleAnalytics.getInstance(context); Tracker tracker = ga.newTracker(BuildConfig.GA_TRACKING_ID); tracker.enableAdvertisingIdCollection(true); tracker.enableExceptionReporting(true); return tracker; } @Provides public ConnectivityManager provideConnectivityManager(Context context) { return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); } @Singleton @Provides public OkHttpClient provideHttpClient(Context context, Interceptor interceptor) { File cacheDir = new File(context.getCacheDir(), CACHE_FILE_NAME); Cache cache = new Cache(cacheDir, MAX_CACHE_SIZE); OkHttpClient.Builder c = new OkHttpClient.Builder() .cache(cache) .addInterceptor(interceptor); return c.build(); } @Provides public Interceptor provideRequestInterceptor(ConnectivityManager connectivityManager) {
// Path: app/src/main/java/io/github/droidkaigi/confsched/api/RequestInterceptor.java // @Singleton // public class RequestInterceptor implements Interceptor { // // final ConnectivityManager connectivityManager; // // @Inject // public RequestInterceptor(ConnectivityManager connectivityManager) { // this.connectivityManager = connectivityManager; // } // // @Override // public Response intercept(Chain chain) throws IOException { // Request.Builder r = chain.request().newBuilder(); // if (isConnected()) { // int maxAge = 2 * 60; // r.addHeader("cache-control", "public, max-age=" + maxAge); // } else { // int maxStale = 30 * 24 * 60 * 60; // 30 days // r.addHeader("cache-control", "public, only-if-cached, max-stale=" + maxStale); // } // // return chain.proceed(r.build()); // } // // protected boolean isConnected() { // NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); // return networkInfo != null && networkInfo.isConnectedOrConnecting(); // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/di/AppModule.java import com.google.android.gms.analytics.GoogleAnalytics; import com.google.android.gms.analytics.Tracker; import com.github.gfx.android.orma.AccessThreadConstraint; import com.github.gfx.android.orma.migration.ManualStepMigration; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.support.annotation.NonNull; import java.io.File; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import io.github.droidkaigi.confsched.BuildConfig; import io.github.droidkaigi.confsched.activity.ActivityNavigator; import io.github.droidkaigi.confsched.api.RequestInterceptor; import io.github.droidkaigi.confsched.model.OrmaDatabase; import okhttp3.Cache; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import rx.subscriptions.CompositeSubscription; @Singleton @Provides public Tracker provideGoogleAnalyticsTracker(Context context) { GoogleAnalytics ga = GoogleAnalytics.getInstance(context); Tracker tracker = ga.newTracker(BuildConfig.GA_TRACKING_ID); tracker.enableAdvertisingIdCollection(true); tracker.enableExceptionReporting(true); return tracker; } @Provides public ConnectivityManager provideConnectivityManager(Context context) { return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); } @Singleton @Provides public OkHttpClient provideHttpClient(Context context, Interceptor interceptor) { File cacheDir = new File(context.getCacheDir(), CACHE_FILE_NAME); Cache cache = new Cache(cacheDir, MAX_CACHE_SIZE); OkHttpClient.Builder c = new OkHttpClient.Builder() .cache(cache) .addInterceptor(interceptor); return c.build(); } @Provides public Interceptor provideRequestInterceptor(ConnectivityManager connectivityManager) {
return new RequestInterceptor(connectivityManager);
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/dao/ContributorDao.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Contributor.java // @Table // public class Contributor { // // @PrimaryKey(auto = false) // @Column("name") // @SerializedName("login") // public String name; // // @Column("avatar_url") // @Nullable // @SerializedName("avatar_url") // public String avatarUrl; // // @Column("html_url") // @Nullable // @SerializedName("html_url") // public String htmlUrl; // // @Column("contributions") // @SerializedName("contributions") // public int contributions; // // }
import android.support.annotation.NonNull; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Contributor; import io.github.droidkaigi.confsched.model.Contributor_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase;
package io.github.droidkaigi.confsched.dao; @Singleton public class ContributorDao { OrmaDatabase orma; @Inject public ContributorDao(OrmaDatabase orma) { this.orma = orma; } private Contributor_Relation contributorRelation() { return orma.relationOfContributor(); }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Contributor.java // @Table // public class Contributor { // // @PrimaryKey(auto = false) // @Column("name") // @SerializedName("login") // public String name; // // @Column("avatar_url") // @Nullable // @SerializedName("avatar_url") // public String avatarUrl; // // @Column("html_url") // @Nullable // @SerializedName("html_url") // public String htmlUrl; // // @Column("contributions") // @SerializedName("contributions") // public int contributions; // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/dao/ContributorDao.java import android.support.annotation.NonNull; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Contributor; import io.github.droidkaigi.confsched.model.Contributor_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase; package io.github.droidkaigi.confsched.dao; @Singleton public class ContributorDao { OrmaDatabase orma; @Inject public ContributorDao(OrmaDatabase orma) { this.orma = orma; } private Contributor_Relation contributorRelation() { return orma.relationOfContributor(); }
public List<Contributor> findAll() {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/api/DroidKaigiClient.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Contributor.java // @Table // public class Contributor { // // @PrimaryKey(auto = false) // @Column("name") // @SerializedName("login") // public String name; // // @Column("avatar_url") // @Nullable // @SerializedName("avatar_url") // public String avatarUrl; // // @Column("html_url") // @Nullable // @SerializedName("html_url") // public String htmlUrl; // // @Column("contributions") // @SerializedName("contributions") // public int contributions; // // }
import android.support.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Contributor; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.SessionFeedback; import io.github.droidkaigi.confsched.util.LocaleUtil; import okhttp3.OkHttpClient; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import rx.Observable;
.baseUrl("https://api.github.com") .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(createGson())) .build(); githubService = githubRetrofit.create(GithubService.class); } public static Gson createGson() { return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); } public Observable<List<Session>> getSessions(@NonNull String languageId) { switch (languageId) { case LocaleUtil.LANG_JA_ID: return service.getSessionsJa(); case LocaleUtil.LANG_AR_ID: return service.getSessionsAr(); case LocaleUtil.LANG_KO_ID: return service.getSessionsKo(); case LocaleUtil.LANG_EN_ID: return service.getSessionsEn(); default: return service.getSessionsEn(); } } public Observable<Response<Void>> submitSessionFeedback(SessionFeedback f) { return googleFormService.submitSessionFeedback(f.sessionId, f.sessionName, f.relevancy, f.asExpected, f.difficulty, f.knowledgeable, f.comment); }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Contributor.java // @Table // public class Contributor { // // @PrimaryKey(auto = false) // @Column("name") // @SerializedName("login") // public String name; // // @Column("avatar_url") // @Nullable // @SerializedName("avatar_url") // public String avatarUrl; // // @Column("html_url") // @Nullable // @SerializedName("html_url") // public String htmlUrl; // // @Column("contributions") // @SerializedName("contributions") // public int contributions; // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/api/DroidKaigiClient.java import android.support.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Contributor; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.SessionFeedback; import io.github.droidkaigi.confsched.util.LocaleUtil; import okhttp3.OkHttpClient; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import rx.Observable; .baseUrl("https://api.github.com") .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(createGson())) .build(); githubService = githubRetrofit.create(GithubService.class); } public static Gson createGson() { return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); } public Observable<List<Session>> getSessions(@NonNull String languageId) { switch (languageId) { case LocaleUtil.LANG_JA_ID: return service.getSessionsJa(); case LocaleUtil.LANG_AR_ID: return service.getSessionsAr(); case LocaleUtil.LANG_KO_ID: return service.getSessionsKo(); case LocaleUtil.LANG_EN_ID: return service.getSessionsEn(); default: return service.getSessionsEn(); } } public Observable<Response<Void>> submitSessionFeedback(SessionFeedback f) { return googleFormService.submitSessionFeedback(f.sessionId, f.sessionName, f.relevancy, f.asExpected, f.difficulty, f.knowledgeable, f.comment); }
public Observable<List<Contributor>> getContributors() {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/fragment/SponsorsFragment.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // }
import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.flexbox.FlexboxLayout; import javax.inject.Inject; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.FragmentSponsorsBinding; import io.github.droidkaigi.confsched.model.Sponsor; import io.github.droidkaigi.confsched.util.AnalyticsTracker; import io.github.droidkaigi.confsched.util.AppUtil; import io.github.droidkaigi.confsched.widget.SponsorImageView; import rx.Observable;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentSponsorsBinding.inflate(inflater, container, false); initView(); return binding.getRoot(); } @Override public void onAttach(Context context) { super.onAttach(context); getComponent().inject(this); } private void initView() { Observable.from(Sponsor.createPlatinumList()) .forEach(sponsor -> addView(sponsor, binding.platinumContainer)); Observable.from(Sponsor.createVideoList()) .forEach(sponsor -> addView(sponsor, binding.videoContainer)); Observable.from(Sponsor.createFoodsList()) .forEach(sponsor -> addView(sponsor, binding.foodsContainer)); Observable.from(Sponsor.createNormalList()) .forEach(sponsor -> addView(sponsor, binding.normalContainer)); } private void addView(Sponsor sponsor, FlexboxLayout container) { SponsorImageView imageView = new SponsorImageView(getActivity()); imageView.bindData(sponsor, v -> { if (TextUtils.isEmpty(sponsor.url)) return; analyticsTracker.sendEvent("sponsor", sponsor.url);
// Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/fragment/SponsorsFragment.java import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.flexbox.FlexboxLayout; import javax.inject.Inject; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.FragmentSponsorsBinding; import io.github.droidkaigi.confsched.model.Sponsor; import io.github.droidkaigi.confsched.util.AnalyticsTracker; import io.github.droidkaigi.confsched.util.AppUtil; import io.github.droidkaigi.confsched.widget.SponsorImageView; import rx.Observable; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentSponsorsBinding.inflate(inflater, container, false); initView(); return binding.getRoot(); } @Override public void onAttach(Context context) { super.onAttach(context); getComponent().inject(this); } private void initView() { Observable.from(Sponsor.createPlatinumList()) .forEach(sponsor -> addView(sponsor, binding.platinumContainer)); Observable.from(Sponsor.createVideoList()) .forEach(sponsor -> addView(sponsor, binding.videoContainer)); Observable.from(Sponsor.createFoodsList()) .forEach(sponsor -> addView(sponsor, binding.foodsContainer)); Observable.from(Sponsor.createNormalList()) .forEach(sponsor -> addView(sponsor, binding.normalContainer)); } private void addView(Sponsor sponsor, FlexboxLayout container) { SponsorImageView imageView = new SponsorImageView(getActivity()); imageView.bindData(sponsor, v -> { if (TextUtils.isEmpty(sponsor.url)) return; analyticsTracker.sendEvent("sponsor", sponsor.url);
AppUtil.showWebPage(getActivity(), sponsor.url);
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/fragment/MyScheduleSessionsTabFragment.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/widget/BindingHolder.java // public class BindingHolder<T extends ViewDataBinding> extends RecyclerView.ViewHolder { // // public final T binding; // // public BindingHolder(@NonNull Context context, @NonNull ViewGroup parent, @LayoutRes int layoutResId) { // super(LayoutInflater.from(context).inflate(layoutResId, parent, false)); // binding = DataBindingUtil.bind(itemView); // } // // }
import android.content.Context; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.util.ArrayMap; import android.util.Pair; import android.view.View; import org.parceler.Parcels; import java.util.ArrayList; import java.util.List; import java.util.Map; import io.github.droidkaigi.confsched.databinding.ItemSessionBinding; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.widget.BindingHolder;
package io.github.droidkaigi.confsched.fragment; public class MyScheduleSessionsTabFragment extends SessionsTabFragment { @NonNull public static MyScheduleSessionsTabFragment newInstance(List<Session> sessions) { MyScheduleSessionsTabFragment fragment = new MyScheduleSessionsTabFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_SESSIONS, Parcels.wrap(sessions)); fragment.setArguments(args); return fragment; } @Override protected SessionsAdapter createAdapter() { return new MyScheduleAdapter(getContext()); } private class MyScheduleAdapter extends SessionsAdapter { private Map<Long, Pair<Integer, Integer>> rangeMap = new ArrayMap<>(); public MyScheduleAdapter(@NonNull Context context) { super(context); } @Override
// Path: app/src/main/java/io/github/droidkaigi/confsched/widget/BindingHolder.java // public class BindingHolder<T extends ViewDataBinding> extends RecyclerView.ViewHolder { // // public final T binding; // // public BindingHolder(@NonNull Context context, @NonNull ViewGroup parent, @LayoutRes int layoutResId) { // super(LayoutInflater.from(context).inflate(layoutResId, parent, false)); // binding = DataBindingUtil.bind(itemView); // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/fragment/MyScheduleSessionsTabFragment.java import android.content.Context; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.util.ArrayMap; import android.util.Pair; import android.view.View; import org.parceler.Parcels; import java.util.ArrayList; import java.util.List; import java.util.Map; import io.github.droidkaigi.confsched.databinding.ItemSessionBinding; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.widget.BindingHolder; package io.github.droidkaigi.confsched.fragment; public class MyScheduleSessionsTabFragment extends SessionsTabFragment { @NonNull public static MyScheduleSessionsTabFragment newInstance(List<Session> sessions) { MyScheduleSessionsTabFragment fragment = new MyScheduleSessionsTabFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_SESSIONS, Parcels.wrap(sessions)); fragment.setArguments(args); return fragment; } @Override protected SessionsAdapter createAdapter() { return new MyScheduleAdapter(getContext()); } private class MyScheduleAdapter extends SessionsAdapter { private Map<Long, Pair<Integer, Integer>> rangeMap = new ArrayMap<>(); public MyScheduleAdapter(@NonNull Context context) { super(context); } @Override
public void onBindViewHolder(BindingHolder<ItemSessionBinding> holder, int position) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/CategoryView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // }
import android.content.Context; import android.databinding.BindingAdapter; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.widget.TextView; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.model.Category;
package io.github.droidkaigi.confsched.widget; public class CategoryView extends TextView { public CategoryView(Context context) { this(context, null); } public CategoryView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public CategoryView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @SuppressWarnings("unused") @BindingAdapter("category")
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/CategoryView.java import android.content.Context; import android.databinding.BindingAdapter; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.widget.TextView; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.model.Category; package io.github.droidkaigi.confsched.widget; public class CategoryView extends TextView { public CategoryView(Context context) { this(context, null); } public CategoryView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public CategoryView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @SuppressWarnings("unused") @BindingAdapter("category")
public static void setCategory(CategoryView categoryView, @Nullable Category category) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/SpeakerSnsIconsView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // }
import android.app.Activity; import android.content.Context; import android.databinding.BindingAdapter; import android.databinding.DataBindingUtil; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.RelativeLayout; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewSpeakerSnsIconsBinding; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.util.AppUtil;
package io.github.droidkaigi.confsched.widget; public class SpeakerSnsIconsView extends RelativeLayout { private ViewSpeakerSnsIconsBinding binding; public SpeakerSnsIconsView(Context context) { this(context, null); } public SpeakerSnsIconsView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SpeakerSnsIconsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_speaker_sns_icons, this, true); } @BindingAdapter("speakerSnsIcons")
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/SpeakerSnsIconsView.java import android.app.Activity; import android.content.Context; import android.databinding.BindingAdapter; import android.databinding.DataBindingUtil; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.RelativeLayout; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewSpeakerSnsIconsBinding; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.util.AppUtil; package io.github.droidkaigi.confsched.widget; public class SpeakerSnsIconsView extends RelativeLayout { private ViewSpeakerSnsIconsBinding binding; public SpeakerSnsIconsView(Context context) { this(context, null); } public SpeakerSnsIconsView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SpeakerSnsIconsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_speaker_sns_icons, this, true); } @BindingAdapter("speakerSnsIcons")
public static void setSpeakerSnsIcons(SpeakerSnsIconsView view, @NonNull Speaker speaker) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/SpeakerSnsIconsView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // }
import android.app.Activity; import android.content.Context; import android.databinding.BindingAdapter; import android.databinding.DataBindingUtil; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.RelativeLayout; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewSpeakerSnsIconsBinding; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.util.AppUtil;
package io.github.droidkaigi.confsched.widget; public class SpeakerSnsIconsView extends RelativeLayout { private ViewSpeakerSnsIconsBinding binding; public SpeakerSnsIconsView(Context context) { this(context, null); } public SpeakerSnsIconsView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SpeakerSnsIconsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_speaker_sns_icons, this, true); } @BindingAdapter("speakerSnsIcons") public static void setSpeakerSnsIcons(SpeakerSnsIconsView view, @NonNull Speaker speaker) { ViewSpeakerSnsIconsBinding binding = view.binding; if (TextUtils.isEmpty(speaker.twitterName) && TextUtils.isEmpty(speaker.githubName)) { binding.getRoot().setVisibility(GONE); return; } if (TextUtils.isEmpty(speaker.twitterName)) { binding.coverTwitter.setVisibility(GONE); } else { binding.coverTwitter.setVisibility(VISIBLE); binding.coverTwitter.setOnClickListener(v ->
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/util/AppUtil.java // public class AppUtil { // // private static final String TAG = AppUtil.class.getSimpleName(); // // private static final String TWITTER_URL = "https://twitter.com/"; // private static final String GITHUB_URL = "https://github.com/"; // private static final String FACEBOOK_URL = "https://www.facebook.com/"; // // private static final String STRING_RES_TYPE = "string"; // // public static String getTwitterUrl(@NonNull String name) { // return TWITTER_URL + name; // } // // public static String getGitHubUrl(@NonNull String name) { // return GITHUB_URL + name; // } // // public static String getFacebookUrl(@NonNull String name) { // return FACEBOOK_URL + name; // } // // public static String getString(@NonNull Context context, @NonNull String resName) { // try { // int resourceId = context.getResources().getIdentifier( // resName, STRING_RES_TYPE, context.getPackageName()); // if (resourceId > 0) { // return context.getString(resourceId); // } else { // Log.d(TAG, "String resource id: " + resName + " is not found."); // return ""; // } // } catch (Exception e) { // Log.e(TAG, "String resource id: " + resName + " is not found.", e); // return ""; // } // } // // public static String getVersionName(Context context) { // return context.getString(R.string.about_version_prefix, BuildConfig.VERSION_NAME); // } // // public static void linkify(Activity activity, TextView textView, String linkText, String url) { // String text = textView.getText().toString(); // // SpannableStringBuilder builder = new SpannableStringBuilder(); // builder.append(text); // builder.setSpan( // new ClickableSpan() { // @Override // public void onClick(View view) { // showWebPage(activity, url); // } // }, // text.indexOf(linkText), // text.indexOf(linkText) + linkText.length(), // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE // ); // // textView.setText(builder); // textView.setMovementMethod(LinkMovementMethod.getInstance()); // } // // public static void showWebPage(Activity activity, @NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder() // .setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public static void setTaskDescription(Activity activity, String label, int color) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // activity.setTaskDescription(new ActivityManager.TaskDescription(label, null, color)); // } // } // // public static int getThemeColorPrimary(Context context) { // TypedValue value = new TypedValue(); // context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true); // return value.data; // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/SpeakerSnsIconsView.java import android.app.Activity; import android.content.Context; import android.databinding.BindingAdapter; import android.databinding.DataBindingUtil; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.RelativeLayout; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewSpeakerSnsIconsBinding; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.util.AppUtil; package io.github.droidkaigi.confsched.widget; public class SpeakerSnsIconsView extends RelativeLayout { private ViewSpeakerSnsIconsBinding binding; public SpeakerSnsIconsView(Context context) { this(context, null); } public SpeakerSnsIconsView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SpeakerSnsIconsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_speaker_sns_icons, this, true); } @BindingAdapter("speakerSnsIcons") public static void setSpeakerSnsIcons(SpeakerSnsIconsView view, @NonNull Speaker speaker) { ViewSpeakerSnsIconsBinding binding = view.binding; if (TextUtils.isEmpty(speaker.twitterName) && TextUtils.isEmpty(speaker.githubName)) { binding.getRoot().setVisibility(GONE); return; } if (TextUtils.isEmpty(speaker.twitterName)) { binding.coverTwitter.setVisibility(GONE); } else { binding.coverTwitter.setVisibility(VISIBLE); binding.coverTwitter.setOnClickListener(v ->
AppUtil.showWebPage((Activity) view.getContext(), AppUtil.getTwitterUrl(speaker.twitterName)));
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/fragment/SettingsFragment.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java // @Singleton // public class SessionDao { // // OrmaDatabase orma; // // @Inject // public SessionDao(OrmaDatabase orma) { // this.orma = orma; // } // // public Session_Relation sessionRelation() { // return orma.relationOfSession(); // } // // private Speaker_Relation speakerRelation() { // return orma.relationOfSpeaker(); // } // // private Place_Relation placeRelation() { // return orma.relationOfPlace(); // } // // private Category_Relation categoryRelation() { // return orma.relationOfCategory(); // } // // private void insertSpeaker(Speaker speaker) { // if (speaker != null && speakerRelation().selector().idEq(speaker.id).isEmpty()) { // speakerRelation().inserter().execute(speaker); // } // } // // private void insertPlace(Place place) { // if (place != null && placeRelation().selector().idEq(place.id).isEmpty()) { // placeRelation().inserter().execute(place); // } // } // // private void insertCategory(Category category) { // if (category != null && categoryRelation().selector().idEq(category.id).isEmpty()) { // categoryRelation().inserter().execute(category); // } // } // // public Observable<List<Session>> findAll() { // return sessionRelation().selector().executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByChecked() { // return sessionRelation().selector().checkedEq(true).executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByPlace(int placeId) { // return sessionRelation().selector().placeEq(placeId).executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByCategory(int categoryId) { // return sessionRelation().selector().categoryEq(categoryId).executeAsObservable() // .toList(); // } // // public void deleteAll() { // sessionRelation().deleter().execute(); // speakerRelation().deleter().execute(); // categoryRelation().deleter().execute(); // placeRelation().deleter().execute(); // } // // public void updateAllSync(List<Session> sessions) { // speakerRelation().deleter().execute(); // categoryRelation().deleter().execute(); // placeRelation().deleter().execute(); // // for (Session session : sessions) { // insertSpeaker(session.speaker); // insertCategory(session.category); // insertPlace(session.place); // sessionRelation().upserter().execute(session); // } // } // // // public void updateAllAsync(List<Session> sessions) { // orma.transactionAsync(() -> updateAllSync(sessions)).subscribe(); // } // // public void updateChecked(Session session) { // sessionRelation().updater() // .idEq(session.id) // .checked(session.checked) // .execute(); // } // // }
import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.List; import javax.inject.Inject; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.activity.ActivityNavigator; import io.github.droidkaigi.confsched.dao.SessionDao; import io.github.droidkaigi.confsched.databinding.FragmentSettingsBinding; import io.github.droidkaigi.confsched.prefs.DefaultPrefs; import io.github.droidkaigi.confsched.util.LocaleUtil; import rx.Observable;
package io.github.droidkaigi.confsched.fragment; public class SettingsFragment extends BaseFragment { public static final String TAG = SettingsFragment.class.getSimpleName(); @Inject ActivityNavigator activityNavigator; @Inject
// Path: app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java // @Singleton // public class SessionDao { // // OrmaDatabase orma; // // @Inject // public SessionDao(OrmaDatabase orma) { // this.orma = orma; // } // // public Session_Relation sessionRelation() { // return orma.relationOfSession(); // } // // private Speaker_Relation speakerRelation() { // return orma.relationOfSpeaker(); // } // // private Place_Relation placeRelation() { // return orma.relationOfPlace(); // } // // private Category_Relation categoryRelation() { // return orma.relationOfCategory(); // } // // private void insertSpeaker(Speaker speaker) { // if (speaker != null && speakerRelation().selector().idEq(speaker.id).isEmpty()) { // speakerRelation().inserter().execute(speaker); // } // } // // private void insertPlace(Place place) { // if (place != null && placeRelation().selector().idEq(place.id).isEmpty()) { // placeRelation().inserter().execute(place); // } // } // // private void insertCategory(Category category) { // if (category != null && categoryRelation().selector().idEq(category.id).isEmpty()) { // categoryRelation().inserter().execute(category); // } // } // // public Observable<List<Session>> findAll() { // return sessionRelation().selector().executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByChecked() { // return sessionRelation().selector().checkedEq(true).executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByPlace(int placeId) { // return sessionRelation().selector().placeEq(placeId).executeAsObservable() // .toList(); // } // // public Observable<List<Session>> findByCategory(int categoryId) { // return sessionRelation().selector().categoryEq(categoryId).executeAsObservable() // .toList(); // } // // public void deleteAll() { // sessionRelation().deleter().execute(); // speakerRelation().deleter().execute(); // categoryRelation().deleter().execute(); // placeRelation().deleter().execute(); // } // // public void updateAllSync(List<Session> sessions) { // speakerRelation().deleter().execute(); // categoryRelation().deleter().execute(); // placeRelation().deleter().execute(); // // for (Session session : sessions) { // insertSpeaker(session.speaker); // insertCategory(session.category); // insertPlace(session.place); // sessionRelation().upserter().execute(session); // } // } // // // public void updateAllAsync(List<Session> sessions) { // orma.transactionAsync(() -> updateAllSync(sessions)).subscribe(); // } // // public void updateChecked(Session session) { // sessionRelation().updater() // .idEq(session.id) // .checked(session.checked) // .execute(); // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/fragment/SettingsFragment.java import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.List; import javax.inject.Inject; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.activity.ActivityNavigator; import io.github.droidkaigi.confsched.dao.SessionDao; import io.github.droidkaigi.confsched.databinding.FragmentSettingsBinding; import io.github.droidkaigi.confsched.prefs.DefaultPrefs; import io.github.droidkaigi.confsched.util.LocaleUtil; import rx.Observable; package io.github.droidkaigi.confsched.fragment; public class SettingsFragment extends BaseFragment { public static final String TAG = SettingsFragment.class.getSimpleName(); @Inject ActivityNavigator activityNavigator; @Inject
SessionDao dao;
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/widget/MapSearchView.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/PlaceMap.java // public class PlaceMap { // // @StringRes // public final int nameRes; // // @StringRes // public final int buildingNameRes; // // @DrawableRes // public final int markerRes; // // public final double latitude; // // public final double longitude; // // public PlaceMap(int nameRes, int buildingNameRes, int markerRes, double latitude, double longitude) { // this.nameRes = nameRes; // this.buildingNameRes = buildingNameRes; // this.markerRes = markerRes; // this.latitude = latitude; // this.longitude = longitude; // } // // public static List<PlaceMap> createList() { // List<PlaceMap> list = new ArrayList<>(4); // // list.add(new PlaceMap(R.string.map_main_name, R.string.map_main_building, // R.drawable.ic_place_red_500_36dp_vector, 35.605899, 139.683541)); // list.add(new PlaceMap(R.string.map_ab_name, R.string.map_ab_building, // R.drawable.ic_place_green_500_36dp_vector, 35.603012, 139.684206)); // list.add(new PlaceMap(R.string.map_cd_name, R.string.map_cd_building, // R.drawable.ic_place_blue_500_36dp_vector, 35.603352, 139.684249)); // list.add(new PlaceMap(R.string.map_party_name, R.string.map_party_building, // R.drawable.ic_place_purple_500_36dp_vector, 35.607513, 139.684689)); // // return list; // } // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.databinding.DataBindingUtil; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.FrameLayout; import io.codetail.animation.ViewAnimationUtils; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewMapSearchBinding; import io.github.droidkaigi.confsched.model.PlaceMap; import io.github.droidkaigi.confsched.util.LocaleUtil; import java.util.List; import rx.Observable;
package io.github.droidkaigi.confsched.widget; public class MapSearchView extends FrameLayout { private static final Interpolator INTERPOLATOR = new AccelerateDecelerateInterpolator(); private ViewMapSearchBinding binding; private OnVisibilityChangeListener onVisibilityChangeListener; public MapSearchView(Context context) { this(context, null); } public MapSearchView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public MapSearchView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_map_search, this, true); }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/PlaceMap.java // public class PlaceMap { // // @StringRes // public final int nameRes; // // @StringRes // public final int buildingNameRes; // // @DrawableRes // public final int markerRes; // // public final double latitude; // // public final double longitude; // // public PlaceMap(int nameRes, int buildingNameRes, int markerRes, double latitude, double longitude) { // this.nameRes = nameRes; // this.buildingNameRes = buildingNameRes; // this.markerRes = markerRes; // this.latitude = latitude; // this.longitude = longitude; // } // // public static List<PlaceMap> createList() { // List<PlaceMap> list = new ArrayList<>(4); // // list.add(new PlaceMap(R.string.map_main_name, R.string.map_main_building, // R.drawable.ic_place_red_500_36dp_vector, 35.605899, 139.683541)); // list.add(new PlaceMap(R.string.map_ab_name, R.string.map_ab_building, // R.drawable.ic_place_green_500_36dp_vector, 35.603012, 139.684206)); // list.add(new PlaceMap(R.string.map_cd_name, R.string.map_cd_building, // R.drawable.ic_place_blue_500_36dp_vector, 35.603352, 139.684249)); // list.add(new PlaceMap(R.string.map_party_name, R.string.map_party_building, // R.drawable.ic_place_purple_500_36dp_vector, 35.607513, 139.684689)); // // return list; // } // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/widget/MapSearchView.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.databinding.DataBindingUtil; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.FrameLayout; import io.codetail.animation.ViewAnimationUtils; import io.github.droidkaigi.confsched.R; import io.github.droidkaigi.confsched.databinding.ViewMapSearchBinding; import io.github.droidkaigi.confsched.model.PlaceMap; import io.github.droidkaigi.confsched.util.LocaleUtil; import java.util.List; import rx.Observable; package io.github.droidkaigi.confsched.widget; public class MapSearchView extends FrameLayout { private static final Interpolator INTERPOLATOR = new AccelerateDecelerateInterpolator(); private ViewMapSearchBinding binding; private OnVisibilityChangeListener onVisibilityChangeListener; public MapSearchView(Context context) { this(context, null); } public MapSearchView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public MapSearchView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_map_search, this, true); }
public void bindData(List<PlaceMap> placeMaps, OnItemClickListener listener) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // }
import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Category_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.Place_Relation; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.Session_Relation; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.model.Speaker_Relation; import rx.Observable;
package io.github.droidkaigi.confsched.dao; @Singleton public class SessionDao { OrmaDatabase orma; @Inject public SessionDao(OrmaDatabase orma) { this.orma = orma; } public Session_Relation sessionRelation() { return orma.relationOfSession(); } private Speaker_Relation speakerRelation() { return orma.relationOfSpeaker(); } private Place_Relation placeRelation() { return orma.relationOfPlace(); } private Category_Relation categoryRelation() { return orma.relationOfCategory(); }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Category_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.Place_Relation; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.Session_Relation; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.model.Speaker_Relation; import rx.Observable; package io.github.droidkaigi.confsched.dao; @Singleton public class SessionDao { OrmaDatabase orma; @Inject public SessionDao(OrmaDatabase orma) { this.orma = orma; } public Session_Relation sessionRelation() { return orma.relationOfSession(); } private Speaker_Relation speakerRelation() { return orma.relationOfSpeaker(); } private Place_Relation placeRelation() { return orma.relationOfPlace(); } private Category_Relation categoryRelation() { return orma.relationOfCategory(); }
private void insertSpeaker(Speaker speaker) {
konifar/droidkaigi2016
app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // }
import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Category_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.Place_Relation; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.Session_Relation; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.model.Speaker_Relation; import rx.Observable;
package io.github.droidkaigi.confsched.dao; @Singleton public class SessionDao { OrmaDatabase orma; @Inject public SessionDao(OrmaDatabase orma) { this.orma = orma; } public Session_Relation sessionRelation() { return orma.relationOfSession(); } private Speaker_Relation speakerRelation() { return orma.relationOfSpeaker(); } private Place_Relation placeRelation() { return orma.relationOfPlace(); } private Category_Relation categoryRelation() { return orma.relationOfCategory(); } private void insertSpeaker(Speaker speaker) { if (speaker != null && speakerRelation().selector().idEq(speaker.id).isEmpty()) { speakerRelation().inserter().execute(speaker); } } private void insertPlace(Place place) { if (place != null && placeRelation().selector().idEq(place.id).isEmpty()) { placeRelation().inserter().execute(place); } }
// Path: app/src/main/java/io/github/droidkaigi/confsched/model/Category.java // @Parcel // @Table // public class Category implements SearchGroup { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // public Category() { // } // // public int getThemeResId() { // switch (id) { // case 1: // return R.style.AppTheme_NoActionBar_Amber; // case 2: // return R.style.AppTheme_NoActionBar_Indigo; // case 3: // return R.style.AppTheme_NoActionBar_Orange; // case 4: // return R.style.AppTheme_NoActionBar_Pink; // case 5: // return R.style.AppTheme_NoActionBar_Purple; // case 6: // return R.style.AppTheme_NoActionBar_Teal; // case 7: // return R.style.AppTheme_NoActionBar_LightGreen; // case 8: // return R.style.AppTheme_NoActionBar_Red; // default: // return R.style.AppTheme_NoActionBar_Indigo; // } // } // // public int getVividColorResId() { // switch (id) { // case 1: // return R.color.amber500; // case 2: // return R.color.indigo500; // case 3: // return R.color.orange500; // case 4: // return R.color.pink500; // case 5: // return R.color.purple500; // case 6: // return R.color.teal500; // case 7: // return R.color.lightgreen500; // case 8: // return R.color.red500; // default: // return R.color.indigo500; // } // } // // public int getPaleColorResId() { // switch (id) { // case 1: // return R.color.amber500_alpha_54; // case 2: // return R.color.indigo500_alpha_54; // case 3: // return R.color.orange500_alpha_54; // case 4: // return R.color.pink500_alpha_54; // case 5: // return R.color.purple500_alpha_54; // case 6: // return R.color.teal500_alpha_54; // case 7: // return R.color.lightgreen500_alpha_54; // case 8: // return R.color.red500_alpha_54; // default: // return R.color.indigo500_alpha_54; // } // } // // @Override // public int getId() { // return id; // } // // @Override // public String getName() { // return name; // } // // @Override // public Type getType() { // return Type.CATEGORY; // } // // } // // Path: app/src/main/java/io/github/droidkaigi/confsched/model/Speaker.java // @Parcel // @Table // public class Speaker { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public int id; // // @Column(indexed = true) // @SerializedName("name") // public String name; // // @Column // @Nullable // @SerializedName("image_url") // public String imageUrl; // // @Column // @Nullable // @SerializedName("twitter_name") // public String twitterName; // // @Column // @Nullable // @SerializedName("github_name") // public String githubName; // // } // Path: app/src/main/java/io/github/droidkaigi/confsched/dao/SessionDao.java import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.github.droidkaigi.confsched.model.Category; import io.github.droidkaigi.confsched.model.Category_Relation; import io.github.droidkaigi.confsched.model.OrmaDatabase; import io.github.droidkaigi.confsched.model.Place; import io.github.droidkaigi.confsched.model.Place_Relation; import io.github.droidkaigi.confsched.model.Session; import io.github.droidkaigi.confsched.model.Session_Relation; import io.github.droidkaigi.confsched.model.Speaker; import io.github.droidkaigi.confsched.model.Speaker_Relation; import rx.Observable; package io.github.droidkaigi.confsched.dao; @Singleton public class SessionDao { OrmaDatabase orma; @Inject public SessionDao(OrmaDatabase orma) { this.orma = orma; } public Session_Relation sessionRelation() { return orma.relationOfSession(); } private Speaker_Relation speakerRelation() { return orma.relationOfSpeaker(); } private Place_Relation placeRelation() { return orma.relationOfPlace(); } private Category_Relation categoryRelation() { return orma.relationOfCategory(); } private void insertSpeaker(Speaker speaker) { if (speaker != null && speakerRelation().selector().idEq(speaker.id).isEmpty()) { speakerRelation().inserter().execute(speaker); } } private void insertPlace(Place place) { if (place != null && placeRelation().selector().idEq(place.id).isEmpty()) { placeRelation().inserter().execute(place); } }
private void insertCategory(Category category) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/NemesisCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class NemesisCard extends Card { private String setupDescription;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/NemesisCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class NemesisCard extends Card { private String setupDescription;
public NemesisCard(int id, String name, CardType type, String picture, Expansion expansion, String setupDescription) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/NemesisCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class NemesisCard extends Card { private String setupDescription;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/NemesisCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class NemesisCard extends Card { private String setupDescription;
public NemesisCard(int id, String name, CardType type, String picture, Expansion expansion, String setupDescription) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/utils/GetIntentExtras.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.cards.MarketSetupCard; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.utils; /** * Created by honza on 2.10.17. */ public interface GetIntentExtras { public int getPlayers();
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/utils/GetIntentExtras.java import com.games.boardgames.aeonsend.cards.MarketSetupCard; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.utils; /** * Created by honza on 2.10.17. */ public interface GetIntentExtras { public int getPlayers();
public Expansion[] getExpansions();
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/utils/GetIntentExtras.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.cards.MarketSetupCard; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.utils; /** * Created by honza on 2.10.17. */ public interface GetIntentExtras { public int getPlayers(); public Expansion[] getExpansions();
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/utils/GetIntentExtras.java import com.games.boardgames.aeonsend.cards.MarketSetupCard; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.utils; /** * Created by honza on 2.10.17. */ public interface GetIntentExtras { public int getPlayers(); public Expansion[] getExpansions();
public MarketSetupCard getSetup();
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // }
import android.os.Bundle; import com.games.boardgames.aeonsend.cards.MarketSetupCard; import java.util.List;
package com.games.boardgames.aeonsend.listeners; /** * Created by honza on 2.10.17. */ public interface OnDataPass { public void onDataPass(String name, List list); public void onDataPass(String name, Integer i);
// Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java // public class MarketSetupCard implements Serializable { // private String name; // private int image; // private int numberOfGems; // private int numberofRelics; // private int numberOfSpells; // // private PriceRange[] gemsPriceList; // private PriceRange[] relicsPriceList; // private PriceRange[] spellsPriceList; // // public MarketSetupCard(String name, int image, PriceRange[] gemsPriceList, // PriceRange[] relicsPriceList, PriceRange[] spellsPriceList) { // this.name = name; // this.image = image; // this.gemsPriceList = gemsPriceList; // this.relicsPriceList = relicsPriceList; // this.spellsPriceList = spellsPriceList; // this.numberOfGems = getNumberOfGems(); // this.numberofRelics = getNumberofRelics(); // this.numberOfSpells = getNumberOfSpells(); // // if (numberOfGems + numberofRelics + numberOfSpells != 9) { // Log.d("CreateMarketCard", "MarketSetupCard: " + name + ", has wrong number of Supply Cards." + // " Number of provided supply cards is: " + numberOfGems + numberofRelics + numberOfSpells); // } // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getImage() { // return image; // } // // public void setImage(int image) { // this.image = image; // } // // public int getNumberOfGems() { // Log.d("#GEMS", "getNumberOfGems: " + gemsPriceList.toString()); // return gemsPriceList.length; // } // // public void setNumberOfGems(int numberOfGems) { // this.numberOfGems = numberOfGems; // } // // public int getNumberofRelics() { // return relicsPriceList.length; // } // // public void setNumberofRelics(int numberofRelics) { // this.numberofRelics = numberofRelics; // } // // public int getNumberOfSpells() { // return spellsPriceList.length; // } // // public void setNumberOfSpells(int numberOfSpells) { // this.numberOfSpells = numberOfSpells; // } // // public PriceRange[] getGemsPriceList() { // return gemsPriceList; // } // // public void setGemsPriceList(PriceRange[] gemsPriceList) { // this.gemsPriceList = gemsPriceList; // } // // public PriceRange[] getRelicsPriceList() { // return relicsPriceList; // } // // public void setRelicsPriceList(PriceRange[] relicsPriceList) { // this.relicsPriceList = relicsPriceList; // } // // public PriceRange[] getSpellsPriceList() { // return spellsPriceList; // } // // public void setSpellsPriceList(PriceRange[] spellsPriceList) { // this.spellsPriceList = spellsPriceList; // } // // public static HashMap<PriceRange, Integer> mapPriceRangeFromArray(PriceRange[] priceRanges) { // HashMap<PriceRange, Integer> mapPriceRange = new LinkedHashMap<>(); // int i = 0; // // for (PriceRange priceRange : priceRanges) { // if (!(mapPriceRange.get(priceRange) == null)) { // i = mapPriceRange.get(priceRange); // } else { // i = 0; // } // // mapPriceRange.put(priceRange, ++i); // } // // return mapPriceRange; // } // // public static String toStringPriceRange(HashMap<PriceRange, Integer> mapPriceRange) { // StringBuilder sb = new StringBuilder(); // // for (Map.Entry me : mapPriceRange.entrySet()) { // sb.append(me.getValue() + "x " + me.getKey().toString() + " | "); // } // return sb.toString(); // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java import android.os.Bundle; import com.games.boardgames.aeonsend.cards.MarketSetupCard; import java.util.List; package com.games.boardgames.aeonsend.listeners; /** * Created by honza on 2.10.17. */ public interface OnDataPass { public void onDataPass(String name, List list); public void onDataPass(String name, Integer i);
public void onDataPass(String name, MarketSetupCard card);
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // }
import com.games.boardgames.aeonsend.enums.CardType;
package com.games.boardgames.aeonsend.utils; /** * Created by honza on 25.9.17. */ public class Constants { public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; public static final String DRAWABLEDEFTYPE = "drawable"; // Cards table name
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java import com.games.boardgames.aeonsend.enums.CardType; package com.games.boardgames.aeonsend.utils; /** * Created by honza on 25.9.17. */ public class Constants { public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; public static final String DRAWABLEDEFTYPE = "drawable"; // Cards table name
public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue();
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/ExpansionCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 29.9.17. */ public class ExpansionCard extends Card { private boolean isSelected = false;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/ExpansionCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 29.9.17. */ public class ExpansionCard extends Card { private boolean isSelected = false;
public ExpansionCard(int id, String name, CardType type, String picture, Expansion expansion) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/ExpansionCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 29.9.17. */ public class ExpansionCard extends Card { private boolean isSelected = false;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/ExpansionCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 29.9.17. */ public class ExpansionCard extends Card { private boolean isSelected = false;
public ExpansionCard(int id, String name, CardType type, String picture, Expansion expansion) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // }
import android.util.Log; import com.games.boardgames.aeonsend.enums.PriceRange; import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 14.9.17. */ public class MarketSetupCard implements Serializable { private String name; private int image; private int numberOfGems; private int numberofRelics; private int numberOfSpells;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/MarketSetupCard.java import android.util.Log; import com.games.boardgames.aeonsend.enums.PriceRange; import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 14.9.17. */ public class MarketSetupCard implements Serializable { private String name; private int image; private int numberOfGems; private int numberofRelics; private int numberOfSpells;
private PriceRange[] gemsPriceList;
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/SupplyCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class SupplyCard extends Card { protected PriceRange price;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/SupplyCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class SupplyCard extends Card { protected PriceRange price;
public SupplyCard(int id, String name, CardType type, String picture, PriceRange price, Expansion expansion) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/SupplyCard.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // }
import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class SupplyCard extends Card { protected PriceRange price;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/SupplyCard.java import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class SupplyCard extends Card { protected PriceRange price;
public SupplyCard(int id, String name, CardType type, String picture, PriceRange price, Expansion expansion) {
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange;
package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers;
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // } // Path: app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange; package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers;
private OnDataPass dataPasser;
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange;
package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers; private OnDataPass dataPasser;
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // } // Path: app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange; package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers; private OnDataPass dataPasser;
private OnPlayersChange playerChanger;
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange;
package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers; private OnDataPass dataPasser; private OnPlayersChange playerChanger; @Override public void onAttach(Context context) { super.onAttach(context); dataPasser = (OnDataPass) context; playerChanger = (OnPlayersChange) context;
// Path: app/src/main/java/com/games/boardgames/aeonsend/utils/Constants.java // public class Constants { // public static final String PACKAGENAME = "com.games.boardgames.aeonsend"; // public static final String DRAWABLEDEFTYPE = "drawable"; // // // Cards table name // public final static String EXPANSIONTABLE = CardType.EXPANSION.getValue(); // public final static String NEMESISTABLE = CardType.NEMESIS.getValue(); // public final static String CHARACTERTABLE = CardType.CHARACTER.getValue(); // public final static String GEMTABLE = CardType.GEM.getValue(); // public final static String RELICTABLE = CardType.RELIC.getValue(); // public final static String SPELLTABLE = CardType.SPELL.getValue(); // public final static String[] tables = {EXPANSIONTABLE, NEMESISTABLE, CHARACTERTABLE, GEMTABLE, RELICTABLE, SPELLTABLE}; // // // Extras names // public final static String EXTRASNUMPLAYERS = "numPlayers"; // public final static String EXTRASCHOSENSETUP = "chosenSetup"; // public final static String EXTRASSELECTEDEXPANSION = "selectedExpansions"; // // // Refresh wait // public final static Integer REFRESHWAIT = 500; // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnDataPass.java // public interface OnDataPass { // public void onDataPass(String name, List list); // // public void onDataPass(String name, Integer i); // // public void onDataPass(String name, MarketSetupCard card); // // public Bundle getFragmentValuesBundle(); // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/listeners/OnPlayersChange.java // public interface OnPlayersChange { // void onPlayersChange(int number); // } // Path: app/src/main/java/com/games/boardgames/aeonsend/fragments/PlayersBottomSheetDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.games.boardgames.aeonsend.R; import com.games.boardgames.aeonsend.utils.Constants; import com.games.boardgames.aeonsend.listeners.OnDataPass; import com.games.boardgames.aeonsend.listeners.OnPlayersChange; package com.games.boardgames.aeonsend.fragments; /** * Created by honza on 29.9.17. */ public class PlayersBottomSheetDialogFragment extends BottomSheetDialogFragment { private TextView textView; private ImageView subtractImageView; private ImageView addImageView; private int numPlayers; private OnDataPass dataPasser; private OnPlayersChange playerChanger; @Override public void onAttach(Context context) { super.onAttach(context); dataPasser = (OnDataPass) context; playerChanger = (OnPlayersChange) context;
numPlayers = dataPasser.getFragmentValuesBundle().getInt(Constants.EXTRASNUMPLAYERS);
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // }
import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class Card implements Serializable { protected int id; protected String name;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class Card implements Serializable { protected int id; protected String name;
protected CardType type;
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // }
import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable;
package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class Card implements Serializable { protected int id; protected String name; protected CardType type; protected String picture;
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable; package com.games.boardgames.aeonsend.cards; /** * Created by honza on 3.9.17. */ public class Card implements Serializable { protected int id; protected String name; protected CardType type; protected String picture;
protected Expansion expansion;
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // }
import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable;
public void setName(String name) { this.name = name; } public CardType getType() { return type; } public void setType(CardType type) { this.type = type; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public Expansion getExpansion() { return expansion; } public void setExpansion(Expansion expansion) { this.expansion = expansion; } // Map obtained cursor data to Card object and return correct object based on the value of type public static Card getCardFromCursor(Cursor cursor) throws Exception {
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable; public void setName(String name) { this.name = name; } public CardType getType() { return type; } public void setType(CardType type) { this.type = type; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public Expansion getExpansion() { return expansion; } public void setExpansion(Expansion expansion) { this.expansion = expansion; } // Map obtained cursor data to Card object and return correct object based on the value of type public static Card getCardFromCursor(Cursor cursor) throws Exception {
int id = cursor.getInt(cursor.getColumnIndex(TableColumns.KEY_ID.getValue()));
JanSvoboda/aeonsend-randomizer
app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // }
import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable;
return type; } public void setType(CardType type) { this.type = type; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public Expansion getExpansion() { return expansion; } public void setExpansion(Expansion expansion) { this.expansion = expansion; } // Map obtained cursor data to Card object and return correct object based on the value of type public static Card getCardFromCursor(Cursor cursor) throws Exception { int id = cursor.getInt(cursor.getColumnIndex(TableColumns.KEY_ID.getValue())); String name = cursor.getString(cursor.getColumnIndex(TableColumns.KEY_NAME.getValue())); CardType type = CardType.fromString(cursor.getString(cursor.getColumnIndex(TableColumns.KEY_TYPE.getValue()))); String picture = cursor.getString(cursor.getColumnIndex(TableColumns.KEY_PICTURE.getValue())); Expansion expansion = Expansion.valueOf(cursor.getString(cursor.getColumnIndex(TableColumns.KEY_EXPANSION.getValue())));
// Path: app/src/main/java/com/games/boardgames/aeonsend/enums/CardType.java // public enum CardType { // EXPANSION("expansion"), // SPELL("spell"), // RELIC("relic"), // GEM("gem"), // NEMESIS("nemesis"), // CHARACTER("character"); // // // private String value; // // CardType(String value) { // this.value = value; // } // // public String getValue() { // return this.value; // } // // private static final CardType[] copyOfValues = values(); // // public static CardType fromString(String value) { // for (CardType type : copyOfValues) { // if (type.value.equalsIgnoreCase(value)) { // return type; // } // } // return null; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/Expansion.java // public enum Expansion { // BASIC(0), DEPTHS(1), NAMELESS(2); // // private int value; // // Expansion(int i) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/PriceRange.java // public enum PriceRange { // ANY(0, 9, "ANY"), // TWO(2, 2, "2"), // THREE(3, 3, "3"), // FOUR(4, 4, "4"), // FIVE(5, 5, "5"), // SIX(6, 6, "6"), // SEVEN(7, 7, "7"), // EIGHT(8, 8, "8"), // NULL(0, 0, "0"), // LESSTHANFOUR(0, 3, "<4"), // LESSTHANFIVE(0, 4, "<5"), // LESSTHANSIX(0, 5, "<6"), // MORETHANTHREE(4, 9, ">3"), // MORETHANFOUR(5, 9, ">4"), // MORETHANFIVE(6, 9, ">5"), // MORETHANSIX(7, 9, ">6"), // THREEORFOUR(3, 4, "3/4"), // FOURORFIVE(4, 5, "4/5"), // FIVEORSIX(5, 6, "5/6"); // // private int minPrice; // private int maxPrice; // private String name; // // PriceRange(int minPrice, int maxPrice, String name) { // this.minPrice = minPrice; // this.maxPrice = maxPrice; // this.name = name; // } // // public int getMinPrice() { // return minPrice; // } // // public void setMinPrice(int minPrice) { // this.minPrice = minPrice; // } // // public int getMaxPrice() { // return maxPrice; // } // // public void setMaxPrice(int maxPrice) { // this.maxPrice = maxPrice; // } // // @Override // public String toString() { // return name; // } // // private static final PriceRange[] copyOfValues = values(); // // public static PriceRange fromString(String name) { // for (PriceRange priceRange : copyOfValues) { // if (priceRange.name.equalsIgnoreCase(name)) { // return priceRange; // } // } // return null; // } // // } // // Path: app/src/main/java/com/games/boardgames/aeonsend/enums/TableColumns.java // public enum TableColumns { // KEY_ID("id"), KEY_NAME("name"), KEY_TYPE("type"), KEY_PRICE("price"), KEY_PICTURE("picture"), KEY_EXPANSION("expansion"), KEY_SETUPDESCRIPTION("setup_description"); // // private String value; // // TableColumns(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // } // Path: app/src/main/java/com/games/boardgames/aeonsend/cards/Card.java import android.database.Cursor; import com.games.boardgames.aeonsend.enums.CardType; import com.games.boardgames.aeonsend.enums.Expansion; import com.games.boardgames.aeonsend.enums.PriceRange; import com.games.boardgames.aeonsend.enums.TableColumns; import java.io.Serializable; return type; } public void setType(CardType type) { this.type = type; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public Expansion getExpansion() { return expansion; } public void setExpansion(Expansion expansion) { this.expansion = expansion; } // Map obtained cursor data to Card object and return correct object based on the value of type public static Card getCardFromCursor(Cursor cursor) throws Exception { int id = cursor.getInt(cursor.getColumnIndex(TableColumns.KEY_ID.getValue())); String name = cursor.getString(cursor.getColumnIndex(TableColumns.KEY_NAME.getValue())); CardType type = CardType.fromString(cursor.getString(cursor.getColumnIndex(TableColumns.KEY_TYPE.getValue()))); String picture = cursor.getString(cursor.getColumnIndex(TableColumns.KEY_PICTURE.getValue())); Expansion expansion = Expansion.valueOf(cursor.getString(cursor.getColumnIndex(TableColumns.KEY_EXPANSION.getValue())));
PriceRange price = null;
Predelnik/ChibiPaintMod
src/chibipaint/controller/CPCommandSettings.java
// Path: src/chibipaint/gui/CPIconButton.java // public class CPIconButton extends JComponent implements MouseListener // { // // private final Image icons; // private final int iconW; // private final int iconH; // private final int iconIndex; // private final int border; // private CPCommandId commandId; // private CPCommandId doubleClickCommandId; // private final ArrayList<ICPController> controllers = new ArrayList<ICPController> (); // // private boolean mouseOver = false; // private boolean mousePressed = false; // private boolean selected = false; // // public CPIconButton (Image icons, int iconW, int iconH, int iconIndex, int border) // { // this.icons = icons; // this.iconW = iconW; // this.iconH = iconH; // this.iconIndex = iconIndex; // this.border = border; // // MediaTracker tracker = new MediaTracker (this); // tracker.addImage (icons, 0); // try // { // tracker.waitForAll (); // } // catch (Exception ignored) // { // } // // addMouseListener (this); // } // // public void setSelected (boolean s) // { // if (selected != s) // { // selected = s; // repaint (); // } // } // // @Override // public void paint (Graphics g) // { // Dimension d = getSize (); // g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) // * iconH, null); // // if (!this.isEnabled ()) // { // g.setColor (Color.lightGray); // } // else if (mouseOver && !mousePressed) // { // g.setColor (Color.orange); // } // else if (selected || mousePressed) // { // g.setColor (Color.red); // } // else // { // g.setColor (Color.black); // } // // g.drawRect (0, 0, d.width - 1, d.height - 1); // } // // @Override // public void mouseClicked (MouseEvent e) // { // if (e.getClickCount () == 2 && doubleClickCommandId != null) // { // for (ICPController controller : controllers) // controller.performCommand (doubleClickCommandId, new CPCommandSettings.SourceIconButton (this)); // } // } // // @Override // public void mouseEntered (MouseEvent e) // { // mouseOver = true; // repaint (); // } // // @Override // public void mouseExited (MouseEvent e) // { // mouseOver = false; // repaint (); // } // // @Override // public void mousePressed (MouseEvent e) // { // requestFocusInWindow (); // // if (!this.isEnabled ()) // return; // // mousePressed = true; // repaint (); // } // // @Override // public void mouseReleased (MouseEvent e) // { // if (!this.isEnabled ()) // return; // // if (mouseOver) // { // for (ICPController controller : controllers) // controller.performCommand (commandId, new CPCommandSettings.SourceIconButton (this)); // } // mousePressed = false; // repaint (); // } // // void addController (ICPController l) // { // controllers.add (l); // } // // void setCPActionCommand (CPCommandId command) // { // commandId = command; // } // // public void setCPActionCommandDouble (CPCommandId command) // { // doubleClickCommandId = command; // } // // @Override // public Dimension getPreferredSize () // { // return new Dimension (iconW + 2 * border, iconH + 2 * border); // } // // @Override // public Dimension getMaximumSize () // { // return getPreferredSize (); // } // // @Override // public Dimension getMinimumSize () // { // return getPreferredSize (); // } // // } // // Path: src/chibipaint/util/CPEnums.java // public class CPEnums // { // public static enum Direction // { // Up, // Down, // Left, // Right, // Invalid; // // public static Direction fromKeyEvent (KeyEvent event) // { // switch (event.getKeyCode ()) // { // case KeyEvent.VK_LEFT: // return Left; // case KeyEvent.VK_RIGHT: // return Right; // case KeyEvent.VK_UP: // return Up; // case KeyEvent.VK_DOWN: // return Down; // default: // return Invalid; // } // } // } // }
import chibipaint.util.CPEnums; import chibipaint.gui.CPIconButton;
/* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.controller; public interface CPCommandSettings { public class FileExtension implements CPCommandSettings { public final String extension; public FileExtension (String value) { extension = value; } } public class RecentFileNumber implements CPCommandSettings { public final int number; public RecentFileNumber (int numberArg) { number = numberArg; } } public class CheckBoxState implements CPCommandSettings { public final boolean checked; public CheckBoxState (boolean checkedArg) { checked = checkedArg; } } public class DirectionSettings implements CPCommandSettings {
// Path: src/chibipaint/gui/CPIconButton.java // public class CPIconButton extends JComponent implements MouseListener // { // // private final Image icons; // private final int iconW; // private final int iconH; // private final int iconIndex; // private final int border; // private CPCommandId commandId; // private CPCommandId doubleClickCommandId; // private final ArrayList<ICPController> controllers = new ArrayList<ICPController> (); // // private boolean mouseOver = false; // private boolean mousePressed = false; // private boolean selected = false; // // public CPIconButton (Image icons, int iconW, int iconH, int iconIndex, int border) // { // this.icons = icons; // this.iconW = iconW; // this.iconH = iconH; // this.iconIndex = iconIndex; // this.border = border; // // MediaTracker tracker = new MediaTracker (this); // tracker.addImage (icons, 0); // try // { // tracker.waitForAll (); // } // catch (Exception ignored) // { // } // // addMouseListener (this); // } // // public void setSelected (boolean s) // { // if (selected != s) // { // selected = s; // repaint (); // } // } // // @Override // public void paint (Graphics g) // { // Dimension d = getSize (); // g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) // * iconH, null); // // if (!this.isEnabled ()) // { // g.setColor (Color.lightGray); // } // else if (mouseOver && !mousePressed) // { // g.setColor (Color.orange); // } // else if (selected || mousePressed) // { // g.setColor (Color.red); // } // else // { // g.setColor (Color.black); // } // // g.drawRect (0, 0, d.width - 1, d.height - 1); // } // // @Override // public void mouseClicked (MouseEvent e) // { // if (e.getClickCount () == 2 && doubleClickCommandId != null) // { // for (ICPController controller : controllers) // controller.performCommand (doubleClickCommandId, new CPCommandSettings.SourceIconButton (this)); // } // } // // @Override // public void mouseEntered (MouseEvent e) // { // mouseOver = true; // repaint (); // } // // @Override // public void mouseExited (MouseEvent e) // { // mouseOver = false; // repaint (); // } // // @Override // public void mousePressed (MouseEvent e) // { // requestFocusInWindow (); // // if (!this.isEnabled ()) // return; // // mousePressed = true; // repaint (); // } // // @Override // public void mouseReleased (MouseEvent e) // { // if (!this.isEnabled ()) // return; // // if (mouseOver) // { // for (ICPController controller : controllers) // controller.performCommand (commandId, new CPCommandSettings.SourceIconButton (this)); // } // mousePressed = false; // repaint (); // } // // void addController (ICPController l) // { // controllers.add (l); // } // // void setCPActionCommand (CPCommandId command) // { // commandId = command; // } // // public void setCPActionCommandDouble (CPCommandId command) // { // doubleClickCommandId = command; // } // // @Override // public Dimension getPreferredSize () // { // return new Dimension (iconW + 2 * border, iconH + 2 * border); // } // // @Override // public Dimension getMaximumSize () // { // return getPreferredSize (); // } // // @Override // public Dimension getMinimumSize () // { // return getPreferredSize (); // } // // } // // Path: src/chibipaint/util/CPEnums.java // public class CPEnums // { // public static enum Direction // { // Up, // Down, // Left, // Right, // Invalid; // // public static Direction fromKeyEvent (KeyEvent event) // { // switch (event.getKeyCode ()) // { // case KeyEvent.VK_LEFT: // return Left; // case KeyEvent.VK_RIGHT: // return Right; // case KeyEvent.VK_UP: // return Up; // case KeyEvent.VK_DOWN: // return Down; // default: // return Invalid; // } // } // } // } // Path: src/chibipaint/controller/CPCommandSettings.java import chibipaint.util.CPEnums; import chibipaint.gui.CPIconButton; /* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.controller; public interface CPCommandSettings { public class FileExtension implements CPCommandSettings { public final String extension; public FileExtension (String value) { extension = value; } } public class RecentFileNumber implements CPCommandSettings { public final int number; public RecentFileNumber (int numberArg) { number = numberArg; } } public class CheckBoxState implements CPCommandSettings { public final boolean checked; public CheckBoxState (boolean checkedArg) { checked = checkedArg; } } public class DirectionSettings implements CPCommandSettings {
public final CPEnums.Direction direction;
Predelnik/ChibiPaintMod
src/chibipaint/controller/CPCommandSettings.java
// Path: src/chibipaint/gui/CPIconButton.java // public class CPIconButton extends JComponent implements MouseListener // { // // private final Image icons; // private final int iconW; // private final int iconH; // private final int iconIndex; // private final int border; // private CPCommandId commandId; // private CPCommandId doubleClickCommandId; // private final ArrayList<ICPController> controllers = new ArrayList<ICPController> (); // // private boolean mouseOver = false; // private boolean mousePressed = false; // private boolean selected = false; // // public CPIconButton (Image icons, int iconW, int iconH, int iconIndex, int border) // { // this.icons = icons; // this.iconW = iconW; // this.iconH = iconH; // this.iconIndex = iconIndex; // this.border = border; // // MediaTracker tracker = new MediaTracker (this); // tracker.addImage (icons, 0); // try // { // tracker.waitForAll (); // } // catch (Exception ignored) // { // } // // addMouseListener (this); // } // // public void setSelected (boolean s) // { // if (selected != s) // { // selected = s; // repaint (); // } // } // // @Override // public void paint (Graphics g) // { // Dimension d = getSize (); // g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) // * iconH, null); // // if (!this.isEnabled ()) // { // g.setColor (Color.lightGray); // } // else if (mouseOver && !mousePressed) // { // g.setColor (Color.orange); // } // else if (selected || mousePressed) // { // g.setColor (Color.red); // } // else // { // g.setColor (Color.black); // } // // g.drawRect (0, 0, d.width - 1, d.height - 1); // } // // @Override // public void mouseClicked (MouseEvent e) // { // if (e.getClickCount () == 2 && doubleClickCommandId != null) // { // for (ICPController controller : controllers) // controller.performCommand (doubleClickCommandId, new CPCommandSettings.SourceIconButton (this)); // } // } // // @Override // public void mouseEntered (MouseEvent e) // { // mouseOver = true; // repaint (); // } // // @Override // public void mouseExited (MouseEvent e) // { // mouseOver = false; // repaint (); // } // // @Override // public void mousePressed (MouseEvent e) // { // requestFocusInWindow (); // // if (!this.isEnabled ()) // return; // // mousePressed = true; // repaint (); // } // // @Override // public void mouseReleased (MouseEvent e) // { // if (!this.isEnabled ()) // return; // // if (mouseOver) // { // for (ICPController controller : controllers) // controller.performCommand (commandId, new CPCommandSettings.SourceIconButton (this)); // } // mousePressed = false; // repaint (); // } // // void addController (ICPController l) // { // controllers.add (l); // } // // void setCPActionCommand (CPCommandId command) // { // commandId = command; // } // // public void setCPActionCommandDouble (CPCommandId command) // { // doubleClickCommandId = command; // } // // @Override // public Dimension getPreferredSize () // { // return new Dimension (iconW + 2 * border, iconH + 2 * border); // } // // @Override // public Dimension getMaximumSize () // { // return getPreferredSize (); // } // // @Override // public Dimension getMinimumSize () // { // return getPreferredSize (); // } // // } // // Path: src/chibipaint/util/CPEnums.java // public class CPEnums // { // public static enum Direction // { // Up, // Down, // Left, // Right, // Invalid; // // public static Direction fromKeyEvent (KeyEvent event) // { // switch (event.getKeyCode ()) // { // case KeyEvent.VK_LEFT: // return Left; // case KeyEvent.VK_RIGHT: // return Right; // case KeyEvent.VK_UP: // return Up; // case KeyEvent.VK_DOWN: // return Down; // default: // return Invalid; // } // } // } // }
import chibipaint.util.CPEnums; import chibipaint.gui.CPIconButton;
public RecentFileNumber (int numberArg) { number = numberArg; } } public class CheckBoxState implements CPCommandSettings { public final boolean checked; public CheckBoxState (boolean checkedArg) { checked = checkedArg; } } public class DirectionSettings implements CPCommandSettings { public final CPEnums.Direction direction; public DirectionSettings (CPEnums.Direction directionArg) { direction = directionArg; } } // This is because icon button rely heavily on this // TODO: remove this logic public class SourceIconButton implements CPCommandSettings {
// Path: src/chibipaint/gui/CPIconButton.java // public class CPIconButton extends JComponent implements MouseListener // { // // private final Image icons; // private final int iconW; // private final int iconH; // private final int iconIndex; // private final int border; // private CPCommandId commandId; // private CPCommandId doubleClickCommandId; // private final ArrayList<ICPController> controllers = new ArrayList<ICPController> (); // // private boolean mouseOver = false; // private boolean mousePressed = false; // private boolean selected = false; // // public CPIconButton (Image icons, int iconW, int iconH, int iconIndex, int border) // { // this.icons = icons; // this.iconW = iconW; // this.iconH = iconH; // this.iconIndex = iconIndex; // this.border = border; // // MediaTracker tracker = new MediaTracker (this); // tracker.addImage (icons, 0); // try // { // tracker.waitForAll (); // } // catch (Exception ignored) // { // } // // addMouseListener (this); // } // // public void setSelected (boolean s) // { // if (selected != s) // { // selected = s; // repaint (); // } // } // // @Override // public void paint (Graphics g) // { // Dimension d = getSize (); // g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) // * iconH, null); // // if (!this.isEnabled ()) // { // g.setColor (Color.lightGray); // } // else if (mouseOver && !mousePressed) // { // g.setColor (Color.orange); // } // else if (selected || mousePressed) // { // g.setColor (Color.red); // } // else // { // g.setColor (Color.black); // } // // g.drawRect (0, 0, d.width - 1, d.height - 1); // } // // @Override // public void mouseClicked (MouseEvent e) // { // if (e.getClickCount () == 2 && doubleClickCommandId != null) // { // for (ICPController controller : controllers) // controller.performCommand (doubleClickCommandId, new CPCommandSettings.SourceIconButton (this)); // } // } // // @Override // public void mouseEntered (MouseEvent e) // { // mouseOver = true; // repaint (); // } // // @Override // public void mouseExited (MouseEvent e) // { // mouseOver = false; // repaint (); // } // // @Override // public void mousePressed (MouseEvent e) // { // requestFocusInWindow (); // // if (!this.isEnabled ()) // return; // // mousePressed = true; // repaint (); // } // // @Override // public void mouseReleased (MouseEvent e) // { // if (!this.isEnabled ()) // return; // // if (mouseOver) // { // for (ICPController controller : controllers) // controller.performCommand (commandId, new CPCommandSettings.SourceIconButton (this)); // } // mousePressed = false; // repaint (); // } // // void addController (ICPController l) // { // controllers.add (l); // } // // void setCPActionCommand (CPCommandId command) // { // commandId = command; // } // // public void setCPActionCommandDouble (CPCommandId command) // { // doubleClickCommandId = command; // } // // @Override // public Dimension getPreferredSize () // { // return new Dimension (iconW + 2 * border, iconH + 2 * border); // } // // @Override // public Dimension getMaximumSize () // { // return getPreferredSize (); // } // // @Override // public Dimension getMinimumSize () // { // return getPreferredSize (); // } // // } // // Path: src/chibipaint/util/CPEnums.java // public class CPEnums // { // public static enum Direction // { // Up, // Down, // Left, // Right, // Invalid; // // public static Direction fromKeyEvent (KeyEvent event) // { // switch (event.getKeyCode ()) // { // case KeyEvent.VK_LEFT: // return Left; // case KeyEvent.VK_RIGHT: // return Right; // case KeyEvent.VK_UP: // return Up; // case KeyEvent.VK_DOWN: // return Down; // default: // return Invalid; // } // } // } // } // Path: src/chibipaint/controller/CPCommandSettings.java import chibipaint.util.CPEnums; import chibipaint.gui.CPIconButton; public RecentFileNumber (int numberArg) { number = numberArg; } } public class CheckBoxState implements CPCommandSettings { public final boolean checked; public CheckBoxState (boolean checkedArg) { checked = checkedArg; } } public class DirectionSettings implements CPCommandSettings { public final CPEnums.Direction direction; public DirectionSettings (CPEnums.Direction directionArg) { direction = directionArg; } } // This is because icon button rely heavily on this // TODO: remove this logic public class SourceIconButton implements CPCommandSettings {
public final CPIconButton button;
Predelnik/ChibiPaintMod
src/chibipaint/gui/CPIconButton.java
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // }
import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList;
/* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.gui; public class CPIconButton extends JComponent implements MouseListener { private final Image icons; private final int iconW; private final int iconH; private final int iconIndex; private final int border;
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // } // Path: src/chibipaint/gui/CPIconButton.java import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; /* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.gui; public class CPIconButton extends JComponent implements MouseListener { private final Image icons; private final int iconW; private final int iconH; private final int iconIndex; private final int border;
private CPCommandId commandId;
Predelnik/ChibiPaintMod
src/chibipaint/gui/CPIconButton.java
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // }
import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList;
/* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.gui; public class CPIconButton extends JComponent implements MouseListener { private final Image icons; private final int iconW; private final int iconH; private final int iconIndex; private final int border; private CPCommandId commandId; private CPCommandId doubleClickCommandId;
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // } // Path: src/chibipaint/gui/CPIconButton.java import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; /* * ChibiPaintMod * Copyright (c) 2012-2014 Sergey Semushin * Copyright (c) 2006-2008 Marc Schefer * * This file is part of ChibiPaintMod (previously ChibiPaint). * * ChibiPaintMod 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. * * ChibiPaintMod 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 ChibiPaintMod. If not, see <http://www.gnu.org/licenses/>. */ package chibipaint.gui; public class CPIconButton extends JComponent implements MouseListener { private final Image icons; private final int iconW; private final int iconH; private final int iconIndex; private final int border; private CPCommandId commandId; private CPCommandId doubleClickCommandId;
private final ArrayList<ICPController> controllers = new ArrayList<ICPController> ();
Predelnik/ChibiPaintMod
src/chibipaint/gui/CPIconButton.java
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // }
import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList;
Dimension d = getSize (); g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) * iconH, null); if (!this.isEnabled ()) { g.setColor (Color.lightGray); } else if (mouseOver && !mousePressed) { g.setColor (Color.orange); } else if (selected || mousePressed) { g.setColor (Color.red); } else { g.setColor (Color.black); } g.drawRect (0, 0, d.width - 1, d.height - 1); } @Override public void mouseClicked (MouseEvent e) { if (e.getClickCount () == 2 && doubleClickCommandId != null) { for (ICPController controller : controllers)
// Path: src/chibipaint/controller/CPCommandId.java // public enum CPCommandId // { // ZoomIn, // ZoomOut, // Zoom100, // ZoomSpecific, // Undo, // Redo, // ClearHistory, // Pencil, // Pen, // Eraser, // SoftEraser, // AirBrush, // Dodge, // Burn, // Water, // Blur, // Smudge, // Blender, // FloodFill, // MagicWand, // FreeSelection, // FreeTransform, // RectSelection, // RotateCanvas, // FreeHand, // Line, // Bezier, // About, // Test, // LayerToggleAll, // LayerDuplicate, // LayerMergeDown, // LayerMergeAll, // Fill, // Clear, // SelectAll, // AlphaToSelection, // InvertSelection, // DeselectAll, // MNoise, // CNoise, // FXBoxBlur, // FXGaussianBlur, // FXInvert, // FXMakeGrayscaleByLuma, // ApplyToAllLayers, // ShowSelection, // LinearInterpolation, // ShowGrid, // GridOptions, // ResetCanvasRotation, // PalColor, // PalBrush, // PalLayers, // PalStroke, // PalSwatches, // PalTool, // PalMisc, // PalTextures, // TogglePalettes, // Copy, // CopyMerged, // Paste, // Cut, // ApplyTransform, // CancelTransform, // MoveTransform, // FlipHorizontally, // FlipVertically, // Rotate90CCW, // Rotate90CW, // AddLayer, // RemoveLayer, // // // Don't forget to add ids to corresponding functions below // // // For App only: // Export, // Additional in info is extension // Import, // Additional in info is extension // Exit, // Save, // New, // OpenRecent, // Additional in info is number // // // For Applet only: // Float, // Send; // // public boolean isForAppOnly () // { // switch (this) // { // case Export: // case Import: // case Exit: // case OpenRecent: // case Save: // case New: // return true; // default: // return false; // } // } // // public boolean isForAppletOnly () // { // switch (this) // { // case Float: // case Send: // return true; // default: // return false; // } // } // // public boolean isSpecificToType () // { // return (this.isForAppletOnly () || this.isForAppOnly ()); // } // } // // Path: src/chibipaint/controller/CPCommandSettings.java // public interface CPCommandSettings // { // public class FileExtension implements CPCommandSettings // { // public final String extension; // // public FileExtension (String value) // { // extension = value; // } // } // // public class RecentFileNumber implements CPCommandSettings // { // public final int number; // // public RecentFileNumber (int numberArg) // { // number = numberArg; // } // } // // public class CheckBoxState implements CPCommandSettings // { // public final boolean checked; // // public CheckBoxState (boolean checkedArg) // { // checked = checkedArg; // } // } // // public class DirectionSettings implements CPCommandSettings // { // public final CPEnums.Direction direction; // // public DirectionSettings (CPEnums.Direction directionArg) // { // direction = directionArg; // } // } // // // This is because icon button rely heavily on this // // TODO: remove this logic // public class SourceIconButton implements CPCommandSettings // { // public final CPIconButton button; // // public SourceIconButton (CPIconButton buttonArg) // { // button = buttonArg; // } // } // // // } // // Path: src/chibipaint/controller/ICPController.java // public interface ICPController // { // abstract public void performCommand (CPCommandId commandId, CPCommandSettings commandSettings); // } // Path: src/chibipaint/gui/CPIconButton.java import chibipaint.controller.CPCommandId; import chibipaint.controller.CPCommandSettings; import chibipaint.controller.ICPController; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; Dimension d = getSize (); g.drawImage (icons, border, border, iconW + border, iconH + border, 0, iconIndex * iconH, iconW, (iconIndex + 1) * iconH, null); if (!this.isEnabled ()) { g.setColor (Color.lightGray); } else if (mouseOver && !mousePressed) { g.setColor (Color.orange); } else if (selected || mousePressed) { g.setColor (Color.red); } else { g.setColor (Color.black); } g.drawRect (0, 0, d.width - 1, d.height - 1); } @Override public void mouseClicked (MouseEvent e) { if (e.getClickCount () == 2 && doubleClickCommandId != null) { for (ICPController controller : controllers)
controller.performCommand (doubleClickCommandId, new CPCommandSettings.SourceIconButton (this));
kpavlov/fixio
core/src/main/java/fixio/handlers/FixMessageHandler.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // }
import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import io.netty.channel.ChannelHandlerContext;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixMessageHandler { /** * Performs some processing on incoming {@link FixMessage}. * * @param ctx current ChannelHandlerContext * @param msg a FixMessage to handle * @return true if message should be handled by following {@link FixMessageHandler} in a chain. */ boolean handle(ChannelHandlerContext ctx, FixMessage msg);
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // Path: core/src/main/java/fixio/handlers/FixMessageHandler.java import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import io.netty.channel.ChannelHandlerContext; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixMessageHandler { /** * Performs some processing on incoming {@link FixMessage}. * * @param ctx current ChannelHandlerContext * @param msg a FixMessage to handle * @return true if message should be handled by following {@link FixMessageHandler} in a chain. */ boolean handle(ChannelHandlerContext ctx, FixMessage msg);
void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder);
kpavlov/fixio
core/src/main/java/fixio/fixprotocol/fields/StringField.java
// Path: core/src/main/java/fixio/Utils.java // public class Utils { // // private Utils() { // } // // /** // * Converts a String to ASCII byte array, provided that string contains only ASCII characters. // * // * @param str string to convert // * @return a byte array // * @see <a href="http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html">Java Best Practices char to byte</a> // */ // public static byte[] stringToBytesASCII(String str) { // char[] buffer = str.toCharArray(); // final int length = buffer.length; // byte[] b = new byte[length]; // for (int i = 0; i < length; i++) { // b[i] = (byte) buffer[i]; // } // return b; // } // // /** // * Converts ASCII byte array to String, provided that string contains only ASCII characters. // * // * @param bytes a byte array tp convert // * @return converted String // * @see <a href="http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html">Java Best Practices char to byte</a> // */ // public static String bytesToStringASCII(byte[] bytes) { // final int length = bytes.length; // char[] buffer = new char[length]; // for (int i = 0; i < length; i++) { // buffer[i] = (char) bytes[i]; // } // return new String(buffer); // } // // }
import fixio.Utils; import java.util.Arrays;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class StringField extends AbstractField<String> { private final byte[] value; public StringField(int tagNum, String value) { super(tagNum);
// Path: core/src/main/java/fixio/Utils.java // public class Utils { // // private Utils() { // } // // /** // * Converts a String to ASCII byte array, provided that string contains only ASCII characters. // * // * @param str string to convert // * @return a byte array // * @see <a href="http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html">Java Best Practices char to byte</a> // */ // public static byte[] stringToBytesASCII(String str) { // char[] buffer = str.toCharArray(); // final int length = buffer.length; // byte[] b = new byte[length]; // for (int i = 0; i < length; i++) { // b[i] = (byte) buffer[i]; // } // return b; // } // // /** // * Converts ASCII byte array to String, provided that string contains only ASCII characters. // * // * @param bytes a byte array tp convert // * @return converted String // * @see <a href="http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html">Java Best Practices char to byte</a> // */ // public static String bytesToStringASCII(byte[] bytes) { // final int length = bytes.length; // char[] buffer = new char[length]; // for (int i = 0; i < length; i++) { // buffer[i] = (char) bytes[i]; // } // return new String(buffer); // } // // } // Path: core/src/main/java/fixio/fixprotocol/fields/StringField.java import fixio.Utils; import java.util.Arrays; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class StringField extends AbstractField<String> { private final byte[] value; public StringField(int tagNum, String value) { super(tagNum);
this.value = Utils.stringToBytesASCII(value);
kpavlov/fixio
core/src/main/java/fixio/FixServer.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup;
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/main/java/fixio/FixServer.java import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup;
private FixAuthenticator authenticator;
kpavlov/fixio
core/src/main/java/fixio/FixServer.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port,
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/main/java/fixio/FixServer.java import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port,
FixApplication fixApplication,
kpavlov/fixio
core/src/main/java/fixio/FixServer.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port, FixApplication fixApplication, FixAuthenticator authenticator,
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/main/java/fixio/FixServer.java import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port, FixApplication fixApplication, FixAuthenticator authenticator,
SessionRepository sessionRepository) {
kpavlov/fixio
core/src/main/java/fixio/FixServer.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port, FixApplication fixApplication, FixAuthenticator authenticator, SessionRepository sessionRepository) { super(fixApplication, sessionRepository); assert (authenticator != null) : "Authenticator is required"; this.authenticator = authenticator; this.port = port; } public void start() throws InterruptedException { bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); final ServerBootstrap bootstrap = new ServerBootstrap();
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAcceptorChannelInitializer.java // public class FixAcceptorChannelInitializer<C extends Channel> extends FixChannelInitializer<C> { // // private final FixAuthenticator authenticator; // private final SessionRepository sessionRepository; // // public FixAcceptorChannelInitializer(EventLoopGroup workerGroup, // FixApplication fixApplication, // FixAuthenticator authenticator, // SessionRepository sessionRepository) { // super(workerGroup, fixApplication); // this.authenticator = authenticator; // this.sessionRepository = sessionRepository; // } // // @Override // protected MessageToMessageCodec<FixMessage, FixMessageBuilder> createSessionHandler() { // return new ServerSessionHandler(getFixApplication(), authenticator, sessionRepository); // } // // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/main/java/fixio/FixServer.java import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAcceptorChannelInitializer; import fixio.netty.pipeline.server.FixAuthenticator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; public class FixServer extends AbstractFixConnector { private static final Logger LOGGER = LoggerFactory.getLogger(FixServer.class); private final int port; private Channel channel; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private FixAuthenticator authenticator; public FixServer(int port, FixApplication fixApplication, FixAuthenticator authenticator, SessionRepository sessionRepository) { super(fixApplication, sessionRepository); assert (authenticator != null) : "Authenticator is required"; this.authenticator = authenticator; this.port = port; } public void start() throws InterruptedException { bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); final ServerBootstrap bootstrap = new ServerBootstrap();
final FixAcceptorChannelInitializer<SocketChannel> channelInitializer = new FixAcceptorChannelInitializer<>(
kpavlov/fixio
core/src/main/java/fixio/fixprotocol/fields/FieldFactory.java
// Path: core/src/main/java/fixio/fixprotocol/DataType.java // public enum DataType { // INT, // CHAR, // MULTIPLECHARVALUE, // STRING, // FLOAT, // BOOLEAN, // AMT, // QTY, // PRICE, // PRICEOFFSET, // SEQNUM, // LENGTH, // NUMINGROUP, // MONTHYEAR, // UTCTIMESTAMP, // UTCDATEONLY, // UTCTIMEONLY, // PERCENTAGE, // CURRENCY, // COUNTRY, // LANGUAGE, // EXCHANGE, // LOCALMKTDATE, // MULTIPLESTRINGVALUE, // TZTIMEONLY, // TZTIMESTAMP, // XMLDATA, // DATA // }
import fixio.fixprotocol.DataType; import fixio.fixprotocol.FieldType; import java.text.ParseException; import java.time.Instant; import java.time.ZoneOffset;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class FieldFactory { public static <F extends AbstractField> F valueOf(int tagNum, byte[] value) { return valueOf(tagNum, value, 0, value.length); } @SuppressWarnings("unchecked") public static <F extends AbstractField> F valueOf(int tagNum, byte[] value, int offset, int length) { if (tagNum <= 0) { throw new IllegalArgumentException("Invalid tagNum=" + tagNum); } if (length <= 0) { throw new IllegalArgumentException("Value length must be positive but was " + length); } FieldType fieldType = FieldType.forTag(tagNum); try {
// Path: core/src/main/java/fixio/fixprotocol/DataType.java // public enum DataType { // INT, // CHAR, // MULTIPLECHARVALUE, // STRING, // FLOAT, // BOOLEAN, // AMT, // QTY, // PRICE, // PRICEOFFSET, // SEQNUM, // LENGTH, // NUMINGROUP, // MONTHYEAR, // UTCTIMESTAMP, // UTCDATEONLY, // UTCTIMEONLY, // PERCENTAGE, // CURRENCY, // COUNTRY, // LANGUAGE, // EXCHANGE, // LOCALMKTDATE, // MULTIPLESTRINGVALUE, // TZTIMEONLY, // TZTIMESTAMP, // XMLDATA, // DATA // } // Path: core/src/main/java/fixio/fixprotocol/fields/FieldFactory.java import fixio.fixprotocol.DataType; import fixio.fixprotocol.FieldType; import java.text.ParseException; import java.time.Instant; import java.time.ZoneOffset; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class FieldFactory { public static <F extends AbstractField> F valueOf(int tagNum, byte[] value) { return valueOf(tagNum, value, 0, value.length); } @SuppressWarnings("unchecked") public static <F extends AbstractField> F valueOf(int tagNum, byte[] value, int offset, int length) { if (tagNum <= 0) { throw new IllegalArgumentException("Invalid tagNum=" + tagNum); } if (length <= 0) { throw new IllegalArgumentException("Value length must be positive but was " + length); } FieldType fieldType = FieldType.forTag(tagNum); try {
final DataType dataType = fieldType.type();
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplicationAdapter.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try {
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplicationAdapter.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try {
if (msg instanceof FixMessage) {
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplicationAdapter.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try { if (msg instanceof FixMessage) { onMessage(ctx, (FixMessage) msg, out); } else if (msg instanceof LogonEvent) { onLogon(ctx, (LogonEvent) msg); } else if (msg instanceof LogoutEvent) { onLogout(ctx, (LogoutEvent) msg); } } finally { ReferenceCountUtil.release(msg); } } /** * @implNote This implementation does nothing. */ @Override public void onLogon(ChannelHandlerContext ctx, LogonEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplicationAdapter.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try { if (msg instanceof FixMessage) { onMessage(ctx, (FixMessage) msg, out); } else if (msg instanceof LogonEvent) { onLogon(ctx, (LogonEvent) msg); } else if (msg instanceof LogoutEvent) { onLogout(ctx, (LogoutEvent) msg); } } finally { ReferenceCountUtil.release(msg); } } /** * @implNote This implementation does nothing. */ @Override public void onLogon(ChannelHandlerContext ctx, LogonEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException {
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplicationAdapter.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try { if (msg instanceof FixMessage) { onMessage(ctx, (FixMessage) msg, out); } else if (msg instanceof LogonEvent) { onLogon(ctx, (LogonEvent) msg); } else if (msg instanceof LogoutEvent) { onLogout(ctx, (LogoutEvent) msg); } } finally { ReferenceCountUtil.release(msg); } } /** * @implNote This implementation does nothing. */ @Override public void onLogon(ChannelHandlerContext ctx, LogonEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException { } /** * @implSpec This implementation does nothing. */ @Override
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplicationAdapter.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.util.ReferenceCountUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; @ChannelHandler.Sharable public class FixApplicationAdapter extends MessageToMessageDecoder<Object> implements FixApplication { private static final Logger LOGGER = LoggerFactory.getLogger(FixApplicationAdapter.class); @Override protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { try { if (msg instanceof FixMessage) { onMessage(ctx, (FixMessage) msg, out); } else if (msg instanceof LogonEvent) { onLogon(ctx, (LogonEvent) msg); } else if (msg instanceof LogoutEvent) { onLogout(ctx, (LogoutEvent) msg); } } finally { ReferenceCountUtil.release(msg); } } /** * @implNote This implementation does nothing. */ @Override public void onLogon(ChannelHandlerContext ctx, LogonEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) { } /** * @implSpec This implementation does nothing. */ @Override public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException { } /** * @implSpec This implementation does nothing. */ @Override
public void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder msg) {
kpavlov/fixio
core/src/main/java/fixio/fixprotocol/FixConst.java
// Path: core/src/main/java/fixio/fixprotocol/fields/DateTimeFormatterWrapper.java // public class DateTimeFormatterWrapper { // private final String pattern; // private final ZoneId zoneId; // private final DateTimeFormatter dateTimeFormatter; // private final String padding; // private final int paddingLen; // // public DateTimeFormatterWrapper(String pattern, ZoneId zoneId) { // this.pattern = pattern; // this.zoneId = zoneId; // int idx = pattern.indexOf('\''); // if (idx > 0) { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern.substring(0, idx)).withZone(zoneId); // this.padding = pattern.substring(idx).replaceAll("'", ""); // } else { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern).withZone(zoneId); // this.padding = ""; // } // this.paddingLen = this.padding.length(); // } // // public String getPattern() { // return pattern; // } // // public ZoneId getZoneId() { // return zoneId; // } // // public DateTimeFormatter getDateTimeFormatter() { // return dateTimeFormatter; // } // // public String getPadding() { // return padding; // } // // // public String format(TemporalAccessor value) { // return dateTimeFormatter.format(value) + padding; // } // // public LocalDate parseLocalDate(String timestampString) { // return LocalDate.parse(timestampString, dateTimeFormatter); // } // // public LocalTime parseLocalTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return LocalTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return LocalTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // // public ZonedDateTime parseZonedDateTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return ZonedDateTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return ZonedDateTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // }
import fixio.fixprotocol.fields.DateTimeFormatterWrapper; import java.time.ZoneId; import java.time.ZoneOffset;
package fixio.fixprotocol; public class FixConst { public static final ZoneId DEFAULT_ZONE_ID = ZoneOffset.UTC; public static final String DATE_PATTERN = "yyyyMMdd"; // public static final String TIME_PATTERN_SECONDS = "HH:mm:ss"; public static final String TIME_PATTERN_MILLIS = "HH:mm:ss.SSS"; public static final String TIME_PATTERN_MICROS = "HH:mm:ss.SSSSSS"; public static final String TIME_PATTERN_NANOS = "HH:mm:ss.nnnnnnnnn"; public static final String TIME_PATTERN_PICOS = "HH:mm:ss.nnnnnnnnn'000'"; // not supported by java.time at the moment, use nanos and pad '000' // public static final String DATE_TIME_PATTERN_SECONDS = DATE_PATTERN + "-" + TIME_PATTERN_SECONDS; public static final String DATE_TIME_PATTERN_MILLIS = DATE_PATTERN + "-" + TIME_PATTERN_MILLIS; public static final String DATE_TIME_PATTERN_MICROS = DATE_PATTERN + "-" + TIME_PATTERN_MICROS; public static final String DATE_TIME_PATTERN_NANOS = DATE_PATTERN + "-" + TIME_PATTERN_NANOS; public static final String DATE_TIME_PATTERN_PICOS = DATE_PATTERN + "-" + TIME_PATTERN_PICOS; // public static final int TIME_PATTERN_SECONDS_LENGTH = TIME_PATTERN_SECONDS.length(); public static final int TIME_PATTERN_MILLIS_LENGTH = TIME_PATTERN_MILLIS.length(); public static final int TIME_PATTERN_MICROS_LENGTH = TIME_PATTERN_MICROS.length(); public static final int TIME_PATTERN_NANOS_LENGTH = TIME_PATTERN_NANOS.length(); public static final int TIME_PATTERN_PICOS_LENGTH = TIME_PATTERN_PICOS.length(); // public static final int DATE_TIME_PATTERN_SECONDS_LENGTH = DATE_TIME_PATTERN_SECONDS.length(); public static final int DATE_TIME_PATTERN_MILLIS_LENGTH = DATE_TIME_PATTERN_MILLIS.length(); public static final int DATE_TIME_PATTERN_MICROS_LENGTH = DATE_TIME_PATTERN_MICROS.length(); public static final int DATE_TIME_PATTERN_NANOS_LENGTH = DATE_TIME_PATTERN_NANOS.length(); public static final int DATE_TIME_PATTERN_PICOS_LENGTH = DATE_TIME_PATTERN_PICOS.length(); //
// Path: core/src/main/java/fixio/fixprotocol/fields/DateTimeFormatterWrapper.java // public class DateTimeFormatterWrapper { // private final String pattern; // private final ZoneId zoneId; // private final DateTimeFormatter dateTimeFormatter; // private final String padding; // private final int paddingLen; // // public DateTimeFormatterWrapper(String pattern, ZoneId zoneId) { // this.pattern = pattern; // this.zoneId = zoneId; // int idx = pattern.indexOf('\''); // if (idx > 0) { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern.substring(0, idx)).withZone(zoneId); // this.padding = pattern.substring(idx).replaceAll("'", ""); // } else { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern).withZone(zoneId); // this.padding = ""; // } // this.paddingLen = this.padding.length(); // } // // public String getPattern() { // return pattern; // } // // public ZoneId getZoneId() { // return zoneId; // } // // public DateTimeFormatter getDateTimeFormatter() { // return dateTimeFormatter; // } // // public String getPadding() { // return padding; // } // // // public String format(TemporalAccessor value) { // return dateTimeFormatter.format(value) + padding; // } // // public LocalDate parseLocalDate(String timestampString) { // return LocalDate.parse(timestampString, dateTimeFormatter); // } // // public LocalTime parseLocalTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return LocalTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return LocalTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // // public ZonedDateTime parseZonedDateTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return ZonedDateTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return ZonedDateTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // } // Path: core/src/main/java/fixio/fixprotocol/FixConst.java import fixio.fixprotocol.fields.DateTimeFormatterWrapper; import java.time.ZoneId; import java.time.ZoneOffset; package fixio.fixprotocol; public class FixConst { public static final ZoneId DEFAULT_ZONE_ID = ZoneOffset.UTC; public static final String DATE_PATTERN = "yyyyMMdd"; // public static final String TIME_PATTERN_SECONDS = "HH:mm:ss"; public static final String TIME_PATTERN_MILLIS = "HH:mm:ss.SSS"; public static final String TIME_PATTERN_MICROS = "HH:mm:ss.SSSSSS"; public static final String TIME_PATTERN_NANOS = "HH:mm:ss.nnnnnnnnn"; public static final String TIME_PATTERN_PICOS = "HH:mm:ss.nnnnnnnnn'000'"; // not supported by java.time at the moment, use nanos and pad '000' // public static final String DATE_TIME_PATTERN_SECONDS = DATE_PATTERN + "-" + TIME_PATTERN_SECONDS; public static final String DATE_TIME_PATTERN_MILLIS = DATE_PATTERN + "-" + TIME_PATTERN_MILLIS; public static final String DATE_TIME_PATTERN_MICROS = DATE_PATTERN + "-" + TIME_PATTERN_MICROS; public static final String DATE_TIME_PATTERN_NANOS = DATE_PATTERN + "-" + TIME_PATTERN_NANOS; public static final String DATE_TIME_PATTERN_PICOS = DATE_PATTERN + "-" + TIME_PATTERN_PICOS; // public static final int TIME_PATTERN_SECONDS_LENGTH = TIME_PATTERN_SECONDS.length(); public static final int TIME_PATTERN_MILLIS_LENGTH = TIME_PATTERN_MILLIS.length(); public static final int TIME_PATTERN_MICROS_LENGTH = TIME_PATTERN_MICROS.length(); public static final int TIME_PATTERN_NANOS_LENGTH = TIME_PATTERN_NANOS.length(); public static final int TIME_PATTERN_PICOS_LENGTH = TIME_PATTERN_PICOS.length(); // public static final int DATE_TIME_PATTERN_SECONDS_LENGTH = DATE_TIME_PATTERN_SECONDS.length(); public static final int DATE_TIME_PATTERN_MILLIS_LENGTH = DATE_TIME_PATTERN_MILLIS.length(); public static final int DATE_TIME_PATTERN_MICROS_LENGTH = DATE_TIME_PATTERN_MICROS.length(); public static final int DATE_TIME_PATTERN_NANOS_LENGTH = DATE_TIME_PATTERN_NANOS.length(); public static final int DATE_TIME_PATTERN_PICOS_LENGTH = DATE_TIME_PATTERN_PICOS.length(); //
public static final DateTimeFormatterWrapper DATE_FORMATTER = new DateTimeFormatterWrapper(DATE_PATTERN, DEFAULT_ZONE_ID);
kpavlov/fixio
examples/src/main/java/fixio/examples/quickfix/QuickFixServer.java
// Path: examples/src/main/java/fixio/examples/common/Quote.java // public class Quote { // // private final double bid; // private final double offer; // // public Quote(double bid, double offer) { // this.bid = bid; // this.offer = offer; // } // // public double getBid() { // return bid; // } // // public double getOffer() { // return offer; // } // } // // Path: examples/src/main/java/fixio/examples/common/QuoteGeneratorTask.java // public class QuoteGeneratorTask implements Runnable { // // private static final Logger LOGGER = LoggerFactory.getLogger(QuoteGeneratorTask.class); // private final BlockingQueue<Quote> receiver; // // private static int DATA_SIZE = 1000; // private final Quote[] data = new Quote[DATA_SIZE]; // // public QuoteGeneratorTask(BlockingQueue<Quote> receiverQueue) { // receiver = receiverQueue; // for (int i = 0; i < DATA_SIZE; i++) { // data[i] = createQuote(i); // } // } // // @Override // public void run() { // LOGGER.info("Started"); // final Thread thread = Thread.currentThread(); // int t = 0; // while (!thread.isInterrupted()) { // if (receiver.remainingCapacity() > 1000) { // try { // Quote quote = data[t % DATA_SIZE]; // t++; // receiver.put(quote); // Thread.yield(); // } catch (InterruptedException e) { // LOGGER.info("Interrupted."); // thread.interrupt(); // return; // } catch (Throwable e) { // LOGGER.error("Unable to submit quote.", e); // } // } // Thread.yield(); // } // LOGGER.info("Stopped"); // } // // private static Quote createQuote(double t) { // double bid = Math.sin(t / 100) * 2 + 0.5; // double offer = Math.sin(t - 10 / 100) * 2 + 0.5; // return new Quote(bid, offer); // } // // public void stop() { // Thread.currentThread().interrupt(); // } // }
import fixio.examples.common.Quote; import fixio.examples.common.QuoteGeneratorTask; import quickfix.Acceptor; import quickfix.Application; import quickfix.ConfigError; import quickfix.DefaultMessageFactory; import quickfix.LogFactory; import quickfix.MemoryStoreFactory; import quickfix.MessageFactory; import quickfix.MessageStoreFactory; import quickfix.SLF4JLogFactory; import quickfix.SessionSettings; import quickfix.SocketAcceptor; import java.util.concurrent.ArrayBlockingQueue;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.examples.quickfix; public class QuickFixServer { private final ArrayBlockingQueue<Quote> quoteQueue = new ArrayBlockingQueue<>(8192); private Thread generator;
// Path: examples/src/main/java/fixio/examples/common/Quote.java // public class Quote { // // private final double bid; // private final double offer; // // public Quote(double bid, double offer) { // this.bid = bid; // this.offer = offer; // } // // public double getBid() { // return bid; // } // // public double getOffer() { // return offer; // } // } // // Path: examples/src/main/java/fixio/examples/common/QuoteGeneratorTask.java // public class QuoteGeneratorTask implements Runnable { // // private static final Logger LOGGER = LoggerFactory.getLogger(QuoteGeneratorTask.class); // private final BlockingQueue<Quote> receiver; // // private static int DATA_SIZE = 1000; // private final Quote[] data = new Quote[DATA_SIZE]; // // public QuoteGeneratorTask(BlockingQueue<Quote> receiverQueue) { // receiver = receiverQueue; // for (int i = 0; i < DATA_SIZE; i++) { // data[i] = createQuote(i); // } // } // // @Override // public void run() { // LOGGER.info("Started"); // final Thread thread = Thread.currentThread(); // int t = 0; // while (!thread.isInterrupted()) { // if (receiver.remainingCapacity() > 1000) { // try { // Quote quote = data[t % DATA_SIZE]; // t++; // receiver.put(quote); // Thread.yield(); // } catch (InterruptedException e) { // LOGGER.info("Interrupted."); // thread.interrupt(); // return; // } catch (Throwable e) { // LOGGER.error("Unable to submit quote.", e); // } // } // Thread.yield(); // } // LOGGER.info("Stopped"); // } // // private static Quote createQuote(double t) { // double bid = Math.sin(t / 100) * 2 + 0.5; // double offer = Math.sin(t - 10 / 100) * 2 + 0.5; // return new Quote(bid, offer); // } // // public void stop() { // Thread.currentThread().interrupt(); // } // } // Path: examples/src/main/java/fixio/examples/quickfix/QuickFixServer.java import fixio.examples.common.Quote; import fixio.examples.common.QuoteGeneratorTask; import quickfix.Acceptor; import quickfix.Application; import quickfix.ConfigError; import quickfix.DefaultMessageFactory; import quickfix.LogFactory; import quickfix.MemoryStoreFactory; import quickfix.MessageFactory; import quickfix.MessageStoreFactory; import quickfix.SLF4JLogFactory; import quickfix.SessionSettings; import quickfix.SocketAcceptor; import java.util.concurrent.ArrayBlockingQueue; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.examples.quickfix; public class QuickFixServer { private final ArrayBlockingQueue<Quote> quoteQueue = new ArrayBlockingQueue<>(8192); private Thread generator;
private QuoteGeneratorTask generatorTask;
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplication.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplication.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */
void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out)
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplication.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */ void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out)
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplication.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */ void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out)
throws BusinessRejectException, InterruptedException;
kpavlov/fixio
core/src/main/java/fixio/handlers/FixApplication.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // }
import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */ void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException; /** * Invoked before {@link FixMessageBuilder} is sent. * * @param ctx current {@link ChannelHandlerContext} * @param messageBuilder a message builder */
// Path: core/src/main/java/fixio/fixprotocol/FixMessage.java // public interface FixMessage { // // String FIX_4_0 = "FIX.4.0"; // String FIX_4_1 = "FIX.4.1"; // String FIX_4_2 = "FIX.4.2"; // String FIX_4_3 = "FIX.4.3"; // String FIX_4_4 = "FIX.4.4"; // String FIX_5_0 = "FIXT.1.1"; // // FixMessageHeader getHeader(); // // List<FixMessageFragment> getBody(); // // Integer getInt(int tagNum); // // Integer getInt(FieldType field); // // String getString(int tagNum); // // @SuppressWarnings("unchecked") // <T> T getValue(int tagNum); // // String getString(FieldType field); // // <T> T getValue(FieldType field); // // Character getChar(int tagNum); // // Character getChar(FieldType fieldType); // // String getMessageType(); // // default FixMessageFragment getFirst(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // default List<FixMessageFragment> getAll(int tagNum) { // final List<FixMessageFragment> body = getBody(); // List<FixMessageFragment> result = new ArrayList<>(8); // for (int i = 0; i < body.size(); i++) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // result.add(item); // } // } // return result; // } // // default FixMessageFragment getLast(int tagNum) { // final List<FixMessageFragment> body = getBody(); // for (int i = body.size() - 1; i >= 0; i--) { // FixMessageFragment item = body.get(i); // if (item.getTagNum() == tagNum) { // return item; // } // } // return null; // } // // } // // Path: core/src/main/java/fixio/fixprotocol/FixMessageBuilder.java // public interface FixMessageBuilder extends FieldListBuilder<FixMessageBuilder> { // FixMessageHeader getHeader(); // // void copyHeader(FixMessageHeader header); // // List<? extends FixMessageFragment> getBody(); // // void copyBody(List<? extends FixMessageFragment> body); // } // // Path: core/src/main/java/fixio/validator/BusinessRejectException.java // public class BusinessRejectException extends Exception { // // /** // * MsgSeqNum of rejected message // */ // private final int refSeqNum; // // /** // * The MsgType of the FIX message being referenced. // */ // private final String refMsgType; // // /** // * The value of the business-level "ID" field on the message being referenced. // * Required unless the corresponding ID field (see list above) was not specified. // */ // private final int businessRejectReason; // // /** // * Where possible, message to explain reason for rejection. // */ // private final String text; // // public BusinessRejectException(int refSeqNum, String refMsgType, int businessRejectReason, String text) { // super(text); // this.refSeqNum = refSeqNum; // this.refMsgType = refMsgType; // this.businessRejectReason = businessRejectReason; // this.text = text; // } // // public int getRefSeqNum() { // return refSeqNum; // } // // public String getRefMsgType() { // return refMsgType; // } // // public int getBusinessRejectReason() { // return businessRejectReason; // } // // public String getText() { // return text; // } // } // Path: core/src/main/java/fixio/handlers/FixApplication.java import fixio.events.LogonEvent; import fixio.events.LogoutEvent; import fixio.fixprotocol.FixMessage; import fixio.fixprotocol.FixMessageBuilder; import fixio.validator.BusinessRejectException; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.handlers; public interface FixApplication extends ChannelHandler { /** * Invoked after FIX session was successfully established. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogon(ChannelHandlerContext ctx, LogonEvent msg); /** * Invoked after FIX session was closed. * * @param ctx current {@link ChannelHandlerContext} * @param msg {@link LogonEvent} message to handle */ void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); /** * Invoked when message arrived * * @param ctx current {@link ChannelHandlerContext} * @param msg a {@link FixMessage} to handle * @param out a {@link List} where decoded messages should be added * @throws BusinessRejectException when message can't be accepted * @throws InterruptedException if interrupted while processing a message */ void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException; /** * Invoked before {@link FixMessageBuilder} is sent. * * @param ctx current {@link ChannelHandlerContext} * @param messageBuilder a message builder */
void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder);
kpavlov/fixio
core/src/main/java/fixio/fixprotocol/FixMessageHeader.java
// Path: core/src/main/java/fixio/fixprotocol/fields/DateTimeFormatterWrapper.java // public class DateTimeFormatterWrapper { // private final String pattern; // private final ZoneId zoneId; // private final DateTimeFormatter dateTimeFormatter; // private final String padding; // private final int paddingLen; // // public DateTimeFormatterWrapper(String pattern, ZoneId zoneId) { // this.pattern = pattern; // this.zoneId = zoneId; // int idx = pattern.indexOf('\''); // if (idx > 0) { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern.substring(0, idx)).withZone(zoneId); // this.padding = pattern.substring(idx).replaceAll("'", ""); // } else { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern).withZone(zoneId); // this.padding = ""; // } // this.paddingLen = this.padding.length(); // } // // public String getPattern() { // return pattern; // } // // public ZoneId getZoneId() { // return zoneId; // } // // public DateTimeFormatter getDateTimeFormatter() { // return dateTimeFormatter; // } // // public String getPadding() { // return padding; // } // // // public String format(TemporalAccessor value) { // return dateTimeFormatter.format(value) + padding; // } // // public LocalDate parseLocalDate(String timestampString) { // return LocalDate.parse(timestampString, dateTimeFormatter); // } // // public LocalTime parseLocalTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return LocalTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return LocalTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // // public ZonedDateTime parseZonedDateTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return ZonedDateTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return ZonedDateTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // }
import fixio.fixprotocol.fields.DateTimeFormatterWrapper; import java.time.ZonedDateTime; import java.util.List;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol; public class FixMessageHeader { private String beginString; private String messageType; private int msgSeqNum; private ZonedDateTime sendingTime; private String senderCompID; private String senderSubID; private String senderLocationID; private String targetCompID; private String targetSubID; private String targetLocationID; private List<FixMessageFragment> customFields;
// Path: core/src/main/java/fixio/fixprotocol/fields/DateTimeFormatterWrapper.java // public class DateTimeFormatterWrapper { // private final String pattern; // private final ZoneId zoneId; // private final DateTimeFormatter dateTimeFormatter; // private final String padding; // private final int paddingLen; // // public DateTimeFormatterWrapper(String pattern, ZoneId zoneId) { // this.pattern = pattern; // this.zoneId = zoneId; // int idx = pattern.indexOf('\''); // if (idx > 0) { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern.substring(0, idx)).withZone(zoneId); // this.padding = pattern.substring(idx).replaceAll("'", ""); // } else { // this.dateTimeFormatter = DateTimeFormatter.ofPattern(pattern).withZone(zoneId); // this.padding = ""; // } // this.paddingLen = this.padding.length(); // } // // public String getPattern() { // return pattern; // } // // public ZoneId getZoneId() { // return zoneId; // } // // public DateTimeFormatter getDateTimeFormatter() { // return dateTimeFormatter; // } // // public String getPadding() { // return padding; // } // // // public String format(TemporalAccessor value) { // return dateTimeFormatter.format(value) + padding; // } // // public LocalDate parseLocalDate(String timestampString) { // return LocalDate.parse(timestampString, dateTimeFormatter); // } // // public LocalTime parseLocalTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return LocalTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return LocalTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // // public ZonedDateTime parseZonedDateTime(String timestampString) { // if (timestampString != null) { // if (paddingLen > 0) { // int idx = timestampString.length() - paddingLen; // return ZonedDateTime.parse(timestampString.substring(0, idx), dateTimeFormatter); // } else { // return ZonedDateTime.parse(timestampString, dateTimeFormatter); // } // } // return null; // } // } // Path: core/src/main/java/fixio/fixprotocol/FixMessageHeader.java import fixio.fixprotocol.fields.DateTimeFormatterWrapper; import java.time.ZonedDateTime; import java.util.List; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol; public class FixMessageHeader { private String beginString; private String messageType; private int msgSeqNum; private ZonedDateTime sendingTime; private String senderCompID; private String senderSubID; private String senderLocationID; private String targetCompID; private String targetSubID; private String targetLocationID; private List<FixMessageFragment> customFields;
private DateTimeFormatterWrapper dateTimeFormatter = null;
kpavlov/fixio
core/src/test/java/fixio/FixServerTest.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/test/java/fixio/FixServerTest.java import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock
private FixApplication fixApplication;
kpavlov/fixio
core/src/test/java/fixio/FixServerTest.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock private FixApplication fixApplication; @Mock
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/test/java/fixio/FixServerTest.java import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock private FixApplication fixApplication; @Mock
private FixAuthenticator fixAuthenticator;
kpavlov/fixio
core/src/test/java/fixio/FixServerTest.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // }
import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock private FixApplication fixApplication; @Mock private FixAuthenticator fixAuthenticator; @Mock
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // // Path: core/src/main/java/fixio/netty/pipeline/server/FixAuthenticator.java // public interface FixAuthenticator { // // /** // * Verify credentials and returns true if acceptor authorize session initiator. // * // * @param logonMessage a Logon(35='A') message // * @return true if the session acceptor has authenticated the party requesting connection. // */ // boolean authenticate(FixMessage logonMessage); // } // Path: core/src/test/java/fixio/FixServerTest.java import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; import fixio.netty.pipeline.server.FixAuthenticator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; @RunWith(org.mockito.junit.MockitoJUnitRunner.class) public class FixServerTest { private FixServer server; @Mock private FixApplication fixApplication; @Mock private FixAuthenticator fixAuthenticator; @Mock
private SessionRepository sessionRepository;
kpavlov/fixio
core/src/main/java/fixio/AbstractFixConnector.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // }
import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; /** * AbstractFixConnector is base class for {@link FixClient} and {@link FixServer}. * * @author Konstantin Pavlov */ @SuppressWarnings("WeakerAccess") public abstract class AbstractFixConnector {
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // Path: core/src/main/java/fixio/AbstractFixConnector.java import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; /** * AbstractFixConnector is base class for {@link FixClient} and {@link FixServer}. * * @author Konstantin Pavlov */ @SuppressWarnings("WeakerAccess") public abstract class AbstractFixConnector {
private final FixApplication fixApplication;
kpavlov/fixio
core/src/main/java/fixio/AbstractFixConnector.java
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // }
import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; /** * AbstractFixConnector is base class for {@link FixClient} and {@link FixServer}. * * @author Konstantin Pavlov */ @SuppressWarnings("WeakerAccess") public abstract class AbstractFixConnector { private final FixApplication fixApplication;
// Path: core/src/main/java/fixio/handlers/FixApplication.java // public interface FixApplication extends ChannelHandler { // // /** // * Invoked after FIX session was successfully established. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogon(ChannelHandlerContext ctx, LogonEvent msg); // // /** // * Invoked after FIX session was closed. // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg {@link LogonEvent} message to handle // */ // void onLogout(ChannelHandlerContext ctx, LogoutEvent msg); // // /** // * Invoked when message arrived // * // * @param ctx current {@link ChannelHandlerContext} // * @param msg a {@link FixMessage} to handle // * @param out a {@link List} where decoded messages should be added // * @throws BusinessRejectException when message can't be accepted // * @throws InterruptedException if interrupted while processing a message // */ // void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) // throws BusinessRejectException, InterruptedException; // // /** // * Invoked before {@link FixMessageBuilder} is sent. // * // * @param ctx current {@link ChannelHandlerContext} // * @param messageBuilder a message builder // */ // void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder); // } // // Path: core/src/main/java/fixio/netty/pipeline/SessionRepository.java // public interface SessionRepository { // // FixSession getOrCreateSession(FixMessageHeader header); // // FixSession getSession(FixMessageHeader header); // // void removeSession(SessionId sessionId); // } // Path: core/src/main/java/fixio/AbstractFixConnector.java import fixio.handlers.FixApplication; import fixio.netty.pipeline.SessionRepository; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio; /** * AbstractFixConnector is base class for {@link FixClient} and {@link FixServer}. * * @author Konstantin Pavlov */ @SuppressWarnings("WeakerAccess") public abstract class AbstractFixConnector { private final FixApplication fixApplication;
private final SessionRepository sessionRepository;
kpavlov/fixio
core/src/main/java/fixio/netty/pipeline/client/PropertyFixSessionSettingsProviderImpl.java
// Path: core/src/main/java/fixio/fixprotocol/FixConst.java // public class FixConst { // // public static final ZoneId DEFAULT_ZONE_ID = ZoneOffset.UTC; // // public static final String DATE_PATTERN = "yyyyMMdd"; // // // public static final String TIME_PATTERN_SECONDS = "HH:mm:ss"; // public static final String TIME_PATTERN_MILLIS = "HH:mm:ss.SSS"; // public static final String TIME_PATTERN_MICROS = "HH:mm:ss.SSSSSS"; // public static final String TIME_PATTERN_NANOS = "HH:mm:ss.nnnnnnnnn"; // public static final String TIME_PATTERN_PICOS = "HH:mm:ss.nnnnnnnnn'000'"; // not supported by java.time at the moment, use nanos and pad '000' // // // public static final String DATE_TIME_PATTERN_SECONDS = DATE_PATTERN + "-" + TIME_PATTERN_SECONDS; // public static final String DATE_TIME_PATTERN_MILLIS = DATE_PATTERN + "-" + TIME_PATTERN_MILLIS; // public static final String DATE_TIME_PATTERN_MICROS = DATE_PATTERN + "-" + TIME_PATTERN_MICROS; // public static final String DATE_TIME_PATTERN_NANOS = DATE_PATTERN + "-" + TIME_PATTERN_NANOS; // public static final String DATE_TIME_PATTERN_PICOS = DATE_PATTERN + "-" + TIME_PATTERN_PICOS; // // // public static final int TIME_PATTERN_SECONDS_LENGTH = TIME_PATTERN_SECONDS.length(); // public static final int TIME_PATTERN_MILLIS_LENGTH = TIME_PATTERN_MILLIS.length(); // public static final int TIME_PATTERN_MICROS_LENGTH = TIME_PATTERN_MICROS.length(); // public static final int TIME_PATTERN_NANOS_LENGTH = TIME_PATTERN_NANOS.length(); // public static final int TIME_PATTERN_PICOS_LENGTH = TIME_PATTERN_PICOS.length(); // // // public static final int DATE_TIME_PATTERN_SECONDS_LENGTH = DATE_TIME_PATTERN_SECONDS.length(); // public static final int DATE_TIME_PATTERN_MILLIS_LENGTH = DATE_TIME_PATTERN_MILLIS.length(); // public static final int DATE_TIME_PATTERN_MICROS_LENGTH = DATE_TIME_PATTERN_MICROS.length(); // public static final int DATE_TIME_PATTERN_NANOS_LENGTH = DATE_TIME_PATTERN_NANOS.length(); // public static final int DATE_TIME_PATTERN_PICOS_LENGTH = DATE_TIME_PATTERN_PICOS.length(); // // // public static final DateTimeFormatterWrapper DATE_FORMATTER = new DateTimeFormatterWrapper(DATE_PATTERN, DEFAULT_ZONE_ID); // // // public static final DateTimeFormatterWrapper TIME_FORMATTER_SECONDS = new DateTimeFormatterWrapper(TIME_PATTERN_SECONDS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_MILLIS = new DateTimeFormatterWrapper(TIME_PATTERN_MILLIS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_MICROS = new DateTimeFormatterWrapper(TIME_PATTERN_MICROS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_NANOS = new DateTimeFormatterWrapper(TIME_PATTERN_NANOS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_PICOS = new DateTimeFormatterWrapper(TIME_PATTERN_PICOS, DEFAULT_ZONE_ID); // // // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_SECONDS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_SECONDS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_MILLIS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_MILLIS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_MICROS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_MICROS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_NANOS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_NANOS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_PICOS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_PICOS, DEFAULT_ZONE_ID); // // private FixConst() { // // to prevent instatiation // } // // public enum TimeStampPrecision { // SECONDS, // MILLIS, // MICROS, // NANOS, // PICOS // } // // }
import fixio.fixprotocol.FixConst; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; import java.util.Properties;
return properties; } private void loadProperties(String resource) { try { final InputStream inputStream = getClass().getResourceAsStream(resource); if (inputStream == null) { LOGGER.error("Can't read FixSessionSettings from {}", resource); throw new IllegalArgumentException("Resource not found: " + resource); } properties.load(inputStream); } catch (IOException e) { String message = "Unable to load FixSessionSettings from " + resource; LOGGER.error(message, e); throw new IllegalArgumentException(message, e); } } @Override public boolean isResetMsgSeqNum() { return Boolean.parseBoolean(properties.getProperty("ResetOnLogon", "true")); } @Override public int getHeartbeatInterval() { return Integer.parseInt(properties.getProperty("HeartBtInt", "60")); } @Override public String getTimeStampPrecision() {// "SECONDS", "MILLIS", "MICROS", "NANOS". Default is "MILLIS"
// Path: core/src/main/java/fixio/fixprotocol/FixConst.java // public class FixConst { // // public static final ZoneId DEFAULT_ZONE_ID = ZoneOffset.UTC; // // public static final String DATE_PATTERN = "yyyyMMdd"; // // // public static final String TIME_PATTERN_SECONDS = "HH:mm:ss"; // public static final String TIME_PATTERN_MILLIS = "HH:mm:ss.SSS"; // public static final String TIME_PATTERN_MICROS = "HH:mm:ss.SSSSSS"; // public static final String TIME_PATTERN_NANOS = "HH:mm:ss.nnnnnnnnn"; // public static final String TIME_PATTERN_PICOS = "HH:mm:ss.nnnnnnnnn'000'"; // not supported by java.time at the moment, use nanos and pad '000' // // // public static final String DATE_TIME_PATTERN_SECONDS = DATE_PATTERN + "-" + TIME_PATTERN_SECONDS; // public static final String DATE_TIME_PATTERN_MILLIS = DATE_PATTERN + "-" + TIME_PATTERN_MILLIS; // public static final String DATE_TIME_PATTERN_MICROS = DATE_PATTERN + "-" + TIME_PATTERN_MICROS; // public static final String DATE_TIME_PATTERN_NANOS = DATE_PATTERN + "-" + TIME_PATTERN_NANOS; // public static final String DATE_TIME_PATTERN_PICOS = DATE_PATTERN + "-" + TIME_PATTERN_PICOS; // // // public static final int TIME_PATTERN_SECONDS_LENGTH = TIME_PATTERN_SECONDS.length(); // public static final int TIME_PATTERN_MILLIS_LENGTH = TIME_PATTERN_MILLIS.length(); // public static final int TIME_PATTERN_MICROS_LENGTH = TIME_PATTERN_MICROS.length(); // public static final int TIME_PATTERN_NANOS_LENGTH = TIME_PATTERN_NANOS.length(); // public static final int TIME_PATTERN_PICOS_LENGTH = TIME_PATTERN_PICOS.length(); // // // public static final int DATE_TIME_PATTERN_SECONDS_LENGTH = DATE_TIME_PATTERN_SECONDS.length(); // public static final int DATE_TIME_PATTERN_MILLIS_LENGTH = DATE_TIME_PATTERN_MILLIS.length(); // public static final int DATE_TIME_PATTERN_MICROS_LENGTH = DATE_TIME_PATTERN_MICROS.length(); // public static final int DATE_TIME_PATTERN_NANOS_LENGTH = DATE_TIME_PATTERN_NANOS.length(); // public static final int DATE_TIME_PATTERN_PICOS_LENGTH = DATE_TIME_PATTERN_PICOS.length(); // // // public static final DateTimeFormatterWrapper DATE_FORMATTER = new DateTimeFormatterWrapper(DATE_PATTERN, DEFAULT_ZONE_ID); // // // public static final DateTimeFormatterWrapper TIME_FORMATTER_SECONDS = new DateTimeFormatterWrapper(TIME_PATTERN_SECONDS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_MILLIS = new DateTimeFormatterWrapper(TIME_PATTERN_MILLIS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_MICROS = new DateTimeFormatterWrapper(TIME_PATTERN_MICROS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_NANOS = new DateTimeFormatterWrapper(TIME_PATTERN_NANOS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper TIME_FORMATTER_PICOS = new DateTimeFormatterWrapper(TIME_PATTERN_PICOS, DEFAULT_ZONE_ID); // // // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_SECONDS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_SECONDS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_MILLIS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_MILLIS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_MICROS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_MICROS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_NANOS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_NANOS, DEFAULT_ZONE_ID); // public static final DateTimeFormatterWrapper DATE_TIME_FORMATTER_PICOS = new DateTimeFormatterWrapper(DATE_TIME_PATTERN_PICOS, DEFAULT_ZONE_ID); // // private FixConst() { // // to prevent instatiation // } // // public enum TimeStampPrecision { // SECONDS, // MILLIS, // MICROS, // NANOS, // PICOS // } // // } // Path: core/src/main/java/fixio/netty/pipeline/client/PropertyFixSessionSettingsProviderImpl.java import fixio.fixprotocol.FixConst; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; import java.util.Properties; return properties; } private void loadProperties(String resource) { try { final InputStream inputStream = getClass().getResourceAsStream(resource); if (inputStream == null) { LOGGER.error("Can't read FixSessionSettings from {}", resource); throw new IllegalArgumentException("Resource not found: " + resource); } properties.load(inputStream); } catch (IOException e) { String message = "Unable to load FixSessionSettings from " + resource; LOGGER.error(message, e); throw new IllegalArgumentException(message, e); } } @Override public boolean isResetMsgSeqNum() { return Boolean.parseBoolean(properties.getProperty("ResetOnLogon", "true")); } @Override public int getHeartbeatInterval() { return Integer.parseInt(properties.getProperty("HeartBtInt", "60")); } @Override public String getTimeStampPrecision() {// "SECONDS", "MILLIS", "MICROS", "NANOS". Default is "MILLIS"
return properties.getProperty("TimeStampPrecision", FixConst.TimeStampPrecision.MILLIS.toString()).trim();
kpavlov/fixio
core/src/main/java/fixio/fixprotocol/fields/UTCDateOnlyField.java
// Path: core/src/main/java/fixio/fixprotocol/FixConst.java // public static final DateTimeFormatterWrapper DATE_FORMATTER = new DateTimeFormatterWrapper(DATE_PATTERN, DEFAULT_ZONE_ID);
import java.text.ParseException; import java.time.LocalDate; import java.util.Objects; import static fixio.fixprotocol.FixConst.DATE_FORMATTER; import static java.nio.charset.StandardCharsets.US_ASCII;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; /** * Field representing Date represented in UTC (Universal Time Coordinated, also known as "GMT") in YYYYMMDD format. * <p> * This special-purpose field is paired with UTCTimeOnly to form a proper UTCTimestamp for bandwidth-sensitive messages. * </p> * <p> * Valid values: * YYYY = 0000-9999, * MM = 01-12, * DD = 01-31. * </p> * Example(s): <code>MDEntryDate="20030910"</code> */ public class UTCDateOnlyField extends AbstractField<LocalDate> { private final LocalDate value; public UTCDateOnlyField(int tagNum, byte[] bytes) throws ParseException { super(tagNum); this.value = parse(bytes); } public UTCDateOnlyField(int tagNum, String timestampString) throws ParseException { super(tagNum); this.value = parse(timestampString); } public UTCDateOnlyField(int tagNum, LocalDate value) { super(tagNum); this.value = value; } public static LocalDate parse(String timestampString) throws ParseException { if (timestampString != null) { int len = timestampString.length(); if (len < 8) { throw new ParseException("Unparseable date: '" + timestampString + "'", 0); } else if (len == 8) {
// Path: core/src/main/java/fixio/fixprotocol/FixConst.java // public static final DateTimeFormatterWrapper DATE_FORMATTER = new DateTimeFormatterWrapper(DATE_PATTERN, DEFAULT_ZONE_ID); // Path: core/src/main/java/fixio/fixprotocol/fields/UTCDateOnlyField.java import java.text.ParseException; import java.time.LocalDate; import java.util.Objects; import static fixio.fixprotocol.FixConst.DATE_FORMATTER; import static java.nio.charset.StandardCharsets.US_ASCII; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; /** * Field representing Date represented in UTC (Universal Time Coordinated, also known as "GMT") in YYYYMMDD format. * <p> * This special-purpose field is paired with UTCTimeOnly to form a proper UTCTimestamp for bandwidth-sensitive messages. * </p> * <p> * Valid values: * YYYY = 0000-9999, * MM = 01-12, * DD = 01-31. * </p> * Example(s): <code>MDEntryDate="20030910"</code> */ public class UTCDateOnlyField extends AbstractField<LocalDate> { private final LocalDate value; public UTCDateOnlyField(int tagNum, byte[] bytes) throws ParseException { super(tagNum); this.value = parse(bytes); } public UTCDateOnlyField(int tagNum, String timestampString) throws ParseException { super(tagNum); this.value = parse(timestampString); } public UTCDateOnlyField(int tagNum, LocalDate value) { super(tagNum); this.value = value; } public static LocalDate parse(String timestampString) throws ParseException { if (timestampString != null) { int len = timestampString.length(); if (len < 8) { throw new ParseException("Unparseable date: '" + timestampString + "'", 0); } else if (len == 8) {
return DATE_FORMATTER.parseLocalDate(timestampString);
kpavlov/fixio
core/src/test/java/fixio/netty/codec/DecodingTestHelper.java
// Path: core/src/main/java/fixio/fixprotocol/FixMessageImpl.java // public class FixMessageImpl implements FixMessage { // // private final FixMessageHeader header = new FixMessageHeader(); // private final FixMessageTrailer trailer = new FixMessageTrailer(); // private final List<FixMessageFragment> body = new ArrayList<>(); // // public FixMessageImpl add(int tagNum, byte[] value) { // return add(tagNum, value, 0, value.length); // } // // public FixMessageImpl addBody(int tagNum, String value) { // body.add(new StringField(tagNum, value)); // return this; // } // // public FixMessageImpl addBody(GroupField group) { // body.add(group); // return this; // } // // public FixMessageImpl add(int tagNum, byte[] value, int offset, int length) { // assert (tagNum > 0) : "TagNum must be positive. Got " + tagNum; // assert (value != null) : "Value must be specified."; // AbstractField field = FieldFactory.valueOf(tagNum, value, offset, length); // FieldType fieldType = FieldType.forTag(tagNum); // switch (fieldType) { // case BeginString: // header.setBeginString(((StringField) field).getValue().intern()); // break; // case CheckSum: // int checksum = (value[offset] - '0') * 100 + (value[offset + 1] - '0') * 10 + (value[offset + 2] - '0'); // trailer.setCheckSum(checksum); // break; // case SenderCompID: // header.setSenderCompID(((StringField) field).getValue()); // break; // case TargetCompID: // header.setTargetCompID(((StringField) field).getValue()); // break; // case MsgSeqNum: // header.setMsgSeqNum(((IntField) field).intValue()); // break; // case MsgType: // header.setMessageType(((StringField) field).getValue().intern()); // break; // default: // body.add(field); // break; // } // return this; // } // // @Override // public List<FixMessageFragment> getBody() { // return body; // } // // @Override // public String getString(int tagNum) { // FixMessageFragment item = getFirst(tagNum); // if (item == null) { // return null; // } // if (item instanceof StringField) { // return ((StringField) item).getValue(); // } else { // throw new IllegalArgumentException("Tag " + tagNum + " is not a Field."); // } // } // // @SuppressWarnings("unchecked") // @Override // public <T> T getValue(FieldType fieldType) { // return getValue(fieldType.tag()); // } // // @SuppressWarnings("unchecked") // @Override // public <T> T getValue(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field instanceof AbstractField) { // return (T) field.getValue(); // } // return null; // } // // @Override // public String getString(FieldType field) { // return getString(field.tag()); // } // // @Override // public Character getChar(FieldType fieldType) { // return getChar(fieldType.tag()); // } // // @Override // public Character getChar(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field == null) { // return null; // } // if (field instanceof CharField) { // return ((CharField) field).getValue(); // } else { // throw new IllegalArgumentException("Tag " + tagNum + " is not a Field."); // } // } // // @Override // public Integer getInt(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field instanceof IntField) { // return ((IntField) field).getValue(); // } // return null; // } // // @Override // public Integer getInt(FieldType field) { // return getInt(field.tag()); // } // // @Override // public FixMessageHeader getHeader() { // return header; // } // // public int getMsgSeqNum() { // return header.getMsgSeqNum(); // } // // @Override // public String getMessageType() { // return header.getMessageType(); // } // // public void setMessageType(String messageType) { // header.setMessageType(messageType); // } // // public int getChecksum() { // return trailer.getCheckSum(); // } // // public List<Group> getGroups(int tagNum) { // FixMessageFragment fragment = getFirst(tagNum); // if (fragment instanceof GroupField) { // return ((GroupField) fragment).getGroups(); // } // return null; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder(512); // final String sp = System.getProperty("line.separator"); // sb.append(sp); // sb.append("header{").append(header).append("}").append(sp); // sb.append("body{").append(body).append("}").append(sp); // sb.append("trailer{").append(trailer).append('}').append(sp); // return sb.toString(); // } // }
import fixio.fixprotocol.FixMessageImpl; import io.netty.buffer.Unpooled; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List;
package fixio.netty.codec; public class DecodingTestHelper { private static String normalizeMessage(String source) { return source.replace('|', '\u0001'); } public static List<Object> decode(String message, FixMessageDecoder decoder) { String[] tags = normalizeMessage(message).split("\u0001"); List<Object> result = new ArrayList<>(); for (String tag : tags) { decoder.decode(null, Unpooled.wrappedBuffer(tag.getBytes(StandardCharsets.US_ASCII)), result); } return result; }
// Path: core/src/main/java/fixio/fixprotocol/FixMessageImpl.java // public class FixMessageImpl implements FixMessage { // // private final FixMessageHeader header = new FixMessageHeader(); // private final FixMessageTrailer trailer = new FixMessageTrailer(); // private final List<FixMessageFragment> body = new ArrayList<>(); // // public FixMessageImpl add(int tagNum, byte[] value) { // return add(tagNum, value, 0, value.length); // } // // public FixMessageImpl addBody(int tagNum, String value) { // body.add(new StringField(tagNum, value)); // return this; // } // // public FixMessageImpl addBody(GroupField group) { // body.add(group); // return this; // } // // public FixMessageImpl add(int tagNum, byte[] value, int offset, int length) { // assert (tagNum > 0) : "TagNum must be positive. Got " + tagNum; // assert (value != null) : "Value must be specified."; // AbstractField field = FieldFactory.valueOf(tagNum, value, offset, length); // FieldType fieldType = FieldType.forTag(tagNum); // switch (fieldType) { // case BeginString: // header.setBeginString(((StringField) field).getValue().intern()); // break; // case CheckSum: // int checksum = (value[offset] - '0') * 100 + (value[offset + 1] - '0') * 10 + (value[offset + 2] - '0'); // trailer.setCheckSum(checksum); // break; // case SenderCompID: // header.setSenderCompID(((StringField) field).getValue()); // break; // case TargetCompID: // header.setTargetCompID(((StringField) field).getValue()); // break; // case MsgSeqNum: // header.setMsgSeqNum(((IntField) field).intValue()); // break; // case MsgType: // header.setMessageType(((StringField) field).getValue().intern()); // break; // default: // body.add(field); // break; // } // return this; // } // // @Override // public List<FixMessageFragment> getBody() { // return body; // } // // @Override // public String getString(int tagNum) { // FixMessageFragment item = getFirst(tagNum); // if (item == null) { // return null; // } // if (item instanceof StringField) { // return ((StringField) item).getValue(); // } else { // throw new IllegalArgumentException("Tag " + tagNum + " is not a Field."); // } // } // // @SuppressWarnings("unchecked") // @Override // public <T> T getValue(FieldType fieldType) { // return getValue(fieldType.tag()); // } // // @SuppressWarnings("unchecked") // @Override // public <T> T getValue(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field instanceof AbstractField) { // return (T) field.getValue(); // } // return null; // } // // @Override // public String getString(FieldType field) { // return getString(field.tag()); // } // // @Override // public Character getChar(FieldType fieldType) { // return getChar(fieldType.tag()); // } // // @Override // public Character getChar(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field == null) { // return null; // } // if (field instanceof CharField) { // return ((CharField) field).getValue(); // } else { // throw new IllegalArgumentException("Tag " + tagNum + " is not a Field."); // } // } // // @Override // public Integer getInt(int tagNum) { // FixMessageFragment field = getFirst(tagNum); // if (field instanceof IntField) { // return ((IntField) field).getValue(); // } // return null; // } // // @Override // public Integer getInt(FieldType field) { // return getInt(field.tag()); // } // // @Override // public FixMessageHeader getHeader() { // return header; // } // // public int getMsgSeqNum() { // return header.getMsgSeqNum(); // } // // @Override // public String getMessageType() { // return header.getMessageType(); // } // // public void setMessageType(String messageType) { // header.setMessageType(messageType); // } // // public int getChecksum() { // return trailer.getCheckSum(); // } // // public List<Group> getGroups(int tagNum) { // FixMessageFragment fragment = getFirst(tagNum); // if (fragment instanceof GroupField) { // return ((GroupField) fragment).getGroups(); // } // return null; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder(512); // final String sp = System.getProperty("line.separator"); // sb.append(sp); // sb.append("header{").append(header).append("}").append(sp); // sb.append("body{").append(body).append("}").append(sp); // sb.append("trailer{").append(trailer).append('}').append(sp); // return sb.toString(); // } // } // Path: core/src/test/java/fixio/netty/codec/DecodingTestHelper.java import fixio.fixprotocol.FixMessageImpl; import io.netty.buffer.Unpooled; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; package fixio.netty.codec; public class DecodingTestHelper { private static String normalizeMessage(String source) { return source.replace('|', '\u0001'); } public static List<Object> decode(String message, FixMessageDecoder decoder) { String[] tags = normalizeMessage(message).split("\u0001"); List<Object> result = new ArrayList<>(); for (String tag : tags) { decoder.decode(null, Unpooled.wrappedBuffer(tag.getBytes(StandardCharsets.US_ASCII)), result); } return result; }
public static FixMessageImpl decodeOne(String message, FixMessageDecoder decoder) {
kpavlov/fixio
core/src/test/java/fixio/fixprotocol/fields/UTCTimestampFieldTest.java
// Path: core/src/main/java/fixio/netty/pipeline/FixClock.java // public class FixClock extends Clock { // // private static final FixClock INSTANCE = new FixClock(Clock.system(FixConst.DEFAULT_ZONE_ID)); // // private final Clock clock; // private final ZoneId zoneId; // private final long initialNanos; // private final Instant initialInstant; // // private FixClock(Clock clock) { // this.clock = clock; // this.zoneId = clock.getZone(); // this.initialInstant = clock.instant(); // this.initialNanos = System.nanoTime(); // } // // public static FixClock systemUTC() { // return INSTANCE; // } // // @Override // public Instant instant() { // return initialInstant.plusNanos(System.nanoTime() - initialNanos); // } // // @Override // public ZoneId getZone() { // return zoneId; // } // // @Override // public FixClock withZone(final ZoneId zone) { // return new FixClock(clock.withZone(zone)); // } // // public ZonedDateTime now() { // return ZonedDateTime.now(this); // } // }
import fixio.netty.pipeline.FixClock; import org.junit.Test; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.util.Random; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals;
/* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class UTCTimestampFieldTest { public static final int MILLIS = 537; public static final int MICROS = 537123; public static final int NANOS = 537123456; public static final long PICOS = 537123456987L; // java time does not support picos // private static final String TIMESTAMP_NO_MILLIS = "19980604-08:03:31"; private static final String TIMESTAMP_WITH_MILLIS = TIMESTAMP_NO_MILLIS+"."+MILLIS; private static final String TIMESTAMP_WITH_MICROS = TIMESTAMP_NO_MILLIS+"."+MICROS; private static final String TIMESTAMP_WITH_NANOS = TIMESTAMP_NO_MILLIS+"."+NANOS; private static final String TIMESTAMP_WITH_PICOS = TIMESTAMP_NO_MILLIS+"."+PICOS; //
// Path: core/src/main/java/fixio/netty/pipeline/FixClock.java // public class FixClock extends Clock { // // private static final FixClock INSTANCE = new FixClock(Clock.system(FixConst.DEFAULT_ZONE_ID)); // // private final Clock clock; // private final ZoneId zoneId; // private final long initialNanos; // private final Instant initialInstant; // // private FixClock(Clock clock) { // this.clock = clock; // this.zoneId = clock.getZone(); // this.initialInstant = clock.instant(); // this.initialNanos = System.nanoTime(); // } // // public static FixClock systemUTC() { // return INSTANCE; // } // // @Override // public Instant instant() { // return initialInstant.plusNanos(System.nanoTime() - initialNanos); // } // // @Override // public ZoneId getZone() { // return zoneId; // } // // @Override // public FixClock withZone(final ZoneId zone) { // return new FixClock(clock.withZone(zone)); // } // // public ZonedDateTime now() { // return ZonedDateTime.now(this); // } // } // Path: core/src/test/java/fixio/fixprotocol/fields/UTCTimestampFieldTest.java import fixio.netty.pipeline.FixClock; import org.junit.Test; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.util.Random; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; /* * Copyright 2014 The FIX.io Project * * The FIX.io Project 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 fixio.fixprotocol.fields; public class UTCTimestampFieldTest { public static final int MILLIS = 537; public static final int MICROS = 537123; public static final int NANOS = 537123456; public static final long PICOS = 537123456987L; // java time does not support picos // private static final String TIMESTAMP_NO_MILLIS = "19980604-08:03:31"; private static final String TIMESTAMP_WITH_MILLIS = TIMESTAMP_NO_MILLIS+"."+MILLIS; private static final String TIMESTAMP_WITH_MICROS = TIMESTAMP_NO_MILLIS+"."+MICROS; private static final String TIMESTAMP_WITH_NANOS = TIMESTAMP_NO_MILLIS+"."+NANOS; private static final String TIMESTAMP_WITH_PICOS = TIMESTAMP_NO_MILLIS+"."+PICOS; //
private final ZonedDateTime testDate = ZonedDateTime.of(LocalDate.of(1998, 6, 4), LocalTime.of(8, 3, 31), FixClock.systemUTC().getZone());
kpavlov/fixio
core/src/test/java/fixio/fixprotocol/fields/FieldFactoryTest.java
// Path: core/src/main/java/fixio/fixprotocol/DataType.java // public enum DataType { // INT, // CHAR, // MULTIPLECHARVALUE, // STRING, // FLOAT, // BOOLEAN, // AMT, // QTY, // PRICE, // PRICEOFFSET, // SEQNUM, // LENGTH, // NUMINGROUP, // MONTHYEAR, // UTCTIMESTAMP, // UTCDATEONLY, // UTCTIMEONLY, // PERCENTAGE, // CURRENCY, // COUNTRY, // LANGUAGE, // EXCHANGE, // LOCALMKTDATE, // MULTIPLESTRINGVALUE, // TZTIMEONLY, // TZTIMESTAMP, // XMLDATA, // DATA // } // // Path: core/src/main/java/fixio/netty/pipeline/FixClock.java // public static FixClock systemUTC() { // return INSTANCE; // }
import fixio.fixprotocol.DataType; import fixio.fixprotocol.FieldType; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZonedDateTime; import java.util.Random; import java.util.concurrent.TimeUnit; import static fixio.netty.pipeline.FixClock.systemUTC; import static java.nio.charset.StandardCharsets.US_ASCII; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang3.RandomStringUtils.randomAscii; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue;
String value = "Y"; BooleanField field = FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.PossDupFlag.tag(), field.getTagNum()); assertSame("value", Boolean.TRUE, field.getValue()); assertTrue("value", field.booleanValue()); } @Test public void testValueOfBooleanFalse() { String value = "N"; BooleanField field = FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.PossDupFlag.tag(), field.getTagNum()); assertSame("value", Boolean.FALSE, field.getValue()); assertFalse("value", field.booleanValue()); } @Test(expected = IllegalArgumentException.class) @Parameters({"XXX", "", "-"}) public void testFailValueOfIncorrectBoolean(String value) { FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); } @Test public void testValueOfUtcTimestampWithMillis() { String value = "19980604-08:03:31.537"; UTCTimestampField field = FieldFactory.valueOf(FieldType.OrigTime.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.OrigTime.tag(), field.getTagNum());
// Path: core/src/main/java/fixio/fixprotocol/DataType.java // public enum DataType { // INT, // CHAR, // MULTIPLECHARVALUE, // STRING, // FLOAT, // BOOLEAN, // AMT, // QTY, // PRICE, // PRICEOFFSET, // SEQNUM, // LENGTH, // NUMINGROUP, // MONTHYEAR, // UTCTIMESTAMP, // UTCDATEONLY, // UTCTIMEONLY, // PERCENTAGE, // CURRENCY, // COUNTRY, // LANGUAGE, // EXCHANGE, // LOCALMKTDATE, // MULTIPLESTRINGVALUE, // TZTIMEONLY, // TZTIMESTAMP, // XMLDATA, // DATA // } // // Path: core/src/main/java/fixio/netty/pipeline/FixClock.java // public static FixClock systemUTC() { // return INSTANCE; // } // Path: core/src/test/java/fixio/fixprotocol/fields/FieldFactoryTest.java import fixio.fixprotocol.DataType; import fixio.fixprotocol.FieldType; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZonedDateTime; import java.util.Random; import java.util.concurrent.TimeUnit; import static fixio.netty.pipeline.FixClock.systemUTC; import static java.nio.charset.StandardCharsets.US_ASCII; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang3.RandomStringUtils.randomAscii; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; String value = "Y"; BooleanField field = FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.PossDupFlag.tag(), field.getTagNum()); assertSame("value", Boolean.TRUE, field.getValue()); assertTrue("value", field.booleanValue()); } @Test public void testValueOfBooleanFalse() { String value = "N"; BooleanField field = FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.PossDupFlag.tag(), field.getTagNum()); assertSame("value", Boolean.FALSE, field.getValue()); assertFalse("value", field.booleanValue()); } @Test(expected = IllegalArgumentException.class) @Parameters({"XXX", "", "-"}) public void testFailValueOfIncorrectBoolean(String value) { FieldFactory.valueOf(FieldType.PossDupFlag.tag(), value.getBytes(US_ASCII)); } @Test public void testValueOfUtcTimestampWithMillis() { String value = "19980604-08:03:31.537"; UTCTimestampField field = FieldFactory.valueOf(FieldType.OrigTime.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.OrigTime.tag(), field.getTagNum());
assertEquals("value", ZonedDateTime.of(LocalDate.of(1998, 6, 4), LocalTime.of(8, 3, 31, (int) TimeUnit.MILLISECONDS.toNanos(537)), systemUTC().getZone()).toInstant().toEpochMilli(), field.getValue().toInstant().toEpochMilli());