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 |
|---|---|---|---|---|---|---|
EndlessCodeGroup/RPGInventory | src/main/java/ru/endlesscode/rpginventory/misc/Updater.java | // Path: src/main/java/ru/endlesscode/rpginventory/utils/Log.java
// @SuppressWarnings("CheckStyle")
// public final class Log {
//
// private static Logger logger;
//
// private Log() {
// // static class
// }
//
// public static void init(@NotNull Logger logger) {
// Log.logger = logger;
// }
//
// public static void i(@NotNull String message, Object... args) {
// logger.info(prepareMessage(message, args));
// }
//
// public static void w(Throwable t) {
// logger.log(Level.WARNING, t.getMessage(), t);
// }
//
// public static void w(@NotNull String message, Object... args) {
// logger.warning(prepareMessage(message, args));
// }
//
// public static void w(Throwable t, @NotNull String message, Object... args) {
// logger.log(Level.WARNING, prepareMessage(message, args), t);
// }
//
// public static void d(Throwable t) {
// logger.log(Level.FINE, "", t);
// }
//
// public static void s(@NotNull String message, Object... args) {
// logger.severe(prepareMessage(message, args));
// }
//
// private static String prepareMessage(String message, Object... args) {
// return MessageFormat.format(message, args);
// }
// }
| import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import ru.endlesscode.rpginventory.utils.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; | * @return true if Updater should consider the remote version an update, false if not.
*/
private boolean shouldUpdate(String localVersion, String remoteVersion) {
return !localVersion.equalsIgnoreCase(remoteVersion);
}
/**
* Evaluate whether the version number is marked showing that it should not be updated by this program.
*
* @param version a version number to check for tags in.
* @return true if updating should be disabled.
*/
private boolean hasTag(@NotNull String version) {
for (final String string : Updater.NO_UPDATE_TAG) {
if (version.contains(string)) {
return true;
}
}
return false;
}
/**
* Make a connection to the BukkitDev API and request the newest file's details.
*
* @return true if successful.
*/
private boolean read() {
try {
return tryToRead();
} catch (@NotNull final IOException | NullPointerException e) { | // Path: src/main/java/ru/endlesscode/rpginventory/utils/Log.java
// @SuppressWarnings("CheckStyle")
// public final class Log {
//
// private static Logger logger;
//
// private Log() {
// // static class
// }
//
// public static void init(@NotNull Logger logger) {
// Log.logger = logger;
// }
//
// public static void i(@NotNull String message, Object... args) {
// logger.info(prepareMessage(message, args));
// }
//
// public static void w(Throwable t) {
// logger.log(Level.WARNING, t.getMessage(), t);
// }
//
// public static void w(@NotNull String message, Object... args) {
// logger.warning(prepareMessage(message, args));
// }
//
// public static void w(Throwable t, @NotNull String message, Object... args) {
// logger.log(Level.WARNING, prepareMessage(message, args), t);
// }
//
// public static void d(Throwable t) {
// logger.log(Level.FINE, "", t);
// }
//
// public static void s(@NotNull String message, Object... args) {
// logger.severe(prepareMessage(message, args));
// }
//
// private static String prepareMessage(String message, Object... args) {
// return MessageFormat.format(message, args);
// }
// }
// Path: src/main/java/ru/endlesscode/rpginventory/misc/Updater.java
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import ru.endlesscode.rpginventory.utils.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
* @return true if Updater should consider the remote version an update, false if not.
*/
private boolean shouldUpdate(String localVersion, String remoteVersion) {
return !localVersion.equalsIgnoreCase(remoteVersion);
}
/**
* Evaluate whether the version number is marked showing that it should not be updated by this program.
*
* @param version a version number to check for tags in.
* @return true if updating should be disabled.
*/
private boolean hasTag(@NotNull String version) {
for (final String string : Updater.NO_UPDATE_TAG) {
if (version.contains(string)) {
return true;
}
}
return false;
}
/**
* Make a connection to the BukkitDev API and request the newest file's details.
*
* @return true if successful.
*/
private boolean read() {
try {
return tryToRead();
} catch (@NotNull final IOException | NullPointerException e) { | Log.s("The updater could not contact {0} for check updates.", HOST); |
EndlessCodeGroup/RPGInventory | src/main/java/ru/endlesscode/rpginventory/compat/VersionHandler.java | // Path: src/main/java/ru/endlesscode/rpginventory/utils/Version.java
// public final class Version implements Comparable<Version> {
//
// private final int major;
// private final int minor;
// private final int patch;
// private final String qualifier;
//
// /**
// * Constructs Version object from the given data according to semantic versioning.
// *
// * @param major Major version.
// * @param minor Minor version.
// * @param patch Patch version.
// */
// public Version(int major, int minor, int patch) {
// this(major, minor, patch, "");
// }
//
// /**
// * Constructs Version object from the given data according to semantic versioning.
// *
// * @param major Major version.
// * @param minor Minor version.
// * @param patch Patch version.
// * @param qualifier Qualifier, or empty string if qualifier not exists.
// * @throws IllegalArgumentException when passed negative version codes.
// */
// public Version(int major, int minor, int patch, @NotNull String qualifier) {
// if (major < 0 || minor < 0 || patch < 0) {
// throw new IllegalArgumentException("Version can't include negative numbers");
// }
//
// this.major = major;
// this.minor = minor;
// this.patch = patch;
// this.qualifier = Objects.requireNonNull(qualifier, "'qualifier' shouldn't be null");
// }
//
// /**
// * Parses version from the given string.
// *
// * @param version String representation of version.
// * @return The constructed version.
// * @throws IllegalArgumentException If passed string with wrong format.
// */
// @NotNull
// public static Version parseVersion(@NotNull String version) {
// String[] parts = version.split("-", 2);
// String qualifier = (parts.length > 1) ? parts[1] : "";
// parts = parts[0].split("\\.", 3);
//
// try {
// int patch = (parts.length > 2) ? Integer.parseInt(parts[2]) : 0;
// int minor = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
// int major = Integer.parseInt(parts[0]);
//
// return new Version(major, minor, patch, qualifier);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException(String.format("Can not parse version string: %s", version), e);
// }
// }
//
// public int compareTo(String version) {
// return this.compareTo(Version.parseVersion(version));
// }
//
// @Override
// public int compareTo(@NotNull Version o) {
// int result;
// if ((result = Integer.compare(major, o.major)) != 0
// || (result = Integer.compare(minor, o.minor)) != 0
// || (result = Integer.compare(patch, o.patch)) != 0) {
// // TODO: Maybe compare also qualifiers
// return result;
// }
//
// return 0;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o || o == null || getClass() != o.getClass()) {
// return true;
// }
//
// Version version = (Version) o;
// return major == version.major
// && minor == version.minor
// && patch == version.patch
// && Objects.equals(qualifier, version.qualifier);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(major, minor, patch, qualifier);
// }
//
// @Override
// public String toString() {
// return String.format("%d.%d.%d%s", major, minor, patch, qualifier.isEmpty() ? "" : "-" + qualifier);
// }
//
// public int getMajor() {
// return major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public int getPatch() {
// return patch;
// }
//
// @NotNull
// public String getQualifier() {
// return qualifier;
// }
//
// /**
// * Returns version code in format xxyyzz, where x - major version, y - minor and z - patch.
// * Example:
// * 1.12.2 -> 11202
// * 21.0.12 -> 210012
// * 1.9 -> 10900
// * 2.2.1 -> 20201
// * Major, minor and patch versions shouldn't be higher than 99.
// */
// public int getVersionCode() {
// return major * 10000 + minor * 100 + patch;
// }
//
// /**
// * Checks that version has qualifier.
// *
// * @return true if version contains qualifier, otherwise false.
// */
// public boolean hasQualifier() {
// return !qualifier.isEmpty();
// }
// }
| import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import ru.endlesscode.rpginventory.utils.Version;
import java.util.regex.Matcher; | public static final int VERSION_1_18 = 1_18_00;
private static final Pattern pattern = Pattern.compile("(?<version>\\d\\.\\d{1,2}(\\.\\d)?)-.*");
private static int versionCode = -1;
public static boolean isNotSupportedVersion() {
return getVersionCode() < VERSION_1_14 || getVersionCode() >= VERSION_1_18;
}
public static boolean isExperimentalSupport() {
return getVersionCode() == VERSION_1_17;
}
public static boolean isLegacy() {
return getVersionCode() < VERSION_1_13;
}
public static int getVersionCode() {
if (versionCode == -1) {
initVersionCode();
}
return versionCode;
}
private static void initVersionCode() {
Matcher matcher = pattern.matcher(Bukkit.getBukkitVersion());
if (matcher.find()) {
String versionString = matcher.group("version"); | // Path: src/main/java/ru/endlesscode/rpginventory/utils/Version.java
// public final class Version implements Comparable<Version> {
//
// private final int major;
// private final int minor;
// private final int patch;
// private final String qualifier;
//
// /**
// * Constructs Version object from the given data according to semantic versioning.
// *
// * @param major Major version.
// * @param minor Minor version.
// * @param patch Patch version.
// */
// public Version(int major, int minor, int patch) {
// this(major, minor, patch, "");
// }
//
// /**
// * Constructs Version object from the given data according to semantic versioning.
// *
// * @param major Major version.
// * @param minor Minor version.
// * @param patch Patch version.
// * @param qualifier Qualifier, or empty string if qualifier not exists.
// * @throws IllegalArgumentException when passed negative version codes.
// */
// public Version(int major, int minor, int patch, @NotNull String qualifier) {
// if (major < 0 || minor < 0 || patch < 0) {
// throw new IllegalArgumentException("Version can't include negative numbers");
// }
//
// this.major = major;
// this.minor = minor;
// this.patch = patch;
// this.qualifier = Objects.requireNonNull(qualifier, "'qualifier' shouldn't be null");
// }
//
// /**
// * Parses version from the given string.
// *
// * @param version String representation of version.
// * @return The constructed version.
// * @throws IllegalArgumentException If passed string with wrong format.
// */
// @NotNull
// public static Version parseVersion(@NotNull String version) {
// String[] parts = version.split("-", 2);
// String qualifier = (parts.length > 1) ? parts[1] : "";
// parts = parts[0].split("\\.", 3);
//
// try {
// int patch = (parts.length > 2) ? Integer.parseInt(parts[2]) : 0;
// int minor = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
// int major = Integer.parseInt(parts[0]);
//
// return new Version(major, minor, patch, qualifier);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException(String.format("Can not parse version string: %s", version), e);
// }
// }
//
// public int compareTo(String version) {
// return this.compareTo(Version.parseVersion(version));
// }
//
// @Override
// public int compareTo(@NotNull Version o) {
// int result;
// if ((result = Integer.compare(major, o.major)) != 0
// || (result = Integer.compare(minor, o.minor)) != 0
// || (result = Integer.compare(patch, o.patch)) != 0) {
// // TODO: Maybe compare also qualifiers
// return result;
// }
//
// return 0;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o || o == null || getClass() != o.getClass()) {
// return true;
// }
//
// Version version = (Version) o;
// return major == version.major
// && minor == version.minor
// && patch == version.patch
// && Objects.equals(qualifier, version.qualifier);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(major, minor, patch, qualifier);
// }
//
// @Override
// public String toString() {
// return String.format("%d.%d.%d%s", major, minor, patch, qualifier.isEmpty() ? "" : "-" + qualifier);
// }
//
// public int getMajor() {
// return major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public int getPatch() {
// return patch;
// }
//
// @NotNull
// public String getQualifier() {
// return qualifier;
// }
//
// /**
// * Returns version code in format xxyyzz, where x - major version, y - minor and z - patch.
// * Example:
// * 1.12.2 -> 11202
// * 21.0.12 -> 210012
// * 1.9 -> 10900
// * 2.2.1 -> 20201
// * Major, minor and patch versions shouldn't be higher than 99.
// */
// public int getVersionCode() {
// return major * 10000 + minor * 100 + patch;
// }
//
// /**
// * Checks that version has qualifier.
// *
// * @return true if version contains qualifier, otherwise false.
// */
// public boolean hasQualifier() {
// return !qualifier.isEmpty();
// }
// }
// Path: src/main/java/ru/endlesscode/rpginventory/compat/VersionHandler.java
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import ru.endlesscode.rpginventory.utils.Version;
import java.util.regex.Matcher;
public static final int VERSION_1_18 = 1_18_00;
private static final Pattern pattern = Pattern.compile("(?<version>\\d\\.\\d{1,2}(\\.\\d)?)-.*");
private static int versionCode = -1;
public static boolean isNotSupportedVersion() {
return getVersionCode() < VERSION_1_14 || getVersionCode() >= VERSION_1_18;
}
public static boolean isExperimentalSupport() {
return getVersionCode() == VERSION_1_17;
}
public static boolean isLegacy() {
return getVersionCode() < VERSION_1_13;
}
public static int getVersionCode() {
if (versionCode == -1) {
initVersionCode();
}
return versionCode;
}
private static void initVersionCode() {
Matcher matcher = pattern.matcher(Bukkit.getBukkitVersion());
if (matcher.find()) {
String versionString = matcher.group("version"); | versionCode = Version.parseVersion(versionString).getVersionCode(); |
EndlessCodeGroup/RPGInventory | src/main/java/ru/endlesscode/rpginventory/misc/config/VanillaSlotAction.java | // Path: src/main/java/ru/endlesscode/rpginventory/utils/SafeEnums.java
// public class SafeEnums {
//
// private SafeEnums() {
// // Shouldn't be instantiated
// }
//
// @Nullable
// public static DyeColor getDyeColor(String name) {
// return valueOf(DyeColor.class, name, "color");
// }
//
// @Nullable
// public static Horse.Color getHorseColor(String name) {
// return valueOf(Horse.Color.class, name, "horse color");
// }
//
// @Nullable
// public static Horse.Style getHorseStyle(String name) {
// return valueOf(Horse.Style.class, name, "horse style");
// }
//
// @Nullable
// public static Cat.Type getCatType(String name) {
// return valueOf(Cat.Type.class, name, "cat type");
// }
//
// @NotNull
// public static <T extends Enum<T>> T valueOfOrDefault(Class<T> enumClass, String name, T defaultValue) {
// return valueOfOrDefault(enumClass, name, defaultValue, enumClass.getSimpleName());
// }
//
// @NotNull
// public static <T extends Enum<T>> T valueOfOrDefault(Class<T> enumClass, String name, T defaultValue, String alias) {
// T value = valueOf(enumClass, name, alias);
// if (value != null) {
// return value;
// } else {
// Log.w("Used {0} {1} by default.", defaultValue.name(), alias);
// return defaultValue;
// }
// }
//
// @Nullable
// public static <T extends Enum<T>> T valueOf(Class<T> enumClass, String name, String alias) {
// if (name == null) {
// return null;
// }
//
// try {
// return Enum.valueOf(enumClass, name.toUpperCase());
// } catch (IllegalArgumentException e) {
// Log.w("Unknown {0}: {1}. Available values: {2}", alias, name, Arrays.toString(enumClass.getEnumConstants()));
// return null;
// }
// }
// }
| import ru.endlesscode.rpginventory.utils.SafeEnums; | /*
* This file is part of RPGInventory.
* Copyright (C) 2018 EndlessCode Group and contributors
*
* RPGInventory is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RPGInventory is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RPGInventory. If not, see <http://www.gnu.org/licenses/>.
*/
package ru.endlesscode.rpginventory.misc.config;
public enum VanillaSlotAction {
/**
* Do vanilla action.
*/
DEFAULT,
/**
* Open RPG inventory.
*/
RPGINV;
static VanillaSlotAction parseString(String stringValue) { | // Path: src/main/java/ru/endlesscode/rpginventory/utils/SafeEnums.java
// public class SafeEnums {
//
// private SafeEnums() {
// // Shouldn't be instantiated
// }
//
// @Nullable
// public static DyeColor getDyeColor(String name) {
// return valueOf(DyeColor.class, name, "color");
// }
//
// @Nullable
// public static Horse.Color getHorseColor(String name) {
// return valueOf(Horse.Color.class, name, "horse color");
// }
//
// @Nullable
// public static Horse.Style getHorseStyle(String name) {
// return valueOf(Horse.Style.class, name, "horse style");
// }
//
// @Nullable
// public static Cat.Type getCatType(String name) {
// return valueOf(Cat.Type.class, name, "cat type");
// }
//
// @NotNull
// public static <T extends Enum<T>> T valueOfOrDefault(Class<T> enumClass, String name, T defaultValue) {
// return valueOfOrDefault(enumClass, name, defaultValue, enumClass.getSimpleName());
// }
//
// @NotNull
// public static <T extends Enum<T>> T valueOfOrDefault(Class<T> enumClass, String name, T defaultValue, String alias) {
// T value = valueOf(enumClass, name, alias);
// if (value != null) {
// return value;
// } else {
// Log.w("Used {0} {1} by default.", defaultValue.name(), alias);
// return defaultValue;
// }
// }
//
// @Nullable
// public static <T extends Enum<T>> T valueOf(Class<T> enumClass, String name, String alias) {
// if (name == null) {
// return null;
// }
//
// try {
// return Enum.valueOf(enumClass, name.toUpperCase());
// } catch (IllegalArgumentException e) {
// Log.w("Unknown {0}: {1}. Available values: {2}", alias, name, Arrays.toString(enumClass.getEnumConstants()));
// return null;
// }
// }
// }
// Path: src/main/java/ru/endlesscode/rpginventory/misc/config/VanillaSlotAction.java
import ru.endlesscode.rpginventory.utils.SafeEnums;
/*
* This file is part of RPGInventory.
* Copyright (C) 2018 EndlessCode Group and contributors
*
* RPGInventory is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RPGInventory is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RPGInventory. If not, see <http://www.gnu.org/licenses/>.
*/
package ru.endlesscode.rpginventory.misc.config;
public enum VanillaSlotAction {
/**
* Do vanilla action.
*/
DEFAULT,
/**
* Open RPG inventory.
*/
RPGINV;
static VanillaSlotAction parseString(String stringValue) { | return SafeEnums.valueOfOrDefault(VanillaSlotAction.class, stringValue, DEFAULT, "slot action"); |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/HacklistApplication.java | // Path: app/src/main/java/com/projects/elad/hacklist/injection/components/AppComponent.java
// @HacklistApplicationScope
// @Component(modules = {AppModule.class, NetModule.class})
// public interface AppComponent {
// void inject(HomePresenter homePresenter);
// void inject(BookmarksPresenter bookmarksPresenter);
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
// @Module
// public class AppModule {
// protected final Application application;
// public AppModule(Application application) {
// this.application = application;
// }
//
// @Provides
// Application provideApplication(){
// return application;
// }
//
// @Provides
// Context provideContext(){
// return application;
// }
//
// @Provides
// @HacklistApplicationScope
// public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){
// return new RealmBookmarksHelper(context);
// }
//
//
//
//
// }
| import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.injection.components.AppComponent;
import com.projects.elad.hacklist.injection.components.DaggerAppComponent;
import com.projects.elad.hacklist.injection.modules.AppModule; | package com.projects.elad.hacklist;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class HacklistApplication extends Application {
private AppComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
}
public static HacklistApplication get(Context context) {
return (HacklistApplication) context.getApplicationContext();
}
public AppComponent getComponent() {
if (appComponent == null) {
appComponent = DaggerAppComponent.builder() | // Path: app/src/main/java/com/projects/elad/hacklist/injection/components/AppComponent.java
// @HacklistApplicationScope
// @Component(modules = {AppModule.class, NetModule.class})
// public interface AppComponent {
// void inject(HomePresenter homePresenter);
// void inject(BookmarksPresenter bookmarksPresenter);
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
// @Module
// public class AppModule {
// protected final Application application;
// public AppModule(Application application) {
// this.application = application;
// }
//
// @Provides
// Application provideApplication(){
// return application;
// }
//
// @Provides
// Context provideContext(){
// return application;
// }
//
// @Provides
// @HacklistApplicationScope
// public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){
// return new RealmBookmarksHelper(context);
// }
//
//
//
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/HacklistApplication.java
import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.injection.components.AppComponent;
import com.projects.elad.hacklist.injection.components.DaggerAppComponent;
import com.projects.elad.hacklist.injection.modules.AppModule;
package com.projects.elad.hacklist;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class HacklistApplication extends Application {
private AppComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
}
public static HacklistApplication get(Context context) {
return (HacklistApplication) context.getApplicationContext();
}
public AppComponent getComponent() {
if (appComponent == null) {
appComponent = DaggerAppComponent.builder() | .appModule(new AppModule(this)) |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/modules/HomeFragmentModule.java | // Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/HomePresenter.java
// public class HomePresenter extends BasePresenter<HomeMvpView> {
//
// @Inject DataManager dataManager;
// private HashMap<Integer, Subscription> subscriptions;
// @Inject Context context;
//
// public HomePresenter() {
// subscriptions = new HashMap<>();
// }
//
//
// @Override
// public void attachView(HomeMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication)(((FragmentHome)getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
// @Override
// public void detachView() {
// super.detachView();
// unSubscribeAll();
// }
//
// void unSubscribeAll() {
// for (Subscription sub : subscriptions.values()) {
// RxUtil.unsubscribe(sub);
// }
// subscriptions.clear();
// }
//
// public void loadHackEvent() {
// checkViewAttached();
// unSubscribeAll();
//
// int month = dataManager.getDate().getCurrMonthInt();
// String year = dataManager.getDate().getCurrentYear();
// while (month < 12) {
// subscriptions.put(month,
// dataManager.getHacklistService().getMonthObject(year, Utils.getStringForMonthInt(month))
// .observeOn(AndroidSchedulers.mainThread())
// .subscribeOn(Schedulers.newThread())
// .map(v -> v.entrySet().iterator().next().getValue())
// .subscribe(new Subscriber<List<HackEvent>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(List<HackEvent> events) {
// getMvpView().showHackEvents(Mappers.mapHackEventsToListItems(events,context));
// }
// }));
//
// month++;
// }
//
// }
//
//
// public void saveListItem(ListItem item) {
// dataManager.saveBookmark(Mappers.mapHomeListItemToBookmarkDbEntity(item));
// }
//
// public boolean isBookmarkSaved(String title) {
// return dataManager.isSaved(title);
// }
//
//
// public void deleteBookmark(String title) {
// dataManager.deleteBookmark(title);
// }
// }
| import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.presenters.HomePresenter;
import dagger.Module;
import dagger.Provides; | package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@Module
public class HomeFragmentModule {
@Provides
@PerFragment | // Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/HomePresenter.java
// public class HomePresenter extends BasePresenter<HomeMvpView> {
//
// @Inject DataManager dataManager;
// private HashMap<Integer, Subscription> subscriptions;
// @Inject Context context;
//
// public HomePresenter() {
// subscriptions = new HashMap<>();
// }
//
//
// @Override
// public void attachView(HomeMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication)(((FragmentHome)getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
// @Override
// public void detachView() {
// super.detachView();
// unSubscribeAll();
// }
//
// void unSubscribeAll() {
// for (Subscription sub : subscriptions.values()) {
// RxUtil.unsubscribe(sub);
// }
// subscriptions.clear();
// }
//
// public void loadHackEvent() {
// checkViewAttached();
// unSubscribeAll();
//
// int month = dataManager.getDate().getCurrMonthInt();
// String year = dataManager.getDate().getCurrentYear();
// while (month < 12) {
// subscriptions.put(month,
// dataManager.getHacklistService().getMonthObject(year, Utils.getStringForMonthInt(month))
// .observeOn(AndroidSchedulers.mainThread())
// .subscribeOn(Schedulers.newThread())
// .map(v -> v.entrySet().iterator().next().getValue())
// .subscribe(new Subscriber<List<HackEvent>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(List<HackEvent> events) {
// getMvpView().showHackEvents(Mappers.mapHackEventsToListItems(events,context));
// }
// }));
//
// month++;
// }
//
// }
//
//
// public void saveListItem(ListItem item) {
// dataManager.saveBookmark(Mappers.mapHomeListItemToBookmarkDbEntity(item));
// }
//
// public boolean isBookmarkSaved(String title) {
// return dataManager.isSaved(title);
// }
//
//
// public void deleteBookmark(String title) {
// dataManager.deleteBookmark(title);
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/HomeFragmentModule.java
import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.presenters.HomePresenter;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@Module
public class HomeFragmentModule {
@Provides
@PerFragment | public HomePresenter providePresenter() { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/modules/BookmarksFragmentModule.java | // Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/BookmarksPresenter.java
// public class BookmarksPresenter extends BasePresenter<BookmarksMvpView> {
//
// @Inject
// DataManager dataManager;
// @Inject
// Context context;
// private Subscription subscription;
//
// public BookmarksPresenter() {
// }
//
//
// @Override
// public void detachView() {
// super.detachView();
// RxUtil.unsubscribe(subscription);
// }
//
// @Override
// public void attachView(BookmarksMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication) (((FragmentBookmarks) getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
//
// public void loadBookmarks() {
// RxUtil.unsubscribe(subscription);
// subscription = dataManager.getAllBookmarks()
// .map(dbEntities -> Mappers.mapBookmarkDbEntityToItem(dbEntities, context))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Subscriber<List<BookmarkItem>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
// Toast.makeText(context, "Error when fetching bookmarks" + e.toString(), Toast.LENGTH_LONG).show();
// }
//
// @Override
// public void onNext(List<BookmarkItem> bookmarkItems) {
// if (bookmarkItems.isEmpty()) {
// getMvpView().showEmpty();
// } else {
// getMvpView().showBookmarks(bookmarkItems);
// }
// }
// });
// }
//
//
// public void deleteBookmark(BookmarkItem bookmark) {
// dataManager.deleteBookmark(bookmark.getBookmarkTitle());
// loadBookmarks();
// }
// }
| import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.presenters.BookmarksPresenter;
import dagger.Module;
import dagger.Provides; | package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@Module
public class BookmarksFragmentModule {
@PerFragment
@Provides | // Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/BookmarksPresenter.java
// public class BookmarksPresenter extends BasePresenter<BookmarksMvpView> {
//
// @Inject
// DataManager dataManager;
// @Inject
// Context context;
// private Subscription subscription;
//
// public BookmarksPresenter() {
// }
//
//
// @Override
// public void detachView() {
// super.detachView();
// RxUtil.unsubscribe(subscription);
// }
//
// @Override
// public void attachView(BookmarksMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication) (((FragmentBookmarks) getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
//
// public void loadBookmarks() {
// RxUtil.unsubscribe(subscription);
// subscription = dataManager.getAllBookmarks()
// .map(dbEntities -> Mappers.mapBookmarkDbEntityToItem(dbEntities, context))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Subscriber<List<BookmarkItem>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
// Toast.makeText(context, "Error when fetching bookmarks" + e.toString(), Toast.LENGTH_LONG).show();
// }
//
// @Override
// public void onNext(List<BookmarkItem> bookmarkItems) {
// if (bookmarkItems.isEmpty()) {
// getMvpView().showEmpty();
// } else {
// getMvpView().showBookmarks(bookmarkItems);
// }
// }
// });
// }
//
//
// public void deleteBookmark(BookmarkItem bookmark) {
// dataManager.deleteBookmark(bookmark.getBookmarkTitle());
// loadBookmarks();
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/BookmarksFragmentModule.java
import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.presenters.BookmarksPresenter;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@Module
public class BookmarksFragmentModule {
@PerFragment
@Provides | public BookmarksPresenter provideBookmarksPresenter() { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/data/DataManager.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
| import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable; | package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService; | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/data/DataManager.java
import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable;
package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService; | private CurrDate date; |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/data/DataManager.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
| import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable; | package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService;
private CurrDate date; | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/data/DataManager.java
import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable;
package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService;
private CurrDate date; | private RealmBookmarksHelper realmHelper; |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/data/DataManager.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
| import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable; | package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService;
private CurrDate date;
private RealmBookmarksHelper realmHelper;
@Inject
public DataManager(HacklistService hacklistService , CurrDate date, RealmBookmarksHelper realmBookmarksHelper) {
this.hacklistService = hacklistService;
this.date = date;
this.realmHelper = realmBookmarksHelper;
}
public HacklistService getHacklistService() {
return hacklistService;
}
public CurrDate getDate() {
return date;
}
| // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/data/DataManager.java
import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.util.CurrDate;
import java.util.List;
import javax.inject.Inject;
import rx.Observable;
package com.projects.elad.hacklist.data;
/**
* Created by EladKeyshawn on 24/02/2017.
*/
public class DataManager {
private HacklistService hacklistService;
private CurrDate date;
private RealmBookmarksHelper realmHelper;
@Inject
public DataManager(HacklistService hacklistService , CurrDate date, RealmBookmarksHelper realmBookmarksHelper) {
this.hacklistService = hacklistService;
this.date = date;
this.realmHelper = realmBookmarksHelper;
}
public HacklistService getHacklistService() {
return hacklistService;
}
public CurrDate getDate() {
return date;
}
| public Observable<List<BookmarkDbEntity>> getAllBookmarks() { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
| import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.util.CurrDate;
import dagger.Module;
import dagger.Provides; | package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class NetModule { | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java
import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.util.CurrDate;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class NetModule { | private CurrDate currDate; |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
| import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.util.CurrDate;
import dagger.Module;
import dagger.Provides; | package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class NetModule {
private CurrDate currDate;
public NetModule() {
currDate = new CurrDate();
}
@Provides
@HacklistApplicationScope
public CurrDate provideCurrDate() {
return currDate;
}
@Provides
@HacklistApplicationScope | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
// public interface HacklistService {
//
// @GET("/{YEAR}/{MONTH}.json")
// Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
//
//
// /******** Helper class that sets up new services *******/
// class ServiceCreator {
//
// public static HacklistService newHacklistService() {
// RestAdapter retrofitAdapter = new RestAdapter.Builder()
// .setLogLevel(RestAdapter.LogLevel.FULL)
// .setEndpoint(Constants.HACKALIST_BASE_URL)
// .build();
//
// return retrofitAdapter.create(HacklistService.class);
// }
// }
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/CurrDate.java
// public class CurrDate {
// private int currYearInt;
// private int currMonthInt;
// private String currentYear;
// private String currentMonth;
//
// public CurrDate() {
// Calendar calender = Calendar.getInstance();
//
// currYearInt = calender.get(Calendar.YEAR);
// currMonthInt = calender.get(Calendar.MONTH);
//
// currentYear = String.valueOf(currYearInt);
// currentMonth = Utils.getStringForMonthInt(currMonthInt);
// }
//
// public int getCurrYearInt() {
// return currYearInt;
// }
//
// public int getCurrMonthInt() {
// return currMonthInt;
// }
//
// public String getCurrentYear() {
// return currentYear;
// }
//
// public String getCurrentMonth() {
// return currentMonth;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java
import com.projects.elad.hacklist.data.api.HacklistService;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.util.CurrDate;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class NetModule {
private CurrDate currDate;
public NetModule() {
currDate = new CurrDate();
}
@Provides
@HacklistApplicationScope
public CurrDate provideCurrDate() {
return currDate;
}
@Provides
@HacklistApplicationScope | public HacklistService provideHacklistService(){ |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/components/AppComponent.java | // Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
// @Module
// public class AppModule {
// protected final Application application;
// public AppModule(Application application) {
// this.application = application;
// }
//
// @Provides
// Application provideApplication(){
// return application;
// }
//
// @Provides
// Context provideContext(){
// return application;
// }
//
// @Provides
// @HacklistApplicationScope
// public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){
// return new RealmBookmarksHelper(context);
// }
//
//
//
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java
// @Module
// public class NetModule {
// private CurrDate currDate;
//
// public NetModule() {
// currDate = new CurrDate();
// }
//
// @Provides
// @HacklistApplicationScope
// public CurrDate provideCurrDate() {
// return currDate;
// }
//
// @Provides
// @HacklistApplicationScope
// public HacklistService provideHacklistService(){
// return HacklistService.ServiceCreator.newHacklistService();
// }
//
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/BookmarksPresenter.java
// public class BookmarksPresenter extends BasePresenter<BookmarksMvpView> {
//
// @Inject
// DataManager dataManager;
// @Inject
// Context context;
// private Subscription subscription;
//
// public BookmarksPresenter() {
// }
//
//
// @Override
// public void detachView() {
// super.detachView();
// RxUtil.unsubscribe(subscription);
// }
//
// @Override
// public void attachView(BookmarksMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication) (((FragmentBookmarks) getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
//
// public void loadBookmarks() {
// RxUtil.unsubscribe(subscription);
// subscription = dataManager.getAllBookmarks()
// .map(dbEntities -> Mappers.mapBookmarkDbEntityToItem(dbEntities, context))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Subscriber<List<BookmarkItem>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
// Toast.makeText(context, "Error when fetching bookmarks" + e.toString(), Toast.LENGTH_LONG).show();
// }
//
// @Override
// public void onNext(List<BookmarkItem> bookmarkItems) {
// if (bookmarkItems.isEmpty()) {
// getMvpView().showEmpty();
// } else {
// getMvpView().showBookmarks(bookmarkItems);
// }
// }
// });
// }
//
//
// public void deleteBookmark(BookmarkItem bookmark) {
// dataManager.deleteBookmark(bookmark.getBookmarkTitle());
// loadBookmarks();
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/HomePresenter.java
// public class HomePresenter extends BasePresenter<HomeMvpView> {
//
// @Inject DataManager dataManager;
// private HashMap<Integer, Subscription> subscriptions;
// @Inject Context context;
//
// public HomePresenter() {
// subscriptions = new HashMap<>();
// }
//
//
// @Override
// public void attachView(HomeMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication)(((FragmentHome)getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
// @Override
// public void detachView() {
// super.detachView();
// unSubscribeAll();
// }
//
// void unSubscribeAll() {
// for (Subscription sub : subscriptions.values()) {
// RxUtil.unsubscribe(sub);
// }
// subscriptions.clear();
// }
//
// public void loadHackEvent() {
// checkViewAttached();
// unSubscribeAll();
//
// int month = dataManager.getDate().getCurrMonthInt();
// String year = dataManager.getDate().getCurrentYear();
// while (month < 12) {
// subscriptions.put(month,
// dataManager.getHacklistService().getMonthObject(year, Utils.getStringForMonthInt(month))
// .observeOn(AndroidSchedulers.mainThread())
// .subscribeOn(Schedulers.newThread())
// .map(v -> v.entrySet().iterator().next().getValue())
// .subscribe(new Subscriber<List<HackEvent>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(List<HackEvent> events) {
// getMvpView().showHackEvents(Mappers.mapHackEventsToListItems(events,context));
// }
// }));
//
// month++;
// }
//
// }
//
//
// public void saveListItem(ListItem item) {
// dataManager.saveBookmark(Mappers.mapHomeListItemToBookmarkDbEntity(item));
// }
//
// public boolean isBookmarkSaved(String title) {
// return dataManager.isSaved(title);
// }
//
//
// public void deleteBookmark(String title) {
// dataManager.deleteBookmark(title);
// }
// }
| import com.projects.elad.hacklist.injection.modules.AppModule;
import com.projects.elad.hacklist.injection.modules.NetModule;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.presentation.presenters.BookmarksPresenter;
import com.projects.elad.hacklist.presentation.presenters.HomePresenter;
import dagger.Component; | package com.projects.elad.hacklist.injection.components;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@HacklistApplicationScope
@Component(modules = {AppModule.class, NetModule.class})
public interface AppComponent { | // Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
// @Module
// public class AppModule {
// protected final Application application;
// public AppModule(Application application) {
// this.application = application;
// }
//
// @Provides
// Application provideApplication(){
// return application;
// }
//
// @Provides
// Context provideContext(){
// return application;
// }
//
// @Provides
// @HacklistApplicationScope
// public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){
// return new RealmBookmarksHelper(context);
// }
//
//
//
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/NetModule.java
// @Module
// public class NetModule {
// private CurrDate currDate;
//
// public NetModule() {
// currDate = new CurrDate();
// }
//
// @Provides
// @HacklistApplicationScope
// public CurrDate provideCurrDate() {
// return currDate;
// }
//
// @Provides
// @HacklistApplicationScope
// public HacklistService provideHacklistService(){
// return HacklistService.ServiceCreator.newHacklistService();
// }
//
//
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/BookmarksPresenter.java
// public class BookmarksPresenter extends BasePresenter<BookmarksMvpView> {
//
// @Inject
// DataManager dataManager;
// @Inject
// Context context;
// private Subscription subscription;
//
// public BookmarksPresenter() {
// }
//
//
// @Override
// public void detachView() {
// super.detachView();
// RxUtil.unsubscribe(subscription);
// }
//
// @Override
// public void attachView(BookmarksMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication) (((FragmentBookmarks) getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
//
// public void loadBookmarks() {
// RxUtil.unsubscribe(subscription);
// subscription = dataManager.getAllBookmarks()
// .map(dbEntities -> Mappers.mapBookmarkDbEntityToItem(dbEntities, context))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Subscriber<List<BookmarkItem>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
// Toast.makeText(context, "Error when fetching bookmarks" + e.toString(), Toast.LENGTH_LONG).show();
// }
//
// @Override
// public void onNext(List<BookmarkItem> bookmarkItems) {
// if (bookmarkItems.isEmpty()) {
// getMvpView().showEmpty();
// } else {
// getMvpView().showBookmarks(bookmarkItems);
// }
// }
// });
// }
//
//
// public void deleteBookmark(BookmarkItem bookmark) {
// dataManager.deleteBookmark(bookmark.getBookmarkTitle());
// loadBookmarks();
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/presenters/HomePresenter.java
// public class HomePresenter extends BasePresenter<HomeMvpView> {
//
// @Inject DataManager dataManager;
// private HashMap<Integer, Subscription> subscriptions;
// @Inject Context context;
//
// public HomePresenter() {
// subscriptions = new HashMap<>();
// }
//
//
// @Override
// public void attachView(HomeMvpView mvpView) {
// super.attachView(mvpView);
// ((HacklistApplication)(((FragmentHome)getMvpView()).getActivity().getApplication())).getComponent().inject(this);
//
// }
//
// @Override
// public void detachView() {
// super.detachView();
// unSubscribeAll();
// }
//
// void unSubscribeAll() {
// for (Subscription sub : subscriptions.values()) {
// RxUtil.unsubscribe(sub);
// }
// subscriptions.clear();
// }
//
// public void loadHackEvent() {
// checkViewAttached();
// unSubscribeAll();
//
// int month = dataManager.getDate().getCurrMonthInt();
// String year = dataManager.getDate().getCurrentYear();
// while (month < 12) {
// subscriptions.put(month,
// dataManager.getHacklistService().getMonthObject(year, Utils.getStringForMonthInt(month))
// .observeOn(AndroidSchedulers.mainThread())
// .subscribeOn(Schedulers.newThread())
// .map(v -> v.entrySet().iterator().next().getValue())
// .subscribe(new Subscriber<List<HackEvent>>() {
// @Override
// public void onCompleted() {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(List<HackEvent> events) {
// getMvpView().showHackEvents(Mappers.mapHackEventsToListItems(events,context));
// }
// }));
//
// month++;
// }
//
// }
//
//
// public void saveListItem(ListItem item) {
// dataManager.saveBookmark(Mappers.mapHomeListItemToBookmarkDbEntity(item));
// }
//
// public boolean isBookmarkSaved(String title) {
// return dataManager.isSaved(title);
// }
//
//
// public void deleteBookmark(String title) {
// dataManager.deleteBookmark(title);
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/components/AppComponent.java
import com.projects.elad.hacklist.injection.modules.AppModule;
import com.projects.elad.hacklist.injection.modules.NetModule;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import com.projects.elad.hacklist.presentation.presenters.BookmarksPresenter;
import com.projects.elad.hacklist.presentation.presenters.HomePresenter;
import dagger.Component;
package com.projects.elad.hacklist.injection.components;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@HacklistApplicationScope
@Component(modules = {AppModule.class, NetModule.class})
public interface AppComponent { | void inject(HomePresenter homePresenter); |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java | // Path: app/src/main/java/com/projects/elad/hacklist/util/Constants.java
// public class Constants {
//
// public static final String HACKALIST_BASE_URL = "http://www.hackalist.org/api/1.0";
// public static final String FACEBOOK_API_GET_PAGE_PICTURE = "https://graph.facebook.com/v2.7/"; //** /{page-id}/picture **/
//
// }
| import com.projects.elad.hacklist.util.Constants;
import java.util.List;
import java.util.Map;
import retrofit.RestAdapter;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package com.projects.elad.hacklist.data.api;
public interface HacklistService {
@GET("/{YEAR}/{MONTH}.json")
Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
/******** Helper class that sets up new services *******/
class ServiceCreator {
public static HacklistService newHacklistService() {
RestAdapter retrofitAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL) | // Path: app/src/main/java/com/projects/elad/hacklist/util/Constants.java
// public class Constants {
//
// public static final String HACKALIST_BASE_URL = "http://www.hackalist.org/api/1.0";
// public static final String FACEBOOK_API_GET_PAGE_PICTURE = "https://graph.facebook.com/v2.7/"; //** /{page-id}/picture **/
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/data/api/HacklistService.java
import com.projects.elad.hacklist.util.Constants;
import java.util.List;
import java.util.Map;
import retrofit.RestAdapter;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package com.projects.elad.hacklist.data.api;
public interface HacklistService {
@GET("/{YEAR}/{MONTH}.json")
Observable<Map<String, List<HackEvent>>> getMonthObject(@Path("YEAR") String year, @Path("MONTH") String month);
/******** Helper class that sets up new services *******/
class ServiceCreator {
public static HacklistService newHacklistService() {
RestAdapter retrofitAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL) | .setEndpoint(Constants.HACKALIST_BASE_URL) |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java | // Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java
// public class ListItem extends AbstractItem<ListItem, ListItem.ViewHolder> {
//
//
// Context context;
// String title;
// String year;
// String startDate;
// String endDate;
// String website;
// String host;
// String people;
// String duration;
// String travel;
// String prizes;
// String facebookUrl;
//
// public ListItem(HackEvent e, Context context) {
// this.context = context;
// this.title = e.getTitle();
// this.year = e.getYear();
// this.startDate = e.getStartDate();
// this.endDate = e.getEndDate();
// this.host = e.getHost();
// this.people = e.getSize();
// this.duration = e.getLength();
// this.travel = e.getTravel();
// this.prizes = e.getPrize();
// this.facebookUrl = e.getFacebookURL();
// this.website = e.getUrl();
// }
//
//
//
// public String getWebsite() {
// return website;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getTravel() {
// return travel;
// }
//
//
// public String getHost() {
// return host;
// }
//
//
// public String getPeople() {
// return people;
// }
//
// public String getDuration() {
// return duration;
// }
//
//
// public String getPrizes() {
// return prizes;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
//
// /** Here starts fast adapter implementation **/
//
//
// @Override
// public int getType() {
// return 0;
// }
//
// @Override
// public int getLayoutRes() {
// return R.layout.list_card_item;
// }
//
// @Override
// public void bindView(ListItem.ViewHolder holder) {
// super.bindView(holder);
//
// holder.title.setText(getTitle());
// holder.startDate.setText(getStartDate());
// holder.endDate.setText(getEndDate());
// holder.host.setText(getHost());
// holder.people.setText(getPeople());
// holder.duration.setText(getDuration());
// holder.year.setText("- " + year);
//
//
// switch (travel) {
// case "no":
// holder.travelIcon.setImageResource(R.drawable.ic_x_red);
// break;
// case "unknown":
// holder.travelIcon.setImageResource(R.drawable.ic_question);
// break;
// case "yes":
// holder.travelIcon.setImageResource(R.drawable.ic_ok_tick);
// break;
// }
// switch (getPrizes()) {
// case "no":
// holder.prizesIcon.setImageResource(R.drawable.ic_x_red);
// break;
// case "unknown":
// holder.prizesIcon.setImageResource(R.drawable.ic_question);
// break;
// case "yes":
// holder.prizesIcon.setImageResource(R.drawable.ic_ok_tick);
// break;
// }
//
// Picasso.with(context)
// .load(Utils.getPageIdFromUrl(facebookUrl))
// .placeholder(R.mipmap.ic_launcher)
// .into(holder.profile);
//
//
// }
//
// protected static class ViewHolder extends RecyclerView.ViewHolder {
// TextView title;
// TextView year;
// TextView startDate;
// TextView endDate;
// TextView host;
// TextView people;
// TextView duration;
//
// ImageView travelIcon;
// ImageView prizesIcon;
// ImageView profile;
//
//
// public ViewHolder(View itemView) {
// super(itemView);
//
// title = (TextView) itemView.findViewById(R.id.list_item_title);
// startDate = (TextView) itemView.findViewById(R.id.list_item_start_date);
// endDate = (TextView) itemView.findViewById(R.id.list_item_end_date);
// host = (TextView) itemView.findViewById(R.id.list_item_host);
// year = (TextView) itemView.findViewById(R.id.list_item_year);
// travelIcon = (ImageView) itemView.findViewById(R.id.list_item_travel_tick);
// prizesIcon = (ImageView) itemView.findViewById(R.id.list_item_prize_tick);
// people = (TextView) itemView.findViewById(R.id.list_item_size);
// duration = (TextView) itemView.findViewById(R.id.list_item_length);
// profile = (ImageView) itemView.findViewById(R.id.list_item_icon);
//
// }
// }
//
// }
| import com.projects.elad.hacklist.presentation.main.adapters.ListItem;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey; | package com.projects.elad.hacklist.data.db;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
public class BookmarkDbEntity extends RealmObject {
@PrimaryKey
private String eventTitle;
private String facebookUrl;
public BookmarkDbEntity() {
}
| // Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java
// public class ListItem extends AbstractItem<ListItem, ListItem.ViewHolder> {
//
//
// Context context;
// String title;
// String year;
// String startDate;
// String endDate;
// String website;
// String host;
// String people;
// String duration;
// String travel;
// String prizes;
// String facebookUrl;
//
// public ListItem(HackEvent e, Context context) {
// this.context = context;
// this.title = e.getTitle();
// this.year = e.getYear();
// this.startDate = e.getStartDate();
// this.endDate = e.getEndDate();
// this.host = e.getHost();
// this.people = e.getSize();
// this.duration = e.getLength();
// this.travel = e.getTravel();
// this.prizes = e.getPrize();
// this.facebookUrl = e.getFacebookURL();
// this.website = e.getUrl();
// }
//
//
//
// public String getWebsite() {
// return website;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getTravel() {
// return travel;
// }
//
//
// public String getHost() {
// return host;
// }
//
//
// public String getPeople() {
// return people;
// }
//
// public String getDuration() {
// return duration;
// }
//
//
// public String getPrizes() {
// return prizes;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
//
// /** Here starts fast adapter implementation **/
//
//
// @Override
// public int getType() {
// return 0;
// }
//
// @Override
// public int getLayoutRes() {
// return R.layout.list_card_item;
// }
//
// @Override
// public void bindView(ListItem.ViewHolder holder) {
// super.bindView(holder);
//
// holder.title.setText(getTitle());
// holder.startDate.setText(getStartDate());
// holder.endDate.setText(getEndDate());
// holder.host.setText(getHost());
// holder.people.setText(getPeople());
// holder.duration.setText(getDuration());
// holder.year.setText("- " + year);
//
//
// switch (travel) {
// case "no":
// holder.travelIcon.setImageResource(R.drawable.ic_x_red);
// break;
// case "unknown":
// holder.travelIcon.setImageResource(R.drawable.ic_question);
// break;
// case "yes":
// holder.travelIcon.setImageResource(R.drawable.ic_ok_tick);
// break;
// }
// switch (getPrizes()) {
// case "no":
// holder.prizesIcon.setImageResource(R.drawable.ic_x_red);
// break;
// case "unknown":
// holder.prizesIcon.setImageResource(R.drawable.ic_question);
// break;
// case "yes":
// holder.prizesIcon.setImageResource(R.drawable.ic_ok_tick);
// break;
// }
//
// Picasso.with(context)
// .load(Utils.getPageIdFromUrl(facebookUrl))
// .placeholder(R.mipmap.ic_launcher)
// .into(holder.profile);
//
//
// }
//
// protected static class ViewHolder extends RecyclerView.ViewHolder {
// TextView title;
// TextView year;
// TextView startDate;
// TextView endDate;
// TextView host;
// TextView people;
// TextView duration;
//
// ImageView travelIcon;
// ImageView prizesIcon;
// ImageView profile;
//
//
// public ViewHolder(View itemView) {
// super(itemView);
//
// title = (TextView) itemView.findViewById(R.id.list_item_title);
// startDate = (TextView) itemView.findViewById(R.id.list_item_start_date);
// endDate = (TextView) itemView.findViewById(R.id.list_item_end_date);
// host = (TextView) itemView.findViewById(R.id.list_item_host);
// year = (TextView) itemView.findViewById(R.id.list_item_year);
// travelIcon = (ImageView) itemView.findViewById(R.id.list_item_travel_tick);
// prizesIcon = (ImageView) itemView.findViewById(R.id.list_item_prize_tick);
// people = (TextView) itemView.findViewById(R.id.list_item_size);
// duration = (TextView) itemView.findViewById(R.id.list_item_length);
// profile = (ImageView) itemView.findViewById(R.id.list_item_icon);
//
// }
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
import com.projects.elad.hacklist.presentation.main.adapters.ListItem;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
package com.projects.elad.hacklist.data.db;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
public class BookmarkDbEntity extends RealmObject {
@PrimaryKey
private String eventTitle;
private String facebookUrl;
public BookmarkDbEntity() {
}
| public BookmarkDbEntity(ListItem item) { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
| import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import dagger.Module;
import dagger.Provides; | package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class AppModule {
protected final Application application;
public AppModule(Application application) {
this.application = application;
}
@Provides
Application provideApplication(){
return application;
}
@Provides
Context provideContext(){
return application;
}
@Provides
@HacklistApplicationScope | // Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
// private Realm realm;
// private Context context;
// @Inject
// public RealmBookmarksHelper(Context context) {
// Realm.init(context);
// this.context = context;
// }
//
// public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
// try {
// realm = Realm.getDefaultInstance();
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
// if (bookmark == null)
// bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
// bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
//
// });
// } finally {
// realm.close();
// }
// }
//
//
// public BookmarkDbEntity findInRealm(Realm realm, String title) {
// return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
// }
//
// public List<BookmarkDbEntity> findAllBookmarks() {
// realm = Realm.getDefaultInstance();
// return realm.where(BookmarkDbEntity.class).findAll();
// }
//
// public void deleteBookmark(String title) {
// try {
// realm = Realm.getDefaultInstance();
//
// realm.executeTransaction(transactionRealm -> {
// BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
// if (bookmark!=null) bookmark.deleteFromRealm();
// });
// } finally {
// realm.close();
// }
// }
//
// public boolean isInDatabase(String title) {
// realm = Realm.getDefaultInstance();
// BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
// realm.close();
// return entity != null;
// }
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;
/**
* Created by EladKeyshawn on 25/02/2017.
*/
@Module
public class AppModule {
protected final Application application;
public AppModule(Application application) {
this.application = application;
}
@Provides
Application provideApplication(){
return application;
}
@Provides
Context provideContext(){
return application;
}
@Provides
@HacklistApplicationScope | public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){ |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/BookmarkItem.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso; | package com.projects.elad.hacklist.presentation.main.adapters;
public class BookmarkItem extends AbstractItem<BookmarkItem, BookmarkItem.ViewHolder> {
private String bookmarkTitle;
private String eventFacebookUrl;
private Context context;
| // Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/BookmarkItem.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso;
package com.projects.elad.hacklist.presentation.main.adapters;
public class BookmarkItem extends AbstractItem<BookmarkItem, BookmarkItem.ViewHolder> {
private String bookmarkTitle;
private String eventFacebookUrl;
private Context context;
| public BookmarkItem(Context context, BookmarkDbEntity entity) { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/BookmarkItem.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso; |
public String getBookmarkTitle() {
return bookmarkTitle;
}
public String getEventFacebookUrl() {
return eventFacebookUrl;
}
public Context getContext() {
return context;
}
@Override
public int getType() {
return 0;
}
@Override
public int getLayoutRes() {
return R.layout.bookmark_event_item;
}
@Override
public void bindView(BookmarkItem.ViewHolder holder) {
super.bindView(holder);
holder.title.setText(bookmarkTitle);
Picasso.with(context) | // Path: app/src/main/java/com/projects/elad/hacklist/data/db/BookmarkDbEntity.java
// public class BookmarkDbEntity extends RealmObject {
// @PrimaryKey
// private String eventTitle;
// private String facebookUrl;
//
//
// public BookmarkDbEntity() {
//
// }
//
// public BookmarkDbEntity(ListItem item) {
// this.eventTitle = item.getTitle();
// this.facebookUrl = item.getFacebookUrl();
// }
//
//
// public String getEventTitle() {
// return eventTitle;
// }
//
// public String getFacebookUrl() {
// return facebookUrl;
// }
//
// public void setEventTitle(String eventTitle) {
// this.eventTitle = eventTitle;
// }
//
// public void setFacebookUrl(String facebookUrl) {
// this.facebookUrl = facebookUrl;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/BookmarkItem.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.db.BookmarkDbEntity;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso;
public String getBookmarkTitle() {
return bookmarkTitle;
}
public String getEventFacebookUrl() {
return eventFacebookUrl;
}
public Context getContext() {
return context;
}
@Override
public int getType() {
return 0;
}
@Override
public int getLayoutRes() {
return R.layout.bookmark_event_item;
}
@Override
public void bindView(BookmarkItem.ViewHolder holder) {
super.bindView(holder);
holder.title.setText(bookmarkTitle);
Picasso.with(context) | .load(Utils.getPageIdFromUrl(eventFacebookUrl)) |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/injection/components/BookmarksFragmentComponent.java | // Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/BookmarksFragmentModule.java
// @Module
// public class BookmarksFragmentModule {
//
// @PerFragment
// @Provides
// public BookmarksPresenter provideBookmarksPresenter() {
// return new BookmarksPresenter();
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/fragments/FragmentBookmarks.java
// public class FragmentBookmarks extends Fragment implements FastAdapter.OnLongClickListener, BookmarksMvpView {
//
// private FastAdapter fastAdapter;
// private ItemAdapter<BookmarkItem> itemFastAdapter;
// private LinearLayout noBookmarksLayout;
// private RecyclerView bookmarksList;
// private FragmentActivity context;
// @Inject BookmarksPresenter bookmarksPresenter;
//
//
// public FragmentBookmarks() {
// }
//
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setHasOptionsMenu(true);
// getComponent().inject(this);
// }
//
// BookmarksFragmentComponent getComponent() {
// return DaggerBookmarksFragmentComponent.builder().bookmarksFragmentModule(new BookmarksFragmentModule()).build();
// }
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// context = super.getActivity();
// View ourView = inflater.inflate(R.layout.fragment_bookmarks, container, false);
//
// noBookmarksLayout = (LinearLayout) ourView.findViewById(R.id.no_bookmarks_layout);
// bookmarksList = (RecyclerView) ourView.findViewById(R.id.bookmarks_list);
//
// fastAdapter = new FastAdapter();
// itemFastAdapter = new ItemAdapter<>();
// fastAdapter.withSelectOnLongClick(false);
// fastAdapter.withSelectable(false);
// fastAdapter.withOnLongClickListener(this);
//
//
// bookmarksList.setLayoutManager(new LinearLayoutManager(context));
// bookmarksList.setAdapter(itemFastAdapter.wrap(fastAdapter));
//
//
// return ourView;
// }
//
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// bookmarksPresenter.attachView(this);
// bookmarksPresenter.loadBookmarks();
// }
//
//
// public void showBookmarks(List<BookmarkItem> items) {
// noBookmarksLayout.setVisibility(View.GONE);
// itemFastAdapter.clear();
// itemFastAdapter.add(items);
// }
//
// @Override
// public void showEmpty() {
// itemFastAdapter.clear();
// noBookmarksLayout.setVisibility(View.VISIBLE);
// }
//
//
// @Override
// public void onResume() {
// super.onResume();
// }
//
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
// bookmarksPresenter.detachView();
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) { // fragment is visible so update bookmarks
// bookmarksPresenter.loadBookmarks();
// }
//
// }
//
// @Override
// public boolean onLongClick(View v, IAdapter adapter, IItem item, int position) {
// BookmarkItem bookmark = (BookmarkItem) item;
// openDeleteBookmarkDialog(bookmark);
// return true;
// }
//
// private void openDeleteBookmarkDialog(final BookmarkItem bookmark) {
// new MaterialDialog.Builder(context)
// .title("Delete bookmark")
// .content("Are you sure you to delete this bookmark?")
// .positiveText("delete")
// .positiveColor(Color.RED)
// .negativeText("cancel")
// .onPositive((dialog1, which) -> bookmarksPresenter.deleteBookmark(bookmark))
// .show();
//
// }
//
// }
| import com.projects.elad.hacklist.injection.modules.BookmarksFragmentModule;
import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.main.fragments.FragmentBookmarks;
import dagger.Component; | package com.projects.elad.hacklist.injection.components;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@PerFragment
@Component(modules = BookmarksFragmentModule.class)
public interface BookmarksFragmentComponent { | // Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/BookmarksFragmentModule.java
// @Module
// public class BookmarksFragmentModule {
//
// @PerFragment
// @Provides
// public BookmarksPresenter provideBookmarksPresenter() {
// return new BookmarksPresenter();
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/fragments/FragmentBookmarks.java
// public class FragmentBookmarks extends Fragment implements FastAdapter.OnLongClickListener, BookmarksMvpView {
//
// private FastAdapter fastAdapter;
// private ItemAdapter<BookmarkItem> itemFastAdapter;
// private LinearLayout noBookmarksLayout;
// private RecyclerView bookmarksList;
// private FragmentActivity context;
// @Inject BookmarksPresenter bookmarksPresenter;
//
//
// public FragmentBookmarks() {
// }
//
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setHasOptionsMenu(true);
// getComponent().inject(this);
// }
//
// BookmarksFragmentComponent getComponent() {
// return DaggerBookmarksFragmentComponent.builder().bookmarksFragmentModule(new BookmarksFragmentModule()).build();
// }
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// context = super.getActivity();
// View ourView = inflater.inflate(R.layout.fragment_bookmarks, container, false);
//
// noBookmarksLayout = (LinearLayout) ourView.findViewById(R.id.no_bookmarks_layout);
// bookmarksList = (RecyclerView) ourView.findViewById(R.id.bookmarks_list);
//
// fastAdapter = new FastAdapter();
// itemFastAdapter = new ItemAdapter<>();
// fastAdapter.withSelectOnLongClick(false);
// fastAdapter.withSelectable(false);
// fastAdapter.withOnLongClickListener(this);
//
//
// bookmarksList.setLayoutManager(new LinearLayoutManager(context));
// bookmarksList.setAdapter(itemFastAdapter.wrap(fastAdapter));
//
//
// return ourView;
// }
//
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// bookmarksPresenter.attachView(this);
// bookmarksPresenter.loadBookmarks();
// }
//
//
// public void showBookmarks(List<BookmarkItem> items) {
// noBookmarksLayout.setVisibility(View.GONE);
// itemFastAdapter.clear();
// itemFastAdapter.add(items);
// }
//
// @Override
// public void showEmpty() {
// itemFastAdapter.clear();
// noBookmarksLayout.setVisibility(View.VISIBLE);
// }
//
//
// @Override
// public void onResume() {
// super.onResume();
// }
//
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
// bookmarksPresenter.detachView();
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) { // fragment is visible so update bookmarks
// bookmarksPresenter.loadBookmarks();
// }
//
// }
//
// @Override
// public boolean onLongClick(View v, IAdapter adapter, IItem item, int position) {
// BookmarkItem bookmark = (BookmarkItem) item;
// openDeleteBookmarkDialog(bookmark);
// return true;
// }
//
// private void openDeleteBookmarkDialog(final BookmarkItem bookmark) {
// new MaterialDialog.Builder(context)
// .title("Delete bookmark")
// .content("Are you sure you to delete this bookmark?")
// .positiveText("delete")
// .positiveColor(Color.RED)
// .negativeText("cancel")
// .onPositive((dialog1, which) -> bookmarksPresenter.deleteBookmark(bookmark))
// .show();
//
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/injection/components/BookmarksFragmentComponent.java
import com.projects.elad.hacklist.injection.modules.BookmarksFragmentModule;
import com.projects.elad.hacklist.injection.scopes.PerFragment;
import com.projects.elad.hacklist.presentation.main.fragments.FragmentBookmarks;
import dagger.Component;
package com.projects.elad.hacklist.injection.components;
/**
* Created by EladKeyshawn on 01/03/2017.
*/
@PerFragment
@Component(modules = BookmarksFragmentModule.class)
public interface BookmarksFragmentComponent { | void inject(FragmentBookmarks fragmentHome); |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HackEvent.java
// public class HackEvent {
//
//
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("url")
// @Expose
// private String url;
// @SerializedName("startDate")
// @Expose
// private String startDate;
// @SerializedName("endDate")
// @Expose
// private String endDate;
// @SerializedName("year")
// @Expose
// private String year;
// @SerializedName("city")
// @Expose
// private String city;
// @SerializedName("host")
// @Expose
// private String host;
// @SerializedName("length")
// @Expose
// private String length;
// @SerializedName("size")
// @Expose
// private String size;
// @SerializedName("travel")
// @Expose
// private String travel;
// @SerializedName("prize")
// @Expose
// private String prize;
// @SerializedName("highSchoolers")
// @Expose
// private String highSchoolers;
// @SerializedName("facebookURL")
// @Expose
// private String facebookURL;
// @SerializedName("twitterURL")
// @Expose
// private String twitterURL;
// @SerializedName("googlePlusURL")
// @Expose
// private String googlePlusURL;
// @SerializedName("notes")
// @Expose
// private String notes;
//
//
// public String getTitle() {
// return title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getYear() {
// return year;
// }
//
// public String getCity() {
// return city;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getLength() {
// return length;
// }
//
// public String getSize() {
// return size;
// }
//
// public String getTravel() {
// return travel;
// }
//
// public String getPrize() {
// return prize;
// }
//
// public String getHighSchoolers() {
// return highSchoolers;
// }
//
// public String getFacebookURL() {
// return facebookURL;
// }
//
// public String getTwitterURL() {
// return twitterURL;
// }
//
// public String getGooglePlusURL() {
// return googlePlusURL;
// }
//
// public String getNotes() {
// return notes;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.api.HackEvent;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso; | package com.projects.elad.hacklist.presentation.main.adapters;
public class ListItem extends AbstractItem<ListItem, ListItem.ViewHolder> {
Context context;
String title;
String year;
String startDate;
String endDate;
String website;
String host;
String people;
String duration;
String travel;
String prizes;
String facebookUrl;
| // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HackEvent.java
// public class HackEvent {
//
//
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("url")
// @Expose
// private String url;
// @SerializedName("startDate")
// @Expose
// private String startDate;
// @SerializedName("endDate")
// @Expose
// private String endDate;
// @SerializedName("year")
// @Expose
// private String year;
// @SerializedName("city")
// @Expose
// private String city;
// @SerializedName("host")
// @Expose
// private String host;
// @SerializedName("length")
// @Expose
// private String length;
// @SerializedName("size")
// @Expose
// private String size;
// @SerializedName("travel")
// @Expose
// private String travel;
// @SerializedName("prize")
// @Expose
// private String prize;
// @SerializedName("highSchoolers")
// @Expose
// private String highSchoolers;
// @SerializedName("facebookURL")
// @Expose
// private String facebookURL;
// @SerializedName("twitterURL")
// @Expose
// private String twitterURL;
// @SerializedName("googlePlusURL")
// @Expose
// private String googlePlusURL;
// @SerializedName("notes")
// @Expose
// private String notes;
//
//
// public String getTitle() {
// return title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getYear() {
// return year;
// }
//
// public String getCity() {
// return city;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getLength() {
// return length;
// }
//
// public String getSize() {
// return size;
// }
//
// public String getTravel() {
// return travel;
// }
//
// public String getPrize() {
// return prize;
// }
//
// public String getHighSchoolers() {
// return highSchoolers;
// }
//
// public String getFacebookURL() {
// return facebookURL;
// }
//
// public String getTwitterURL() {
// return twitterURL;
// }
//
// public String getGooglePlusURL() {
// return googlePlusURL;
// }
//
// public String getNotes() {
// return notes;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.api.HackEvent;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso;
package com.projects.elad.hacklist.presentation.main.adapters;
public class ListItem extends AbstractItem<ListItem, ListItem.ViewHolder> {
Context context;
String title;
String year;
String startDate;
String endDate;
String website;
String host;
String people;
String duration;
String travel;
String prizes;
String facebookUrl;
| public ListItem(HackEvent e, Context context) { |
EladKeyshawn/HackList | app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HackEvent.java
// public class HackEvent {
//
//
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("url")
// @Expose
// private String url;
// @SerializedName("startDate")
// @Expose
// private String startDate;
// @SerializedName("endDate")
// @Expose
// private String endDate;
// @SerializedName("year")
// @Expose
// private String year;
// @SerializedName("city")
// @Expose
// private String city;
// @SerializedName("host")
// @Expose
// private String host;
// @SerializedName("length")
// @Expose
// private String length;
// @SerializedName("size")
// @Expose
// private String size;
// @SerializedName("travel")
// @Expose
// private String travel;
// @SerializedName("prize")
// @Expose
// private String prize;
// @SerializedName("highSchoolers")
// @Expose
// private String highSchoolers;
// @SerializedName("facebookURL")
// @Expose
// private String facebookURL;
// @SerializedName("twitterURL")
// @Expose
// private String twitterURL;
// @SerializedName("googlePlusURL")
// @Expose
// private String googlePlusURL;
// @SerializedName("notes")
// @Expose
// private String notes;
//
//
// public String getTitle() {
// return title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getYear() {
// return year;
// }
//
// public String getCity() {
// return city;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getLength() {
// return length;
// }
//
// public String getSize() {
// return size;
// }
//
// public String getTravel() {
// return travel;
// }
//
// public String getPrize() {
// return prize;
// }
//
// public String getHighSchoolers() {
// return highSchoolers;
// }
//
// public String getFacebookURL() {
// return facebookURL;
// }
//
// public String getTwitterURL() {
// return twitterURL;
// }
//
// public String getGooglePlusURL() {
// return googlePlusURL;
// }
//
// public String getNotes() {
// return notes;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.api.HackEvent;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso; | holder.host.setText(getHost());
holder.people.setText(getPeople());
holder.duration.setText(getDuration());
holder.year.setText("- " + year);
switch (travel) {
case "no":
holder.travelIcon.setImageResource(R.drawable.ic_x_red);
break;
case "unknown":
holder.travelIcon.setImageResource(R.drawable.ic_question);
break;
case "yes":
holder.travelIcon.setImageResource(R.drawable.ic_ok_tick);
break;
}
switch (getPrizes()) {
case "no":
holder.prizesIcon.setImageResource(R.drawable.ic_x_red);
break;
case "unknown":
holder.prizesIcon.setImageResource(R.drawable.ic_question);
break;
case "yes":
holder.prizesIcon.setImageResource(R.drawable.ic_ok_tick);
break;
}
Picasso.with(context) | // Path: app/src/main/java/com/projects/elad/hacklist/data/api/HackEvent.java
// public class HackEvent {
//
//
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("url")
// @Expose
// private String url;
// @SerializedName("startDate")
// @Expose
// private String startDate;
// @SerializedName("endDate")
// @Expose
// private String endDate;
// @SerializedName("year")
// @Expose
// private String year;
// @SerializedName("city")
// @Expose
// private String city;
// @SerializedName("host")
// @Expose
// private String host;
// @SerializedName("length")
// @Expose
// private String length;
// @SerializedName("size")
// @Expose
// private String size;
// @SerializedName("travel")
// @Expose
// private String travel;
// @SerializedName("prize")
// @Expose
// private String prize;
// @SerializedName("highSchoolers")
// @Expose
// private String highSchoolers;
// @SerializedName("facebookURL")
// @Expose
// private String facebookURL;
// @SerializedName("twitterURL")
// @Expose
// private String twitterURL;
// @SerializedName("googlePlusURL")
// @Expose
// private String googlePlusURL;
// @SerializedName("notes")
// @Expose
// private String notes;
//
//
// public String getTitle() {
// return title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getStartDate() {
// return startDate;
// }
//
// public String getEndDate() {
// return endDate;
// }
//
// public String getYear() {
// return year;
// }
//
// public String getCity() {
// return city;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getLength() {
// return length;
// }
//
// public String getSize() {
// return size;
// }
//
// public String getTravel() {
// return travel;
// }
//
// public String getPrize() {
// return prize;
// }
//
// public String getHighSchoolers() {
// return highSchoolers;
// }
//
// public String getFacebookURL() {
// return facebookURL;
// }
//
// public String getTwitterURL() {
// return twitterURL;
// }
//
// public String getGooglePlusURL() {
// return googlePlusURL;
// }
//
// public String getNotes() {
// return notes;
// }
// }
//
// Path: app/src/main/java/com/projects/elad/hacklist/util/Utils.java
// public class Utils {
//
//
// // get month in calender format and gives a string
// public static String getStringForMonthInt(int monthInt) {
// int temp = monthInt + 1;
// StringBuilder resultString = new StringBuilder();
// if (temp > 0 && temp < 10) {
// resultString.append("0").append(String.valueOf(temp));
// } else {
// resultString.append(String.valueOf(temp));
// }
// return resultString.toString();
// }
//
// public static String getPageIdFromUrl(String url) {
//
// StringBuilder resultUrl = new StringBuilder();
// resultUrl.append(Constants.FACEBOOK_API_GET_PAGE_PICTURE);
// int slashIndex = url.lastIndexOf('/');
//
// resultUrl.append(url.substring(slashIndex + 1)).append("/picture?type=large");
//
// return resultUrl.toString();
//
// }
//
// }
// Path: app/src/main/java/com/projects/elad/hacklist/presentation/main/adapters/ListItem.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.projects.elad.hacklist.R;
import com.projects.elad.hacklist.data.api.HackEvent;
import com.projects.elad.hacklist.util.Utils;
import com.squareup.picasso.Picasso;
holder.host.setText(getHost());
holder.people.setText(getPeople());
holder.duration.setText(getDuration());
holder.year.setText("- " + year);
switch (travel) {
case "no":
holder.travelIcon.setImageResource(R.drawable.ic_x_red);
break;
case "unknown":
holder.travelIcon.setImageResource(R.drawable.ic_question);
break;
case "yes":
holder.travelIcon.setImageResource(R.drawable.ic_ok_tick);
break;
}
switch (getPrizes()) {
case "no":
holder.prizesIcon.setImageResource(R.drawable.ic_x_red);
break;
case "unknown":
holder.prizesIcon.setImageResource(R.drawable.ic_question);
break;
case "yes":
holder.prizesIcon.setImageResource(R.drawable.ic_ok_tick);
break;
}
Picasso.with(context) | .load(Utils.getPageIdFromUrl(facebookUrl)) |
EsotericSoftware/yamlbeans | src/com/esotericsoftware/yamlbeans/Beans.java | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// static class ConstructorParameters {
// public Constructor constructor;
// public String[] parameterNames;
// }
| import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.esotericsoftware.yamlbeans.YamlConfig.ConstructorParameters;
| /*
* Copyright (c) 2008 Nathan Sweet
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans;
/** Utility for dealing with beans and public fields.
* @author <a href="mailto:misc@n4te.com">Nathan Sweet</a> */
class Beans {
private Beans () {
}
static public boolean isScalar (Class c) {
return c.isPrimitive() || c == String.class || c == Integer.class || c == Boolean.class || c == Float.class
|| c == Long.class || c == Double.class || c == Short.class || c == Byte.class || c == Character.class;
}
static public DeferredConstruction getDeferredConstruction (Class type, YamlConfig config) {
| // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// static class ConstructorParameters {
// public Constructor constructor;
// public String[] parameterNames;
// }
// Path: src/com/esotericsoftware/yamlbeans/Beans.java
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.esotericsoftware.yamlbeans.YamlConfig.ConstructorParameters;
/*
* Copyright (c) 2008 Nathan Sweet
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans;
/** Utility for dealing with beans and public fields.
* @author <a href="mailto:misc@n4te.com">Nathan Sweet</a> */
class Beans {
private Beans () {
}
static public boolean isScalar (Class c) {
return c.isPrimitive() || c == String.class || c == Integer.class || c == Boolean.class || c == Float.class
|| c == Long.class || c == Double.class || c == Short.class || c == Byte.class || c == Character.class;
}
static public DeferredConstruction getDeferredConstruction (Class type, YamlConfig config) {
| ConstructorParameters parameters = config.readConfig.constructorParameters.get(type);
|
EsotericSoftware/yamlbeans | src/com/esotericsoftware/yamlbeans/emitter/EmitterWriter.java | // Path: src/com/esotericsoftware/yamlbeans/constants/Unicode.java
// public final class Unicode {
//
// static public final char BELL = '\u0007';
// static public final char BACKSPACE = '\u0008';
// static public final char HORIZONTAL_TABULATION = '\u0009';
// static public final char VERTICAL_TABULATION = '\u000b';
// static public final char FORM_FEED = '\u000c';
// static public final char ESCAPE = '\u001b';
// static public final char SPACE = '\u0020';
// static public final char TILDE = '\u007e';
// static public final char NEXT_LINE = '\u0085';
// static public final char NO_BREAK_SPACE = '\u00a0';
//
// private Unicode() {
// }
// }
| import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import com.esotericsoftware.yamlbeans.constants.Unicode;
| /*
* Copyright (c) 2008 Nathan Sweet, Copyright (c) 2006 Ola Bini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans.emitter;
/** @author <a href="mailto:misc@n4te.com">Nathan Sweet</a>
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> */
class EmitterWriter {
private static final Map<Integer, String> ESCAPE_REPLACEMENTS = new HashMap();
static {
ESCAPE_REPLACEMENTS.put((int)'\0', "0");
| // Path: src/com/esotericsoftware/yamlbeans/constants/Unicode.java
// public final class Unicode {
//
// static public final char BELL = '\u0007';
// static public final char BACKSPACE = '\u0008';
// static public final char HORIZONTAL_TABULATION = '\u0009';
// static public final char VERTICAL_TABULATION = '\u000b';
// static public final char FORM_FEED = '\u000c';
// static public final char ESCAPE = '\u001b';
// static public final char SPACE = '\u0020';
// static public final char TILDE = '\u007e';
// static public final char NEXT_LINE = '\u0085';
// static public final char NO_BREAK_SPACE = '\u00a0';
//
// private Unicode() {
// }
// }
// Path: src/com/esotericsoftware/yamlbeans/emitter/EmitterWriter.java
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import com.esotericsoftware.yamlbeans.constants.Unicode;
/*
* Copyright (c) 2008 Nathan Sweet, Copyright (c) 2006 Ola Bini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans.emitter;
/** @author <a href="mailto:misc@n4te.com">Nathan Sweet</a>
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> */
class EmitterWriter {
private static final Map<Integer, String> ESCAPE_REPLACEMENTS = new HashMap();
static {
ESCAPE_REPLACEMENTS.put((int)'\0', "0");
| ESCAPE_REPLACEMENTS.put((int)Unicode.BELL, "a");
|
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/YamlConfigTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer; | yamlConfig = new YamlConfig();
}
@Test
public void testSetClassTag() throws YamlException {
yamlConfig.setClassTag("String", String.class);
yamlConfig.setClassTag("!Int", Integer.class);
String yaml = "!String test\n---\n!Int 1";
YamlReader yamlReader = new YamlReader(yaml, yamlConfig);
assertEquals("test", yamlReader.read());
assertEquals(1, yamlReader.read());
try {
yamlConfig.setClassTag(null, String.class);
} catch (IllegalArgumentException e) {
assertEquals("tag cannot be null.", e.getMessage());
}
try {
yamlConfig.setClassTag("str", null);
} catch (IllegalArgumentException e) {
assertEquals("type cannot be null.", e.getMessage());
}
}
@Test
public void testSetScalarSerializer() throws YamlException {
TimeZone timeZone = TimeZone.getTimeZone("GMT+0");
TimeZone.setDefault(timeZone);
| // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
// Path: test/com/esotericsoftware/yamlbeans/YamlConfigTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer;
yamlConfig = new YamlConfig();
}
@Test
public void testSetClassTag() throws YamlException {
yamlConfig.setClassTag("String", String.class);
yamlConfig.setClassTag("!Int", Integer.class);
String yaml = "!String test\n---\n!Int 1";
YamlReader yamlReader = new YamlReader(yaml, yamlConfig);
assertEquals("test", yamlReader.read());
assertEquals(1, yamlReader.read());
try {
yamlConfig.setClassTag(null, String.class);
} catch (IllegalArgumentException e) {
assertEquals("tag cannot be null.", e.getMessage());
}
try {
yamlConfig.setClassTag("str", null);
} catch (IllegalArgumentException e) {
assertEquals("type cannot be null.", e.getMessage());
}
}
@Test
public void testSetScalarSerializer() throws YamlException {
TimeZone timeZone = TimeZone.getTimeZone("GMT+0");
TimeZone.setDefault(timeZone);
| yamlConfig.setScalarSerializer(Date.class, new DateSerializer()); |
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/YamlConfigTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer; | try {
yamlConfig.setPropertyDefaultType(TestObject.class, null, Date.class);
} catch (IllegalArgumentException e) {
assertEquals("propertyName cannot be null.", e.getMessage());
}
try {
yamlConfig.setPropertyDefaultType(TestObject.class, "object", null);
} catch (IllegalArgumentException e) {
assertEquals("defaultType cannot be null.", e.getMessage());
}
try {
yamlConfig.setPropertyDefaultType(TestObject.class, "aaa", Date.class);
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("does not have a property named"));
}
}
@Test
public void testSetBeanProperties() throws YamlException {
String yaml = "a: test";
YamlReader yamlReader = new YamlReader(yaml, yamlConfig);
TestObject testObject = yamlReader.read(TestObject.class);
assertEquals("test", testObject.a);
yamlConfig.setBeanProperties(false);
yamlReader = new YamlReader(yaml, yamlConfig);
try {
yamlReader.read(TestObject.class); | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
// Path: test/com/esotericsoftware/yamlbeans/YamlConfigTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer;
try {
yamlConfig.setPropertyDefaultType(TestObject.class, null, Date.class);
} catch (IllegalArgumentException e) {
assertEquals("propertyName cannot be null.", e.getMessage());
}
try {
yamlConfig.setPropertyDefaultType(TestObject.class, "object", null);
} catch (IllegalArgumentException e) {
assertEquals("defaultType cannot be null.", e.getMessage());
}
try {
yamlConfig.setPropertyDefaultType(TestObject.class, "aaa", Date.class);
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("does not have a property named"));
}
}
@Test
public void testSetBeanProperties() throws YamlException {
String yaml = "a: test";
YamlReader yamlReader = new YamlReader(yaml, yamlConfig);
TestObject testObject = yamlReader.read(TestObject.class);
assertEquals("test", testObject.a);
yamlConfig.setBeanProperties(false);
yamlReader = new YamlReader(yaml, yamlConfig);
try {
yamlReader.read(TestObject.class); | } catch (YamlReaderException e) { |
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/YamlConfigTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer; |
}
@Test
public void testSetUseVerbatimTags() throws YamlException {
List<Integer> list = new LinkedList<Integer>();
list.add(1);
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write(list);
yamlWriter.close();
assertEquals("!java.util.LinkedList" + LINE_SEPARATOR + "- 1" + LINE_SEPARATOR, stringWriter.toString());
stringWriter = new StringWriter();
yamlConfig.writeConfig.setUseVerbatimTags(true);
yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write(list);
yamlWriter.close();
assertEquals("!<java.util.LinkedList>" + LINE_SEPARATOR + "- 1" + LINE_SEPARATOR, stringWriter.toString());
}
@Test
public void testSetQuoteChar() throws YamlException {
TestObject testObject = new TestObject();
testObject.age = 18;
testObject.name = "xxx";
StringWriter stringWriter = new StringWriter();
yamlConfig.writeConfig.setWriteRootTags(false); | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum Quote {
// NONE('\0'), SINGLE('\''), DOUBLE('"'), LITERAL('|'), FOLDED('>');
//
// char c;
//
// Quote (char c) {
// this.c = c;
// }
//
// public char getStyle() {
// return c;
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
//
// Path: src/com/esotericsoftware/yamlbeans/scalar/DateSerializer.java
// public class DateSerializer implements ScalarSerializer<Date> {
// private DateTimeParser dateParser = new DateTimeParser();
//
// public Date read (String value) throws YamlException {
// try {
// return dateParser.parse(value);
// } catch (ParseException ex) {
// throw new YamlException("Invalid date: " + value, ex);
// }
// }
//
// public String write (Date object) throws YamlException {
// return dateParser.format(object);
// }
// }
// Path: test/com/esotericsoftware/yamlbeans/YamlConfigTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlConfig.Quote;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import com.esotericsoftware.yamlbeans.scalar.DateSerializer;
}
@Test
public void testSetUseVerbatimTags() throws YamlException {
List<Integer> list = new LinkedList<Integer>();
list.add(1);
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write(list);
yamlWriter.close();
assertEquals("!java.util.LinkedList" + LINE_SEPARATOR + "- 1" + LINE_SEPARATOR, stringWriter.toString());
stringWriter = new StringWriter();
yamlConfig.writeConfig.setUseVerbatimTags(true);
yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write(list);
yamlWriter.close();
assertEquals("!<java.util.LinkedList>" + LINE_SEPARATOR + "- 1" + LINE_SEPARATOR, stringWriter.toString());
}
@Test
public void testSetQuoteChar() throws YamlException {
TestObject testObject = new TestObject();
testObject.age = 18;
testObject.name = "xxx";
StringWriter stringWriter = new StringWriter();
yamlConfig.writeConfig.setWriteRootTags(false); | yamlConfig.writeConfig.setQuoteChar(Quote.NONE); |
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/GenericTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum WriteClassName {
// ALWAYS, NEVER, AUTO
// }
| import com.esotericsoftware.yamlbeans.YamlConfig.WriteClassName;
import junit.framework.Assert;
import junit.framework.TestCase;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map; | + "- 100500" + LINE_SEPARATOR
+ "- 10" + LINE_SEPARATOR
+ "stringMap: " + LINE_SEPARATOR
+ " a: av" + LINE_SEPARATOR
+ " b: bv" + LINE_SEPARATOR
+ "structList: " + LINE_SEPARATOR
+ "- i: 10" + LINE_SEPARATOR
+ " str: aaa" + LINE_SEPARATOR
+ "- i: 20" + LINE_SEPARATOR
+ " str: bbb" + LINE_SEPARATOR
+ "structMap: " + LINE_SEPARATOR
+ " a: " + LINE_SEPARATOR
+ " i: 1" + LINE_SEPARATOR
+ " str: aa" + LINE_SEPARATOR
+ " b: " + LINE_SEPARATOR
+ " i: 2" + LINE_SEPARATOR
+ " str: ab" + LINE_SEPARATOR;
public void testRead() throws YamlException {
Test test = createTest();
Test read = new YamlReader(YAML).read(Test.class);
Assert.assertEquals(test, read);
}
public void testWrite() throws YamlException {
Test test = createTest();
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter); | // Path: src/com/esotericsoftware/yamlbeans/YamlConfig.java
// public static enum WriteClassName {
// ALWAYS, NEVER, AUTO
// }
// Path: test/com/esotericsoftware/yamlbeans/GenericTest.java
import com.esotericsoftware.yamlbeans.YamlConfig.WriteClassName;
import junit.framework.Assert;
import junit.framework.TestCase;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+ "- 100500" + LINE_SEPARATOR
+ "- 10" + LINE_SEPARATOR
+ "stringMap: " + LINE_SEPARATOR
+ " a: av" + LINE_SEPARATOR
+ " b: bv" + LINE_SEPARATOR
+ "structList: " + LINE_SEPARATOR
+ "- i: 10" + LINE_SEPARATOR
+ " str: aaa" + LINE_SEPARATOR
+ "- i: 20" + LINE_SEPARATOR
+ " str: bbb" + LINE_SEPARATOR
+ "structMap: " + LINE_SEPARATOR
+ " a: " + LINE_SEPARATOR
+ " i: 1" + LINE_SEPARATOR
+ " str: aa" + LINE_SEPARATOR
+ " b: " + LINE_SEPARATOR
+ " i: 2" + LINE_SEPARATOR
+ " str: ab" + LINE_SEPARATOR;
public void testRead() throws YamlException {
Test test = createTest();
Test read = new YamlReader(YAML).read(Test.class);
Assert.assertEquals(test, read);
}
public void testWrite() throws YamlException {
Test test = createTest();
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter); | yamlWriter.getConfig().writeConfig.setWriteClassname(WriteClassName.NEVER); |
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/YamlReaderTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
| import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import junit.framework.TestCase;
| assertEquals(null, reader.get("1"));
reader.read();
assertEquals("test", reader.get("1"));
reader.read();
assertEquals("222", reader.get("1"));
assertEquals("111", reader.get("2"));
}
public void testGetAnchorsUseGuessNumberTypes() throws YamlException {
String yaml = "number: &1 123";
YamlReader reader = new YamlReader(yaml);
reader.read();
assertEquals("123", reader.get("1"));
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.readConfig.guessNumberTypes = true;
reader = new YamlReader(yaml, yamlConfig);
reader.read();
assertEquals(123, ((Long) reader.get("1")).intValue());
}
public void testAnchorAndAlias() throws YamlException {
String yaml = "key: &1 value\nkey1: *1\n---\nkey: *1";
YamlReader reader = new YamlReader(yaml);
assertEquals("value", ((Map<String, String>) reader.read()).get("key1"));
assertEquals("value", reader.get("1"));
try {
reader.read();
| // Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
// Path: test/com/esotericsoftware/yamlbeans/YamlReaderTest.java
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import junit.framework.TestCase;
assertEquals(null, reader.get("1"));
reader.read();
assertEquals("test", reader.get("1"));
reader.read();
assertEquals("222", reader.get("1"));
assertEquals("111", reader.get("2"));
}
public void testGetAnchorsUseGuessNumberTypes() throws YamlException {
String yaml = "number: &1 123";
YamlReader reader = new YamlReader(yaml);
reader.read();
assertEquals("123", reader.get("1"));
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.readConfig.guessNumberTypes = true;
reader = new YamlReader(yaml, yamlConfig);
reader.read();
assertEquals(123, ((Long) reader.get("1")).intValue());
}
public void testAnchorAndAlias() throws YamlException {
String yaml = "key: &1 value\nkey1: *1\n---\nkey: *1";
YamlReader reader = new YamlReader(yaml);
assertEquals("value", ((Map<String, String>) reader.read()).get("key1"));
assertEquals("value", reader.get("1"));
try {
reader.read();
| } catch (YamlReaderException e) {
|
EsotericSoftware/yamlbeans | src/com/esotericsoftware/yamlbeans/emitter/ScalarAnalysis.java | // Path: src/com/esotericsoftware/yamlbeans/constants/Unicode.java
// public final class Unicode {
//
// static public final char BELL = '\u0007';
// static public final char BACKSPACE = '\u0008';
// static public final char HORIZONTAL_TABULATION = '\u0009';
// static public final char VERTICAL_TABULATION = '\u000b';
// static public final char FORM_FEED = '\u000c';
// static public final char ESCAPE = '\u001b';
// static public final char SPACE = '\u0020';
// static public final char TILDE = '\u007e';
// static public final char NEXT_LINE = '\u0085';
// static public final char NO_BREAK_SPACE = '\u00a0';
//
// private Unicode() {
// }
// }
| import java.util.regex.Pattern;
import com.esotericsoftware.yamlbeans.constants.Unicode;
| boolean leading = false;
int index = 0;
while (index < scalar.length()) {
char ceh = scalar.charAt(index);
if (index == 0) {
if (SPECIAL_INDICATOR.indexOf(ceh) != -1) {
flowIndicators = true;
blockIndicators = true;
}
if (ceh == '?' || ceh == ':') {
flowIndicators = true;
if (followedBySpace) blockIndicators = true;
}
if (ceh == '-' && followedBySpace) {
flowIndicators = true;
blockIndicators = true;
}
} else {
if (FLOW_INDICATOR.indexOf(ceh) != -1) flowIndicators = true;
if (ceh == ':') {
flowIndicators = true;
if (followedBySpace) blockIndicators = true;
}
if (ceh == '#' && preceededBySpace) {
flowIndicators = true;
blockIndicators = true;
}
}
| // Path: src/com/esotericsoftware/yamlbeans/constants/Unicode.java
// public final class Unicode {
//
// static public final char BELL = '\u0007';
// static public final char BACKSPACE = '\u0008';
// static public final char HORIZONTAL_TABULATION = '\u0009';
// static public final char VERTICAL_TABULATION = '\u000b';
// static public final char FORM_FEED = '\u000c';
// static public final char ESCAPE = '\u001b';
// static public final char SPACE = '\u0020';
// static public final char TILDE = '\u007e';
// static public final char NEXT_LINE = '\u0085';
// static public final char NO_BREAK_SPACE = '\u00a0';
//
// private Unicode() {
// }
// }
// Path: src/com/esotericsoftware/yamlbeans/emitter/ScalarAnalysis.java
import java.util.regex.Pattern;
import com.esotericsoftware.yamlbeans.constants.Unicode;
boolean leading = false;
int index = 0;
while (index < scalar.length()) {
char ceh = scalar.charAt(index);
if (index == 0) {
if (SPECIAL_INDICATOR.indexOf(ceh) != -1) {
flowIndicators = true;
blockIndicators = true;
}
if (ceh == '?' || ceh == ':') {
flowIndicators = true;
if (followedBySpace) blockIndicators = true;
}
if (ceh == '-' && followedBySpace) {
flowIndicators = true;
blockIndicators = true;
}
} else {
if (FLOW_INDICATOR.indexOf(ceh) != -1) flowIndicators = true;
if (ceh == ':') {
flowIndicators = true;
if (followedBySpace) blockIndicators = true;
}
if (ceh == '#' && preceededBySpace) {
flowIndicators = true;
blockIndicators = true;
}
}
| if (ceh == '\n' || Unicode.NEXT_LINE == ceh) lineBreaks = true;
|
EsotericSoftware/yamlbeans | src/com/esotericsoftware/yamlbeans/DeferredConstruction.java | // Path: src/com/esotericsoftware/yamlbeans/Beans.java
// static public abstract class Property implements Comparable<Property> {
// private final Class declaringClass;
// private final String name;
// private final Class type;
// private final Class elementType;
//
// Property (Class declaringClass, String name, Class type, Type genericType) {
// this.declaringClass = declaringClass;
// this.name = name;
// this.type = type;
// this.elementType = getElementTypeFromGenerics(genericType);
// }
//
// private Class getElementTypeFromGenerics (Type type) {
// if (type instanceof ParameterizedType) {
// ParameterizedType parameterizedType = (ParameterizedType)type;
// Type rawType = parameterizedType.getRawType();
//
// if (isCollection(rawType) || isMap(rawType)) {
// Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
// if (actualTypeArguments.length > 0) {
// final Type cType = actualTypeArguments[actualTypeArguments.length - 1];
// if (cType instanceof Class) {
// return (Class)cType;
// } else if (cType instanceof WildcardType) {
// WildcardType t = (WildcardType)cType;
// final Type bound = t.getUpperBounds()[0];
// return bound instanceof Class ? (Class)bound : null;
// } else if (cType instanceof ParameterizedType) {
// ParameterizedType t = (ParameterizedType)cType;
// final Type rt = t.getRawType();
// return rt instanceof Class ? (Class)rt : null;
// }
// }
// }
// }
// return null;
// }
//
// private boolean isMap (Type type) {
// return Map.class.isAssignableFrom((Class)type);
// }
//
// private boolean isCollection (Type type) {
// return Collection.class.isAssignableFrom((Class)type);
// }
//
// public int hashCode () {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((declaringClass == null) ? 0 : declaringClass.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((type == null) ? 0 : type.hashCode());
// result = prime * result + ((elementType == null) ? 0 : elementType.hashCode());
// return result;
// }
//
// public boolean equals (Object obj) {
// if (this == obj) return true;
// if (obj == null) return false;
// if (getClass() != obj.getClass()) return false;
// Property other = (Property)obj;
// if (declaringClass == null) {
// if (other.declaringClass != null) return false;
// } else if (!declaringClass.equals(other.declaringClass)) return false;
// if (name == null) {
// if (other.name != null) return false;
// } else if (!name.equals(other.name)) return false;
// if (type == null) {
// if (other.type != null) return false;
// } else if (!type.equals(other.type)) return false;
// if (elementType == null) {
// if (other.elementType != null) return false;
// } else if (!elementType.equals(other.elementType)) return false;
// return true;
// }
//
// public Class getDeclaringClass () {
// return declaringClass;
// }
//
// public Class getElementType () {
// return elementType;
// }
//
// public Class getType () {
// return type;
// }
//
// public String getName () {
// return name;
// }
//
// public String toString () {
// return name;
// }
//
// public int compareTo (Property o) {
// int comparison = name.compareTo(o.name);
// if (comparison != 0) {
// // Sort id and name above all other fields.
// if (name.equals("id")) return -1;
// if (o.name.equals("id")) return 1;
// if (name.equals("name")) return -1;
// if (o.name.equals("name")) return 1;
// }
// return comparison;
// }
//
// abstract public void set (Object object, Object value) throws Exception;
//
// abstract public Object get (Object object) throws Exception;
// }
| import com.esotericsoftware.yamlbeans.Beans.Property;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
| public Object construct () throws InvocationTargetException {
try {
Object[] parameters = new Object[parameterValues.length];
int i = 0;
boolean missingParameter = false;
for (ParameterValue parameter : parameterValues) {
if (parameter == null)
missingParameter = true;
else
parameters[i++] = parameter.value;
}
Object object;
if (missingParameter) {
try {
object = constructor.getDeclaringClass().getConstructor().newInstance();
} catch (Exception ex) {
throw new InvocationTargetException(new YamlException("Missing constructor property: " + parameterNames[i]));
}
} else object = constructor.newInstance(parameters);
for (PropertyValue propertyValue : propertyValues) {
if (propertyValue.value != null)
propertyValue.property.set(object, propertyValue.value);
}
return object;
} catch (Exception ex) {
throw new InvocationTargetException(ex, "Error constructing instance of class: "
+ constructor.getDeclaringClass().getName());
}
}
| // Path: src/com/esotericsoftware/yamlbeans/Beans.java
// static public abstract class Property implements Comparable<Property> {
// private final Class declaringClass;
// private final String name;
// private final Class type;
// private final Class elementType;
//
// Property (Class declaringClass, String name, Class type, Type genericType) {
// this.declaringClass = declaringClass;
// this.name = name;
// this.type = type;
// this.elementType = getElementTypeFromGenerics(genericType);
// }
//
// private Class getElementTypeFromGenerics (Type type) {
// if (type instanceof ParameterizedType) {
// ParameterizedType parameterizedType = (ParameterizedType)type;
// Type rawType = parameterizedType.getRawType();
//
// if (isCollection(rawType) || isMap(rawType)) {
// Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
// if (actualTypeArguments.length > 0) {
// final Type cType = actualTypeArguments[actualTypeArguments.length - 1];
// if (cType instanceof Class) {
// return (Class)cType;
// } else if (cType instanceof WildcardType) {
// WildcardType t = (WildcardType)cType;
// final Type bound = t.getUpperBounds()[0];
// return bound instanceof Class ? (Class)bound : null;
// } else if (cType instanceof ParameterizedType) {
// ParameterizedType t = (ParameterizedType)cType;
// final Type rt = t.getRawType();
// return rt instanceof Class ? (Class)rt : null;
// }
// }
// }
// }
// return null;
// }
//
// private boolean isMap (Type type) {
// return Map.class.isAssignableFrom((Class)type);
// }
//
// private boolean isCollection (Type type) {
// return Collection.class.isAssignableFrom((Class)type);
// }
//
// public int hashCode () {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((declaringClass == null) ? 0 : declaringClass.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((type == null) ? 0 : type.hashCode());
// result = prime * result + ((elementType == null) ? 0 : elementType.hashCode());
// return result;
// }
//
// public boolean equals (Object obj) {
// if (this == obj) return true;
// if (obj == null) return false;
// if (getClass() != obj.getClass()) return false;
// Property other = (Property)obj;
// if (declaringClass == null) {
// if (other.declaringClass != null) return false;
// } else if (!declaringClass.equals(other.declaringClass)) return false;
// if (name == null) {
// if (other.name != null) return false;
// } else if (!name.equals(other.name)) return false;
// if (type == null) {
// if (other.type != null) return false;
// } else if (!type.equals(other.type)) return false;
// if (elementType == null) {
// if (other.elementType != null) return false;
// } else if (!elementType.equals(other.elementType)) return false;
// return true;
// }
//
// public Class getDeclaringClass () {
// return declaringClass;
// }
//
// public Class getElementType () {
// return elementType;
// }
//
// public Class getType () {
// return type;
// }
//
// public String getName () {
// return name;
// }
//
// public String toString () {
// return name;
// }
//
// public int compareTo (Property o) {
// int comparison = name.compareTo(o.name);
// if (comparison != 0) {
// // Sort id and name above all other fields.
// if (name.equals("id")) return -1;
// if (o.name.equals("id")) return 1;
// if (name.equals("name")) return -1;
// if (o.name.equals("name")) return 1;
// }
// return comparison;
// }
//
// abstract public void set (Object object, Object value) throws Exception;
//
// abstract public Object get (Object object) throws Exception;
// }
// Path: src/com/esotericsoftware/yamlbeans/DeferredConstruction.java
import com.esotericsoftware.yamlbeans.Beans.Property;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
public Object construct () throws InvocationTargetException {
try {
Object[] parameters = new Object[parameterValues.length];
int i = 0;
boolean missingParameter = false;
for (ParameterValue parameter : parameterValues) {
if (parameter == null)
missingParameter = true;
else
parameters[i++] = parameter.value;
}
Object object;
if (missingParameter) {
try {
object = constructor.getDeclaringClass().getConstructor().newInstance();
} catch (Exception ex) {
throw new InvocationTargetException(new YamlException("Missing constructor property: " + parameterNames[i]));
}
} else object = constructor.newInstance(parameters);
for (PropertyValue propertyValue : propertyValues) {
if (propertyValue.value != null)
propertyValue.property.set(object, propertyValue.value);
}
return object;
} catch (Exception ex) {
throw new InvocationTargetException(ex, "Error constructing instance of class: "
+ constructor.getDeclaringClass().getName());
}
}
| public void storeProperty (Property property, Object value) {
|
EsotericSoftware/yamlbeans | test/com/esotericsoftware/yamlbeans/MergeTest.java | // Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
| import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import static org.junit.Assert.*; | Map<String, Object> map = (Map<String, Object>) yamlReader.read();
assertEquals("value1", ((Map<String, String>) map.get("test2")).get("key1"));
assertEquals("value2", ((Map<String, String>) map.get("test2")).get("key2"));
}
@SuppressWarnings("unchecked")
@Test
public void testMergeUpdateValue() throws YamlException {
StringBuilder sb = new StringBuilder();
sb.append("test1: &1\n").append(" - key1: value1\n").append(" - key2: value2\n").append(" - key3: value3\n");
sb.append("test2:\n").append(" key2: value22\n").append(" << : *1\n").append(" key3: value33\n");
YamlReader yamlReader = new YamlReader(sb.toString());
Map<String, Object> map = (Map<String, Object>) yamlReader.read();
assertEquals("value1", ((Map<String, String>) map.get("test2")).get("key1"));
assertEquals("value22", ((Map<String, String>) map.get("test2")).get("key2"));
assertEquals("value33", ((Map<String, String>) map.get("test2")).get("key3"));
}
@Test
public void testMergeExpectThrowYamlReaderException() throws YamlException {
StringBuilder sb = new StringBuilder();
sb.append("test1: &1 123\n");
sb.append("<< : *1\n");
YamlReader yamlReader = new YamlReader(sb.toString());
try {
yamlReader.read();
fail("Expected a mapping or a sequence of mappings"); | // Path: src/com/esotericsoftware/yamlbeans/YamlReader.java
// public class YamlReaderException extends YamlException {
// public YamlReaderException (String message, Throwable cause) {
// super("Line " + parser.getLineNumber() + ", column " + parser.getColumn() + ": " + message, cause);
// }
//
// public YamlReaderException (String message) {
// this(message, null);
// }
// }
// Path: test/com/esotericsoftware/yamlbeans/MergeTest.java
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import org.junit.Test;
import com.esotericsoftware.yamlbeans.YamlReader.YamlReaderException;
import static org.junit.Assert.*;
Map<String, Object> map = (Map<String, Object>) yamlReader.read();
assertEquals("value1", ((Map<String, String>) map.get("test2")).get("key1"));
assertEquals("value2", ((Map<String, String>) map.get("test2")).get("key2"));
}
@SuppressWarnings("unchecked")
@Test
public void testMergeUpdateValue() throws YamlException {
StringBuilder sb = new StringBuilder();
sb.append("test1: &1\n").append(" - key1: value1\n").append(" - key2: value2\n").append(" - key3: value3\n");
sb.append("test2:\n").append(" key2: value22\n").append(" << : *1\n").append(" key3: value33\n");
YamlReader yamlReader = new YamlReader(sb.toString());
Map<String, Object> map = (Map<String, Object>) yamlReader.read();
assertEquals("value1", ((Map<String, String>) map.get("test2")).get("key1"));
assertEquals("value22", ((Map<String, String>) map.get("test2")).get("key2"));
assertEquals("value33", ((Map<String, String>) map.get("test2")).get("key3"));
}
@Test
public void testMergeExpectThrowYamlReaderException() throws YamlException {
StringBuilder sb = new StringBuilder();
sb.append("test1: &1 123\n");
sb.append("<< : *1\n");
YamlReader yamlReader = new YamlReader(sb.toString());
try {
yamlReader.read();
fail("Expected a mapping or a sequence of mappings"); | } catch (YamlReaderException e) { |
EsotericSoftware/yamlbeans | src/com/esotericsoftware/yamlbeans/parser/DocumentStartEvent.java | // Path: src/com/esotericsoftware/yamlbeans/Version.java
// public class Version {
//
// public static final Version V1_0 = new Version(1, 0);
//
// public static final Version V1_1 = new Version(1, 1);
//
// /**
// * YAML 1.1
// */
// public static final Version DEFAULT_VERSION = V1_1;
//
// private final int major;
// private final int minor;
//
// private Version (int major, int minor) {
// this.major = major;
// this.minor = minor;
// }
//
// public static Version getVersion(String value) {
// Version version = null;
// if (value != null) {
// int dotIndex = value.indexOf('.');
// int major = 0;
// int minor = 0;
// if (dotIndex > 0) {
// try {
// major = Integer.parseInt(value.substring(0, dotIndex));
// minor = Integer.parseInt(value.substring(dotIndex + 1));
// } catch (NumberFormatException e) {
// return null;
// }
// }
//
// if (major == V1_0.major && minor == V1_0.minor) {
// version = V1_0;
// } else if (major == V1_1.major && minor == V1_1.minor) {
// version = V1_1;
// }
// }
// return version;
// }
//
// public int getMajor() {
// return major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public String toString () {
// return major + "." + minor;
// }
// }
| import com.esotericsoftware.yamlbeans.Version;
import java.util.Map; | /*
* Copyright (c) 2008 Nathan Sweet, Copyright (c) 2006 Ola Bini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans.parser;
/** @author <a href="mailto:misc@n4te.com">Nathan Sweet</a>
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> */
public class DocumentStartEvent extends Event {
public final boolean isExplicit; | // Path: src/com/esotericsoftware/yamlbeans/Version.java
// public class Version {
//
// public static final Version V1_0 = new Version(1, 0);
//
// public static final Version V1_1 = new Version(1, 1);
//
// /**
// * YAML 1.1
// */
// public static final Version DEFAULT_VERSION = V1_1;
//
// private final int major;
// private final int minor;
//
// private Version (int major, int minor) {
// this.major = major;
// this.minor = minor;
// }
//
// public static Version getVersion(String value) {
// Version version = null;
// if (value != null) {
// int dotIndex = value.indexOf('.');
// int major = 0;
// int minor = 0;
// if (dotIndex > 0) {
// try {
// major = Integer.parseInt(value.substring(0, dotIndex));
// minor = Integer.parseInt(value.substring(dotIndex + 1));
// } catch (NumberFormatException e) {
// return null;
// }
// }
//
// if (major == V1_0.major && minor == V1_0.minor) {
// version = V1_0;
// } else if (major == V1_1.major && minor == V1_1.minor) {
// version = V1_1;
// }
// }
// return version;
// }
//
// public int getMajor() {
// return major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public String toString () {
// return major + "." + minor;
// }
// }
// Path: src/com/esotericsoftware/yamlbeans/parser/DocumentStartEvent.java
import com.esotericsoftware.yamlbeans.Version;
import java.util.Map;
/*
* Copyright (c) 2008 Nathan Sweet, Copyright (c) 2006 Ola Bini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.esotericsoftware.yamlbeans.parser;
/** @author <a href="mailto:misc@n4te.com">Nathan Sweet</a>
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> */
public class DocumentStartEvent extends Event {
public final boolean isExplicit; | public final Version version; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/utils/DialogUtils.java | // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListItem;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo; | package com.pddstudio.otgsubs.utils;
/**
* Created by pddstudio on 25/04/2017.
*/
public class DialogUtils {
private DialogUtils() {}
| // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/utils/DialogUtils.java
import android.content.Context;
import android.support.annotation.NonNull;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListItem;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
package com.pddstudio.otgsubs.utils;
/**
* Created by pddstudio on 25/04/2017.
*/
public class DialogUtils {
private DialogUtils() {}
| public static MaterialSimpleListAdapter createAssetsItemSelectionAdapter(@NonNull Context context, @NonNull MaterialSimpleListAdapter.Callback callback, @NonNull AssetFileInfo assetFileInfo) { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/utils/DialogUtils.java | // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListItem;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo; | package com.pddstudio.otgsubs.utils;
/**
* Created by pddstudio on 25/04/2017.
*/
public class DialogUtils {
private DialogUtils() {}
public static MaterialSimpleListAdapter createAssetsItemSelectionAdapter(@NonNull Context context, @NonNull MaterialSimpleListAdapter.Callback callback, @NonNull AssetFileInfo assetFileInfo) {
MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(callback);
/*adapter.add(new MaterialSimpleListItem.Builder(context).content("Rename Item")
.iconPaddingDp(4)
.icon(R.drawable.ic_mode_edit_24dp)
.tag(new TagPair<>(assetFileInfo, AssetsModificationType.RENAME))
.build());*/
//TODO: fix rename action not working properly
adapter.add(new MaterialSimpleListItem.Builder(context).content("Delete Item")
.iconPaddingDp(4)
.icon(R.drawable.ic_delete_forever_24dp) | // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/utils/DialogUtils.java
import android.content.Context;
import android.support.annotation.NonNull;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter;
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListItem;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
package com.pddstudio.otgsubs.utils;
/**
* Created by pddstudio on 25/04/2017.
*/
public class DialogUtils {
private DialogUtils() {}
public static MaterialSimpleListAdapter createAssetsItemSelectionAdapter(@NonNull Context context, @NonNull MaterialSimpleListAdapter.Callback callback, @NonNull AssetFileInfo assetFileInfo) {
MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(callback);
/*adapter.add(new MaterialSimpleListItem.Builder(context).content("Rename Item")
.iconPaddingDp(4)
.icon(R.drawable.ic_mode_edit_24dp)
.tag(new TagPair<>(assetFileInfo, AssetsModificationType.RENAME))
.build());*/
//TODO: fix rename action not working properly
adapter.add(new MaterialSimpleListItem.Builder(context).content("Delete Item")
.iconPaddingDp(4)
.icon(R.drawable.ic_delete_forever_24dp) | .tag(new TagPair<>(assetFileInfo, AssetsModificationType.DELETE)) |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType; | package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 24/04/2017.
*/
public class AssetTypeAddedEvent {
private final AssetsType assetsType; | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 24/04/2017.
*/
public class AssetTypeAddedEvent {
private final AssetsType assetsType; | private final AssetFileInfo assetFileInfo; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/views/ColorPickerView.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
| import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.pddstudio.otgsubs.R;
import com.pddstudio.substratum.template.patcher.TemplateConfiguration; | package com.pddstudio.otgsubs.views;
/**
* Created by pddstudio on 04/05/2017.
*/
public class ColorPickerView extends RelativeLayout implements View.OnClickListener {
private Button colorPickerButton;
private ImageView colorImageView;
| // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/views/ColorPickerView.java
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.pddstudio.otgsubs.R;
import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
package com.pddstudio.otgsubs.views;
/**
* Created by pddstudio on 04/05/2017.
*/
public class ColorPickerView extends RelativeLayout implements View.OnClickListener {
private Button colorPickerButton;
private ImageView colorImageView;
| private TemplateConfiguration templateConfiguration; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/receivers/PackageManagerReceiver.java | // Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ManifestProcessorBean {
//
// private static final String TAG = ManifestProcessorBean.class.getSimpleName();
//
// private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
//
// @RootContext
// protected Context context;
//
// @Bean
// ApkHelper apkHelper;
//
// public List<ApkInfo> getSupportedThemes() {
// return StreamSupport.stream(apkHelper.getInstalledApks()).map(apkInfo -> {
// try {
// ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(apkInfo.getPackageName(), PackageManager.GET_META_DATA);
// if(applicationInfo == null) {
// return null;
// }
//
// Bundle bundle = applicationInfo.metaData;
// if(bundle == null) {
// return null;
// }
//
// boolean supported = bundle.getBoolean(OTG_SUBS_META_DATA_FLAG, false);
// if(supported) {
// Log.d(TAG, "Found OTGSubs supported apk: " + apkInfo.getPackageName());
// return apkInfo;
// } else {
// return null;
// }
// } catch (PackageManager.NameNotFoundException e) {
// //ignore
// return null;
// }
// }).filter(Objects::nonNull).collect(Collectors.toList());
// }
//
// public boolean isPackageSupported(String packageName) {
// if(packageName == null || packageName.isEmpty()) {
// return false;
// }
// return StreamSupport.stream(getSupportedThemes()).anyMatch(apkInfo -> apkInfo.getPackageName().equals(packageName));
// }
//
// public ApkInfo getApkInfoForPackage(String packageName) {
// if(!isPackageSupported(packageName)) {
// return null;
// }
// return StreamSupport.stream(getSupportedThemes()).filter(apkInfo -> apkInfo.getPackageName().equals(packageName)).findAny().orElse(null);
// }
//
// public Context getRootContext() {
// return context;
// }
//
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
| import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.pddstudio.otgsubs.PatcherActivity_;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.beans.ManifestProcessorBean;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EReceiver;
import org.androidannotations.annotations.ReceiverAction;
import org.androidannotations.annotations.SystemService;
import org.androidannotations.api.support.content.AbstractBroadcastReceiver; | package com.pddstudio.otgsubs.receivers;
/**
* Created by pddstudio on 11/05/2017.
*/
@EReceiver
public class PackageManagerReceiver extends AbstractBroadcastReceiver {
private static final String TAG = PackageManagerReceiver.class.getSimpleName();
private static final int NOTIFICATION_ID = 42;
@SystemService
protected NotificationManager notificationManager;
@Bean | // Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ManifestProcessorBean {
//
// private static final String TAG = ManifestProcessorBean.class.getSimpleName();
//
// private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
//
// @RootContext
// protected Context context;
//
// @Bean
// ApkHelper apkHelper;
//
// public List<ApkInfo> getSupportedThemes() {
// return StreamSupport.stream(apkHelper.getInstalledApks()).map(apkInfo -> {
// try {
// ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(apkInfo.getPackageName(), PackageManager.GET_META_DATA);
// if(applicationInfo == null) {
// return null;
// }
//
// Bundle bundle = applicationInfo.metaData;
// if(bundle == null) {
// return null;
// }
//
// boolean supported = bundle.getBoolean(OTG_SUBS_META_DATA_FLAG, false);
// if(supported) {
// Log.d(TAG, "Found OTGSubs supported apk: " + apkInfo.getPackageName());
// return apkInfo;
// } else {
// return null;
// }
// } catch (PackageManager.NameNotFoundException e) {
// //ignore
// return null;
// }
// }).filter(Objects::nonNull).collect(Collectors.toList());
// }
//
// public boolean isPackageSupported(String packageName) {
// if(packageName == null || packageName.isEmpty()) {
// return false;
// }
// return StreamSupport.stream(getSupportedThemes()).anyMatch(apkInfo -> apkInfo.getPackageName().equals(packageName));
// }
//
// public ApkInfo getApkInfoForPackage(String packageName) {
// if(!isPackageSupported(packageName)) {
// return null;
// }
// return StreamSupport.stream(getSupportedThemes()).filter(apkInfo -> apkInfo.getPackageName().equals(packageName)).findAny().orElse(null);
// }
//
// public Context getRootContext() {
// return context;
// }
//
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/receivers/PackageManagerReceiver.java
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.pddstudio.otgsubs.PatcherActivity_;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.beans.ManifestProcessorBean;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EReceiver;
import org.androidannotations.annotations.ReceiverAction;
import org.androidannotations.annotations.SystemService;
import org.androidannotations.api.support.content.AbstractBroadcastReceiver;
package com.pddstudio.otgsubs.receivers;
/**
* Created by pddstudio on 11/05/2017.
*/
@EReceiver
public class PackageManagerReceiver extends AbstractBroadcastReceiver {
private static final String TAG = PackageManagerReceiver.class.getSimpleName();
private static final int NOTIFICATION_ID = 42;
@SystemService
protected NotificationManager notificationManager;
@Bean | protected ManifestProcessorBean manifestProcessorBean; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/receivers/PackageManagerReceiver.java | // Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ManifestProcessorBean {
//
// private static final String TAG = ManifestProcessorBean.class.getSimpleName();
//
// private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
//
// @RootContext
// protected Context context;
//
// @Bean
// ApkHelper apkHelper;
//
// public List<ApkInfo> getSupportedThemes() {
// return StreamSupport.stream(apkHelper.getInstalledApks()).map(apkInfo -> {
// try {
// ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(apkInfo.getPackageName(), PackageManager.GET_META_DATA);
// if(applicationInfo == null) {
// return null;
// }
//
// Bundle bundle = applicationInfo.metaData;
// if(bundle == null) {
// return null;
// }
//
// boolean supported = bundle.getBoolean(OTG_SUBS_META_DATA_FLAG, false);
// if(supported) {
// Log.d(TAG, "Found OTGSubs supported apk: " + apkInfo.getPackageName());
// return apkInfo;
// } else {
// return null;
// }
// } catch (PackageManager.NameNotFoundException e) {
// //ignore
// return null;
// }
// }).filter(Objects::nonNull).collect(Collectors.toList());
// }
//
// public boolean isPackageSupported(String packageName) {
// if(packageName == null || packageName.isEmpty()) {
// return false;
// }
// return StreamSupport.stream(getSupportedThemes()).anyMatch(apkInfo -> apkInfo.getPackageName().equals(packageName));
// }
//
// public ApkInfo getApkInfoForPackage(String packageName) {
// if(!isPackageSupported(packageName)) {
// return null;
// }
// return StreamSupport.stream(getSupportedThemes()).filter(apkInfo -> apkInfo.getPackageName().equals(packageName)).findAny().orElse(null);
// }
//
// public Context getRootContext() {
// return context;
// }
//
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
| import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.pddstudio.otgsubs.PatcherActivity_;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.beans.ManifestProcessorBean;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EReceiver;
import org.androidannotations.annotations.ReceiverAction;
import org.androidannotations.annotations.SystemService;
import org.androidannotations.api.support.content.AbstractBroadcastReceiver; | package com.pddstudio.otgsubs.receivers;
/**
* Created by pddstudio on 11/05/2017.
*/
@EReceiver
public class PackageManagerReceiver extends AbstractBroadcastReceiver {
private static final String TAG = PackageManagerReceiver.class.getSimpleName();
private static final int NOTIFICATION_ID = 42;
@SystemService
protected NotificationManager notificationManager;
@Bean
protected ManifestProcessorBean manifestProcessorBean;
@ReceiverAction(actions = Intent.ACTION_PACKAGE_ADDED, dataSchemes = "package")
protected void onPackageAdded(Intent intent) {
Log.d(TAG, "onPackageAdded() : " + intent);
validatePackageCompatibility(intent);
}
@ReceiverAction(actions = Intent.ACTION_PACKAGE_REPLACED, dataSchemes = "package")
protected void onPackageUpdated(Intent intent) {
Log.d(TAG, "onPackageUpdated() : " + intent);
validatePackageCompatibility(intent);
}
private void validatePackageCompatibility(Intent intent) {
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
if (uid == -1) {
return;
}
PackageManager packageManager = manifestProcessorBean.getRootContext().getPackageManager();
String packageName = packageManager.getNameForUid(uid);
if (manifestProcessorBean.isPackageSupported(packageName)) { | // Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ManifestProcessorBean {
//
// private static final String TAG = ManifestProcessorBean.class.getSimpleName();
//
// private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
//
// @RootContext
// protected Context context;
//
// @Bean
// ApkHelper apkHelper;
//
// public List<ApkInfo> getSupportedThemes() {
// return StreamSupport.stream(apkHelper.getInstalledApks()).map(apkInfo -> {
// try {
// ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(apkInfo.getPackageName(), PackageManager.GET_META_DATA);
// if(applicationInfo == null) {
// return null;
// }
//
// Bundle bundle = applicationInfo.metaData;
// if(bundle == null) {
// return null;
// }
//
// boolean supported = bundle.getBoolean(OTG_SUBS_META_DATA_FLAG, false);
// if(supported) {
// Log.d(TAG, "Found OTGSubs supported apk: " + apkInfo.getPackageName());
// return apkInfo;
// } else {
// return null;
// }
// } catch (PackageManager.NameNotFoundException e) {
// //ignore
// return null;
// }
// }).filter(Objects::nonNull).collect(Collectors.toList());
// }
//
// public boolean isPackageSupported(String packageName) {
// if(packageName == null || packageName.isEmpty()) {
// return false;
// }
// return StreamSupport.stream(getSupportedThemes()).anyMatch(apkInfo -> apkInfo.getPackageName().equals(packageName));
// }
//
// public ApkInfo getApkInfoForPackage(String packageName) {
// if(!isPackageSupported(packageName)) {
// return null;
// }
// return StreamSupport.stream(getSupportedThemes()).filter(apkInfo -> apkInfo.getPackageName().equals(packageName)).findAny().orElse(null);
// }
//
// public Context getRootContext() {
// return context;
// }
//
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/receivers/PackageManagerReceiver.java
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.pddstudio.otgsubs.PatcherActivity_;
import com.pddstudio.otgsubs.R;
import com.pddstudio.otgsubs.beans.ManifestProcessorBean;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EReceiver;
import org.androidannotations.annotations.ReceiverAction;
import org.androidannotations.annotations.SystemService;
import org.androidannotations.api.support.content.AbstractBroadcastReceiver;
package com.pddstudio.otgsubs.receivers;
/**
* Created by pddstudio on 11/05/2017.
*/
@EReceiver
public class PackageManagerReceiver extends AbstractBroadcastReceiver {
private static final String TAG = PackageManagerReceiver.class.getSimpleName();
private static final int NOTIFICATION_ID = 42;
@SystemService
protected NotificationManager notificationManager;
@Bean
protected ManifestProcessorBean manifestProcessorBean;
@ReceiverAction(actions = Intent.ACTION_PACKAGE_ADDED, dataSchemes = "package")
protected void onPackageAdded(Intent intent) {
Log.d(TAG, "onPackageAdded() : " + intent);
validatePackageCompatibility(intent);
}
@ReceiverAction(actions = Intent.ACTION_PACKAGE_REPLACED, dataSchemes = "package")
protected void onPackageUpdated(Intent intent) {
Log.d(TAG, "onPackageUpdated() : " + intent);
validatePackageCompatibility(intent);
}
private void validatePackageCompatibility(Intent intent) {
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
if (uid == -1) {
return;
}
PackageManager packageManager = manifestProcessorBean.getRootContext().getPackageManager();
String packageName = packageManager.getNameForUid(uid);
if (manifestProcessorBean.isPackageSupported(packageName)) { | ApkInfo info = manifestProcessorBean.getApkInfoForPackage(packageName); |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
| import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport; | package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 28/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ManifestProcessorBean {
private static final String TAG = ManifestProcessorBean.class.getSimpleName();
private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
@RootContext
protected Context context;
@Bean | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;
package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 28/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ManifestProcessorBean {
private static final String TAG = ManifestProcessorBean.class.getSimpleName();
private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
@RootContext
protected Context context;
@Bean | ApkHelper apkHelper; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
| import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport; | package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 28/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ManifestProcessorBean {
private static final String TAG = ManifestProcessorBean.class.getSimpleName();
private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
@RootContext
protected Context context;
@Bean
ApkHelper apkHelper;
| // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/ManifestProcessorBean.java
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;
package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 28/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ManifestProcessorBean {
private static final String TAG = ManifestProcessorBean.class.getSimpleName();
private static final String OTG_SUBS_META_DATA_FLAG = "OTGSubs_Supported";
@RootContext
protected Context context;
@Bean
ApkHelper apkHelper;
| public List<ApkInfo> getSupportedThemes() { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/models/AssetsAdapterItem.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.iconics.typeface.IIcon;
import com.mikepenz.iconics.view.IconicsImageView;
import com.pddstudio.otgsubs.R;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.util.List; | package com.pddstudio.otgsubs.models;
/**
* Created by pddstudio on 24/04/2017.
*/
public class AssetsAdapterItem extends AbstractItem<AssetsAdapterItem, AssetsAdapterItem.ViewHolder> {
private AssetFileInfo fileInfo;
public AssetsAdapterItem(AssetFileInfo fileInfo) {
this.fileInfo = fileInfo;
}
private IIcon getIconForAssetsInfo() { | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsAdapterItem.java
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.iconics.typeface.IIcon;
import com.mikepenz.iconics.view.IconicsImageView;
import com.pddstudio.otgsubs.R;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.util.List;
package com.pddstudio.otgsubs.models;
/**
* Created by pddstudio on 24/04/2017.
*/
public class AssetsAdapterItem extends AbstractItem<AssetsAdapterItem, AssetsAdapterItem.ViewHolder> {
private AssetFileInfo fileInfo;
public AssetsAdapterItem(AssetFileInfo fileInfo) {
this.fileInfo = fileInfo;
}
private IIcon getIconForAssetsInfo() { | if (fileInfo.getType().equals(AssetsType.AUDIO)) { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java | // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
| import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo; | package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 25/04/2017.
*/
public class ExistingAssetsItemEvent {
private AssetFileInfo assetFileInfo; | // Path: app/src/main/java/com/pddstudio/otgsubs/models/AssetsModificationType.java
// public enum AssetsModificationType implements Serializable {
// RENAME,
// DELETE
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
import com.pddstudio.otgsubs.models.AssetsModificationType;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 25/04/2017.
*/
public class ExistingAssetsItemEvent {
private AssetFileInfo assetFileInfo; | private AssetsModificationType modificationType; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/events/PatchThemePreparationEvent.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
| import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.util.List; | package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 04/05/2017.
*/
public class PatchThemePreparationEvent {
private boolean success; | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/events/PatchThemePreparationEvent.java
import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.util.List;
package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 04/05/2017.
*/
public class PatchThemePreparationEvent {
private boolean success; | private List<TemplateConfiguration> templateConfigurations; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/events/PatchThemePreparationEvent.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
| import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.util.List; | package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 04/05/2017.
*/
public class PatchThemePreparationEvent {
private boolean success;
private List<TemplateConfiguration> templateConfigurations; | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/events/PatchThemePreparationEvent.java
import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.util.List;
package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 04/05/2017.
*/
public class PatchThemePreparationEvent {
private boolean success;
private List<TemplateConfiguration> templateConfigurations; | private ThemeConfiguration themeConfiguration; |
PDDStudio/OTGSubs | substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.io.File;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport; | package com.pddstudio.substratum.packager.utils;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkHelper {
private static final String TAG = ApkHelper.class.getSimpleName();
@RootContext
Context context;
PackageManager packageManager;
| // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import com.pddstudio.substratum.packager.models.ApkInfo;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import java.io.File;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;
package com.pddstudio.substratum.packager.utils;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkHelper {
private static final String TAG = ApkHelper.class.getSimpleName();
@RootContext
Context context;
PackageManager packageManager;
| public List<ApkInfo> getInstalledApks() { |
PDDStudio/OTGSubs | substratum-packager/src/main/java/com/pddstudio/substratum/packager/ApkExtractor.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
| import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java8.util.stream.StreamSupport; | package com.pddstudio.substratum.packager;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkExtractor {
private static final String TAG = ApkExtractor.class.getSimpleName();
| // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/ApkExtractor.java
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java8.util.stream.StreamSupport;
package com.pddstudio.substratum.packager;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkExtractor {
private static final String TAG = ApkExtractor.class.getSimpleName();
| private List<ApkInfo> apkInfos; |
PDDStudio/OTGSubs | substratum-packager/src/main/java/com/pddstudio/substratum/packager/ApkExtractor.java | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
| import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java8.util.stream.StreamSupport; | package com.pddstudio.substratum.packager;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkExtractor {
private static final String TAG = ApkExtractor.class.getSimpleName();
private List<ApkInfo> apkInfos;
@Bean | // Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/ApkInfo.java
// public class ApkInfo implements Serializable {
//
// private String appName;
// private String apk;
// private String version;
// private String source;
// private String data;
//
// public ApkInfo(String appName, String apk, String version, String source, String data) {
// this.appName = appName;
// this.apk = apk;
// this.version = version;
// this.source = source;
// this.data = data;
// }
//
// public String getAppName() {
// return appName;
// }
//
// public void setAppName(String appName) {
// this.appName = appName;
// }
//
// public String getPackageName() {
// return apk;
// }
//
// public void setApk(String apk) {
// this.apk = apk;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// @Override
// public String toString() {
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// return gson.toJson(this);
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/utils/ApkHelper.java
// @EBean(scope = EBean.Scope.Singleton)
// public class ApkHelper {
//
// private static final String TAG = ApkHelper.class.getSimpleName();
//
// @RootContext
// Context context;
// PackageManager packageManager;
//
// public List<ApkInfo> getInstalledApks() {
// packageManager = context.getPackageManager();
// List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
// return StreamSupport.stream(packages).map(this::convertPackageInfoToApkInfo).filter(apkInfo -> apkInfo != null).collect(Collectors.toList());
// }
//
// private ApkInfo convertPackageInfoToApkInfo(PackageInfo packageInfo) {
// if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// return new ApkInfo(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(),
// packageInfo.packageName,
// packageInfo.versionName,
// packageInfo.applicationInfo.sourceDir,
// packageInfo.applicationInfo.dataDir);
// } else {
// return null;
// }
// }
//
// public static Intent getShareIntent(File file) {
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_SEND);
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// intent.setType("application/vnd.android.package-archive");
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// return intent;
// }
//
// }
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/ApkExtractor.java
import android.util.Log;
import com.pddstudio.substratum.packager.models.ApkInfo;
import com.pddstudio.substratum.packager.utils.ApkHelper;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java8.util.stream.StreamSupport;
package com.pddstudio.substratum.packager;
/**
* Created by pddstudio on 21/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class ApkExtractor {
private static final String TAG = ApkExtractor.class.getSimpleName();
private List<ApkInfo> apkInfos;
@Bean | protected ApkHelper apkHelper; |
PDDStudio/OTGSubs | substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplatePatcher.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/LinePatcher.java
// public abstract class LinePatcher implements Patcher<String, String, String> {
//
// @Override
// public String patch(String target, String key, String value) {
// return patchLine(target, key, value);
// }
//
// public abstract String patchLine(String line, String targetKey, String replacementValue);
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java
// public class JsonConfigModel implements Serializable, ThemeConfiguration {
//
// @SerializedName("themeName")
// private String themeName;
//
// @SerializedName("themeAuthor")
// private String themeAuthor;
//
// @SerializedName("themeTemplates")
// private List<Template> templateList;
//
// @Override
// public String getThemeName() {
// return themeName;
// }
//
// @Override
// public String getThemeAuthor() {
// return themeAuthor;
// }
//
// @Override
// public List<TemplateConfiguration> getThemeTemplates() {
// List<TemplateConfiguration> configurations = new ArrayList<>();
// StreamSupport.stream(templateList).filter(Objects::nonNull).forEach(configurations::add);
// return configurations;
// }
//
// }
| import android.util.Log;
import com.google.gson.Gson;
import com.pddstudio.substratum.template.patcher.internal.LinePatcher;
import com.pddstudio.substratum.template.patcher.internal.model.JsonConfigModel;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport; | package com.pddstudio.substratum.template.patcher;
/**
* Created by pddstudio on 25/04/2017.
*/
public class TemplatePatcher {
private static final String TAG = TemplatePatcher.class.getSimpleName();
| // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/LinePatcher.java
// public abstract class LinePatcher implements Patcher<String, String, String> {
//
// @Override
// public String patch(String target, String key, String value) {
// return patchLine(target, key, value);
// }
//
// public abstract String patchLine(String line, String targetKey, String replacementValue);
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java
// public class JsonConfigModel implements Serializable, ThemeConfiguration {
//
// @SerializedName("themeName")
// private String themeName;
//
// @SerializedName("themeAuthor")
// private String themeAuthor;
//
// @SerializedName("themeTemplates")
// private List<Template> templateList;
//
// @Override
// public String getThemeName() {
// return themeName;
// }
//
// @Override
// public String getThemeAuthor() {
// return themeAuthor;
// }
//
// @Override
// public List<TemplateConfiguration> getThemeTemplates() {
// List<TemplateConfiguration> configurations = new ArrayList<>();
// StreamSupport.stream(templateList).filter(Objects::nonNull).forEach(configurations::add);
// return configurations;
// }
//
// }
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplatePatcher.java
import android.util.Log;
import com.google.gson.Gson;
import com.pddstudio.substratum.template.patcher.internal.LinePatcher;
import com.pddstudio.substratum.template.patcher.internal.model.JsonConfigModel;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;
package com.pddstudio.substratum.template.patcher;
/**
* Created by pddstudio on 25/04/2017.
*/
public class TemplatePatcher {
private static final String TAG = TemplatePatcher.class.getSimpleName();
| private final LinePatcher linePatcher; |
PDDStudio/OTGSubs | substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplatePatcher.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/LinePatcher.java
// public abstract class LinePatcher implements Patcher<String, String, String> {
//
// @Override
// public String patch(String target, String key, String value) {
// return patchLine(target, key, value);
// }
//
// public abstract String patchLine(String line, String targetKey, String replacementValue);
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java
// public class JsonConfigModel implements Serializable, ThemeConfiguration {
//
// @SerializedName("themeName")
// private String themeName;
//
// @SerializedName("themeAuthor")
// private String themeAuthor;
//
// @SerializedName("themeTemplates")
// private List<Template> templateList;
//
// @Override
// public String getThemeName() {
// return themeName;
// }
//
// @Override
// public String getThemeAuthor() {
// return themeAuthor;
// }
//
// @Override
// public List<TemplateConfiguration> getThemeTemplates() {
// List<TemplateConfiguration> configurations = new ArrayList<>();
// StreamSupport.stream(templateList).filter(Objects::nonNull).forEach(configurations::add);
// return configurations;
// }
//
// }
| import android.util.Log;
import com.google.gson.Gson;
import com.pddstudio.substratum.template.patcher.internal.LinePatcher;
import com.pddstudio.substratum.template.patcher.internal.model.JsonConfigModel;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport; | }
}
private void patch(TemplateConfiguration templateConfiguration, PatchingCallback callback) throws PatchingException {
File templateFile = callback.resolveTemplateFileName(templateConfiguration.getTemplateFileName());
if(templateFile == null ||!templateFile.exists() || templateFile.isDirectory()) {
throw new PatchingException("Template File must not be null, empty or a directory!");
}
try {
List<String> content = FileUtils.readLines(templateFile, Charset.forName("utf-8"));
List<String> patchedContent = patchLines(content, templateConfiguration);
if(patchedContent != null && !patchedContent.isEmpty()) {
File newDestination = new File(templateFile.getParentFile(), FilenameUtils.removeExtension(callback.getPatchedFileName(templateConfiguration) + ".xml"));
StreamSupport.stream(patchedContent).forEach(line -> Log.d(TAG, "PATCHED: " + line));
FileUtils.writeLines(newDestination, patchedContent, false);
}
} catch (IOException e) {
throw new PatchingException(e);
}
}
public static final class Builder {
private final List<File> targetFiles;
private LinePatcher linePatcher = XmlPatcher.getInstance();
private final ThemeConfiguration themeConfiguration;
public static Builder fromJson(String jsonContent) throws PatchingException {
Log.d("TemplatePatcher$Builder", "JSON: " + jsonContent);
Gson gson = new Gson(); | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/LinePatcher.java
// public abstract class LinePatcher implements Patcher<String, String, String> {
//
// @Override
// public String patch(String target, String key, String value) {
// return patchLine(target, key, value);
// }
//
// public abstract String patchLine(String line, String targetKey, String replacementValue);
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java
// public class JsonConfigModel implements Serializable, ThemeConfiguration {
//
// @SerializedName("themeName")
// private String themeName;
//
// @SerializedName("themeAuthor")
// private String themeAuthor;
//
// @SerializedName("themeTemplates")
// private List<Template> templateList;
//
// @Override
// public String getThemeName() {
// return themeName;
// }
//
// @Override
// public String getThemeAuthor() {
// return themeAuthor;
// }
//
// @Override
// public List<TemplateConfiguration> getThemeTemplates() {
// List<TemplateConfiguration> configurations = new ArrayList<>();
// StreamSupport.stream(templateList).filter(Objects::nonNull).forEach(configurations::add);
// return configurations;
// }
//
// }
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplatePatcher.java
import android.util.Log;
import com.google.gson.Gson;
import com.pddstudio.substratum.template.patcher.internal.LinePatcher;
import com.pddstudio.substratum.template.patcher.internal.model.JsonConfigModel;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;
}
}
private void patch(TemplateConfiguration templateConfiguration, PatchingCallback callback) throws PatchingException {
File templateFile = callback.resolveTemplateFileName(templateConfiguration.getTemplateFileName());
if(templateFile == null ||!templateFile.exists() || templateFile.isDirectory()) {
throw new PatchingException("Template File must not be null, empty or a directory!");
}
try {
List<String> content = FileUtils.readLines(templateFile, Charset.forName("utf-8"));
List<String> patchedContent = patchLines(content, templateConfiguration);
if(patchedContent != null && !patchedContent.isEmpty()) {
File newDestination = new File(templateFile.getParentFile(), FilenameUtils.removeExtension(callback.getPatchedFileName(templateConfiguration) + ".xml"));
StreamSupport.stream(patchedContent).forEach(line -> Log.d(TAG, "PATCHED: " + line));
FileUtils.writeLines(newDestination, patchedContent, false);
}
} catch (IOException e) {
throw new PatchingException(e);
}
}
public static final class Builder {
private final List<File> targetFiles;
private LinePatcher linePatcher = XmlPatcher.getInstance();
private final ThemeConfiguration themeConfiguration;
public static Builder fromJson(String jsonContent) throws PatchingException {
Log.d("TemplatePatcher$Builder", "JSON: " + jsonContent);
Gson gson = new Gson(); | JsonConfigModel configModel = gson.fromJson(jsonContent, JsonConfigModel.class); |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport; | package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 24/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class PackageInfoBean {
| // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java
import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport;
package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 24/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class PackageInfoBean {
| private final List<AssetFileInfo> fontInformation; |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport; | package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 24/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class PackageInfoBean {
private final List<AssetFileInfo> fontInformation;
private final List<AssetFileInfo> overlayInformation;
private final List<AssetFileInfo> audioInformation;
private final List<AssetFileInfo> bootAnimationInformation;
@Bean
EventBusBean eventBusBean;
public PackageInfoBean() {
this.fontInformation = new ArrayList<>();
this.overlayInformation = new ArrayList<>();
this.audioInformation = new ArrayList<>();
this.bootAnimationInformation = new ArrayList<>();
}
| // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java
import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport;
package com.pddstudio.otgsubs.beans;
/**
* Created by pddstudio on 24/04/2017.
*/
@EBean(scope = EBean.Scope.Singleton)
public class PackageInfoBean {
private final List<AssetFileInfo> fontInformation;
private final List<AssetFileInfo> overlayInformation;
private final List<AssetFileInfo> audioInformation;
private final List<AssetFileInfo> bootAnimationInformation;
@Bean
EventBusBean eventBusBean;
public PackageInfoBean() {
this.fontInformation = new ArrayList<>();
this.overlayInformation = new ArrayList<>();
this.audioInformation = new ArrayList<>();
this.bootAnimationInformation = new ArrayList<>();
}
| private void redirectEvent(AssetTypeAddedEvent event) { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport; | String parent = new File(oldInfo.getRelativeAssetsDestinationLocation()).getParent();
File newFile = new File(parent, newFileName);
oldInfo.setRelativeAssetsDestinationLocation(newFile.getAbsolutePath());
} else {
oldInfo.setFileName(newFileName);
}
});
}
public void register() {
eventBusBean.register(this);
}
public void unregister() {
eventBusBean.unregister(this);
}
@Subscribe
public void onDialogResultReceived(AssetTypeAddedEvent event) {
if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo); | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java
import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport;
String parent = new File(oldInfo.getRelativeAssetsDestinationLocation()).getParent();
File newFile = new File(parent, newFileName);
oldInfo.setRelativeAssetsDestinationLocation(newFile.getAbsolutePath());
} else {
oldInfo.setFileName(newFileName);
}
});
}
public void register() {
eventBusBean.register(this);
}
public void unregister() {
eventBusBean.unregister(this);
}
@Subscribe
public void onDialogResultReceived(AssetTypeAddedEvent event) {
if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo); | eventBusBean.post(new RefreshItemListEvent()); |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport; | }
});
}
public void register() {
eventBusBean.register(this);
}
public void unregister() {
eventBusBean.unregister(this);
}
@Subscribe
public void onDialogResultReceived(AssetTypeAddedEvent event) {
if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo);
eventBusBean.post(new RefreshItemListEvent());
}
}
@Subscribe | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java
import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport;
}
});
}
public void register() {
eventBusBean.register(this);
}
public void unregister() {
eventBusBean.unregister(this);
}
@Subscribe
public void onDialogResultReceived(AssetTypeAddedEvent event) {
if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo);
eventBusBean.post(new RefreshItemListEvent());
}
}
@Subscribe | public void onExistingAssetsModifiedEventReceived(ExistingAssetsItemEvent event) { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java | // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
| import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport; | if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo);
eventBusBean.post(new RefreshItemListEvent());
}
}
@Subscribe
public void onExistingAssetsModifiedEventReceived(ExistingAssetsItemEvent event) {
if(event != null) {
switch (event.getModificationType()) {
case DELETE:
removeItemIfPresent(event.getAssetFileInfo());
break;
case RENAME:
renameItemIfPresent(event.getAssetFileInfo(), event.getNewName());
break;
}
eventBusBean.post(new RefreshItemListEvent());
}
}
| // Path: app/src/main/java/com/pddstudio/otgsubs/events/AssetTypeAddedEvent.java
// public class AssetTypeAddedEvent {
//
// private final AssetsType assetsType;
// private final AssetFileInfo assetFileInfo;
// private boolean fragmentIgnore = true;
//
// public AssetTypeAddedEvent(AssetsType assetsType, AssetFileInfo assetFileInfo) {
// this.assetsType = assetsType;
// this.assetFileInfo = assetFileInfo;
// }
//
// public AssetsType getAssetsType() {
// return assetsType;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public boolean isIgnore() {
// return fragmentIgnore;
// }
//
// public void setFragmentIgnore(boolean fragmentIgnore) {
// this.fragmentIgnore = fragmentIgnore;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ExistingAssetsItemEvent.java
// public class ExistingAssetsItemEvent {
//
// private AssetFileInfo assetFileInfo;
// private AssetsModificationType modificationType;
// private String newName;
//
// public ExistingAssetsItemEvent(AssetFileInfo assetFileInfo, AssetsModificationType modificationType) {
// this.assetFileInfo = assetFileInfo;
// this.modificationType = modificationType;
// }
//
// public void setNewName(String newName) {
// this.newName = newName;
// }
//
// public AssetFileInfo getAssetFileInfo() {
// return assetFileInfo;
// }
//
// public AssetsModificationType getModificationType() {
// return modificationType;
// }
//
// public String getNewName() {
// return newName;
// }
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/ImportAssetsFromApkEvent.java
// public class ImportAssetsFromApkEvent {
//
// private final List<AssetFileInfo> assets;
//
// public ImportAssetsFromApkEvent() {
// assets = new ArrayList<>();
// }
//
// public ImportAssetsFromApkEvent withList(List<AssetFileInfo> files) {
// this.assets.addAll(files);
// return this;
// }
//
// public List<AssetFileInfo> getAssets() {
// return assets;
// }
//
// }
//
// Path: app/src/main/java/com/pddstudio/otgsubs/events/RefreshItemListEvent.java
// public class RefreshItemListEvent {}
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetFileInfo.java
// public class AssetFileInfo implements Serializable {
//
// private AssetsType type;
// private String fileLocation;
// private String fileName;
// private String relativeAssetsDestinationLocation;
//
// public AssetFileInfo(AssetsType type, String fileLocation, String fileName) {
// this.type = type;
// this.fileLocation = fileLocation;
// this.fileName = fileName;
// }
//
// public AssetsType getType() {
// return type;
// }
//
// public String getFileLocation() {
// return fileLocation;
// }
//
// public String getFileName() {
// return fileName;
// }
//
// public String getRelativeAssetsDestinationLocation() {
// return relativeAssetsDestinationLocation;
// }
//
// public void setRelativeAssetsDestinationLocation(String relativeAssetsDestinationLocation) {
// this.relativeAssetsDestinationLocation = relativeAssetsDestinationLocation;
// }
//
// public void setFileName(String fileName) {
// this.fileName = fileName;
// }
// }
//
// Path: substratum-packager/src/main/java/com/pddstudio/substratum/packager/models/AssetsType.java
// public enum AssetsType implements Serializable {
// FONTS(R.string.fragment_title_fonts),
// OVERLAYS(R.string.fragment_title_overlays),
// AUDIO(R.string.fragment_title_audio),
// BOOT_ANIMATIONS(R.string.fragment_title_boot_animations);
//
// private final int titleName;
//
// AssetsType(int title) {
// this.titleName = title;
// }
//
// public int getTitleRes() {
// return titleName;
// }
//
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/beans/PackageInfoBean.java
import android.support.annotation.NonNull;
import com.pddstudio.otgsubs.events.AssetTypeAddedEvent;
import com.pddstudio.otgsubs.events.ExistingAssetsItemEvent;
import com.pddstudio.otgsubs.events.ImportAssetsFromApkEvent;
import com.pddstudio.otgsubs.events.RefreshItemListEvent;
import com.pddstudio.substratum.packager.models.AssetFileInfo;
import com.pddstudio.substratum.packager.models.AssetsType;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java8.util.stream.StreamSupport;
if(event != null && event.isIgnore()) {
AssetFileInfo info = event.getAssetFileInfo();
storeAssetFileInfo(info);
redirectEvent(event);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onImportEventReceived(ImportAssetsFromApkEvent event) {
if(event != null) {
StreamSupport.stream(event.getAssets()).forEach(this::storeAssetFileInfo);
eventBusBean.post(new RefreshItemListEvent());
}
}
@Subscribe
public void onExistingAssetsModifiedEventReceived(ExistingAssetsItemEvent event) {
if(event != null) {
switch (event.getModificationType()) {
case DELETE:
removeItemIfPresent(event.getAssetFileInfo());
break;
case RENAME:
renameItemIfPresent(event.getAssetFileInfo(), event.getNewName());
break;
}
eventBusBean.post(new RefreshItemListEvent());
}
}
| public List<AssetFileInfo> getExistingInformation(AssetsType assetsType) { |
PDDStudio/OTGSubs | substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
| import com.google.gson.annotations.SerializedName;
import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.StreamSupport; | package com.pddstudio.substratum.template.patcher.internal.model;
/**
* Created by pddstudio on 25/04/2017.
*/
public class JsonConfigModel implements Serializable, ThemeConfiguration {
@SerializedName("themeName")
private String themeName;
@SerializedName("themeAuthor")
private String themeAuthor;
@SerializedName("themeTemplates")
private List<Template> templateList;
@Override
public String getThemeName() {
return themeName;
}
@Override
public String getThemeAuthor() {
return themeAuthor;
}
@Override | // Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/TemplateConfiguration.java
// public interface TemplateConfiguration {
// HashMap<String, String> getThemeMappings();
// void updateThemeMappings(HashMap<String, String> updatedMap);
// void setTemplateName(String templateName);
// String getTemplateName();
// String getTemplateFileName();
// String getTemplateId();
// String getTemplateTitle();
// String getTemplateType();
// String getTemplateDescription();
// }
//
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/ThemeConfiguration.java
// public interface ThemeConfiguration {
// String getThemeName();
// String getThemeAuthor();
// List<TemplateConfiguration> getThemeTemplates();
// }
// Path: substratum-template-patcher/src/main/java/com/pddstudio/substratum/template/patcher/internal/model/JsonConfigModel.java
import com.google.gson.annotations.SerializedName;
import com.pddstudio.substratum.template.patcher.TemplateConfiguration;
import com.pddstudio.substratum.template.patcher.ThemeConfiguration;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java8.util.Objects;
import java8.util.stream.StreamSupport;
package com.pddstudio.substratum.template.patcher.internal.model;
/**
* Created by pddstudio on 25/04/2017.
*/
public class JsonConfigModel implements Serializable, ThemeConfiguration {
@SerializedName("themeName")
private String themeName;
@SerializedName("themeAuthor")
private String themeAuthor;
@SerializedName("themeTemplates")
private List<Template> templateList;
@Override
public String getThemeName() {
return themeName;
}
@Override
public String getThemeAuthor() {
return themeAuthor;
}
@Override | public List<TemplateConfiguration> getThemeTemplates() { |
PDDStudio/OTGSubs | app/src/main/java/com/pddstudio/otgsubs/events/FileChooserDialogEvent.java | // Path: app/src/main/java/com/pddstudio/otgsubs/models/FileChooserType.java
// public enum FileChooserType implements Serializable {
// DIRECTORY,
// ZIP_FILE,
// IGNORE
// }
| import com.pddstudio.otgsubs.models.FileChooserType; | package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 21/04/2017.
*/
public class FileChooserDialogEvent {
private String resultLocation;
private boolean openRequest; | // Path: app/src/main/java/com/pddstudio/otgsubs/models/FileChooserType.java
// public enum FileChooserType implements Serializable {
// DIRECTORY,
// ZIP_FILE,
// IGNORE
// }
// Path: app/src/main/java/com/pddstudio/otgsubs/events/FileChooserDialogEvent.java
import com.pddstudio.otgsubs.models.FileChooserType;
package com.pddstudio.otgsubs.events;
/**
* Created by pddstudio on 21/04/2017.
*/
public class FileChooserDialogEvent {
private String resultLocation;
private boolean openRequest; | private FileChooserType fileChooserType; |
pierre/collector | src/test/java/com/ning/metrics/collector/jaxrs/TestThriftLegacyBodyResource.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import javax.ws.rs.core.Response; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestThriftLegacyBodyResource extends TestResources<BodyResource>
{
protected TestThriftLegacyBodyResource()
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/test/java/com/ning/metrics/collector/jaxrs/TestThriftLegacyBodyResource.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import javax.ws.rs.core.Response;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestThriftLegacyBodyResource extends TestResources<BodyResource>
{
protected TestThriftLegacyBodyResource()
{ | super(DeserializationType.DEFAULT); |
pierre/collector | src/test/java/com/ning/metrics/collector/filtering/TestOrFilter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java
// public class ParsedRequest
// {
// private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
// private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
//
// private final String eventName;
// private final DateTime eventDateTime;
// private String ipAddress;
// private String referrerHost = null;
// private String referrerPath = null;
// private final String userAgent;
// private final Granularity granularity;
// private int contentLength = 0;
// private DeserializationType contentType;
// private final InputStream inputStream;
//
// /**
// * Constructor used by the external API (GET only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType deserialization type (BASE_64_QUERY or DECIMAL_QUERY)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this(eventName, httpHeaders, null, eventDateTime, granularityString, peerIpAddress, contentType);
// }
//
// /**
// * Constructor used by the internal API (POST only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param inputStream content of the POST request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType Content-Type of the POST request (optional)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final InputStream inputStream,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this.eventName = eventName;
//
// this.eventDateTime = eventExtractorUtil.dateFromDateTime(eventDateTime);
//
// granularity = eventExtractorUtil.granularityFromString(granularityString);
//
// referrerHost = eventExtractorUtil.getReferrerHostFromHeaders(httpHeaders);
// referrerPath = eventExtractorUtil.getReferrerPathFromHeaders(httpHeaders);
//
// ipAddress = eventExtractorUtil.ipAddressFromHeaders(httpHeaders);
// if (ipAddress == null) {
// ipAddress = peerIpAddress;
// }
//
// try {
// contentLength = eventExtractorUtil.contentLengthFromHeaders(httpHeaders);
// }
// catch (NumberFormatException e) {
// log.warn(String.format("Illegal Content-Length header"), e);
// throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
//
// this.contentType = contentType;
// if (this.contentType == null) {
// this.contentType = DeserializationType.DEFAULT;
// }
//
// this.inputStream = inputStream;
//
// userAgent = eventExtractorUtil.getUserAgentFromHeaders(httpHeaders);
// }
//
// public String getEventName()
// {
// return eventName;
// }
//
// public DateTime getDateTime()
// {
// return eventDateTime;
// }
//
// public String getReferrerHost()
// {
// return referrerHost;
// }
//
// public String getReferrerPath()
// {
// return referrerPath;
// }
//
// public String getIpAddress()
// {
// return ipAddress;
// }
//
// public String getUserAgent()
// {
// return userAgent;
// }
//
// public Granularity getBucketGranularity()
// {
// return granularity;
// }
//
// public int getContentLength()
// {
// return contentLength;
// }
//
// public DeserializationType getContentType()
// {
// return contentType;
// }
//
// public InputStream getInputStream()
// {
// return inputStream;
// }
//
// @Override
// public String toString()
// {
// final StringBuilder builder = new StringBuilder();
// builder.append(String.format("name: %s, ", eventName == null ? "NULL" : eventName));
// builder.append(String.format("date: %s, ", eventDateTime == null ? "NULL" : eventDateTime));
// builder.append(String.format("referrerHost: %s, ", referrerHost == null ? "NULL" : referrerHost));
// builder.append(String.format("referrerPath: %s, ", referrerPath == null ? "NULL" : referrerPath));
// builder.append(String.format("ip: %s, ", ipAddress == null ? "NULL" : ipAddress));
// builder.append(String.format("ua: %s, ", userAgent == null ? "NULL" : userAgent));
// builder.append(String.format("granularity: %s, ", granularity == null ? "NULL" : granularity));
// builder.append(String.format("contentLength: %d, ", contentLength));
// builder.append(String.format("contentType: %s", contentType == null ? "NULL" : contentType));
// return builder.toString();
// }
// }
| import com.ning.metrics.collector.endpoint.ParsedRequest;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.filtering;
public class TestOrFilter
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java
// public class ParsedRequest
// {
// private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
// private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
//
// private final String eventName;
// private final DateTime eventDateTime;
// private String ipAddress;
// private String referrerHost = null;
// private String referrerPath = null;
// private final String userAgent;
// private final Granularity granularity;
// private int contentLength = 0;
// private DeserializationType contentType;
// private final InputStream inputStream;
//
// /**
// * Constructor used by the external API (GET only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType deserialization type (BASE_64_QUERY or DECIMAL_QUERY)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this(eventName, httpHeaders, null, eventDateTime, granularityString, peerIpAddress, contentType);
// }
//
// /**
// * Constructor used by the internal API (POST only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param inputStream content of the POST request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType Content-Type of the POST request (optional)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final InputStream inputStream,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this.eventName = eventName;
//
// this.eventDateTime = eventExtractorUtil.dateFromDateTime(eventDateTime);
//
// granularity = eventExtractorUtil.granularityFromString(granularityString);
//
// referrerHost = eventExtractorUtil.getReferrerHostFromHeaders(httpHeaders);
// referrerPath = eventExtractorUtil.getReferrerPathFromHeaders(httpHeaders);
//
// ipAddress = eventExtractorUtil.ipAddressFromHeaders(httpHeaders);
// if (ipAddress == null) {
// ipAddress = peerIpAddress;
// }
//
// try {
// contentLength = eventExtractorUtil.contentLengthFromHeaders(httpHeaders);
// }
// catch (NumberFormatException e) {
// log.warn(String.format("Illegal Content-Length header"), e);
// throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
//
// this.contentType = contentType;
// if (this.contentType == null) {
// this.contentType = DeserializationType.DEFAULT;
// }
//
// this.inputStream = inputStream;
//
// userAgent = eventExtractorUtil.getUserAgentFromHeaders(httpHeaders);
// }
//
// public String getEventName()
// {
// return eventName;
// }
//
// public DateTime getDateTime()
// {
// return eventDateTime;
// }
//
// public String getReferrerHost()
// {
// return referrerHost;
// }
//
// public String getReferrerPath()
// {
// return referrerPath;
// }
//
// public String getIpAddress()
// {
// return ipAddress;
// }
//
// public String getUserAgent()
// {
// return userAgent;
// }
//
// public Granularity getBucketGranularity()
// {
// return granularity;
// }
//
// public int getContentLength()
// {
// return contentLength;
// }
//
// public DeserializationType getContentType()
// {
// return contentType;
// }
//
// public InputStream getInputStream()
// {
// return inputStream;
// }
//
// @Override
// public String toString()
// {
// final StringBuilder builder = new StringBuilder();
// builder.append(String.format("name: %s, ", eventName == null ? "NULL" : eventName));
// builder.append(String.format("date: %s, ", eventDateTime == null ? "NULL" : eventDateTime));
// builder.append(String.format("referrerHost: %s, ", referrerHost == null ? "NULL" : referrerHost));
// builder.append(String.format("referrerPath: %s, ", referrerPath == null ? "NULL" : referrerPath));
// builder.append(String.format("ip: %s, ", ipAddress == null ? "NULL" : ipAddress));
// builder.append(String.format("ua: %s, ", userAgent == null ? "NULL" : userAgent));
// builder.append(String.format("granularity: %s, ", granularity == null ? "NULL" : granularity));
// builder.append(String.format("contentLength: %d, ", contentLength));
// builder.append(String.format("contentType: %s", contentType == null ? "NULL" : contentType));
// return builder.toString();
// }
// }
// Path: src/test/java/com/ning/metrics/collector/filtering/TestOrFilter.java
import com.ning.metrics.collector.endpoint.ParsedRequest;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.filtering;
public class TestOrFilter
{ | private static final Filter<ParsedRequest> TRUE_FILTER = new Filter<ParsedRequest>() |
pierre/collector | src/test/java/com/ning/metrics/collector/jaxrs/TestJsonBodyResource.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.mockito.Mockito;
import javax.ws.rs.core.Response;
import java.io.InputStream; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestJsonBodyResource extends TestResources<BodyResource>
{
protected TestJsonBodyResource()
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/test/java/com/ning/metrics/collector/jaxrs/TestJsonBodyResource.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.mockito.Mockito;
import javax.ws.rs.core.Response;
import java.io.InputStream;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestJsonBodyResource extends TestResources<BodyResource>
{
protected TestJsonBodyResource()
{ | super(DeserializationType.JSON); |
pierre/collector | src/main/java/com/ning/metrics/collector/realtime/RealTimeQueueModule.java | // Path: src/main/java/com/ning/metrics/collector/realtime/amq/ActiveMQConnectionFactory.java
// public class ActiveMQConnectionFactory implements EventQueueConnectionFactory
// {
// // General configuration which does not include per-category overrides
// private final CollectorConfig baseConfig;
//
// @Inject
// public ActiveMQConnectionFactory(final CollectorConfig baseConfig)
// {
// this.baseConfig = baseConfig;
// }
//
// @Override
// public EventQueueConnection createConnection()
// {
// return new ActiveMQConnection(baseConfig);
// }
// }
| import com.google.inject.Binder;
import com.google.inject.Module;
import com.ning.metrics.collector.realtime.amq.ActiveMQConnectionFactory;
import org.weakref.jmx.guice.ExportBuilder;
import org.weakref.jmx.guice.MBeanModule; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.realtime;
public class RealTimeQueueModule implements Module
{
@Override
public void configure(final Binder binder)
{
// JMX exporter
final ExportBuilder builder = MBeanModule.newExporter(binder);
binder.bind(EventListenerDispatcher.class).asEagerSingleton();
builder.export(EventListenerDispatcher.class).as("com.ning.metrics.collector:name=Listeners");
// The following is for AMQ
binder.bind(GlobalEventQueueStats.class).asEagerSingleton();
builder.export(GlobalEventQueueStats.class).as("com.ning.metrics.collector:name=RTQueueStats");
| // Path: src/main/java/com/ning/metrics/collector/realtime/amq/ActiveMQConnectionFactory.java
// public class ActiveMQConnectionFactory implements EventQueueConnectionFactory
// {
// // General configuration which does not include per-category overrides
// private final CollectorConfig baseConfig;
//
// @Inject
// public ActiveMQConnectionFactory(final CollectorConfig baseConfig)
// {
// this.baseConfig = baseConfig;
// }
//
// @Override
// public EventQueueConnection createConnection()
// {
// return new ActiveMQConnection(baseConfig);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/realtime/RealTimeQueueModule.java
import com.google.inject.Binder;
import com.google.inject.Module;
import com.ning.metrics.collector.realtime.amq.ActiveMQConnectionFactory;
import org.weakref.jmx.guice.ExportBuilder;
import org.weakref.jmx.guice.MBeanModule;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.realtime;
public class RealTimeQueueModule implements Module
{
@Override
public void configure(final Binder binder)
{
// JMX exporter
final ExportBuilder builder = MBeanModule.newExporter(binder);
binder.bind(EventListenerDispatcher.class).asEagerSingleton();
builder.export(EventListenerDispatcher.class).as("com.ning.metrics.collector:name=Listeners");
// The following is for AMQ
binder.bind(GlobalEventQueueStats.class).asEagerSingleton();
builder.export(GlobalEventQueueStats.class).as("com.ning.metrics.collector:name=RTQueueStats");
| binder.bind(EventQueueConnectionFactory.class).to(ActiveMQConnectionFactory.class).asEagerSingleton(); |
pierre/collector | src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import com.ning.metrics.serialization.event.Granularity;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.io.InputStream; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.endpoint;
public class ParsedRequest
{
private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
private final String eventName;
private final DateTime eventDateTime;
private String ipAddress;
private String referrerHost = null;
private String referrerPath = null;
private final String userAgent;
private final Granularity granularity;
private int contentLength = 0; | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import com.ning.metrics.serialization.event.Granularity;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.io.InputStream;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.endpoint;
public class ParsedRequest
{
private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
private final String eventName;
private final DateTime eventDateTime;
private String ipAddress;
private String referrerHost = null;
private String referrerPath = null;
private final String userAgent;
private final Granularity granularity;
private int contentLength = 0; | private DeserializationType contentType; |
pierre/collector | src/main/java/com/ning/metrics/collector/filtering/EventInclusionFilter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java
// public class ParsedRequest
// {
// private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
// private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
//
// private final String eventName;
// private final DateTime eventDateTime;
// private String ipAddress;
// private String referrerHost = null;
// private String referrerPath = null;
// private final String userAgent;
// private final Granularity granularity;
// private int contentLength = 0;
// private DeserializationType contentType;
// private final InputStream inputStream;
//
// /**
// * Constructor used by the external API (GET only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType deserialization type (BASE_64_QUERY or DECIMAL_QUERY)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this(eventName, httpHeaders, null, eventDateTime, granularityString, peerIpAddress, contentType);
// }
//
// /**
// * Constructor used by the internal API (POST only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param inputStream content of the POST request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType Content-Type of the POST request (optional)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final InputStream inputStream,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this.eventName = eventName;
//
// this.eventDateTime = eventExtractorUtil.dateFromDateTime(eventDateTime);
//
// granularity = eventExtractorUtil.granularityFromString(granularityString);
//
// referrerHost = eventExtractorUtil.getReferrerHostFromHeaders(httpHeaders);
// referrerPath = eventExtractorUtil.getReferrerPathFromHeaders(httpHeaders);
//
// ipAddress = eventExtractorUtil.ipAddressFromHeaders(httpHeaders);
// if (ipAddress == null) {
// ipAddress = peerIpAddress;
// }
//
// try {
// contentLength = eventExtractorUtil.contentLengthFromHeaders(httpHeaders);
// }
// catch (NumberFormatException e) {
// log.warn(String.format("Illegal Content-Length header"), e);
// throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
//
// this.contentType = contentType;
// if (this.contentType == null) {
// this.contentType = DeserializationType.DEFAULT;
// }
//
// this.inputStream = inputStream;
//
// userAgent = eventExtractorUtil.getUserAgentFromHeaders(httpHeaders);
// }
//
// public String getEventName()
// {
// return eventName;
// }
//
// public DateTime getDateTime()
// {
// return eventDateTime;
// }
//
// public String getReferrerHost()
// {
// return referrerHost;
// }
//
// public String getReferrerPath()
// {
// return referrerPath;
// }
//
// public String getIpAddress()
// {
// return ipAddress;
// }
//
// public String getUserAgent()
// {
// return userAgent;
// }
//
// public Granularity getBucketGranularity()
// {
// return granularity;
// }
//
// public int getContentLength()
// {
// return contentLength;
// }
//
// public DeserializationType getContentType()
// {
// return contentType;
// }
//
// public InputStream getInputStream()
// {
// return inputStream;
// }
//
// @Override
// public String toString()
// {
// final StringBuilder builder = new StringBuilder();
// builder.append(String.format("name: %s, ", eventName == null ? "NULL" : eventName));
// builder.append(String.format("date: %s, ", eventDateTime == null ? "NULL" : eventDateTime));
// builder.append(String.format("referrerHost: %s, ", referrerHost == null ? "NULL" : referrerHost));
// builder.append(String.format("referrerPath: %s, ", referrerPath == null ? "NULL" : referrerPath));
// builder.append(String.format("ip: %s, ", ipAddress == null ? "NULL" : ipAddress));
// builder.append(String.format("ua: %s, ", userAgent == null ? "NULL" : userAgent));
// builder.append(String.format("granularity: %s, ", granularity == null ? "NULL" : granularity));
// builder.append(String.format("contentLength: %d, ", contentLength));
// builder.append(String.format("contentType: %s", contentType == null ? "NULL" : contentType));
// return builder.toString();
// }
// }
| import java.util.regex.Pattern;
import com.ning.metrics.collector.endpoint.ParsedRequest; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.filtering;
public class EventInclusionFilter extends PatternSetFilter
{
public EventInclusionFilter(FieldExtractor fieldExtractor, Iterable<Pattern> patterns)
{
super(fieldExtractor, patterns);
}
@Override | // Path: src/main/java/com/ning/metrics/collector/endpoint/ParsedRequest.java
// public class ParsedRequest
// {
// private static final Logger log = LoggerFactory.getLogger(ParsedRequest.class);
// private static final EventExtractorUtil eventExtractorUtil = new EventExtractorUtil();
//
// private final String eventName;
// private final DateTime eventDateTime;
// private String ipAddress;
// private String referrerHost = null;
// private String referrerPath = null;
// private final String userAgent;
// private final Granularity granularity;
// private int contentLength = 0;
// private DeserializationType contentType;
// private final InputStream inputStream;
//
// /**
// * Constructor used by the external API (GET only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType deserialization type (BASE_64_QUERY or DECIMAL_QUERY)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this(eventName, httpHeaders, null, eventDateTime, granularityString, peerIpAddress, contentType);
// }
//
// /**
// * Constructor used by the internal API (POST only)
// *
// * @param eventName name of the event parsed
// * @param httpHeaders HTTP headers of the incoming request
// * @param inputStream content of the POST request
// * @param eventDateTime query value parameter (optional)
// * @param granularityString query value parameter (optional)
// * @param peerIpAddress requestor (peer) IP address (optional)
// * @param contentType Content-Type of the POST request (optional)
// */
// public ParsedRequest(final String eventName,
// final HttpHeaders httpHeaders,
// final InputStream inputStream,
// final DateTime eventDateTime,
// final String granularityString,
// final String peerIpAddress,
// final DeserializationType contentType)
// {
// this.eventName = eventName;
//
// this.eventDateTime = eventExtractorUtil.dateFromDateTime(eventDateTime);
//
// granularity = eventExtractorUtil.granularityFromString(granularityString);
//
// referrerHost = eventExtractorUtil.getReferrerHostFromHeaders(httpHeaders);
// referrerPath = eventExtractorUtil.getReferrerPathFromHeaders(httpHeaders);
//
// ipAddress = eventExtractorUtil.ipAddressFromHeaders(httpHeaders);
// if (ipAddress == null) {
// ipAddress = peerIpAddress;
// }
//
// try {
// contentLength = eventExtractorUtil.contentLengthFromHeaders(httpHeaders);
// }
// catch (NumberFormatException e) {
// log.warn(String.format("Illegal Content-Length header"), e);
// throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
//
// this.contentType = contentType;
// if (this.contentType == null) {
// this.contentType = DeserializationType.DEFAULT;
// }
//
// this.inputStream = inputStream;
//
// userAgent = eventExtractorUtil.getUserAgentFromHeaders(httpHeaders);
// }
//
// public String getEventName()
// {
// return eventName;
// }
//
// public DateTime getDateTime()
// {
// return eventDateTime;
// }
//
// public String getReferrerHost()
// {
// return referrerHost;
// }
//
// public String getReferrerPath()
// {
// return referrerPath;
// }
//
// public String getIpAddress()
// {
// return ipAddress;
// }
//
// public String getUserAgent()
// {
// return userAgent;
// }
//
// public Granularity getBucketGranularity()
// {
// return granularity;
// }
//
// public int getContentLength()
// {
// return contentLength;
// }
//
// public DeserializationType getContentType()
// {
// return contentType;
// }
//
// public InputStream getInputStream()
// {
// return inputStream;
// }
//
// @Override
// public String toString()
// {
// final StringBuilder builder = new StringBuilder();
// builder.append(String.format("name: %s, ", eventName == null ? "NULL" : eventName));
// builder.append(String.format("date: %s, ", eventDateTime == null ? "NULL" : eventDateTime));
// builder.append(String.format("referrerHost: %s, ", referrerHost == null ? "NULL" : referrerHost));
// builder.append(String.format("referrerPath: %s, ", referrerPath == null ? "NULL" : referrerPath));
// builder.append(String.format("ip: %s, ", ipAddress == null ? "NULL" : ipAddress));
// builder.append(String.format("ua: %s, ", userAgent == null ? "NULL" : userAgent));
// builder.append(String.format("granularity: %s, ", granularity == null ? "NULL" : granularity));
// builder.append(String.format("contentLength: %d, ", contentLength));
// builder.append(String.format("contentType: %s", contentType == null ? "NULL" : contentType));
// return builder.toString();
// }
// }
// Path: src/main/java/com/ning/metrics/collector/filtering/EventInclusionFilter.java
import java.util.regex.Pattern;
import com.ning.metrics.collector.endpoint.ParsedRequest;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.filtering;
public class EventInclusionFilter extends PatternSetFilter
{
public EventInclusionFilter(FieldExtractor fieldExtractor, Iterable<Pattern> patterns)
{
super(fieldExtractor, patterns);
}
@Override | public boolean passesFilter(String name, ParsedRequest parsedRequest) |
pierre/collector | src/test/java/com/ning/metrics/collector/jaxrs/TestThriftBodyResource.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.mockito.Mockito;
import javax.ws.rs.core.Response;
import java.io.InputStream; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestThriftBodyResource extends TestResources<BodyResource>
{
protected TestThriftBodyResource()
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/test/java/com/ning/metrics/collector/jaxrs/TestThriftBodyResource.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.mockito.Mockito;
import javax.ws.rs.core.Response;
import java.io.InputStream;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestThriftBodyResource extends TestResources<BodyResource>
{
protected TestThriftBodyResource()
{ | super(DeserializationType.THRIFT); |
pierre/collector | src/test/java/com/ning/metrics/collector/endpoint/TestParsedRequest.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.joda.time.DateTime;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.ws.rs.core.HttpHeaders; | final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getReferrerPath());
}
@Test(groups = "fast")
public void testParseUserAgent() throws Exception
{
final ParsedRequest parsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertEquals(parsedRequest.getUserAgent(), userAgent);
userAgent = null;
final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getUserAgent());
}
@Test(groups = "fast")
public void testParseIP() throws Exception
{
final ParsedRequest parsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertEquals(parsedRequest.getIpAddress(), ip);
ip = null;
final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getIpAddress());
}
@Test(groups = "fast")
public void testParseDateExplicit() throws Exception
{
final HttpHeaders httpHeaders = createDummyHeaders(); | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/test/java/com/ning/metrics/collector/endpoint/TestParsedRequest.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import org.joda.time.DateTime;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.ws.rs.core.HttpHeaders;
final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getReferrerPath());
}
@Test(groups = "fast")
public void testParseUserAgent() throws Exception
{
final ParsedRequest parsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertEquals(parsedRequest.getUserAgent(), userAgent);
userAgent = null;
final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getUserAgent());
}
@Test(groups = "fast")
public void testParseIP() throws Exception
{
final ParsedRequest parsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertEquals(parsedRequest.getIpAddress(), ip);
ip = null;
final ParsedRequest emptyFieldParsedRequest = createParsedRequestWithNoQueryParameter();
Assert.assertNull(emptyFieldParsedRequest.getIpAddress());
}
@Test(groups = "fast")
public void testParseDateExplicit() throws Exception
{
final HttpHeaders httpHeaders = createDummyHeaders(); | final ParsedRequest parsedRequest = new ParsedRequest("DummyEvent", httpHeaders, new DateTime("2001-02-03"), null, null, DeserializationType.DEFAULT); |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/Tokenizer.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing;
interface Tokenizer
{
boolean hasNext();
| // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/Tokenizer.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing;
interface Tokenizer
{
boolean hasNext();
| Token next() throws EventParsingException; |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/UrlDecodingTokenizer.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing;
class UrlDecodingTokenizer implements Tokenizer
{
private final Tokenizer baseTokenizer;
public UrlDecodingTokenizer(final Tokenizer baseTokenizer)
{
this.baseTokenizer = baseTokenizer;
}
@Override
public boolean hasNext()
{
return baseTokenizer.hasNext();
}
| // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/UrlDecodingTokenizer.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing;
class UrlDecodingTokenizer implements Tokenizer
{
private final Tokenizer baseTokenizer;
public UrlDecodingTokenizer(final Tokenizer baseTokenizer)
{
this.baseTokenizer = baseTokenizer;
}
@Override
public boolean hasNext()
{
return baseTokenizer.hasNext();
}
| public Token next() throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/ShortConverter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class ShortConverter implements Converter<Short>
{
private final NumberConverter numberConverter;
public ShortConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/ShortConverter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class ShortConverter implements Converter<Short>
{
private final NumberConverter numberConverter;
public ShortConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| public Short convert(final String input) throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/DoubleConverter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class DoubleConverter implements Converter<Double>
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/DoubleConverter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class DoubleConverter implements Converter<Double>
{ | public Double convert(final String input) throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/guice/providers/EventFilterProvider.java | // Path: src/main/java/com/ning/metrics/collector/filtering/EventInclusionFilter.java
// public class EventInclusionFilter extends PatternSetFilter
// {
// public EventInclusionFilter(FieldExtractor fieldExtractor, Iterable<Pattern> patterns)
// {
// super(fieldExtractor, patterns);
// }
//
// @Override
// public boolean passesFilter(String name, ParsedRequest parsedRequest)
// {
// return !super.passesFilter(name, parsedRequest);
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/filtering/PatternSetFilter.java
// public class PatternSetFilter implements Filter<ParsedRequest>
// {
// private final FieldExtractor fieldExtractor;
// private final ConcurrentMap<String, Pattern> patternMap = new ConcurrentHashMap<String, Pattern>();
//
// @Inject
// public PatternSetFilter(final FieldExtractor fieldExtractor, final Iterable<Pattern> patterns)
// {
// this.fieldExtractor = fieldExtractor;
//
// for (final Pattern pattern : patterns) {
// patternMap.put(pattern.toString(), pattern);
// }
// }
//
// @Override
// public boolean passesFilter(final String name, final ParsedRequest parsedRequest)
// {
// final String input = fieldExtractor.getField(name, parsedRequest);
//
// if (input == null) {
// return false;
// }
//
// for (final Pattern pattern : patternMap.values()) {
// if (pattern.matcher(input).find()) {
// return true;
// }
// }
//
// return false;
// }
//
// @Managed(description = "list of patterns for this filter")
// public List<String> getPatternSet()
// {
// return new ArrayList<String>(patternMap.keySet());
// }
//
// @Managed(description = "add a regular expression to filter set")
// public void addPattern(final String patternString)
// {
// patternMap.put(patternString, Pattern.compile(patternString));
// }
//
// @Managed(description = "add a regular expression to filter set")
// public void removePattern(final String patternString)
// {
// patternMap.remove(patternString);
// }
// }
| import com.ning.metrics.collector.filtering.EventInclusionFilter;
import com.ning.metrics.collector.filtering.FieldExtractor;
import com.ning.metrics.collector.filtering.PatternSetFilter;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice.providers;
public class EventFilterProvider implements Provider<PatternSetFilter>
{
private final FieldExtractor fieldExtractor;
private final Set<Pattern> patternSet = new HashSet<Pattern>();
private final boolean isEventInclusionFilter;
@Inject
public EventFilterProvider(final FieldExtractor fieldExtractor, final String patternListString, final String delimiter, final boolean isEventInclusionFilter)
{
this.fieldExtractor = fieldExtractor;
this.isEventInclusionFilter = isEventInclusionFilter;
if (patternListString != null && !patternListString.isEmpty()) {
for (final String str : patternListString.split(delimiter)) {
patternSet.add(Pattern.compile(str));
}
}
}
@Override
public PatternSetFilter get()
{ | // Path: src/main/java/com/ning/metrics/collector/filtering/EventInclusionFilter.java
// public class EventInclusionFilter extends PatternSetFilter
// {
// public EventInclusionFilter(FieldExtractor fieldExtractor, Iterable<Pattern> patterns)
// {
// super(fieldExtractor, patterns);
// }
//
// @Override
// public boolean passesFilter(String name, ParsedRequest parsedRequest)
// {
// return !super.passesFilter(name, parsedRequest);
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/filtering/PatternSetFilter.java
// public class PatternSetFilter implements Filter<ParsedRequest>
// {
// private final FieldExtractor fieldExtractor;
// private final ConcurrentMap<String, Pattern> patternMap = new ConcurrentHashMap<String, Pattern>();
//
// @Inject
// public PatternSetFilter(final FieldExtractor fieldExtractor, final Iterable<Pattern> patterns)
// {
// this.fieldExtractor = fieldExtractor;
//
// for (final Pattern pattern : patterns) {
// patternMap.put(pattern.toString(), pattern);
// }
// }
//
// @Override
// public boolean passesFilter(final String name, final ParsedRequest parsedRequest)
// {
// final String input = fieldExtractor.getField(name, parsedRequest);
//
// if (input == null) {
// return false;
// }
//
// for (final Pattern pattern : patternMap.values()) {
// if (pattern.matcher(input).find()) {
// return true;
// }
// }
//
// return false;
// }
//
// @Managed(description = "list of patterns for this filter")
// public List<String> getPatternSet()
// {
// return new ArrayList<String>(patternMap.keySet());
// }
//
// @Managed(description = "add a regular expression to filter set")
// public void addPattern(final String patternString)
// {
// patternMap.put(patternString, Pattern.compile(patternString));
// }
//
// @Managed(description = "add a regular expression to filter set")
// public void removePattern(final String patternString)
// {
// patternMap.remove(patternString);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/guice/providers/EventFilterProvider.java
import com.ning.metrics.collector.filtering.EventInclusionFilter;
import com.ning.metrics.collector.filtering.FieldExtractor;
import com.ning.metrics.collector.filtering.PatternSetFilter;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice.providers;
public class EventFilterProvider implements Provider<PatternSetFilter>
{
private final FieldExtractor fieldExtractor;
private final Set<Pattern> patternSet = new HashSet<Pattern>();
private final boolean isEventInclusionFilter;
@Inject
public EventFilterProvider(final FieldExtractor fieldExtractor, final String patternListString, final String delimiter, final boolean isEventInclusionFilter)
{
this.fieldExtractor = fieldExtractor;
this.isEventInclusionFilter = isEventInclusionFilter;
if (patternListString != null && !patternListString.isEmpty()) {
for (final String str : patternListString.split(delimiter)) {
patternSet.add(Pattern.compile(str));
}
}
}
@Override
public PatternSetFilter get()
{ | return isEventInclusionFilter ? new EventInclusionFilter(fieldExtractor, patternSet) : new PatternSetFilter(fieldExtractor, patternSet); |
pierre/collector | src/test/java/com/ning/metrics/collector/jaxrs/TestCollectorResource.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
| import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import javax.ws.rs.core.Response; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestCollectorResource extends TestResources<CollectorResource>
{
protected TestCollectorResource()
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/DeserializationType.java
// public enum DeserializationType
// {
// // BodyResource
// SMILE, JSON, THRIFT, DEFAULT,
// // CollectorResource
// DECIMAL_QUERY,
// // Base64CollectorResource
// BASE_64_QUERY,
// }
// Path: src/test/java/com/ning/metrics/collector/jaxrs/TestCollectorResource.java
import com.ning.metrics.collector.endpoint.extractors.DeserializationType;
import javax.ws.rs.core.Response;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.jaxrs;
public class TestCollectorResource extends TestResources<CollectorResource>
{
protected TestCollectorResource()
{ | super(DeserializationType.DECIMAL_QUERY); |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/IntegerConverter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class IntegerConverter implements Converter<Integer>
{
private final NumberConverter numberConverter;
public IntegerConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/IntegerConverter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class IntegerConverter implements Converter<Integer>
{
private final NumberConverter numberConverter;
public IntegerConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| public Integer convert(final String input) throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/BooleanConverter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class BooleanConverter implements Converter<Boolean>
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/BooleanConverter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class BooleanConverter implements Converter<Boolean>
{ | public Boolean convert(final String input) throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/ByteConverter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class ByteConverter implements Converter<Byte>
{
private final NumberConverter numberConverter;
public ByteConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/ByteConverter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public class ByteConverter implements Converter<Byte>
{
private final NumberConverter numberConverter;
public ByteConverter(final NumberConverter numberConverter)
{
this.numberConverter = numberConverter;
}
| public Byte convert(final String input) throws EventParsingException |
pierre/collector | src/main/java/com/ning/metrics/collector/events/parsing/converters/Converter.java | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
| import com.ning.metrics.collector.endpoint.extractors.EventParsingException; | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public interface Converter<T>
{ | // Path: src/main/java/com/ning/metrics/collector/endpoint/extractors/EventParsingException.java
// @SuppressWarnings("serial")
// public class EventParsingException extends Exception
// {
//
// public EventParsingException(final String message)
// {
// super(message);
// }
//
// public EventParsingException(final String message, final Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: src/main/java/com/ning/metrics/collector/events/parsing/converters/Converter.java
import com.ning.metrics.collector.endpoint.extractors.EventParsingException;
/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning 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.ning.metrics.collector.events.parsing.converters;
public interface Converter<T>
{ | T convert(String input) throws EventParsingException; |
pierre/collector | src/main/java/com/ning/metrics/collector/guice/HealthChecksModule.java | // Path: src/main/java/com/ning/metrics/collector/healthchecks/RealtimeHealthCheck.java
// public class RealtimeHealthCheck extends HealthCheck
// {
// private final EventQueueProcessorImpl processor;
// private final GlobalEventQueueStats stats;
//
// @Inject
// public RealtimeHealthCheck(final EventQueueProcessor processor, final GlobalEventQueueStats stats)
// {
// super(RealtimeHealthCheck.class.getName());
// this.processor = (EventQueueProcessorImpl) processor;
// this.stats = stats;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("enabled: %s, ", processor.isEnabled()));
// builder.append(String.format("running: %s, ", processor.isRunning()));
// builder.append(String.format("types: %s, ", processor.getTypesToCollect()));
// builder.append(String.format("queue sizes: {%s}, ", stats.toString()));
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("sent: %s, ", stats.getSentEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // AMQ error
// builder.append(String.format("ignored: %s", stats.getIgnoredEvents())); // system disabled
//
// final String message = builder.toString();
//
// if (processor.isEnabled() && !processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access realtime subsystem");
// }
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/healthchecks/WriterHealthCheck.java
// public class WriterHealthCheck extends HealthCheck
// {
// private final EventSpoolDispatcher processor;
// private final WriterStats stats;
// private final PersistentWriterFactory factory;
// private final CollectorConfig config;
//
// @Inject
// public WriterHealthCheck(final EventSpoolDispatcher processor, final PersistentWriterFactory factory, final WriterStats stats, final CollectorConfig config)
// {
// super(WriterHealthCheck.class.getName());
// this.processor = processor;
// this.factory = factory;
// this.stats = stats;
// this.config = config;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("running: %s, ", processor.isRunning()));
//
// builder.append("local files: {");
// int i = 1;
// final Set<String> paths = processor.getQueuesPerPath().keySet();
// for (final String queue : paths) {
// final LocalQueueAndWriter worker = processor.getQueuesPerPath().get(queue);
// builder.append(String.format("%s: %d", queue, worker.size()));
// if (worker.size() == config.getMaxQueueSize()) {
// builder.append(" [FULL]");
// }
//
// if (i < paths.size()) {
// builder.append(", ");
// }
// i++;
// }
// builder.append("}, ");
//
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("written: %s, ", stats.getWrittenEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // I/O error
// builder.append(String.format("ignored: %s, ", stats.getIgnoredEvents())); // system disabled
// if (factory instanceof HadoopWriterFactory) {
// builder.append(String.format("pendingFiles: %s, ", ((HadoopWriterFactory) factory).nbLocalFiles())); // files waiting to be flushed
// }
// builder.append(String.format("flushes: %s", stats.getHdfsFlushes())); // HDFS flushes
//
// final String message = builder.toString();
// if (!processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access writer subsystem");
// }
// }
// }
| import com.ning.metrics.collector.healthchecks.HadoopHealthCheck;
import com.ning.metrics.collector.healthchecks.RealtimeHealthCheck;
import com.ning.metrics.collector.healthchecks.WriterHealthCheck;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.yammer.metrics.core.HealthCheck;
import com.yammer.metrics.guice.servlet.AdminServletModule; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice;
public class HealthChecksModule extends AbstractModule
{
@Override
protected void configure()
{
install(new AdminServletModule());
final Multibinder<HealthCheck> healthChecksBinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
healthChecksBinder.addBinding().to(HadoopHealthCheck.class).asEagerSingleton(); | // Path: src/main/java/com/ning/metrics/collector/healthchecks/RealtimeHealthCheck.java
// public class RealtimeHealthCheck extends HealthCheck
// {
// private final EventQueueProcessorImpl processor;
// private final GlobalEventQueueStats stats;
//
// @Inject
// public RealtimeHealthCheck(final EventQueueProcessor processor, final GlobalEventQueueStats stats)
// {
// super(RealtimeHealthCheck.class.getName());
// this.processor = (EventQueueProcessorImpl) processor;
// this.stats = stats;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("enabled: %s, ", processor.isEnabled()));
// builder.append(String.format("running: %s, ", processor.isRunning()));
// builder.append(String.format("types: %s, ", processor.getTypesToCollect()));
// builder.append(String.format("queue sizes: {%s}, ", stats.toString()));
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("sent: %s, ", stats.getSentEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // AMQ error
// builder.append(String.format("ignored: %s", stats.getIgnoredEvents())); // system disabled
//
// final String message = builder.toString();
//
// if (processor.isEnabled() && !processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access realtime subsystem");
// }
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/healthchecks/WriterHealthCheck.java
// public class WriterHealthCheck extends HealthCheck
// {
// private final EventSpoolDispatcher processor;
// private final WriterStats stats;
// private final PersistentWriterFactory factory;
// private final CollectorConfig config;
//
// @Inject
// public WriterHealthCheck(final EventSpoolDispatcher processor, final PersistentWriterFactory factory, final WriterStats stats, final CollectorConfig config)
// {
// super(WriterHealthCheck.class.getName());
// this.processor = processor;
// this.factory = factory;
// this.stats = stats;
// this.config = config;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("running: %s, ", processor.isRunning()));
//
// builder.append("local files: {");
// int i = 1;
// final Set<String> paths = processor.getQueuesPerPath().keySet();
// for (final String queue : paths) {
// final LocalQueueAndWriter worker = processor.getQueuesPerPath().get(queue);
// builder.append(String.format("%s: %d", queue, worker.size()));
// if (worker.size() == config.getMaxQueueSize()) {
// builder.append(" [FULL]");
// }
//
// if (i < paths.size()) {
// builder.append(", ");
// }
// i++;
// }
// builder.append("}, ");
//
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("written: %s, ", stats.getWrittenEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // I/O error
// builder.append(String.format("ignored: %s, ", stats.getIgnoredEvents())); // system disabled
// if (factory instanceof HadoopWriterFactory) {
// builder.append(String.format("pendingFiles: %s, ", ((HadoopWriterFactory) factory).nbLocalFiles())); // files waiting to be flushed
// }
// builder.append(String.format("flushes: %s", stats.getHdfsFlushes())); // HDFS flushes
//
// final String message = builder.toString();
// if (!processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access writer subsystem");
// }
// }
// }
// Path: src/main/java/com/ning/metrics/collector/guice/HealthChecksModule.java
import com.ning.metrics.collector.healthchecks.HadoopHealthCheck;
import com.ning.metrics.collector.healthchecks.RealtimeHealthCheck;
import com.ning.metrics.collector.healthchecks.WriterHealthCheck;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.yammer.metrics.core.HealthCheck;
import com.yammer.metrics.guice.servlet.AdminServletModule;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice;
public class HealthChecksModule extends AbstractModule
{
@Override
protected void configure()
{
install(new AdminServletModule());
final Multibinder<HealthCheck> healthChecksBinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
healthChecksBinder.addBinding().to(HadoopHealthCheck.class).asEagerSingleton(); | healthChecksBinder.addBinding().to(RealtimeHealthCheck.class).asEagerSingleton(); |
pierre/collector | src/main/java/com/ning/metrics/collector/guice/HealthChecksModule.java | // Path: src/main/java/com/ning/metrics/collector/healthchecks/RealtimeHealthCheck.java
// public class RealtimeHealthCheck extends HealthCheck
// {
// private final EventQueueProcessorImpl processor;
// private final GlobalEventQueueStats stats;
//
// @Inject
// public RealtimeHealthCheck(final EventQueueProcessor processor, final GlobalEventQueueStats stats)
// {
// super(RealtimeHealthCheck.class.getName());
// this.processor = (EventQueueProcessorImpl) processor;
// this.stats = stats;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("enabled: %s, ", processor.isEnabled()));
// builder.append(String.format("running: %s, ", processor.isRunning()));
// builder.append(String.format("types: %s, ", processor.getTypesToCollect()));
// builder.append(String.format("queue sizes: {%s}, ", stats.toString()));
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("sent: %s, ", stats.getSentEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // AMQ error
// builder.append(String.format("ignored: %s", stats.getIgnoredEvents())); // system disabled
//
// final String message = builder.toString();
//
// if (processor.isEnabled() && !processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access realtime subsystem");
// }
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/healthchecks/WriterHealthCheck.java
// public class WriterHealthCheck extends HealthCheck
// {
// private final EventSpoolDispatcher processor;
// private final WriterStats stats;
// private final PersistentWriterFactory factory;
// private final CollectorConfig config;
//
// @Inject
// public WriterHealthCheck(final EventSpoolDispatcher processor, final PersistentWriterFactory factory, final WriterStats stats, final CollectorConfig config)
// {
// super(WriterHealthCheck.class.getName());
// this.processor = processor;
// this.factory = factory;
// this.stats = stats;
// this.config = config;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("running: %s, ", processor.isRunning()));
//
// builder.append("local files: {");
// int i = 1;
// final Set<String> paths = processor.getQueuesPerPath().keySet();
// for (final String queue : paths) {
// final LocalQueueAndWriter worker = processor.getQueuesPerPath().get(queue);
// builder.append(String.format("%s: %d", queue, worker.size()));
// if (worker.size() == config.getMaxQueueSize()) {
// builder.append(" [FULL]");
// }
//
// if (i < paths.size()) {
// builder.append(", ");
// }
// i++;
// }
// builder.append("}, ");
//
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("written: %s, ", stats.getWrittenEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // I/O error
// builder.append(String.format("ignored: %s, ", stats.getIgnoredEvents())); // system disabled
// if (factory instanceof HadoopWriterFactory) {
// builder.append(String.format("pendingFiles: %s, ", ((HadoopWriterFactory) factory).nbLocalFiles())); // files waiting to be flushed
// }
// builder.append(String.format("flushes: %s", stats.getHdfsFlushes())); // HDFS flushes
//
// final String message = builder.toString();
// if (!processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access writer subsystem");
// }
// }
// }
| import com.ning.metrics.collector.healthchecks.HadoopHealthCheck;
import com.ning.metrics.collector.healthchecks.RealtimeHealthCheck;
import com.ning.metrics.collector.healthchecks.WriterHealthCheck;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.yammer.metrics.core.HealthCheck;
import com.yammer.metrics.guice.servlet.AdminServletModule; | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice;
public class HealthChecksModule extends AbstractModule
{
@Override
protected void configure()
{
install(new AdminServletModule());
final Multibinder<HealthCheck> healthChecksBinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
healthChecksBinder.addBinding().to(HadoopHealthCheck.class).asEagerSingleton();
healthChecksBinder.addBinding().to(RealtimeHealthCheck.class).asEagerSingleton(); | // Path: src/main/java/com/ning/metrics/collector/healthchecks/RealtimeHealthCheck.java
// public class RealtimeHealthCheck extends HealthCheck
// {
// private final EventQueueProcessorImpl processor;
// private final GlobalEventQueueStats stats;
//
// @Inject
// public RealtimeHealthCheck(final EventQueueProcessor processor, final GlobalEventQueueStats stats)
// {
// super(RealtimeHealthCheck.class.getName());
// this.processor = (EventQueueProcessorImpl) processor;
// this.stats = stats;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("enabled: %s, ", processor.isEnabled()));
// builder.append(String.format("running: %s, ", processor.isRunning()));
// builder.append(String.format("types: %s, ", processor.getTypesToCollect()));
// builder.append(String.format("queue sizes: {%s}, ", stats.toString()));
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("sent: %s, ", stats.getSentEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // AMQ error
// builder.append(String.format("ignored: %s", stats.getIgnoredEvents())); // system disabled
//
// final String message = builder.toString();
//
// if (processor.isEnabled() && !processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access realtime subsystem");
// }
// }
// }
//
// Path: src/main/java/com/ning/metrics/collector/healthchecks/WriterHealthCheck.java
// public class WriterHealthCheck extends HealthCheck
// {
// private final EventSpoolDispatcher processor;
// private final WriterStats stats;
// private final PersistentWriterFactory factory;
// private final CollectorConfig config;
//
// @Inject
// public WriterHealthCheck(final EventSpoolDispatcher processor, final PersistentWriterFactory factory, final WriterStats stats, final CollectorConfig config)
// {
// super(WriterHealthCheck.class.getName());
// this.processor = processor;
// this.factory = factory;
// this.stats = stats;
// this.config = config;
// }
//
// @Override
// public Result check()
// {
// try {
// final StringBuilder builder = new StringBuilder();
//
// builder.append(String.format("running: %s, ", processor.isRunning()));
//
// builder.append("local files: {");
// int i = 1;
// final Set<String> paths = processor.getQueuesPerPath().keySet();
// for (final String queue : paths) {
// final LocalQueueAndWriter worker = processor.getQueuesPerPath().get(queue);
// builder.append(String.format("%s: %d", queue, worker.size()));
// if (worker.size() == config.getMaxQueueSize()) {
// builder.append(" [FULL]");
// }
//
// if (i < paths.size()) {
// builder.append(", ");
// }
// i++;
// }
// builder.append("}, ");
//
// builder.append(String.format("enqueued: %s, ", stats.getEnqueuedEvents()));
// builder.append(String.format("written: %s, ", stats.getWrittenEvents()));
// builder.append(String.format("dropped: %s, ", stats.getDroppedEvents())); // queue full
// builder.append(String.format("errored: %s, ", stats.getErroredEvents())); // I/O error
// builder.append(String.format("ignored: %s, ", stats.getIgnoredEvents())); // system disabled
// if (factory instanceof HadoopWriterFactory) {
// builder.append(String.format("pendingFiles: %s, ", ((HadoopWriterFactory) factory).nbLocalFiles())); // files waiting to be flushed
// }
// builder.append(String.format("flushes: %s", stats.getHdfsFlushes())); // HDFS flushes
//
// final String message = builder.toString();
// if (!processor.isRunning()) {
// return Result.unhealthy(message);
// }
// else {
// return Result.healthy(message);
// }
// }
// catch (Exception e) {
// return Result.unhealthy("Exception when trying to access writer subsystem");
// }
// }
// }
// Path: src/main/java/com/ning/metrics/collector/guice/HealthChecksModule.java
import com.ning.metrics.collector.healthchecks.HadoopHealthCheck;
import com.ning.metrics.collector.healthchecks.RealtimeHealthCheck;
import com.ning.metrics.collector.healthchecks.WriterHealthCheck;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.yammer.metrics.core.HealthCheck;
import com.yammer.metrics.guice.servlet.AdminServletModule;
/*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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.ning.metrics.collector.guice;
public class HealthChecksModule extends AbstractModule
{
@Override
protected void configure()
{
install(new AdminServletModule());
final Multibinder<HealthCheck> healthChecksBinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
healthChecksBinder.addBinding().to(HadoopHealthCheck.class).asEagerSingleton();
healthChecksBinder.addBinding().to(RealtimeHealthCheck.class).asEagerSingleton(); | healthChecksBinder.addBinding().to(WriterHealthCheck.class).asEagerSingleton(); |
searchisko/mbox_tools | mbox_parser/src/main/java/org/searchisko/mbox/parser/MessageBodyParser.java | // Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/MailAttachment.java
// public class MailAttachment {
//
// private String contentType;
// private String fileName;
// private String content;
//
// public String getContentType() { return this.contentType; }
// public void setContentType(String contentType) { this.contentType = contentType; }
//
// public String getFileName() { return this.fileName; }
// public void setFileName(String fileName) { this.fileName = fileName; }
//
// public String getContent() { return this.content; }
// public void setContent(String content) { this.content = content; }
// }
| import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
import com.sun.xml.messaging.saaj.packaging.mime.internet.MimeUtility;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.dom.*;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.searchisko.mbox.dto.MailAttachment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.ArrayList;
import java.util.List; | /*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* Represents the content of parsed mail body (no headers).
*
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
public class MessageBodyParser {
private static Logger log = LoggerFactory.getLogger(MessageBodyParser.class);
/**
* Supported message body subtypes.
*/
public enum SupportedMultiPartType {
ALTERNATIVE("alternative"), MIXED("mixed"), RELATED("related"), SIGNED("signed"),
/*,TODO: APPLEDOUBLE("appledouble")*/
UNKNOWN("");
private final String value;
private SupportedMultiPartType(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
public static SupportedMultiPartType getValue(String value) {
try {
return valueOf(value.replaceAll("-", "_").toUpperCase());
} catch (Exception e) {
return UNKNOWN;
}
}
}
/**
* Represents parsed message body content.
*/
public static class MailBodyContent {
private String messageId;
private String firstTextContent;
private String firstTextContentWithoutQuotes;
private String firstHtmlContent;
private List<String> textMessages = new ArrayList<>();
private List<String> htmlMessages = new ArrayList<>(); | // Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/MailAttachment.java
// public class MailAttachment {
//
// private String contentType;
// private String fileName;
// private String content;
//
// public String getContentType() { return this.contentType; }
// public void setContentType(String contentType) { this.contentType = contentType; }
//
// public String getFileName() { return this.fileName; }
// public void setFileName(String fileName) { this.fileName = fileName; }
//
// public String getContent() { return this.content; }
// public void setContent(String content) { this.content = content; }
// }
// Path: mbox_parser/src/main/java/org/searchisko/mbox/parser/MessageBodyParser.java
import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
import com.sun.xml.messaging.saaj.packaging.mime.internet.MimeUtility;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.dom.*;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.searchisko.mbox.dto.MailAttachment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* Represents the content of parsed mail body (no headers).
*
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
public class MessageBodyParser {
private static Logger log = LoggerFactory.getLogger(MessageBodyParser.class);
/**
* Supported message body subtypes.
*/
public enum SupportedMultiPartType {
ALTERNATIVE("alternative"), MIXED("mixed"), RELATED("related"), SIGNED("signed"),
/*,TODO: APPLEDOUBLE("appledouble")*/
UNKNOWN("");
private final String value;
private SupportedMultiPartType(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
public static SupportedMultiPartType getValue(String value) {
try {
return valueOf(value.replaceAll("-", "_").toUpperCase());
} catch (Exception e) {
return UNKNOWN;
}
}
}
/**
* Represents parsed message body content.
*/
public static class MailBodyContent {
private String messageId;
private String firstTextContent;
private String firstTextContentWithoutQuotes;
private String firstHtmlContent;
private List<String> textMessages = new ArrayList<>();
private List<String> htmlMessages = new ArrayList<>(); | private List<MailAttachment> attachments = new ArrayList<>(); |
searchisko/mbox_tools | mbox_parser/src/test/java/org/searchisko/mbox/parser/MessageHeaderParsingTest.java | // Path: mbox_parser/src/test/java/org/searchisko/mbox/MessageTestSupport.java
// public class MessageTestSupport extends BaseTestSupport {
//
// protected Message getMessage(String path, MessageBuilder mb) throws IOException, MimeException {
// InputStream is = getInputStream(path);
// Message message = mb.parseMessage(is);
// is.close();
// return message;
// }
// }
//
// Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/Mail.java
// public class Mail {
//
// private final String message_id;
// private final String message_id_original;
//
// private final String[] to;
// private final String subject_original;
// private final String subject;
// private final String author_name;
// private final String author_email;
// private final String date;
//
// private final String in_reply_to;
// private final String[] references;
//
// private final String message_snippet;
// private final String first_text_message;
// private final String first_text_message_without_quotes;
// private final String first_html_message;
//
// private final String[] text_messages;
// private final Integer text_messages_cnt;
//
// private final String[] html_messages;
// private final Integer html_messages_cnt;
//
// private final MailAttachment[] message_attachments;
// private final Integer message_attachments_cnt;
//
// public Mail(final String messageId, final String message_id_original, final String[] to, final String subject_original,
// final String subject, final String author_name, String author_email, final String date, final String in_reply_to,
// final String[] references, final String message_snippet, final String first_text_message,
// final String first_text_message_without_quotes, final String first_html_message, final String[] text_messages,
// final Integer text_messages_cnt, final String[] html_messages, final Integer html_messages_cnt,
// final MailAttachment[] message_attachments, final Integer message_attachments_cnt) {
//
// this.message_id = messageId;
// this.message_id_original = message_id_original;
// this.to = to;
// this.subject_original = subject_original;
// this.subject = subject;
// this.author_name = author_name;
// this.author_email = author_email;
// this.date = date;
// this.in_reply_to = in_reply_to;
// this.references = references;
// this.message_snippet = message_snippet;
// this.first_text_message = first_text_message;
// this.first_text_message_without_quotes = first_text_message_without_quotes;
// this.first_html_message = first_html_message;
// this.text_messages = text_messages;
// this.text_messages_cnt = text_messages_cnt;
// this.html_messages = html_messages;
// this.html_messages_cnt = html_messages_cnt;
// this.message_attachments = message_attachments;
// this.message_attachments_cnt = message_attachments_cnt;
// }
//
// public String message_id() { return message_id; }
// public String message_id_original() { return message_id_original; }
//
// public String[] to() { return to; }
// public String subject_original() { return subject_original; }
// public String subject() { return subject; }
// public String author_name() { return author_name; }
// public String author_email() { return author_email; }
// public String dateUTC() { return date; }
// public String in_reply_to() { return in_reply_to; }
// public String[] references() { return references; }
// public String message_snippet() { return message_snippet; }
// public String first_text_message() { return first_text_message; }
// public String first_text_message_without_quotes() { return first_text_message_without_quotes; }
// public String first_html_message() { return first_html_message; }
// public String[] text_messages() { return text_messages; }
// public Integer text_messages_cnt() { return text_messages_cnt; }
// public String[] html_messages() { return html_messages; }
// public Integer html_messages_cnt() { return html_messages_cnt; }
// public MailAttachment[] message_attachments() { return message_attachments; }
// public Integer message_attachments_cnt() { return message_attachments_cnt; }
//
// }
| import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.Message;
import org.apache.james.mime4j.dom.MessageBuilder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Before;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.searchisko.mbox.MessageTestSupport;
import org.searchisko.mbox.dto.Mail;
import java.io.*;
import java.util.Arrays; | /*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class MessageHeaderParsingTest extends MessageTestSupport {
private MessageBuilder mb;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() throws MimeException {
mb = MessageParser.getMessageBuilder();
}
@Test
public void shouldParseHeaders() throws IOException, MimeException, MessageParseException {
Message msg = getMessage("mbox/encoding/invalid/simple.mbox", mb); | // Path: mbox_parser/src/test/java/org/searchisko/mbox/MessageTestSupport.java
// public class MessageTestSupport extends BaseTestSupport {
//
// protected Message getMessage(String path, MessageBuilder mb) throws IOException, MimeException {
// InputStream is = getInputStream(path);
// Message message = mb.parseMessage(is);
// is.close();
// return message;
// }
// }
//
// Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/Mail.java
// public class Mail {
//
// private final String message_id;
// private final String message_id_original;
//
// private final String[] to;
// private final String subject_original;
// private final String subject;
// private final String author_name;
// private final String author_email;
// private final String date;
//
// private final String in_reply_to;
// private final String[] references;
//
// private final String message_snippet;
// private final String first_text_message;
// private final String first_text_message_without_quotes;
// private final String first_html_message;
//
// private final String[] text_messages;
// private final Integer text_messages_cnt;
//
// private final String[] html_messages;
// private final Integer html_messages_cnt;
//
// private final MailAttachment[] message_attachments;
// private final Integer message_attachments_cnt;
//
// public Mail(final String messageId, final String message_id_original, final String[] to, final String subject_original,
// final String subject, final String author_name, String author_email, final String date, final String in_reply_to,
// final String[] references, final String message_snippet, final String first_text_message,
// final String first_text_message_without_quotes, final String first_html_message, final String[] text_messages,
// final Integer text_messages_cnt, final String[] html_messages, final Integer html_messages_cnt,
// final MailAttachment[] message_attachments, final Integer message_attachments_cnt) {
//
// this.message_id = messageId;
// this.message_id_original = message_id_original;
// this.to = to;
// this.subject_original = subject_original;
// this.subject = subject;
// this.author_name = author_name;
// this.author_email = author_email;
// this.date = date;
// this.in_reply_to = in_reply_to;
// this.references = references;
// this.message_snippet = message_snippet;
// this.first_text_message = first_text_message;
// this.first_text_message_without_quotes = first_text_message_without_quotes;
// this.first_html_message = first_html_message;
// this.text_messages = text_messages;
// this.text_messages_cnt = text_messages_cnt;
// this.html_messages = html_messages;
// this.html_messages_cnt = html_messages_cnt;
// this.message_attachments = message_attachments;
// this.message_attachments_cnt = message_attachments_cnt;
// }
//
// public String message_id() { return message_id; }
// public String message_id_original() { return message_id_original; }
//
// public String[] to() { return to; }
// public String subject_original() { return subject_original; }
// public String subject() { return subject; }
// public String author_name() { return author_name; }
// public String author_email() { return author_email; }
// public String dateUTC() { return date; }
// public String in_reply_to() { return in_reply_to; }
// public String[] references() { return references; }
// public String message_snippet() { return message_snippet; }
// public String first_text_message() { return first_text_message; }
// public String first_text_message_without_quotes() { return first_text_message_without_quotes; }
// public String first_html_message() { return first_html_message; }
// public String[] text_messages() { return text_messages; }
// public Integer text_messages_cnt() { return text_messages_cnt; }
// public String[] html_messages() { return html_messages; }
// public Integer html_messages_cnt() { return html_messages_cnt; }
// public MailAttachment[] message_attachments() { return message_attachments; }
// public Integer message_attachments_cnt() { return message_attachments_cnt; }
//
// }
// Path: mbox_parser/src/test/java/org/searchisko/mbox/parser/MessageHeaderParsingTest.java
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.Message;
import org.apache.james.mime4j.dom.MessageBuilder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Before;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.searchisko.mbox.MessageTestSupport;
import org.searchisko.mbox.dto.Mail;
import java.io.*;
import java.util.Arrays;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class MessageHeaderParsingTest extends MessageTestSupport {
private MessageBuilder mb;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() throws MimeException {
mb = MessageParser.getMessageBuilder();
}
@Test
public void shouldParseHeaders() throws IOException, MimeException, MessageParseException {
Message msg = getMessage("mbox/encoding/invalid/simple.mbox", mb); | Mail mail = MessageParser.parse(msg, "clientSuffix"); |
searchisko/mbox_tools | mbox_indexer/src/test/java/org/searchisko/http/client/ClientTest.java | // Path: mbox_indexer/src/main/java/org/searchisko/http/client/Client.java
// public static ClientConfig getConfig() {
// return new ClientConfig();
// }
| import com.github.tomakehurst.wiremock.junit.WireMockClassRule;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.searchisko.http.client.Client.getConfig; | /*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.http.client;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class ClientTest {
@ClassRule
public static WireMockClassRule wireMockRule = new WireMockClassRule(8089);
@Test
public void shouldNotFail() throws IOException, URISyntaxException {
stubFor(post(urlMatching("/service/ct/[0-9]+"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"foo\":\"bar\"}")));
| // Path: mbox_indexer/src/main/java/org/searchisko/http/client/Client.java
// public static ClientConfig getConfig() {
// return new ClientConfig();
// }
// Path: mbox_indexer/src/test/java/org/searchisko/http/client/ClientTest.java
import com.github.tomakehurst.wiremock.junit.WireMockClassRule;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.searchisko.http.client.Client.getConfig;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.http.client;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class ClientTest {
@ClassRule
public static WireMockClassRule wireMockRule = new WireMockClassRule(8089);
@Test
public void shouldNotFail() throws IOException, URISyntaxException {
stubFor(post(urlMatching("/service/ct/[0-9]+"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"foo\":\"bar\"}")));
| Client client = new Client(getConfig().serviceHost(new URI("http://localhost:8089")).servicePath("/service").contentType("ct")); |
searchisko/mbox_tools | mbox_parser/src/test/java/org/searchisko/mbox/parser/MessageBodyParsingTest.java | // Path: mbox_parser/src/test/java/org/searchisko/mbox/MessageTestSupport.java
// public class MessageTestSupport extends BaseTestSupport {
//
// protected Message getMessage(String path, MessageBuilder mb) throws IOException, MimeException {
// InputStream is = getInputStream(path);
// Message message = mb.parseMessage(is);
// is.close();
// return message;
// }
// }
//
// Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/Mail.java
// public class Mail {
//
// private final String message_id;
// private final String message_id_original;
//
// private final String[] to;
// private final String subject_original;
// private final String subject;
// private final String author_name;
// private final String author_email;
// private final String date;
//
// private final String in_reply_to;
// private final String[] references;
//
// private final String message_snippet;
// private final String first_text_message;
// private final String first_text_message_without_quotes;
// private final String first_html_message;
//
// private final String[] text_messages;
// private final Integer text_messages_cnt;
//
// private final String[] html_messages;
// private final Integer html_messages_cnt;
//
// private final MailAttachment[] message_attachments;
// private final Integer message_attachments_cnt;
//
// public Mail(final String messageId, final String message_id_original, final String[] to, final String subject_original,
// final String subject, final String author_name, String author_email, final String date, final String in_reply_to,
// final String[] references, final String message_snippet, final String first_text_message,
// final String first_text_message_without_quotes, final String first_html_message, final String[] text_messages,
// final Integer text_messages_cnt, final String[] html_messages, final Integer html_messages_cnt,
// final MailAttachment[] message_attachments, final Integer message_attachments_cnt) {
//
// this.message_id = messageId;
// this.message_id_original = message_id_original;
// this.to = to;
// this.subject_original = subject_original;
// this.subject = subject;
// this.author_name = author_name;
// this.author_email = author_email;
// this.date = date;
// this.in_reply_to = in_reply_to;
// this.references = references;
// this.message_snippet = message_snippet;
// this.first_text_message = first_text_message;
// this.first_text_message_without_quotes = first_text_message_without_quotes;
// this.first_html_message = first_html_message;
// this.text_messages = text_messages;
// this.text_messages_cnt = text_messages_cnt;
// this.html_messages = html_messages;
// this.html_messages_cnt = html_messages_cnt;
// this.message_attachments = message_attachments;
// this.message_attachments_cnt = message_attachments_cnt;
// }
//
// public String message_id() { return message_id; }
// public String message_id_original() { return message_id_original; }
//
// public String[] to() { return to; }
// public String subject_original() { return subject_original; }
// public String subject() { return subject; }
// public String author_name() { return author_name; }
// public String author_email() { return author_email; }
// public String dateUTC() { return date; }
// public String in_reply_to() { return in_reply_to; }
// public String[] references() { return references; }
// public String message_snippet() { return message_snippet; }
// public String first_text_message() { return first_text_message; }
// public String first_text_message_without_quotes() { return first_text_message_without_quotes; }
// public String first_html_message() { return first_html_message; }
// public String[] text_messages() { return text_messages; }
// public Integer text_messages_cnt() { return text_messages_cnt; }
// public String[] html_messages() { return html_messages; }
// public Integer html_messages_cnt() { return html_messages_cnt; }
// public MailAttachment[] message_attachments() { return message_attachments; }
// public Integer message_attachments_cnt() { return message_attachments_cnt; }
//
// }
| import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.Message;
import org.apache.james.mime4j.dom.MessageBuilder;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.searchisko.mbox.MessageTestSupport;
import org.searchisko.mbox.dto.Mail;
import java.io.IOException;
import static org.junit.Assert.assertEquals; | /*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class MessageBodyParsingTest extends MessageTestSupport {
private MessageBuilder mb;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() throws MimeException {
mb = MessageParser.getMessageBuilder();
}
@Test
public void shouldParseMessage() throws IOException, MimeException, MessageParseException {
Message msg = getMessage("mbox/encoding/invalid/simple.mbox", mb); | // Path: mbox_parser/src/test/java/org/searchisko/mbox/MessageTestSupport.java
// public class MessageTestSupport extends BaseTestSupport {
//
// protected Message getMessage(String path, MessageBuilder mb) throws IOException, MimeException {
// InputStream is = getInputStream(path);
// Message message = mb.parseMessage(is);
// is.close();
// return message;
// }
// }
//
// Path: mbox_parser/src/main/java/org/searchisko/mbox/dto/Mail.java
// public class Mail {
//
// private final String message_id;
// private final String message_id_original;
//
// private final String[] to;
// private final String subject_original;
// private final String subject;
// private final String author_name;
// private final String author_email;
// private final String date;
//
// private final String in_reply_to;
// private final String[] references;
//
// private final String message_snippet;
// private final String first_text_message;
// private final String first_text_message_without_quotes;
// private final String first_html_message;
//
// private final String[] text_messages;
// private final Integer text_messages_cnt;
//
// private final String[] html_messages;
// private final Integer html_messages_cnt;
//
// private final MailAttachment[] message_attachments;
// private final Integer message_attachments_cnt;
//
// public Mail(final String messageId, final String message_id_original, final String[] to, final String subject_original,
// final String subject, final String author_name, String author_email, final String date, final String in_reply_to,
// final String[] references, final String message_snippet, final String first_text_message,
// final String first_text_message_without_quotes, final String first_html_message, final String[] text_messages,
// final Integer text_messages_cnt, final String[] html_messages, final Integer html_messages_cnt,
// final MailAttachment[] message_attachments, final Integer message_attachments_cnt) {
//
// this.message_id = messageId;
// this.message_id_original = message_id_original;
// this.to = to;
// this.subject_original = subject_original;
// this.subject = subject;
// this.author_name = author_name;
// this.author_email = author_email;
// this.date = date;
// this.in_reply_to = in_reply_to;
// this.references = references;
// this.message_snippet = message_snippet;
// this.first_text_message = first_text_message;
// this.first_text_message_without_quotes = first_text_message_without_quotes;
// this.first_html_message = first_html_message;
// this.text_messages = text_messages;
// this.text_messages_cnt = text_messages_cnt;
// this.html_messages = html_messages;
// this.html_messages_cnt = html_messages_cnt;
// this.message_attachments = message_attachments;
// this.message_attachments_cnt = message_attachments_cnt;
// }
//
// public String message_id() { return message_id; }
// public String message_id_original() { return message_id_original; }
//
// public String[] to() { return to; }
// public String subject_original() { return subject_original; }
// public String subject() { return subject; }
// public String author_name() { return author_name; }
// public String author_email() { return author_email; }
// public String dateUTC() { return date; }
// public String in_reply_to() { return in_reply_to; }
// public String[] references() { return references; }
// public String message_snippet() { return message_snippet; }
// public String first_text_message() { return first_text_message; }
// public String first_text_message_without_quotes() { return first_text_message_without_quotes; }
// public String first_html_message() { return first_html_message; }
// public String[] text_messages() { return text_messages; }
// public Integer text_messages_cnt() { return text_messages_cnt; }
// public String[] html_messages() { return html_messages; }
// public Integer html_messages_cnt() { return html_messages_cnt; }
// public MailAttachment[] message_attachments() { return message_attachments; }
// public Integer message_attachments_cnt() { return message_attachments_cnt; }
//
// }
// Path: mbox_parser/src/test/java/org/searchisko/mbox/parser/MessageBodyParsingTest.java
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.Message;
import org.apache.james.mime4j.dom.MessageBuilder;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.searchisko.mbox.MessageTestSupport;
import org.searchisko.mbox.dto.Mail;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.searchisko.mbox.parser;
/**
* @author Lukáš Vlček (lvlcek@redhat.com)
*/
@RunWith(JUnit4.class)
public class MessageBodyParsingTest extends MessageTestSupport {
private MessageBuilder mb;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() throws MimeException {
mb = MessageParser.getMessageBuilder();
}
@Test
public void shouldParseMessage() throws IOException, MimeException, MessageParseException {
Message msg = getMessage("mbox/encoding/invalid/simple.mbox", mb); | Mail mail = MessageParser.parse(msg); |
sabrinathai/ExperienceSampler | Example ExperienceSampler/exampleExperienceSampleriOS/plugins/cordova-plugin-local-notification/src/android/notification/Builder.java | // Path: Example ExperienceSampler/exampleExperienceSampleriOS/plugins/cordova-plugin-local-notification/src/android/notification/Notification.java
// public static final String EXTRA_UPDATE = "NOTIFICATION_UPDATE";
| import android.support.v4.media.session.MediaSessionCompat;
import java.util.List;
import java.util.Random;
import de.appplant.cordova.plugin.notification.action.Action;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static de.appplant.cordova.plugin.notification.Notification.EXTRA_UPDATE;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.MessagingStyle.Message;
import android.support.v4.media.app.NotificationCompat.MediaStyle; |
/**
* Returns a new PendingIntent for a notification action, including the
* action's identifier.
*
* @param action Notification action needing the PendingIntent
*/
private PendingIntent getPendingIntentForAction (Action action) {
Intent intent = new Intent(context, clickActivity)
.putExtra(Notification.EXTRA_ID, options.getId())
.putExtra(Action.EXTRA_ID, action.getId())
.putExtra(Options.EXTRA_LAUNCH, action.isLaunchingApp())
.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (extras != null) {
intent.putExtras(extras);
}
int reqCode = random.nextInt();
return PendingIntent.getService(
context, reqCode, intent, FLAG_UPDATE_CURRENT);
}
/**
* If the builder shall build an notification or an updated version.
*
* @return true in case of an updated version.
*/
private boolean isUpdate() { | // Path: Example ExperienceSampler/exampleExperienceSampleriOS/plugins/cordova-plugin-local-notification/src/android/notification/Notification.java
// public static final String EXTRA_UPDATE = "NOTIFICATION_UPDATE";
// Path: Example ExperienceSampler/exampleExperienceSampleriOS/plugins/cordova-plugin-local-notification/src/android/notification/Builder.java
import android.support.v4.media.session.MediaSessionCompat;
import java.util.List;
import java.util.Random;
import de.appplant.cordova.plugin.notification.action.Action;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static de.appplant.cordova.plugin.notification.Notification.EXTRA_UPDATE;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.MessagingStyle.Message;
import android.support.v4.media.app.NotificationCompat.MediaStyle;
/**
* Returns a new PendingIntent for a notification action, including the
* action's identifier.
*
* @param action Notification action needing the PendingIntent
*/
private PendingIntent getPendingIntentForAction (Action action) {
Intent intent = new Intent(context, clickActivity)
.putExtra(Notification.EXTRA_ID, options.getId())
.putExtra(Action.EXTRA_ID, action.getId())
.putExtra(Options.EXTRA_LAUNCH, action.isLaunchingApp())
.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (extras != null) {
intent.putExtras(extras);
}
int reqCode = random.nextInt();
return PendingIntent.getService(
context, reqCode, intent, FLAG_UPDATE_CURRENT);
}
/**
* If the builder shall build an notification or an updated version.
*
* @return true in case of an updated version.
*/
private boolean isUpdate() { | return extras != null && extras.getBoolean(EXTRA_UPDATE, false); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| Form f = not(exists("x","X",implies($("P"),$("Q")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| Form f = not(exists("x","X",implies($("P"),$("Q")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| Form f = not(exists("x","X",implies($("P"),$("Q")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| Form f = not(exists("x","X",implies($("P"),$("Q")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
| Form f = not(exists("x","X",implies($("P"),$("Q")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/Jan2016.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
Form f = not(exists("x","X",implies($("P"),$("Q"))));
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/Jan2016.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class Jan2016 {
public static void main(String[] args)throws Exception {
Form f = not(exists("x","X",implies($("P"),$("Q"))));
| hyp(f) |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPropositional.java | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
| // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPropositional.java
import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
| Form p = $("P"); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPropositional.java | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
| // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPropositional.java
import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
| Form p = $("P"); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPropositional.java | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P"); | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPropositional.java
import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P"); | Form pnot = not($("P")); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPropositional.java | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P");
Form pnot = not($("P")); | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPropositional.java
import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P");
Form pnot = not($("P")); | Form notpornot = not(or($("P"),not($("P")))); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPropositional.java | // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P");
Form pnot = not($("P"));
Form notpornot = not(or($("P"),not($("P"))));
| // Path: src/discretemaths/Proof.java
// public static Proof begin()
// {
// return new Proof();
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPropositional.java
import static discretemaths.Proof.begin;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.not;
import static discretemaths.forms.Form.or;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPropositional {
public static void main(String[] args) throws Exception{
Form p = $("P");
Form pnot = not($("P"));
Form notpornot = not(or($("P"),not($("P"))));
| begin() |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| Form f = exists("x","X",exists("y", "Y", $("P"))); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| Form f = exists("x","X",exists("y", "Y", $("P"))); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
| Form f = exists("x","X",exists("y", "Y", $("P"))); |
ccol002/DiscreteMaths | src/discretemaths/examples/AdvancedPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form; | package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
Form f = exists("x","X",exists("y", "Y", $("P")));
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/AdvancedPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.and;
import static discretemaths.forms.Form.exists;
import static discretemaths.forms.Form.forall;
import static discretemaths.forms.Form.implies;
import static discretemaths.forms.Form.not;
import discretemaths.forms.Form;
package discretemaths.examples;
public class AdvancedPredicate {
public static void main(String[] args)throws Exception {
Form f = exists("x","X",exists("y", "Y", $("P")));
| /*1*/ hyp(f) |
ccol002/DiscreteMaths | src/discretemaths/examples/BasicPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form; | package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/BasicPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form;
package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| Form f = forall("x","X",$("P")); |
ccol002/DiscreteMaths | src/discretemaths/examples/BasicPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form; | package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/BasicPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form;
package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| Form f = forall("x","X",$("P")); |
ccol002/DiscreteMaths | src/discretemaths/examples/BasicPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form; | package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/BasicPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form;
package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
| Form f = forall("x","X",$("P")); |
ccol002/DiscreteMaths | src/discretemaths/examples/BasicPredicate.java | // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
| import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form; | package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
Form f = forall("x","X",$("P"));
| // Path: src/discretemaths/Proof.java
// public static Proof hyp(Form... forms) throws InvalidRuleException
// {
// Proof pf = new Proof();
//
// for (Form p:forms){
// if (!p.isWellFormed())
// throw new InvalidRuleException("Malformed formula: " + p);
// pf.proof.add(p);
// pf.reasons.add(new Hyp());
// pf.depths.add(pf.depth);
// }
// return pf;
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// Path: src/discretemaths/forms/Form.java
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// Path: src/discretemaths/forms/Form.java
// public abstract class Form {
//
// protected String substNew;
// protected String substOld;
//
// public Form subst(String substNew, String substOld)throws InvalidFormException
// {
// if (substNew==null || substOld==null)
// throw new InvalidFormException("Variables substitution requires two non-null inputs");
// this.substNew = substNew;
// this.substOld = substOld;
// return this;
// }
//
// public Form removeSubst()
// {
// this.substNew = null;
// this.substOld = null;
// return this;
// }
//
// public boolean hasSubt()
// {
// return substNew !=null && substOld != null;
// }
//
// public String getSubstNew()
// {
// return substNew;
// }
//
// public String getSubstOld()
// {
// return substOld;
// }
//
// public abstract Form clone();
//
// public Form cloneHelper(Form f)
// {
// try{
// if (f.hasSubt())
// subst(f.getSubstNew(), f.getSubstOld());
// }catch(Exception ex)
// {
// //should not be a problem when called within the class itself
// System.err.println("Something strange happend.. you should never see this");
// }
// return this;
// }
//
// public abstract String toString();
//
// public String toStringHelper(String s)
// {
// String subst = "["+substOld+" <- "+substNew+"]";
//
// if (substNew==null || substOld==null)
// return s;
// else if (s.startsWith("("))
// return s+subst;
// else
// return "("+s+")"+subst;
// }
//
// public boolean isWellFormed()
// {
// if (substNew ==null && substOld != null)
// return false;
// else if (substNew !=null && substOld == null)
// return false;
// else
// return true;
// }
//
// public abstract boolean occursFree(String x);
//
//
// public static Form $(String prop, String... vars)
// {
// return new Pred(prop, vars);
// }
//
// public static Form and(Form p1, Form p2) throws InvalidFormException
// {
// return new And(p1,p2);
// }
//
// public static Form or(Form p1, Form p2) throws InvalidFormException
// {
// return new Or(p1,p2);
// }
//
// public static Form implies(Form p1, Form p2) throws InvalidFormException
// {
// return new Implies(p1,p2);
// }
//
// public static Form biimplies(Form p1, Form p2) throws InvalidFormException
// {
// return new Biimplies(p1,p2);
// }
//
// public static Form not(Form p1) throws InvalidFormException
// {
// return new Not(p1);
// }
//
// public static Form forall(String var, String type, Form form) throws InvalidFormException
// {
// return new Forall(var, type, form);
// }
//
// public static Form exists(String var, String type, Form form) throws InvalidFormException
// {
// return new Exists(var, type, form);
// }
// }
// Path: src/discretemaths/examples/BasicPredicate.java
import static discretemaths.Proof.hyp;
import static discretemaths.forms.Form.$;
import static discretemaths.forms.Form.forall;
import discretemaths.forms.Form;
package discretemaths.examples;
public class BasicPredicate {
public static void main(String[] args)throws Exception {
Form f = forall("x","X",$("P"));
| /*1*/ hyp(f) |
WSDOT/Archetypes | archetypes/mgwt-basic/src/main/java/gov/wa/wsdot/apps/mgwtbasic/client/BasicEntryPoint.java | // Path: archetypes/mgwt-basic/src/main/java/gov/wa/wsdot/apps/mgwtbasic/client/activities/home/HomePlace.java
// public class HomePlace extends Place {
//
// public static class HomePlaceTokenizer implements PlaceTokenizer<HomePlace> {
//
// @Override
// public HomePlace getPlace(String token) {
// return new HomePlace();
// }
//
// @Override
// public String getToken(HomePlace place) {
// return "";
// }
//
// }
//
// @Override
// public int hashCode() {
// return 3;
// }
//
// @Override
// public boolean equals(Object other) {
// if (other == this) {
// return true;
// }
//
// if (other == null) {
// return false;
// }
//
// if (other instanceof HomePlace) {
// return true;
// }
//
// return false;
// }
// }
| import gov.wa.wsdot.apps.mgwtbasic.client.activities.home.HomePlace;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.googlecode.mgwt.mvp.client.AnimatingActivityManager;
import com.googlecode.mgwt.mvp.client.history.MGWTPlaceHistoryHandler;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTSettings;
import com.googlecode.mgwt.ui.client.MGWTSettings.ViewPort;
import com.googlecode.mgwt.ui.client.util.SuperDevModeUtil;
import com.googlecode.mgwt.ui.client.widget.animation.AnimationWidget; | package gov.wa.wsdot.apps.mgwtbasic.client;
public class BasicEntryPoint implements EntryPoint {
private void start() {
SuperDevModeUtil.showDevMode();
ViewPort viewPort = new MGWTSettings.ViewPort();
viewPort.setUserScaleAble(false).setInitialScale(1.0).setMinimumScale(1.0).setMaximumScale(1.0);
MGWTSettings settings = new MGWTSettings();
settings.setViewPort(viewPort);
settings.setIconUrl("logo.png");
settings.setFullscreen(true);
settings.setFixIOS71BodyBug(true);
settings.setPreventScrolling(true);
MGWT.applySettings(settings);
final ClientFactory clientFactory = new ClientFactoryImpl();
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
createPhoneDisplay(clientFactory);
AppHistoryObserver historyObserver = new AppHistoryObserver();
MGWTPlaceHistoryHandler historyHandler = new MGWTPlaceHistoryHandler(historyMapper, historyObserver); | // Path: archetypes/mgwt-basic/src/main/java/gov/wa/wsdot/apps/mgwtbasic/client/activities/home/HomePlace.java
// public class HomePlace extends Place {
//
// public static class HomePlaceTokenizer implements PlaceTokenizer<HomePlace> {
//
// @Override
// public HomePlace getPlace(String token) {
// return new HomePlace();
// }
//
// @Override
// public String getToken(HomePlace place) {
// return "";
// }
//
// }
//
// @Override
// public int hashCode() {
// return 3;
// }
//
// @Override
// public boolean equals(Object other) {
// if (other == this) {
// return true;
// }
//
// if (other == null) {
// return false;
// }
//
// if (other instanceof HomePlace) {
// return true;
// }
//
// return false;
// }
// }
// Path: archetypes/mgwt-basic/src/main/java/gov/wa/wsdot/apps/mgwtbasic/client/BasicEntryPoint.java
import gov.wa.wsdot.apps.mgwtbasic.client.activities.home.HomePlace;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.googlecode.mgwt.mvp.client.AnimatingActivityManager;
import com.googlecode.mgwt.mvp.client.history.MGWTPlaceHistoryHandler;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTSettings;
import com.googlecode.mgwt.ui.client.MGWTSettings.ViewPort;
import com.googlecode.mgwt.ui.client.util.SuperDevModeUtil;
import com.googlecode.mgwt.ui.client.widget.animation.AnimationWidget;
package gov.wa.wsdot.apps.mgwtbasic.client;
public class BasicEntryPoint implements EntryPoint {
private void start() {
SuperDevModeUtil.showDevMode();
ViewPort viewPort = new MGWTSettings.ViewPort();
viewPort.setUserScaleAble(false).setInitialScale(1.0).setMinimumScale(1.0).setMaximumScale(1.0);
MGWTSettings settings = new MGWTSettings();
settings.setViewPort(viewPort);
settings.setIconUrl("logo.png");
settings.setFullscreen(true);
settings.setFixIOS71BodyBug(true);
settings.setPreventScrolling(true);
MGWT.applySettings(settings);
final ClientFactory clientFactory = new ClientFactoryImpl();
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
createPhoneDisplay(clientFactory);
AppHistoryObserver historyObserver = new AppHistoryObserver();
MGWTPlaceHistoryHandler historyHandler = new MGWTPlaceHistoryHandler(historyMapper, historyObserver); | historyHandler.register(clientFactory.getPlaceController(), clientFactory.getEventBus(), new HomePlace()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.