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
|
---|---|---|---|---|---|---|
basgren/railways | src/net/bitpot/railways/navigation/GotoRouteMethodModel.java | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
//
// Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
| import com.intellij.ide.util.gotoByName.FilteringGotoByModel;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.Route;
import net.bitpot.railways.models.requestMethods.RequestMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; | package net.bitpot.railways.navigation;
public class GotoRouteMethodModel extends FilteringGotoByModel<RequestMethod> {
public GotoRouteMethodModel(Project project) {
super(project, ChooseByRouteRegistry.getInstance(project).getRouteContributors());
}
@Nullable
@Override
protected RequestMethod filterValueFor(NavigationItem item) { | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
//
// Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
// Path: src/net/bitpot/railways/navigation/GotoRouteMethodModel.java
import com.intellij.ide.util.gotoByName.FilteringGotoByModel;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.Route;
import net.bitpot.railways.models.requestMethods.RequestMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
package net.bitpot.railways.navigation;
public class GotoRouteMethodModel extends FilteringGotoByModel<RequestMethod> {
public GotoRouteMethodModel(Project project) {
super(project, ChooseByRouteRegistry.getInstance(project).getRouteContributors());
}
@Nullable
@Override
protected RequestMethod filterValueFor(NavigationItem item) { | return (item instanceof Route) ? ((Route) item).getRequestMethod() : null; |
basgren/railways | src/net/bitpot/railways/parser/route/RoutePathChunk.java | // Path: src/net/bitpot/railways/gui/RailwaysColors.java
// public class RailwaysColors {
//
// // Color of selection.
// public static final Color HIGHLIGHT_BG_COLOR =
// EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes()
// .getBackgroundColor();
//
// // Route token colors
// // Scheme color names can be taken in RubyMine/lib/resources.jar!/colorSchemes directory.
// public static final Color PARAM_TOKEN_COLOR = schemeColor("RUBY_SYMBOL");
// public static final Color METHOD_COLOR = schemeColor("RUBY_METHOD_NAME");
// public static final Color OPTIONAL_TOKEN_COLOR = JBColor.GRAY;
//
// // Color of the nonexistent action that's referenced by a route.
// public static final Color DISABLED_ITEM_COLOR = JBColor.GRAY;
//
//
//
// // Text attributes
//
// public static final SimpleTextAttributes REGULAR_HL_ATTR = plainTextAttr(null, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes PARAM_TOKEN_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, null);
// public static final SimpleTextAttributes PARAM_TOKEN_HL_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes OPTIONAL_TOKEN_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, null);
// public static final SimpleTextAttributes OPTIONAL_TOKEN_HL_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes METHOD_ATTR = plainTextAttr(METHOD_COLOR, null);
// public static final SimpleTextAttributes METHOD_HL_ATTR = plainTextAttr(METHOD_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes DISABLED_ITEM_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, null);
// public static final SimpleTextAttributes DISABLED_ITEM_HL_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, HIGHLIGHT_BG_COLOR);
//
//
// private static Color schemeColor(String name) {
// return TextAttributesKey.find(name)
// .getDefaultAttributes().getForegroundColor();
// }
//
//
// private static SimpleTextAttributes plainTextAttr(Color fgColor, Color bgColor) {
// return new SimpleTextAttributes(bgColor, fgColor,
// null, SimpleTextAttributes.STYLE_PLAIN);
// }
// }
| import com.intellij.ui.SimpleTextAttributes;
import net.bitpot.railways.gui.RailwaysColors;
import org.jetbrains.annotations.NotNull; | package net.bitpot.railways.parser.route;
public class RoutePathChunk extends TextChunk {
public final static int PLAIN = 0;
public final static int PARAMETER = 1;
public final static int OPTIONAL = 2;
public RoutePathChunk(@NotNull String text, int chunkType, int offsetAbs) {
super(text, chunkType, offsetAbs);
}
@Override
public SimpleTextAttributes getTextAttrs() {
switch(getType()) {
case RoutePathChunk.PARAMETER: | // Path: src/net/bitpot/railways/gui/RailwaysColors.java
// public class RailwaysColors {
//
// // Color of selection.
// public static final Color HIGHLIGHT_BG_COLOR =
// EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes()
// .getBackgroundColor();
//
// // Route token colors
// // Scheme color names can be taken in RubyMine/lib/resources.jar!/colorSchemes directory.
// public static final Color PARAM_TOKEN_COLOR = schemeColor("RUBY_SYMBOL");
// public static final Color METHOD_COLOR = schemeColor("RUBY_METHOD_NAME");
// public static final Color OPTIONAL_TOKEN_COLOR = JBColor.GRAY;
//
// // Color of the nonexistent action that's referenced by a route.
// public static final Color DISABLED_ITEM_COLOR = JBColor.GRAY;
//
//
//
// // Text attributes
//
// public static final SimpleTextAttributes REGULAR_HL_ATTR = plainTextAttr(null, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes PARAM_TOKEN_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, null);
// public static final SimpleTextAttributes PARAM_TOKEN_HL_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes OPTIONAL_TOKEN_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, null);
// public static final SimpleTextAttributes OPTIONAL_TOKEN_HL_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes METHOD_ATTR = plainTextAttr(METHOD_COLOR, null);
// public static final SimpleTextAttributes METHOD_HL_ATTR = plainTextAttr(METHOD_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes DISABLED_ITEM_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, null);
// public static final SimpleTextAttributes DISABLED_ITEM_HL_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, HIGHLIGHT_BG_COLOR);
//
//
// private static Color schemeColor(String name) {
// return TextAttributesKey.find(name)
// .getDefaultAttributes().getForegroundColor();
// }
//
//
// private static SimpleTextAttributes plainTextAttr(Color fgColor, Color bgColor) {
// return new SimpleTextAttributes(bgColor, fgColor,
// null, SimpleTextAttributes.STYLE_PLAIN);
// }
// }
// Path: src/net/bitpot/railways/parser/route/RoutePathChunk.java
import com.intellij.ui.SimpleTextAttributes;
import net.bitpot.railways.gui.RailwaysColors;
import org.jetbrains.annotations.NotNull;
package net.bitpot.railways.parser.route;
public class RoutePathChunk extends TextChunk {
public final static int PLAIN = 0;
public final static int PARAMETER = 1;
public final static int OPTIONAL = 2;
public RoutePathChunk(@NotNull String text, int chunkType, int offsetAbs) {
super(text, chunkType, offsetAbs);
}
@Override
public SimpleTextAttributes getTextAttrs() {
switch(getType()) {
case RoutePathChunk.PARAMETER: | return isHighlighted() ? RailwaysColors.PARAM_TOKEN_HL_ATTR : |
basgren/railways | src/net/bitpot/railways/parser/route/RouteActionChunk.java | // Path: src/net/bitpot/railways/gui/RailwaysColors.java
// public class RailwaysColors {
//
// // Color of selection.
// public static final Color HIGHLIGHT_BG_COLOR =
// EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes()
// .getBackgroundColor();
//
// // Route token colors
// // Scheme color names can be taken in RubyMine/lib/resources.jar!/colorSchemes directory.
// public static final Color PARAM_TOKEN_COLOR = schemeColor("RUBY_SYMBOL");
// public static final Color METHOD_COLOR = schemeColor("RUBY_METHOD_NAME");
// public static final Color OPTIONAL_TOKEN_COLOR = JBColor.GRAY;
//
// // Color of the nonexistent action that's referenced by a route.
// public static final Color DISABLED_ITEM_COLOR = JBColor.GRAY;
//
//
//
// // Text attributes
//
// public static final SimpleTextAttributes REGULAR_HL_ATTR = plainTextAttr(null, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes PARAM_TOKEN_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, null);
// public static final SimpleTextAttributes PARAM_TOKEN_HL_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes OPTIONAL_TOKEN_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, null);
// public static final SimpleTextAttributes OPTIONAL_TOKEN_HL_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes METHOD_ATTR = plainTextAttr(METHOD_COLOR, null);
// public static final SimpleTextAttributes METHOD_HL_ATTR = plainTextAttr(METHOD_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes DISABLED_ITEM_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, null);
// public static final SimpleTextAttributes DISABLED_ITEM_HL_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, HIGHLIGHT_BG_COLOR);
//
//
// private static Color schemeColor(String name) {
// return TextAttributesKey.find(name)
// .getDefaultAttributes().getForegroundColor();
// }
//
//
// private static SimpleTextAttributes plainTextAttr(Color fgColor, Color bgColor) {
// return new SimpleTextAttributes(bgColor, fgColor,
// null, SimpleTextAttributes.STYLE_PLAIN);
// }
// }
| import com.intellij.ui.SimpleTextAttributes;
import net.bitpot.railways.gui.RailwaysColors;
import org.jetbrains.annotations.NotNull; | package net.bitpot.railways.parser.route;
public class RouteActionChunk extends TextChunk {
public static final int CONTAINER = 0; // Class or module
public static final int ACTION = 1;
public RouteActionChunk(@NotNull String text, int chunkType, int startPos) {
super(text, chunkType, startPos);
}
@Override
public SimpleTextAttributes getTextAttrs() {
SimpleTextAttributes textAttrs;
if (getType() == RouteActionChunk.ACTION)
textAttrs = isHighlighted() ? | // Path: src/net/bitpot/railways/gui/RailwaysColors.java
// public class RailwaysColors {
//
// // Color of selection.
// public static final Color HIGHLIGHT_BG_COLOR =
// EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes()
// .getBackgroundColor();
//
// // Route token colors
// // Scheme color names can be taken in RubyMine/lib/resources.jar!/colorSchemes directory.
// public static final Color PARAM_TOKEN_COLOR = schemeColor("RUBY_SYMBOL");
// public static final Color METHOD_COLOR = schemeColor("RUBY_METHOD_NAME");
// public static final Color OPTIONAL_TOKEN_COLOR = JBColor.GRAY;
//
// // Color of the nonexistent action that's referenced by a route.
// public static final Color DISABLED_ITEM_COLOR = JBColor.GRAY;
//
//
//
// // Text attributes
//
// public static final SimpleTextAttributes REGULAR_HL_ATTR = plainTextAttr(null, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes PARAM_TOKEN_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, null);
// public static final SimpleTextAttributes PARAM_TOKEN_HL_ATTR = plainTextAttr(PARAM_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes OPTIONAL_TOKEN_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, null);
// public static final SimpleTextAttributes OPTIONAL_TOKEN_HL_ATTR = plainTextAttr(OPTIONAL_TOKEN_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes METHOD_ATTR = plainTextAttr(METHOD_COLOR, null);
// public static final SimpleTextAttributes METHOD_HL_ATTR = plainTextAttr(METHOD_COLOR, HIGHLIGHT_BG_COLOR);
//
// public static final SimpleTextAttributes DISABLED_ITEM_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, null);
// public static final SimpleTextAttributes DISABLED_ITEM_HL_ATTR = plainTextAttr(DISABLED_ITEM_COLOR, HIGHLIGHT_BG_COLOR);
//
//
// private static Color schemeColor(String name) {
// return TextAttributesKey.find(name)
// .getDefaultAttributes().getForegroundColor();
// }
//
//
// private static SimpleTextAttributes plainTextAttr(Color fgColor, Color bgColor) {
// return new SimpleTextAttributes(bgColor, fgColor,
// null, SimpleTextAttributes.STYLE_PLAIN);
// }
// }
// Path: src/net/bitpot/railways/parser/route/RouteActionChunk.java
import com.intellij.ui.SimpleTextAttributes;
import net.bitpot.railways.gui.RailwaysColors;
import org.jetbrains.annotations.NotNull;
package net.bitpot.railways.parser.route;
public class RouteActionChunk extends TextChunk {
public static final int CONTAINER = 0; // Class or module
public static final int ACTION = 1;
public RouteActionChunk(@NotNull String text, int chunkType, int startPos) {
super(text, chunkType, startPos);
}
@Override
public SimpleTextAttributes getTextAttrs() {
SimpleTextAttributes textAttrs;
if (getType() == RouteActionChunk.ACTION)
textAttrs = isHighlighted() ? | RailwaysColors.METHOD_HL_ATTR : RailwaysColors.METHOD_ATTR; |
basgren/railways | src/net/bitpot/railways/models/requestMethods/DeleteRequestMethod.java | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
| import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; | package net.bitpot.railways.models.requestMethods;
public class DeleteRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
// Path: src/net/bitpot/railways/models/requestMethods/DeleteRequestMethod.java
import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
package net.bitpot.railways.models.requestMethods;
public class DeleteRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | return RailwaysIcons.HTTP_METHOD_DELETE; |
basgren/railways | src/net/bitpot/railways/routesView/RoutesViewPane.java | // Path: src/net/bitpot/railways/utils/RailwaysUtils.java
// public class RailwaysUtils {
// @SuppressWarnings("unused")
// private final static Logger log = Logger.getInstance(RailwaysUtils.class.getName());
//
// public final static StringFormatter STRIP_REQUEST_FORMAT = RailwaysUtils::stripRequestFormat;
//
// /**
// * Returns true if specified project has at least one Ruby on Rails module.
// *
// * @param project Project which should be checked for Rails modules.
// * @return True if a project has at least one Ruby on Rails module.
// */
// public static boolean hasRailsModules(Project project) {
// Module[] modules = ModuleManager.getInstance(project).getModules();
// for (Module m : modules)
// if (RailsApp.fromModule(m) != null)
// return true;
//
// return false;
// }
//
//
// /**
// * Internally used method that runs rake task and gets its output. This
// * method should be called from backgroundable task.
// *
// * @param module Rails module for which rake task should be run.
// * @return Output of 'rake routes'.
// */
// @Nullable
// public static ProcessOutput queryRakeRoutes(Module module,
// String routesTaskName, String railsEnv) {
// // Get root path of Rails application from module.
// RailsApp app = RailsApp.fromModule(module);
// if ((app == null) || (app.getRailsApplicationRoot() == null))
// return null;
//
// String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl();
//
// ModuleRootManager mManager = ModuleRootManager.getInstance(module);
// Sdk sdk = mManager.getSdk();
// if (sdk == null) {
// Notifications.Bus.notify(new Notification("Railways",
// "Railways error",
// "Cannot update route list for '" + module.getName() +
// "' module, because its SDK is not set",
// NotificationType.ERROR)
// , module.getProject());
// return null;
// }
//
// try {
// railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv;
//
// // Will work on IntelliJ platform since 2017.3
// return RubyGemExecutionContext.create(sdk, "rails")
// .withModule(module)
// .withWorkingDirPath(moduleContentRoot)
// .withExecutionMode(new ExecutionModes.SameThreadMode())
// .withArguments(routesTaskName, "--trace", railsEnv)
// .executeScript();
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
//
// /**
// * Shows a dialog with 'rake routes' error stacktrace.
// *
// * @param routesManager RoutesManager which error stacktrace should be
// * displayed.
// */
// public static void showErrorInfo(@NotNull RoutesManager routesManager) {
// ErrorInfoDlg.showError("Error information:",
// routesManager.getParseErrorStackTrace());
// }
//
//
// /**
// * Invokes action with specified ID. This method provides very simple
// * implementation of invoking action manually when ActionEvent and
// * DataContext are unavailable. Created DataContext in this method provides
// * only CommonDataKeys.PROJECT value.
// *
// * @param actionId ID of action to invoke
// * @param project Current project
// */
// public static void invokeAction(String actionId, final Project project) {
// AnAction act = ActionManager.getInstance().getAction(actionId);
//
// // For simple actions which don't heavily use data context, we can create
// // it manually.
// DataContext dataContext = dataId -> {
// if (CommonDataKeys.PROJECT.is(dataId))
// return project;
//
// return null;
// };
//
// act.actionPerformed(new AnActionEvent(null, dataContext,
// ActionPlaces.UNKNOWN, act.getTemplatePresentation(),
// ActionManager.getInstance(), 0));
// }
//
//
// public static void updateActionsStatus(Module module, RouteList routeList) {
// RailsApp app = RailsApp.fromModule(module);
// if ((app == null) || (DumbService.isDumb(module.getProject())))
// return;
//
// // TODO: investigate multiple calls of this method when switching focus from code to tool window without any changes.
//
// for (Route route: routeList)
// route.updateActionStatus(app);
// }
//
//
// private final static String FORMAT_STR = "(.:format)";
//
// @NotNull
// public static String stripRequestFormat(@NotNull String routePath) {
// int endIndex = routePath.length() - FORMAT_STR.length();
// if (routePath.indexOf(FORMAT_STR) == endIndex)
// return routePath.substring(0, endIndex);
//
// return routePath;
// }
//
// }
| import com.intellij.ide.PowerSaveMode;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.psi.*;
import com.intellij.ui.content.Content;
import com.intellij.util.Alarm;
import net.bitpot.railways.utils.RailwaysUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ruby.rails.model.RailsApp; | }
public void dispose() {
PsiManager.getInstance(myModule.getProject())
.removePsiTreeChangeListener(myRoutesChangeListener);
}
public Content getContent() {
return myContent;
}
public Module getModule() {
return myModule;
}
public RoutesManager getRoutesManager() {
return myRoutesManager;
}
public boolean isRoutesInvalidated() {
return isInvalidated;
}
public void updateRoutes() { | // Path: src/net/bitpot/railways/utils/RailwaysUtils.java
// public class RailwaysUtils {
// @SuppressWarnings("unused")
// private final static Logger log = Logger.getInstance(RailwaysUtils.class.getName());
//
// public final static StringFormatter STRIP_REQUEST_FORMAT = RailwaysUtils::stripRequestFormat;
//
// /**
// * Returns true if specified project has at least one Ruby on Rails module.
// *
// * @param project Project which should be checked for Rails modules.
// * @return True if a project has at least one Ruby on Rails module.
// */
// public static boolean hasRailsModules(Project project) {
// Module[] modules = ModuleManager.getInstance(project).getModules();
// for (Module m : modules)
// if (RailsApp.fromModule(m) != null)
// return true;
//
// return false;
// }
//
//
// /**
// * Internally used method that runs rake task and gets its output. This
// * method should be called from backgroundable task.
// *
// * @param module Rails module for which rake task should be run.
// * @return Output of 'rake routes'.
// */
// @Nullable
// public static ProcessOutput queryRakeRoutes(Module module,
// String routesTaskName, String railsEnv) {
// // Get root path of Rails application from module.
// RailsApp app = RailsApp.fromModule(module);
// if ((app == null) || (app.getRailsApplicationRoot() == null))
// return null;
//
// String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl();
//
// ModuleRootManager mManager = ModuleRootManager.getInstance(module);
// Sdk sdk = mManager.getSdk();
// if (sdk == null) {
// Notifications.Bus.notify(new Notification("Railways",
// "Railways error",
// "Cannot update route list for '" + module.getName() +
// "' module, because its SDK is not set",
// NotificationType.ERROR)
// , module.getProject());
// return null;
// }
//
// try {
// railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv;
//
// // Will work on IntelliJ platform since 2017.3
// return RubyGemExecutionContext.create(sdk, "rails")
// .withModule(module)
// .withWorkingDirPath(moduleContentRoot)
// .withExecutionMode(new ExecutionModes.SameThreadMode())
// .withArguments(routesTaskName, "--trace", railsEnv)
// .executeScript();
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
//
// /**
// * Shows a dialog with 'rake routes' error stacktrace.
// *
// * @param routesManager RoutesManager which error stacktrace should be
// * displayed.
// */
// public static void showErrorInfo(@NotNull RoutesManager routesManager) {
// ErrorInfoDlg.showError("Error information:",
// routesManager.getParseErrorStackTrace());
// }
//
//
// /**
// * Invokes action with specified ID. This method provides very simple
// * implementation of invoking action manually when ActionEvent and
// * DataContext are unavailable. Created DataContext in this method provides
// * only CommonDataKeys.PROJECT value.
// *
// * @param actionId ID of action to invoke
// * @param project Current project
// */
// public static void invokeAction(String actionId, final Project project) {
// AnAction act = ActionManager.getInstance().getAction(actionId);
//
// // For simple actions which don't heavily use data context, we can create
// // it manually.
// DataContext dataContext = dataId -> {
// if (CommonDataKeys.PROJECT.is(dataId))
// return project;
//
// return null;
// };
//
// act.actionPerformed(new AnActionEvent(null, dataContext,
// ActionPlaces.UNKNOWN, act.getTemplatePresentation(),
// ActionManager.getInstance(), 0));
// }
//
//
// public static void updateActionsStatus(Module module, RouteList routeList) {
// RailsApp app = RailsApp.fromModule(module);
// if ((app == null) || (DumbService.isDumb(module.getProject())))
// return;
//
// // TODO: investigate multiple calls of this method when switching focus from code to tool window without any changes.
//
// for (Route route: routeList)
// route.updateActionStatus(app);
// }
//
//
// private final static String FORMAT_STR = "(.:format)";
//
// @NotNull
// public static String stripRequestFormat(@NotNull String routePath) {
// int endIndex = routePath.length() - FORMAT_STR.length();
// if (routePath.indexOf(FORMAT_STR) == endIndex)
// return routePath.substring(0, endIndex);
//
// return routePath;
// }
//
// }
// Path: src/net/bitpot/railways/routesView/RoutesViewPane.java
import com.intellij.ide.PowerSaveMode;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.psi.*;
import com.intellij.ui.content.Content;
import com.intellij.util.Alarm;
import net.bitpot.railways.utils.RailwaysUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ruby.rails.model.RailsApp;
}
public void dispose() {
PsiManager.getInstance(myModule.getProject())
.removePsiTreeChangeListener(myRoutesChangeListener);
}
public Content getContent() {
return myContent;
}
public Module getModule() {
return myModule;
}
public RoutesManager getRoutesManager() {
return myRoutesManager;
}
public boolean isRoutesInvalidated() {
return isInvalidated;
}
public void updateRoutes() { | RailwaysUtils.invokeAction("railways.UpdateRoutesList", myModule.getProject()); |
basgren/railways | src/net/bitpot/railways/actions/CopyRouteActionBase.java | // Path: src/net/bitpot/railways/gui/RoutesCopyProvider.java
// public abstract class RoutesCopyProvider extends TextCopyProvider {
//
// private final Route[] routes;
//
// public RoutesCopyProvider(Route[] routes) {
// this.routes = routes;
// }
//
// /**
// * Returns route value that should be copied to clipboard.
// * @param route Route which value should be copied to clipboard (route name in this
// * implementation).
// * @return String to copy
// */
// public abstract String getCopyValue(Route route);
//
// @Nullable
// @Override
// public Collection<String> getTextLinesToCopy() {
// if (routes == null)
// return null;
//
// List<String> copyLines = new ArrayList<>(routes.length);
//
// for (Route route : routes) {
// copyLines.add(getCopyValue(route));
// }
//
// return copyLines;
// }
// }
//
// Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
| import com.intellij.ide.CopyProvider;
import com.intellij.openapi.actionSystem.*;
import net.bitpot.railways.gui.RoutesCopyProvider;
import net.bitpot.railways.models.Route; | package net.bitpot.railways.actions;
/**
* Provides functionality to copy route data from selected items. Requires
* data context to implement DataProvider interface and provide data for
* SELECTED_ITEMS and SELECTED_ITEM keys.
*/
public abstract class CopyRouteActionBase extends AnAction {
/**
* Should return from route a string to be copied.
* @param route Route which data will be copied.
* @return A string to be copied.
*/
abstract public String getRouteValue(Route route);
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
DataContext ctx = anActionEvent.getDataContext();
Route[] routes = (Route[])PlatformDataKeys.SELECTED_ITEMS.getData(ctx);
| // Path: src/net/bitpot/railways/gui/RoutesCopyProvider.java
// public abstract class RoutesCopyProvider extends TextCopyProvider {
//
// private final Route[] routes;
//
// public RoutesCopyProvider(Route[] routes) {
// this.routes = routes;
// }
//
// /**
// * Returns route value that should be copied to clipboard.
// * @param route Route which value should be copied to clipboard (route name in this
// * implementation).
// * @return String to copy
// */
// public abstract String getCopyValue(Route route);
//
// @Nullable
// @Override
// public Collection<String> getTextLinesToCopy() {
// if (routes == null)
// return null;
//
// List<String> copyLines = new ArrayList<>(routes.length);
//
// for (Route route : routes) {
// copyLines.add(getCopyValue(route));
// }
//
// return copyLines;
// }
// }
//
// Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
// Path: src/net/bitpot/railways/actions/CopyRouteActionBase.java
import com.intellij.ide.CopyProvider;
import com.intellij.openapi.actionSystem.*;
import net.bitpot.railways.gui.RoutesCopyProvider;
import net.bitpot.railways.models.Route;
package net.bitpot.railways.actions;
/**
* Provides functionality to copy route data from selected items. Requires
* data context to implement DataProvider interface and provide data for
* SELECTED_ITEMS and SELECTED_ITEM keys.
*/
public abstract class CopyRouteActionBase extends AnAction {
/**
* Should return from route a string to be copied.
* @param route Route which data will be copied.
* @return A string to be copied.
*/
abstract public String getRouteValue(Route route);
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
DataContext ctx = anActionEvent.getDataContext();
Route[] routes = (Route[])PlatformDataKeys.SELECTED_ITEMS.getData(ctx);
| CopyProvider provider = new RoutesCopyProvider(routes) { |
basgren/railways | src/net/bitpot/railways/models/requestMethods/PatchRequestMethod.java | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
| import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; | package net.bitpot.railways.models.requestMethods;
public class PatchRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
// Path: src/net/bitpot/railways/models/requestMethods/PatchRequestMethod.java
import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
package net.bitpot.railways.models.requestMethods;
public class PatchRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | return RailwaysIcons.HTTP_METHOD_PUT; |
basgren/railways | src/net/bitpot/railways/navigation/RouteModuleRendererFactory.java | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
| import com.intellij.ide.util.ModuleRendererFactory;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.util.ui.UIUtil;
import net.bitpot.railways.models.Route;
import javax.swing.*;
import java.awt.*; | package net.bitpot.railways.navigation;
/**
* Factory creates module renderer that renders Route module.
*/
public class RouteModuleRendererFactory extends ModuleRendererFactory {
@Override
protected boolean handles(Object o) {
// Handle only Route objects. | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
// Path: src/net/bitpot/railways/navigation/RouteModuleRendererFactory.java
import com.intellij.ide.util.ModuleRendererFactory;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.util.ui.UIUtil;
import net.bitpot.railways.models.Route;
import javax.swing.*;
import java.awt.*;
package net.bitpot.railways.navigation;
/**
* Factory creates module renderer that renders Route module.
*/
public class RouteModuleRendererFactory extends ModuleRendererFactory {
@Override
protected boolean handles(Object o) {
// Handle only Route objects. | return o instanceof Route; |
basgren/railways | src/net/bitpot/railways/actions/CopyRouteNameAction.java | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
| import net.bitpot.railways.models.Route; | package net.bitpot.railways.actions;
public class CopyRouteNameAction extends CopyRouteActionBase {
@Override | // Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
//
// private final Module module;
// private final RequestMethod requestMethod;
// private final String path;
// private final String routeName;
//
// @Nullable
// private RailsEngine myParentEngine = null;
//
// // Cached path and action text chunks.
// private List<TextChunk> pathChunks = null;
// private List<TextChunk> actionChunks = null;
//
//
// public Route(@Nullable Module module, RequestMethod requestMethod, String path,
// String name) {
// this.module = module;
//
// this.requestMethod = requestMethod;
// this.path = path;
// this.routeName = name;
// }
//
//
// /**
// * Returns module the route belongs to.
// * @return Route module
// */
// public Module getModule() {
// return module;
// }
//
//
// @NotNull
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
//
// /**
// * Returns displayable text for route action in short format. Short format
// * is used in routes table.
// *
// * @return Displayable text for route action, ex. "users#create"
// */
// public String getActionTitle() {
// return getQualifiedActionTitle();
// }
//
//
// /**
// * Returns qualified name for route action.
// *
// * @return Displayable text for route action, ex. "UsersController#create"
// */
// public String getQualifiedActionTitle() {
// return "";
// }
//
//
// /**
// * Returns displayable name for navigation list.
// *
// * @return Display name of current route.
// */
// @Nullable
// @Override
// public String getName() {
// return path;
// }
//
//
// @Nullable
// @Override
// public ItemPresentation getPresentation() {
// final Route route = this;
//
// return new ItemPresentation() {
// @Nullable
// @Override
// public String getPresentableText() {
// return path;
// }
//
//
// @Nullable
// @Override
// public String getLocationString() {
// return getActionTitle();
// }
//
//
// @Nullable
// @Override
// public Icon getIcon(boolean unused) {
// return route.getRequestMethod().getIcon();
// }
// };
// }
//
//
// @Override
// public void navigate(boolean requestFocus) {
// // This method should be overridden in subclasses that support navigation.
// }
//
//
// @Override
// public boolean canNavigate() {
// return false;
// }
//
//
// @Override
// public boolean canNavigateToSource() {
// return canNavigate();
// }
//
//
// public String getPath() {
// return path;
// }
//
// public String getPathWithMethod() {
// String path = RailwaysUtils.stripRequestFormat(getPath());
//
// if (getRequestMethod() == RequestMethods.ANY)
// return path;
//
// return String.format("%s %s", getRequestMethod().getName(), path);
// }
//
//
// public List<TextChunk> getPathChunks() {
// if (pathChunks == null)
// pathChunks = RoutePathParser.getInstance().parse(getPath());
//
// return pathChunks;
// }
//
//
// public List<TextChunk> getActionChunks() {
// if (actionChunks == null)
// actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
//
// return actionChunks;
// }
//
//
// public String getRouteName() {
// if (getParentEngine() != null)
// return getParentEngine().getNamespace() + "." + routeName;
//
// return routeName;
// }
//
//
// /**
// * Checks route action status and sets isActionDeclarationFound flag.
// *
// * @param app Rails application which will be checked for controller action.
// */
// public void updateActionStatus(RailsApp app) {
// // Should be overridden in subclasses if an update is required.
// }
//
//
// @Nullable
// public RailsEngine getParentEngine() {
// return myParentEngine;
// }
//
// public void setParentEngine(RailsEngine parentEngine) {
// myParentEngine = parentEngine;
// }
//
//
// public Icon getActionIcon() {
// return RailwaysIcons.NODE_UNKNOWN;
// }
// }
// Path: src/net/bitpot/railways/actions/CopyRouteNameAction.java
import net.bitpot.railways.models.Route;
package net.bitpot.railways.actions;
public class CopyRouteNameAction extends CopyRouteActionBase {
@Override | public String getRouteValue(Route route) { |
basgren/railways | src/net/bitpot/railways/models/requestMethods/GetRequestMethod.java | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
| import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; | package net.bitpot.railways.models.requestMethods;
public class GetRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
// Path: src/net/bitpot/railways/models/requestMethods/GetRequestMethod.java
import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
package net.bitpot.railways.models.requestMethods;
public class GetRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | return RailwaysIcons.HTTP_METHOD_GET; |
basgren/railways | src/net/bitpot/railways/models/requestMethods/PostRequestMethod.java | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
| import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; | package net.bitpot.railways.models.requestMethods;
public class PostRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
// Path: src/net/bitpot/railways/models/requestMethods/PostRequestMethod.java
import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
package net.bitpot.railways.models.requestMethods;
public class PostRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | return RailwaysIcons.HTTP_METHOD_POST; |
basgren/railways | src/net/bitpot/railways/navigation/ChooseByRouteNameFilter.java | // Path: src/net/bitpot/railways/models/RequestMethods.java
// public class RequestMethods {
// public static final RequestMethod GET = new GetRequestMethod();
// public static final RequestMethod POST = new PostRequestMethod();
// public static final RequestMethod PUT = new PutRequestMethod();
// public static final RequestMethod PATCH = new PatchRequestMethod();
// public static final RequestMethod DELETE = new DeleteRequestMethod();
// public static final RequestMethod ANY = new AnyRequestMethod();
//
//
// private static final List<RequestMethod> requestMethods = createRequestMethods();
//
//
// private static List<RequestMethod> createRequestMethods() {
// Vector<RequestMethod> methods = new Vector<>();
// methods.add(GET);
// methods.add(POST);
// methods.add(PUT);
// methods.add(PATCH);
// methods.add(DELETE);
// methods.add(ANY);
//
// return methods;
// }
//
//
// /**
// * Finds request method by name. If no request method is found, AnyRequestMethod is
// * returned.
// *
// * @param name Name of request method.
// * @return RequestMethod object.
// */
// @NotNull
// public static RequestMethod get(String name) {
// for(RequestMethod method: requestMethods)
// if (method.getName().equals(name))
// return method;
//
// return ANY;
// }
//
//
// public static Collection<RequestMethod> getAllRequestMethods() {
// return requestMethods;
// }
// }
//
// Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
| import com.intellij.ide.util.gotoByName.ChooseByNameFilter;
import com.intellij.ide.util.gotoByName.ChooseByNameFilterConfiguration;
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
import com.intellij.ide.util.gotoByName.FilteringGotoByModel;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.RequestMethods;
import net.bitpot.railways.models.requestMethods.RequestMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collection; | package net.bitpot.railways.navigation;
/**
*
*/
public class ChooseByRouteNameFilter extends ChooseByNameFilter<RequestMethod> {
/**
* A constructor
*
* @param popup a parent popup
* @param model a model for popup
* @param filterConfiguration storage for selected filter values
* @param project a context project
*/
public ChooseByRouteNameFilter(@NotNull ChooseByNamePopup popup,
@NotNull FilteringGotoByModel<RequestMethod> model,
@NotNull ChooseByNameFilterConfiguration<RequestMethod> filterConfiguration,
@NotNull Project project) {
super(popup, model, filterConfiguration, project);
}
@Override
protected String textForFilterValue(@NotNull RequestMethod value) {
return value.getName();
}
@Nullable
@Override
protected Icon iconForFilterValue(@NotNull RequestMethod value) {
return value.getIcon();
}
@NotNull
@Override
protected Collection<RequestMethod> getAllFilterValues() { | // Path: src/net/bitpot/railways/models/RequestMethods.java
// public class RequestMethods {
// public static final RequestMethod GET = new GetRequestMethod();
// public static final RequestMethod POST = new PostRequestMethod();
// public static final RequestMethod PUT = new PutRequestMethod();
// public static final RequestMethod PATCH = new PatchRequestMethod();
// public static final RequestMethod DELETE = new DeleteRequestMethod();
// public static final RequestMethod ANY = new AnyRequestMethod();
//
//
// private static final List<RequestMethod> requestMethods = createRequestMethods();
//
//
// private static List<RequestMethod> createRequestMethods() {
// Vector<RequestMethod> methods = new Vector<>();
// methods.add(GET);
// methods.add(POST);
// methods.add(PUT);
// methods.add(PATCH);
// methods.add(DELETE);
// methods.add(ANY);
//
// return methods;
// }
//
//
// /**
// * Finds request method by name. If no request method is found, AnyRequestMethod is
// * returned.
// *
// * @param name Name of request method.
// * @return RequestMethod object.
// */
// @NotNull
// public static RequestMethod get(String name) {
// for(RequestMethod method: requestMethods)
// if (method.getName().equals(name))
// return method;
//
// return ANY;
// }
//
//
// public static Collection<RequestMethod> getAllRequestMethods() {
// return requestMethods;
// }
// }
//
// Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
// Path: src/net/bitpot/railways/navigation/ChooseByRouteNameFilter.java
import com.intellij.ide.util.gotoByName.ChooseByNameFilter;
import com.intellij.ide.util.gotoByName.ChooseByNameFilterConfiguration;
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
import com.intellij.ide.util.gotoByName.FilteringGotoByModel;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.RequestMethods;
import net.bitpot.railways.models.requestMethods.RequestMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collection;
package net.bitpot.railways.navigation;
/**
*
*/
public class ChooseByRouteNameFilter extends ChooseByNameFilter<RequestMethod> {
/**
* A constructor
*
* @param popup a parent popup
* @param model a model for popup
* @param filterConfiguration storage for selected filter values
* @param project a context project
*/
public ChooseByRouteNameFilter(@NotNull ChooseByNamePopup popup,
@NotNull FilteringGotoByModel<RequestMethod> model,
@NotNull ChooseByNameFilterConfiguration<RequestMethod> filterConfiguration,
@NotNull Project project) {
super(popup, model, filterConfiguration, project);
}
@Override
protected String textForFilterValue(@NotNull RequestMethod value) {
return value.getName();
}
@Nullable
@Override
protected Icon iconForFilterValue(@NotNull RequestMethod value) {
return value.getIcon();
}
@NotNull
@Override
protected Collection<RequestMethod> getAllFilterValues() { | return RequestMethods.getAllRequestMethods(); |
basgren/railways | src/net/bitpot/railways/navigation/GotoRouteFilterConfiguration.java | // Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
| import com.intellij.ide.util.gotoByName.ChooseByNameFilterConfiguration;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.requestMethods.RequestMethod; | package net.bitpot.railways.navigation;
@State(
name = "GotoRouteFilterConfiguration",
storages = {@Storage(value = StoragePathMacros.WORKSPACE_FILE)}) | // Path: src/net/bitpot/railways/models/requestMethods/RequestMethod.java
// public interface RequestMethod {
//
// /**
// * Returns the icon used for showing routes of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// Icon getIcon();
//
// /**
// * Returns the name of the route type. The name must be unique among all route types.
// *
// * @return The route type name.
// */
// @NotNull
// @NonNls
// String getName();
//
// }
// Path: src/net/bitpot/railways/navigation/GotoRouteFilterConfiguration.java
import com.intellij.ide.util.gotoByName.ChooseByNameFilterConfiguration;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
import net.bitpot.railways.models.requestMethods.RequestMethod;
package net.bitpot.railways.navigation;
@State(
name = "GotoRouteFilterConfiguration",
storages = {@Storage(value = StoragePathMacros.WORKSPACE_FILE)}) | public class GotoRouteFilterConfiguration extends ChooseByNameFilterConfiguration<RequestMethod> { |
basgren/railways | src/net/bitpot/railways/models/requestMethods/AnyRequestMethod.java | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
| import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; | package net.bitpot.railways.models.requestMethods;
public class AnyRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | // Path: src/net/bitpot/railways/gui/RailwaysIcons.java
// public class RailwaysIcons {
// private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/";
//
// private static Icon pluginIcon(String name) {
// return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class);
// }
//
// public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png");
// public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png");
// public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png");
// public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png");
// public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png");
// public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration;
//
// // Icons for table items
// public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class;
// public static final Icon NODE_ERROR = AllIcons.General.Error;
// public static final Icon NODE_METHOD = AllIcons.Nodes.Method;
// public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin;
// public static final Icon NODE_REDIRECT = pluginIcon("redirect.png");
// public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method;
// public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png");
//
// public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class);
// public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class);
// }
// Path: src/net/bitpot/railways/models/requestMethods/AnyRequestMethod.java
import net.bitpot.railways.gui.RailwaysIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
package net.bitpot.railways.models.requestMethods;
public class AnyRequestMethod implements RequestMethod {
@Override
public Icon getIcon() { | return RailwaysIcons.HTTP_METHOD_ANY; |
mariodavid/cuba-ordermanagement | modules/portal/src/com/company/ordermanagement/portal/controllers/PortalController.java | // Path: modules/global/src/com/company/ordermanagement/entity/Product.java
// @NamePattern("%s|name")
// @Table(name = "OM_PRODUCT")
// @Entity(name = "om$Product")
// public class Product extends StandardEntity {
// private static final long serialVersionUID = -5073711717993812319L;
//
// @Column(name = "NAME", nullable = false)
// protected String name;
//
// @ManyToOne(fetch = FetchType.LAZY, optional = false)
// @JoinColumn(name = "CATEGORY_ID")
// protected ProductCategory category;
//
// @Lob
// @Column(name = "DESCRIPTION")
// protected String description;
//
// @JoinTable(name = "OM_PRODUCT_FILE_DESCRIPTOR_LINK",
// joinColumns = @JoinColumn(name = "PRODUCT_ID"),
// inverseJoinColumns = @JoinColumn(name = "FILE_DESCRIPTOR_ID"))
// @ManyToMany
// protected Set<FileDescriptor> images;
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setImages(Set<FileDescriptor> images) {
// this.images = images;
// }
//
// public Set<FileDescriptor> getImages() {
// return images;
// }
//
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setCategory(ProductCategory category) {
// this.category = category;
// }
//
// public ProductCategory getCategory() {
// return category;
// }
//
//
// }
//
// Path: modules/portal/src/com/company/ordermanagement/portal/command/LoginUserCommand.java
// @SuppressWarnings({"UnusedDeclaration"})
// public class LoginUserCommand {
//
// private String login;
//
// private String password;
//
// public String getLogin() {
// return login;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
| import com.company.ordermanagement.entity.Product;
import com.company.ordermanagement.portal.command.LoginUserCommand;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.portal.security.PortalSessionProvider;
import com.haulmont.cuba.security.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.inject.Inject; | /*
* Copyright (c) 2015 ordermanagement
*/
package com.company.ordermanagement.portal.controllers;
/**
* @author mario
*/
@Controller
public class PortalController {
@Inject
protected DataService dataService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
if (!PortalSessionProvider.getUserSession().isAuthenticated()) { | // Path: modules/global/src/com/company/ordermanagement/entity/Product.java
// @NamePattern("%s|name")
// @Table(name = "OM_PRODUCT")
// @Entity(name = "om$Product")
// public class Product extends StandardEntity {
// private static final long serialVersionUID = -5073711717993812319L;
//
// @Column(name = "NAME", nullable = false)
// protected String name;
//
// @ManyToOne(fetch = FetchType.LAZY, optional = false)
// @JoinColumn(name = "CATEGORY_ID")
// protected ProductCategory category;
//
// @Lob
// @Column(name = "DESCRIPTION")
// protected String description;
//
// @JoinTable(name = "OM_PRODUCT_FILE_DESCRIPTOR_LINK",
// joinColumns = @JoinColumn(name = "PRODUCT_ID"),
// inverseJoinColumns = @JoinColumn(name = "FILE_DESCRIPTOR_ID"))
// @ManyToMany
// protected Set<FileDescriptor> images;
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setImages(Set<FileDescriptor> images) {
// this.images = images;
// }
//
// public Set<FileDescriptor> getImages() {
// return images;
// }
//
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setCategory(ProductCategory category) {
// this.category = category;
// }
//
// public ProductCategory getCategory() {
// return category;
// }
//
//
// }
//
// Path: modules/portal/src/com/company/ordermanagement/portal/command/LoginUserCommand.java
// @SuppressWarnings({"UnusedDeclaration"})
// public class LoginUserCommand {
//
// private String login;
//
// private String password;
//
// public String getLogin() {
// return login;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
// Path: modules/portal/src/com/company/ordermanagement/portal/controllers/PortalController.java
import com.company.ordermanagement.entity.Product;
import com.company.ordermanagement.portal.command.LoginUserCommand;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.portal.security.PortalSessionProvider;
import com.haulmont.cuba.security.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.inject.Inject;
/*
* Copyright (c) 2015 ordermanagement
*/
package com.company.ordermanagement.portal.controllers;
/**
* @author mario
*/
@Controller
public class PortalController {
@Inject
protected DataService dataService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
if (!PortalSessionProvider.getUserSession().isAuthenticated()) { | final LoginUserCommand loginUserCommand = new LoginUserCommand(); |
mariodavid/cuba-ordermanagement | modules/portal/src/com/company/ordermanagement/portal/controllers/PortalController.java | // Path: modules/global/src/com/company/ordermanagement/entity/Product.java
// @NamePattern("%s|name")
// @Table(name = "OM_PRODUCT")
// @Entity(name = "om$Product")
// public class Product extends StandardEntity {
// private static final long serialVersionUID = -5073711717993812319L;
//
// @Column(name = "NAME", nullable = false)
// protected String name;
//
// @ManyToOne(fetch = FetchType.LAZY, optional = false)
// @JoinColumn(name = "CATEGORY_ID")
// protected ProductCategory category;
//
// @Lob
// @Column(name = "DESCRIPTION")
// protected String description;
//
// @JoinTable(name = "OM_PRODUCT_FILE_DESCRIPTOR_LINK",
// joinColumns = @JoinColumn(name = "PRODUCT_ID"),
// inverseJoinColumns = @JoinColumn(name = "FILE_DESCRIPTOR_ID"))
// @ManyToMany
// protected Set<FileDescriptor> images;
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setImages(Set<FileDescriptor> images) {
// this.images = images;
// }
//
// public Set<FileDescriptor> getImages() {
// return images;
// }
//
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setCategory(ProductCategory category) {
// this.category = category;
// }
//
// public ProductCategory getCategory() {
// return category;
// }
//
//
// }
//
// Path: modules/portal/src/com/company/ordermanagement/portal/command/LoginUserCommand.java
// @SuppressWarnings({"UnusedDeclaration"})
// public class LoginUserCommand {
//
// private String login;
//
// private String password;
//
// public String getLogin() {
// return login;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
| import com.company.ordermanagement.entity.Product;
import com.company.ordermanagement.portal.command.LoginUserCommand;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.portal.security.PortalSessionProvider;
import com.haulmont.cuba.security.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.inject.Inject; | /*
* Copyright (c) 2015 ordermanagement
*/
package com.company.ordermanagement.portal.controllers;
/**
* @author mario
*/
@Controller
public class PortalController {
@Inject
protected DataService dataService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
if (!PortalSessionProvider.getUserSession().isAuthenticated()) {
final LoginUserCommand loginUserCommand = new LoginUserCommand();
model.addAttribute(loginUserCommand);
} | // Path: modules/global/src/com/company/ordermanagement/entity/Product.java
// @NamePattern("%s|name")
// @Table(name = "OM_PRODUCT")
// @Entity(name = "om$Product")
// public class Product extends StandardEntity {
// private static final long serialVersionUID = -5073711717993812319L;
//
// @Column(name = "NAME", nullable = false)
// protected String name;
//
// @ManyToOne(fetch = FetchType.LAZY, optional = false)
// @JoinColumn(name = "CATEGORY_ID")
// protected ProductCategory category;
//
// @Lob
// @Column(name = "DESCRIPTION")
// protected String description;
//
// @JoinTable(name = "OM_PRODUCT_FILE_DESCRIPTOR_LINK",
// joinColumns = @JoinColumn(name = "PRODUCT_ID"),
// inverseJoinColumns = @JoinColumn(name = "FILE_DESCRIPTOR_ID"))
// @ManyToMany
// protected Set<FileDescriptor> images;
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setImages(Set<FileDescriptor> images) {
// this.images = images;
// }
//
// public Set<FileDescriptor> getImages() {
// return images;
// }
//
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setCategory(ProductCategory category) {
// this.category = category;
// }
//
// public ProductCategory getCategory() {
// return category;
// }
//
//
// }
//
// Path: modules/portal/src/com/company/ordermanagement/portal/command/LoginUserCommand.java
// @SuppressWarnings({"UnusedDeclaration"})
// public class LoginUserCommand {
//
// private String login;
//
// private String password;
//
// public String getLogin() {
// return login;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
// Path: modules/portal/src/com/company/ordermanagement/portal/controllers/PortalController.java
import com.company.ordermanagement.entity.Product;
import com.company.ordermanagement.portal.command.LoginUserCommand;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.portal.security.PortalSessionProvider;
import com.haulmont.cuba.security.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.inject.Inject;
/*
* Copyright (c) 2015 ordermanagement
*/
package com.company.ordermanagement.portal.controllers;
/**
* @author mario
*/
@Controller
public class PortalController {
@Inject
protected DataService dataService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
if (!PortalSessionProvider.getUserSession().isAuthenticated()) {
final LoginUserCommand loginUserCommand = new LoginUserCommand();
model.addAttribute(loginUserCommand);
} | LoadContext l = LoadContext.create(Product.class).setView("product-view"); |
redBorder/cep | src/main/java/net/redborder/cep/rest/RestRules.java | // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package net.redborder.cep.rest;
/**
* This class implements the methods available from the HTTP REST API.
*/
@Singleton
@Path("/v1/")
public class RestRules {
private final Logger log = LogManager.getLogger(RestRules.class);
private ObjectMapper mapper = new ObjectMapper();
/**
* This method handles HTTP POST requests with JSON data.
* It sends an add operation to the listener passing it the JSON data.
*
* @param json A string in JSON format.
* @return Response with the appropriate HTTP code.
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response add(String json) {
RestListener listener = RestManager.getListener();
Response response;
try {
log.info("Add request with json: {}", json);
listener.add(parseMap(json));
response = Response.ok().build(); | // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/net/redborder/cep/rest/RestRules.java
import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package net.redborder.cep.rest;
/**
* This class implements the methods available from the HTTP REST API.
*/
@Singleton
@Path("/v1/")
public class RestRules {
private final Logger log = LogManager.getLogger(RestRules.class);
private ObjectMapper mapper = new ObjectMapper();
/**
* This method handles HTTP POST requests with JSON data.
* It sends an add operation to the listener passing it the JSON data.
*
* @param json A string in JSON format.
* @return Response with the appropriate HTTP code.
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response add(String json) {
RestListener listener = RestManager.getListener();
Response response;
try {
log.info("Add request with json: {}", json);
listener.add(parseMap(json));
response = Response.ok().build(); | } catch (RestInvalidException e) { |
redBorder/cep | src/main/java/net/redborder/cep/rest/RestRules.java | // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | } catch (Exception e) {
e.printStackTrace();
response = Response.serverError()
.entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
.build();
}
return response;
}
/**
* This methods handles HTTP DELETE requests.
* It sends an remove operation to the listener passing it an ID.
*
* @param id The ID sent by the user on the request
* @return Response with the appropriate HTTP code.
*/
@DELETE
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response remove(@PathParam("id") String id) {
RestListener listener = RestManager.getListener();
Response response;
// Check if the listener accepted the operation
try {
log.info("Remove request with id: {}", id);
listener.remove(id);
response = Response.ok().build(); | // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/net/redborder/cep/rest/RestRules.java
import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
} catch (Exception e) {
e.printStackTrace();
response = Response.serverError()
.entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
.build();
}
return response;
}
/**
* This methods handles HTTP DELETE requests.
* It sends an remove operation to the listener passing it an ID.
*
* @param id The ID sent by the user on the request
* @return Response with the appropriate HTTP code.
*/
@DELETE
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response remove(@PathParam("id") String id) {
RestListener listener = RestManager.getListener();
Response response;
// Check if the listener accepted the operation
try {
log.info("Remove request with id: {}", id);
listener.remove(id);
response = Response.ok().build(); | } catch (RestNotFoundException e) { |
redBorder/cep | src/main/java/net/redborder/cep/rest/RestRules.java | // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | @GET
@Produces(MediaType.APPLICATION_JSON)
public Response list() {
RestListener listener = RestManager.getListener();
Response response;
try {
List<Map<String, Object>> list = listener.list();
log.info("List request {}", list);
response = Response.ok().entity(list).build();
} catch (Exception e) {
e.printStackTrace();
response = Response.serverError()
.entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
.build();
}
return response;
}
// Helper methods
/**
* This method returns a map from a given json string
*
* @param str The JSON string to parse
* @return A map with the JSON contents
* @throws RestException If the string does not have a valid JSON format
*/
| // Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
// public RestException(String message) {
// super(message);
// }
//
// public RestException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
// public RestInvalidException(String message) {
// super(message);
// }
//
// public RestInvalidException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
// public RestNotFoundException(String message) {
// super(message);
// }
//
// public RestNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/net/redborder/cep/rest/RestRules.java
import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response list() {
RestListener listener = RestManager.getListener();
Response response;
try {
List<Map<String, Object>> list = listener.list();
log.info("List request {}", list);
response = Response.ok().entity(list).build();
} catch (Exception e) {
e.printStackTrace();
response = Response.serverError()
.entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
.build();
}
return response;
}
// Helper methods
/**
* This method returns a map from a given json string
*
* @param str The JSON string to parse
* @return A map with the JSON contents
* @throws RestException If the string does not have a valid JSON format
*/
| private Map<String, Object> parseMap(String str) throws RestException { |
redBorder/cep | src/main/java/net/redborder/cep/sources/kafka/Topic.java | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
| import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import java.util.HashMap;
import java.util.Map; | package net.redborder.cep.sources.kafka;
/**
* This class represents a kafka topic that will be consumed by KafkaSource.
* Every topic has a Parser, that will be used to parse messages coming from
* the topic, and a Source, that will receive every message consumed by the topic.
*
* @see Parser
* @see Source
*/
public class Topic {
// The name of the topic
private final String name;
// The parser that will be used to parse messages coming from this topic | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
// Path: src/main/java/net/redborder/cep/sources/kafka/Topic.java
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import java.util.HashMap;
import java.util.Map;
package net.redborder.cep.sources.kafka;
/**
* This class represents a kafka topic that will be consumed by KafkaSource.
* Every topic has a Parser, that will be used to parse messages coming from
* the topic, and a Source, that will receive every message consumed by the topic.
*
* @see Parser
* @see Source
*/
public class Topic {
// The name of the topic
private final String name;
// The parser that will be used to parse messages coming from this topic | private final Parser parser; |
redBorder/cep | src/main/java/net/redborder/cep/sources/kafka/Topic.java | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
| import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import java.util.HashMap;
import java.util.Map; | package net.redborder.cep.sources.kafka;
/**
* This class represents a kafka topic that will be consumed by KafkaSource.
* Every topic has a Parser, that will be used to parse messages coming from
* the topic, and a Source, that will receive every message consumed by the topic.
*
* @see Parser
* @see Source
*/
public class Topic {
// The name of the topic
private final String name;
// The parser that will be used to parse messages coming from this topic
private final Parser parser;
// The source that will receive the messages consumed from this topic | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
// Path: src/main/java/net/redborder/cep/sources/kafka/Topic.java
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import java.util.HashMap;
import java.util.Map;
package net.redborder.cep.sources.kafka;
/**
* This class represents a kafka topic that will be consumed by KafkaSource.
* Every topic has a Parser, that will be used to parse messages coming from
* the topic, and a Source, that will receive every message consumed by the topic.
*
* @see Parser
* @see Source
*/
public class Topic {
// The name of the topic
private final String name;
// The parser that will be used to parse messages coming from this topic
private final Parser parser;
// The source that will receive the messages consumed from this topic | private final Source source; |
redBorder/cep | src/main/java/net/redborder/cep/sources/kafka/Consumer.java | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
| import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.UnsupportedEncodingException;
import java.util.Map; | package net.redborder.cep.sources.kafka;
/**
* A thread that will consume messages from a given partition from a topic.
* This thread will forward the read messages to a source, that gets from a
* given topic.
*
* @see Topic
* @see Source
*/
public class Consumer implements Runnable {
private final static Logger log = LogManager.getLogger(Consumer.class);
// The KafkaStream from where this thread will consume messages
// This object represents a partition on a topic.
private KafkaStream stream;
// The partition's topic
private Topic topic;
// The parser that will be used to parse the consumed messages | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
// Path: src/main/java/net/redborder/cep/sources/kafka/Consumer.java
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.UnsupportedEncodingException;
import java.util.Map;
package net.redborder.cep.sources.kafka;
/**
* A thread that will consume messages from a given partition from a topic.
* This thread will forward the read messages to a source, that gets from a
* given topic.
*
* @see Topic
* @see Source
*/
public class Consumer implements Runnable {
private final static Logger log = LogManager.getLogger(Consumer.class);
// The KafkaStream from where this thread will consume messages
// This object represents a partition on a topic.
private KafkaStream stream;
// The partition's topic
private Topic topic;
// The parser that will be used to parse the consumed messages | private Parser parser; |
redBorder/cep | src/main/java/net/redborder/cep/sources/kafka/Consumer.java | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
| import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.UnsupportedEncodingException;
import java.util.Map; | package net.redborder.cep.sources.kafka;
/**
* A thread that will consume messages from a given partition from a topic.
* This thread will forward the read messages to a source, that gets from a
* given topic.
*
* @see Topic
* @see Source
*/
public class Consumer implements Runnable {
private final static Logger log = LogManager.getLogger(Consumer.class);
// The KafkaStream from where this thread will consume messages
// This object represents a partition on a topic.
private KafkaStream stream;
// The partition's topic
private Topic topic;
// The parser that will be used to parse the consumed messages
private Parser parser;
// The source that will receive the consumed messages | // Path: src/main/java/net/redborder/cep/sources/Source.java
// public abstract class Source {
// private static final Logger log = LogManager.getLogger(Source.class);
//
// // The instance of disruptor that will consume the events that are produced by this source
// public EventProducer eventProducer;
//
// // The instance of the parsers manager that will serve parser instances in order to parse
// // the events that come from this source
// public ParsersManager parsersManager;
//
// // The list of properties associated with this instance on the config file
// public Map<String, Object> properties;
//
// /**
// * Create a new source.
// * <p>This method will prepare the instance with some needed variables
// * in order to be started later with the start method (implemented by children).
// *
// * @param parsersManager Instance of ParserManager that will serve parsers to this source instance
// * @param eventHandler Instance of EventHandler that will receive the events generated by this source instance
// * @param properties Map of properties associated with this source
// */
//
// public Source(ParsersManager parsersManager, EventHandler eventHandler, Map<String, Object> properties) {
// // Save the references for later use
// this.parsersManager = parsersManager;
// this.properties = properties;
//
// // Create the ring buffer for this topic and start it
// Disruptor<MapEvent> disruptor = new Disruptor<>(new MapEventFactory(), ConfigData.getRingBufferSize(), Executors.newCachedThreadPool());
// disruptor.handleEventsWith(eventHandler);
// disruptor.start();
//
// // Create the event producer that will receive the events produced by
// // this source instance
// eventProducer = new EventProducer(disruptor.getRingBuffer());
// prepare();
// }
//
// /**
// * Sends a new string message to the stream.
// * <p>The param msg should be a string that will be parsed by the parser manager. The parser manager
// * stores a reference of the parser that must be used with each stream, so when a string message
// * is sent, the parser manager parses it to convert it into a map object.
// * <p>This method should be called when the source wants to generate a message to the stream.
// *
// * @param streamName The stream that will receive the message
// * @param msg The string message that will be sent
// */
//
// public void send(String streamName, String msg) {
// Map<String, Object> data = parsersManager.parse(streamName, msg);
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Sends a new map message to the producer.
// *
// * @param streamName The stream that will receive the message
// * @param data The message that will be sent
// */
//
// public void send(String streamName, Map<String, Object> data) {
// eventProducer.putData(streamName, data);
// }
//
// /**
// * Gets a property from the source properties.
// * <p>The source properties are a series of optional properties that are specified on the config file
// * and associated with each stream.
// *
// * @param propertyName The property that will be returned
// * @return The value associated with the property name specified
// */
//
// public Object getProperty(String propertyName){
// return properties.get(propertyName);
// }
//
// /**
// * This method is called by the SourceManager to add one or more new streams to the source.
// * <p>The source implementation must process the streams and do whatever it needs to do to add
// * that stream to the source. For example, you could create a new consumer thread for each stream
// * received, open a new HTTP connection to some external third-party API, etc.
// * <p>The streams that will be passed to the function addStreams of the implementations are
// * specified on the config file by the user.
// *
// * @param streamName One or more streams that has been added in the source.
// * @see SourcesManager
// */
//
// public abstract void addStreams(String ... streamName);
//
// /**
// * This method is called automatically by the Source constructor after finishing, so your
// * implementation can use it to prepare for the following start. For example, you could use it
// * to establish a connection, open some resource, etc.
// */
//
// public abstract void prepare();
//
// /**
// * This method will be called when the Source should be started, so after this call, the source
// * must start to generate messages to the producers using the send methods provided by this class.
// */
//
// public abstract void start();
//
// /**
// * This method will be called when the Source must stop, in order to close connections and
// * release resources that will no longer be useful.
// */
//
// public abstract void shutdown();
// }
//
// Path: src/main/java/net/redborder/cep/sources/parsers/Parser.java
// public interface Parser {
//
// /**
// * This method receives a message string and produces a
// * java map from the string given.
// *
// * @param message The string message that will be parsed
// * @return A map that is the result of parsing the given string
// */
//
// Map<String, Object> parse(String message);
// }
// Path: src/main/java/net/redborder/cep/sources/kafka/Consumer.java
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import net.redborder.cep.sources.Source;
import net.redborder.cep.sources.parsers.Parser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.UnsupportedEncodingException;
import java.util.Map;
package net.redborder.cep.sources.kafka;
/**
* A thread that will consume messages from a given partition from a topic.
* This thread will forward the read messages to a source, that gets from a
* given topic.
*
* @see Topic
* @see Source
*/
public class Consumer implements Runnable {
private final static Logger log = LogManager.getLogger(Consumer.class);
// The KafkaStream from where this thread will consume messages
// This object represents a partition on a topic.
private KafkaStream stream;
// The partition's topic
private Topic topic;
// The parser that will be used to parse the consumed messages
private Parser parser;
// The source that will receive the consumed messages | private Source source; |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/ht/hTrak.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypetrak/htpost.java
// public class htpost extends post {
// @SerializedName("hypetrak_specific")
// public hypetrakconfig hypetrak;
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypetrak.htpost;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import java.util.List;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.ht;
/**
* Created by hesk on 8/9/15.
*/
public interface hTrak {
@GET("/wp-json/posts")
void search(
final @Query("filter[s]") String search_keyword,
final @Query("page") int page,
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering, | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypetrak/htpost.java
// public class htpost extends post {
// @SerializedName("hypetrak_specific")
// public hypetrakconfig hypetrak;
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/ht/hTrak.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypetrak.htpost;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import java.util.List;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.ht;
/**
* Created by hesk on 8/9/15.
*/
public interface hTrak {
@GET("/wp-json/posts")
void search(
final @Query("filter[s]") String search_keyword,
final @Query("page") int page,
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering, | final Callback<List<htpost>> cb) throws ApiException; |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/clients/PBEditorialClient.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/gson/GsonFactory.java
// public class GsonFactory {
//
// public static Gson newGsonInstance() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.excludeFieldsWithModifiers(Modifier.STATIC, Modifier.TRANSIENT);
// gsonBuilder.registerTypeAdapter(Date.class, new DateAdapter());
// return gsonBuilder.create();
// }
//
//
// public static class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory {
// public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
//
// Class<T> rawType = (Class<T>) type.getRawType();
// if (rawType != String.class) {
// return null;
// }
// return (TypeAdapter<T>) new MissingCharacterConversion();
// }
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/gson/MissingCharacterConversion.java
// public class MissingCharacterConversion extends TypeAdapter<String> {
// private boolean hasHtmlEscapers = false;
//
// public MissingCharacterConversion(boolean hasHtmlEscapers) {
// this.hasHtmlEscapers = hasHtmlEscapers;
// }
//
// public MissingCharacterConversion() {
// this(false);
// }
//
// public String read(JsonReader reader) throws IOException {
// if (reader.peek() == JsonToken.NULL) {
// reader.nextNull();
// return "";
// }
// String beforeDecoding = reader.nextString();
// // String decodedValue1 = URLDecoder.decode(str, "UTF-8");
// // return Html.fromHtml((String) str).toString();
// if (hasHtmlEscapers) {
// return beforeDecoding;
// // return URLDecoder.decode(beforeDecoding);
// // return StringEscapeUtils.unescapeEcmaScript(beforeDecoding);
// } else {
// return beforeDecoding.replace("&", "&");
// }
// }
//
// public void write(JsonWriter writer, String value) throws IOException {
// if (value == null) {
// writer.nullValue();
// return;
// }
// // String xy = value.getX() + "," + value.getY();
// writer.value(value);
// }
//
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/pb/pbPost.java
// public interface pbPost {
// @GET("/wp-json/posts")
// void search(
// final @Query("filter[s]") String search_keyword,
// final @Query("page") int page,
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final Callback<List<pbpost>> cb) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void lateset(
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final @Query("page") int page,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void fromLink(
// final @Query("filter[name]") String last_slug,
// final Callback<List<htpost>> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void lateset(
// final @Query("filter[posts_per_page]") int limit,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// @GET("/wp-json/posts")
// void category(
// final @Query("filter[category_name]") String tag_cate,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// @GET("/wp-json/posts")
// void category(
// final @Query("filter[category_name]") String tag_cate,
// final @Query("page") int page,
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// /**
// * only used on installation override
// *
// * @param pid post ID
// * @param cb call back object
// * @throws ApiException the exceptions
// */
// @GET("/wp-json/posts/{pid}")
// void the_post(
// final @Path("pid") long pid,
// final Callback<pbpost> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/mobile-config")
// void mobile_config(final Callback<mobileconfig> cb) throws ApiException;
//
//
// }
| import android.os.Build;
import com.google.gson.GsonBuilder;
import com.hypebeast.sdk.api.gson.GsonFactory;
import com.hypebeast.sdk.api.gson.MissingCharacterConversion;
import com.hypebeast.sdk.api.gson.RealmExclusion;
import com.hypebeast.sdk.api.resources.pb.pbPost;
import java.util.Iterator;
import java.util.List;
import retrofit.RestAdapter;
import retrofit.client.Header;
import retrofit.client.Response;
import retrofit.converter.GsonConverter; | @Override
protected void registerAdapter() {
mAdapter = new RestAdapter.Builder()
.setEndpoint(BASE_URL_PB)
.setLogLevel(RestAdapter.LogLevel.HEADERS)
.setErrorHandler(handlerError)
.setRequestInterceptor(getIn())
.setConverter(new GsonConverter(gsonsetup))
.build();
}
@Override
protected String get_USER_AGENT() {
return USER_AGENT;
}
@Override
protected void jsonCreate() {
gsonsetup = new GsonBuilder()
.setDateFormat(DATE_FORMAT)
.setExclusionStrategies(new RealmExclusion())
.registerTypeAdapterFactory(new GsonFactory.NullStringToEmptyAdapterFactory())
.registerTypeAdapter(String.class, new MissingCharacterConversion())
.create();
}
public PBEditorialClient() {
super();
}
| // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/gson/GsonFactory.java
// public class GsonFactory {
//
// public static Gson newGsonInstance() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.excludeFieldsWithModifiers(Modifier.STATIC, Modifier.TRANSIENT);
// gsonBuilder.registerTypeAdapter(Date.class, new DateAdapter());
// return gsonBuilder.create();
// }
//
//
// public static class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory {
// public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
//
// Class<T> rawType = (Class<T>) type.getRawType();
// if (rawType != String.class) {
// return null;
// }
// return (TypeAdapter<T>) new MissingCharacterConversion();
// }
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/gson/MissingCharacterConversion.java
// public class MissingCharacterConversion extends TypeAdapter<String> {
// private boolean hasHtmlEscapers = false;
//
// public MissingCharacterConversion(boolean hasHtmlEscapers) {
// this.hasHtmlEscapers = hasHtmlEscapers;
// }
//
// public MissingCharacterConversion() {
// this(false);
// }
//
// public String read(JsonReader reader) throws IOException {
// if (reader.peek() == JsonToken.NULL) {
// reader.nextNull();
// return "";
// }
// String beforeDecoding = reader.nextString();
// // String decodedValue1 = URLDecoder.decode(str, "UTF-8");
// // return Html.fromHtml((String) str).toString();
// if (hasHtmlEscapers) {
// return beforeDecoding;
// // return URLDecoder.decode(beforeDecoding);
// // return StringEscapeUtils.unescapeEcmaScript(beforeDecoding);
// } else {
// return beforeDecoding.replace("&", "&");
// }
// }
//
// public void write(JsonWriter writer, String value) throws IOException {
// if (value == null) {
// writer.nullValue();
// return;
// }
// // String xy = value.getX() + "," + value.getY();
// writer.value(value);
// }
//
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/pb/pbPost.java
// public interface pbPost {
// @GET("/wp-json/posts")
// void search(
// final @Query("filter[s]") String search_keyword,
// final @Query("page") int page,
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final Callback<List<pbpost>> cb) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void lateset(
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final @Query("page") int page,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void fromLink(
// final @Query("filter[name]") String last_slug,
// final Callback<List<htpost>> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/posts")
// void lateset(
// final @Query("filter[posts_per_page]") int limit,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// @GET("/wp-json/posts")
// void category(
// final @Query("filter[category_name]") String tag_cate,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// @GET("/wp-json/posts")
// void category(
// final @Query("filter[category_name]") String tag_cate,
// final @Query("page") int page,
// final @Query("filter[posts_per_page]") int limit,
// final @Query("filter[order]") String ordering,
// final Callback<List<pbpost>> cb
// ) throws ApiException;
//
// /**
// * only used on installation override
// *
// * @param pid post ID
// * @param cb call back object
// * @throws ApiException the exceptions
// */
// @GET("/wp-json/posts/{pid}")
// void the_post(
// final @Path("pid") long pid,
// final Callback<pbpost> cb
// ) throws ApiException;
//
//
// @GET("/wp-json/mobile-config")
// void mobile_config(final Callback<mobileconfig> cb) throws ApiException;
//
//
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/clients/PBEditorialClient.java
import android.os.Build;
import com.google.gson.GsonBuilder;
import com.hypebeast.sdk.api.gson.GsonFactory;
import com.hypebeast.sdk.api.gson.MissingCharacterConversion;
import com.hypebeast.sdk.api.gson.RealmExclusion;
import com.hypebeast.sdk.api.resources.pb.pbPost;
import java.util.Iterator;
import java.util.List;
import retrofit.RestAdapter;
import retrofit.client.Header;
import retrofit.client.Response;
import retrofit.converter.GsonConverter;
@Override
protected void registerAdapter() {
mAdapter = new RestAdapter.Builder()
.setEndpoint(BASE_URL_PB)
.setLogLevel(RestAdapter.LogLevel.HEADERS)
.setErrorHandler(handlerError)
.setRequestInterceptor(getIn())
.setConverter(new GsonConverter(gsonsetup))
.build();
}
@Override
protected String get_USER_AGENT() {
return USER_AGENT;
}
@Override
protected void jsonCreate() {
gsonsetup = new GsonBuilder()
.setDateFormat(DATE_FORMAT)
.setExclusionStrategies(new RealmExclusion())
.registerTypeAdapterFactory(new GsonFactory.NullStringToEmptyAdapterFactory())
.registerTypeAdapter(String.class, new MissingCharacterConversion())
.create();
}
public PBEditorialClient() {
super();
}
| public pbPost createPostsFeed() { |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ResponseProductList.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/Product.java
// public class Product {
// @SerializedName("id")
// private int id;
// @SerializedName("name")
// private String name;
// @SerializedName("description")
// private String description;
// @SerializedName("price")
// private int price;
// // @SerializedName("sale_price")
// // private int sale_price;
// @SerializedName("created_at")
// private String created_at;
// @SerializedName("updated_at")
// private String updated_at;
// @SerializedName("_links")
// private connection _links;
// @SerializedName("_embedded")
// private RelatedGroups _embedded;
// @SerializedName("images")
// private List<Image> images = new ArrayList<Image>();
// @SerializedName("variants")
// private List<Variant> variants = new ArrayList<Variant>();
// @SerializedName("attributes")
// private List<Attributes> attributes = new ArrayList<Attributes>();
//
// public final static String trick = "<style type=\"text/css\">\n" +
// "html, body {\n" +
// "width:100%;\n" +
// "height: 100%;\n" +
// "margin: 0px;\n" +
// "padding: 0px;\n" +
// "}\n" +
// "</style>";
//
// public int getId() {
// return id;
// }
//
// public List<Image> get_product_images() {
// return images;
// }
//
// public String get_cover_image() {
// return images.get(0).data.medium.href;
// }
//
// public String get_brand_name() {
// return _embedded.brands.get(0).getcodename();
// }
//
// public String price_sale() {
// return "";
// }
// public String price() {
// return price(String.valueOf((float) price / (float) 100));
// }
//
// private String price(final String p) {
// return "$" + p + " USD";
// }
//
// @SuppressLint("StringFormatMatches")
// public static String readPriceTag(Context c, final String price) {
// String formate = c.getResources().getString(R.string.price_tag_format_usd);
// return String.format(formate, price);
// }
//
// public String getSingleEndPoint() {
// return _links == null ? "" : _links.self.href;
// }
//
// public String getTitle() {
// return name;
// }
//
// public String get_desc() {
// return description;
// }
//
//
//
// public boolean hasVariance() {
// return variants.size() > 1;
// }
//
// public String getBrandUrl() {
// return _links.brand.href;
// }
//
// public boolean matchCurrentHref(String url) {
// return _links.self.href.equalsIgnoreCase(url);
// }
//
// public ArrayList<Variant> getMappedVariants() throws Exception {
// if (!hasVariance()) throw new Exception("variance not found");
// ArrayList<Variant> h = new ArrayList<Variant>();
// for (int i = 1; i < variants.size(); i++) {
// Variant m = variants.get(i).init();
// h.add(m);
// }
// return h;
// }
//
// public List<Attributes> getAttributes() {
// return attributes;
// }
//
// public ArrayList<ProductGroupContainer> getProductGroupContainer() {
// return _links.group_products;
// }
//
// /**
// * n can only be bigger than 1
// * n greater than 1
// *
// * @param n the input integer
// * @return the integer number.
// */
// public int getVariantID(int n) {
// return variants.get(n).getId();
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/FilterGroup.java
// public class FilterGroup {
// @SerializedName("size")
// public filterpart size;
// @SerializedName("brand")
// public filterpart brand;
// @SerializedName("category")
// public filterpart category;
// @SerializedName("color")
// public filterpart color;
// @SerializedName("price")
// public filterpart priceRange;
//
// public static String[] convertToStringList(filterpart items) {
// final ArrayList<String> itemlist = new ArrayList<String>();
// if (items.filter_name == filterpart.FacetType.range) {
// Iterator<Range> ri = items.rangeslist.iterator();
// while (ri.hasNext()) {
// Range r = ri.next();
// itemlist.add(r.getCallDisplay());
// }
// } else if (items.filter_name == filterpart.FacetType.terms) {
// final Iterator<TermWrap> itemwrap = items.contentlist.iterator();
// while (itemwrap.hasNext()) {
// TermWrap f = itemwrap.next();
// itemlist.add(f.toString());
// }
// }
// return itemlist.toArray(new String[itemlist.size()]);
// }
// }
| import com.google.gson.annotations.SerializedName;
import com.hypebeast.sdk.api.model.Alternative;
import com.hypebeast.sdk.api.model.symfony.Product;
import com.hypebeast.sdk.api.model.symfony.embededList;
import com.hypebeast.sdk.api.model.symfony.FilterGroup;
import java.util.List; | package com.hypebeast.sdk.api.model.hypebeaststore;
/**
* Created by hesk on 2/6/15.
*/
public class ResponseProductList extends Alternative {
@SerializedName("page")
private int page;
@SerializedName("limit")
private int limit;
@SerializedName("pages")
private int pages;
@SerializedName("total")
public int total;
@SerializedName("_embedded")
private embededList embededitems;
@SerializedName("facets") | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/Product.java
// public class Product {
// @SerializedName("id")
// private int id;
// @SerializedName("name")
// private String name;
// @SerializedName("description")
// private String description;
// @SerializedName("price")
// private int price;
// // @SerializedName("sale_price")
// // private int sale_price;
// @SerializedName("created_at")
// private String created_at;
// @SerializedName("updated_at")
// private String updated_at;
// @SerializedName("_links")
// private connection _links;
// @SerializedName("_embedded")
// private RelatedGroups _embedded;
// @SerializedName("images")
// private List<Image> images = new ArrayList<Image>();
// @SerializedName("variants")
// private List<Variant> variants = new ArrayList<Variant>();
// @SerializedName("attributes")
// private List<Attributes> attributes = new ArrayList<Attributes>();
//
// public final static String trick = "<style type=\"text/css\">\n" +
// "html, body {\n" +
// "width:100%;\n" +
// "height: 100%;\n" +
// "margin: 0px;\n" +
// "padding: 0px;\n" +
// "}\n" +
// "</style>";
//
// public int getId() {
// return id;
// }
//
// public List<Image> get_product_images() {
// return images;
// }
//
// public String get_cover_image() {
// return images.get(0).data.medium.href;
// }
//
// public String get_brand_name() {
// return _embedded.brands.get(0).getcodename();
// }
//
// public String price_sale() {
// return "";
// }
// public String price() {
// return price(String.valueOf((float) price / (float) 100));
// }
//
// private String price(final String p) {
// return "$" + p + " USD";
// }
//
// @SuppressLint("StringFormatMatches")
// public static String readPriceTag(Context c, final String price) {
// String formate = c.getResources().getString(R.string.price_tag_format_usd);
// return String.format(formate, price);
// }
//
// public String getSingleEndPoint() {
// return _links == null ? "" : _links.self.href;
// }
//
// public String getTitle() {
// return name;
// }
//
// public String get_desc() {
// return description;
// }
//
//
//
// public boolean hasVariance() {
// return variants.size() > 1;
// }
//
// public String getBrandUrl() {
// return _links.brand.href;
// }
//
// public boolean matchCurrentHref(String url) {
// return _links.self.href.equalsIgnoreCase(url);
// }
//
// public ArrayList<Variant> getMappedVariants() throws Exception {
// if (!hasVariance()) throw new Exception("variance not found");
// ArrayList<Variant> h = new ArrayList<Variant>();
// for (int i = 1; i < variants.size(); i++) {
// Variant m = variants.get(i).init();
// h.add(m);
// }
// return h;
// }
//
// public List<Attributes> getAttributes() {
// return attributes;
// }
//
// public ArrayList<ProductGroupContainer> getProductGroupContainer() {
// return _links.group_products;
// }
//
// /**
// * n can only be bigger than 1
// * n greater than 1
// *
// * @param n the input integer
// * @return the integer number.
// */
// public int getVariantID(int n) {
// return variants.get(n).getId();
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/FilterGroup.java
// public class FilterGroup {
// @SerializedName("size")
// public filterpart size;
// @SerializedName("brand")
// public filterpart brand;
// @SerializedName("category")
// public filterpart category;
// @SerializedName("color")
// public filterpart color;
// @SerializedName("price")
// public filterpart priceRange;
//
// public static String[] convertToStringList(filterpart items) {
// final ArrayList<String> itemlist = new ArrayList<String>();
// if (items.filter_name == filterpart.FacetType.range) {
// Iterator<Range> ri = items.rangeslist.iterator();
// while (ri.hasNext()) {
// Range r = ri.next();
// itemlist.add(r.getCallDisplay());
// }
// } else if (items.filter_name == filterpart.FacetType.terms) {
// final Iterator<TermWrap> itemwrap = items.contentlist.iterator();
// while (itemwrap.hasNext()) {
// TermWrap f = itemwrap.next();
// itemlist.add(f.toString());
// }
// }
// return itemlist.toArray(new String[itemlist.size()]);
// }
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ResponseProductList.java
import com.google.gson.annotations.SerializedName;
import com.hypebeast.sdk.api.model.Alternative;
import com.hypebeast.sdk.api.model.symfony.Product;
import com.hypebeast.sdk.api.model.symfony.embededList;
import com.hypebeast.sdk.api.model.symfony.FilterGroup;
import java.util.List;
package com.hypebeast.sdk.api.model.hypebeaststore;
/**
* Created by hesk on 2/6/15.
*/
public class ResponseProductList extends Alternative {
@SerializedName("page")
private int page;
@SerializedName("limit")
private int limit;
@SerializedName("pages")
private int pages;
@SerializedName("total")
public int total;
@SerializedName("_embedded")
private embededList embededitems;
@SerializedName("facets") | private FilterGroup filters; |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ResponseProductList.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/Product.java
// public class Product {
// @SerializedName("id")
// private int id;
// @SerializedName("name")
// private String name;
// @SerializedName("description")
// private String description;
// @SerializedName("price")
// private int price;
// // @SerializedName("sale_price")
// // private int sale_price;
// @SerializedName("created_at")
// private String created_at;
// @SerializedName("updated_at")
// private String updated_at;
// @SerializedName("_links")
// private connection _links;
// @SerializedName("_embedded")
// private RelatedGroups _embedded;
// @SerializedName("images")
// private List<Image> images = new ArrayList<Image>();
// @SerializedName("variants")
// private List<Variant> variants = new ArrayList<Variant>();
// @SerializedName("attributes")
// private List<Attributes> attributes = new ArrayList<Attributes>();
//
// public final static String trick = "<style type=\"text/css\">\n" +
// "html, body {\n" +
// "width:100%;\n" +
// "height: 100%;\n" +
// "margin: 0px;\n" +
// "padding: 0px;\n" +
// "}\n" +
// "</style>";
//
// public int getId() {
// return id;
// }
//
// public List<Image> get_product_images() {
// return images;
// }
//
// public String get_cover_image() {
// return images.get(0).data.medium.href;
// }
//
// public String get_brand_name() {
// return _embedded.brands.get(0).getcodename();
// }
//
// public String price_sale() {
// return "";
// }
// public String price() {
// return price(String.valueOf((float) price / (float) 100));
// }
//
// private String price(final String p) {
// return "$" + p + " USD";
// }
//
// @SuppressLint("StringFormatMatches")
// public static String readPriceTag(Context c, final String price) {
// String formate = c.getResources().getString(R.string.price_tag_format_usd);
// return String.format(formate, price);
// }
//
// public String getSingleEndPoint() {
// return _links == null ? "" : _links.self.href;
// }
//
// public String getTitle() {
// return name;
// }
//
// public String get_desc() {
// return description;
// }
//
//
//
// public boolean hasVariance() {
// return variants.size() > 1;
// }
//
// public String getBrandUrl() {
// return _links.brand.href;
// }
//
// public boolean matchCurrentHref(String url) {
// return _links.self.href.equalsIgnoreCase(url);
// }
//
// public ArrayList<Variant> getMappedVariants() throws Exception {
// if (!hasVariance()) throw new Exception("variance not found");
// ArrayList<Variant> h = new ArrayList<Variant>();
// for (int i = 1; i < variants.size(); i++) {
// Variant m = variants.get(i).init();
// h.add(m);
// }
// return h;
// }
//
// public List<Attributes> getAttributes() {
// return attributes;
// }
//
// public ArrayList<ProductGroupContainer> getProductGroupContainer() {
// return _links.group_products;
// }
//
// /**
// * n can only be bigger than 1
// * n greater than 1
// *
// * @param n the input integer
// * @return the integer number.
// */
// public int getVariantID(int n) {
// return variants.get(n).getId();
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/FilterGroup.java
// public class FilterGroup {
// @SerializedName("size")
// public filterpart size;
// @SerializedName("brand")
// public filterpart brand;
// @SerializedName("category")
// public filterpart category;
// @SerializedName("color")
// public filterpart color;
// @SerializedName("price")
// public filterpart priceRange;
//
// public static String[] convertToStringList(filterpart items) {
// final ArrayList<String> itemlist = new ArrayList<String>();
// if (items.filter_name == filterpart.FacetType.range) {
// Iterator<Range> ri = items.rangeslist.iterator();
// while (ri.hasNext()) {
// Range r = ri.next();
// itemlist.add(r.getCallDisplay());
// }
// } else if (items.filter_name == filterpart.FacetType.terms) {
// final Iterator<TermWrap> itemwrap = items.contentlist.iterator();
// while (itemwrap.hasNext()) {
// TermWrap f = itemwrap.next();
// itemlist.add(f.toString());
// }
// }
// return itemlist.toArray(new String[itemlist.size()]);
// }
// }
| import com.google.gson.annotations.SerializedName;
import com.hypebeast.sdk.api.model.Alternative;
import com.hypebeast.sdk.api.model.symfony.Product;
import com.hypebeast.sdk.api.model.symfony.embededList;
import com.hypebeast.sdk.api.model.symfony.FilterGroup;
import java.util.List; | package com.hypebeast.sdk.api.model.hypebeaststore;
/**
* Created by hesk on 2/6/15.
*/
public class ResponseProductList extends Alternative {
@SerializedName("page")
private int page;
@SerializedName("limit")
private int limit;
@SerializedName("pages")
private int pages;
@SerializedName("total")
public int total;
@SerializedName("_embedded")
private embededList embededitems;
@SerializedName("facets")
private FilterGroup filters;
public int totalpages() {
return pages;
}
public int current_page() {
return page;
}
| // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/Product.java
// public class Product {
// @SerializedName("id")
// private int id;
// @SerializedName("name")
// private String name;
// @SerializedName("description")
// private String description;
// @SerializedName("price")
// private int price;
// // @SerializedName("sale_price")
// // private int sale_price;
// @SerializedName("created_at")
// private String created_at;
// @SerializedName("updated_at")
// private String updated_at;
// @SerializedName("_links")
// private connection _links;
// @SerializedName("_embedded")
// private RelatedGroups _embedded;
// @SerializedName("images")
// private List<Image> images = new ArrayList<Image>();
// @SerializedName("variants")
// private List<Variant> variants = new ArrayList<Variant>();
// @SerializedName("attributes")
// private List<Attributes> attributes = new ArrayList<Attributes>();
//
// public final static String trick = "<style type=\"text/css\">\n" +
// "html, body {\n" +
// "width:100%;\n" +
// "height: 100%;\n" +
// "margin: 0px;\n" +
// "padding: 0px;\n" +
// "}\n" +
// "</style>";
//
// public int getId() {
// return id;
// }
//
// public List<Image> get_product_images() {
// return images;
// }
//
// public String get_cover_image() {
// return images.get(0).data.medium.href;
// }
//
// public String get_brand_name() {
// return _embedded.brands.get(0).getcodename();
// }
//
// public String price_sale() {
// return "";
// }
// public String price() {
// return price(String.valueOf((float) price / (float) 100));
// }
//
// private String price(final String p) {
// return "$" + p + " USD";
// }
//
// @SuppressLint("StringFormatMatches")
// public static String readPriceTag(Context c, final String price) {
// String formate = c.getResources().getString(R.string.price_tag_format_usd);
// return String.format(formate, price);
// }
//
// public String getSingleEndPoint() {
// return _links == null ? "" : _links.self.href;
// }
//
// public String getTitle() {
// return name;
// }
//
// public String get_desc() {
// return description;
// }
//
//
//
// public boolean hasVariance() {
// return variants.size() > 1;
// }
//
// public String getBrandUrl() {
// return _links.brand.href;
// }
//
// public boolean matchCurrentHref(String url) {
// return _links.self.href.equalsIgnoreCase(url);
// }
//
// public ArrayList<Variant> getMappedVariants() throws Exception {
// if (!hasVariance()) throw new Exception("variance not found");
// ArrayList<Variant> h = new ArrayList<Variant>();
// for (int i = 1; i < variants.size(); i++) {
// Variant m = variants.get(i).init();
// h.add(m);
// }
// return h;
// }
//
// public List<Attributes> getAttributes() {
// return attributes;
// }
//
// public ArrayList<ProductGroupContainer> getProductGroupContainer() {
// return _links.group_products;
// }
//
// /**
// * n can only be bigger than 1
// * n greater than 1
// *
// * @param n the input integer
// * @return the integer number.
// */
// public int getVariantID(int n) {
// return variants.get(n).getId();
// }
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/symfony/FilterGroup.java
// public class FilterGroup {
// @SerializedName("size")
// public filterpart size;
// @SerializedName("brand")
// public filterpart brand;
// @SerializedName("category")
// public filterpart category;
// @SerializedName("color")
// public filterpart color;
// @SerializedName("price")
// public filterpart priceRange;
//
// public static String[] convertToStringList(filterpart items) {
// final ArrayList<String> itemlist = new ArrayList<String>();
// if (items.filter_name == filterpart.FacetType.range) {
// Iterator<Range> ri = items.rangeslist.iterator();
// while (ri.hasNext()) {
// Range r = ri.next();
// itemlist.add(r.getCallDisplay());
// }
// } else if (items.filter_name == filterpart.FacetType.terms) {
// final Iterator<TermWrap> itemwrap = items.contentlist.iterator();
// while (itemwrap.hasNext()) {
// TermWrap f = itemwrap.next();
// itemlist.add(f.toString());
// }
// }
// return itemlist.toArray(new String[itemlist.size()]);
// }
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ResponseProductList.java
import com.google.gson.annotations.SerializedName;
import com.hypebeast.sdk.api.model.Alternative;
import com.hypebeast.sdk.api.model.symfony.Product;
import com.hypebeast.sdk.api.model.symfony.embededList;
import com.hypebeast.sdk.api.model.symfony.FilterGroup;
import java.util.List;
package com.hypebeast.sdk.api.model.hypebeaststore;
/**
* Created by hesk on 2/6/15.
*/
public class ResponseProductList extends Alternative {
@SerializedName("page")
private int page;
@SerializedName("limit")
private int limit;
@SerializedName("pages")
private int pages;
@SerializedName("total")
public int total;
@SerializedName("_embedded")
private embededList embededitems;
@SerializedName("facets")
private FilterGroup filters;
public int totalpages() {
return pages;
}
public int current_page() {
return page;
}
| public List<Product> getlist() { |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hbstore/Products.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ReponseNormal.java
// public class ReponseNormal extends Alternative {
// @SerializedName("products")
// public ResponseProductList product_list;
//
// @SerializedName("taxon")
// public taxonomy taxon_result;
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypebeaststore.ReponseNormal;
import com.hypebeast.sdk.api.model.hypebeaststore.ResponseSingleProduct;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.hbstore;
/**
* Created by hesk on 30/6/15.
*/
public interface Products {
@GET("/products/{product_identification_no}")
void PIDReq(
final @Path("product_identification_no") long product_id, final Callback<ResponseSingleProduct> result) throws ApiException;
@GET("/categories/{catename}")
void bycate(
final @Path("catename") String category_name, | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/ReponseNormal.java
// public class ReponseNormal extends Alternative {
// @SerializedName("products")
// public ResponseProductList product_list;
//
// @SerializedName("taxon")
// public taxonomy taxon_result;
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hbstore/Products.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypebeaststore.ReponseNormal;
import com.hypebeast.sdk.api.model.hypebeaststore.ResponseSingleProduct;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.hbstore;
/**
* Created by hesk on 30/6/15.
*/
public interface Products {
@GET("/products/{product_identification_no}")
void PIDReq(
final @Path("product_identification_no") long product_id, final Callback<ResponseSingleProduct> result) throws ApiException;
@GET("/categories/{catename}")
void bycate(
final @Path("catename") String category_name, | final Callback<ReponseNormal> result) throws ApiException; |
jjhesk/slideSelectionList | SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/V1/StringControlAdapter.java | // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/SelectChoice.java
// public class SelectChoice extends LevelResources<String> {
// public enum ListType {
// MAINFILTER,
// FILTER_ITEM
// }
//
// private String choice_selection;
//
// public String selected_string() {
// return choice_selection;
// }
//
// @Override
// public void setSelectedAtPos(int selectedAtPos) {
// super.setSelectedAtPos(selectedAtPos);
// this.choice_selection = resource.get(selectedAtPos);
// }
//
// public SelectChoice(int selection) {
// super(selection);
// }
//
// public SelectChoice(boolean selected, String TAG) {
// super(selected, TAG);
// }
//
// public SelectChoice(boolean selected) {
// super(selected);
// }
//
// public SelectChoice(int[] selection) {
// super(selection);
// }
//
// public String[] getSimpleSource() {
// String[] stockArr = new String[resource.size()];
// stockArr = resource.toArray(stockArr);
// return stockArr;
// }
//
// public ArrayList<String> getSource() {
// return resource;
// }
//
// public String toString() {
// return "";
// }
//
//
// public SelectChoice clone() {
// if (isMultiSelection) {
// return new SelectChoice(getSelections());
// } else {
// return new SelectChoice(getSelection());
// }
//
// }
//
// public int getFromSubFilter(SelectChoice sub) {
// String selected_item = sub.selected_string();
// Iterator<String> k = resource.iterator();
// int u = 0;
// while (k.hasNext()) {
// String e = k.next();
// if (e.equalsIgnoreCase(selected_item)) {
// return u;
// }
// u++;
// }
//
// return 0;
// }
// }
//
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/Util.java
// public class Util {
// public static final String SELECTION = "selected";
// public static final String DATASTRING = "strings";
// public static final String LEVEL = "mlevel";
//
// public static SelectChoice fromBundle(Bundle fromData) {
// int[] selection = fromData.getIntArray(SimpleSingleList.SELECTION);
// String[] data = fromData.getStringArray(SimpleSingleList.DATASTRING);
// SelectChoice lv0;
// if (selection.length > 1) {
// lv0 = new SelectChoice(selection);
// } else {
// lv0 = new SelectChoice(selection[0]);
// }
// lv0.setResourceData(data);
// lv0.setLevel(0);
// return lv0;
// }
//
// public static Bundle stuffs(SelectChoice option) {
// Bundle b = new Bundle();
// int[] single_selection = new int[]{option.getSelection()};
// b.putIntArray(SELECTION, single_selection);
// b.putStringArray(DATASTRING, option.getSimpleSource());
// b.putInt(LEVEL, option.getLevel());
// return b;
// }
//
// public static Bundle stuffs(int selection, String[] list, int order) {
// Bundle b = new Bundle();
// int[] single_selection = new int[]{selection};
// b.putIntArray(SELECTION, single_selection);
// b.putStringArray(DATASTRING, list);
// b.putInt(LEVEL, order);
// return b;
// }
//
// public static Bundle stuffs(int[] selections, String[] list, int order) {
// Bundle b = new Bundle();
// b.putIntArray(SELECTION, selections);
// b.putStringArray(DATASTRING, list);
// b.putInt(LEVEL, order);
// return b;
// }
//
// }
| import android.app.FragmentManager;
import android.os.Bundle;
import com.hkm.slideselection.worker.SelectChoice;
import com.hkm.slideselection.worker.Util; | package com.hkm.slideselection.V1;
/**
* Created by hesk on 10/9/15.
*/
public class StringControlAdapter extends DynamicAdapter<SelectChoice> {
public StringControlAdapter(FragmentManager fragmentManager, SelectChoice configuration) {
super(fragmentManager, configuration);
}
public StringControlAdapter(FragmentManager fragmentManager, Bundle mfrombundle) {
super(fragmentManager);
firstPage = SimpleSingleList.newInstance(mfrombundle); | // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/SelectChoice.java
// public class SelectChoice extends LevelResources<String> {
// public enum ListType {
// MAINFILTER,
// FILTER_ITEM
// }
//
// private String choice_selection;
//
// public String selected_string() {
// return choice_selection;
// }
//
// @Override
// public void setSelectedAtPos(int selectedAtPos) {
// super.setSelectedAtPos(selectedAtPos);
// this.choice_selection = resource.get(selectedAtPos);
// }
//
// public SelectChoice(int selection) {
// super(selection);
// }
//
// public SelectChoice(boolean selected, String TAG) {
// super(selected, TAG);
// }
//
// public SelectChoice(boolean selected) {
// super(selected);
// }
//
// public SelectChoice(int[] selection) {
// super(selection);
// }
//
// public String[] getSimpleSource() {
// String[] stockArr = new String[resource.size()];
// stockArr = resource.toArray(stockArr);
// return stockArr;
// }
//
// public ArrayList<String> getSource() {
// return resource;
// }
//
// public String toString() {
// return "";
// }
//
//
// public SelectChoice clone() {
// if (isMultiSelection) {
// return new SelectChoice(getSelections());
// } else {
// return new SelectChoice(getSelection());
// }
//
// }
//
// public int getFromSubFilter(SelectChoice sub) {
// String selected_item = sub.selected_string();
// Iterator<String> k = resource.iterator();
// int u = 0;
// while (k.hasNext()) {
// String e = k.next();
// if (e.equalsIgnoreCase(selected_item)) {
// return u;
// }
// u++;
// }
//
// return 0;
// }
// }
//
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/Util.java
// public class Util {
// public static final String SELECTION = "selected";
// public static final String DATASTRING = "strings";
// public static final String LEVEL = "mlevel";
//
// public static SelectChoice fromBundle(Bundle fromData) {
// int[] selection = fromData.getIntArray(SimpleSingleList.SELECTION);
// String[] data = fromData.getStringArray(SimpleSingleList.DATASTRING);
// SelectChoice lv0;
// if (selection.length > 1) {
// lv0 = new SelectChoice(selection);
// } else {
// lv0 = new SelectChoice(selection[0]);
// }
// lv0.setResourceData(data);
// lv0.setLevel(0);
// return lv0;
// }
//
// public static Bundle stuffs(SelectChoice option) {
// Bundle b = new Bundle();
// int[] single_selection = new int[]{option.getSelection()};
// b.putIntArray(SELECTION, single_selection);
// b.putStringArray(DATASTRING, option.getSimpleSource());
// b.putInt(LEVEL, option.getLevel());
// return b;
// }
//
// public static Bundle stuffs(int selection, String[] list, int order) {
// Bundle b = new Bundle();
// int[] single_selection = new int[]{selection};
// b.putIntArray(SELECTION, single_selection);
// b.putStringArray(DATASTRING, list);
// b.putInt(LEVEL, order);
// return b;
// }
//
// public static Bundle stuffs(int[] selections, String[] list, int order) {
// Bundle b = new Bundle();
// b.putIntArray(SELECTION, selections);
// b.putStringArray(DATASTRING, list);
// b.putInt(LEVEL, order);
// return b;
// }
//
// }
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/V1/StringControlAdapter.java
import android.app.FragmentManager;
import android.os.Bundle;
import com.hkm.slideselection.worker.SelectChoice;
import com.hkm.slideselection.worker.Util;
package com.hkm.slideselection.V1;
/**
* Created by hesk on 10/9/15.
*/
public class StringControlAdapter extends DynamicAdapter<SelectChoice> {
public StringControlAdapter(FragmentManager fragmentManager, SelectChoice configuration) {
super(fragmentManager, configuration);
}
public StringControlAdapter(FragmentManager fragmentManager, Bundle mfrombundle) {
super(fragmentManager);
firstPage = SimpleSingleList.newInstance(mfrombundle); | firstPageListConfiguration = Util.fromBundle(mfrombundle); |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.hypebeast;
/**
* Created by hesk on 13/8/15.
*/
public interface feedhost {
/**
* only used on installation override
*
* @param pid post ID
* @param cb call back object
* @throws ApiException the exceptions
*/
@GET("/wp-json/posts/{pid}")
void the_post(
final @Path("pid") long pid, | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.hypebeast;
/**
* Created by hesk on 13/8/15.
*/
public interface feedhost {
/**
* only used on installation override
*
* @param pid post ID
* @param cb call back object
* @throws ApiException the exceptions
*/
@GET("/wp-json/posts/{pid}")
void the_post(
final @Path("pid") long pid, | final Callback<ResponsePostW> cb |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.hypebeast;
/**
* Created by hesk on 13/8/15.
*/
public interface feedhost {
/**
* only used on installation override
*
* @param pid post ID
* @param cb call back object
* @throws ApiException the exceptions
*/
@GET("/wp-json/posts/{pid}")
void the_post(
final @Path("pid") long pid,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/page/{page_no}")
void the_recent_page(
final @Path("page_no") int page_number,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/{cate_name}/page/{page_no}")
void cate_list(
final @Path("page_no") int pagepage_number_no,
final @Path("cate_name") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/tags/{tag_text}/page/{page_no}")
void tag_list(
final @Path("page_no") int pagepage_number_no,
final @Path("tag_text") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/search/page/{page_no}")
void search(
final @Query("s") String search_keyword,
final @Path("page_no") int page_number, | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.hypebeast;
/**
* Created by hesk on 13/8/15.
*/
public interface feedhost {
/**
* only used on installation override
*
* @param pid post ID
* @param cb call back object
* @throws ApiException the exceptions
*/
@GET("/wp-json/posts/{pid}")
void the_post(
final @Path("pid") long pid,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/page/{page_no}")
void the_recent_page(
final @Path("page_no") int page_number,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/{cate_name}/page/{page_no}")
void cate_list(
final @Path("page_no") int pagepage_number_no,
final @Path("cate_name") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/tags/{tag_text}/page/{page_no}")
void tag_list(
final @Path("page_no") int pagepage_number_no,
final @Path("tag_text") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/search/page/{page_no}")
void search(
final @Query("s") String search_keyword,
final @Path("page_no") int page_number, | final Callback<ResponsePostFromSearch> cb) throws ApiException; |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | ) throws ApiException;
@GET("/page/{page_no}")
void the_recent_page(
final @Path("page_no") int page_number,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/{cate_name}/page/{page_no}")
void cate_list(
final @Path("page_no") int pagepage_number_no,
final @Path("cate_name") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/tags/{tag_text}/page/{page_no}")
void tag_list(
final @Path("page_no") int pagepage_number_no,
final @Path("tag_text") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/search/page/{page_no}")
void search(
final @Query("s") String search_keyword,
final @Path("page_no") int page_number,
final Callback<ResponsePostFromSearch> cb) throws ApiException;
@GET("/api/mobile-app-config")
void mobile_config( | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/Foundation.java
// public class Foundation {
// @SerializedName("en")
// public configbank english;
// @SerializedName("cnt")
// public configbank chinese_traditional;
// @SerializedName("cns")
// public configbank chinese_simplified;
// @SerializedName("ja")
// public configbank japanese;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostFromSearch.java
// public class ResponsePostFromSearch {
// @SerializedName("posts")
// public PostsObject posts;
// @SerializedName("keyword")
// public String keyword_search;
// }
//
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hbeditorial/ResponsePostW.java
// public class ResponsePostW {
// @SerializedName("posts")
// public PostsObject post;
// public int page_limit = 0;
// private ArrayList<ArticleData> list;
//
// public ResponsePostW() {
// if (post != null) {
// page_limit = post.limit;
// list = post._embedded.getItems();
// }
// }
//
// public ArrayList<ArticleData> getListFeed() {
// return list;
// }
//
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hypebeast/feedhost.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hbeditorial.Foundation;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostFromSearch;
import com.hypebeast.sdk.api.model.hbeditorial.ResponsePostW;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
) throws ApiException;
@GET("/page/{page_no}")
void the_recent_page(
final @Path("page_no") int page_number,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/{cate_name}/page/{page_no}")
void cate_list(
final @Path("page_no") int pagepage_number_no,
final @Path("cate_name") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/tags/{tag_text}/page/{page_no}")
void tag_list(
final @Path("page_no") int pagepage_number_no,
final @Path("tag_text") String tag_keyword,
final Callback<ResponsePostW> cb
) throws ApiException;
@GET("/search/page/{page_no}")
void search(
final @Query("s") String search_keyword,
final @Path("page_no") int page_number,
final Callback<ResponsePostFromSearch> cb) throws ApiException;
@GET("/api/mobile-app-config")
void mobile_config( | final Callback<Foundation> cb |
jjhesk/slideSelectionList | SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/search/SearchBar.java | // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/StyleUtil.java
// public class StyleUtil {
//
// public static int resolveDimension(Context context, @AttrRes int attr, @DimenRes int fallbackRes) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getDimensionPixelSize(0,
// (int) context.getResources().getDimension(fallbackRes));
// } finally {
// a.recycle();
// }
// }
//
// @ColorInt
// public static int resolveColor(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getColor(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// public static int resolveInt(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getInt(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// public static String resolveString(Context context, @AttrRes int attr) {
// TypedValue v = new TypedValue();
// context.getTheme().resolveAttribute(attr, v, true);
// return (String) v.string;
// }
//
// public static int resolveResId(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getResourceId(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hkm.slideselection.R;
import com.hkm.slideselection.StyleUtil; | package com.hkm.slideselection.search;
/**
* Created by hesk on 8/10/15.
*/
public class SearchBar implements TextView.OnEditorActionListener, TextWatcher {
private RelativeLayout container;
private EditText mEditText;
private onEnterQuery enter;
private ImageButton searchButton;
private TextView mPlaceHolder;
private onEnterQuery mQuery;
private Context mContext;
private boolean enableSearch;
public SearchBar(View root, onEnterQuery query) {
this(root);
mContext = root.getContext(); | // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/StyleUtil.java
// public class StyleUtil {
//
// public static int resolveDimension(Context context, @AttrRes int attr, @DimenRes int fallbackRes) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getDimensionPixelSize(0,
// (int) context.getResources().getDimension(fallbackRes));
// } finally {
// a.recycle();
// }
// }
//
// @ColorInt
// public static int resolveColor(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getColor(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// public static int resolveInt(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getInt(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// public static String resolveString(Context context, @AttrRes int attr) {
// TypedValue v = new TypedValue();
// context.getTheme().resolveAttribute(attr, v, true);
// return (String) v.string;
// }
//
// public static int resolveResId(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
// try {
// return a.getResourceId(0, fallback);
// } finally {
// a.recycle();
// }
// }
//
// }
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/search/SearchBar.java
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hkm.slideselection.R;
import com.hkm.slideselection.StyleUtil;
package com.hkm.slideselection.search;
/**
* Created by hesk on 8/10/15.
*/
public class SearchBar implements TextView.OnEditorActionListener, TextWatcher {
private RelativeLayout container;
private EditText mEditText;
private onEnterQuery enter;
private ImageButton searchButton;
private TextView mPlaceHolder;
private onEnterQuery mQuery;
private Context mContext;
private boolean enableSearch;
public SearchBar(View root, onEnterQuery query) {
this(root);
mContext = root.getContext(); | String placeholder = StyleUtil.resolveString(mContext, R.attr.selectionsearchbar_placeholder); |
jjhesk/slideSelectionList | SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/V1/DynamicAdapter.java | // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/app/ViewPagerHolder.java
// public class ViewPagerHolder extends ViewPager {
// public ViewPagerHolder(Context context) {
// super(context);
// }
//
// public ViewPagerHolder(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public boolean onInterceptTouchEvent(MotionEvent event) {
// // Never allow swiping to switch between pages
// return false;
// }
//
// @Override
// public boolean onTouchEvent(MotionEvent event) {
// // Never allow swiping to switch between pages
// return false;
// }
//
// }
//
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/LevelResources.java
// public abstract class LevelResources<T extends Serializable> {
// public final boolean isMultiSelection;
// private int singleSelection = -1;
// private int[] multiSelection;
// private int level_list = 0;
// protected ArrayList<T> resource = new ArrayList<T>();
// private int selectedAtPos;
// private String tag;
//
// public static final String TAG = "base";
//
//
// public LevelResources() {
// isMultiSelection = false;
// }
//
// /**
// * creating a new level resource
// *
// * @param isMultiSelection multi support
// * @param Tag tag name
// */
// public LevelResources(boolean isMultiSelection, String Tag) {
// this.isMultiSelection = isMultiSelection;
// this.tag = Tag;
// if (isMultiSelection) {
// multiSelection = new int[]{-1};
// } else {
// singleSelection = -1;
// }
// }
//
// /**
// * creating a new level resource
// *
// * @param isMultiSelection multi support
// */
// public LevelResources(boolean isMultiSelection) {
// this.isMultiSelection = isMultiSelection;
// this.tag = TAG;
// if (isMultiSelection) {
// multiSelection = new int[]{-1};
// } else {
// singleSelection = -1;
// }
// }
//
// /**
// * loading the previous data
// *
// * @param selection with the selection
// */
// public LevelResources(int selection) {
// isMultiSelection = false;
// singleSelection = selection;
// }
//
// /**
// * loading the previous data
// *
// * @param selections with the selection
// */
// public LevelResources(int[] selections) {
// isMultiSelection = true;
// multiSelection = selections;
// }
//
// public boolean isTag(String name) {
// return tag == null ? false : name.equalsIgnoreCase(tag) || name.startsWith(tag);
// }
//
// public void setTag(String t) {
// tag = t;
// }
//
// public String getTag() {
// return tag;
// }
//
// /**
// * the level number
// *
// * @param g the number supposed to show the level
// */
// public void setLevel(int g) {
// this.level_list = g;
// }
//
// public int getLevel() {
// return level_list;
// }
//
// public void setResourceData(T[] h) {
// resource.clear();
// // final List<T> data = new ArrayList<>();
// for (int i = 0; i < h.length; i++) {
// resource.add(h[i]);
// }
// //resource.addAll(data);
// }
//
// public void setResourceData(List<T> data) {
// resource.clear();
// resource.addAll(data);
// }
//
// public boolean isMulti() {
// return isMultiSelection;
// }
//
// public int getSelection() {
// return singleSelection;
// }
//
// public int[] getSelections() {
// return multiSelection;
// }
//
// public abstract T[] getSimpleSource();
//
// public void setSelectedAtPos(int selectedAtPos) {
// if (!isMultiSelection) {
// this.selectedAtPos = selectedAtPos;
// } else {
//
// }
// }
// }
| import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Handler;
import android.os.Parcelable;
import android.support.v13.app.FragmentStatePagerAdapter;
import com.hkm.slideselection.app.ViewPagerHolder;
import com.hkm.slideselection.worker.LevelResources;
import java.util.ArrayList; | this.firstPage = firstPage;
firstPageListConfiguration = configuration;
}
public DynamicAdapter(FragmentManager fragmentManager, H configuration) {
this(fragmentManager);
firstPageListConfiguration = configuration;
}
protected void addConfiguration(H FConfiguration) {
levelObjects.add(FConfiguration);
notifyDataSetChanged();
}
protected void addConfiguration(H FConfiguration, int level) {
levelObjects.add(level - 1, FConfiguration);
notifyDataSetChanged();
}
protected void takeOutConfiguration() {
hh.postDelayed(new Runnable() {
@Override
public void run() {
levelObjects.remove(levelObjects.size() - 1);
notifyDataSetChanged();
}
}, 800);
}
| // Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/app/ViewPagerHolder.java
// public class ViewPagerHolder extends ViewPager {
// public ViewPagerHolder(Context context) {
// super(context);
// }
//
// public ViewPagerHolder(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public boolean onInterceptTouchEvent(MotionEvent event) {
// // Never allow swiping to switch between pages
// return false;
// }
//
// @Override
// public boolean onTouchEvent(MotionEvent event) {
// // Never allow swiping to switch between pages
// return false;
// }
//
// }
//
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/worker/LevelResources.java
// public abstract class LevelResources<T extends Serializable> {
// public final boolean isMultiSelection;
// private int singleSelection = -1;
// private int[] multiSelection;
// private int level_list = 0;
// protected ArrayList<T> resource = new ArrayList<T>();
// private int selectedAtPos;
// private String tag;
//
// public static final String TAG = "base";
//
//
// public LevelResources() {
// isMultiSelection = false;
// }
//
// /**
// * creating a new level resource
// *
// * @param isMultiSelection multi support
// * @param Tag tag name
// */
// public LevelResources(boolean isMultiSelection, String Tag) {
// this.isMultiSelection = isMultiSelection;
// this.tag = Tag;
// if (isMultiSelection) {
// multiSelection = new int[]{-1};
// } else {
// singleSelection = -1;
// }
// }
//
// /**
// * creating a new level resource
// *
// * @param isMultiSelection multi support
// */
// public LevelResources(boolean isMultiSelection) {
// this.isMultiSelection = isMultiSelection;
// this.tag = TAG;
// if (isMultiSelection) {
// multiSelection = new int[]{-1};
// } else {
// singleSelection = -1;
// }
// }
//
// /**
// * loading the previous data
// *
// * @param selection with the selection
// */
// public LevelResources(int selection) {
// isMultiSelection = false;
// singleSelection = selection;
// }
//
// /**
// * loading the previous data
// *
// * @param selections with the selection
// */
// public LevelResources(int[] selections) {
// isMultiSelection = true;
// multiSelection = selections;
// }
//
// public boolean isTag(String name) {
// return tag == null ? false : name.equalsIgnoreCase(tag) || name.startsWith(tag);
// }
//
// public void setTag(String t) {
// tag = t;
// }
//
// public String getTag() {
// return tag;
// }
//
// /**
// * the level number
// *
// * @param g the number supposed to show the level
// */
// public void setLevel(int g) {
// this.level_list = g;
// }
//
// public int getLevel() {
// return level_list;
// }
//
// public void setResourceData(T[] h) {
// resource.clear();
// // final List<T> data = new ArrayList<>();
// for (int i = 0; i < h.length; i++) {
// resource.add(h[i]);
// }
// //resource.addAll(data);
// }
//
// public void setResourceData(List<T> data) {
// resource.clear();
// resource.addAll(data);
// }
//
// public boolean isMulti() {
// return isMultiSelection;
// }
//
// public int getSelection() {
// return singleSelection;
// }
//
// public int[] getSelections() {
// return multiSelection;
// }
//
// public abstract T[] getSimpleSource();
//
// public void setSelectedAtPos(int selectedAtPos) {
// if (!isMultiSelection) {
// this.selectedAtPos = selectedAtPos;
// } else {
//
// }
// }
// }
// Path: SmartSelectionList/slideselection/src/main/java/com/hkm/slideselection/V1/DynamicAdapter.java
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Handler;
import android.os.Parcelable;
import android.support.v13.app.FragmentStatePagerAdapter;
import com.hkm.slideselection.app.ViewPagerHolder;
import com.hkm.slideselection.worker.LevelResources;
import java.util.ArrayList;
this.firstPage = firstPage;
firstPageListConfiguration = configuration;
}
public DynamicAdapter(FragmentManager fragmentManager, H configuration) {
this(fragmentManager);
firstPageListConfiguration = configuration;
}
protected void addConfiguration(H FConfiguration) {
levelObjects.add(FConfiguration);
notifyDataSetChanged();
}
protected void addConfiguration(H FConfiguration, int level) {
levelObjects.add(level - 1, FConfiguration);
notifyDataSetChanged();
}
protected void takeOutConfiguration() {
hh.postDelayed(new Runnable() {
@Override
public void run() {
levelObjects.remove(levelObjects.size() - 1);
notifyDataSetChanged();
}
}, 800);
}
| public void levelForward(ViewPagerHolder pager, H mH) { |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hbstore/Overhead.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/MobileConfig.java
// public class MobileConfig {
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypebeaststore.MobileConfig;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.hbstore;
/**
* Created by hesk on 10/9/15.
*/
public interface Overhead {
@GET("/wp-json/mobile-config") | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypebeaststore/MobileConfig.java
// public class MobileConfig {
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/hbstore/Overhead.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypebeaststore.MobileConfig;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.hbstore;
/**
* Created by hesk on 10/9/15.
*/
public interface Overhead {
@GET("/wp-json/mobile-config") | void mobile_config(final Callback<MobileConfig> cb) throws ApiException; |
jjhesk/slideSelectionList | SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/pb/pbPost.java | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypetrak/htpost.java
// public class htpost extends post {
// @SerializedName("hypetrak_specific")
// public hypetrakconfig hypetrak;
// }
| import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypetrak.htpost;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import com.hypebeast.sdk.api.model.popbees.pbpost;
import com.hypebeast.sdk.api.model.wprest.post;
import java.util.List;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query; | package com.hypebeast.sdk.api.resources.pb;
/**
* Created by hesk on 3/7/15.
*/
public interface pbPost {
@GET("/wp-json/posts")
void search(
final @Query("filter[s]") String search_keyword,
final @Query("page") int page,
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering,
final Callback<List<pbpost>> cb) throws ApiException;
@GET("/wp-json/posts")
void lateset(
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering,
final @Query("page") int page,
final Callback<List<pbpost>> cb
) throws ApiException;
@GET("/wp-json/posts")
void fromLink(
final @Query("filter[name]") String last_slug, | // Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/model/hypetrak/htpost.java
// public class htpost extends post {
// @SerializedName("hypetrak_specific")
// public hypetrakconfig hypetrak;
// }
// Path: SmartSelectionList/hbsdk/src/main/java/com/hypebeast/sdk/api/resources/pb/pbPost.java
import com.hypebeast.sdk.api.exception.ApiException;
import com.hypebeast.sdk.api.model.hypetrak.htpost;
import com.hypebeast.sdk.api.model.popbees.mobileconfig;
import com.hypebeast.sdk.api.model.popbees.pbpost;
import com.hypebeast.sdk.api.model.wprest.post;
import java.util.List;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
package com.hypebeast.sdk.api.resources.pb;
/**
* Created by hesk on 3/7/15.
*/
public interface pbPost {
@GET("/wp-json/posts")
void search(
final @Query("filter[s]") String search_keyword,
final @Query("page") int page,
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering,
final Callback<List<pbpost>> cb) throws ApiException;
@GET("/wp-json/posts")
void lateset(
final @Query("filter[posts_per_page]") int limit,
final @Query("filter[order]") String ordering,
final @Query("page") int page,
final Callback<List<pbpost>> cb
) throws ApiException;
@GET("/wp-json/posts")
void fromLink(
final @Query("filter[name]") String last_slug, | final Callback<List<htpost>> cb |
abdulla-alali/lecture_examples | Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
// public class MusicPlayerService extends Service {
//
// @SuppressWarnings("unused")
// private final String TAG = "MusicService";
//
// private static final int NOTIFICATION_ID = 1;
// private MediaPlayer mPlayer;
// private int mStartID;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Set up the Media Player
// mPlayer = MediaPlayer.create(this, R.raw.badnews);
//
// if (null != mPlayer) {
//
// mPlayer.setLooping(false);
//
// // Stop Service when music has finished playing
// mPlayer.setOnCompletionListener(new OnCompletionListener() {
//
// @Override
// public void onCompletion(MediaPlayer mp) {
//
// // stop Service if it was started with this ID
// // Otherwise let other start commands proceed
// stopSelf(mStartID);
//
// }
// });
// }
//
// // Create a notification area notification so the user
// // can get back to the MusicServiceClient
//
// final Intent notificationIntent = new Intent(getApplicationContext(),
// MusicPlayerClient.class);
// final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
// notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//
// final Notification notification = new Notification.Builder(
// getApplicationContext())
// .setSmallIcon(android.R.drawable.ic_media_play)
// .setOngoing(true).setContentTitle(getResources().getString(R.string.music_notif_title))
// .setContentText(getResources().getString(R.string.music_notif_text))
// .setContentIntent(pendingIntent).build();
//
// // Put this Service in a foreground state, so it won't
// // readily be killed by the system
// startForeground(NOTIFICATION_ID, notification);
//
// }
//
//
// @Override
// public int onStartCommand(Intent intent, int flags, int startid) {
//
// if (null != mPlayer) {
//
// // ID for this start command
// mStartID = startid;
//
// if (mPlayer.isPlaying()) {
//
// // Rewind to beginning of song
// mPlayer.seekTo(0);
//
// } else {
//
// // Start playing song
// mPlayer.start();
//
// }
//
// }
//
// // Don't automatically restart this Service if it is killed
// return START_NOT_STICKY;
// }
//
// @Override
// public void onDestroy() {
//
// if (null != mPlayer) {
//
// mPlayer.stop();
// mPlayer.release();
//
// }
// }
//
// // Can't bind to this Service
// @Override
// public IBinder onBind(Intent intent) {
//
// return null;
//
// }
//
// }
| import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.MusicPlayerService; | package qa.edu.qu.cse.cmps312.services;
public class MusicPlayerClient extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player_client);
}
public void buttonClicked(View view) {
final Intent musicServiceIntent = new Intent(getApplicationContext(), | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
// public class MusicPlayerService extends Service {
//
// @SuppressWarnings("unused")
// private final String TAG = "MusicService";
//
// private static final int NOTIFICATION_ID = 1;
// private MediaPlayer mPlayer;
// private int mStartID;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Set up the Media Player
// mPlayer = MediaPlayer.create(this, R.raw.badnews);
//
// if (null != mPlayer) {
//
// mPlayer.setLooping(false);
//
// // Stop Service when music has finished playing
// mPlayer.setOnCompletionListener(new OnCompletionListener() {
//
// @Override
// public void onCompletion(MediaPlayer mp) {
//
// // stop Service if it was started with this ID
// // Otherwise let other start commands proceed
// stopSelf(mStartID);
//
// }
// });
// }
//
// // Create a notification area notification so the user
// // can get back to the MusicServiceClient
//
// final Intent notificationIntent = new Intent(getApplicationContext(),
// MusicPlayerClient.class);
// final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
// notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//
// final Notification notification = new Notification.Builder(
// getApplicationContext())
// .setSmallIcon(android.R.drawable.ic_media_play)
// .setOngoing(true).setContentTitle(getResources().getString(R.string.music_notif_title))
// .setContentText(getResources().getString(R.string.music_notif_text))
// .setContentIntent(pendingIntent).build();
//
// // Put this Service in a foreground state, so it won't
// // readily be killed by the system
// startForeground(NOTIFICATION_ID, notification);
//
// }
//
//
// @Override
// public int onStartCommand(Intent intent, int flags, int startid) {
//
// if (null != mPlayer) {
//
// // ID for this start command
// mStartID = startid;
//
// if (mPlayer.isPlaying()) {
//
// // Rewind to beginning of song
// mPlayer.seekTo(0);
//
// } else {
//
// // Start playing song
// mPlayer.start();
//
// }
//
// }
//
// // Don't automatically restart this Service if it is killed
// return START_NOT_STICKY;
// }
//
// @Override
// public void onDestroy() {
//
// if (null != mPlayer) {
//
// mPlayer.stop();
// mPlayer.release();
//
// }
// }
//
// // Can't bind to this Service
// @Override
// public IBinder onBind(Intent intent) {
//
// return null;
//
// }
//
// }
// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.MusicPlayerService;
package qa.edu.qu.cse.cmps312.services;
public class MusicPlayerClient extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player_client);
}
public void buttonClicked(View view) {
final Intent musicServiceIntent = new Intent(getApplicationContext(), | MusicPlayerService.class); |
abdulla-alali/lecture_examples | Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingJSONActivity.java | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
| import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts; | package qa.edu.qu.cse.cmps312.networking;
public class NetworkingJSONActivity extends AppCompatActivity {
ListView mListView;
TextView mTextview;
ProgressBar mProgressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_json);
mListView = (ListView)findViewById(R.id.listView);
mProgressBar = (ProgressBar)findViewById(R.id.progressBar);
mTextview = (TextView)findViewById(R.id.textView1); | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
// Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingJSONActivity.java
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts;
package qa.edu.qu.cse.cmps312.networking;
public class NetworkingJSONActivity extends AppCompatActivity {
ListView mListView;
TextView mTextview;
ProgressBar mProgressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_json);
mListView = (ListView)findViewById(R.id.listView);
mProgressBar = (ProgressBar)findViewById(R.id.progressBar);
mTextview = (TextView)findViewById(R.id.textView1); | new HttpGetTask().execute(Consts.URL + Consts.USERNAME); |
abdulla-alali/lecture_examples | Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingURLActivity.java | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
| import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts; | package qa.edu.qu.cse.cmps312.networking;
public class NetworkingURLActivity extends AppCompatActivity {
private TextView mTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_url);
mTextView = (TextView) findViewById(R.id.textView1);
final Button loadButton = (Button) findViewById(R.id.button1);
loadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new HttpGetTask().execute();
}
});
}
private class HttpGetTask extends AsyncTask<Void, Void, String> {
private static final String TAG = "HttpGetTask";
@Override
protected String doInBackground(Void... params) {
String data = "";
HttpURLConnection httpUrlConnection = null;
try {
//This is using my username and password | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
// Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingURLActivity.java
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts;
package qa.edu.qu.cse.cmps312.networking;
public class NetworkingURLActivity extends AppCompatActivity {
private TextView mTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_url);
mTextView = (TextView) findViewById(R.id.textView1);
final Button loadButton = (Button) findViewById(R.id.button1);
loadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new HttpGetTask().execute();
}
});
}
private class HttpGetTask extends AsyncTask<Void, Void, String> {
private static final String TAG = "HttpGetTask";
@Override
protected String doInBackground(Void... params) {
String data = "";
HttpURLConnection httpUrlConnection = null;
try {
//This is using my username and password | httpUrlConnection = (HttpURLConnection) new URL(Consts.URL + Consts.USERNAME) |
abdulla-alali/lecture_examples | Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingSocketActivity.java | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts; | package qa.edu.qu.cse.cmps312.networking;
public class NetworkingSocketActivity extends AppCompatActivity {
TextView mTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_url);
mTextView = (TextView) findViewById(R.id.textView1);
final Button loadButton = (Button) findViewById(R.id.button1);
loadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new HttpGetTask().execute();
}
});
}
private class HttpGetTask extends AsyncTask<Void, Void, String> {
private static final String HOST = "api.geonames.org";
// Get your own user name at http://www.geonames.org/login
private static final String HTTP_GET_COMMAND = "GET /earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=" | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
// Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingSocketActivity.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts;
package qa.edu.qu.cse.cmps312.networking;
public class NetworkingSocketActivity extends AppCompatActivity {
TextView mTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_url);
mTextView = (TextView) findViewById(R.id.textView1);
final Button loadButton = (Button) findViewById(R.id.button1);
loadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new HttpGetTask().execute();
}
});
}
private class HttpGetTask extends AsyncTask<Void, Void, String> {
private static final String HOST = "api.geonames.org";
// Get your own user name at http://www.geonames.org/login
private static final String HTTP_GET_COMMAND = "GET /earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=" | + Consts.USERNAME |
abdulla-alali/lecture_examples | Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingXMLActivity.java | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
| import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts; | package qa.edu.qu.cse.cmps312.networking;
public class NetworkingXMLActivity extends AppCompatActivity {
ListView mListView;
TextView mTextview;
ProgressBar mProgressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_json);
mListView = (ListView) findViewById(R.id.listView);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mTextview = (TextView) findViewById(R.id.textView1); | // Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/Consts/Consts.java
// public class Consts {
// // Get your user name at http://www.geonames.org/login
// public static final String USERNAME = "insert_username";
// public static final String URL = "http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// public static final String URLXML = "http://api.geonames.org/earthquakes?north=44.1&south=-9.9&east=-22.4&west=55.2&username=";
// }
// Path: Networking/app/src/main/java/qa/edu/qu/cse/cmps312/networking/NetworkingXMLActivity.java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import qa.edu.qu.cse.cmps312.networking.Consts.Consts;
package qa.edu.qu.cse.cmps312.networking;
public class NetworkingXMLActivity extends AppCompatActivity {
ListView mListView;
TextView mTextview;
ProgressBar mProgressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_networking_json);
mListView = (ListView) findViewById(R.id.listView);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mTextview = (TextView) findViewById(R.id.textView1); | new HttpGetTask().execute(Consts.URLXML + Consts.USERNAME); |
abdulla-alali/lecture_examples | Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MainActivity.java | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/LocalLoggingService.java
// public class LocalLoggingService extends IntentService {
//
// public static String EXTRA_LOG = "qa.edu.qu.cse.cmps312.services.MESSAGE";
// private static final String TAG = "LoggingService";
//
// public LocalLoggingService() {
// super("LocalLoggingService");
// }
//
// @Override
// protected void onHandleIntent(Intent intent) {
//
// Log.i(TAG, intent.getStringExtra(EXTRA_LOG));
//
// }
//
// }
| import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.LocalLoggingService; | package qa.edu.qu.cse.cmps312.services;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonClicked(View view) {
switch (view.getId()) {
case R.id.local_logging_button:
// Create an Intent for starting the LoggingService
Intent startServiceIntent = new Intent(getApplicationContext(), | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/LocalLoggingService.java
// public class LocalLoggingService extends IntentService {
//
// public static String EXTRA_LOG = "qa.edu.qu.cse.cmps312.services.MESSAGE";
// private static final String TAG = "LoggingService";
//
// public LocalLoggingService() {
// super("LocalLoggingService");
// }
//
// @Override
// protected void onHandleIntent(Intent intent) {
//
// Log.i(TAG, intent.getStringExtra(EXTRA_LOG));
//
// }
//
// }
// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MainActivity.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.LocalLoggingService;
package qa.edu.qu.cse.cmps312.services;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonClicked(View view) {
switch (view.getId()) {
case R.id.local_logging_button:
// Create an Intent for starting the LoggingService
Intent startServiceIntent = new Intent(getApplicationContext(), | LocalLoggingService.class); |
abdulla-alali/lecture_examples | Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
// public class MusicPlayerClient extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_music_player_client);
// }
//
// public void buttonClicked(View view) {
// final Intent musicServiceIntent = new Intent(getApplicationContext(),
// MusicPlayerService.class);
// switch (view.getId()) {
// case R.id.play_button:
//
// // Start the MusicService using the Intent
// startService(musicServiceIntent);
//
// break;
// case R.id.stop_button:
//
// // Stop the MusicService using the Intent
// stopService(musicServiceIntent);
//
// break;
//
// }
// }
// }
| import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.IBinder;
import qa.edu.qu.cse.cmps312.services.MusicPlayerClient;
import qa.edu.qu.cse.cmps312.services.R; | package qa.edu.qu.cse.cmps312.services.services;
public class MusicPlayerService extends Service {
@SuppressWarnings("unused")
private final String TAG = "MusicService";
private static final int NOTIFICATION_ID = 1;
private MediaPlayer mPlayer;
private int mStartID;
@Override
public void onCreate() {
super.onCreate();
// Set up the Media Player
mPlayer = MediaPlayer.create(this, R.raw.badnews);
if (null != mPlayer) {
mPlayer.setLooping(false);
// Stop Service when music has finished playing
mPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// stop Service if it was started with this ID
// Otherwise let other start commands proceed
stopSelf(mStartID);
}
});
}
// Create a notification area notification so the user
// can get back to the MusicServiceClient
final Intent notificationIntent = new Intent(getApplicationContext(), | // Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
// public class MusicPlayerClient extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_music_player_client);
// }
//
// public void buttonClicked(View view) {
// final Intent musicServiceIntent = new Intent(getApplicationContext(),
// MusicPlayerService.class);
// switch (view.getId()) {
// case R.id.play_button:
//
// // Start the MusicService using the Intent
// startService(musicServiceIntent);
//
// break;
// case R.id.stop_button:
//
// // Stop the MusicService using the Intent
// stopService(musicServiceIntent);
//
// break;
//
// }
// }
// }
// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.IBinder;
import qa.edu.qu.cse.cmps312.services.MusicPlayerClient;
import qa.edu.qu.cse.cmps312.services.R;
package qa.edu.qu.cse.cmps312.services.services;
public class MusicPlayerService extends Service {
@SuppressWarnings("unused")
private final String TAG = "MusicService";
private static final int NOTIFICATION_ID = 1;
private MediaPlayer mPlayer;
private int mStartID;
@Override
public void onCreate() {
super.onCreate();
// Set up the Media Player
mPlayer = MediaPlayer.create(this, R.raw.badnews);
if (null != mPlayer) {
mPlayer.setLooping(false);
// Stop Service when music has finished playing
mPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// stop Service if it was started with this ID
// Otherwise let other start commands proceed
stopSelf(mStartID);
}
});
}
// Create a notification area notification so the user
// can get back to the MusicServiceClient
final Intent notificationIntent = new Intent(getApplicationContext(), | MusicPlayerClient.class); |
millecker/storm-apps | wordcount/src/at/illecker/storm/wordcount/spout/SampleTweetSpout.java | // Path: commons/src/at/illecker/storm/commons/tweet/Tweet.java
// public final class Tweet implements Serializable {
// private static final long serialVersionUID = 5246263296320608188L;
// private final Long m_id;
// private final String m_text;
// private final Double m_score;
//
// public Tweet(Long id, String text, Double score) {
// this.m_id = id;
// this.m_text = text;
// this.m_score = score;
// }
//
// public Tweet(Long id, String text) {
// this(id, text, null);
// }
//
// public Long getId() {
// return m_id;
// }
//
// public String getText() {
// return m_text;
// }
//
// public Double getScore() {
// return m_score;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Tweet other = (Tweet) obj;
// // check if id is matching
// if (this.m_id != other.getId()) {
// return false;
// }
// // check if text is matching
// if (!this.m_text.equals(other.getText())) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Tweet [id=" + m_id + ", text=" + m_text
// + ((m_score != null) ? ", score=" + m_score : "") + "]";
// }
//
// public static List<Tweet> getTestTweets() {
// List<Tweet> tweets = new ArrayList<Tweet>();
// tweets.add(new Tweet(1L,
// "Gas by my house hit $3.39 !!!! I'm goin to Chapel Hill on Sat . :)",
// 1.0));
// tweets
// .add(new Tweet(
// 2L,
// "@oluoch @victor_otti @kunjand I just watched it ! Sridevi's comeback .... U remember her from the 90s ?? Sun mornings on NTA ;)",
// 1.0));
// tweets
// .add(new Tweet(
// 3L,
// "PBR & @mokbpresents bring you Jim White at the @Do317 Lounge on October 23rd at 7 pm ! http://t.co/7x8OfC56.",
// 0.5));
// tweets
// .add(new Tweet(
// 4L,
// "Why is it so hard to find the @TVGuideMagazine these days ? Went to 3 stores for the Castle cover issue . NONE . Will search again tomorrow ...",
// 0.0));
// tweets.add(new Tweet(0L,
// "called in sick for the third straight day. ugh.", 0.0));
// tweets
// .add(new Tweet(
// 5L,
// "Here we go. BANK FAAAAIL FRIDAY -- The FDIC says the Bradford Bank in Baltimore, Maryland has become the 82nd bank failure of the year.",
// 0.0));
// tweets.add(new Tweet(0L,
// "Oh, I'm afraid your Windows-using friends will not survive.", 0.0));
//
// tweets
// .add(new Tweet(
// 6L,
// "Excuse the connectivity of this live stream , from Baba Amr , so many activists using only one Sat Modem . LIVE http://t.co/U283IhZ5 #Homs"));
// tweets
// .add(new Tweet(
// 7L,
// "Show your LOVE for your local field & it might win an award ! Gallagher Park #Bedlington current 4th in National Award http://t.co/WeiMDtQt"));
// tweets
// .add(new Tweet(
// 8L,
// "@firecore Can you tell me when an update for the Apple TV 3rd gen becomes available ? The missing update holds me back from buying #appletv3"));
// tweets
// .add(new Tweet(
// 9L,
// "My #cre blog Oklahoma Per Square Foot returns to the @JournalRecord blog hub tomorrow . I will have some interesting local data to share ."));
// tweets
// .add(new Tweet(
// 10L,
// "\" " @bbcburnsy : Loads from SB ; "talks with Chester continue ; no deals 4 out of contract players ' til Jan ; Dev t Roth , Coops to Chest'ld #hcafc \""));
//
// // thesis examples
// tweets
// .add(new Tweet(
// 11L,
// "@user1 @user2 OMG I just watched Michael's comeback ! U remember him from the 90s ?? yaaaa \uD83D\uDE09 #michaelcomeback"));
// tweets
// .add(new Tweet(12L,
// "@user1 @user2 OMG I just watched it again ! \uD83D\uDE09 #michaelcomeback"));
// tweets.add(new Tweet(13L,
// "@user3 I luv him too ! \uD83D\uDE09 #michaelcomeback"));
//
// return tweets;
// }
//
// }
| import java.util.List;
import java.util.Map;
import at.illecker.storm.commons.tweet.Tweet;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichSpout;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values; | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package at.illecker.storm.wordcount.spout;
public class SampleTweetSpout extends BaseRichSpout {
public static final String ID = "sample-tweet-spout";
private static final long serialVersionUID = 3621927972989123163L;
private SpoutOutputCollector m_collector; | // Path: commons/src/at/illecker/storm/commons/tweet/Tweet.java
// public final class Tweet implements Serializable {
// private static final long serialVersionUID = 5246263296320608188L;
// private final Long m_id;
// private final String m_text;
// private final Double m_score;
//
// public Tweet(Long id, String text, Double score) {
// this.m_id = id;
// this.m_text = text;
// this.m_score = score;
// }
//
// public Tweet(Long id, String text) {
// this(id, text, null);
// }
//
// public Long getId() {
// return m_id;
// }
//
// public String getText() {
// return m_text;
// }
//
// public Double getScore() {
// return m_score;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Tweet other = (Tweet) obj;
// // check if id is matching
// if (this.m_id != other.getId()) {
// return false;
// }
// // check if text is matching
// if (!this.m_text.equals(other.getText())) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Tweet [id=" + m_id + ", text=" + m_text
// + ((m_score != null) ? ", score=" + m_score : "") + "]";
// }
//
// public static List<Tweet> getTestTweets() {
// List<Tweet> tweets = new ArrayList<Tweet>();
// tweets.add(new Tweet(1L,
// "Gas by my house hit $3.39 !!!! I'm goin to Chapel Hill on Sat . :)",
// 1.0));
// tweets
// .add(new Tweet(
// 2L,
// "@oluoch @victor_otti @kunjand I just watched it ! Sridevi's comeback .... U remember her from the 90s ?? Sun mornings on NTA ;)",
// 1.0));
// tweets
// .add(new Tweet(
// 3L,
// "PBR & @mokbpresents bring you Jim White at the @Do317 Lounge on October 23rd at 7 pm ! http://t.co/7x8OfC56.",
// 0.5));
// tweets
// .add(new Tweet(
// 4L,
// "Why is it so hard to find the @TVGuideMagazine these days ? Went to 3 stores for the Castle cover issue . NONE . Will search again tomorrow ...",
// 0.0));
// tweets.add(new Tweet(0L,
// "called in sick for the third straight day. ugh.", 0.0));
// tweets
// .add(new Tweet(
// 5L,
// "Here we go. BANK FAAAAIL FRIDAY -- The FDIC says the Bradford Bank in Baltimore, Maryland has become the 82nd bank failure of the year.",
// 0.0));
// tweets.add(new Tweet(0L,
// "Oh, I'm afraid your Windows-using friends will not survive.", 0.0));
//
// tweets
// .add(new Tweet(
// 6L,
// "Excuse the connectivity of this live stream , from Baba Amr , so many activists using only one Sat Modem . LIVE http://t.co/U283IhZ5 #Homs"));
// tweets
// .add(new Tweet(
// 7L,
// "Show your LOVE for your local field & it might win an award ! Gallagher Park #Bedlington current 4th in National Award http://t.co/WeiMDtQt"));
// tweets
// .add(new Tweet(
// 8L,
// "@firecore Can you tell me when an update for the Apple TV 3rd gen becomes available ? The missing update holds me back from buying #appletv3"));
// tweets
// .add(new Tweet(
// 9L,
// "My #cre blog Oklahoma Per Square Foot returns to the @JournalRecord blog hub tomorrow . I will have some interesting local data to share ."));
// tweets
// .add(new Tweet(
// 10L,
// "\" " @bbcburnsy : Loads from SB ; "talks with Chester continue ; no deals 4 out of contract players ' til Jan ; Dev t Roth , Coops to Chest'ld #hcafc \""));
//
// // thesis examples
// tweets
// .add(new Tweet(
// 11L,
// "@user1 @user2 OMG I just watched Michael's comeback ! U remember him from the 90s ?? yaaaa \uD83D\uDE09 #michaelcomeback"));
// tweets
// .add(new Tweet(12L,
// "@user1 @user2 OMG I just watched it again ! \uD83D\uDE09 #michaelcomeback"));
// tweets.add(new Tweet(13L,
// "@user3 I luv him too ! \uD83D\uDE09 #michaelcomeback"));
//
// return tweets;
// }
//
// }
// Path: wordcount/src/at/illecker/storm/wordcount/spout/SampleTweetSpout.java
import java.util.List;
import java.util.Map;
import at.illecker.storm.commons.tweet.Tweet;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichSpout;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package at.illecker.storm.wordcount.spout;
public class SampleTweetSpout extends BaseRichSpout {
public static final String ID = "sample-tweet-spout";
private static final long serialVersionUID = 3621927972989123163L;
private SpoutOutputCollector m_collector; | private List<Tweet> m_tweets = Tweet.getTestTweets(); |
millecker/storm-apps | commons/src/at/illecker/storm/commons/spout/TwitterStreamSpout.java | // Path: commons/src/at/illecker/storm/commons/util/TimeUtils.java
// public class TimeUtils {
//
// public static void sleepMillis(long millis) {
// try {
// Time.sleep(millis);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
//
// // 1 ms = 1 000 000 ns
// public static void sleepNanos(long nanos) {
// long start = System.nanoTime();
// long end = 0;
// do {
// end = System.nanoTime();
// } while (start + nanos >= end);
// // System.out.println("waited time: " + (end - start) + " ns");
// }
// }
| import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import twitter4j.FilterQuery;
import twitter4j.StallWarning;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
import twitter4j.auth.AccessToken;
import twitter4j.conf.ConfigurationBuilder;
import at.illecker.storm.commons.util.TimeUtils;
import backtype.storm.Config;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichSpout;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values; | private String[] m_keyWords;
private String m_filterLanguage;
public TwitterStreamSpout(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret, String[] keyWords,
String filterLanguage) {
this.m_consumerKey = consumerKey;
this.m_consumerSecret = consumerSecret;
this.m_accessToken = accessToken;
this.m_accessTokenSecret = accessTokenSecret;
this.m_keyWords = keyWords;
this.m_filterLanguage = filterLanguage; // "en"
}
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
// key of output tuples
declarer.declare(new Fields("id", "text", "score"));
}
@Override
public void open(Map config, TopologyContext context,
SpoutOutputCollector collector) {
m_collector = collector;
m_tweetsQueue = new LinkedBlockingQueue<Status>(1000);
// Optional startup sleep to finish bolt preparation
// before spout starts emitting
if (config.get(CONF_STARTUP_SLEEP_MS) != null) {
long startupSleepMillis = (Long) config.get(CONF_STARTUP_SLEEP_MS); | // Path: commons/src/at/illecker/storm/commons/util/TimeUtils.java
// public class TimeUtils {
//
// public static void sleepMillis(long millis) {
// try {
// Time.sleep(millis);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
//
// // 1 ms = 1 000 000 ns
// public static void sleepNanos(long nanos) {
// long start = System.nanoTime();
// long end = 0;
// do {
// end = System.nanoTime();
// } while (start + nanos >= end);
// // System.out.println("waited time: " + (end - start) + " ns");
// }
// }
// Path: commons/src/at/illecker/storm/commons/spout/TwitterStreamSpout.java
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import twitter4j.FilterQuery;
import twitter4j.StallWarning;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
import twitter4j.auth.AccessToken;
import twitter4j.conf.ConfigurationBuilder;
import at.illecker.storm.commons.util.TimeUtils;
import backtype.storm.Config;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichSpout;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
private String[] m_keyWords;
private String m_filterLanguage;
public TwitterStreamSpout(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret, String[] keyWords,
String filterLanguage) {
this.m_consumerKey = consumerKey;
this.m_consumerSecret = consumerSecret;
this.m_accessToken = accessToken;
this.m_accessTokenSecret = accessTokenSecret;
this.m_keyWords = keyWords;
this.m_filterLanguage = filterLanguage; // "en"
}
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
// key of output tuples
declarer.declare(new Fields("id", "text", "score"));
}
@Override
public void open(Map config, TopologyContext context,
SpoutOutputCollector collector) {
m_collector = collector;
m_tweetsQueue = new LinkedBlockingQueue<Status>(1000);
// Optional startup sleep to finish bolt preparation
// before spout starts emitting
if (config.get(CONF_STARTUP_SLEEP_MS) != null) {
long startupSleepMillis = (Long) config.get(CONF_STARTUP_SLEEP_MS); | TimeUtils.sleepMillis(startupSleepMillis); |
knowledgecode/WebSocket-for-Android | src/android/org/eclipse/jetty/io/nio/SelectorManager.java | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
| import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task; | //
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.io.nio;
/* ------------------------------------------------------------ */
/**
* The Selector Manager manages and number of SelectSets to allow
* NIO scheduling to scale to large numbers of connections.
* <p>
*/
public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable
{ | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
// Path: src/android/org/eclipse/jetty/io/nio/SelectorManager.java
import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task;
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.io.nio;
/* ------------------------------------------------------------ */
/**
* The Selector Manager manages and number of SelectSets to allow
* NIO scheduling to scale to large numbers of connections.
* <p>
*/
public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable
{ | public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); |
knowledgecode/WebSocket-for-Android | src/android/org/eclipse/jetty/io/nio/SelectorManager.java | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
| import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task; | /* ------------------------------------------------------------------------------- */
@Override
protected void doStop() throws Exception
{
SelectSet[] sets= _selectSet;
_selectSet=null;
if (sets!=null)
{
for (SelectSet set : sets)
{
if (set!=null)
set.stop();
}
}
super.doStop();
}
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointClosed(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointOpened(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */ | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
// Path: src/android/org/eclipse/jetty/io/nio/SelectorManager.java
import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task;
/* ------------------------------------------------------------------------------- */
@Override
protected void doStop() throws Exception
{
SelectSet[] sets= _selectSet;
_selectSet=null;
if (sets!=null)
{
for (SelectSet set : sets)
{
if (set!=null)
set.stop();
}
}
super.doStop();
}
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointClosed(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointOpened(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */ | protected abstract void endPointUpgraded(ConnectedEndPoint endpoint,Connection oldConnection); |
knowledgecode/WebSocket-for-Android | src/android/org/eclipse/jetty/io/nio/SelectorManager.java | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
| import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task; | /* ------------------------------------------------------------------------------- */
@Override
protected void doStop() throws Exception
{
SelectSet[] sets= _selectSet;
_selectSet=null;
if (sets!=null)
{
for (SelectSet set : sets)
{
if (set!=null)
set.stop();
}
}
super.doStop();
}
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointClosed(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointOpened(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */ | // Path: src/android/org/eclipse/jetty/io/ConnectedEndPoint.java
// public interface ConnectedEndPoint extends EndPoint
// {
// Connection getConnection();
// void setConnection(Connection connection);
// }
//
// Path: src/android/org/eclipse/jetty/io/Connection.java
// public interface Connection
// {
// /* ------------------------------------------------------------ */
// /**
// * Handle the connection.
// * @return The Connection to use for the next handling of the connection.
// * This allows protocol upgrades and support for CONNECT.
// * @throws IOException if the handling of I/O operations fail
// */
// Connection handle() throws IOException;
//
// /**
// * <p>The semantic of this method is to return true to indicate interest in further reads,
// * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p>
// *
// * @return true to indicate interest in further reads, false otherwise
// */
// // TODO: rename to isReadInterested() in the next release
// boolean isSuspended();
//
// /**
// * Called after the connection is closed
// */
// void onClose();
//
// /**
// * Called when the connection idle timeout expires
// * @param idleForMs how long the connection has been idle
// * @see #isIdle()
// */
// void onIdleExpired(long idleForMs);
// }
//
// Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
// Path: src/android/org/eclipse/jetty/io/nio/SelectorManager.java
import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channel;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Timeout;
import org.eclipse.jetty.util.thread.Timeout.Task;
/* ------------------------------------------------------------------------------- */
@Override
protected void doStop() throws Exception
{
SelectSet[] sets= _selectSet;
_selectSet=null;
if (sets!=null)
{
for (SelectSet set : sets)
{
if (set!=null)
set.stop();
}
}
super.doStop();
}
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointClosed(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */
/**
* @param endpoint
*/
protected abstract void endPointOpened(SelectChannelEndPoint endpoint);
/* ------------------------------------------------------------ */ | protected abstract void endPointUpgraded(ConnectedEndPoint endpoint,Connection oldConnection); |
knowledgecode/WebSocket-for-Android | src/android/com/knowledgecode/cordova/websocket/DestroyTask.java | // Path: src/android/org/eclipse/jetty/websocket/WebSocket.java
// public interface Connection
// {
// String getProtocol();
// String getExtensions();
// void sendMessage(String data) throws IOException;
// void sendMessage(byte[] data, int offset, int length) throws IOException;
//
// /**
// * Close the connection with normal close code.
// */
// void close();
//
// /**
// * Close the connection with normal close code.
// * @param silent Whether telling the app this thing or not
// */
// void close(boolean silent);
//
// /** Close the connection with specific closeCode and message.
// * @param closeCode The close code to send, or -1 for no close code
// * @param message The message to send or null for no message
// */
// void close(int closeCode,String message);
//
// boolean isOpen();
//
// /**
// * @param ms The time in ms that the connection can be idle before closing
// */
// void setMaxIdleTime(int ms);
//
// /**
// * @param size size<0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// void setMaxTextMessageSize(int size);
//
// /**
// * @param size size<0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// void setMaxBinaryMessageSize(int size);
//
// /**
// * @return The time in ms that the connection can be idle before closing
// */
// int getMaxIdleTime();
//
// /**
// * Size in characters of the maximum text message to be received
// * @return size <0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// int getMaxTextMessageSize();
//
// /**
// * Size in bytes of the maximum binary message to be received
// * @return size <0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// int getMaxBinaryMessageSize();
// }
| import org.apache.cordova.CallbackContext;
import org.eclipse.jetty.websocket.WebSocket.Connection;
import org.eclipse.jetty.websocket.WebSocketClientFactory;
import com.knowledgecode.cordova.websocket.TaskRunner.Task;
import android.util.SparseArray; | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.knowledgecode.cordova.websocket;
/**
* Stop WebSocket client.
*/
class DestroyTask implements Task {
private final WebSocketClientFactory _factory; | // Path: src/android/org/eclipse/jetty/websocket/WebSocket.java
// public interface Connection
// {
// String getProtocol();
// String getExtensions();
// void sendMessage(String data) throws IOException;
// void sendMessage(byte[] data, int offset, int length) throws IOException;
//
// /**
// * Close the connection with normal close code.
// */
// void close();
//
// /**
// * Close the connection with normal close code.
// * @param silent Whether telling the app this thing or not
// */
// void close(boolean silent);
//
// /** Close the connection with specific closeCode and message.
// * @param closeCode The close code to send, or -1 for no close code
// * @param message The message to send or null for no message
// */
// void close(int closeCode,String message);
//
// boolean isOpen();
//
// /**
// * @param ms The time in ms that the connection can be idle before closing
// */
// void setMaxIdleTime(int ms);
//
// /**
// * @param size size<0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// void setMaxTextMessageSize(int size);
//
// /**
// * @param size size<0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// void setMaxBinaryMessageSize(int size);
//
// /**
// * @return The time in ms that the connection can be idle before closing
// */
// int getMaxIdleTime();
//
// /**
// * Size in characters of the maximum text message to be received
// * @return size <0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// int getMaxTextMessageSize();
//
// /**
// * Size in bytes of the maximum binary message to be received
// * @return size <0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// int getMaxBinaryMessageSize();
// }
// Path: src/android/com/knowledgecode/cordova/websocket/DestroyTask.java
import org.apache.cordova.CallbackContext;
import org.eclipse.jetty.websocket.WebSocket.Connection;
import org.eclipse.jetty.websocket.WebSocketClientFactory;
import com.knowledgecode.cordova.websocket.TaskRunner.Task;
import android.util.SparseArray;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.knowledgecode.cordova.websocket;
/**
* Stop WebSocket client.
*/
class DestroyTask implements Task {
private final WebSocketClientFactory _factory; | private final SparseArray<Connection> _map; |
knowledgecode/WebSocket-for-Android | src/android/com/knowledgecode/cordova/websocket/WebSocket.java | // Path: src/android/org/eclipse/jetty/websocket/WebSocket.java
// public interface Connection
// {
// String getProtocol();
// String getExtensions();
// void sendMessage(String data) throws IOException;
// void sendMessage(byte[] data, int offset, int length) throws IOException;
//
// /**
// * Close the connection with normal close code.
// */
// void close();
//
// /**
// * Close the connection with normal close code.
// * @param silent Whether telling the app this thing or not
// */
// void close(boolean silent);
//
// /** Close the connection with specific closeCode and message.
// * @param closeCode The close code to send, or -1 for no close code
// * @param message The message to send or null for no message
// */
// void close(int closeCode,String message);
//
// boolean isOpen();
//
// /**
// * @param ms The time in ms that the connection can be idle before closing
// */
// void setMaxIdleTime(int ms);
//
// /**
// * @param size size<0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// void setMaxTextMessageSize(int size);
//
// /**
// * @param size size<0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// void setMaxBinaryMessageSize(int size);
//
// /**
// * @return The time in ms that the connection can be idle before closing
// */
// int getMaxIdleTime();
//
// /**
// * Size in characters of the maximum text message to be received
// * @return size <0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// int getMaxTextMessageSize();
//
// /**
// * Size in bytes of the maximum binary message to be received
// * @return size <0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// int getMaxBinaryMessageSize();
// }
| import android.util.SparseArray;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.cordova.CordovaPreferences;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.websocket.WebSocket.Connection;
import org.eclipse.jetty.websocket.WebSocketClientFactory; | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.knowledgecode.cordova.websocket;
/**
* Cordova WebSocket Plugin for Android
* This plugin is using Jetty under the terms of the Apache License v2.0.
*
* @author KNOWLEDGECODE <[email protected]>
* @version 0.12.2
*/
public class WebSocket extends CordovaPlugin {
static final String CREATE_TASK = "create";
static final String SEND_TASK = "send";
static final String CLOSE_TASK = "close";
static final String RESET_TASK = "reset";
static final String DESTROY_TASK = "destroy";
private WebSocketClientFactory _factory; | // Path: src/android/org/eclipse/jetty/websocket/WebSocket.java
// public interface Connection
// {
// String getProtocol();
// String getExtensions();
// void sendMessage(String data) throws IOException;
// void sendMessage(byte[] data, int offset, int length) throws IOException;
//
// /**
// * Close the connection with normal close code.
// */
// void close();
//
// /**
// * Close the connection with normal close code.
// * @param silent Whether telling the app this thing or not
// */
// void close(boolean silent);
//
// /** Close the connection with specific closeCode and message.
// * @param closeCode The close code to send, or -1 for no close code
// * @param message The message to send or null for no message
// */
// void close(int closeCode,String message);
//
// boolean isOpen();
//
// /**
// * @param ms The time in ms that the connection can be idle before closing
// */
// void setMaxIdleTime(int ms);
//
// /**
// * @param size size<0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// void setMaxTextMessageSize(int size);
//
// /**
// * @param size size<0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// void setMaxBinaryMessageSize(int size);
//
// /**
// * @return The time in ms that the connection can be idle before closing
// */
// int getMaxIdleTime();
//
// /**
// * Size in characters of the maximum text message to be received
// * @return size <0 No aggregation of frames to messages, >=0 max size of text frame aggregation buffer in characters
// */
// int getMaxTextMessageSize();
//
// /**
// * Size in bytes of the maximum binary message to be received
// * @return size <0 no aggregation of binary frames, >=0 size of binary frame aggregation buffer
// */
// int getMaxBinaryMessageSize();
// }
// Path: src/android/com/knowledgecode/cordova/websocket/WebSocket.java
import android.util.SparseArray;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.cordova.CordovaPreferences;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.websocket.WebSocket.Connection;
import org.eclipse.jetty.websocket.WebSocketClientFactory;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.knowledgecode.cordova.websocket;
/**
* Cordova WebSocket Plugin for Android
* This plugin is using Jetty under the terms of the Apache License v2.0.
*
* @author KNOWLEDGECODE <[email protected]>
* @version 0.12.2
*/
public class WebSocket extends CordovaPlugin {
static final String CREATE_TASK = "create";
static final String SEND_TASK = "send";
static final String CLOSE_TASK = "close";
static final String RESET_TASK = "reset";
static final String DESTROY_TASK = "destroy";
private WebSocketClientFactory _factory; | private SparseArray<Connection> _conn; |
knowledgecode/WebSocket-for-Android | src/android/org/eclipse/jetty/util/resource/URLResource.java | // Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; | //
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util.resource;
/* ------------------------------------------------------------ */
/** Abstract resource class.
*/
public class URLResource extends Resource
{ | // Path: src/android/org/eclipse/jetty/util/log/Logger.java
// public interface Logger
// {
// /**
// * @return the name of this logger
// */
// public String getName();
//
// /**
// * Formats and logs at warn level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void warn(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at warn level
// * @param thrown the Throwable to log
// */
// public void warn(Throwable thrown);
//
// /**
// * Logs the given message at warn level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void warn(String msg, Throwable thrown);
//
// /**
// * Formats and logs at info level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void info(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at info level
// * @param thrown the Throwable to log
// */
// public void info(Throwable thrown);
//
// /**
// * Logs the given message at info level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void info(String msg, Throwable thrown);
//
// /**
// * @return whether the debug level is enabled
// */
// public boolean isDebugEnabled();
//
// /**
// * Mutator used to turn debug on programmatically.
// * @param enabled whether to enable the debug level
// */
// public void setDebugEnabled(boolean enabled);
//
// /**
// * Formats and logs at debug level.
// * @param msg the formatting string
// * @param args the optional arguments
// */
// public void debug(String msg, Object... args);
//
// /**
// * Logs the given Throwable information at debug level
// * @param thrown the Throwable to log
// */
// public void debug(Throwable thrown);
//
// /**
// * Logs the given message at debug level, with Throwable information.
// * @param msg the message to log
// * @param thrown the Throwable to log
// */
// public void debug(String msg, Throwable thrown);
//
// /**
// * @param name the name of the logger
// * @return a logger with the given name
// */
// public Logger getLogger(String name);
//
// /**
// * Ignore an exception.
// * <p>This should be used rather than an empty catch block.
// */
// public void ignore(Throwable ignored);
// }
// Path: src/android/org/eclipse/jetty/util/resource/URLResource.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util.resource;
/* ------------------------------------------------------------ */
/** Abstract resource class.
*/
public class URLResource extends Resource
{ | private static final Logger LOG = Log.getLogger(URLResource.class); |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/ArrayProto.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
//
// Path: src/org/jf/dexlib2/util/TypeUtils.java
// public final class TypeUtils {
// public static boolean isWideType(@Nonnull String type) {
// char c = type.charAt(0);
// return c == 'J' || c == 'D';
// }
//
// public static boolean isWideType(@Nonnull TypeReference type) {
// return isWideType(type.getType());
// }
//
// public static boolean isPrimitiveType(String type) {
// return type.length() == 1;
// }
//
// @Nonnull
// public static String getPackage(@Nonnull String type) {
// int lastSlash = type.lastIndexOf('/');
// if (lastSlash < 0) {
// return "";
// }
// return type.substring(1, lastSlash);
// }
//
// public static boolean canAccessClass(@Nonnull String accessorType, @Nonnull ClassDef accesseeClassDef) {
// if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) {
// return true;
// }
//
// // Classes can only be public or package private. Any private or protected inner classes are actually
// // package private.
// return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorType));
// }
//
// private TypeUtils() {}
// }
| import com.google.common.base.Strings;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
import org.jf.dexlib2.util.TypeUtils;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | @Override public boolean isInterface() { return false; }
/**
* @return The base element type of this array. E.g. This would return Ljava/lang/String; for [[Ljava/lang/String;
*/
@Nonnull public String getElementType() { return elementType; }
/**
* @return The immediate element type of this array. E.g. This would return [Ljava/lang/String; for
* [[Ljava/lang/String;
*/
@Nonnull public String getImmediateElementType() {
if (dimensions > 1) {
return makeArrayType(elementType, dimensions-1);
}
return elementType;
}
@Override public boolean implementsInterface(@Nonnull String iface) {
return iface.equals("Ljava/lang/Cloneable;") || iface.equals("Ljava/io/Serializable;");
}
@Nullable @Override
public String getSuperclass() {
return "Ljava/lang/Object;";
}
@Nonnull @Override
public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
if (other instanceof ArrayProto) { | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
//
// Path: src/org/jf/dexlib2/util/TypeUtils.java
// public final class TypeUtils {
// public static boolean isWideType(@Nonnull String type) {
// char c = type.charAt(0);
// return c == 'J' || c == 'D';
// }
//
// public static boolean isWideType(@Nonnull TypeReference type) {
// return isWideType(type.getType());
// }
//
// public static boolean isPrimitiveType(String type) {
// return type.length() == 1;
// }
//
// @Nonnull
// public static String getPackage(@Nonnull String type) {
// int lastSlash = type.lastIndexOf('/');
// if (lastSlash < 0) {
// return "";
// }
// return type.substring(1, lastSlash);
// }
//
// public static boolean canAccessClass(@Nonnull String accessorType, @Nonnull ClassDef accesseeClassDef) {
// if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) {
// return true;
// }
//
// // Classes can only be public or package private. Any private or protected inner classes are actually
// // package private.
// return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorType));
// }
//
// private TypeUtils() {}
// }
// Path: src/org/jf/dexlib2/analysis/ArrayProto.java
import com.google.common.base.Strings;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
import org.jf.dexlib2.util.TypeUtils;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Override public boolean isInterface() { return false; }
/**
* @return The base element type of this array. E.g. This would return Ljava/lang/String; for [[Ljava/lang/String;
*/
@Nonnull public String getElementType() { return elementType; }
/**
* @return The immediate element type of this array. E.g. This would return [Ljava/lang/String; for
* [[Ljava/lang/String;
*/
@Nonnull public String getImmediateElementType() {
if (dimensions > 1) {
return makeArrayType(elementType, dimensions-1);
}
return elementType;
}
@Override public boolean implementsInterface(@Nonnull String iface) {
return iface.equals("Ljava/lang/Cloneable;") || iface.equals("Ljava/io/Serializable;");
}
@Nullable @Override
public String getSuperclass() {
return "Ljava/lang/Object;";
}
@Nonnull @Override
public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
if (other instanceof ArrayProto) { | if (TypeUtils.isPrimitiveType(getElementType()) || |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/ArrayProto.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
//
// Path: src/org/jf/dexlib2/util/TypeUtils.java
// public final class TypeUtils {
// public static boolean isWideType(@Nonnull String type) {
// char c = type.charAt(0);
// return c == 'J' || c == 'D';
// }
//
// public static boolean isWideType(@Nonnull TypeReference type) {
// return isWideType(type.getType());
// }
//
// public static boolean isPrimitiveType(String type) {
// return type.length() == 1;
// }
//
// @Nonnull
// public static String getPackage(@Nonnull String type) {
// int lastSlash = type.lastIndexOf('/');
// if (lastSlash < 0) {
// return "";
// }
// return type.substring(1, lastSlash);
// }
//
// public static boolean canAccessClass(@Nonnull String accessorType, @Nonnull ClassDef accesseeClassDef) {
// if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) {
// return true;
// }
//
// // Classes can only be public or package private. Any private or protected inner classes are actually
// // package private.
// return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorType));
// }
//
// private TypeUtils() {}
// }
| import com.google.common.base.Strings;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
import org.jf.dexlib2.util.TypeUtils;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | }
} catch (UnresolvedClassException ex) {
// ignore
}
return classPath.getClass("Ljava/lang/Object;");
}
// otherwise, defer to the other class' getCommonSuperclass
return other.getCommonSuperclass(this);
}
private static final String BRACKETS = Strings.repeat("[", 256);
@Nonnull
private static String makeArrayType(@Nonnull String elementType, int dimensions) {
return BRACKETS.substring(0, dimensions) + elementType;
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
if (fieldOffset==8) {
return new ImmutableFieldReference(getType(), "length", "int");
}
return null;
}
@Override
@Nullable | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
//
// Path: src/org/jf/dexlib2/util/TypeUtils.java
// public final class TypeUtils {
// public static boolean isWideType(@Nonnull String type) {
// char c = type.charAt(0);
// return c == 'J' || c == 'D';
// }
//
// public static boolean isWideType(@Nonnull TypeReference type) {
// return isWideType(type.getType());
// }
//
// public static boolean isPrimitiveType(String type) {
// return type.length() == 1;
// }
//
// @Nonnull
// public static String getPackage(@Nonnull String type) {
// int lastSlash = type.lastIndexOf('/');
// if (lastSlash < 0) {
// return "";
// }
// return type.substring(1, lastSlash);
// }
//
// public static boolean canAccessClass(@Nonnull String accessorType, @Nonnull ClassDef accesseeClassDef) {
// if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) {
// return true;
// }
//
// // Classes can only be public or package private. Any private or protected inner classes are actually
// // package private.
// return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorType));
// }
//
// private TypeUtils() {}
// }
// Path: src/org/jf/dexlib2/analysis/ArrayProto.java
import com.google.common.base.Strings;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
import org.jf.dexlib2.util.TypeUtils;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
}
} catch (UnresolvedClassException ex) {
// ignore
}
return classPath.getClass("Ljava/lang/Object;");
}
// otherwise, defer to the other class' getCommonSuperclass
return other.getCommonSuperclass(this);
}
private static final String BRACKETS = Strings.repeat("[", 256);
@Nonnull
private static String makeArrayType(@Nonnull String elementType, int dimensions) {
return BRACKETS.substring(0, dimensions) + elementType;
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
if (fieldOffset==8) {
return new ImmutableFieldReference(getType(), "length", "int");
}
return null;
}
@Override
@Nullable | public Method getMethodByVtableIndex(int vtableIndex) { |
CvvT/DexTamper | src/com/cc/dextamper/option/Packer.java | // Path: src/com/cc/dextamper/context/MethodConfig.java
// public class MethodConfig {
// private static HashMap<MethodConfig, List<Params>> collection = new HashMap<>();
// private String className;
// private String methodName;
// private String description;
//
// public MethodConfig(){}
//
// public MethodConfig(MethodReference ref, List<Object> params){
// className = ref.getDefiningClass();
// methodName = ref.getName();
// List<? extends CharSequence> types = ref.getParameterTypes();
// StringBuilder sBuilder = new StringBuilder(types.size()+3);
// sBuilder.append("(");
// for (CharSequence type: types){
// sBuilder.append(type);
// }
// sBuilder.append(")");
// sBuilder.append(ref.getReturnType());
// description = sBuilder.toString();
// if (collection.containsKey(this)) {
// List<Params> list = collection.get(this);
// list.add(new Params(params));
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((description == null) ? 0 : description.hashCode());
// result = prime * result + ((methodName == null) ? 0 : methodName.hashCode());
// result = prime * result + ((className == null) ? 0 : className.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// MethodConfig other = (MethodConfig) obj;
// if (description == null) {
// if (other.description != null)
// return false;
// } else if (!description.equals(other.description))
// return false;
// if (methodName == null) {
// if (other.methodName != null)
// return false;
// } else if (!methodName.equals(other.methodName))
// return false;
// if (className == null) {
// if (other.className != null)
// return false;
// } else if (!className.equals(other.className))
// return false;
// return true;
// }
//
// public static void printInfo(){
// for (Entry<MethodConfig, List<Params>> entry: collection.entrySet()){
// MethodConfig config = entry.getKey();
// List<Params> list = entry.getValue();
// if (list.size() == 0)
// continue;
// System.out.println(config.className + "->" + config.methodName + config.description);
// System.out.println(list.size() + " " + list.get(0).size());
// for (Params param: list){
// for (Object object: param.params)
// System.out.println(object);
// }
// }
// }
//
// public static void addtoCollection(MethodConfig config){
// List<Params> list = new ArrayList<>();
// collection.put(config, list);
// }
//
// class Params{
// List<Object> params;
//
// public Params(List<Object> params){
// this.params = params;
// }
//
// public String toString(){
// int count = params.size();
// StringBuilder sBuilder = new StringBuilder();
// for (int i = count-1; i >= 0; i--){
// sBuilder.append(params.get(i));
// }
// return sBuilder.toString();
// }
//
// public int size(){
// return params.size();
// }
// }
//
// public String getClassName(){
// return className;
// }
//
// public String getMethodName(){
// return methodName;
// }
//
// public String getDescription(){
// return description;
// }
//
// public void setClassName(String classname){
// this.className = classname;
// }
//
// public void setMethodName(String methodname){
// this.methodName = methodname;
// }
//
// public void setDescription(String descriptor){
// this.description = descriptor;
// }
// }
| import java.util.List;
import com.cc.dextamper.context.MethodConfig; | package com.cc.dextamper.option;
public class Packer {
private String name; | // Path: src/com/cc/dextamper/context/MethodConfig.java
// public class MethodConfig {
// private static HashMap<MethodConfig, List<Params>> collection = new HashMap<>();
// private String className;
// private String methodName;
// private String description;
//
// public MethodConfig(){}
//
// public MethodConfig(MethodReference ref, List<Object> params){
// className = ref.getDefiningClass();
// methodName = ref.getName();
// List<? extends CharSequence> types = ref.getParameterTypes();
// StringBuilder sBuilder = new StringBuilder(types.size()+3);
// sBuilder.append("(");
// for (CharSequence type: types){
// sBuilder.append(type);
// }
// sBuilder.append(")");
// sBuilder.append(ref.getReturnType());
// description = sBuilder.toString();
// if (collection.containsKey(this)) {
// List<Params> list = collection.get(this);
// list.add(new Params(params));
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((description == null) ? 0 : description.hashCode());
// result = prime * result + ((methodName == null) ? 0 : methodName.hashCode());
// result = prime * result + ((className == null) ? 0 : className.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// MethodConfig other = (MethodConfig) obj;
// if (description == null) {
// if (other.description != null)
// return false;
// } else if (!description.equals(other.description))
// return false;
// if (methodName == null) {
// if (other.methodName != null)
// return false;
// } else if (!methodName.equals(other.methodName))
// return false;
// if (className == null) {
// if (other.className != null)
// return false;
// } else if (!className.equals(other.className))
// return false;
// return true;
// }
//
// public static void printInfo(){
// for (Entry<MethodConfig, List<Params>> entry: collection.entrySet()){
// MethodConfig config = entry.getKey();
// List<Params> list = entry.getValue();
// if (list.size() == 0)
// continue;
// System.out.println(config.className + "->" + config.methodName + config.description);
// System.out.println(list.size() + " " + list.get(0).size());
// for (Params param: list){
// for (Object object: param.params)
// System.out.println(object);
// }
// }
// }
//
// public static void addtoCollection(MethodConfig config){
// List<Params> list = new ArrayList<>();
// collection.put(config, list);
// }
//
// class Params{
// List<Object> params;
//
// public Params(List<Object> params){
// this.params = params;
// }
//
// public String toString(){
// int count = params.size();
// StringBuilder sBuilder = new StringBuilder();
// for (int i = count-1; i >= 0; i--){
// sBuilder.append(params.get(i));
// }
// return sBuilder.toString();
// }
//
// public int size(){
// return params.size();
// }
// }
//
// public String getClassName(){
// return className;
// }
//
// public String getMethodName(){
// return methodName;
// }
//
// public String getDescription(){
// return description;
// }
//
// public void setClassName(String classname){
// this.className = classname;
// }
//
// public void setMethodName(String methodname){
// this.methodName = methodname;
// }
//
// public void setDescription(String descriptor){
// this.description = descriptor;
// }
// }
// Path: src/com/cc/dextamper/option/Packer.java
import java.util.List;
import com.cc.dextamper.context.MethodConfig;
package com.cc.dextamper.option;
public class Packer {
private String name; | private List<MethodConfig> method; |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/TypeProto.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
| import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public interface TypeProto {
@Nonnull ClassPath getClassPath();
@Nonnull String getType();
boolean isInterface();
boolean implementsInterface(@Nonnull String iface);
@Nullable String getSuperclass();
@Nonnull TypeProto getCommonSuperclass(@Nonnull TypeProto other);
@Nullable FieldReference getFieldByOffset(int fieldOffset); | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
// Path: src/org/jf/dexlib2/analysis/TypeProto.java
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public interface TypeProto {
@Nonnull ClassPath getClassPath();
@Nonnull String getType();
boolean isInterface();
boolean implementsInterface(@Nonnull String iface);
@Nullable String getSuperclass();
@Nonnull TypeProto getCommonSuperclass(@Nonnull TypeProto other);
@Nullable FieldReference getFieldByOffset(int fieldOffset); | @Nullable Method getMethodByVtableIndex(int vtableIndex); |
CvvT/DexTamper | src/com/cc/dextamper/sample/AddClass.java | // Path: src/com/cc/dextamper/Configure.java
// public class Configure {
//
// public int API_LEVEL = 16;
// public String inPath;
// public String outPath;
// public boolean hasModifed = false;
//
// public Configure(String in, String out){
// this.inPath = in;
// this.outPath = out;
// }
//
// public Configure(String in, String out, int api){
// this(in, out);
// this.API_LEVEL = api;
// }
//
// }
//
// Path: src/com/cc/dextamper/tamper/MergeDex.java
// public class MergeDex {
//
// private String add_path;
// private Configure config;
// DexBackedDexFile dexfile;
// private Map<String, Integer> internedItem = new HashMap<>();
// private boolean ADD_ALL = false;
//
// public MergeDex(Configure configure, String addpath) throws IOException{
// this.config = configure;
// this.add_path = addpath;
// if (configure.hasModifed) {
// dexfile = DexFileFactory.loadDexFile(configure.outPath, configure.API_LEVEL);
// }else{
// dexfile = DexFileFactory.loadDexFile(configure.inPath, configure.API_LEVEL);
// }
// }
//
// /*
// * If you add a class name here, the class will be added to the new dex file
// */
// public void addclassName(String className){
// className = className.replaceAll("\\.", "/");
// className = "L" + className + ";";
// if (!internedItem.containsKey(className)) {
// System.out.println(className);
// internedItem.put(className, 0);
// }
// }
//
// /*
// * If you want to add all class except the class which has name starting with "Landroid"
// * or "Ljava" or "Ldalvik", I will simply drop these kind of class and add the others.
// * Just call this function
// */
// public void addAllclass(){
// this.ADD_ALL = true;
// }
//
// public void merge(){
// try {
// DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
// dexfile.setaddDexFile(addfile, new FilterClassDef() {
//
// @Override
// public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
// // TODO Auto-generated method stub
// String className = classDef.getType();
// if (ADD_ALL) {
// if (!className.startsWith("Landroid") &&
// !className.startsWith("Ljava") &&
// !className.startsWith("Ldalvik")) {
// return classDef;
// }else{
// return null;
// }
// }
//
// if (internedItem.containsKey(className)) {
// System.out.println("contain " + className);
// return classDef;
// }
// return null;
// }
// });
//
// DexRewriter rewriter = new DexRewriter(new RewriterModule());
// DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
// DexPool.writeTo(config.outPath, rewrittenDexFile);
// config.hasModifed = true;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }
| import java.io.IOException;
import com.cc.dextamper.Configure;
import com.cc.dextamper.tamper.MergeDex; | package com.cc.dextamper.sample;
public class AddClass {
private static String path = "/Users/CwT/Documents/workspace/DexTamper/test/test.apk";
private static String add_path = "/Users/CwT/Documents/workspace/DexTamper/test/add.apk";
public static void main(String argv[]){ | // Path: src/com/cc/dextamper/Configure.java
// public class Configure {
//
// public int API_LEVEL = 16;
// public String inPath;
// public String outPath;
// public boolean hasModifed = false;
//
// public Configure(String in, String out){
// this.inPath = in;
// this.outPath = out;
// }
//
// public Configure(String in, String out, int api){
// this(in, out);
// this.API_LEVEL = api;
// }
//
// }
//
// Path: src/com/cc/dextamper/tamper/MergeDex.java
// public class MergeDex {
//
// private String add_path;
// private Configure config;
// DexBackedDexFile dexfile;
// private Map<String, Integer> internedItem = new HashMap<>();
// private boolean ADD_ALL = false;
//
// public MergeDex(Configure configure, String addpath) throws IOException{
// this.config = configure;
// this.add_path = addpath;
// if (configure.hasModifed) {
// dexfile = DexFileFactory.loadDexFile(configure.outPath, configure.API_LEVEL);
// }else{
// dexfile = DexFileFactory.loadDexFile(configure.inPath, configure.API_LEVEL);
// }
// }
//
// /*
// * If you add a class name here, the class will be added to the new dex file
// */
// public void addclassName(String className){
// className = className.replaceAll("\\.", "/");
// className = "L" + className + ";";
// if (!internedItem.containsKey(className)) {
// System.out.println(className);
// internedItem.put(className, 0);
// }
// }
//
// /*
// * If you want to add all class except the class which has name starting with "Landroid"
// * or "Ljava" or "Ldalvik", I will simply drop these kind of class and add the others.
// * Just call this function
// */
// public void addAllclass(){
// this.ADD_ALL = true;
// }
//
// public void merge(){
// try {
// DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
// dexfile.setaddDexFile(addfile, new FilterClassDef() {
//
// @Override
// public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
// // TODO Auto-generated method stub
// String className = classDef.getType();
// if (ADD_ALL) {
// if (!className.startsWith("Landroid") &&
// !className.startsWith("Ljava") &&
// !className.startsWith("Ldalvik")) {
// return classDef;
// }else{
// return null;
// }
// }
//
// if (internedItem.containsKey(className)) {
// System.out.println("contain " + className);
// return classDef;
// }
// return null;
// }
// });
//
// DexRewriter rewriter = new DexRewriter(new RewriterModule());
// DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
// DexPool.writeTo(config.outPath, rewrittenDexFile);
// config.hasModifed = true;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }
// Path: src/com/cc/dextamper/sample/AddClass.java
import java.io.IOException;
import com.cc.dextamper.Configure;
import com.cc.dextamper.tamper.MergeDex;
package com.cc.dextamper.sample;
public class AddClass {
private static String path = "/Users/CwT/Documents/workspace/DexTamper/test/test.apk";
private static String add_path = "/Users/CwT/Documents/workspace/DexTamper/test/add.apk";
public static void main(String argv[]){ | Configure configure = new Configure(path, "out.dex"); |
CvvT/DexTamper | src/com/cc/dextamper/sample/AddClass.java | // Path: src/com/cc/dextamper/Configure.java
// public class Configure {
//
// public int API_LEVEL = 16;
// public String inPath;
// public String outPath;
// public boolean hasModifed = false;
//
// public Configure(String in, String out){
// this.inPath = in;
// this.outPath = out;
// }
//
// public Configure(String in, String out, int api){
// this(in, out);
// this.API_LEVEL = api;
// }
//
// }
//
// Path: src/com/cc/dextamper/tamper/MergeDex.java
// public class MergeDex {
//
// private String add_path;
// private Configure config;
// DexBackedDexFile dexfile;
// private Map<String, Integer> internedItem = new HashMap<>();
// private boolean ADD_ALL = false;
//
// public MergeDex(Configure configure, String addpath) throws IOException{
// this.config = configure;
// this.add_path = addpath;
// if (configure.hasModifed) {
// dexfile = DexFileFactory.loadDexFile(configure.outPath, configure.API_LEVEL);
// }else{
// dexfile = DexFileFactory.loadDexFile(configure.inPath, configure.API_LEVEL);
// }
// }
//
// /*
// * If you add a class name here, the class will be added to the new dex file
// */
// public void addclassName(String className){
// className = className.replaceAll("\\.", "/");
// className = "L" + className + ";";
// if (!internedItem.containsKey(className)) {
// System.out.println(className);
// internedItem.put(className, 0);
// }
// }
//
// /*
// * If you want to add all class except the class which has name starting with "Landroid"
// * or "Ljava" or "Ldalvik", I will simply drop these kind of class and add the others.
// * Just call this function
// */
// public void addAllclass(){
// this.ADD_ALL = true;
// }
//
// public void merge(){
// try {
// DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
// dexfile.setaddDexFile(addfile, new FilterClassDef() {
//
// @Override
// public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
// // TODO Auto-generated method stub
// String className = classDef.getType();
// if (ADD_ALL) {
// if (!className.startsWith("Landroid") &&
// !className.startsWith("Ljava") &&
// !className.startsWith("Ldalvik")) {
// return classDef;
// }else{
// return null;
// }
// }
//
// if (internedItem.containsKey(className)) {
// System.out.println("contain " + className);
// return classDef;
// }
// return null;
// }
// });
//
// DexRewriter rewriter = new DexRewriter(new RewriterModule());
// DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
// DexPool.writeTo(config.outPath, rewrittenDexFile);
// config.hasModifed = true;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }
| import java.io.IOException;
import com.cc.dextamper.Configure;
import com.cc.dextamper.tamper.MergeDex; | package com.cc.dextamper.sample;
public class AddClass {
private static String path = "/Users/CwT/Documents/workspace/DexTamper/test/test.apk";
private static String add_path = "/Users/CwT/Documents/workspace/DexTamper/test/add.apk";
public static void main(String argv[]){
Configure configure = new Configure(path, "out.dex"); | // Path: src/com/cc/dextamper/Configure.java
// public class Configure {
//
// public int API_LEVEL = 16;
// public String inPath;
// public String outPath;
// public boolean hasModifed = false;
//
// public Configure(String in, String out){
// this.inPath = in;
// this.outPath = out;
// }
//
// public Configure(String in, String out, int api){
// this(in, out);
// this.API_LEVEL = api;
// }
//
// }
//
// Path: src/com/cc/dextamper/tamper/MergeDex.java
// public class MergeDex {
//
// private String add_path;
// private Configure config;
// DexBackedDexFile dexfile;
// private Map<String, Integer> internedItem = new HashMap<>();
// private boolean ADD_ALL = false;
//
// public MergeDex(Configure configure, String addpath) throws IOException{
// this.config = configure;
// this.add_path = addpath;
// if (configure.hasModifed) {
// dexfile = DexFileFactory.loadDexFile(configure.outPath, configure.API_LEVEL);
// }else{
// dexfile = DexFileFactory.loadDexFile(configure.inPath, configure.API_LEVEL);
// }
// }
//
// /*
// * If you add a class name here, the class will be added to the new dex file
// */
// public void addclassName(String className){
// className = className.replaceAll("\\.", "/");
// className = "L" + className + ";";
// if (!internedItem.containsKey(className)) {
// System.out.println(className);
// internedItem.put(className, 0);
// }
// }
//
// /*
// * If you want to add all class except the class which has name starting with "Landroid"
// * or "Ljava" or "Ldalvik", I will simply drop these kind of class and add the others.
// * Just call this function
// */
// public void addAllclass(){
// this.ADD_ALL = true;
// }
//
// public void merge(){
// try {
// DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
// dexfile.setaddDexFile(addfile, new FilterClassDef() {
//
// @Override
// public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
// // TODO Auto-generated method stub
// String className = classDef.getType();
// if (ADD_ALL) {
// if (!className.startsWith("Landroid") &&
// !className.startsWith("Ljava") &&
// !className.startsWith("Ldalvik")) {
// return classDef;
// }else{
// return null;
// }
// }
//
// if (internedItem.containsKey(className)) {
// System.out.println("contain " + className);
// return classDef;
// }
// return null;
// }
// });
//
// DexRewriter rewriter = new DexRewriter(new RewriterModule());
// DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
// DexPool.writeTo(config.outPath, rewrittenDexFile);
// config.hasModifed = true;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }
// Path: src/com/cc/dextamper/sample/AddClass.java
import java.io.IOException;
import com.cc.dextamper.Configure;
import com.cc.dextamper.tamper.MergeDex;
package com.cc.dextamper.sample;
public class AddClass {
private static String path = "/Users/CwT/Documents/workspace/DexTamper/test/test.apk";
private static String add_path = "/Users/CwT/Documents/workspace/DexTamper/test/add.apk";
public static void main(String argv[]){
Configure configure = new Configure(path, "out.dex"); | MergeDex merge; |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/PrimitiveProto.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
| import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public class PrimitiveProto implements TypeProto {
protected final ClassPath classPath;
protected final String type;
public PrimitiveProto(@Nonnull ClassPath classPath, @Nonnull String type) {
this.classPath = classPath;
this.type = type;
}
@Override public String toString() { return type; }
@Nonnull @Override public ClassPath getClassPath() { return classPath; }
@Nonnull @Override public String getType() { return type; }
@Override public boolean isInterface() { return false; }
@Override public boolean implementsInterface(@Nonnull String iface) { return false; }
@Nullable @Override public String getSuperclass() { return null; }
@Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
throw new ExceptionWithContext("Cannot call getCommonSuperclass on PrimitiveProto");
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
return null;
}
@Override
@Nullable | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
// Path: src/org/jf/dexlib2/analysis/PrimitiveProto.java
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public class PrimitiveProto implements TypeProto {
protected final ClassPath classPath;
protected final String type;
public PrimitiveProto(@Nonnull ClassPath classPath, @Nonnull String type) {
this.classPath = classPath;
this.type = type;
}
@Override public String toString() { return type; }
@Nonnull @Override public ClassPath getClassPath() { return classPath; }
@Nonnull @Override public String getType() { return type; }
@Override public boolean isInterface() { return false; }
@Override public boolean implementsInterface(@Nonnull String iface) { return false; }
@Nullable @Override public String getSuperclass() { return null; }
@Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
throw new ExceptionWithContext("Cannot call getCommonSuperclass on PrimitiveProto");
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
return null;
}
@Override
@Nullable | public Method getMethodByVtableIndex(int vtableIndex) { |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/util/TypeProtoUtils.java | // Path: src/org/jf/dexlib2/analysis/TypeProto.java
// public interface TypeProto {
// @Nonnull ClassPath getClassPath();
// @Nonnull String getType();
// boolean isInterface();
// boolean implementsInterface(@Nonnull String iface);
// @Nullable String getSuperclass();
// @Nonnull TypeProto getCommonSuperclass(@Nonnull TypeProto other);
// @Nullable FieldReference getFieldByOffset(int fieldOffset);
// @Nullable Method getMethodByVtableIndex(int vtableIndex);
// int findMethodIndexInVtable(@Nonnull MethodReference method);
// }
| import org.jf.dexlib2.analysis.TypeProto;
import org.jf.dexlib2.analysis.UnresolvedClassException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Iterator;
import java.util.NoSuchElementException; | /*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis.util;
public class TypeProtoUtils {
/**
* Get the chain of superclasses of the given class. The first element will be the immediate superclass followed by
* it's superclass, etc. up to java.lang.Object.
*
* Returns an empty iterable if called on java.lang.Object or a primitive.
*
* If any class in the superclass chain can't be resolved, the iterable will return Ujava/lang/Object; to represent
* the unknown class.
*
* @return An iterable containing the superclasses of this class.
*/
@Nonnull | // Path: src/org/jf/dexlib2/analysis/TypeProto.java
// public interface TypeProto {
// @Nonnull ClassPath getClassPath();
// @Nonnull String getType();
// boolean isInterface();
// boolean implementsInterface(@Nonnull String iface);
// @Nullable String getSuperclass();
// @Nonnull TypeProto getCommonSuperclass(@Nonnull TypeProto other);
// @Nullable FieldReference getFieldByOffset(int fieldOffset);
// @Nullable Method getMethodByVtableIndex(int vtableIndex);
// int findMethodIndexInVtable(@Nonnull MethodReference method);
// }
// Path: src/org/jf/dexlib2/analysis/util/TypeProtoUtils.java
import org.jf.dexlib2.analysis.TypeProto;
import org.jf.dexlib2.analysis.UnresolvedClassException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Iterator;
import java.util.NoSuchElementException;
/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis.util;
public class TypeProtoUtils {
/**
* Get the chain of superclasses of the given class. The first element will be the immediate superclass followed by
* it's superclass, etc. up to java.lang.Object.
*
* Returns an empty iterable if called on java.lang.Object or a primitive.
*
* If any class in the superclass chain can't be resolved, the iterable will return Ujava/lang/Object; to represent
* the unknown class.
*
* @return An iterable containing the superclasses of this class.
*/
@Nonnull | public static Iterable<TypeProto> getSuperclassChain(@Nonnull final TypeProto typeProto) { |
CvvT/DexTamper | src/org/jf/dexlib2/util/SyntheticAccessorFSM.java | // Path: src/org/jf/dexlib2/Opcodes.java
// public class Opcodes {
//
// /**
// * Either the api level for dalvik opcodes, or the art version for art opcodes
// */
// public final int api;
// public final int artVersion;
// @Nonnull private final Opcode[] opcodesByValue = new Opcode[255];
// @Nonnull private final EnumMap<Opcode, Short> opcodeValues;
// @Nonnull private final HashMap<String, Opcode> opcodesByName;
//
// @Nonnull
// public static Opcodes forApi(int api) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), false);
// }
//
// @Nonnull
// public static Opcodes forApi(int api, boolean experimental) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion) {
// return forArtVersion(artVersion, false);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion, boolean experimental) {
// return new Opcodes(VersionMap.mapArtVersionToApi(artVersion), artVersion, experimental);
// }
//
// @Deprecated
// public Opcodes(int api) {
// this(api, false);
// }
//
// @Deprecated
// public Opcodes(int api, boolean experimental) {
// this(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// private Opcodes(int api, int artVersion, boolean experimental) {
// this.api = api;
// this.artVersion = artVersion;
//
// opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
// opcodesByName = Maps.newHashMap();
//
// int version;
// if (isArt()) {
// version = artVersion;
// } else {
// version = api;
// }
//
// for (Opcode opcode: Opcode.values()) {
// RangeMap<Integer, Short> versionToValueMap;
//
// if (isArt()) {
// versionToValueMap = opcode.artVersionToValueMap;
// } else {
// versionToValueMap = opcode.apiToValueMap;
// }
//
// Short opcodeValue = versionToValueMap.get(version);
// if (opcodeValue != null && (!opcode.isExperimental() || experimental)) {
// if (!opcode.format.isPayloadFormat) {
// opcodesByValue[opcodeValue] = opcode;
// }
// opcodeValues.put(opcode, opcodeValue);
// opcodesByName.put(opcode.name.toLowerCase(), opcode);
// }
// }
// }
//
// @Nullable
// public Opcode getOpcodeByName(@Nonnull String opcodeName) {
// return opcodesByName.get(opcodeName.toLowerCase());
// }
//
// @Nullable
// public Opcode getOpcodeByValue(int opcodeValue) {
// switch (opcodeValue) {
// case 0x100:
// return Opcode.PACKED_SWITCH_PAYLOAD;
// case 0x200:
// return Opcode.SPARSE_SWITCH_PAYLOAD;
// case 0x300:
// return Opcode.ARRAY_PAYLOAD;
// default:
// if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) {
// return opcodesByValue[opcodeValue];
// }
// return null;
// }
// }
//
// @Nullable
// public Short getOpcodeValue(@Nonnull Opcode opcode) {
// return opcodeValues.get(opcode);
// }
//
// public boolean isArt() {
// return artVersion != VersionMap.NO_VERSION;
// }
// }
| import org.jf.dexlib2.iface.instruction.Instruction;
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction;
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction;
import org.jf.dexlib2.Opcodes;
import java.util.List; | public static final int USHR = SyntheticAccessorResolver.USHR_ASSIGNMENT;
public static final int INT = 0;
public static final int LONG = 1;
public static final int FLOAT = 2;
public static final int DOUBLE = 3;
public static final int POSITIVE_ONE = 1;
public static final int NEGATIVE_ONE = -1;
public static final int OTHER = 0;
public static int test(List<? extends Instruction> instructions) {
int accessorType = -1;
int cs, p = 0;
int pe = instructions.size();
// one of the math type constants representing the type of math operation being performed
int mathOp = -1;
// for increments an decrements, the type of value the math operation is on
int mathType = -1;
// for increments and decrements, the value of the constant that is used
long constantValue = 0;
// The source register for the put instruction
int putRegister = -1;
// The return register;
int returnRegister = -1;
| // Path: src/org/jf/dexlib2/Opcodes.java
// public class Opcodes {
//
// /**
// * Either the api level for dalvik opcodes, or the art version for art opcodes
// */
// public final int api;
// public final int artVersion;
// @Nonnull private final Opcode[] opcodesByValue = new Opcode[255];
// @Nonnull private final EnumMap<Opcode, Short> opcodeValues;
// @Nonnull private final HashMap<String, Opcode> opcodesByName;
//
// @Nonnull
// public static Opcodes forApi(int api) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), false);
// }
//
// @Nonnull
// public static Opcodes forApi(int api, boolean experimental) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion) {
// return forArtVersion(artVersion, false);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion, boolean experimental) {
// return new Opcodes(VersionMap.mapArtVersionToApi(artVersion), artVersion, experimental);
// }
//
// @Deprecated
// public Opcodes(int api) {
// this(api, false);
// }
//
// @Deprecated
// public Opcodes(int api, boolean experimental) {
// this(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// private Opcodes(int api, int artVersion, boolean experimental) {
// this.api = api;
// this.artVersion = artVersion;
//
// opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
// opcodesByName = Maps.newHashMap();
//
// int version;
// if (isArt()) {
// version = artVersion;
// } else {
// version = api;
// }
//
// for (Opcode opcode: Opcode.values()) {
// RangeMap<Integer, Short> versionToValueMap;
//
// if (isArt()) {
// versionToValueMap = opcode.artVersionToValueMap;
// } else {
// versionToValueMap = opcode.apiToValueMap;
// }
//
// Short opcodeValue = versionToValueMap.get(version);
// if (opcodeValue != null && (!opcode.isExperimental() || experimental)) {
// if (!opcode.format.isPayloadFormat) {
// opcodesByValue[opcodeValue] = opcode;
// }
// opcodeValues.put(opcode, opcodeValue);
// opcodesByName.put(opcode.name.toLowerCase(), opcode);
// }
// }
// }
//
// @Nullable
// public Opcode getOpcodeByName(@Nonnull String opcodeName) {
// return opcodesByName.get(opcodeName.toLowerCase());
// }
//
// @Nullable
// public Opcode getOpcodeByValue(int opcodeValue) {
// switch (opcodeValue) {
// case 0x100:
// return Opcode.PACKED_SWITCH_PAYLOAD;
// case 0x200:
// return Opcode.SPARSE_SWITCH_PAYLOAD;
// case 0x300:
// return Opcode.ARRAY_PAYLOAD;
// default:
// if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) {
// return opcodesByValue[opcodeValue];
// }
// return null;
// }
// }
//
// @Nullable
// public Short getOpcodeValue(@Nonnull Opcode opcode) {
// return opcodeValues.get(opcode);
// }
//
// public boolean isArt() {
// return artVersion != VersionMap.NO_VERSION;
// }
// }
// Path: src/org/jf/dexlib2/util/SyntheticAccessorFSM.java
import org.jf.dexlib2.iface.instruction.Instruction;
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction;
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction;
import org.jf.dexlib2.Opcodes;
import java.util.List;
public static final int USHR = SyntheticAccessorResolver.USHR_ASSIGNMENT;
public static final int INT = 0;
public static final int LONG = 1;
public static final int FLOAT = 2;
public static final int DOUBLE = 3;
public static final int POSITIVE_ONE = 1;
public static final int NEGATIVE_ONE = -1;
public static final int OTHER = 0;
public static int test(List<? extends Instruction> instructions) {
int accessorType = -1;
int cs, p = 0;
int pe = instructions.size();
// one of the math type constants representing the type of math operation being performed
int mathOp = -1;
// for increments an decrements, the type of value the math operation is on
int mathType = -1;
// for increments and decrements, the value of the constant that is used
long constantValue = 0;
// The source register for the put instruction
int putRegister = -1;
// The return register;
int returnRegister = -1;
| Opcodes opcodes = Opcodes.forApi(20); |
CvvT/DexTamper | src/org/jf/dexlib2/util/MethodUtil.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
| import com.google.common.base.Predicate;
import org.jf.dexlib2.AccessFlags;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.util.CharSequenceUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection; | /*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.util;
public final class MethodUtil {
private static int directMask = AccessFlags.STATIC.getValue() | AccessFlags.PRIVATE.getValue() |
AccessFlags.CONSTRUCTOR.getValue();
| // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
// Path: src/org/jf/dexlib2/util/MethodUtil.java
import com.google.common.base.Predicate;
import org.jf.dexlib2.AccessFlags;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.util.CharSequenceUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
/*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.util;
public final class MethodUtil {
private static int directMask = AccessFlags.STATIC.getValue() | AccessFlags.PRIVATE.getValue() |
AccessFlags.CONSTRUCTOR.getValue();
| public static Predicate<Method> METHOD_IS_DIRECT = new Predicate<Method>() { |
CvvT/DexTamper | src/org/jf/dexlib2/dexbacked/DexBackedOdexFile.java | // Path: src/org/jf/dexlib2/Opcodes.java
// public class Opcodes {
//
// /**
// * Either the api level for dalvik opcodes, or the art version for art opcodes
// */
// public final int api;
// public final int artVersion;
// @Nonnull private final Opcode[] opcodesByValue = new Opcode[255];
// @Nonnull private final EnumMap<Opcode, Short> opcodeValues;
// @Nonnull private final HashMap<String, Opcode> opcodesByName;
//
// @Nonnull
// public static Opcodes forApi(int api) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), false);
// }
//
// @Nonnull
// public static Opcodes forApi(int api, boolean experimental) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion) {
// return forArtVersion(artVersion, false);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion, boolean experimental) {
// return new Opcodes(VersionMap.mapArtVersionToApi(artVersion), artVersion, experimental);
// }
//
// @Deprecated
// public Opcodes(int api) {
// this(api, false);
// }
//
// @Deprecated
// public Opcodes(int api, boolean experimental) {
// this(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// private Opcodes(int api, int artVersion, boolean experimental) {
// this.api = api;
// this.artVersion = artVersion;
//
// opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
// opcodesByName = Maps.newHashMap();
//
// int version;
// if (isArt()) {
// version = artVersion;
// } else {
// version = api;
// }
//
// for (Opcode opcode: Opcode.values()) {
// RangeMap<Integer, Short> versionToValueMap;
//
// if (isArt()) {
// versionToValueMap = opcode.artVersionToValueMap;
// } else {
// versionToValueMap = opcode.apiToValueMap;
// }
//
// Short opcodeValue = versionToValueMap.get(version);
// if (opcodeValue != null && (!opcode.isExperimental() || experimental)) {
// if (!opcode.format.isPayloadFormat) {
// opcodesByValue[opcodeValue] = opcode;
// }
// opcodeValues.put(opcode, opcodeValue);
// opcodesByName.put(opcode.name.toLowerCase(), opcode);
// }
// }
// }
//
// @Nullable
// public Opcode getOpcodeByName(@Nonnull String opcodeName) {
// return opcodesByName.get(opcodeName.toLowerCase());
// }
//
// @Nullable
// public Opcode getOpcodeByValue(int opcodeValue) {
// switch (opcodeValue) {
// case 0x100:
// return Opcode.PACKED_SWITCH_PAYLOAD;
// case 0x200:
// return Opcode.SPARSE_SWITCH_PAYLOAD;
// case 0x300:
// return Opcode.ARRAY_PAYLOAD;
// default:
// if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) {
// return opcodesByValue[opcodeValue];
// }
// return null;
// }
// }
//
// @Nullable
// public Short getOpcodeValue(@Nonnull Opcode opcode) {
// return opcodeValues.get(opcode);
// }
//
// public boolean isArt() {
// return artVersion != VersionMap.NO_VERSION;
// }
// }
| import com.google.common.io.ByteStreams;
import org.jf.dexlib2.Opcodes;
import org.jf.dexlib2.dexbacked.raw.OdexHeaderItem;
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
import javax.annotation.Nonnull;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List; | /*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.dexbacked;
public class DexBackedOdexFile extends DexBackedDexFile {
private static final int DEPENDENCY_COUNT_OFFSET = 12;
private static final int DEPENDENCY_START_OFFSET = 16;
private final byte[] odexBuf;
| // Path: src/org/jf/dexlib2/Opcodes.java
// public class Opcodes {
//
// /**
// * Either the api level for dalvik opcodes, or the art version for art opcodes
// */
// public final int api;
// public final int artVersion;
// @Nonnull private final Opcode[] opcodesByValue = new Opcode[255];
// @Nonnull private final EnumMap<Opcode, Short> opcodeValues;
// @Nonnull private final HashMap<String, Opcode> opcodesByName;
//
// @Nonnull
// public static Opcodes forApi(int api) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), false);
// }
//
// @Nonnull
// public static Opcodes forApi(int api, boolean experimental) {
// return new Opcodes(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion) {
// return forArtVersion(artVersion, false);
// }
//
// @Nonnull
// public static Opcodes forArtVersion(int artVersion, boolean experimental) {
// return new Opcodes(VersionMap.mapArtVersionToApi(artVersion), artVersion, experimental);
// }
//
// @Deprecated
// public Opcodes(int api) {
// this(api, false);
// }
//
// @Deprecated
// public Opcodes(int api, boolean experimental) {
// this(api, VersionMap.mapApiToArtVersion(api), experimental);
// }
//
// private Opcodes(int api, int artVersion, boolean experimental) {
// this.api = api;
// this.artVersion = artVersion;
//
// opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
// opcodesByName = Maps.newHashMap();
//
// int version;
// if (isArt()) {
// version = artVersion;
// } else {
// version = api;
// }
//
// for (Opcode opcode: Opcode.values()) {
// RangeMap<Integer, Short> versionToValueMap;
//
// if (isArt()) {
// versionToValueMap = opcode.artVersionToValueMap;
// } else {
// versionToValueMap = opcode.apiToValueMap;
// }
//
// Short opcodeValue = versionToValueMap.get(version);
// if (opcodeValue != null && (!opcode.isExperimental() || experimental)) {
// if (!opcode.format.isPayloadFormat) {
// opcodesByValue[opcodeValue] = opcode;
// }
// opcodeValues.put(opcode, opcodeValue);
// opcodesByName.put(opcode.name.toLowerCase(), opcode);
// }
// }
// }
//
// @Nullable
// public Opcode getOpcodeByName(@Nonnull String opcodeName) {
// return opcodesByName.get(opcodeName.toLowerCase());
// }
//
// @Nullable
// public Opcode getOpcodeByValue(int opcodeValue) {
// switch (opcodeValue) {
// case 0x100:
// return Opcode.PACKED_SWITCH_PAYLOAD;
// case 0x200:
// return Opcode.SPARSE_SWITCH_PAYLOAD;
// case 0x300:
// return Opcode.ARRAY_PAYLOAD;
// default:
// if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) {
// return opcodesByValue[opcodeValue];
// }
// return null;
// }
// }
//
// @Nullable
// public Short getOpcodeValue(@Nonnull Opcode opcode) {
// return opcodeValues.get(opcode);
// }
//
// public boolean isArt() {
// return artVersion != VersionMap.NO_VERSION;
// }
// }
// Path: src/org/jf/dexlib2/dexbacked/DexBackedOdexFile.java
import com.google.common.io.ByteStreams;
import org.jf.dexlib2.Opcodes;
import org.jf.dexlib2.dexbacked.raw.OdexHeaderItem;
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
import javax.annotation.Nonnull;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.dexbacked;
public class DexBackedOdexFile extends DexBackedDexFile {
private static final int DEPENDENCY_COUNT_OFFSET = 12;
private static final int DEPENDENCY_START_OFFSET = 16;
private final byte[] odexBuf;
| public DexBackedOdexFile(@Nonnull Opcodes opcodes, @Nonnull byte[] odexBuf, byte[] dexBuf) { |
CvvT/DexTamper | src/org/jf/dexlib2/util/TypeUtils.java | // Path: src/org/jf/dexlib2/iface/ClassDef.java
// public interface ClassDef extends TypeReference, Annotatable {
// /**
// * Gets the class type.
// *
// * This will be a type descriptor per the dex file specification.
// *
// * @return The class type
// */
// @Override @Nonnull String getType();
//
// /**
// * Gets the access flags for this class.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a class.
// *
// * @return The access flags for this class
// */
// int getAccessFlags();
//
// /**
// * Gets the superclass of this class.
// *
// * This will only be null if this is the base java.lang.Object class.
// *
// * @return The superclass of this class
// */
// @Nullable String getSuperclass();
//
// /**
// * Gets a list of the interfaces that this class implements.
// *
// * @return A list of the interfaces that this class implements
// */
// @Nonnull List<String> getInterfaces();
//
// /**
// * Gets the name of the primary source file that this class is defined in, if available.
// *
// * This will be the default source file associated with all methods defined in this class. This can be overridden
// * for sections of an individual method with the SetSourceFile debug item.
// *
// * @return The name of the primary source file for this class, or null if not available
// */
// @Nullable String getSourceFile();
//
// /**
// * Gets a set of the annotations that are applied to this class.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this class
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets the static fields that are defined by this class.
// *
// * The static fields that are returned must have no duplicates.
// *
// * @return The static fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getStaticFields();
//
// /**
// * Gets the instance fields that are defined by this class.
// *
// * The instance fields that are returned must have no duplicates.
// *
// * @return The instance fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getInstanceFields();
//
// /**
// * Gets all the fields that are defined by this class.
// *
// * This is a convenience method that combines getStaticFields() and getInstanceFields()
// *
// * The returned fields may be in any order. I.e. It's not safe to assume that all instance fields will come after
// * all static fields.
// *
// * Note that there typically should not be any duplicate fields between the two, but some versions of
// * dalvik inadvertently allow duplicate static/instance fields, and are supported here for completeness
// *
// * @return A set of the fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getFields();
//
// /**
// * Gets the direct methods that are defined by this class.
// *
// * The direct methods that are returned must have no duplicates.
// *
// * @return The direct methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getDirectMethods();
//
// /**
// * Gets the virtual methods that are defined by this class.
// *
// * The virtual methods that are returned must have no duplicates.
// *
// * @return The virtual methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getVirtualMethods();
//
// /**
// * Gets all the methods that are defined by this class.
// *
// * This is a convenience method that combines getDirectMethods() and getVirtualMethods().
// *
// * The returned methods may be in any order. I.e. It's not safe to assume that all virtual methods will come after
// * all direct methods.
// *
// * Note that there typically should not be any duplicate methods between the two, but some versions of
// * dalvik inadvertently allow duplicate direct/virtual methods, and are supported here for completeness
// *
// * @return An iterable of the methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getMethods();
// }
| import org.jf.dexlib2.AccessFlags;
import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.reference.TypeReference;
import javax.annotation.Nonnull; | /*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.util;
public final class TypeUtils {
public static boolean isWideType(@Nonnull String type) {
char c = type.charAt(0);
return c == 'J' || c == 'D';
}
public static boolean isWideType(@Nonnull TypeReference type) {
return isWideType(type.getType());
}
public static boolean isPrimitiveType(String type) {
return type.length() == 1;
}
@Nonnull
public static String getPackage(@Nonnull String type) {
int lastSlash = type.lastIndexOf('/');
if (lastSlash < 0) {
return "";
}
return type.substring(1, lastSlash);
}
| // Path: src/org/jf/dexlib2/iface/ClassDef.java
// public interface ClassDef extends TypeReference, Annotatable {
// /**
// * Gets the class type.
// *
// * This will be a type descriptor per the dex file specification.
// *
// * @return The class type
// */
// @Override @Nonnull String getType();
//
// /**
// * Gets the access flags for this class.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a class.
// *
// * @return The access flags for this class
// */
// int getAccessFlags();
//
// /**
// * Gets the superclass of this class.
// *
// * This will only be null if this is the base java.lang.Object class.
// *
// * @return The superclass of this class
// */
// @Nullable String getSuperclass();
//
// /**
// * Gets a list of the interfaces that this class implements.
// *
// * @return A list of the interfaces that this class implements
// */
// @Nonnull List<String> getInterfaces();
//
// /**
// * Gets the name of the primary source file that this class is defined in, if available.
// *
// * This will be the default source file associated with all methods defined in this class. This can be overridden
// * for sections of an individual method with the SetSourceFile debug item.
// *
// * @return The name of the primary source file for this class, or null if not available
// */
// @Nullable String getSourceFile();
//
// /**
// * Gets a set of the annotations that are applied to this class.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this class
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets the static fields that are defined by this class.
// *
// * The static fields that are returned must have no duplicates.
// *
// * @return The static fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getStaticFields();
//
// /**
// * Gets the instance fields that are defined by this class.
// *
// * The instance fields that are returned must have no duplicates.
// *
// * @return The instance fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getInstanceFields();
//
// /**
// * Gets all the fields that are defined by this class.
// *
// * This is a convenience method that combines getStaticFields() and getInstanceFields()
// *
// * The returned fields may be in any order. I.e. It's not safe to assume that all instance fields will come after
// * all static fields.
// *
// * Note that there typically should not be any duplicate fields between the two, but some versions of
// * dalvik inadvertently allow duplicate static/instance fields, and are supported here for completeness
// *
// * @return A set of the fields that are defined by this class
// */
// @Nonnull Iterable<? extends Field> getFields();
//
// /**
// * Gets the direct methods that are defined by this class.
// *
// * The direct methods that are returned must have no duplicates.
// *
// * @return The direct methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getDirectMethods();
//
// /**
// * Gets the virtual methods that are defined by this class.
// *
// * The virtual methods that are returned must have no duplicates.
// *
// * @return The virtual methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getVirtualMethods();
//
// /**
// * Gets all the methods that are defined by this class.
// *
// * This is a convenience method that combines getDirectMethods() and getVirtualMethods().
// *
// * The returned methods may be in any order. I.e. It's not safe to assume that all virtual methods will come after
// * all direct methods.
// *
// * Note that there typically should not be any duplicate methods between the two, but some versions of
// * dalvik inadvertently allow duplicate direct/virtual methods, and are supported here for completeness
// *
// * @return An iterable of the methods that are defined by this class.
// */
// @Nonnull Iterable<? extends Method> getMethods();
// }
// Path: src/org/jf/dexlib2/util/TypeUtils.java
import org.jf.dexlib2.AccessFlags;
import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.reference.TypeReference;
import javax.annotation.Nonnull;
/*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.util;
public final class TypeUtils {
public static boolean isWideType(@Nonnull String type) {
char c = type.charAt(0);
return c == 'J' || c == 'D';
}
public static boolean isWideType(@Nonnull TypeReference type) {
return isWideType(type.getType());
}
public static boolean isPrimitiveType(String type) {
return type.length() == 1;
}
@Nonnull
public static String getPackage(@Nonnull String type) {
int lastSlash = type.lastIndexOf('/');
if (lastSlash < 0) {
return "";
}
return type.substring(1, lastSlash);
}
| public static boolean canAccessClass(@Nonnull String accessorType, @Nonnull ClassDef accesseeClassDef) { |
CvvT/DexTamper | src/org/jf/dexlib2/analysis/UnknownClassProto.java | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
| import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public class UnknownClassProto implements TypeProto {
@Nonnull protected final ClassPath classPath;
public UnknownClassProto(@Nonnull ClassPath classPath) {
this.classPath = classPath;
}
@Override public String toString() { return "Ujava/lang/Object;"; }
@Nonnull @Override public ClassPath getClassPath() { return classPath; }
@Nullable @Override public String getSuperclass() { return null; }
@Override public boolean isInterface() { return false; }
@Override public boolean implementsInterface(@Nonnull String iface) { return false; }
@Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
if (other.getType().equals("Ljava/lang/Object;")) {
return other;
}
if (other instanceof ArrayProto) {
// if it's an array class, it's safe to assume this unknown class isn't related, and so
// java.lang.Object is the only possible superclass
return classPath.getClass("Ljava/lang/Object;");
}
return this;
}
@Nonnull @Override public String getType() {
// use the otherwise used U prefix for an unknown/unresolvable class
return "Ujava/lang/Object;";
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
return classPath.getClass("Ljava/lang/Object;").getFieldByOffset(fieldOffset);
}
@Override
@Nullable | // Path: src/org/jf/dexlib2/iface/Method.java
// public interface Method extends MethodReference, Member {
// /**
// * Gets the type of the class that defines this method.
// *
// * @return The type of the class that defines this method
// */
// @Override @Nonnull String getDefiningClass();
//
// /**
// * Gets the name of this method.
// *
// * @return The name of this method
// */
// @Override @Nonnull String getName();
//
// /**
// * Gets a list of the parameters of this method.
// *
// * As per the MethodReference interface, the MethodParameter objects contained in the returned list also act
// * as a simple reference to the type of the parameter. However, the MethodParameter object can also contain
// * additional information about the parameter.
// *
// * Note: In some implementations, the returned list is likely to *not* provide efficient random access.
// *
// * @return A list of MethodParameter objects, representing the parameters of this method.
// */
// @Nonnull List<? extends MethodParameter> getParameters();
//
// /**
// * Gets the return type of this method.
// *
// * @return The return type of this method.
// */
// @Override @Nonnull String getReturnType();
//
// /**
// * Gets the access flags for this method.
// *
// * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a method.
// *
// * @return The access flags for this method
// */
// @Override int getAccessFlags();
//
// /**
// * Gets a set of the annotations that are applied to this method.
// *
// * The annotations in the returned set are guaranteed to have unique types.
// *
// * @return A set of the annotations that are applied to this method
// */
// @Override @Nonnull Set<? extends Annotation> getAnnotations();
//
// /**
// * Gets a MethodImplementation object that defines the implementation of the method.
// *
// * If this is an abstract method in an abstract class, or an interface method in an interface definition, then the
// * method has no implementation, and this will return null.
// *
// * @return A MethodImplementation object defining the implementation of this method, or null if the method has no
// * implementation
// */
// @Nullable MethodImplementation getImplementation();
// }
// Path: src/org/jf/dexlib2/analysis/UnknownClassProto.java
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.analysis;
public class UnknownClassProto implements TypeProto {
@Nonnull protected final ClassPath classPath;
public UnknownClassProto(@Nonnull ClassPath classPath) {
this.classPath = classPath;
}
@Override public String toString() { return "Ujava/lang/Object;"; }
@Nonnull @Override public ClassPath getClassPath() { return classPath; }
@Nullable @Override public String getSuperclass() { return null; }
@Override public boolean isInterface() { return false; }
@Override public boolean implementsInterface(@Nonnull String iface) { return false; }
@Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) {
if (other.getType().equals("Ljava/lang/Object;")) {
return other;
}
if (other instanceof ArrayProto) {
// if it's an array class, it's safe to assume this unknown class isn't related, and so
// java.lang.Object is the only possible superclass
return classPath.getClass("Ljava/lang/Object;");
}
return this;
}
@Nonnull @Override public String getType() {
// use the otherwise used U prefix for an unknown/unresolvable class
return "Ujava/lang/Object;";
}
@Override
@Nullable
public FieldReference getFieldByOffset(int fieldOffset) {
return classPath.getClass("Ljava/lang/Object;").getFieldByOffset(fieldOffset);
}
@Override
@Nullable | public Method getMethodByVtableIndex(int vtableIndex) { |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/util/BindUtil.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
//
// OneTypeItemSource source;
// LayoutInflater inflater;
// ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
// @Override
// public void onChanged(ObservableList observableList) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
// };
//
// public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
// this.source = source;
// this.inflater = inflater;
// if(this.source.items != null) {
// this.source.items.removeOnListChangedCallback(callback);
// this.source.items.addOnListChangedCallback(callback);
// }
// }
//
// @Override
// public int getCount() {
// return source == null || source.items == null ? 0 : source.items.size();
// }
//
// @Override
// public Object getItem(int i) {
// return source == null || source.items == null ? null : source.items.get(i);
// }
//
// @Override
// public long getItemId(int i) {
// return i;
// }
//
// @Override
// public View getView(int i, View view, ViewGroup viewGroup) {
// ViewDataBinding binding;
// PositionListeners pl;
// if(view != null) {
// binding = (ViewDataBinding) view.getTag(R.id.binding);
// pl = (PositionListeners) view.getTag(R.id.pl);
// } else {
// view = inflater.inflate(source.itemViewId, null);
// binding = DataBindingUtil.bind(view);
// view.setTag(R.id.binding, binding);
// pl = new PositionListeners();
// pl.listeners = source.listeners;
// view.setTag(R.id.pl, pl);
// }
// binding.setVariable(BR.item, getItem(i));
// try {
// pl.position = i;
// binding.setVariable(BR.pl, pl);
// } catch (Exception e){}
// return view;
// }
// }
| import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter; | package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-24.
*/
public class BindUtil {
@BindingAdapter("oneTypeSource") | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
//
// OneTypeItemSource source;
// LayoutInflater inflater;
// ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
// @Override
// public void onChanged(ObservableList observableList) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
// };
//
// public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
// this.source = source;
// this.inflater = inflater;
// if(this.source.items != null) {
// this.source.items.removeOnListChangedCallback(callback);
// this.source.items.addOnListChangedCallback(callback);
// }
// }
//
// @Override
// public int getCount() {
// return source == null || source.items == null ? 0 : source.items.size();
// }
//
// @Override
// public Object getItem(int i) {
// return source == null || source.items == null ? null : source.items.get(i);
// }
//
// @Override
// public long getItemId(int i) {
// return i;
// }
//
// @Override
// public View getView(int i, View view, ViewGroup viewGroup) {
// ViewDataBinding binding;
// PositionListeners pl;
// if(view != null) {
// binding = (ViewDataBinding) view.getTag(R.id.binding);
// pl = (PositionListeners) view.getTag(R.id.pl);
// } else {
// view = inflater.inflate(source.itemViewId, null);
// binding = DataBindingUtil.bind(view);
// view.setTag(R.id.binding, binding);
// pl = new PositionListeners();
// pl.listeners = source.listeners;
// view.setTag(R.id.pl, pl);
// }
// binding.setVariable(BR.item, getItem(i));
// try {
// pl.position = i;
// binding.setVariable(BR.pl, pl);
// } catch (Exception e){}
// return view;
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/BindUtil.java
import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter;
package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-24.
*/
public class BindUtil {
@BindingAdapter("oneTypeSource") | public static void setOneTypeSource(ListView view, OneTypeItemSource source) { |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/util/BindUtil.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
//
// OneTypeItemSource source;
// LayoutInflater inflater;
// ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
// @Override
// public void onChanged(ObservableList observableList) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
// };
//
// public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
// this.source = source;
// this.inflater = inflater;
// if(this.source.items != null) {
// this.source.items.removeOnListChangedCallback(callback);
// this.source.items.addOnListChangedCallback(callback);
// }
// }
//
// @Override
// public int getCount() {
// return source == null || source.items == null ? 0 : source.items.size();
// }
//
// @Override
// public Object getItem(int i) {
// return source == null || source.items == null ? null : source.items.get(i);
// }
//
// @Override
// public long getItemId(int i) {
// return i;
// }
//
// @Override
// public View getView(int i, View view, ViewGroup viewGroup) {
// ViewDataBinding binding;
// PositionListeners pl;
// if(view != null) {
// binding = (ViewDataBinding) view.getTag(R.id.binding);
// pl = (PositionListeners) view.getTag(R.id.pl);
// } else {
// view = inflater.inflate(source.itemViewId, null);
// binding = DataBindingUtil.bind(view);
// view.setTag(R.id.binding, binding);
// pl = new PositionListeners();
// pl.listeners = source.listeners;
// view.setTag(R.id.pl, pl);
// }
// binding.setVariable(BR.item, getItem(i));
// try {
// pl.position = i;
// binding.setVariable(BR.pl, pl);
// } catch (Exception e){}
// return view;
// }
// }
| import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter; | package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-24.
*/
public class BindUtil {
@BindingAdapter("oneTypeSource")
public static void setOneTypeSource(ListView view, OneTypeItemSource source) { | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
//
// OneTypeItemSource source;
// LayoutInflater inflater;
// ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
// @Override
// public void onChanged(ObservableList observableList) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
// notifyDataSetChanged();
// }
//
// @Override
// public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
// notifyDataSetChanged();
// }
// };
//
// public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
// this.source = source;
// this.inflater = inflater;
// if(this.source.items != null) {
// this.source.items.removeOnListChangedCallback(callback);
// this.source.items.addOnListChangedCallback(callback);
// }
// }
//
// @Override
// public int getCount() {
// return source == null || source.items == null ? 0 : source.items.size();
// }
//
// @Override
// public Object getItem(int i) {
// return source == null || source.items == null ? null : source.items.get(i);
// }
//
// @Override
// public long getItemId(int i) {
// return i;
// }
//
// @Override
// public View getView(int i, View view, ViewGroup viewGroup) {
// ViewDataBinding binding;
// PositionListeners pl;
// if(view != null) {
// binding = (ViewDataBinding) view.getTag(R.id.binding);
// pl = (PositionListeners) view.getTag(R.id.pl);
// } else {
// view = inflater.inflate(source.itemViewId, null);
// binding = DataBindingUtil.bind(view);
// view.setTag(R.id.binding, binding);
// pl = new PositionListeners();
// pl.listeners = source.listeners;
// view.setTag(R.id.pl, pl);
// }
// binding.setVariable(BR.item, getItem(i));
// try {
// pl.position = i;
// binding.setVariable(BR.pl, pl);
// } catch (Exception e){}
// return view;
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/BindUtil.java
import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter;
package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-24.
*/
public class BindUtil {
@BindingAdapter("oneTypeSource")
public static void setOneTypeSource(ListView view, OneTypeItemSource source) { | OneTypeItemSourceListAdapter adapter = new OneTypeItemSourceListAdapter(source, LayoutInflater.from(view.getContext())); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/HelloService.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo;
/**
* Created by discotek on 17-1-16.
*/
public class HelloService extends Service {
Binder binder;
@Nullable
@Override
public IBinder onBind(Intent intent) { | // Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/HelloService.java
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo;
/**
* Created by discotek on 17-1-16.
*/
public class HelloService extends Service {
Binder binder;
@Nullable
@Override
public IBinder onBind(Intent intent) { | ToastUtil.toast(R.string.service_bound); |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/ServiceHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor; | package link.anyauto.smartkey.apt;
public class ServiceHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ServiceHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
| // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/ServiceHandler.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
package link.anyauto.smartkey.apt;
public class ServiceHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ServiceHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
| public void addType(TargetDescriptor des) { |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/ServiceHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor; | package link.anyauto.smartkey.apt;
public class ServiceHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ServiceHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(TargetDescriptor des) {
ClassName serviceType = ClassName.bestGuess(des.name); | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/ServiceHandler.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
package link.anyauto.smartkey.apt;
public class ServiceHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ServiceHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(TargetDescriptor des) {
ClassName serviceType = ClassName.bestGuess(des.name); | ClassName builderName = ClassName.bestGuess(des.name + AnnotationConstants.SUFFIX_SERVICE_TARGET); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/prefs/MyAppPreferences.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyObject.java
// public class MyObject {
// public String haha;
// }
| import java.util.ArrayList;
import link.anyauto.smartkey.annotation.Code;
import link.anyauto.smartkey.annotation.SmartSharedPreferences;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.objects.MyObject; | package link.anyauto.smartkey.demo.prefs;
/**
* Created by discotek on 17-1-8.
*/
@SmartSharedPreferences
public class MyAppPreferences {
public int openTimes;
public String lastVersion;
public String selectedCity;
| // Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyObject.java
// public class MyObject {
// public String haha;
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/prefs/MyAppPreferences.java
import java.util.ArrayList;
import link.anyauto.smartkey.annotation.Code;
import link.anyauto.smartkey.annotation.SmartSharedPreferences;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.objects.MyObject;
package link.anyauto.smartkey.demo.prefs;
/**
* Created by discotek on 17-1-8.
*/
@SmartSharedPreferences
public class MyAppPreferences {
public int openTimes;
public String lastVersion;
public String selectedCity;
| public MyObject myObject; |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/prefs/MyAppPreferences.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyObject.java
// public class MyObject {
// public String haha;
// }
| import java.util.ArrayList;
import link.anyauto.smartkey.annotation.Code;
import link.anyauto.smartkey.annotation.SmartSharedPreferences;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.objects.MyObject; | package link.anyauto.smartkey.demo.prefs;
/**
* Created by discotek on 17-1-8.
*/
@SmartSharedPreferences
public class MyAppPreferences {
public int openTimes;
public String lastVersion;
public String selectedCity;
public MyObject myObject;
@Code(isGeneric = true, genericTypes = {"$T<$T>", "java.util.ArrayList", "link.anyauto.smartkey.demo.objects.MyContact"}) | // Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyObject.java
// public class MyObject {
// public String haha;
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/prefs/MyAppPreferences.java
import java.util.ArrayList;
import link.anyauto.smartkey.annotation.Code;
import link.anyauto.smartkey.annotation.SmartSharedPreferences;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.objects.MyObject;
package link.anyauto.smartkey.demo.prefs;
/**
* Created by discotek on 17-1-8.
*/
@SmartSharedPreferences
public class MyAppPreferences {
public int openTimes;
public String lastVersion;
public String selectedCity;
public MyObject myObject;
@Code(isGeneric = true, genericTypes = {"$T<$T>", "java.util.ArrayList", "link.anyauto.smartkey.demo.objects.MyContact"}) | public ArrayList<MyContact> contacts; |
foreveruseful/smartkey | sdks/src/main/java/link/anyauto/smartkey/sdks/targets/Target.java | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/OnPrepareIntentCallback.java
// public interface OnPrepareIntentCallback {
// /**
// * <pre>
// * When using the generated SmartTargets,
// * this is the callback that will be called just before
// * going to another activity or starting a service.
// * </pre>
// * @param intent
// */
// void prepare(Intent intent);
// }
| import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import link.anyauto.smartkey.sdks.IntentKeyMapper;
import link.anyauto.smartkey.sdks.OnPrepareIntentCallback; | package link.anyauto.smartkey.sdks.targets;
/**
* An activity or a service description.
* @param <T>
* the target generic type.
*/
public abstract class Target<T> {
/**
* flags to add to the intent.
*/
protected int flags;
/**
* the values wrapped in the generated IntentBuilder.
*/ | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/OnPrepareIntentCallback.java
// public interface OnPrepareIntentCallback {
// /**
// * <pre>
// * When using the generated SmartTargets,
// * this is the callback that will be called just before
// * going to another activity or starting a service.
// * </pre>
// * @param intent
// */
// void prepare(Intent intent);
// }
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/Target.java
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import link.anyauto.smartkey.sdks.IntentKeyMapper;
import link.anyauto.smartkey.sdks.OnPrepareIntentCallback;
package link.anyauto.smartkey.sdks.targets;
/**
* An activity or a service description.
* @param <T>
* the target generic type.
*/
public abstract class Target<T> {
/**
* flags to add to the intent.
*/
protected int flags;
/**
* the values wrapped in the generated IntentBuilder.
*/ | protected IntentKeyMapper params; |
foreveruseful/smartkey | sdks/src/main/java/link/anyauto/smartkey/sdks/targets/Target.java | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/OnPrepareIntentCallback.java
// public interface OnPrepareIntentCallback {
// /**
// * <pre>
// * When using the generated SmartTargets,
// * this is the callback that will be called just before
// * going to another activity or starting a service.
// * </pre>
// * @param intent
// */
// void prepare(Intent intent);
// }
| import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import link.anyauto.smartkey.sdks.IntentKeyMapper;
import link.anyauto.smartkey.sdks.OnPrepareIntentCallback; | package link.anyauto.smartkey.sdks.targets;
/**
* An activity or a service description.
* @param <T>
* the target generic type.
*/
public abstract class Target<T> {
/**
* flags to add to the intent.
*/
protected int flags;
/**
* the values wrapped in the generated IntentBuilder.
*/
protected IntentKeyMapper params;
/**
* MIME TYPE of the intent
*/
protected String mimeType;
/**
* ClipData
*/
protected ClipData clipData;
/**
* The callback which allows you to add a finishing touches on the intent.
*/ | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/OnPrepareIntentCallback.java
// public interface OnPrepareIntentCallback {
// /**
// * <pre>
// * When using the generated SmartTargets,
// * this is the callback that will be called just before
// * going to another activity or starting a service.
// * </pre>
// * @param intent
// */
// void prepare(Intent intent);
// }
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/Target.java
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import link.anyauto.smartkey.sdks.IntentKeyMapper;
import link.anyauto.smartkey.sdks.OnPrepareIntentCallback;
package link.anyauto.smartkey.sdks.targets;
/**
* An activity or a service description.
* @param <T>
* the target generic type.
*/
public abstract class Target<T> {
/**
* flags to add to the intent.
*/
protected int flags;
/**
* the values wrapped in the generated IntentBuilder.
*/
protected IntentKeyMapper params;
/**
* MIME TYPE of the intent
*/
protected String mimeType;
/**
* ClipData
*/
protected ClipData clipData;
/**
* The callback which allows you to add a finishing touches on the intent.
*/ | protected OnPrepareIntentCallback callback; |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/SharePreferenceGenerator.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartSharedPreferences; | package link.anyauto.smartkey.apt;
/**
* <pre>
* Generate helper classes and methods for manipulating shared preferences.
* Recommend way:
* Write only one class describing all data needed for the whole application,
* then read and write anything through the generated class' helper methods.
* </pre>
*/
public class SharePreferenceGenerator extends Generator {
public SharePreferenceGenerator(ProcessingEnvironment env) {
super(env);
smartClz = SmartSharedPreferences.class;
}
@Override
protected void genClass(ClassDescription des) { | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/SharePreferenceGenerator.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartSharedPreferences;
package link.anyauto.smartkey.apt;
/**
* <pre>
* Generate helper classes and methods for manipulating shared preferences.
* Recommend way:
* Write only one class describing all data needed for the whole application,
* then read and write anything through the generated class' helper methods.
* </pre>
*/
public class SharePreferenceGenerator extends Generator {
public SharePreferenceGenerator(ProcessingEnvironment env) {
super(env);
smartClz = SmartSharedPreferences.class;
}
@Override
protected void genClass(ClassDescription des) { | String clzName = des.simpleClzName + AnnotationConstants.SUFFIX_SHARED_PREFERENCES_BUILDER; |
foreveruseful/smartkey | sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
| import android.app.Activity;
import android.content.Intent;
import link.anyauto.smartkey.sdks.IntentKeyMapper; | package link.anyauto.smartkey.sdks.targets;
/**
* Util for wrapping result when an activity finishes.
* Created by LYQ on 17-1-18.
*/
public class BackResult {
int code = Activity.RESULT_OK;
Intent intent; | // Path: sdks/src/main/java/link/anyauto/smartkey/sdks/IntentKeyMapper.java
// public interface IntentKeyMapper {
// /**
// * Build an Intent with the values of the IntentBuilder.
// * @return
// */
// Intent buildIntent();
// }
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java
import android.app.Activity;
import android.content.Intent;
import link.anyauto.smartkey.sdks.IntentKeyMapper;
package link.anyauto.smartkey.sdks.targets;
/**
* Util for wrapping result when an activity finishes.
* Created by LYQ on 17-1-18.
*/
public class BackResult {
int code = Activity.RESULT_OK;
Intent intent; | IntentKeyMapper params; |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/share/ShareVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.app.Activity;
import android.content.Intent;
import android.databinding.ObservableArrayMap;
import android.net.Uri;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo.share;
/**
* Created by discotek on 17-1-27.
*/
public class ShareVM extends BaseVMAdapter {
static final int REQ_PICK_PIC = 1;
int pickPosition;
public ObservableArrayMap<Integer, Uri> pics = new ObservableArrayMap<>();
public ShareVM(Activity activity) {
setActivity(activity);
}
public void pick(int position) {
SmartTargets.toNotDeterminedActivityTarget()
.action(Intent.ACTION_GET_CONTENT)
.mimeType("image/*")
.goForResult(activity, REQ_PICK_PIC);
pickPosition = position;
}
public void shareOne() {
Uri uri = null;
for(Uri u : pics.values()) {
uri = u;
break;
}
if(uri == null) { | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/share/ShareVM.java
import android.app.Activity;
import android.content.Intent;
import android.databinding.ObservableArrayMap;
import android.net.Uri;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo.share;
/**
* Created by discotek on 17-1-27.
*/
public class ShareVM extends BaseVMAdapter {
static final int REQ_PICK_PIC = 1;
int pickPosition;
public ObservableArrayMap<Integer, Uri> pics = new ObservableArrayMap<>();
public ShareVM(Activity activity) {
setActivity(activity);
}
public void pick(int position) {
SmartTargets.toNotDeterminedActivityTarget()
.action(Intent.ACTION_GET_CONTENT)
.mimeType("image/*")
.goForResult(activity, REQ_PICK_PIC);
pickPosition = position;
}
public void shareOne() {
Uri uri = null;
for(Uri u : pics.values()) {
uri = u;
break;
}
if(uri == null) { | ToastUtil.toast(R.string.select_pics_please); |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/ManifestHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
| import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.ArrayList;
import link.anyauto.smartkey.annotation.AnnotationConstants; | package link.anyauto.smartkey.apt.manifestanalyzer;
public class ManifestHandler extends DefaultHandler {
static final String MANIFEST = "manifest";
static final String APP = "application"; | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/ManifestHandler.java
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.ArrayList;
import link.anyauto.smartkey.annotation.AnnotationConstants;
package link.anyauto.smartkey.apt.manifestanalyzer;
public class ManifestHandler extends DefaultHandler {
static final String MANIFEST = "manifest";
static final String APP = "application"; | static final String ACT = AnnotationConstants.TARGET_TYPE_ACTIVITY; |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter; | package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName); | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter;
package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName); | ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_ACTIVITY_TARGET); |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter; | package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName);
ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.simpleClzName, des.clzName, activityType, builderName, des.clz.getAnnotation(SmartTarget.class).req());
}
| // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter;
package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName);
ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.simpleClzName, des.clzName, activityType, builderName, des.clz.getAnnotation(SmartTarget.class).req());
}
| public void addType(TargetDescriptor des) { |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter; | package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName);
ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.simpleClzName, des.clzName, activityType, builderName, des.clz.getAnnotation(SmartTarget.class).req());
}
public void addType(TargetDescriptor des) {
TypeSpec.Builder type = types.get(des.name);
if (type == null) {
ClassName activityType = ClassName.bestGuess(des.name);
ClassName builderName = ClassName.bestGuess(des.name + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.getSimpleName(), des.name, activityType, builderName, null);
}
if (des.filters.isEmpty() || des.filters.get(0).actions.isEmpty()) {
return;
} | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetDescriptor.java
// public class TargetDescriptor {
// public String name;
// public String aliasName;
// public ArrayList<TargetFilter> filters = new ArrayList<>();
//
// public String getSimpleName() {
// return name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// Path: apt/src/main/java/link/anyauto/smartkey/apt/manifestanalyzer/TargetFilter.java
// public class TargetFilter {
// public ArrayList<String> categories = new ArrayList<>();
// public ArrayList<String> actions = new ArrayList<>();
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/ActivityHandler.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.HashMap;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartTarget;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetDescriptor;
import link.anyauto.smartkey.apt.manifestanalyzer.TargetFilter;
package link.anyauto.smartkey.apt;
public class ActivityHandler {
TypeSpec.Builder smartTargets;
HashMap<String, TypeSpec.Builder> types;
public ActivityHandler(TypeSpec.Builder smartTargets, HashMap<String, TypeSpec.Builder> typesHolder) {
this.smartTargets = smartTargets;
types = typesHolder;
}
public void addType(ClassDescription des) {
ClassName activityType = ClassName.get(des.pkgName, des.simpleClzName);
ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.simpleClzName, des.clzName, activityType, builderName, des.clz.getAnnotation(SmartTarget.class).req());
}
public void addType(TargetDescriptor des) {
TypeSpec.Builder type = types.get(des.name);
if (type == null) {
ClassName activityType = ClassName.bestGuess(des.name);
ClassName builderName = ClassName.bestGuess(des.name + AnnotationConstants.SUFFIX_ACTIVITY_TARGET);
addType(des.getSimpleName(), des.name, activityType, builderName, null);
}
if (des.filters.isEmpty() || des.filters.get(0).actions.isEmpty()) {
return;
} | for (TargetFilter filter : des.filters) { |
foreveruseful/smartkey | apt/src/main/java/link/anyauto/smartkey/apt/IntentGenerator.java | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
| import com.squareup.javapoet.ClassName;
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 java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartIntent; | package link.anyauto.smartkey.apt;
public class IntentGenerator extends Generator {
public IntentGenerator(ProcessingEnvironment environment) {
super(environment);
smartClz = SmartIntent.class;
}
protected void genClass(ClassDescription des) { | // Path: annotation/src/main/java/link/anyauto/smartkey/annotation/AnnotationConstants.java
// public class AnnotationConstants {
// public static final String SUFFIX_INTENT_BUILDER = "IBuilder";
// public static final String SUFFIX_SHARED_PREFERENCES_BUILDER = "SPBuilder";
// public static final String SUFFIX_ACTIVITY_TARGET = "ATarget";
// public static final String SUFFIX_SERVICE_TARGET = "STarget";
//
// public static final String TARGET_TYPE_ACTIVITY = "activity";
// public static final String TARGET_TYPE_ACTIVITY_ALIAS = "activity-alias";
// public static final String TARGET_TYPE_SERVICE = "service";
// }
// Path: apt/src/main/java/link/anyauto/smartkey/apt/IntentGenerator.java
import com.squareup.javapoet.ClassName;
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 java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import link.anyauto.smartkey.annotation.AnnotationConstants;
import link.anyauto.smartkey.annotation.SmartIntent;
package link.anyauto.smartkey.apt;
public class IntentGenerator extends Generator {
public IntentGenerator(ProcessingEnvironment environment) {
super(environment);
smartClz = SmartIntent.class;
}
protected void genClass(ClassDescription des) { | ClassName builderName = ClassName.get(des.pkgName, des.simpleClzName + AnnotationConstants.SUFFIX_INTENT_BUILDER); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/forresult/ForResultVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultReq.java
// @SmartIntent
// public class ForResultReq {
// public String title;
// public String label;
// public String hint;
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java
// public class BackResult {
// int code = Activity.RESULT_OK;
// Intent intent;
// IntentKeyMapper params;
//
// /**
// * Create a back result, default result code is RESULT_OK.
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult() {
// return new BackResult();
// }
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult(int resultCode) {
// return new BackResult(resultCode);
// }
//
// /**
// * Create a back result, default result code is RESULT_OK.
// */
// public BackResult(){}
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// */
// public BackResult(int resultCode) {
// code = resultCode;
// }
//
// /**
// * An intent to send back by this result
// * @param intent
// * the intent
// * @return
// * this
// */
// public BackResult intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// /**
// * Set result code other than default.
// * @param resultCode
// * the result code
// * @return
// * this
// */
// public BackResult resultCode(int resultCode) {
// code = resultCode;
// return this;
// }
//
// /**
// * Params that will send back by this result.
// * @param params
// * the params
// * @return
// * this
// */
// public BackResult params(IntentKeyMapper params) {
// this.params = params;
// return this;
// }
//
// /**
// * Finish the activity with your given result code and or intent and or params.
// * @param activity
// * The activity that will be finish, it's finish() will be called in this method.
// */
// public void finishWithResult(Activity activity) {
// Intent in = intent;
// if(params != null) {
// in = in == null ? params.buildIntent() : in.putExtras(params.buildIntent().getExtras());
// }
// if(in != null) {
// activity.setResult(code, in);
// } else {
// activity.setResult(code);
// }
// activity.finish();;
// }
// }
| import android.app.Activity;
import android.databinding.Bindable;
import link.anyauto.smartkey.demo.BR;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReq;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.sdks.targets.BackResult; | package link.anyauto.smartkey.demo.forresult;
public class ForResultVM extends BaseVMAdapter {
public ForResultVM(Activity activity) {
setActivity(activity);
// Getting values in this very easy way | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultReq.java
// @SmartIntent
// public class ForResultReq {
// public String title;
// public String label;
// public String hint;
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java
// public class BackResult {
// int code = Activity.RESULT_OK;
// Intent intent;
// IntentKeyMapper params;
//
// /**
// * Create a back result, default result code is RESULT_OK.
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult() {
// return new BackResult();
// }
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult(int resultCode) {
// return new BackResult(resultCode);
// }
//
// /**
// * Create a back result, default result code is RESULT_OK.
// */
// public BackResult(){}
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// */
// public BackResult(int resultCode) {
// code = resultCode;
// }
//
// /**
// * An intent to send back by this result
// * @param intent
// * the intent
// * @return
// * this
// */
// public BackResult intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// /**
// * Set result code other than default.
// * @param resultCode
// * the result code
// * @return
// * this
// */
// public BackResult resultCode(int resultCode) {
// code = resultCode;
// return this;
// }
//
// /**
// * Params that will send back by this result.
// * @param params
// * the params
// * @return
// * this
// */
// public BackResult params(IntentKeyMapper params) {
// this.params = params;
// return this;
// }
//
// /**
// * Finish the activity with your given result code and or intent and or params.
// * @param activity
// * The activity that will be finish, it's finish() will be called in this method.
// */
// public void finishWithResult(Activity activity) {
// Intent in = intent;
// if(params != null) {
// in = in == null ? params.buildIntent() : in.putExtras(params.buildIntent().getExtras());
// }
// if(in != null) {
// activity.setResult(code, in);
// } else {
// activity.setResult(code);
// }
// activity.finish();;
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/forresult/ForResultVM.java
import android.app.Activity;
import android.databinding.Bindable;
import link.anyauto.smartkey.demo.BR;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReq;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.sdks.targets.BackResult;
package link.anyauto.smartkey.demo.forresult;
public class ForResultVM extends BaseVMAdapter {
public ForResultVM(Activity activity) {
setActivity(activity);
// Getting values in this very easy way | ForResultReq req = ForResultReqIBuilder.getSmart(activity.getIntent()); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/forresult/ForResultVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultReq.java
// @SmartIntent
// public class ForResultReq {
// public String title;
// public String label;
// public String hint;
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java
// public class BackResult {
// int code = Activity.RESULT_OK;
// Intent intent;
// IntentKeyMapper params;
//
// /**
// * Create a back result, default result code is RESULT_OK.
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult() {
// return new BackResult();
// }
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult(int resultCode) {
// return new BackResult(resultCode);
// }
//
// /**
// * Create a back result, default result code is RESULT_OK.
// */
// public BackResult(){}
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// */
// public BackResult(int resultCode) {
// code = resultCode;
// }
//
// /**
// * An intent to send back by this result
// * @param intent
// * the intent
// * @return
// * this
// */
// public BackResult intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// /**
// * Set result code other than default.
// * @param resultCode
// * the result code
// * @return
// * this
// */
// public BackResult resultCode(int resultCode) {
// code = resultCode;
// return this;
// }
//
// /**
// * Params that will send back by this result.
// * @param params
// * the params
// * @return
// * this
// */
// public BackResult params(IntentKeyMapper params) {
// this.params = params;
// return this;
// }
//
// /**
// * Finish the activity with your given result code and or intent and or params.
// * @param activity
// * The activity that will be finish, it's finish() will be called in this method.
// */
// public void finishWithResult(Activity activity) {
// Intent in = intent;
// if(params != null) {
// in = in == null ? params.buildIntent() : in.putExtras(params.buildIntent().getExtras());
// }
// if(in != null) {
// activity.setResult(code, in);
// } else {
// activity.setResult(code);
// }
// activity.finish();;
// }
// }
| import android.app.Activity;
import android.databinding.Bindable;
import link.anyauto.smartkey.demo.BR;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReq;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.sdks.targets.BackResult; | public String label;
public String hint;
public String getInput() {
return input;
}
public void setInput(String input) {
if(this.input == null || !this.input.equals(input)) {
this.input = input;
notifyPropertyChanged(BR.input);
}
}
public String getInput2() {
return input2;
}
public void setInput2(String input2) {
if(this.input2 == null || !this.input2.equals(input2)) {
this.input2 = input2;
notifyPropertyChanged(BR.input2);
}
}
public void confirm() {
// Yes, it is so easy to return values back to the caller.
// No need to call set result, no need to put values into intent yourself.
// The same as passing values to another activity when start. | // Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultReq.java
// @SmartIntent
// public class ForResultReq {
// public String title;
// public String label;
// public String hint;
// }
//
// Path: sdks/src/main/java/link/anyauto/smartkey/sdks/targets/BackResult.java
// public class BackResult {
// int code = Activity.RESULT_OK;
// Intent intent;
// IntentKeyMapper params;
//
// /**
// * Create a back result, default result code is RESULT_OK.
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult() {
// return new BackResult();
// }
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// * @return
// * the new BackResult instance.
// */
// public static BackResult newBackResult(int resultCode) {
// return new BackResult(resultCode);
// }
//
// /**
// * Create a back result, default result code is RESULT_OK.
// */
// public BackResult(){}
//
// /**
// * Create a back result with the given result code.
// * @param resultCode
// * the result code
// */
// public BackResult(int resultCode) {
// code = resultCode;
// }
//
// /**
// * An intent to send back by this result
// * @param intent
// * the intent
// * @return
// * this
// */
// public BackResult intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// /**
// * Set result code other than default.
// * @param resultCode
// * the result code
// * @return
// * this
// */
// public BackResult resultCode(int resultCode) {
// code = resultCode;
// return this;
// }
//
// /**
// * Params that will send back by this result.
// * @param params
// * the params
// * @return
// * this
// */
// public BackResult params(IntentKeyMapper params) {
// this.params = params;
// return this;
// }
//
// /**
// * Finish the activity with your given result code and or intent and or params.
// * @param activity
// * The activity that will be finish, it's finish() will be called in this method.
// */
// public void finishWithResult(Activity activity) {
// Intent in = intent;
// if(params != null) {
// in = in == null ? params.buildIntent() : in.putExtras(params.buildIntent().getExtras());
// }
// if(in != null) {
// activity.setResult(code, in);
// } else {
// activity.setResult(code);
// }
// activity.finish();;
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/forresult/ForResultVM.java
import android.app.Activity;
import android.databinding.Bindable;
import link.anyauto.smartkey.demo.BR;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReq;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.sdks.targets.BackResult;
public String label;
public String hint;
public String getInput() {
return input;
}
public void setInput(String input) {
if(this.input == null || !this.input.equals(input)) {
this.input = input;
notifyPropertyChanged(BR.input);
}
}
public String getInput2() {
return input2;
}
public void setInput2(String input2) {
if(this.input2 == null || !this.input2.equals(input2)) {
this.input2 = input2;
notifyPropertyChanged(BR.input2);
}
}
public void confirm() {
// Yes, it is so easy to return values back to the caller.
// No need to call set result, no need to put values into intent yourself.
// The same as passing values to another activity when start. | BackResult |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class FillFormVM extends BaseVMAdapter {
public ObservableField<String> name = new ObservableField<>();
public ObservableField<String> mobile = new ObservableField<>();
public ObservableField<String> addr = new ObservableField<>();
public ObservableField<String> counts = new ObservableField<>();
| // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java
import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class FillFormVM extends BaseVMAdapter {
public ObservableField<String> name = new ObservableField<>();
public ObservableField<String> mobile = new ObservableField<>();
public ObservableField<String> addr = new ObservableField<>();
public ObservableField<String> counts = new ObservableField<>();
| ArrayList<MyContact> contacts; |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class FillFormVM extends BaseVMAdapter {
public ObservableField<String> name = new ObservableField<>();
public ObservableField<String> mobile = new ObservableField<>();
public ObservableField<String> addr = new ObservableField<>();
public ObservableField<String> counts = new ObservableField<>();
ArrayList<MyContact> contacts;
public FillFormVM(Activity activity) {
setActivity(activity);
updateCounts();
}
public void viewContacts() {
SmartTargets.toShowFilledFormsActivityATarget().go(activity);
}
public void confirm() {
if(saveContact()) {
viewContacts();
} else { | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java
import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class FillFormVM extends BaseVMAdapter {
public ObservableField<String> name = new ObservableField<>();
public ObservableField<String> mobile = new ObservableField<>();
public ObservableField<String> addr = new ObservableField<>();
public ObservableField<String> counts = new ObservableField<>();
ArrayList<MyContact> contacts;
public FillFormVM(Activity activity) {
setActivity(activity);
updateCounts();
}
public void viewContacts() {
SmartTargets.toShowFilledFormsActivityATarget().go(activity);
}
public void confirm() {
if(saveContact()) {
viewContacts();
} else { | ToastUtil.toast(R.string.input_name_mobile_tips); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil; | viewContacts();
} else {
ToastUtil.toast(R.string.input_name_mobile_tips);
}
}
@Override
public void resume() {
updateCounts();
}
boolean saveContact() {
if(TextUtils.isEmpty(name.get()) || TextUtils.isEmpty(mobile.get())) {
return false;
}
MyContact contact = new MyContact();
contact.name = name.get();
contact.mobile = mobile.get();
contact.addr = addr.get();
contacts.add(contact);
MyAppPreferencesSPBuilder.contacts(contacts);
updateCounts();
return true;
}
void updateCounts() {
contacts = MyAppPreferencesSPBuilder.contacts();
if(contacts == null) {
contacts = new ArrayList<>();
} | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/fillform/FillFormVM.java
import android.app.Activity;
import android.databinding.ObservableField;
import android.text.TextUtils;
import java.util.ArrayList;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
viewContacts();
} else {
ToastUtil.toast(R.string.input_name_mobile_tips);
}
}
@Override
public void resume() {
updateCounts();
}
boolean saveContact() {
if(TextUtils.isEmpty(name.get()) || TextUtils.isEmpty(mobile.get())) {
return false;
}
MyContact contact = new MyContact();
contact.name = name.get();
contact.mobile = mobile.get();
contact.addr = addr.get();
contacts.add(contact);
MyAppPreferencesSPBuilder.contacts(contacts);
updateCounts();
return true;
}
void updateCounts() {
contacts = MyAppPreferencesSPBuilder.contacts();
if(contacts == null) {
contacts = new ArrayList<>();
} | counts.set(App.getStr(R.string.contacts_total_label, contacts.size())); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
| import android.view.LayoutInflater;
import android.widget.Toast;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.databinding.ToastLayoutBinding; | package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-22.
*/
public class ToastUtil {
static Toast toast;
static ToastLayoutBinding binding;
public static void toast(int resId) {
binding.toast.setText(resId);
toast.show();
}
public static void toast(String str) {
binding.toast.setText(str);
toast.show();
}
static void makeToast() {
if(toast == null) { | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
import android.view.LayoutInflater;
import android.widget.Toast;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.databinding.ToastLayoutBinding;
package link.anyauto.smartkey.demo.util;
/**
* Created by discotek on 17-1-22.
*/
public class ToastUtil {
static Toast toast;
static ToastLayoutBinding binding;
public static void toast(int resId) {
binding.toast.setText(resId);
toast.show();
}
public static void toast(String str) {
binding.toast.setText(str);
toast.show();
}
static void makeToast() {
if(toast == null) { | toast = new Toast(App.getInstance()); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK; | package link.anyauto.smartkey.demo.main;
/**
* Created by discotek on 17-1-22.
*/
public class MainVM extends BaseVMAdapter {
public static final int REQ_CODE_FOR_RESULT = 1;
ServiceConnection sc = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) { | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK;
package link.anyauto.smartkey.demo.main;
/**
* Created by discotek on 17-1-22.
*/
public class MainVM extends BaseVMAdapter {
public static final int REQ_CODE_FOR_RESULT = 1;
ServiceConnection sc = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) { | ToastUtil.toast(R.string.bound_success); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK; | package link.anyauto.smartkey.demo.main;
/**
* Created by discotek on 17-1-22.
*/
public class MainVM extends BaseVMAdapter {
public static final int REQ_CODE_FOR_RESULT = 1;
ServiceConnection sc = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
ToastUtil.toast(R.string.bound_success);
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
ToastUtil.toast(R.string.disconnected);
}
};
public String getOpenTimesLabel() { | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK;
package link.anyauto.smartkey.demo.main;
/**
* Created by discotek on 17-1-22.
*/
public class MainVM extends BaseVMAdapter {
public static final int REQ_CODE_FOR_RESULT = 1;
ServiceConnection sc = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
ToastUtil.toast(R.string.bound_success);
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
ToastUtil.toast(R.string.disconnected);
}
};
public String getOpenTimesLabel() { | return App.getStr(R.string.app_opened_times, MyAppPreferencesSPBuilder.openTimes()); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK; |
public void startService() {
// demo on starting a service
SmartTargets.toHelloServiceSTarget().start(activity);
}
public void bindService() {
// demo on binding a service // a service should be started first before it can be bound
SmartTargets.toHelloServiceSTarget().bind(activity, sc, 0);
}
public void stopService() {
// demo on stopping a service
SmartTargets.toHelloServiceSTarget().stop(activity);
}
@Override
public void destroy() {
try {
activity.unbindService(sc);
} catch (Exception e){
e.printStackTrace();
}
SmartTargets.toHelloServiceSTarget().stop(activity);
}
@Override
public void result(int reqCode, int resCode, Intent data) {
if(reqCode == REQ_CODE_FOR_RESULT && resCode == RESULT_OK) {
// Yes, easy right? One line of code will get all your data from result source very smartly. | // Path: app/src/main/java/link/anyauto/smartkey/demo/App.java
// @SmartManifest(manifestPath = "app/src/main/AndroidManifest.xml")
// public class App extends Application {
//
// protected static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// MyAppPreferencesSPBuilder.setApp(this);
// checkVersion();
// }
//
// void checkVersion() {
//
// }
//
// public static String getStr(int resId) {
// return instance.getString(resId);
// }
//
// public static String getStr(int resId, Object ...args) {
// return instance.getString(resId, args);
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/extras/ForResultRes.java
// @SmartIntent
// public class ForResultRes {
// public String input;
// public String input2;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/main/MainVM.java
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import link.anyauto.smartkey.demo.App;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.extras.ForResultReqIBuilder;
import link.anyauto.smartkey.demo.extras.ForResultRes;
import link.anyauto.smartkey.demo.extras.ForResultResIBuilder;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.targets.SmartTargets;
import link.anyauto.smartkey.demo.util.ToastUtil;
import static android.app.Activity.RESULT_OK;
public void startService() {
// demo on starting a service
SmartTargets.toHelloServiceSTarget().start(activity);
}
public void bindService() {
// demo on binding a service // a service should be started first before it can be bound
SmartTargets.toHelloServiceSTarget().bind(activity, sc, 0);
}
public void stopService() {
// demo on stopping a service
SmartTargets.toHelloServiceSTarget().stop(activity);
}
@Override
public void destroy() {
try {
activity.unbindService(sc);
} catch (Exception e){
e.printStackTrace();
}
SmartTargets.toHelloServiceSTarget().stop(activity);
}
@Override
public void result(int reqCode, int resCode, Intent data) {
if(reqCode == REQ_CODE_FOR_RESULT && resCode == RESULT_OK) {
// Yes, easy right? One line of code will get all your data from result source very smartly. | ForResultRes res = ForResultResIBuilder.getSmart(data); |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/fillform/ShowFilledFormsVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/SomethingClicked.java
// public interface SomethingClicked {
// void clicked(int position);
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.SomethingClicked;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class ShowFilledFormsVM extends BaseVMAdapter {
public OneTypeItemSource<MyContact> source;
public ShowFilledFormsVM() {
source = new OneTypeItemSource<>();
source.itemViewId = R.layout.contact_item; | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/SomethingClicked.java
// public interface SomethingClicked {
// void clicked(int position);
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/fillform/ShowFilledFormsVM.java
import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.SomethingClicked;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class ShowFilledFormsVM extends BaseVMAdapter {
public OneTypeItemSource<MyContact> source;
public ShowFilledFormsVM() {
source = new OneTypeItemSource<>();
source.itemViewId = R.layout.contact_item; | source.listeners = new SomethingClicked[]{new SomethingClicked() { |
foreveruseful/smartkey | app/src/main/java/link/anyauto/smartkey/demo/fillform/ShowFilledFormsVM.java | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/SomethingClicked.java
// public interface SomethingClicked {
// void clicked(int position);
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
| import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.SomethingClicked;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.util.ToastUtil; | package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class ShowFilledFormsVM extends BaseVMAdapter {
public OneTypeItemSource<MyContact> source;
public ShowFilledFormsVM() {
source = new OneTypeItemSource<>();
source.itemViewId = R.layout.contact_item;
source.listeners = new SomethingClicked[]{new SomethingClicked() {
@Override
public void clicked(int position) {
delete(position);
}
}};
ArrayList<MyContact> contacts = MyAppPreferencesSPBuilder.contacts();
if(contacts != null) {
source.items.addAll(contacts);
}
}
void delete(int position) {
if(source.items != null && position >= 0 && position < source.items.size()) {
source.items.remove(position);
MyAppPreferencesSPBuilder.contacts(source.items);
} else { | // Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
//
// public int itemViewId = 0;
//
// public ObservableArrayList<T> items = new ObservableArrayList<>();
//
// public SomethingClicked[] listeners;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/SomethingClicked.java
// public interface SomethingClicked {
// void clicked(int position);
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/base/BaseVMAdapter.java
// public class BaseVMAdapter extends BaseObservable implements BaseVM {
//
// protected Activity activity;
//
// public void setActivity(Activity activity) {
// this.activity = activity;
// }
//
// public Activity getActivity() {
// return activity;
// }
//
// @Override
// public void create(Bundle savedInstanceState) {
//
// }
//
// @Override
// public void restart() {
//
// }
//
// @Override
// public void start() {
//
// }
//
// @Override
// public void stop() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void destroy() {
//
// }
//
// @Override
// public void back() {
// if(activity != null) {
// activity.finish();
// }
// }
//
// @Override
// public void result(int reqCode, int resCode, Intent data) {
//
// }
//
// @Override
// public void configChanged(Configuration newConfig) {
//
// }
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/objects/MyContact.java
// public class MyContact {
// public String name;
// public String mobile;
// public String addr;
// }
//
// Path: app/src/main/java/link/anyauto/smartkey/demo/util/ToastUtil.java
// public class ToastUtil {
// static Toast toast;
// static ToastLayoutBinding binding;
//
// public static void toast(int resId) {
// binding.toast.setText(resId);
// toast.show();
// }
//
// public static void toast(String str) {
// binding.toast.setText(str);
// toast.show();
// }
//
// static void makeToast() {
// if(toast == null) {
// toast = new Toast(App.getInstance());
// binding = ToastLayoutBinding.inflate(LayoutInflater.from(App.getInstance()));
// toast.setView(binding.getRoot());
// toast.setDuration(Toast.LENGTH_LONG);
// }
// }
//
// static {
// makeToast();
// }
// }
// Path: app/src/main/java/link/anyauto/smartkey/demo/fillform/ShowFilledFormsVM.java
import java.util.ArrayList;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.SomethingClicked;
import link.anyauto.smartkey.demo.base.BaseVMAdapter;
import link.anyauto.smartkey.demo.objects.MyContact;
import link.anyauto.smartkey.demo.prefs.MyAppPreferencesSPBuilder;
import link.anyauto.smartkey.demo.util.ToastUtil;
package link.anyauto.smartkey.demo.fillform;
/**
* Created by discotek on 17-1-23.
*/
public class ShowFilledFormsVM extends BaseVMAdapter {
public OneTypeItemSource<MyContact> source;
public ShowFilledFormsVM() {
source = new OneTypeItemSource<>();
source.itemViewId = R.layout.contact_item;
source.listeners = new SomethingClicked[]{new SomethingClicked() {
@Override
public void clicked(int position) {
delete(position);
}
}};
ArrayList<MyContact> contacts = MyAppPreferencesSPBuilder.contacts();
if(contacts != null) {
source.items.addAll(contacts);
}
}
void delete(int position) {
if(source.items != null && position >= 0 && position < source.items.size()) {
source.items.remove(position);
MyAppPreferencesSPBuilder.contacts(source.items);
} else { | ToastUtil.toast(R.string.out_of_range); |
Adipa-G/joquery | src/joquery/Query.java | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
| import joquery.core.QueryException;
import java.util.function.Function; | package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public interface Query<T,W extends Query<T,W>>
{
W from(Iterable<T> list);
W where();
W select();
| // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/joquery/Query.java
import joquery.core.QueryException;
import java.util.function.Function;
package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public interface Query<T,W extends Query<T,W>>
{
W from(Iterable<T> list);
W where();
W select();
| W exec(Function<T,?> property) throws QueryException; |
Adipa-G/joquery | src/joquery/core/collection/expr/condition/EqConditionalExpr.java | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
| import joquery.core.QueryException; | package joquery.core.collection.expr.condition;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class EqConditionalExpr<T> extends ConditionalExpr<T>
{
@Override | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/joquery/core/collection/expr/condition/EqConditionalExpr.java
import joquery.core.QueryException;
package joquery.core.collection.expr.condition;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class EqConditionalExpr<T> extends ConditionalExpr<T>
{
@Override | public Object evaluate(T t) throws QueryException |
Adipa-G/joquery | src-test/joquery/GroupTest.java | // Path: src-test/assertions/A.java
// public class A<T>
// {
// private T expected;
//
// public A(T expected)
// {
// this.expected = expected;
// }
//
// public void act(T actual)
// {
// compare(expected,actual,"");
// }
//
// public void act(T actual,String message)
// {
// compare(expected,actual,message);
// }
//
// private void compare(T exp,T act,String message)
// {
// if (exp instanceof Collection)
// {
// Collection expCollection = (Collection) exp;
// Collection actCollection = (Collection) act;
// compareCollection(expCollection,actCollection,message);
// }
// else
// {
// Assert.assertEquals(message,exp,act);
// }
// }
//
// private <U extends Collection> void compareCollection(U exp,U act,String message)
// {
// Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size());
//
// for (Object e : exp)
// {
// boolean found = false;
// for (Object a : act)
// {
// if (e.equals(a))
// {
// found = true;
// break;
// }
// }
// if (!found)
// Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e));
// }
// }
//
// public static <T> A<T> exp(T t)
// {
// return new A<>(t);
// }
// }
//
// Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
| import assertions.A;
import joquery.core.QueryException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; | package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class GroupTest
{
private static Collection<Dto> dtoList;
@BeforeClass
public static void setup()
{
dtoList = new ArrayList<>();
| // Path: src-test/assertions/A.java
// public class A<T>
// {
// private T expected;
//
// public A(T expected)
// {
// this.expected = expected;
// }
//
// public void act(T actual)
// {
// compare(expected,actual,"");
// }
//
// public void act(T actual,String message)
// {
// compare(expected,actual,message);
// }
//
// private void compare(T exp,T act,String message)
// {
// if (exp instanceof Collection)
// {
// Collection expCollection = (Collection) exp;
// Collection actCollection = (Collection) act;
// compareCollection(expCollection,actCollection,message);
// }
// else
// {
// Assert.assertEquals(message,exp,act);
// }
// }
//
// private <U extends Collection> void compareCollection(U exp,U act,String message)
// {
// Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size());
//
// for (Object e : exp)
// {
// boolean found = false;
// for (Object a : act)
// {
// if (e.equals(a))
// {
// found = true;
// break;
// }
// }
// if (!found)
// Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e));
// }
// }
//
// public static <T> A<T> exp(T t)
// {
// return new A<>(t);
// }
// }
//
// Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src-test/joquery/GroupTest.java
import assertions.A;
import joquery.core.QueryException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class GroupTest
{
private static Collection<Dto> dtoList;
@BeforeClass
public static void setup()
{
dtoList = new ArrayList<>();
| dtoList.add(new Dto(1, "A")); |
Adipa-G/joquery | src-test/joquery/GroupTest.java | // Path: src-test/assertions/A.java
// public class A<T>
// {
// private T expected;
//
// public A(T expected)
// {
// this.expected = expected;
// }
//
// public void act(T actual)
// {
// compare(expected,actual,"");
// }
//
// public void act(T actual,String message)
// {
// compare(expected,actual,message);
// }
//
// private void compare(T exp,T act,String message)
// {
// if (exp instanceof Collection)
// {
// Collection expCollection = (Collection) exp;
// Collection actCollection = (Collection) act;
// compareCollection(expCollection,actCollection,message);
// }
// else
// {
// Assert.assertEquals(message,exp,act);
// }
// }
//
// private <U extends Collection> void compareCollection(U exp,U act,String message)
// {
// Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size());
//
// for (Object e : exp)
// {
// boolean found = false;
// for (Object a : act)
// {
// if (e.equals(a))
// {
// found = true;
// break;
// }
// }
// if (!found)
// Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e));
// }
// }
//
// public static <T> A<T> exp(T t)
// {
// return new A<>(t);
// }
// }
//
// Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
| import assertions.A;
import joquery.core.QueryException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; | package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class GroupTest
{
private static Collection<Dto> dtoList;
@BeforeClass
public static void setup()
{
dtoList = new ArrayList<>();
dtoList.add(new Dto(1, "A"));
dtoList.add(new Dto(3, "C"));
dtoList.add(new Dto(2, "C"));
dtoList.add(new Dto(4, "B"));
dtoList.add(new Dto(5, "E"));
dtoList.add(new Dto(5, "F"));
dtoList.add(new Dto(5, "F"));
dtoList.add(new Dto(5, null));
}
@AfterClass
public static void cleanup()
{
dtoList.clear();
dtoList = null;
}
@Test | // Path: src-test/assertions/A.java
// public class A<T>
// {
// private T expected;
//
// public A(T expected)
// {
// this.expected = expected;
// }
//
// public void act(T actual)
// {
// compare(expected,actual,"");
// }
//
// public void act(T actual,String message)
// {
// compare(expected,actual,message);
// }
//
// private void compare(T exp,T act,String message)
// {
// if (exp instanceof Collection)
// {
// Collection expCollection = (Collection) exp;
// Collection actCollection = (Collection) act;
// compareCollection(expCollection,actCollection,message);
// }
// else
// {
// Assert.assertEquals(message,exp,act);
// }
// }
//
// private <U extends Collection> void compareCollection(U exp,U act,String message)
// {
// Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size());
//
// for (Object e : exp)
// {
// boolean found = false;
// for (Object a : act)
// {
// if (e.equals(a))
// {
// found = true;
// break;
// }
// }
// if (!found)
// Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e));
// }
// }
//
// public static <T> A<T> exp(T t)
// {
// return new A<>(t);
// }
// }
//
// Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src-test/joquery/GroupTest.java
import assertions.A;
import joquery.core.QueryException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
package joquery;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class GroupTest
{
private static Collection<Dto> dtoList;
@BeforeClass
public static void setup()
{
dtoList = new ArrayList<>();
dtoList.add(new Dto(1, "A"));
dtoList.add(new Dto(3, "C"));
dtoList.add(new Dto(2, "C"));
dtoList.add(new Dto(4, "B"));
dtoList.add(new Dto(5, "E"));
dtoList.add(new Dto(5, "F"));
dtoList.add(new Dto(5, "F"));
dtoList.add(new Dto(5, null));
}
@AfterClass
public static void cleanup()
{
dtoList.clear();
dtoList = null;
}
@Test | public void groupById_EmptyList_ShouldReturnEmptyList() throws QueryException |
Adipa-G/joquery | src/joquery/core/collection/expr/ConstExpr.java | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
//
// Path: src/joquery/core/QueryMode.java
// public enum QueryMode
// {
// SELECT,
// FROM,
// WHERE,
// SORT
// }
| import joquery.core.QueryException;
import joquery.core.QueryMode; | package joquery.core.collection.expr;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class ConstExpr<T> implements IExpr<T>
{
private Object constVal;
public ConstExpr(Object constVal)
{
this.constVal = constVal;
}
@Override | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
//
// Path: src/joquery/core/QueryMode.java
// public enum QueryMode
// {
// SELECT,
// FROM,
// WHERE,
// SORT
// }
// Path: src/joquery/core/collection/expr/ConstExpr.java
import joquery.core.QueryException;
import joquery.core.QueryMode;
package joquery.core.collection.expr;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class ConstExpr<T> implements IExpr<T>
{
private Object constVal;
public ConstExpr(Object constVal)
{
this.constVal = constVal;
}
@Override | public boolean supportsMode(QueryMode mode) |
Adipa-G/joquery | src/joquery/core/collection/expr/ConstExpr.java | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
//
// Path: src/joquery/core/QueryMode.java
// public enum QueryMode
// {
// SELECT,
// FROM,
// WHERE,
// SORT
// }
| import joquery.core.QueryException;
import joquery.core.QueryMode; | package joquery.core.collection.expr;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class ConstExpr<T> implements IExpr<T>
{
private Object constVal;
public ConstExpr(Object constVal)
{
this.constVal = constVal;
}
@Override
public boolean supportsMode(QueryMode mode)
{
return mode == QueryMode.SELECT
|| mode == QueryMode.WHERE;
}
@Override
public boolean add(IExpr<T> expr)
{
return false;
}
@Override | // Path: src/joquery/core/QueryException.java
// public class QueryException extends Exception
// {
// public QueryException(String message)
// {
// super(message);
// }
//
// public QueryException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
//
// Path: src/joquery/core/QueryMode.java
// public enum QueryMode
// {
// SELECT,
// FROM,
// WHERE,
// SORT
// }
// Path: src/joquery/core/collection/expr/ConstExpr.java
import joquery.core.QueryException;
import joquery.core.QueryMode;
package joquery.core.collection.expr;
/**
* User: Adipa
* Date: 10/6/12
* Time: 9:31 PM
*/
public class ConstExpr<T> implements IExpr<T>
{
private Object constVal;
public ConstExpr(Object constVal)
{
this.constVal = constVal;
}
@Override
public boolean supportsMode(QueryMode mode)
{
return mode == QueryMode.SELECT
|| mode == QueryMode.WHERE;
}
@Override
public boolean add(IExpr<T> expr)
{
return false;
}
@Override | public Object evaluate(T t) throws QueryException |
Adipa-G/joquery | src/joquery/CQ.java | // Path: src/joquery/core/collection/FilterImpl.java
// public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T>
// {
// @Override
// public T first() throws QueryException
// {
// return super.first(list());
// }
//
// @Override
// public T last() throws QueryException
// {
// return super.last(list());
// }
//
// @Override
// public Collection<T> list() throws QueryException
// {
// return transformDefaultSelection();
// }
// }
//
// Path: src/joquery/core/collection/SelectionQueryImpl.java
// public class SelectionQueryImpl<T,U> extends ResultTransformedQueryImpl<T,U,SelectionQuery<T,U>> implements SelectionQuery<T,U>
// {
// }
| import joquery.core.collection.FilterImpl;
import joquery.core.collection.SelectionQueryImpl;
import java.util.Collection; | package joquery;
/**
* User: Adipa
* Date: 10/14/12
* Time: 10:52 AM
*/
public class CQ
{
public static <T> Filter<T> filter()
{ | // Path: src/joquery/core/collection/FilterImpl.java
// public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T>
// {
// @Override
// public T first() throws QueryException
// {
// return super.first(list());
// }
//
// @Override
// public T last() throws QueryException
// {
// return super.last(list());
// }
//
// @Override
// public Collection<T> list() throws QueryException
// {
// return transformDefaultSelection();
// }
// }
//
// Path: src/joquery/core/collection/SelectionQueryImpl.java
// public class SelectionQueryImpl<T,U> extends ResultTransformedQueryImpl<T,U,SelectionQuery<T,U>> implements SelectionQuery<T,U>
// {
// }
// Path: src/joquery/CQ.java
import joquery.core.collection.FilterImpl;
import joquery.core.collection.SelectionQueryImpl;
import java.util.Collection;
package joquery;
/**
* User: Adipa
* Date: 10/14/12
* Time: 10:52 AM
*/
public class CQ
{
public static <T> Filter<T> filter()
{ | return new FilterImpl<>(); |
Adipa-G/joquery | src/joquery/CQ.java | // Path: src/joquery/core/collection/FilterImpl.java
// public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T>
// {
// @Override
// public T first() throws QueryException
// {
// return super.first(list());
// }
//
// @Override
// public T last() throws QueryException
// {
// return super.last(list());
// }
//
// @Override
// public Collection<T> list() throws QueryException
// {
// return transformDefaultSelection();
// }
// }
//
// Path: src/joquery/core/collection/SelectionQueryImpl.java
// public class SelectionQueryImpl<T,U> extends ResultTransformedQueryImpl<T,U,SelectionQuery<T,U>> implements SelectionQuery<T,U>
// {
// }
| import joquery.core.collection.FilterImpl;
import joquery.core.collection.SelectionQueryImpl;
import java.util.Collection; | package joquery;
/**
* User: Adipa
* Date: 10/14/12
* Time: 10:52 AM
*/
public class CQ
{
public static <T> Filter<T> filter()
{
return new FilterImpl<>();
}
public static <T> Filter<T> filter(Collection<T> ts)
{
return new FilterImpl<T>().from(ts);
}
public static <T,U> SelectionQuery<T,U> query()
{ | // Path: src/joquery/core/collection/FilterImpl.java
// public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T>
// {
// @Override
// public T first() throws QueryException
// {
// return super.first(list());
// }
//
// @Override
// public T last() throws QueryException
// {
// return super.last(list());
// }
//
// @Override
// public Collection<T> list() throws QueryException
// {
// return transformDefaultSelection();
// }
// }
//
// Path: src/joquery/core/collection/SelectionQueryImpl.java
// public class SelectionQueryImpl<T,U> extends ResultTransformedQueryImpl<T,U,SelectionQuery<T,U>> implements SelectionQuery<T,U>
// {
// }
// Path: src/joquery/CQ.java
import joquery.core.collection.FilterImpl;
import joquery.core.collection.SelectionQueryImpl;
import java.util.Collection;
package joquery;
/**
* User: Adipa
* Date: 10/14/12
* Time: 10:52 AM
*/
public class CQ
{
public static <T> Filter<T> filter()
{
return new FilterImpl<>();
}
public static <T> Filter<T> filter(Collection<T> ts)
{
return new FilterImpl<T>().from(ts);
}
public static <T,U> SelectionQuery<T,U> query()
{ | return new SelectionQueryImpl<>(); |
Subsets and Splits