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 |
|---|---|---|---|---|---|---|
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/MccyAssetSettingsFixedUriValidatorTest.java | // Path: src/main/java/me/itzg/mccy/config/MccyAssetSettings.java
// @ConfigurationProperties("mccy.assets")
// @Component
// @ValidViaNetworkSettings
// @ValidViaFixedUriSettings
// public class MccyAssetSettings {
//
// @NotNull
// private File storageDir;
//
// @NotNull
// private Via via = Via.REQUEST_URL;
//
// private String network;
//
// private String myNameOnNetwork;
//
// private URI fixedUri;
//
// public Via getVia() {
// return via;
// }
//
// public void setVia(Via via) {
// this.via = via;
// }
//
// public File getStorageDir() {
// return storageDir;
// }
//
// public void setStorageDir(File storageDir) {
// this.storageDir = storageDir;
// }
//
// public String getNetwork() {
// return network;
// }
//
// public void setNetwork(String network) {
// this.network = network;
// }
//
// public URI getFixedUri() {
// return fixedUri;
// }
//
// @SuppressWarnings("unused")
// public void setFixedUri(URI fixedUri) {
// this.fixedUri = fixedUri;
// }
//
// public String getMyNameOnNetwork() {
// return myNameOnNetwork;
// }
//
// public void setMyNameOnNetwork(String myNameOnNetwork) {
// this.myNameOnNetwork = myNameOnNetwork;
// }
//
// public enum Via {
// NETWORK,
// LINK,
// FIXED_URI,
// REQUEST_URL
// }
// }
| import me.itzg.mccy.config.MccyAssetSettings;
import org.hamcrest.Matchers;
import org.hibernate.validator.HibernateValidator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.net.URI;
import java.util.Set;
import static org.junit.Assert.assertThat; | package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
@SuppressWarnings("Duplicates")
public class MccyAssetSettingsFixedUriValidatorTest {
private LocalValidatorFactoryBean validatorFactoryBean;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setUp() throws Exception {
validatorFactoryBean = new LocalValidatorFactoryBean();
validatorFactoryBean.setProviderClass(HibernateValidator.class);
validatorFactoryBean.afterPropertiesSet();
}
@Test
public void testViolatesNone() throws Exception {
final Validator validator = validatorFactoryBean.getValidator();
| // Path: src/main/java/me/itzg/mccy/config/MccyAssetSettings.java
// @ConfigurationProperties("mccy.assets")
// @Component
// @ValidViaNetworkSettings
// @ValidViaFixedUriSettings
// public class MccyAssetSettings {
//
// @NotNull
// private File storageDir;
//
// @NotNull
// private Via via = Via.REQUEST_URL;
//
// private String network;
//
// private String myNameOnNetwork;
//
// private URI fixedUri;
//
// public Via getVia() {
// return via;
// }
//
// public void setVia(Via via) {
// this.via = via;
// }
//
// public File getStorageDir() {
// return storageDir;
// }
//
// public void setStorageDir(File storageDir) {
// this.storageDir = storageDir;
// }
//
// public String getNetwork() {
// return network;
// }
//
// public void setNetwork(String network) {
// this.network = network;
// }
//
// public URI getFixedUri() {
// return fixedUri;
// }
//
// @SuppressWarnings("unused")
// public void setFixedUri(URI fixedUri) {
// this.fixedUri = fixedUri;
// }
//
// public String getMyNameOnNetwork() {
// return myNameOnNetwork;
// }
//
// public void setMyNameOnNetwork(String myNameOnNetwork) {
// this.myNameOnNetwork = myNameOnNetwork;
// }
//
// public enum Via {
// NETWORK,
// LINK,
// FIXED_URI,
// REQUEST_URL
// }
// }
// Path: src/test/java/me/itzg/mccy/services/MccyAssetSettingsFixedUriValidatorTest.java
import me.itzg.mccy.config.MccyAssetSettings;
import org.hamcrest.Matchers;
import org.hibernate.validator.HibernateValidator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.net.URI;
import java.util.Set;
import static org.junit.Assert.assertThat;
package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
@SuppressWarnings("Duplicates")
public class MccyAssetSettingsFixedUriValidatorTest {
private LocalValidatorFactoryBean validatorFactoryBean;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setUp() throws Exception {
validatorFactoryBean = new LocalValidatorFactoryBean();
validatorFactoryBean.setProviderClass(HibernateValidator.class);
validatorFactoryBean.afterPropertiesSet();
}
@Test
public void testViolatesNone() throws Exception {
final Validator validator = validatorFactoryBean.getValidator();
| final MccyAssetSettings settings = new MccyAssetSettings(); |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/FileStorageService.java | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyNotFoundException.java
// public class MccyNotFoundException extends MccyClientException {
// public MccyNotFoundException() {
// }
//
// public MccyNotFoundException(String message) {
// super(message);
// }
//
// public MccyNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyNotFoundException(Throwable cause) {
// super(cause);
// }
// }
| import me.itzg.mccy.config.MccyFilesSettings;
import me.itzg.mccy.types.MccyConstants;
import me.itzg.mccy.types.MccyNotFoundException;
import me.itzg.mccy.types.ReleasingFileSystemResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption; | package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 12/23/2015
*/
@Service
public class FileStorageService {
private static Logger LOG = LoggerFactory.getLogger(FileStorageService.class);
private Path repoPath;
@Autowired
public void setSettings(MccyFilesSettings settings) throws IOException {
MccyFilesSettings settings1 = settings;
repoPath = Paths.get(settings.getRepoDir());
Files.createDirectories(repoPath);
}
public String saveNeedsName(String category, String suffix, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final String originalFilename = src.getOriginalFilename();
final Path tempFile = Files.createTempFile(categoryPath,
temporary ? "temp-" : "", suffix);
// replace the empty placeholder created by createTempFile
Files.copy(src.getInputStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
return tempFile.getFileName().toString();
}
public String save(String category, String filename, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final Path outFile = categoryPath.resolve( | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyNotFoundException.java
// public class MccyNotFoundException extends MccyClientException {
// public MccyNotFoundException() {
// }
//
// public MccyNotFoundException(String message) {
// super(message);
// }
//
// public MccyNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyNotFoundException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/me/itzg/mccy/services/FileStorageService.java
import me.itzg.mccy.config.MccyFilesSettings;
import me.itzg.mccy.types.MccyConstants;
import me.itzg.mccy.types.MccyNotFoundException;
import me.itzg.mccy.types.ReleasingFileSystemResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 12/23/2015
*/
@Service
public class FileStorageService {
private static Logger LOG = LoggerFactory.getLogger(FileStorageService.class);
private Path repoPath;
@Autowired
public void setSettings(MccyFilesSettings settings) throws IOException {
MccyFilesSettings settings1 = settings;
repoPath = Paths.get(settings.getRepoDir());
Files.createDirectories(repoPath);
}
public String saveNeedsName(String category, String suffix, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final String originalFilename = src.getOriginalFilename();
final Path tempFile = Files.createTempFile(categoryPath,
temporary ? "temp-" : "", suffix);
// replace the empty placeholder created by createTempFile
Files.copy(src.getInputStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
return tempFile.getFileName().toString();
}
public String save(String category, String filename, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final Path outFile = categoryPath.resolve( | (temporary ? MccyConstants.TEMP_PREFIX : "") + filename |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/FileStorageService.java | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyNotFoundException.java
// public class MccyNotFoundException extends MccyClientException {
// public MccyNotFoundException() {
// }
//
// public MccyNotFoundException(String message) {
// super(message);
// }
//
// public MccyNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyNotFoundException(Throwable cause) {
// super(cause);
// }
// }
| import me.itzg.mccy.config.MccyFilesSettings;
import me.itzg.mccy.types.MccyConstants;
import me.itzg.mccy.types.MccyNotFoundException;
import me.itzg.mccy.types.ReleasingFileSystemResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption; |
public String save(String category, String filename, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final Path outFile = categoryPath.resolve(
(temporary ? MccyConstants.TEMP_PREFIX : "") + filename
);
Files.copy(src.getInputStream(), outFile);
return outFile.getFileName().toString();
}
public void delete(String category, String filename) {
final Path resolved = repoPath.resolve(category);
try {
Files.delete(resolved.resolve(filename));
} catch (IOException e) {
LOG.warn("Failed to delete {} file named {}", e, category, filename);
}
}
/**
*
* @param category the file storage category
* @param filename the name of the file within the category
* @param out where the content of the file will be written. NOTE: this stream will NOT be closed by this
* method
*/ | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyNotFoundException.java
// public class MccyNotFoundException extends MccyClientException {
// public MccyNotFoundException() {
// }
//
// public MccyNotFoundException(String message) {
// super(message);
// }
//
// public MccyNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyNotFoundException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/me/itzg/mccy/services/FileStorageService.java
import me.itzg.mccy.config.MccyFilesSettings;
import me.itzg.mccy.types.MccyConstants;
import me.itzg.mccy.types.MccyNotFoundException;
import me.itzg.mccy.types.ReleasingFileSystemResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public String save(String category, String filename, boolean temporary, MultipartFile src) throws IOException {
final Path categoryPath = resolveCategoryPath(category);
final Path outFile = categoryPath.resolve(
(temporary ? MccyConstants.TEMP_PREFIX : "") + filename
);
Files.copy(src.getInputStream(), outFile);
return outFile.getFileName().toString();
}
public void delete(String category, String filename) {
final Path resolved = repoPath.resolve(category);
try {
Files.delete(resolved.resolve(filename));
} catch (IOException e) {
LOG.warn("Failed to delete {} file named {}", e, category, filename);
}
}
/**
*
* @param category the file storage category
* @param filename the name of the file within the category
* @param out where the content of the file will be written. NOTE: this stream will NOT be closed by this
* method
*/ | public void copyTo(String category, String filename, OutputStream out) throws IOException, MccyNotFoundException { |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/MccyAssetSettingsNetworkValidatorTest.java | // Path: src/main/java/me/itzg/mccy/config/MccyAssetSettings.java
// @ConfigurationProperties("mccy.assets")
// @Component
// @ValidViaNetworkSettings
// @ValidViaFixedUriSettings
// public class MccyAssetSettings {
//
// @NotNull
// private File storageDir;
//
// @NotNull
// private Via via = Via.REQUEST_URL;
//
// private String network;
//
// private String myNameOnNetwork;
//
// private URI fixedUri;
//
// public Via getVia() {
// return via;
// }
//
// public void setVia(Via via) {
// this.via = via;
// }
//
// public File getStorageDir() {
// return storageDir;
// }
//
// public void setStorageDir(File storageDir) {
// this.storageDir = storageDir;
// }
//
// public String getNetwork() {
// return network;
// }
//
// public void setNetwork(String network) {
// this.network = network;
// }
//
// public URI getFixedUri() {
// return fixedUri;
// }
//
// @SuppressWarnings("unused")
// public void setFixedUri(URI fixedUri) {
// this.fixedUri = fixedUri;
// }
//
// public String getMyNameOnNetwork() {
// return myNameOnNetwork;
// }
//
// public void setMyNameOnNetwork(String myNameOnNetwork) {
// this.myNameOnNetwork = myNameOnNetwork;
// }
//
// public enum Via {
// NETWORK,
// LINK,
// FIXED_URI,
// REQUEST_URL
// }
// }
| import me.itzg.mccy.config.MccyAssetSettings;
import org.hamcrest.Matchers;
import org.hibernate.validator.HibernateValidator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Set;
import static org.junit.Assert.*; | package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class MccyAssetSettingsNetworkValidatorTest {
private LocalValidatorFactoryBean validatorFactoryBean;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setUp() throws Exception {
validatorFactoryBean = new LocalValidatorFactoryBean();
validatorFactoryBean.setProviderClass(HibernateValidator.class);
validatorFactoryBean.afterPropertiesSet();
}
@Test
public void testViolatesNone() throws Exception {
final Validator validator = validatorFactoryBean.getValidator();
| // Path: src/main/java/me/itzg/mccy/config/MccyAssetSettings.java
// @ConfigurationProperties("mccy.assets")
// @Component
// @ValidViaNetworkSettings
// @ValidViaFixedUriSettings
// public class MccyAssetSettings {
//
// @NotNull
// private File storageDir;
//
// @NotNull
// private Via via = Via.REQUEST_URL;
//
// private String network;
//
// private String myNameOnNetwork;
//
// private URI fixedUri;
//
// public Via getVia() {
// return via;
// }
//
// public void setVia(Via via) {
// this.via = via;
// }
//
// public File getStorageDir() {
// return storageDir;
// }
//
// public void setStorageDir(File storageDir) {
// this.storageDir = storageDir;
// }
//
// public String getNetwork() {
// return network;
// }
//
// public void setNetwork(String network) {
// this.network = network;
// }
//
// public URI getFixedUri() {
// return fixedUri;
// }
//
// @SuppressWarnings("unused")
// public void setFixedUri(URI fixedUri) {
// this.fixedUri = fixedUri;
// }
//
// public String getMyNameOnNetwork() {
// return myNameOnNetwork;
// }
//
// public void setMyNameOnNetwork(String myNameOnNetwork) {
// this.myNameOnNetwork = myNameOnNetwork;
// }
//
// public enum Via {
// NETWORK,
// LINK,
// FIXED_URI,
// REQUEST_URL
// }
// }
// Path: src/test/java/me/itzg/mccy/services/MccyAssetSettingsNetworkValidatorTest.java
import me.itzg.mccy.config.MccyAssetSettings;
import org.hamcrest.Matchers;
import org.hibernate.validator.HibernateValidator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Set;
import static org.junit.Assert.*;
package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class MccyAssetSettingsNetworkValidatorTest {
private LocalValidatorFactoryBean validatorFactoryBean;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setUp() throws Exception {
validatorFactoryBean = new LocalValidatorFactoryBean();
validatorFactoryBean.setProviderClass(HibernateValidator.class);
validatorFactoryBean.afterPropertiesSet();
}
@Test
public void testViolatesNone() throws Exception {
final Validator validator = validatorFactoryBean.getValidator();
| final MccyAssetSettings settings = new MccyAssetSettings(); |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/ZipMiningService.java | // Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
| import me.itzg.mccy.types.ZipMiningHandler;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional; | package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
public interface ZipMiningService {
/**
* Walks a zip file invoking the given handlers and returns a file hash ID.
* @param rawInputStream the raw input stream of the zip file
* @param handlers an optional list of handler to be invoked
* @return the overall file's hash ID
* @throws IOException
*/
String interrogate(InputStream rawInputStream, | // Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
// Path: src/main/java/me/itzg/mccy/services/ZipMiningService.java
import me.itzg.mccy.types.ZipMiningHandler;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;
package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 0.2
*/
public interface ZipMiningService {
/**
* Walks a zip file invoking the given handlers and returns a file hash ID.
* @param rawInputStream the raw input stream of the zip file
* @param handlers an optional list of handler to be invoked
* @return the overall file's hash ID
* @throws IOException
*/
String interrogate(InputStream rawInputStream, | Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException; |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/config/GeneralConfig.java | // Path: src/main/java/me/itzg/mccy/services/WebServerPortProvider.java
// public interface WebServerPortProvider {
// int getPort();
// }
//
// Path: src/main/java/me/itzg/mccy/types/FreemarkerVariable.java
// public class FreemarkerVariable {
// private String name;
//
// private Object value;
//
// public FreemarkerVariable(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/UUIDGenerator.java
// public interface UUIDGenerator {
// UUID generate();
// }
| import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import me.itzg.mccy.services.WebServerPortProvider;
import me.itzg.mccy.types.FreemarkerVariable;
import me.itzg.mccy.types.UUIDGenerator;
import me.itzg.mccy.types.YamlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.Executors; | @Bean
public Converter<String, URI> uriConverterFactory() {
return new Converter<String, URI>() {
@Override
public URI convert(String s) {
return URI.create(s);
}
};
}
@Bean
@Autowired
public ConfigurableConversionService conversionService(Converter[] converters) {
final ConfigurableConversionService ours = new DefaultConversionService();
for (Converter converter : converters) {
ours.addConverter(converter);
}
return ours;
}
@Bean
public ConcurrentTaskExecutor remoteInvocationExecutor() {
final CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("remoteInv-");
return new ConcurrentTaskExecutor(Executors.newCachedThreadPool(threadFactory));
}
@Bean | // Path: src/main/java/me/itzg/mccy/services/WebServerPortProvider.java
// public interface WebServerPortProvider {
// int getPort();
// }
//
// Path: src/main/java/me/itzg/mccy/types/FreemarkerVariable.java
// public class FreemarkerVariable {
// private String name;
//
// private Object value;
//
// public FreemarkerVariable(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/UUIDGenerator.java
// public interface UUIDGenerator {
// UUID generate();
// }
// Path: src/main/java/me/itzg/mccy/config/GeneralConfig.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import me.itzg.mccy.services.WebServerPortProvider;
import me.itzg.mccy.types.FreemarkerVariable;
import me.itzg.mccy.types.UUIDGenerator;
import me.itzg.mccy.types.YamlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.Executors;
@Bean
public Converter<String, URI> uriConverterFactory() {
return new Converter<String, URI>() {
@Override
public URI convert(String s) {
return URI.create(s);
}
};
}
@Bean
@Autowired
public ConfigurableConversionService conversionService(Converter[] converters) {
final ConfigurableConversionService ours = new DefaultConversionService();
for (Converter converter : converters) {
ours.addConverter(converter);
}
return ours;
}
@Bean
public ConcurrentTaskExecutor remoteInvocationExecutor() {
final CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("remoteInv-");
return new ConcurrentTaskExecutor(Executors.newCachedThreadPool(threadFactory));
}
@Bean | public UUIDGenerator uuidGenerator() { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/config/GeneralConfig.java | // Path: src/main/java/me/itzg/mccy/services/WebServerPortProvider.java
// public interface WebServerPortProvider {
// int getPort();
// }
//
// Path: src/main/java/me/itzg/mccy/types/FreemarkerVariable.java
// public class FreemarkerVariable {
// private String name;
//
// private Object value;
//
// public FreemarkerVariable(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/UUIDGenerator.java
// public interface UUIDGenerator {
// UUID generate();
// }
| import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import me.itzg.mccy.services.WebServerPortProvider;
import me.itzg.mccy.types.FreemarkerVariable;
import me.itzg.mccy.types.UUIDGenerator;
import me.itzg.mccy.types.YamlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.Executors; | return URI.create(s);
}
};
}
@Bean
@Autowired
public ConfigurableConversionService conversionService(Converter[] converters) {
final ConfigurableConversionService ours = new DefaultConversionService();
for (Converter converter : converters) {
ours.addConverter(converter);
}
return ours;
}
@Bean
public ConcurrentTaskExecutor remoteInvocationExecutor() {
final CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("remoteInv-");
return new ConcurrentTaskExecutor(Executors.newCachedThreadPool(threadFactory));
}
@Bean
public UUIDGenerator uuidGenerator() {
return UUID::randomUUID;
}
@Bean | // Path: src/main/java/me/itzg/mccy/services/WebServerPortProvider.java
// public interface WebServerPortProvider {
// int getPort();
// }
//
// Path: src/main/java/me/itzg/mccy/types/FreemarkerVariable.java
// public class FreemarkerVariable {
// private String name;
//
// private Object value;
//
// public FreemarkerVariable(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/UUIDGenerator.java
// public interface UUIDGenerator {
// UUID generate();
// }
// Path: src/main/java/me/itzg/mccy/config/GeneralConfig.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import me.itzg.mccy.services.WebServerPortProvider;
import me.itzg.mccy.types.FreemarkerVariable;
import me.itzg.mccy.types.UUIDGenerator;
import me.itzg.mccy.types.YamlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.Executors;
return URI.create(s);
}
};
}
@Bean
@Autowired
public ConfigurableConversionService conversionService(Converter[] converters) {
final ConfigurableConversionService ours = new DefaultConversionService();
for (Converter converter : converters) {
ours.addConverter(converter);
}
return ours;
}
@Bean
public ConcurrentTaskExecutor remoteInvocationExecutor() {
final CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("remoteInv-");
return new ConcurrentTaskExecutor(Executors.newCachedThreadPool(threadFactory));
}
@Bean
public UUIDGenerator uuidGenerator() {
return UUID::randomUUID;
}
@Bean | public FreemarkerVariable buildProperties(@Value("classpath:build.properties") Resource propsResource) throws IOException { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/impl/DockerClientProxyImpl.java | // Path: src/main/java/me/itzg/mccy/services/DockerClientConsumer.java
// public interface DockerClientConsumer<T> {
// T use(DockerClient dockerClient) throws DockerException, InterruptedException;
// }
| import com.google.common.base.Optional;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerCertificates;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.exceptions.DockerCertificateException;
import com.spotify.docker.client.exceptions.DockerException;
import me.itzg.mccy.config.MccySettings;
import me.itzg.mccy.services.DockerClientConsumer;
import me.itzg.mccy.services.DockerClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.nio.file.Paths; | package me.itzg.mccy.services.impl;
/**
* @author Geoff Bourne
* @since 0.1
*/
@Service @Primary
public class DockerClientProxyImpl implements DockerClientProxy {
private MccySettings mccySettings;
private DockerClient dockerClient;
@Override | // Path: src/main/java/me/itzg/mccy/services/DockerClientConsumer.java
// public interface DockerClientConsumer<T> {
// T use(DockerClient dockerClient) throws DockerException, InterruptedException;
// }
// Path: src/main/java/me/itzg/mccy/services/impl/DockerClientProxyImpl.java
import com.google.common.base.Optional;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerCertificates;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.exceptions.DockerCertificateException;
import com.spotify.docker.client.exceptions.DockerException;
import me.itzg.mccy.config.MccySettings;
import me.itzg.mccy.services.DockerClientConsumer;
import me.itzg.mccy.services.DockerClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.nio.file.Paths;
package me.itzg.mccy.services.impl;
/**
* @author Geoff Bourne
* @since 0.1
*/
@Service @Primary
public class DockerClientProxyImpl implements DockerClientProxy {
private MccySettings mccySettings;
private DockerClient dockerClient;
@Override | public <T> T access(DockerClientConsumer<T> consumer) throws DockerException, InterruptedException { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/model/WorldDescriptor.java | // Path: src/main/java/me/itzg/mccy/types/ComparableVersion.java
// public class ComparableVersion implements Comparable<ComparableVersion> {
// private final List<Object> parts;
//
// private final boolean dotted;
// private final String originalVersion;
//
// public ComparableVersion(String rawVersion) {
// dotted = true;
// originalVersion = rawVersion;
// parts = Stream.of(rawVersion.split("\\."))
// .map(ComparableVersion::promote)
// .collect(Collectors.toList());
// }
//
// public ComparableVersion(String rawVersion, String pattern) {
// dotted = false;
// this.originalVersion = rawVersion;
//
// final Pattern compiled = Pattern.compile(pattern);
// final Matcher matcher = compiled.matcher(rawVersion);
// if (matcher.matches()) {
// final int partCount = matcher.groupCount();
// parts = new ArrayList<>(partCount);
// for (int i = 0; i < partCount; i++) {
// parts.add(matcher.group(i+1));
// }
// }
// else {
// throw new IllegalArgumentException("The given raw version " + rawVersion + " does not match the given pattern, " + pattern);
// }
// }
//
// private ComparableVersion(List<Object> parts) {
// dotted = true;
// originalVersion = null;
// this.parts = parts;
// }
//
// public static ComparableVersion of(String rawVersion) {
// return new ComparableVersion(rawVersion);
// }
//
// public static ComparableVersion of(String rawVersion, String pattern) {
// return new ComparableVersion(rawVersion, pattern);
// }
//
// @Override
// public boolean equals(Object obj) {
// //noinspection SimplifiableIfStatement
// if (obj instanceof ComparableVersion) {
// return Objects.equals(parts, ((ComparableVersion) obj).parts);
// }
// else {
// return false;
// }
// }
//
// @Override
// public int hashCode() {
// return parts.hashCode();
// }
//
// @Override
// public int compareTo(ComparableVersion o) {
//
// final int minLen = Math.min(parts.size(), o.parts.size());
//
// for (int i = 0; i < minLen; i++) {
// final int comparison;
// if (parts.get(i) instanceof Long && o.parts.get(i) instanceof Long) {
// comparison = ((Long) parts.get(i)).compareTo(((Long) o.parts.get(i)));
// }
// else {
// comparison = (parts.get(i).toString()).compareTo((o.parts.get(i).toString()));
// }
//
// if (comparison != 0) {
// return comparison;
// }
// }
//
// // ...shorter parts means lower version, such as 1.8 < 1.8.1
// return Long.compare(parts.size(), o.parts.size());
// }
//
// public boolean le(ComparableVersion o) {
// return this.compareTo(o) <= 0;
// }
// public boolean lt(ComparableVersion o) {
// return this.compareTo(o) < 0;
// }
// public boolean eq(ComparableVersion o) {
// return this.compareTo(o) == 0;
// }
// public boolean gt(ComparableVersion o) {
// return this.compareTo(o) > 0;
// }
// public boolean ge(ComparableVersion o) {
// return this.compareTo(o) >= 0;
// }
//
// /**
// * This performs the same logic as {@link #trim(int)} put directly computes the resulting string. If you're
// * needing a string in the end, then this is slightly more efficient since an intermediate object is not
// * created.
// * @param leadingParts the number of leading parts of the version to include in the returned value
// * @return the trimmed version as a string
// * @see #trim(int)
// */
// public String trimToString(int leadingParts) {
// if (!dotted) {
// throw new IllegalStateException("Non-dotted versions cannot be trimmed");
// }
// return parts.stream()
// .limit(leadingParts)
// .map(Object::toString)
// .collect(Collectors.joining("."));
// }
//
// /**
// * This takes the given version and potentially trims it back to no more than the given number of leading parts.
// * <p>
// * For example, a given version of 1.8.1 with <code>leadingParts</code> of 2 would become 1.8.
// * </p>
// * @param leadingParts the number of leading parts of the version to include in the returned value
// * @return a new {@link ComparableVersion} that is trimmed back to just the number of parts specified by
// * <code>leadingParts</code>
// */
// public ComparableVersion trim(int leadingParts) {
// if (!dotted) {
// throw new IllegalStateException("Non-dotted versions cannot be trimmed");
// }
// return new ComparableVersion(parts.subList(0, leadingParts));
// }
//
// @JsonValue
// @Override
// public String toString() {
// return !dotted ? originalVersion :
// parts.stream()
// .map(Object::toString)
// .collect(Collectors.joining("."));
// }
//
// private static Object promote(String s) {
// try {
// return new Long(s);
// } catch (NumberFormatException e) {
// return s;
// }
// }
// }
| import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import me.itzg.mccy.types.ComparableVersion;
import me.itzg.mccy.types.MinecraftVersionDeserializer;
import java.util.List; | package me.itzg.mccy.model;
/**
* This conveys the essential fields of a Minecraft world/save/level in an abstract way across versions of
* Minecraft and types of Minecraft servers.
*
* @author Geoff Bourne
* @since 0.2
*/
public class WorldDescriptor {
private String name;
| // Path: src/main/java/me/itzg/mccy/types/ComparableVersion.java
// public class ComparableVersion implements Comparable<ComparableVersion> {
// private final List<Object> parts;
//
// private final boolean dotted;
// private final String originalVersion;
//
// public ComparableVersion(String rawVersion) {
// dotted = true;
// originalVersion = rawVersion;
// parts = Stream.of(rawVersion.split("\\."))
// .map(ComparableVersion::promote)
// .collect(Collectors.toList());
// }
//
// public ComparableVersion(String rawVersion, String pattern) {
// dotted = false;
// this.originalVersion = rawVersion;
//
// final Pattern compiled = Pattern.compile(pattern);
// final Matcher matcher = compiled.matcher(rawVersion);
// if (matcher.matches()) {
// final int partCount = matcher.groupCount();
// parts = new ArrayList<>(partCount);
// for (int i = 0; i < partCount; i++) {
// parts.add(matcher.group(i+1));
// }
// }
// else {
// throw new IllegalArgumentException("The given raw version " + rawVersion + " does not match the given pattern, " + pattern);
// }
// }
//
// private ComparableVersion(List<Object> parts) {
// dotted = true;
// originalVersion = null;
// this.parts = parts;
// }
//
// public static ComparableVersion of(String rawVersion) {
// return new ComparableVersion(rawVersion);
// }
//
// public static ComparableVersion of(String rawVersion, String pattern) {
// return new ComparableVersion(rawVersion, pattern);
// }
//
// @Override
// public boolean equals(Object obj) {
// //noinspection SimplifiableIfStatement
// if (obj instanceof ComparableVersion) {
// return Objects.equals(parts, ((ComparableVersion) obj).parts);
// }
// else {
// return false;
// }
// }
//
// @Override
// public int hashCode() {
// return parts.hashCode();
// }
//
// @Override
// public int compareTo(ComparableVersion o) {
//
// final int minLen = Math.min(parts.size(), o.parts.size());
//
// for (int i = 0; i < minLen; i++) {
// final int comparison;
// if (parts.get(i) instanceof Long && o.parts.get(i) instanceof Long) {
// comparison = ((Long) parts.get(i)).compareTo(((Long) o.parts.get(i)));
// }
// else {
// comparison = (parts.get(i).toString()).compareTo((o.parts.get(i).toString()));
// }
//
// if (comparison != 0) {
// return comparison;
// }
// }
//
// // ...shorter parts means lower version, such as 1.8 < 1.8.1
// return Long.compare(parts.size(), o.parts.size());
// }
//
// public boolean le(ComparableVersion o) {
// return this.compareTo(o) <= 0;
// }
// public boolean lt(ComparableVersion o) {
// return this.compareTo(o) < 0;
// }
// public boolean eq(ComparableVersion o) {
// return this.compareTo(o) == 0;
// }
// public boolean gt(ComparableVersion o) {
// return this.compareTo(o) > 0;
// }
// public boolean ge(ComparableVersion o) {
// return this.compareTo(o) >= 0;
// }
//
// /**
// * This performs the same logic as {@link #trim(int)} put directly computes the resulting string. If you're
// * needing a string in the end, then this is slightly more efficient since an intermediate object is not
// * created.
// * @param leadingParts the number of leading parts of the version to include in the returned value
// * @return the trimmed version as a string
// * @see #trim(int)
// */
// public String trimToString(int leadingParts) {
// if (!dotted) {
// throw new IllegalStateException("Non-dotted versions cannot be trimmed");
// }
// return parts.stream()
// .limit(leadingParts)
// .map(Object::toString)
// .collect(Collectors.joining("."));
// }
//
// /**
// * This takes the given version and potentially trims it back to no more than the given number of leading parts.
// * <p>
// * For example, a given version of 1.8.1 with <code>leadingParts</code> of 2 would become 1.8.
// * </p>
// * @param leadingParts the number of leading parts of the version to include in the returned value
// * @return a new {@link ComparableVersion} that is trimmed back to just the number of parts specified by
// * <code>leadingParts</code>
// */
// public ComparableVersion trim(int leadingParts) {
// if (!dotted) {
// throw new IllegalStateException("Non-dotted versions cannot be trimmed");
// }
// return new ComparableVersion(parts.subList(0, leadingParts));
// }
//
// @JsonValue
// @Override
// public String toString() {
// return !dotted ? originalVersion :
// parts.stream()
// .map(Object::toString)
// .collect(Collectors.joining("."));
// }
//
// private static Object promote(String s) {
// try {
// return new Long(s);
// } catch (NumberFormatException e) {
// return s;
// }
// }
// }
// Path: src/main/java/me/itzg/mccy/model/WorldDescriptor.java
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import me.itzg.mccy.types.ComparableVersion;
import me.itzg.mccy.types.MinecraftVersionDeserializer;
import java.util.List;
package me.itzg.mccy.model;
/**
* This conveys the essential fields of a Minecraft world/save/level in an abstract way across versions of
* Minecraft and types of Minecraft servers.
*
* @author Geoff Bourne
* @since 0.2
*/
public class WorldDescriptor {
private String name;
| private ComparableVersion minecraftVersion; |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/controllers/ErrorAdvice.java | // Path: src/main/java/me/itzg/mccy/types/MccyClientException.java
// public abstract class MccyClientException extends MccyException {
// public MccyClientException() {
// }
//
// public MccyClientException(String message) {
// super(message);
// }
//
// public MccyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyClientException(Throwable cause) {
// super(cause);
// }
// }
| import com.spotify.docker.client.exceptions.DockerRequestException;
import me.itzg.mccy.model.FailedRequest;
import me.itzg.mccy.types.MccyClientException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; | package me.itzg.mccy.controllers;
/**
* @author Geoff Bourne
* @since 12/21/2015
*/
@ControllerAdvice(basePackageClasses = ErrorAdvice.class)
public class ErrorAdvice {
@ExceptionHandler
public ResponseEntity<?> handleDockerClientException(DockerRequestException e) {
return ResponseEntity.badRequest()
.body(new FailedRequest(e.getClass(), e.message()));
}
@ExceptionHandler
public ResponseEntity<?> handleDockerClientException(IllegalArgumentException e) {
return ResponseEntity.badRequest()
.body(new FailedRequest(e.getClass(), e.getMessage()));
}
@ExceptionHandler | // Path: src/main/java/me/itzg/mccy/types/MccyClientException.java
// public abstract class MccyClientException extends MccyException {
// public MccyClientException() {
// }
//
// public MccyClientException(String message) {
// super(message);
// }
//
// public MccyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyClientException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/me/itzg/mccy/controllers/ErrorAdvice.java
import com.spotify.docker.client.exceptions.DockerRequestException;
import me.itzg.mccy.model.FailedRequest;
import me.itzg.mccy.types.MccyClientException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
package me.itzg.mccy.controllers;
/**
* @author Geoff Bourne
* @since 12/21/2015
*/
@ControllerAdvice(basePackageClasses = ErrorAdvice.class)
public class ErrorAdvice {
@ExceptionHandler
public ResponseEntity<?> handleDockerClientException(DockerRequestException e) {
return ResponseEntity.badRequest()
.body(new FailedRequest(e.getClass(), e.message()));
}
@ExceptionHandler
public ResponseEntity<?> handleDockerClientException(IllegalArgumentException e) {
return ResponseEntity.badRequest()
.body(new FailedRequest(e.getClass(), e.getMessage()));
}
@ExceptionHandler | public ResponseEntity<?> handleDockerClientException(MccyClientException e) { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/assets/AssetRouterService.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.EnumMap;
import java.util.List;
import java.util.Map; | package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetRouterService {
@Autowired
private AssetObjectService assetObjectService;
@Autowired
private AssetRepo assetRepo;
private Map<AssetCategory, AssetConsumer> consumers;
@Autowired
public void setBeanFactory(ListableBeanFactory beanFactory) {
final Map<String, Object> beans = beanFactory.getBeansWithAnnotation(AssetConsumerSpec.class);
consumers = new EnumMap<>(AssetCategory.class);
beans.values().forEach(b -> {
final AssetConsumerSpec info = b.getClass().getAnnotation(AssetConsumerSpec.class);
consumers.put(info.category(), ((AssetConsumer) b));
});
}
| // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
// Path: src/main/java/me/itzg/mccy/services/assets/AssetRouterService.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetRouterService {
@Autowired
private AssetObjectService assetObjectService;
@Autowired
private AssetRepo assetRepo;
private Map<AssetCategory, AssetConsumer> consumers;
@Autowired
public void setBeanFactory(ListableBeanFactory beanFactory) {
final Map<String, Object> beans = beanFactory.getBeansWithAnnotation(AssetConsumerSpec.class);
consumers = new EnumMap<>(AssetCategory.class);
beans.values().forEach(b -> {
final AssetConsumerSpec info = b.getClass().getAnnotation(AssetConsumerSpec.class);
consumers.put(info.category(), ((AssetConsumer) b));
});
}
| public Asset upload(MultipartFile assetFile, AssetCategory category, Authentication auth) throws IOException, MccyInvalidFormatException { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/impl/ZipMiningServiceImpl.java | // Path: src/main/java/me/itzg/mccy/services/ZipMiningService.java
// public interface ZipMiningService {
// /**
// * Walks a zip file invoking the given handlers and returns a file hash ID.
// * @param rawInputStream the raw input stream of the zip file
// * @param handlers an optional list of handler to be invoked
// * @return the overall file's hash ID
// * @throws IOException
// */
// String interrogate(InputStream rawInputStream,
// Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException;
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyException.java
// public class MccyException extends Throwable {
// public MccyException() {
// }
//
// public MccyException(String message) {
// super(message);
// }
//
// public MccyException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
| import com.google.common.hash.HashFunction;
import com.google.common.hash.HashingInputStream;
import me.itzg.mccy.services.ZipMiningService;
import me.itzg.mccy.types.MccyException;
import me.itzg.mccy.types.ZipMiningHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; | package me.itzg.mccy.services.impl;
/**
* Mines a given input stream, opens it as a zip stream, and looks for one or more files within the zip
* calling a handler for each.
* It also computes the hash of the outer zip file for identification purposes.
*
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class ZipMiningServiceImpl implements ZipMiningService {
private static Logger LOG = LoggerFactory.getLogger(ZipMiningService.class);
@Autowired
private HashFunction fileIdHash;
@Override public String interrogate(InputStream rawInputStream, | // Path: src/main/java/me/itzg/mccy/services/ZipMiningService.java
// public interface ZipMiningService {
// /**
// * Walks a zip file invoking the given handlers and returns a file hash ID.
// * @param rawInputStream the raw input stream of the zip file
// * @param handlers an optional list of handler to be invoked
// * @return the overall file's hash ID
// * @throws IOException
// */
// String interrogate(InputStream rawInputStream,
// Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException;
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyException.java
// public class MccyException extends Throwable {
// public MccyException() {
// }
//
// public MccyException(String message) {
// super(message);
// }
//
// public MccyException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
// Path: src/main/java/me/itzg/mccy/services/impl/ZipMiningServiceImpl.java
import com.google.common.hash.HashFunction;
import com.google.common.hash.HashingInputStream;
import me.itzg.mccy.services.ZipMiningService;
import me.itzg.mccy.types.MccyException;
import me.itzg.mccy.types.ZipMiningHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
package me.itzg.mccy.services.impl;
/**
* Mines a given input stream, opens it as a zip stream, and looks for one or more files within the zip
* calling a handler for each.
* It also computes the hash of the outer zip file for identification purposes.
*
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class ZipMiningServiceImpl implements ZipMiningService {
private static Logger LOG = LoggerFactory.getLogger(ZipMiningService.class);
@Autowired
private HashFunction fileIdHash;
@Override public String interrogate(InputStream rawInputStream, | Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/impl/ZipMiningServiceImpl.java | // Path: src/main/java/me/itzg/mccy/services/ZipMiningService.java
// public interface ZipMiningService {
// /**
// * Walks a zip file invoking the given handlers and returns a file hash ID.
// * @param rawInputStream the raw input stream of the zip file
// * @param handlers an optional list of handler to be invoked
// * @return the overall file's hash ID
// * @throws IOException
// */
// String interrogate(InputStream rawInputStream,
// Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException;
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyException.java
// public class MccyException extends Throwable {
// public MccyException() {
// }
//
// public MccyException(String message) {
// super(message);
// }
//
// public MccyException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
| import com.google.common.hash.HashFunction;
import com.google.common.hash.HashingInputStream;
import me.itzg.mccy.services.ZipMiningService;
import me.itzg.mccy.types.MccyException;
import me.itzg.mccy.types.ZipMiningHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; | package me.itzg.mccy.services.impl;
/**
* Mines a given input stream, opens it as a zip stream, and looks for one or more files within the zip
* calling a handler for each.
* It also computes the hash of the outer zip file for identification purposes.
*
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class ZipMiningServiceImpl implements ZipMiningService {
private static Logger LOG = LoggerFactory.getLogger(ZipMiningService.class);
@Autowired
private HashFunction fileIdHash;
@Override public String interrogate(InputStream rawInputStream,
Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException {
final HashingInputStream hashingInputStream = new HashingInputStream(fileIdHash, rawInputStream);
final ZipInputStream zipInputStream = new ZipInputStream(hashingInputStream);
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
if (handlers != null) {
final String name = zipEntry.getName();
handlers.orElse(Collections.emptyList()).stream()
.filter(e -> e.getPath().matcher(name).matches())
.forEach(e -> {
final ZipMiningHandler handler = e.getHandler();
try {
handler.handleZipContentFile(name, StreamUtils.nonClosing(zipInputStream)); | // Path: src/main/java/me/itzg/mccy/services/ZipMiningService.java
// public interface ZipMiningService {
// /**
// * Walks a zip file invoking the given handlers and returns a file hash ID.
// * @param rawInputStream the raw input stream of the zip file
// * @param handlers an optional list of handler to be invoked
// * @return the overall file's hash ID
// * @throws IOException
// */
// String interrogate(InputStream rawInputStream,
// Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException;
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyException.java
// public class MccyException extends Throwable {
// public MccyException() {
// }
//
// public MccyException(String message) {
// super(message);
// }
//
// public MccyException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MccyException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/ZipMiningHandler.java
// public interface ZipMiningHandler {
// void handleZipContentFile(String path, InputStream in) throws IOException, MccyException;
//
// static ListBuilder listBuilder() {
// return new ListBuilder();
// }
//
// class Entry {
// private Pattern path;
// private ZipMiningHandler handler;
//
// public Entry(Pattern path, ZipMiningHandler handler) {
// this.path = path;
// this.handler = handler;
// }
//
// public Pattern getPath() {
// return path;
// }
//
// public ZipMiningHandler getHandler() {
// return handler;
// }
// }
//
// class ListBuilder {
//
// private List<Entry> entries = new ArrayList<>();
//
// public ListBuilder add(String pathRegex, ZipMiningHandler handler) {
// entries.add(new Entry(Pattern.compile(pathRegex), handler));
// return this;
// }
//
// public Optional<List<Entry>> build() {
// return Optional.of(entries);
// }
//
// }
// }
// Path: src/main/java/me/itzg/mccy/services/impl/ZipMiningServiceImpl.java
import com.google.common.hash.HashFunction;
import com.google.common.hash.HashingInputStream;
import me.itzg.mccy.services.ZipMiningService;
import me.itzg.mccy.types.MccyException;
import me.itzg.mccy.types.ZipMiningHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
package me.itzg.mccy.services.impl;
/**
* Mines a given input stream, opens it as a zip stream, and looks for one or more files within the zip
* calling a handler for each.
* It also computes the hash of the outer zip file for identification purposes.
*
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class ZipMiningServiceImpl implements ZipMiningService {
private static Logger LOG = LoggerFactory.getLogger(ZipMiningService.class);
@Autowired
private HashFunction fileIdHash;
@Override public String interrogate(InputStream rawInputStream,
Optional<List<ZipMiningHandler.Entry>> handlers) throws IOException {
final HashingInputStream hashingInputStream = new HashingInputStream(fileIdHash, rawInputStream);
final ZipInputStream zipInputStream = new ZipInputStream(hashingInputStream);
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
if (handlers != null) {
final String name = zipEntry.getName();
handlers.orElse(Collections.emptyList()).stream()
.filter(e -> e.getPath().matcher(name).matches())
.forEach(e -> {
final ZipMiningHandler handler = e.getHandler();
try {
handler.handleZipContentFile(name, StreamUtils.nonClosing(zipInputStream)); | } catch (IOException | MccyException e1) { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/impl/ServerStatusServiceImpl.java | // Path: src/main/java/me/itzg/mccy/model/ServerStatus.java
// public class ServerStatus {
//
// private String reportedVersion;
// private int onlinePlayers;
// private int maxPlayers;
// private String reportedDescription;
// private byte[] icon;
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("reportedVersion", reportedVersion)
// .add("onlinePlayers", onlinePlayers)
// .add("maxPlayers", maxPlayers)
// .add("reportedDescription", reportedDescription)
// .add("icon", icon != null ? String.format("(%d bytes)", icon.length) : "null")
// .toString();
// }
//
// public void setReportedVersion(String reportedVersion) {
// this.reportedVersion = reportedVersion;
// }
//
// public String getReportedVersion() {
// return reportedVersion;
// }
//
// public void setOnlinePlayers(int onlinePlayers) {
// this.onlinePlayers = onlinePlayers;
// }
//
// public int getOnlinePlayers() {
// return onlinePlayers;
// }
//
// public void setMaxPlayers(int maxPlayers) {
// this.maxPlayers = maxPlayers;
// }
//
// public int getMaxPlayers() {
// return maxPlayers;
// }
//
// public void setReportedDescription(String reportedDescription) {
// this.reportedDescription = reportedDescription;
// }
//
// public String getReportedDescription() {
// return reportedDescription;
// }
//
// public void setIcon(byte[] icon) {
// this.icon = icon;
// }
//
// public byte[] getIcon() {
// return icon;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/ServerStatusService.java
// public interface ServerStatusService {
// ServerStatus queryStatus(String host, int port) throws TimeoutException, MccyUnexpectedServerException;
// }
| import me.itzg.mccy.config.MccySettings;
import me.itzg.mccy.model.ServerStatus;
import me.itzg.mccy.services.ServerStatusService;
import me.itzg.mccy.types.MccyUnexpectedServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spacehq.mc.protocol.MinecraftConstants;
import org.spacehq.mc.protocol.MinecraftProtocol;
import org.spacehq.mc.protocol.data.SubProtocol;
import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler;
import org.spacehq.packetlib.Client;
import org.spacehq.packetlib.Session;
import org.spacehq.packetlib.tcp.TcpSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.Proxy;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; | package me.itzg.mccy.services.impl;
/**
* @author Geoff Bourne
* @since 1/31/2016
*/
@Service
public class ServerStatusServiceImpl implements ServerStatusService {
private static Logger LOG = LoggerFactory.getLogger(ServerStatusServiceImpl.class);
@Autowired
private MccySettings mccySettings;
@Autowired
private ConcurrentTaskExecutor remoteInvocationExecutor;
@Override | // Path: src/main/java/me/itzg/mccy/model/ServerStatus.java
// public class ServerStatus {
//
// private String reportedVersion;
// private int onlinePlayers;
// private int maxPlayers;
// private String reportedDescription;
// private byte[] icon;
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("reportedVersion", reportedVersion)
// .add("onlinePlayers", onlinePlayers)
// .add("maxPlayers", maxPlayers)
// .add("reportedDescription", reportedDescription)
// .add("icon", icon != null ? String.format("(%d bytes)", icon.length) : "null")
// .toString();
// }
//
// public void setReportedVersion(String reportedVersion) {
// this.reportedVersion = reportedVersion;
// }
//
// public String getReportedVersion() {
// return reportedVersion;
// }
//
// public void setOnlinePlayers(int onlinePlayers) {
// this.onlinePlayers = onlinePlayers;
// }
//
// public int getOnlinePlayers() {
// return onlinePlayers;
// }
//
// public void setMaxPlayers(int maxPlayers) {
// this.maxPlayers = maxPlayers;
// }
//
// public int getMaxPlayers() {
// return maxPlayers;
// }
//
// public void setReportedDescription(String reportedDescription) {
// this.reportedDescription = reportedDescription;
// }
//
// public String getReportedDescription() {
// return reportedDescription;
// }
//
// public void setIcon(byte[] icon) {
// this.icon = icon;
// }
//
// public byte[] getIcon() {
// return icon;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/ServerStatusService.java
// public interface ServerStatusService {
// ServerStatus queryStatus(String host, int port) throws TimeoutException, MccyUnexpectedServerException;
// }
// Path: src/main/java/me/itzg/mccy/services/impl/ServerStatusServiceImpl.java
import me.itzg.mccy.config.MccySettings;
import me.itzg.mccy.model.ServerStatus;
import me.itzg.mccy.services.ServerStatusService;
import me.itzg.mccy.types.MccyUnexpectedServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spacehq.mc.protocol.MinecraftConstants;
import org.spacehq.mc.protocol.MinecraftProtocol;
import org.spacehq.mc.protocol.data.SubProtocol;
import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler;
import org.spacehq.packetlib.Client;
import org.spacehq.packetlib.Session;
import org.spacehq.packetlib.tcp.TcpSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.Proxy;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
package me.itzg.mccy.services.impl;
/**
* @author Geoff Bourne
* @since 1/31/2016
*/
@Service
public class ServerStatusServiceImpl implements ServerStatusService {
private static Logger LOG = LoggerFactory.getLogger(ServerStatusServiceImpl.class);
@Autowired
private MccySettings mccySettings;
@Autowired
private ConcurrentTaskExecutor remoteInvocationExecutor;
@Override | public ServerStatus queryStatus(String host, int port) throws TimeoutException, MccyUnexpectedServerException { |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/assets/AssetRouterServiceTest.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.core.Authentication;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.multipart.MultipartFile;
import static org.junit.Assert.*; | package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration
public class AssetRouterServiceTest {
@Configuration
public static class Context {
@Bean
public AssetRouterService assetRouterService() {
return new AssetRouterService();
}
@Bean
public TestConsumer consumer() {
return new TestConsumer();
}
@Bean @Qualifier("mock")
public AssetObjectService assetObjectService() {
return Mockito.mock(AssetObjectService.class);
}
@Bean @Qualifier("mock")
public AssetRepo assetRepo() {
return Mockito.mock(AssetRepo.class);
}
}
@AssetConsumerSpec(category = AssetCategory.WORLD)
public static class TestConsumer implements AssetConsumer {
private MultipartFile captor;
@Override | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
// Path: src/test/java/me/itzg/mccy/services/assets/AssetRouterServiceTest.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.core.Authentication;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.multipart.MultipartFile;
import static org.junit.Assert.*;
package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration
public class AssetRouterServiceTest {
@Configuration
public static class Context {
@Bean
public AssetRouterService assetRouterService() {
return new AssetRouterService();
}
@Bean
public TestConsumer consumer() {
return new TestConsumer();
}
@Bean @Qualifier("mock")
public AssetObjectService assetObjectService() {
return Mockito.mock(AssetObjectService.class);
}
@Bean @Qualifier("mock")
public AssetRepo assetRepo() {
return Mockito.mock(AssetRepo.class);
}
}
@AssetConsumerSpec(category = AssetCategory.WORLD)
public static class TestConsumer implements AssetConsumer {
private MultipartFile captor;
@Override | public Asset consume(MultipartFile assetFile, Authentication auth) { |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/assets/AssetRouterServiceTest.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.core.Authentication;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.multipart.MultipartFile;
import static org.junit.Assert.*; | package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration
public class AssetRouterServiceTest {
@Configuration
public static class Context {
@Bean
public AssetRouterService assetRouterService() {
return new AssetRouterService();
}
@Bean
public TestConsumer consumer() {
return new TestConsumer();
}
@Bean @Qualifier("mock")
public AssetObjectService assetObjectService() {
return Mockito.mock(AssetObjectService.class);
}
@Bean @Qualifier("mock")
public AssetRepo assetRepo() {
return Mockito.mock(AssetRepo.class);
}
}
@AssetConsumerSpec(category = AssetCategory.WORLD)
public static class TestConsumer implements AssetConsumer {
private MultipartFile captor;
@Override
public Asset consume(MultipartFile assetFile, Authentication auth) {
captor = assetFile; | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
// Path: src/test/java/me/itzg/mccy/services/assets/AssetRouterServiceTest.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.types.MccyInvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.core.Authentication;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.multipart.MultipartFile;
import static org.junit.Assert.*;
package me.itzg.mccy.services.assets;
/**
* @author Geoff Bourne
* @since 0.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration
public class AssetRouterServiceTest {
@Configuration
public static class Context {
@Bean
public AssetRouterService assetRouterService() {
return new AssetRouterService();
}
@Bean
public TestConsumer consumer() {
return new TestConsumer();
}
@Bean @Qualifier("mock")
public AssetObjectService assetObjectService() {
return Mockito.mock(AssetObjectService.class);
}
@Bean @Qualifier("mock")
public AssetRepo assetRepo() {
return Mockito.mock(AssetRepo.class);
}
}
@AssetConsumerSpec(category = AssetCategory.WORLD)
public static class TestConsumer implements AssetConsumer {
private MultipartFile captor;
@Override
public Asset consume(MultipartFile assetFile, Authentication auth) {
captor = assetFile; | final WorldAsset worldAsset = new WorldAsset(); |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImpl.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
| import com.google.common.base.Strings;
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.stereotype.Service;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.prefixQuery; | package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetManagementServiceImpl implements AssetManagementService {
@Autowired
private AssetRepo assetRepo;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
// Path: src/main/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImpl.java
import com.google.common.base.Strings;
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.stereotype.Service;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.prefixQuery;
package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetManagementServiceImpl implements AssetManagementService {
@Autowired
private AssetRepo assetRepo;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired | private AssetObjectService assetObjectService; |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImpl.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
| import com.google.common.base.Strings;
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.stereotype.Service;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.prefixQuery; | package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetManagementServiceImpl implements AssetManagementService {
@Autowired
private AssetRepo assetRepo;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
private AssetObjectService assetObjectService;
@Override | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
// Path: src/main/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImpl.java
import com.google.common.base.Strings;
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.stereotype.Service;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.prefixQuery;
package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
@Service
public class AssetManagementServiceImpl implements AssetManagementService {
@Autowired
private AssetRepo assetRepo;
@Autowired
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
private AssetObjectService assetObjectService;
@Override | public void saveMetadata(AssetCategory category, String assetId, Asset asset) { |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/config/SecurityConfig.java | // Path: src/main/java/me/itzg/mccy/controllers/CsrfHeaderFilter.java
// public class CsrfHeaderFilter extends OncePerRequestFilter {
// @Override
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
// FilterChain filterChain) throws ServletException, IOException {
// CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class
// .getName());
// if (csrf != null) {
// Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN");
// String token = csrf.getToken();
// if (cookie==null || token!=null && !token.equals(cookie.getValue())) {
// cookie = new Cookie("XSRF-TOKEN", token);
// cookie.setPath("/");
// response.addCookie(cookie);
// }
// }
// filterChain.doFilter(request, response);
//
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
| import me.itzg.mccy.controllers.CsrfHeaderFilter;
import me.itzg.mccy.types.MccyConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.security.web.util.matcher.RequestMatcher;
import java.util.List; | package me.itzg.mccy.config;
/**
* @author Geoff Bourne
* @since 12/23/2015
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityProperties securityProperties;
@Autowired
private MccySecuritySettings mccySecuritySettings;
@Autowired
private Environment env;
@Override
protected void configure(HttpSecurity http) throws Exception {
for (String p : mccySecuritySettings.getAllowAnonymous().getGet()) {
http
.authorizeRequests()
.antMatchers(HttpMethod.GET, p).permitAll();
}
http
.authorizeRequests()
.antMatchers("/**").hasRole("USER")
.and().formLogin()
.loginPage("/login")
.defaultSuccessUrl("/")
.permitAll()
.and().logout().logoutSuccessUrl("/") | // Path: src/main/java/me/itzg/mccy/controllers/CsrfHeaderFilter.java
// public class CsrfHeaderFilter extends OncePerRequestFilter {
// @Override
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
// FilterChain filterChain) throws ServletException, IOException {
// CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class
// .getName());
// if (csrf != null) {
// Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN");
// String token = csrf.getToken();
// if (cookie==null || token!=null && !token.equals(cookie.getValue())) {
// cookie = new Cookie("XSRF-TOKEN", token);
// cookie.setPath("/");
// response.addCookie(cookie);
// }
// }
// filterChain.doFilter(request, response);
//
// }
// }
//
// Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
// Path: src/main/java/me/itzg/mccy/config/SecurityConfig.java
import me.itzg.mccy.controllers.CsrfHeaderFilter;
import me.itzg.mccy.types.MccyConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.security.web.util.matcher.RequestMatcher;
import java.util.List;
package me.itzg.mccy.config;
/**
* @author Geoff Bourne
* @since 12/23/2015
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityProperties securityProperties;
@Autowired
private MccySecuritySettings mccySecuritySettings;
@Autowired
private Environment env;
@Override
protected void configure(HttpSecurity http) throws Exception {
for (String p : mccySecuritySettings.getAllowAnonymous().getGet()) {
http
.authorizeRequests()
.antMatchers(HttpMethod.GET, p).permitAll();
}
http
.authorizeRequests()
.antMatchers("/**").hasRole("USER")
.and().formLogin()
.loginPage("/login")
.defaultSuccessUrl("/")
.permitAll()
.and().logout().logoutSuccessUrl("/") | .and().addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class) |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/FileStorageServiceTest.java | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
| import me.itzg.mccy.types.MccyConstants;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.Assert.*; | package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 1/6/2016
*/
public class FileStorageServiceTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void testSaveNeedsName() throws Exception {
final FileStorageService service = new FileStorageService();
final Path repoPath = temp.newFolder().toPath();
org.springframework.test.util.ReflectionTestUtils.setField(service, "repoPath", repoPath);
MultipartFile src;
try (InputStream in = new ClassPathResource("SkyGrid.zip").getInputStream()) {
src = new MockMultipartFile("SkyGrid.zip", in);
}
| // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
// Path: src/test/java/me/itzg/mccy/services/FileStorageServiceTest.java
import me.itzg.mccy.types.MccyConstants;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.Assert.*;
package me.itzg.mccy.services;
/**
* @author Geoff Bourne
* @since 1/6/2016
*/
public class FileStorageServiceTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void testSaveNeedsName() throws Exception {
final FileStorageService service = new FileStorageService();
final Path repoPath = temp.newFolder().toPath();
org.springframework.test.util.ReflectionTestUtils.setField(service, "repoPath", repoPath);
MultipartFile src;
try (InputStream in = new ClassPathResource("SkyGrid.zip").getInputStream()) {
src = new MockMultipartFile("SkyGrid.zip", in);
}
| final String filename = service.saveNeedsName(MccyConstants.CATEGORY_WORLDS, ".zip", true, src); |
moorkop/mccy-engine | src/main/java/me/itzg/mccy/model/ContainerSummary.java | // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.spotify.docker.client.messages.Container;
import com.spotify.docker.client.messages.ContainerInfo;
import com.spotify.docker.client.messages.PortBinding;
import me.itzg.mccy.types.MccyConstants;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors; | package me.itzg.mccy.model;
/**
* Provides a summary of very useful info that's buried in the usual container info
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContainerSummary {
private String id;
private String name;
private String hostIp;
private int hostPort;
private Boolean running;
private String status;
private Map<String,String> labels;
| // Path: src/main/java/me/itzg/mccy/types/MccyConstants.java
// public class MccyConstants {
//
//
// public static final String MCCY_LABEL_PREFIX = MccySwarmApplication.class.getPackage().getName();
// public static final String MCCY_LABEL = MCCY_LABEL_PREFIX;
// public static final String MCCY_LABEL_MODPACK_URL = MCCY_LABEL_PREFIX+".modpack-url";
// public static final String MCCY_LABEL_NAME = MCCY_LABEL_PREFIX+".name";
// public static final String MCCY_LABEL_PUBLIC = MCCY_LABEL_PREFIX+".public";
// public static final String MCCY_LABEL_OWNER = MCCY_LABEL_PREFIX+".owner";
//
// public static final int SERVER_CONTAINER_PORT_INT = 25565;
// public static final String SERVER_CONTAINER_PORT = String.valueOf(SERVER_CONTAINER_PORT_INT)+ "/tcp";
// public static final String IP_ADDR_ALL_IF = "0.0.0.0";
//
// public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
//
// public static final String FILE_MOD_INFO = "mod.info";
// public static final String FILE_MCMOD_INFO = "mcmod.info";
// public static final String FILE_PLUGIN_META = "plugin.yml";
//
// public static final String TEMP_PREFIX = "temp-";
//
// public static final String CATEGORY_WORLDS = "worlds";
// public static final String CATEGORY_MODS = "mods";
//
// public static final ComparableVersion[] FORGE_VERSIONS_SQUASHED = new ComparableVersion[]{
// ComparableVersion.of("1.8"),
// ComparableVersion.of("1.8.8")
// };
// public static final int FORGE_VERSIONS_SQUASHED_SIZE = 2;
//
// public static final String EXT_WORLDS = ".zip";
// public static final String EXT_MODS = ".jar";
// public static final String EXT_MOD_PACK = ".zip";
//
// public static final String ENV_ICON = "ICON";
// public static final String ENV_VERSION = "VERSION";
// public static final String ENV_FORGEVERSION = "FORGEVERSION";
// public static final String ENV_WORLD = "WORLD";
// public static final String ENV_MODPACK = "MODPACK";
// public static final String ENV_TYPE = "TYPE";
// public static final String ENV_DIFFICULTY = "DIFFICULTY";
// public static final String ENV_WHITELIST = "WHITELIST";
// public static final String ENV_OPS = "OPS";
// public static final String ENV_SEED = "SEED";
// public static final String ENV_MODE = "MODE";
// public static final String ENV_MOTD = "MOTD";
// public static final String ENV_PVP = "PVP";
// public static final String ENV_LEVEL_TYPE = "LEVEL_TYPE";
// public static final String ENV_GENERATOR_SETTINGS = "GENERATOR_SETTINGS";
// public static final String ENV_LEVEL = "LEVEL";
//
// public static final String LINK_MCCY = "mccy";
// public static final String SNAPSHOT_VER_PATTERN = "(?<nYear>\\d+)w(?<nWeek>\\d+)(?<sRel>[a-z]+)";
//
// public static final String PROFILE_BASIC_AUTH = "basicAuth";
// public static final String PROFILE_DEV = "dev";
// public static final String MF_ATTR_FML_CORE_PLUGIN = "FMLCorePlugin";
// }
// Path: src/main/java/me/itzg/mccy/model/ContainerSummary.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.spotify.docker.client.messages.Container;
import com.spotify.docker.client.messages.ContainerInfo;
import com.spotify.docker.client.messages.PortBinding;
import me.itzg.mccy.types.MccyConstants;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
package me.itzg.mccy.model;
/**
* Provides a summary of very useful info that's buried in the usual container info
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContainerSummary {
private String id;
private String name;
private String hostIp;
private int hostPort;
private Boolean running;
private String status;
private Map<String,String> labels;
| @EnvironmentVariable(MccyConstants.ENV_TYPE) |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmPool.java | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
| import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import net.datenwerke.sandbox.SandboxedCallResult; | /*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox.jvm;
/**
* A pool holding jvms for remote sandboxing. This can be regarded as an
* analougue of a thread pool containing jvms instead of threads.
*
* @author Arno Mittelbach
*
*/
public interface JvmPool {
/**
* Shutdown the jvm pool
*/
void shutdown();
/**
* Returns true if the pool has been shutdown.
* @return
*/
boolean isShutdown();
/**
* Adds a task to be remotely executed.
*
* @param task
* @return
*/ | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmPool.java
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import net.datenwerke.sandbox.SandboxedCallResult;
/*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox.jvm;
/**
* A pool holding jvms for remote sandboxing. This can be regarded as an
* analougue of a thread pool containing jvms instead of threads.
*
* @author Arno Mittelbach
*
*/
public interface JvmPool {
/**
* Shutdown the jvm pool
*/
void shutdown();
/**
* Returns true if the pool has been shutdown.
* @return
*/
boolean isShutdown();
/**
* Adds a task to be remotely executed.
*
* @param task
* @return
*/ | Future<SandboxedCallResult> addTask(JvmTask task); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxLoader.java | // Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
//
// /**
// *
// */
// private static final long serialVersionUID = 6914720697570769005L;
//
// public SandboxRuntimePermission(String name) {
// super(name);
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.security.Permissions;
import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission;
import org.apache.commons.io.IOUtils;
import sun.misc.Resource;
import sun.misc.URLClassPath; | */
public SandboxLoader() {
this(SandboxService.class.getClassLoader());
}
/**
* Instantiates a new SandboxLoader with the given ClassLoader as parent.
* @param parent
*/
public SandboxLoader(ClassLoader parent) {
this(parent, System.getSecurityManager());
}
/**
* Instantiates a new SandboxLoader with the given ClassLoader as parent and using the given security manager.
* @param parent
* @param securityManager
*/
public SandboxLoader(ClassLoader parent, SecurityManager securityManager) {
super(parent);
this.parent = parent;
this.securityManager = (SandboxSecurityManager) securityManager;
}
/**
* Initializes this classloader with the config provided by the SandboxContext
*
* @param context
*/
public void init(SandboxContext context) { | // Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
//
// /**
// *
// */
// private static final long serialVersionUID = 6914720697570769005L;
//
// public SandboxRuntimePermission(String name) {
// super(name);
// }
//
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxLoader.java
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.security.Permissions;
import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission;
import org.apache.commons.io.IOUtils;
import sun.misc.Resource;
import sun.misc.URLClassPath;
*/
public SandboxLoader() {
this(SandboxService.class.getClassLoader());
}
/**
* Instantiates a new SandboxLoader with the given ClassLoader as parent.
* @param parent
*/
public SandboxLoader(ClassLoader parent) {
this(parent, System.getSecurityManager());
}
/**
* Instantiates a new SandboxLoader with the given ClassLoader as parent and using the given security manager.
* @param parent
* @param securityManager
*/
public SandboxLoader(ClassLoader parent, SecurityManager securityManager) {
super(parent);
this.parent = parent;
this.securityManager = (SandboxSecurityManager) securityManager;
}
/**
* Initializes this classloader with the config provided by the SandboxContext
*
* @param context
*/
public void init(SandboxContext context) { | securityManager.checkPermission(new SandboxRuntimePermission("initSandboxLoader")); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
| import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level; |
public void shutdown() {
shutdown = true;
if(! isAlive())
jvm.destroy();
}
public boolean isShutdown() {
return shutdown;
}
public void restartJvm() {
/* kill jvm */
jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task) | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java
import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public void shutdown() {
shutdown = true;
if(! isAlive())
jvm.destroy();
}
public boolean isShutdown() {
return shutdown;
}
public void restartJvm() {
/* kill jvm */
jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task) | result = new SandboxedCallResultImpl(null); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
| import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level; | public boolean isShutdown() {
return shutdown;
}
public void restartJvm() {
/* kill jvm */
jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task)
result = new SandboxedCallResultImpl(null);
else
result = jvm.execute(task);
if(null == result)
result = new SandboxedCallResultImpl(null);
future.setResult(result); | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java
import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public boolean isShutdown() {
return shutdown;
}
public void restartJvm() {
/* kill jvm */
jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task)
result = new SandboxedCallResultImpl(null);
else
result = jvm.execute(task);
if(null == result)
result = new SandboxedCallResultImpl(null);
future.setResult(result); | } catch(JvmServerDeadException e){ |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
| import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level; | jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task)
result = new SandboxedCallResultImpl(null);
else
result = jvm.execute(task);
if(null == result)
result = new SandboxedCallResultImpl(null);
future.setResult(result);
} catch(JvmServerDeadException e){
/* reinsert task */
addTaskFirst(future);
/* restart jvm */
restartJvm(); | // Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResult.java
// public interface SandboxedCallResult<V> extends Serializable {
//
// /**
// * Returns the raw object
// *
// * @return
// */
// Object getRaw();
//
// /**
// * Returns the object in the scope of the classloader that has loaded this instance
// * of {@link SandboxedCallResult}
// *
// * @return
// */
// V get();
//
// /**
// * Returns the object in the scope of the given classloader.
// *
// * @param loader
// * @return
// */
// Object get(ClassLoader loader);
//
// /**
// * Returns the wrapped object in the scope of the classloader that has loaded object obj.
// *
// * @param obj
// * @return
// */
// Object get(Object obj);
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/SandboxedCallResultImpl.java
// public class SandboxedCallResultImpl<V> implements SandboxedCallResult<V> {
//
// /**
// *
// */
// private static final long serialVersionUID = 2221868658839523140L;
//
// /**
// *
// */
// public final Object raw;
//
// public SandboxedCallResultImpl(Object raw) {
// this.raw = raw;
// }
//
// @Override
// public Object getRaw() {
// return raw;
// }
//
// @Override
// public V get(){
// return (V) get(getClass().getClassLoader());
// }
//
// @Override
// public Object get(Object obj){
// return get(obj.getClass().getClassLoader());
// }
//
// @Override
// public Object get(ClassLoader loader){
// return SandboxServiceImpl.getInstance().bridge(raw, null != loader ? loader : ClassLoader.getSystemClassLoader());
// }
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmKilledUnsafeThreadException.java
// public class JvmKilledUnsafeThreadException extends RemoteException {
//
// /**
// *
// */
// private static final long serialVersionUID = -5420515201162587892L;
//
//
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmPoolInstantiationException.java
// public class JvmPoolInstantiationException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 1764438816801841440L;
//
// public JvmPoolInstantiationException(Throwable e) {
// super(e);
// }
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmServerDeadException.java
// public class JvmServerDeadException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8222817806431025268L;
//
//
// public JvmServerDeadException(Throwable e){
// super(e);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmPoolImpl.java
import java.util.logging.Logger;
import net.datenwerke.sandbox.SandboxedCallResult;
import net.datenwerke.sandbox.SandboxedCallResultImpl;
import net.datenwerke.sandbox.jvm.exceptions.JvmKilledUnsafeThreadException;
import net.datenwerke.sandbox.jvm.exceptions.JvmPoolInstantiationException;
import net.datenwerke.sandbox.jvm.exceptions.JvmServerDeadException;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
jvm.destroy();
/* create new jvm */
jvm = jvmConfig.getInstantiator().spawnJvm();
}
@Override
public void run() {
while(! shutdown){
try {
JvmFuture future = workQueue.take();
if(null != future){
try{
JvmTask task = future.getTask();
SandboxedCallResult result;
if(null == task)
result = new SandboxedCallResultImpl(null);
else
result = jvm.execute(task);
if(null == result)
result = new SandboxedCallResultImpl(null);
future.setResult(result);
} catch(JvmServerDeadException e){
/* reinsert task */
addTaskFirst(future);
/* restart jvm */
restartJvm(); | } catch(JvmKilledUnsafeThreadException e){ |
csm/java-sandbox | src/main/java/net/datenwerke/transloader/configure/ReferenceReflecter.java | // Path: src/main/java/net/datenwerke/transloader/reference/DefaultReflecter.java
// public class DefaultReflecter implements ReferenceReflecter {
// private final FieldSetter setter;
//
// public DefaultReflecter() {
// this(NoSetter.INSTANCE);
// }
//
// public DefaultReflecter(FieldSetter setter) {
// Assert.isNotNull(setter);
// this.setter = setter;
// }
//
// private AbstractReflecter reflecterFor(Object subject) {
// return subject.getClass().isArray() ?
// new ElementReflecter(subject) :
// (AbstractReflecter) new FieldReflecter(subject, setter);
// }
//
// public Reference[] reflectReferencesFrom(Object referer) throws IllegalAccessException {
// Assert.isNotNull(referer);
// return reflecterFor(referer).getAllReferences();
// }
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/FieldSetter.java
// public interface FieldSetter {
// void set(Object value, Field field, Object referer) throws Exception;
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/SerializationSetter.java
// public final class SerializationSetter implements FieldSetter {
// private static final Class[] FIELD_IDS_PARAMTYPES = {ObjectStreamField[].class, long[].class, long[].class};
// private static final Class[] PRIMITIVE_FIELDS_PARAMTYPES = {Object.class, long[].class, char[].class, byte[].class};
// private static final Class[] OBJECT_FIELD_PARAMTYPES = {Object.class, long.class, Class.class, Object.class};
// private static final long[] IRRELEVANT = new long[0];
// private final WrapperConverter converter = new WrapperConverter();
// private final Method getFieldIds;
// private final Method setPrimitiveFields;
// private final Method setObjectField;
// private final Field fieldField;
//
// public SerializationSetter() throws NoSuchMethodException, NoSuchFieldException {
// getFieldIds = InvocationDescription.getMethod("getFieldIDs", FIELD_IDS_PARAMTYPES, ObjectStreamClass.class);
// setPrimitiveFields = InvocationDescription.getMethod("setPrimitiveFieldValues", PRIMITIVE_FIELDS_PARAMTYPES, ObjectInputStream.class);
// setObjectField = InvocationDescription.getMethod("setObjectFieldValue", OBJECT_FIELD_PARAMTYPES, ObjectInputStream.class);
// fieldField = getField("field", ObjectStreamField.class);
// }
//
// public void set(Object value, Field field, Object referer) throws IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException {
// Assert.areNotNull(value, field, referer);
//
// boolean primitive = field.getType().isPrimitive();
// ObjectStreamField streamField = getStreamField(field);
// long[] single = new long[1];
//
// if (primitive) {
// fillIdOf(streamField, single, IRRELEVANT);
// setPrimitiveInto(streamField, single, referer, value);
// } else {
// fillIdOf(streamField, IRRELEVANT, single);
// setObjectInto(field, single, referer, value);
// }
// }
//
// private ObjectStreamField getStreamField(Field field) throws IllegalAccessException {
// ObjectStreamField streamField = new ObjectStreamField(field.getName(), field.getType());
// fieldField.set(streamField, field);
// return streamField;
// }
//
// private void fillIdOf(ObjectStreamField streamField, long[] primitiveId, long[] objectId) throws IllegalAccessException, InvocationTargetException {
// ObjectStreamField[] fields = {streamField};
// Object[] params = {fields, primitiveId, objectId};
// invoke(getFieldIds, params);
// }
//
// private void setPrimitiveInto(ObjectStreamField streamField, long[] primitiveIds, Object referer, Object value) throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
// byte[] bytes = converter.asBytes(value);
// char[] typeCodes = {streamField.getTypeCode()};
// Object[] params = {referer, primitiveIds, typeCodes, bytes};
// invoke(setPrimitiveFields, params);
// }
//
// private void setObjectInto(Field field, long[] objectIds, Object referer, Object value) throws IllegalAccessException, InvocationTargetException {
// Object[] params = {referer, destructure(objectIds), field.getType(), value};
// invoke(setObjectField, params);
// }
//
// private static Long destructure(long[] objectId) {
// return new Long(objectId[0]);
// }
//
// private static Object invoke(Method method, Object[] params) throws IllegalAccessException, InvocationTargetException {
// return method.invoke(null, params);
// }
//
// private static Field getField(String name, Class owner) throws NoSuchFieldException {
// Field field = owner.getDeclaredField(name);
// field.setAccessible(true);
// return field;
// }
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/SimpleSetter.java
// public final class SimpleSetter implements FieldSetter {
// public void set(Object value, Field field, Object referer) throws IllegalAccessException {
// Assert.areNotNull(value, field, referer);
// field.set(referer, value);
// }
// }
| import net.datenwerke.transloader.reference.field.SerializationSetter;
import net.datenwerke.transloader.reference.field.SimpleSetter;
import net.datenwerke.transloader.reference.DefaultReflecter;
import net.datenwerke.transloader.reference.field.FieldSetter; | /*
* transloader
*
* This file is part of transloader http://code.google.com/p/transloader/ as part
* of the java-sandbox https://sourceforge.net/p/dw-sandbox/
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.datenwerke.transloader.configure;
/**
* @author jeremywales
*/
public final class ReferenceReflecter {
public static final net.datenwerke.transloader.reference.ReferenceReflecter DEFAULT;
// TODO revisit FieldSetter decision
static { | // Path: src/main/java/net/datenwerke/transloader/reference/DefaultReflecter.java
// public class DefaultReflecter implements ReferenceReflecter {
// private final FieldSetter setter;
//
// public DefaultReflecter() {
// this(NoSetter.INSTANCE);
// }
//
// public DefaultReflecter(FieldSetter setter) {
// Assert.isNotNull(setter);
// this.setter = setter;
// }
//
// private AbstractReflecter reflecterFor(Object subject) {
// return subject.getClass().isArray() ?
// new ElementReflecter(subject) :
// (AbstractReflecter) new FieldReflecter(subject, setter);
// }
//
// public Reference[] reflectReferencesFrom(Object referer) throws IllegalAccessException {
// Assert.isNotNull(referer);
// return reflecterFor(referer).getAllReferences();
// }
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/FieldSetter.java
// public interface FieldSetter {
// void set(Object value, Field field, Object referer) throws Exception;
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/SerializationSetter.java
// public final class SerializationSetter implements FieldSetter {
// private static final Class[] FIELD_IDS_PARAMTYPES = {ObjectStreamField[].class, long[].class, long[].class};
// private static final Class[] PRIMITIVE_FIELDS_PARAMTYPES = {Object.class, long[].class, char[].class, byte[].class};
// private static final Class[] OBJECT_FIELD_PARAMTYPES = {Object.class, long.class, Class.class, Object.class};
// private static final long[] IRRELEVANT = new long[0];
// private final WrapperConverter converter = new WrapperConverter();
// private final Method getFieldIds;
// private final Method setPrimitiveFields;
// private final Method setObjectField;
// private final Field fieldField;
//
// public SerializationSetter() throws NoSuchMethodException, NoSuchFieldException {
// getFieldIds = InvocationDescription.getMethod("getFieldIDs", FIELD_IDS_PARAMTYPES, ObjectStreamClass.class);
// setPrimitiveFields = InvocationDescription.getMethod("setPrimitiveFieldValues", PRIMITIVE_FIELDS_PARAMTYPES, ObjectInputStream.class);
// setObjectField = InvocationDescription.getMethod("setObjectFieldValue", OBJECT_FIELD_PARAMTYPES, ObjectInputStream.class);
// fieldField = getField("field", ObjectStreamField.class);
// }
//
// public void set(Object value, Field field, Object referer) throws IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException {
// Assert.areNotNull(value, field, referer);
//
// boolean primitive = field.getType().isPrimitive();
// ObjectStreamField streamField = getStreamField(field);
// long[] single = new long[1];
//
// if (primitive) {
// fillIdOf(streamField, single, IRRELEVANT);
// setPrimitiveInto(streamField, single, referer, value);
// } else {
// fillIdOf(streamField, IRRELEVANT, single);
// setObjectInto(field, single, referer, value);
// }
// }
//
// private ObjectStreamField getStreamField(Field field) throws IllegalAccessException {
// ObjectStreamField streamField = new ObjectStreamField(field.getName(), field.getType());
// fieldField.set(streamField, field);
// return streamField;
// }
//
// private void fillIdOf(ObjectStreamField streamField, long[] primitiveId, long[] objectId) throws IllegalAccessException, InvocationTargetException {
// ObjectStreamField[] fields = {streamField};
// Object[] params = {fields, primitiveId, objectId};
// invoke(getFieldIds, params);
// }
//
// private void setPrimitiveInto(ObjectStreamField streamField, long[] primitiveIds, Object referer, Object value) throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
// byte[] bytes = converter.asBytes(value);
// char[] typeCodes = {streamField.getTypeCode()};
// Object[] params = {referer, primitiveIds, typeCodes, bytes};
// invoke(setPrimitiveFields, params);
// }
//
// private void setObjectInto(Field field, long[] objectIds, Object referer, Object value) throws IllegalAccessException, InvocationTargetException {
// Object[] params = {referer, destructure(objectIds), field.getType(), value};
// invoke(setObjectField, params);
// }
//
// private static Long destructure(long[] objectId) {
// return new Long(objectId[0]);
// }
//
// private static Object invoke(Method method, Object[] params) throws IllegalAccessException, InvocationTargetException {
// return method.invoke(null, params);
// }
//
// private static Field getField(String name, Class owner) throws NoSuchFieldException {
// Field field = owner.getDeclaredField(name);
// field.setAccessible(true);
// return field;
// }
// }
//
// Path: src/main/java/net/datenwerke/transloader/reference/field/SimpleSetter.java
// public final class SimpleSetter implements FieldSetter {
// public void set(Object value, Field field, Object referer) throws IllegalAccessException {
// Assert.areNotNull(value, field, referer);
// field.set(referer, value);
// }
// }
// Path: src/main/java/net/datenwerke/transloader/configure/ReferenceReflecter.java
import net.datenwerke.transloader.reference.field.SerializationSetter;
import net.datenwerke.transloader.reference.field.SimpleSetter;
import net.datenwerke.transloader.reference.DefaultReflecter;
import net.datenwerke.transloader.reference.field.FieldSetter;
/*
* transloader
*
* This file is part of transloader http://code.google.com/p/transloader/ as part
* of the java-sandbox https://sourceforge.net/p/dw-sandbox/
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.datenwerke.transloader.configure;
/**
* @author jeremywales
*/
public final class ReferenceReflecter {
public static final net.datenwerke.transloader.reference.ReferenceReflecter DEFAULT;
// TODO revisit FieldSetter decision
static { | FieldSetter setter; |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmInstantiatorImpl.java | // Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmInstantiatonException.java
// public class JvmInstantiatonException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 4366122700205470989L;
//
// public JvmInstantiatonException(){
// super();
// }
//
// public JvmInstantiatonException(Throwable e) {
// super(e);
// }
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/server/SandboxJvmServer.java
// public class SandboxJvmServer extends UnicastRemoteObject implements SandboxRemoteServer {
//
// /**
// *
// */
// private static final long serialVersionUID = 3625471545043099538L;
//
// private final Logger logger = Logger.getLogger(getClass().getName());
//
// private final String name;
//
// private SandboxContext context;
//
// private SandboxLoader classloader;
//
// public SandboxJvmServer(String namePrefix) throws RemoteException {
// this.name = NAME + namePrefix;
//
// logger.log(Level.INFO, "started sandbox server: " + getName());
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public boolean isAlive() {
// return true;
// }
//
// @Override
// public SandboxedCallResult execute(JvmTask task) throws RemoteException {
// try {
// return task.call();
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// } catch (Exception e) {
// throw new RemoteException(e.getMessage(), e);
// }
// }
//
// @Override
// public void destroy() {
// System.exit(0);
// }
//
// @Override
// public void init(SandboxContext context) throws RemoteException {
// if(null != this.context)
// throw new JvmInitializedTwiceException();
//
// this.context = context;
// this.classloader = SandboxServiceImpl.getInstance().initClassLoader(context);
// }
//
// @Override
// public void reset() throws RemoteException {
// this.context = null;
// this.classloader = null;
// }
//
// @Override
// public SandboxedCallResult runInContext(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runInContext(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public SandboxedCallResult runSandboxed(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runSandboxed(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public void registerContext(String name, SandboxContext context)
// throws RemoteException {
// SandboxServiceImpl.getInstance().registerContext(name, context);
// }
//
// public static void main(String[] args) {
// if(args.length < 2)
// System.exit(-1);
//
// String namePrefix = args[0];
// String host = "localhost";
// int port = Integer.parseInt(args[1]);
// try {
// SandboxJvmServer server = new SandboxJvmServer(namePrefix);
//
// new SandboxRemoteServiceImpl();
//
// LocateRegistry.createRegistry(port);
// Naming.rebind("//" + host + ":" + port + "/" + server.getName(), server);
// } catch (Exception e) {
// e.printStackTrace();
// System.exit(-1);
// }
// }
//
//
//
//
// }
| import net.datenwerke.sandbox.jvm.server.SandboxJvmServer;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.datenwerke.sandbox.jvm.exceptions.JvmInstantiatonException; | public JvmInstantiatorImpl(String jvmArgs){
this(10000, 10200, jvmArgs);
}
public JvmInstantiatorImpl(int minPortNumber, int maxPortNumber, String jvmArgs) {
this.currentPortNumber = minPortNumber;
this.minPortNumber = minPortNumber;
this.maxPortNumber = maxPortNumber;
this.jvmArgs = jvmArgs;
}
/*
* (non-Javadoc)
* @see net.datenwerke.sandbox.jvm.JvmInstantiator#spawnJvm()
*/
@Override
public Jvm spawnJvm() {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home")
+ separator + "bin" + separator + "java";
String namePrefix = initNamePrefix();
int portNumber = initPortNumber(0);
ProcessBuilder processBuilder = null;
if(null != jvmArgs){
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, jvmArgs, | // Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmInstantiatonException.java
// public class JvmInstantiatonException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 4366122700205470989L;
//
// public JvmInstantiatonException(){
// super();
// }
//
// public JvmInstantiatonException(Throwable e) {
// super(e);
// }
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/server/SandboxJvmServer.java
// public class SandboxJvmServer extends UnicastRemoteObject implements SandboxRemoteServer {
//
// /**
// *
// */
// private static final long serialVersionUID = 3625471545043099538L;
//
// private final Logger logger = Logger.getLogger(getClass().getName());
//
// private final String name;
//
// private SandboxContext context;
//
// private SandboxLoader classloader;
//
// public SandboxJvmServer(String namePrefix) throws RemoteException {
// this.name = NAME + namePrefix;
//
// logger.log(Level.INFO, "started sandbox server: " + getName());
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public boolean isAlive() {
// return true;
// }
//
// @Override
// public SandboxedCallResult execute(JvmTask task) throws RemoteException {
// try {
// return task.call();
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// } catch (Exception e) {
// throw new RemoteException(e.getMessage(), e);
// }
// }
//
// @Override
// public void destroy() {
// System.exit(0);
// }
//
// @Override
// public void init(SandboxContext context) throws RemoteException {
// if(null != this.context)
// throw new JvmInitializedTwiceException();
//
// this.context = context;
// this.classloader = SandboxServiceImpl.getInstance().initClassLoader(context);
// }
//
// @Override
// public void reset() throws RemoteException {
// this.context = null;
// this.classloader = null;
// }
//
// @Override
// public SandboxedCallResult runInContext(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runInContext(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public SandboxedCallResult runSandboxed(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runSandboxed(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public void registerContext(String name, SandboxContext context)
// throws RemoteException {
// SandboxServiceImpl.getInstance().registerContext(name, context);
// }
//
// public static void main(String[] args) {
// if(args.length < 2)
// System.exit(-1);
//
// String namePrefix = args[0];
// String host = "localhost";
// int port = Integer.parseInt(args[1]);
// try {
// SandboxJvmServer server = new SandboxJvmServer(namePrefix);
//
// new SandboxRemoteServiceImpl();
//
// LocateRegistry.createRegistry(port);
// Naming.rebind("//" + host + ":" + port + "/" + server.getName(), server);
// } catch (Exception e) {
// e.printStackTrace();
// System.exit(-1);
// }
// }
//
//
//
//
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmInstantiatorImpl.java
import net.datenwerke.sandbox.jvm.server.SandboxJvmServer;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.datenwerke.sandbox.jvm.exceptions.JvmInstantiatonException;
public JvmInstantiatorImpl(String jvmArgs){
this(10000, 10200, jvmArgs);
}
public JvmInstantiatorImpl(int minPortNumber, int maxPortNumber, String jvmArgs) {
this.currentPortNumber = minPortNumber;
this.minPortNumber = minPortNumber;
this.maxPortNumber = maxPortNumber;
this.jvmArgs = jvmArgs;
}
/*
* (non-Javadoc)
* @see net.datenwerke.sandbox.jvm.JvmInstantiator#spawnJvm()
*/
@Override
public Jvm spawnJvm() {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home")
+ separator + "bin" + separator + "java";
String namePrefix = initNamePrefix();
int portNumber = initPortNumber(0);
ProcessBuilder processBuilder = null;
if(null != jvmArgs){
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, jvmArgs, | SandboxJvmServer.class.getName(), |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/jvm/JvmInstantiatorImpl.java | // Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmInstantiatonException.java
// public class JvmInstantiatonException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 4366122700205470989L;
//
// public JvmInstantiatonException(){
// super();
// }
//
// public JvmInstantiatonException(Throwable e) {
// super(e);
// }
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/server/SandboxJvmServer.java
// public class SandboxJvmServer extends UnicastRemoteObject implements SandboxRemoteServer {
//
// /**
// *
// */
// private static final long serialVersionUID = 3625471545043099538L;
//
// private final Logger logger = Logger.getLogger(getClass().getName());
//
// private final String name;
//
// private SandboxContext context;
//
// private SandboxLoader classloader;
//
// public SandboxJvmServer(String namePrefix) throws RemoteException {
// this.name = NAME + namePrefix;
//
// logger.log(Level.INFO, "started sandbox server: " + getName());
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public boolean isAlive() {
// return true;
// }
//
// @Override
// public SandboxedCallResult execute(JvmTask task) throws RemoteException {
// try {
// return task.call();
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// } catch (Exception e) {
// throw new RemoteException(e.getMessage(), e);
// }
// }
//
// @Override
// public void destroy() {
// System.exit(0);
// }
//
// @Override
// public void init(SandboxContext context) throws RemoteException {
// if(null != this.context)
// throw new JvmInitializedTwiceException();
//
// this.context = context;
// this.classloader = SandboxServiceImpl.getInstance().initClassLoader(context);
// }
//
// @Override
// public void reset() throws RemoteException {
// this.context = null;
// this.classloader = null;
// }
//
// @Override
// public SandboxedCallResult runInContext(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runInContext(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public SandboxedCallResult runSandboxed(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runSandboxed(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public void registerContext(String name, SandboxContext context)
// throws RemoteException {
// SandboxServiceImpl.getInstance().registerContext(name, context);
// }
//
// public static void main(String[] args) {
// if(args.length < 2)
// System.exit(-1);
//
// String namePrefix = args[0];
// String host = "localhost";
// int port = Integer.parseInt(args[1]);
// try {
// SandboxJvmServer server = new SandboxJvmServer(namePrefix);
//
// new SandboxRemoteServiceImpl();
//
// LocateRegistry.createRegistry(port);
// Naming.rebind("//" + host + ":" + port + "/" + server.getName(), server);
// } catch (Exception e) {
// e.printStackTrace();
// System.exit(-1);
// }
// }
//
//
//
//
// }
| import net.datenwerke.sandbox.jvm.server.SandboxJvmServer;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.datenwerke.sandbox.jvm.exceptions.JvmInstantiatonException; | public Jvm spawnJvm() {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home")
+ separator + "bin" + separator + "java";
String namePrefix = initNamePrefix();
int portNumber = initPortNumber(0);
ProcessBuilder processBuilder = null;
if(null != jvmArgs){
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, jvmArgs,
SandboxJvmServer.class.getName(),
namePrefix, String.valueOf(portNumber));
} else {
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, SandboxJvmServer.class.getName(),
namePrefix, String.valueOf(portNumber));
}
processBuilder.redirectError(Redirect.INHERIT);
processBuilder.redirectOutput(Redirect.INHERIT);
try {
Process process = processBuilder.start();
return new JvmImpl(namePrefix, portNumber, process);
} catch (IOException e) { | // Path: src/main/java/net/datenwerke/sandbox/jvm/exceptions/JvmInstantiatonException.java
// public class JvmInstantiatonException extends RuntimeException {
//
// /**
// *
// */
// private static final long serialVersionUID = 4366122700205470989L;
//
// public JvmInstantiatonException(){
// super();
// }
//
// public JvmInstantiatonException(Throwable e) {
// super(e);
// }
//
// }
//
// Path: src/main/java/net/datenwerke/sandbox/jvm/server/SandboxJvmServer.java
// public class SandboxJvmServer extends UnicastRemoteObject implements SandboxRemoteServer {
//
// /**
// *
// */
// private static final long serialVersionUID = 3625471545043099538L;
//
// private final Logger logger = Logger.getLogger(getClass().getName());
//
// private final String name;
//
// private SandboxContext context;
//
// private SandboxLoader classloader;
//
// public SandboxJvmServer(String namePrefix) throws RemoteException {
// this.name = NAME + namePrefix;
//
// logger.log(Level.INFO, "started sandbox server: " + getName());
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public boolean isAlive() {
// return true;
// }
//
// @Override
// public SandboxedCallResult execute(JvmTask task) throws RemoteException {
// try {
// return task.call();
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// } catch (Exception e) {
// throw new RemoteException(e.getMessage(), e);
// }
// }
//
// @Override
// public void destroy() {
// System.exit(0);
// }
//
// @Override
// public void init(SandboxContext context) throws RemoteException {
// if(null != this.context)
// throw new JvmInitializedTwiceException();
//
// this.context = context;
// this.classloader = SandboxServiceImpl.getInstance().initClassLoader(context);
// }
//
// @Override
// public void reset() throws RemoteException {
// this.context = null;
// this.classloader = null;
// }
//
// @Override
// public SandboxedCallResult runInContext(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runInContext(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public SandboxedCallResult runSandboxed(
// Class<? extends SandboxedEnvironment> call, Object... args) throws RemoteException {
// if(null == context)
// throw new JvmNotInitializedException();
//
// try{
// return SandboxServiceImpl.getInstance().runSandboxed(call, context, classloader, args);
// } catch(JvmKilledUnsafeThreadRuntimeException e){
// throw new JvmKilledUnsafeThreadException();
// }
// }
//
// @Override
// public void registerContext(String name, SandboxContext context)
// throws RemoteException {
// SandboxServiceImpl.getInstance().registerContext(name, context);
// }
//
// public static void main(String[] args) {
// if(args.length < 2)
// System.exit(-1);
//
// String namePrefix = args[0];
// String host = "localhost";
// int port = Integer.parseInt(args[1]);
// try {
// SandboxJvmServer server = new SandboxJvmServer(namePrefix);
//
// new SandboxRemoteServiceImpl();
//
// LocateRegistry.createRegistry(port);
// Naming.rebind("//" + host + ":" + port + "/" + server.getName(), server);
// } catch (Exception e) {
// e.printStackTrace();
// System.exit(-1);
// }
// }
//
//
//
//
// }
// Path: src/main/java/net/datenwerke/sandbox/jvm/JvmInstantiatorImpl.java
import net.datenwerke.sandbox.jvm.server.SandboxJvmServer;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.datenwerke.sandbox.jvm.exceptions.JvmInstantiatonException;
public Jvm spawnJvm() {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home")
+ separator + "bin" + separator + "java";
String namePrefix = initNamePrefix();
int portNumber = initPortNumber(0);
ProcessBuilder processBuilder = null;
if(null != jvmArgs){
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, jvmArgs,
SandboxJvmServer.class.getName(),
namePrefix, String.valueOf(portNumber));
} else {
processBuilder =
new ProcessBuilder(path, "-cp",
classpath, SandboxJvmServer.class.getName(),
namePrefix, String.valueOf(portNumber));
}
processBuilder.redirectError(Redirect.INHERIT);
processBuilder.redirectOutput(Redirect.INHERIT);
try {
Process process = processBuilder.start();
return new JvmImpl(namePrefix, portNumber, process);
} catch (IOException e) { | throw new JvmInstantiatonException(e); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxedThread.java | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
| import java.lang.reflect.Method;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException; | started = true;
try{
if(runInContext)
result = method.invoke(instance);
else {
String pw = service.restrict(context);
try{
result = method.invoke(instance);
} finally {
service.releaseRestriction(pw);
}
}
success = true;
} catch (Exception e) {
this.exception = e;
}
}
public Object getResult() {
return result;
}
public boolean isSuccess() {
return success;
}
public Exception getException() {
return exception;
}
| // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxedThread.java
import java.lang.reflect.Method;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
started = true;
try{
if(runInContext)
result = method.invoke(instance);
else {
String pw = service.restrict(context);
try{
result = method.invoke(instance);
} finally {
service.releaseRestriction(pw);
}
}
success = true;
} catch (Exception e) {
this.exception = e;
}
}
public Object getResult() {
return result;
}
public boolean isSuccess() {
return success;
}
public Exception getException() {
return exception;
}
| public void setKilled(boolean safe, SandboxedTaskKilledException exception) { |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxSecurityManager.java | // Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
//
// /**
// *
// */
// private static final long serialVersionUID = 6914720697570769005L;
//
// public SandboxRuntimePermission(String name) {
// super(name);
// }
//
// }
| import java.security.AccessControlException;
import java.security.Permission;
import java.util.Arrays;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission; |
Class stack[] = getClassContext();
if(! rs.checkPackageAccess(pkg, stack)){
if(debug)
rs.debugDeniedPackageAccess(pkg, stack);
throw new AccessControlException("No package access allowed for package: " + pkg);
}
} finally {
setInCheck(false);
}
}
}
Class[] getCurrentClassContext() {
if(isRestricted())
throw new AccessControlException("no classContext during sandbox");
return super.getClassContext();
}
public void checkPackageDefinition(String pkg) {
if(codesourceSecurityChecks)
super.checkPackageDefinition(pkg);
if(isRestricted())
throw new AccessControlException("no package definition: " + pkg);
}
void setCodesourceSecurityChecks(boolean enable) { | // Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
//
// /**
// *
// */
// private static final long serialVersionUID = 6914720697570769005L;
//
// public SandboxRuntimePermission(String name) {
// super(name);
// }
//
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxSecurityManager.java
import java.security.AccessControlException;
import java.security.Permission;
import java.util.Arrays;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission;
Class stack[] = getClassContext();
if(! rs.checkPackageAccess(pkg, stack)){
if(debug)
rs.debugDeniedPackageAccess(pkg, stack);
throw new AccessControlException("No package access allowed for package: " + pkg);
}
} finally {
setInCheck(false);
}
}
}
Class[] getCurrentClassContext() {
if(isRestricted())
throw new AccessControlException("no classContext during sandbox");
return super.getClassContext();
}
public void checkPackageDefinition(String pkg) {
if(codesourceSecurityChecks)
super.checkPackageDefinition(pkg);
if(isRestricted())
throw new AccessControlException("no package definition: " + pkg);
}
void setCodesourceSecurityChecks(boolean enable) { | checkPermission(new SandboxRuntimePermission("enableCodesourceSecurity")); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxCleanupService.java | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
| import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
import com.google.inject.ImplementedBy; | /*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox;
/**
* Service to perform killing of bad threads.
*
* @author Arno Mittelbach
*
*/
@ImplementedBy(SandboxCleanupServiceImpl.class)
public interface SandboxCleanupService {
/**
* Takes care of thread elimination.
*
* @param monitor The monitor object monitoring the to be killed thread.
* @param exception
* @return
*/ | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxCleanupService.java
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
import com.google.inject.ImplementedBy;
/*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox;
/**
* Service to perform killing of bad threads.
*
* @author Arno Mittelbach
*
*/
@ImplementedBy(SandboxCleanupServiceImpl.class)
public interface SandboxCleanupService {
/**
* Takes care of thread elimination.
*
* @param monitor The monitor object monitoring the to be killed thread.
* @param exception
* @return
*/ | public BadKillInfo kill(SandboxMonitoredThread monitor, SandboxedTaskKilledException exception); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxMonitorDaemon.java | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
| import java.util.logging.Logger;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level; | continue;
if(! monitor.isAlive()){
iterator.remove();
continue;
}
testStack(monitor);
testRuntime(monitor);
}
try {
Thread.sleep(checkInterval);
} catch (InterruptedException e) {
logger.log(Level.WARNING, "SandboxMonitor was interrupted", e);
}
} catch(Exception e){
logger.log(Level.SEVERE, "Exception SandboxMonitorDaemon: ", e);
}
}
}
protected void testRuntime(SandboxMonitoredThread monitor) {
SandboxContext context = monitor.getContext();
if(0 > context.getMaximumRunTime() || null == context.getMaximumRunTimeUnit())
return;
if(context.getMaximumRuntimeMode() == SandboxContext.RuntimeMode.CPU_TIME){
long cpuTime = threadBean.getThreadCpuTime(monitor.getMonitoredThread().getId());
if(cpuTime > TimeUnit.NANOSECONDS.convert(context.getMaximumRunTime(), context.getMaximumRunTimeUnit())) | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxMonitorDaemon.java
import java.util.logging.Logger;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
continue;
if(! monitor.isAlive()){
iterator.remove();
continue;
}
testStack(monitor);
testRuntime(monitor);
}
try {
Thread.sleep(checkInterval);
} catch (InterruptedException e) {
logger.log(Level.WARNING, "SandboxMonitor was interrupted", e);
}
} catch(Exception e){
logger.log(Level.SEVERE, "Exception SandboxMonitorDaemon: ", e);
}
}
}
protected void testRuntime(SandboxMonitoredThread monitor) {
SandboxContext context = monitor.getContext();
if(0 > context.getMaximumRunTime() || null == context.getMaximumRunTimeUnit())
return;
if(context.getMaximumRuntimeMode() == SandboxContext.RuntimeMode.CPU_TIME){
long cpuTime = threadBean.getThreadCpuTime(monitor.getMonitoredThread().getId());
if(cpuTime > TimeUnit.NANOSECONDS.convert(context.getMaximumRunTime(), context.getMaximumRunTimeUnit())) | suspend(monitor, new SandboxedTaskKilledException("killed task as maxmimum runtime was exceeded")); |
csm/java-sandbox | src/main/java/net/datenwerke/sandbox/SandboxCleanupServiceImpl.java | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
| import java.lang.management.LockInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.MonitorInfo;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException; | /*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox;
/**
* Default implementation of {@link SandboxCleanupService}.
*
* @author Arno Mittelbach
*
*/
public class SandboxCleanupServiceImpl implements SandboxCleanupService{
private ThreadMXBean threadBean;
public SandboxCleanupServiceImpl(){
this.threadBean = ManagementFactory.getThreadMXBean();
}
/*
* (non-Javadoc)
* @see net.datenwerke.sandbox.SandboxCleanupService#kill(net.datenwerke.sandbox.SandboxMonitoredThread, net.datenwerke.sandbox.jvm.exceptions.SandboxTaskKilledException)
*/
@Override | // Path: src/main/java/net/datenwerke/sandbox/exception/SandboxedTaskKilledException.java
// public class SandboxedTaskKilledException extends SandboxException {
//
// /**
// *
// */
// private static final long serialVersionUID = 3308981843831471410L;
//
// public SandboxedTaskKilledException(String msg) {
// super(msg);
// }
// }
// Path: src/main/java/net/datenwerke/sandbox/SandboxCleanupServiceImpl.java
import java.lang.management.LockInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.MonitorInfo;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import net.datenwerke.sandbox.exception.SandboxedTaskKilledException;
/*
* java-sandbox
* Copyright (c) 2012 datenwerke Jan Albrecht
* http://www.datenwerke.net
*
* This file is part of the java-sandbox: https://sourceforge.net/p/dw-sandbox/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package net.datenwerke.sandbox;
/**
* Default implementation of {@link SandboxCleanupService}.
*
* @author Arno Mittelbach
*
*/
public class SandboxCleanupServiceImpl implements SandboxCleanupService{
private ThreadMXBean threadBean;
public SandboxCleanupServiceImpl(){
this.threadBean = ManagementFactory.getThreadMXBean();
}
/*
* (non-Javadoc)
* @see net.datenwerke.sandbox.SandboxCleanupService#kill(net.datenwerke.sandbox.SandboxMonitoredThread, net.datenwerke.sandbox.jvm.exceptions.SandboxTaskKilledException)
*/
@Override | public BadKillInfo kill(SandboxMonitoredThread monitor, SandboxedTaskKilledException exception) { |
LilyPad/Bukkit-Connect | src/main/java/lilypad/bukkit/connect/login/LoginListenerProxy.java | // Path: src/main/java/lilypad/bukkit/connect/util/JavassistUtil.java
// public class JavassistUtil {
//
// public static ClassPool getClassPool() {
// ClassPool classPool = ClassPool.getDefault();
// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// if (classLoader instanceof URLClassLoader) {
// URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
// for (URL url : urlClassLoader.getURLs()) {
// try {
// // assume files
// String path = Paths.get(url.toURI()).toString();
// classPool.appendClassPath(path);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
// }
// return classPool;
// }
//
// }
| import com.mojang.authlib.GameProfile;
import javassist.*;
import javassist.bytecode.*;
import lilypad.bukkit.connect.util.JavassistUtil;
import java.lang.reflect.Field; | if (field.getType() == fieldType) {
field.setAccessible(true);
return field;
}
}
return null;
}
private static Class create(Object networkManager) throws Exception {
Object originalLoginListener = null;
packetListenerField = null;
Field[] networkManagerFields = networkManager.getClass().getDeclaredFields();
for (Field field : networkManagerFields) {
if (field.getType().getSimpleName().equals("PacketListener")) {
field.setAccessible(true);
packetListenerField = field;
originalLoginListener = field.get(networkManager);
break;
}
}
if (originalLoginListener == null) {
throw new Exception("Could not find LoginListener in NetworkManager!");
}
if (!originalLoginListener.getClass().getSimpleName().equals("LoginListener")) {
throw new Exception("Could not find LoginListener in NetworkManager, found instead " + originalLoginListener.getClass().getSimpleName() + "!");
}
loginListenerClass = originalLoginListener.getClass();
profileField = findFieldOfType(loginListenerClass, GameProfile.class);
| // Path: src/main/java/lilypad/bukkit/connect/util/JavassistUtil.java
// public class JavassistUtil {
//
// public static ClassPool getClassPool() {
// ClassPool classPool = ClassPool.getDefault();
// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// if (classLoader instanceof URLClassLoader) {
// URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
// for (URL url : urlClassLoader.getURLs()) {
// try {
// // assume files
// String path = Paths.get(url.toURI()).toString();
// classPool.appendClassPath(path);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
// }
// return classPool;
// }
//
// }
// Path: src/main/java/lilypad/bukkit/connect/login/LoginListenerProxy.java
import com.mojang.authlib.GameProfile;
import javassist.*;
import javassist.bytecode.*;
import lilypad.bukkit.connect.util.JavassistUtil;
import java.lang.reflect.Field;
if (field.getType() == fieldType) {
field.setAccessible(true);
return field;
}
}
return null;
}
private static Class create(Object networkManager) throws Exception {
Object originalLoginListener = null;
packetListenerField = null;
Field[] networkManagerFields = networkManager.getClass().getDeclaredFields();
for (Field field : networkManagerFields) {
if (field.getType().getSimpleName().equals("PacketListener")) {
field.setAccessible(true);
packetListenerField = field;
originalLoginListener = field.get(networkManager);
break;
}
}
if (originalLoginListener == null) {
throw new Exception("Could not find LoginListener in NetworkManager!");
}
if (!originalLoginListener.getClass().getSimpleName().equals("LoginListener")) {
throw new Exception("Could not find LoginListener in NetworkManager, found instead " + originalLoginListener.getClass().getSimpleName() + "!");
}
loginListenerClass = originalLoginListener.getClass();
profileField = findFieldOfType(loginListenerClass, GameProfile.class);
| ClassPool classPool = JavassistUtil.getClassPool(); |
LilyPad/Bukkit-Connect | src/main/java/lilypad/bukkit/connect/injector/HandlerListInjector.java | // Path: src/main/java/lilypad/bukkit/connect/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// private static final Field FIELD_MODIFIERS;
// private static final Field FIELD_ACCESSSOR;
// private static final Field FIELD_ACCESSSOR_OVERRIDE;
// private static final Field FIELD_ROOT;
//
// static {
// if (!System.getProperty("java.version").startsWith("1.8")) {
// try {
// getFilterMap(Field.class).clear();
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
//
// Field fieldModifiers = null;
// Field fieldAccessor = null;
// Field fieldAccessorOverride = null;
// Field fieldRoot = null;
// try {
// fieldModifiers = Field.class.getDeclaredField("modifiers");
// fieldModifiers.setAccessible(true);
// fieldAccessor = Field.class.getDeclaredField("fieldAccessor");
// fieldAccessor.setAccessible(true);
// fieldAccessorOverride = Field.class.getDeclaredField("overrideFieldAccessor");
// fieldAccessorOverride.setAccessible(true);
// fieldRoot = Field.class.getDeclaredField("root");
// fieldRoot.setAccessible(true);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// FIELD_MODIFIERS = fieldModifiers;
// FIELD_ACCESSSOR = fieldAccessor;
// FIELD_ACCESSSOR_OVERRIDE = fieldAccessorOverride;
// FIELD_ROOT = fieldRoot;
// }
//
// public static void setFinalField(Class<?> objectClass, Object object, String fieldName, Object value) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
//
// if (Modifier.isFinal(field.getModifiers())) {
// FIELD_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// Field currentField = field;
// do {
// FIELD_ACCESSSOR.set(currentField, null);
// FIELD_ACCESSSOR_OVERRIDE.set(currentField, null);
// } while((currentField = (Field) FIELD_ROOT.get(currentField)) != null);
// }
//
// field.set(object, value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T getPrivateField(Class<?> objectClass, Object object, Class<T> fieldClass, String fieldName) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
// return (T) field.get(object);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends AccessibleObject & Member> Map<Class<?>, String[]> getFilterMap(Class<T> clazz) throws Exception {
// if (Constructor.class.isAssignableFrom(clazz)) {
// return null;
// }
// Method getDeclaredFields0M = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
// getDeclaredFields0M.setAccessible(true);
// Field[] fields = (Field[]) getDeclaredFields0M.invoke(Class.forName("jdk.internal.reflect.Reflection"), false);
// Field field = null;
// for (Field f : fields) {
// if (f.getName().equals(clazz.getSimpleName().toLowerCase() + "FilterMap")) {
// field = f;
// }
// }
// Method setAccessible0M = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
// setAccessible0M.setAccessible(true);
// setAccessible0M.invoke(field, true);
// return (Map<Class<?>, String[]>) field.get(null);
// }
//
// }
| import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import lilypad.bukkit.connect.util.ReflectionUtils;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredListener; | package lilypad.bukkit.connect.injector;
public class HandlerListInjector extends HandlerList {
@SuppressWarnings("unchecked")
public static void prioritize(Plugin plugin, Class<? extends Event> event) throws Exception { | // Path: src/main/java/lilypad/bukkit/connect/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// private static final Field FIELD_MODIFIERS;
// private static final Field FIELD_ACCESSSOR;
// private static final Field FIELD_ACCESSSOR_OVERRIDE;
// private static final Field FIELD_ROOT;
//
// static {
// if (!System.getProperty("java.version").startsWith("1.8")) {
// try {
// getFilterMap(Field.class).clear();
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
//
// Field fieldModifiers = null;
// Field fieldAccessor = null;
// Field fieldAccessorOverride = null;
// Field fieldRoot = null;
// try {
// fieldModifiers = Field.class.getDeclaredField("modifiers");
// fieldModifiers.setAccessible(true);
// fieldAccessor = Field.class.getDeclaredField("fieldAccessor");
// fieldAccessor.setAccessible(true);
// fieldAccessorOverride = Field.class.getDeclaredField("overrideFieldAccessor");
// fieldAccessorOverride.setAccessible(true);
// fieldRoot = Field.class.getDeclaredField("root");
// fieldRoot.setAccessible(true);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// FIELD_MODIFIERS = fieldModifiers;
// FIELD_ACCESSSOR = fieldAccessor;
// FIELD_ACCESSSOR_OVERRIDE = fieldAccessorOverride;
// FIELD_ROOT = fieldRoot;
// }
//
// public static void setFinalField(Class<?> objectClass, Object object, String fieldName, Object value) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
//
// if (Modifier.isFinal(field.getModifiers())) {
// FIELD_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// Field currentField = field;
// do {
// FIELD_ACCESSSOR.set(currentField, null);
// FIELD_ACCESSSOR_OVERRIDE.set(currentField, null);
// } while((currentField = (Field) FIELD_ROOT.get(currentField)) != null);
// }
//
// field.set(object, value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T getPrivateField(Class<?> objectClass, Object object, Class<T> fieldClass, String fieldName) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
// return (T) field.get(object);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends AccessibleObject & Member> Map<Class<?>, String[]> getFilterMap(Class<T> clazz) throws Exception {
// if (Constructor.class.isAssignableFrom(clazz)) {
// return null;
// }
// Method getDeclaredFields0M = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
// getDeclaredFields0M.setAccessible(true);
// Field[] fields = (Field[]) getDeclaredFields0M.invoke(Class.forName("jdk.internal.reflect.Reflection"), false);
// Field field = null;
// for (Field f : fields) {
// if (f.getName().equals(clazz.getSimpleName().toLowerCase() + "FilterMap")) {
// field = f;
// }
// }
// Method setAccessible0M = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
// setAccessible0M.setAccessible(true);
// setAccessible0M.invoke(field, true);
// return (Map<Class<?>, String[]>) field.get(null);
// }
//
// }
// Path: src/main/java/lilypad/bukkit/connect/injector/HandlerListInjector.java
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import lilypad.bukkit.connect.util.ReflectionUtils;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredListener;
package lilypad.bukkit.connect.injector;
public class HandlerListInjector extends HandlerList {
@SuppressWarnings("unchecked")
public static void prioritize(Plugin plugin, Class<? extends Event> event) throws Exception { | HandlerList handlerList = ReflectionUtils.getPrivateField(event, null, HandlerList.class, "handlers"); |
LilyPad/Bukkit-Connect | src/main/java/lilypad/bukkit/connect/hooks/SpigotHook.java | // Path: src/main/java/lilypad/bukkit/connect/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// private static final Field FIELD_MODIFIERS;
// private static final Field FIELD_ACCESSSOR;
// private static final Field FIELD_ACCESSSOR_OVERRIDE;
// private static final Field FIELD_ROOT;
//
// static {
// if (!System.getProperty("java.version").startsWith("1.8")) {
// try {
// getFilterMap(Field.class).clear();
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
//
// Field fieldModifiers = null;
// Field fieldAccessor = null;
// Field fieldAccessorOverride = null;
// Field fieldRoot = null;
// try {
// fieldModifiers = Field.class.getDeclaredField("modifiers");
// fieldModifiers.setAccessible(true);
// fieldAccessor = Field.class.getDeclaredField("fieldAccessor");
// fieldAccessor.setAccessible(true);
// fieldAccessorOverride = Field.class.getDeclaredField("overrideFieldAccessor");
// fieldAccessorOverride.setAccessible(true);
// fieldRoot = Field.class.getDeclaredField("root");
// fieldRoot.setAccessible(true);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// FIELD_MODIFIERS = fieldModifiers;
// FIELD_ACCESSSOR = fieldAccessor;
// FIELD_ACCESSSOR_OVERRIDE = fieldAccessorOverride;
// FIELD_ROOT = fieldRoot;
// }
//
// public static void setFinalField(Class<?> objectClass, Object object, String fieldName, Object value) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
//
// if (Modifier.isFinal(field.getModifiers())) {
// FIELD_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// Field currentField = field;
// do {
// FIELD_ACCESSSOR.set(currentField, null);
// FIELD_ACCESSSOR_OVERRIDE.set(currentField, null);
// } while((currentField = (Field) FIELD_ROOT.get(currentField)) != null);
// }
//
// field.set(object, value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T getPrivateField(Class<?> objectClass, Object object, Class<T> fieldClass, String fieldName) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
// return (T) field.get(object);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends AccessibleObject & Member> Map<Class<?>, String[]> getFilterMap(Class<T> clazz) throws Exception {
// if (Constructor.class.isAssignableFrom(clazz)) {
// return null;
// }
// Method getDeclaredFields0M = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
// getDeclaredFields0M.setAccessible(true);
// Field[] fields = (Field[]) getDeclaredFields0M.invoke(Class.forName("jdk.internal.reflect.Reflection"), false);
// Field field = null;
// for (Field f : fields) {
// if (f.getName().equals(clazz.getSimpleName().toLowerCase() + "FilterMap")) {
// field = f;
// }
// }
// Method setAccessible0M = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
// setAccessible0M.setAccessible(true);
// setAccessible0M.invoke(field, true);
// return (Map<Class<?>, String[]>) field.get(null);
// }
//
// }
| import lilypad.bukkit.connect.util.ReflectionUtils; | package lilypad.bukkit.connect.hooks;
public class SpigotHook {
private boolean isSpigot;
private String whitelistMessage;
private String serverFullMessage;
public SpigotHook() {
Class<?> spigotConfig;
try {
spigotConfig = Class.forName("org.spigotmc.SpigotConfig");
this.isSpigot = true;
} catch(Exception exception) {
this.isSpigot = false;
return;
}
try { | // Path: src/main/java/lilypad/bukkit/connect/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// private static final Field FIELD_MODIFIERS;
// private static final Field FIELD_ACCESSSOR;
// private static final Field FIELD_ACCESSSOR_OVERRIDE;
// private static final Field FIELD_ROOT;
//
// static {
// if (!System.getProperty("java.version").startsWith("1.8")) {
// try {
// getFilterMap(Field.class).clear();
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// }
//
// Field fieldModifiers = null;
// Field fieldAccessor = null;
// Field fieldAccessorOverride = null;
// Field fieldRoot = null;
// try {
// fieldModifiers = Field.class.getDeclaredField("modifiers");
// fieldModifiers.setAccessible(true);
// fieldAccessor = Field.class.getDeclaredField("fieldAccessor");
// fieldAccessor.setAccessible(true);
// fieldAccessorOverride = Field.class.getDeclaredField("overrideFieldAccessor");
// fieldAccessorOverride.setAccessible(true);
// fieldRoot = Field.class.getDeclaredField("root");
// fieldRoot.setAccessible(true);
// } catch (Exception exception) {
// exception.printStackTrace();
// }
// FIELD_MODIFIERS = fieldModifiers;
// FIELD_ACCESSSOR = fieldAccessor;
// FIELD_ACCESSSOR_OVERRIDE = fieldAccessorOverride;
// FIELD_ROOT = fieldRoot;
// }
//
// public static void setFinalField(Class<?> objectClass, Object object, String fieldName, Object value) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
//
// if (Modifier.isFinal(field.getModifiers())) {
// FIELD_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// Field currentField = field;
// do {
// FIELD_ACCESSSOR.set(currentField, null);
// FIELD_ACCESSSOR_OVERRIDE.set(currentField, null);
// } while((currentField = (Field) FIELD_ROOT.get(currentField)) != null);
// }
//
// field.set(object, value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T getPrivateField(Class<?> objectClass, Object object, Class<T> fieldClass, String fieldName) throws Exception {
// Field field = objectClass.getDeclaredField(fieldName);
// field.setAccessible(true);
// return (T) field.get(object);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends AccessibleObject & Member> Map<Class<?>, String[]> getFilterMap(Class<T> clazz) throws Exception {
// if (Constructor.class.isAssignableFrom(clazz)) {
// return null;
// }
// Method getDeclaredFields0M = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
// getDeclaredFields0M.setAccessible(true);
// Field[] fields = (Field[]) getDeclaredFields0M.invoke(Class.forName("jdk.internal.reflect.Reflection"), false);
// Field field = null;
// for (Field f : fields) {
// if (f.getName().equals(clazz.getSimpleName().toLowerCase() + "FilterMap")) {
// field = f;
// }
// }
// Method setAccessible0M = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
// setAccessible0M.setAccessible(true);
// setAccessible0M.invoke(field, true);
// return (Map<Class<?>, String[]>) field.get(null);
// }
//
// }
// Path: src/main/java/lilypad/bukkit/connect/hooks/SpigotHook.java
import lilypad.bukkit.connect.util.ReflectionUtils;
package lilypad.bukkit.connect.hooks;
public class SpigotHook {
private boolean isSpigot;
private String whitelistMessage;
private String serverFullMessage;
public SpigotHook() {
Class<?> spigotConfig;
try {
spigotConfig = Class.forName("org.spigotmc.SpigotConfig");
this.isSpigot = true;
} catch(Exception exception) {
this.isSpigot = false;
return;
}
try { | this.whitelistMessage = ReflectionUtils.getPrivateField(spigotConfig, null, String.class, "whitelistMessage"); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java | // Path: app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java
// public abstract class BaseApplication extends Application {
//
// public abstract void initConfigs();
//
// //TODO Context会产生内存泄漏
// public static Context context = null;
//
// public static Handler handler = null;
//
// public static Thread mainThread = null;
//
// public static int mainThreadId = 0;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = getApplicationContext();
//
// handler = new Handler();
//
// mainThread = Thread.currentThread();
//
// //自定义异常捕获
// CrashHandler.getInstance().init(this);
//
// initConfigs();
// }
//
// public static Context getContext() {
// return context;
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/BmobConfig.java
// public class BmobConfig {
// /**
// * Bmob APPID
// */
// public static final String APPID = "fe1d94a8f037d610f8d693f41d81e41e";
//
// /**
// * 短信验证码模板
// */
// public static final String SMSTEMPLATE = "STemplate";
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
| import com.monsterlin.pigeon.base.BaseApplication;
import com.monsterlin.pigeon.constant.BmobConfig;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.orhanobut.logger.Logger;
import com.taobao.sophix.PatchStatus;
import com.taobao.sophix.SophixManager;
import com.taobao.sophix.listener.PatchLoadStatusListener;
import cn.bmob.v3.Bmob; | package com.monsterlin.pigeon.application;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/10
* @desc : 程序的application
*/
public class PigeonApplication extends BaseApplication {
@Override
public void initConfigs() {
initSophix(); | // Path: app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java
// public abstract class BaseApplication extends Application {
//
// public abstract void initConfigs();
//
// //TODO Context会产生内存泄漏
// public static Context context = null;
//
// public static Handler handler = null;
//
// public static Thread mainThread = null;
//
// public static int mainThreadId = 0;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = getApplicationContext();
//
// handler = new Handler();
//
// mainThread = Thread.currentThread();
//
// //自定义异常捕获
// CrashHandler.getInstance().init(this);
//
// initConfigs();
// }
//
// public static Context getContext() {
// return context;
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/BmobConfig.java
// public class BmobConfig {
// /**
// * Bmob APPID
// */
// public static final String APPID = "fe1d94a8f037d610f8d693f41d81e41e";
//
// /**
// * 短信验证码模板
// */
// public static final String SMSTEMPLATE = "STemplate";
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
// Path: app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java
import com.monsterlin.pigeon.base.BaseApplication;
import com.monsterlin.pigeon.constant.BmobConfig;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.orhanobut.logger.Logger;
import com.taobao.sophix.PatchStatus;
import com.taobao.sophix.SophixManager;
import com.taobao.sophix.listener.PatchLoadStatusListener;
import cn.bmob.v3.Bmob;
package com.monsterlin.pigeon.application;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/10
* @desc : 程序的application
*/
public class PigeonApplication extends BaseApplication {
@Override
public void initConfigs() {
initSophix(); | Bmob.initialize(this, BmobConfig.APPID); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java | // Path: app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java
// public abstract class BaseApplication extends Application {
//
// public abstract void initConfigs();
//
// //TODO Context会产生内存泄漏
// public static Context context = null;
//
// public static Handler handler = null;
//
// public static Thread mainThread = null;
//
// public static int mainThreadId = 0;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = getApplicationContext();
//
// handler = new Handler();
//
// mainThread = Thread.currentThread();
//
// //自定义异常捕获
// CrashHandler.getInstance().init(this);
//
// initConfigs();
// }
//
// public static Context getContext() {
// return context;
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/BmobConfig.java
// public class BmobConfig {
// /**
// * Bmob APPID
// */
// public static final String APPID = "fe1d94a8f037d610f8d693f41d81e41e";
//
// /**
// * 短信验证码模板
// */
// public static final String SMSTEMPLATE = "STemplate";
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
| import com.monsterlin.pigeon.base.BaseApplication;
import com.monsterlin.pigeon.constant.BmobConfig;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.orhanobut.logger.Logger;
import com.taobao.sophix.PatchStatus;
import com.taobao.sophix.SophixManager;
import com.taobao.sophix.listener.PatchLoadStatusListener;
import cn.bmob.v3.Bmob; | package com.monsterlin.pigeon.application;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/10
* @desc : 程序的application
*/
public class PigeonApplication extends BaseApplication {
@Override
public void initConfigs() {
initSophix();
Bmob.initialize(this, BmobConfig.APPID);
}
private void initSophix() {
String appVersion;
try {
appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
} catch (Exception e) {
appVersion = "1.0.0";
}
SophixManager.getInstance().setContext(this)
.setAppVersion(appVersion)
.setAesKey(null)
.setEnableDebug(false)
.setPatchLoadStatusStub(new PatchLoadStatusListener() {
@Override
public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
// 补丁加载回调通知
if (code == PatchStatus.CODE_LOAD_SUCCESS) {
// 表明补丁加载成功 | // Path: app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java
// public abstract class BaseApplication extends Application {
//
// public abstract void initConfigs();
//
// //TODO Context会产生内存泄漏
// public static Context context = null;
//
// public static Handler handler = null;
//
// public static Thread mainThread = null;
//
// public static int mainThreadId = 0;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = getApplicationContext();
//
// handler = new Handler();
//
// mainThread = Thread.currentThread();
//
// //自定义异常捕获
// CrashHandler.getInstance().init(this);
//
// initConfigs();
// }
//
// public static Context getContext() {
// return context;
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/BmobConfig.java
// public class BmobConfig {
// /**
// * Bmob APPID
// */
// public static final String APPID = "fe1d94a8f037d610f8d693f41d81e41e";
//
// /**
// * 短信验证码模板
// */
// public static final String SMSTEMPLATE = "STemplate";
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
// Path: app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java
import com.monsterlin.pigeon.base.BaseApplication;
import com.monsterlin.pigeon.constant.BmobConfig;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.orhanobut.logger.Logger;
import com.taobao.sophix.PatchStatus;
import com.taobao.sophix.SophixManager;
import com.taobao.sophix.listener.PatchLoadStatusListener;
import cn.bmob.v3.Bmob;
package com.monsterlin.pigeon.application;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/10
* @desc : 程序的application
*/
public class PigeonApplication extends BaseApplication {
@Override
public void initConfigs() {
initSophix();
Bmob.initialize(this, BmobConfig.APPID);
}
private void initSophix() {
String appVersion;
try {
appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
} catch (Exception e) {
appVersion = "1.0.0";
}
SophixManager.getInstance().setContext(this)
.setAppVersion(appVersion)
.setAesKey(null)
.setEnableDebug(false)
.setPatchLoadStatusStub(new PatchLoadStatusListener() {
@Override
public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
// 补丁加载回调通知
if (code == PatchStatus.CODE_LOAD_SUCCESS) {
// 表明补丁加载成功 | ToastUtils.showToast(getApplicationContext(),"补丁加载成功"); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/utils/SPUtils.java | // Path: app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java
// public class PigeonApplication extends BaseApplication {
//
// @Override
// public void initConfigs() {
// initSophix();
// Bmob.initialize(this, BmobConfig.APPID);
// }
//
// private void initSophix() {
// String appVersion;
// try {
// appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
// } catch (Exception e) {
// appVersion = "1.0.0";
// }
//
// SophixManager.getInstance().setContext(this)
// .setAppVersion(appVersion)
// .setAesKey(null)
// .setEnableDebug(false)
// .setPatchLoadStatusStub(new PatchLoadStatusListener() {
// @Override
// public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
// // 补丁加载回调通知
// if (code == PatchStatus.CODE_LOAD_SUCCESS) {
// // 表明补丁加载成功
// ToastUtils.showToast(getApplicationContext(),"补丁加载成功");
// } else if (code == PatchStatus.CODE_LOAD_RELAUNCH) {
// // 表明新补丁生效需要重启. 开发者可提示用户或者强制重启;
// // 建议: 用户可以监听进入后台事件, 然后调用killProcessSafely自杀,以此加快应用补丁,详见1.3.2.3
// ToastUtils.showToast(getApplicationContext(),"新补丁生效需要重启");
// SophixManager.getInstance().killProcessSafely();
// } else {
// // 其它错误信息, 查看PatchStatus类说明
// Logger.e("SophixErrorCode:"+code);
// }
// }
// }).initialize();
// SophixManager.getInstance().queryAndLoadNewPatch();
// }
//
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import com.monsterlin.pigeon.application.PigeonApplication; | package com.monsterlin.pigeon.utils;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/13
* @desc : SP工具类
*/
public class SPUtils {
private static final String CONFIG = "CONFIG";
private static SharedPreferences sp;
public static void clear() {
if (sp == null) {
sp = getContext().getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
}
sp.edit().clear().apply();
}
public static Context getContext() { | // Path: app/src/main/java/com/monsterlin/pigeon/application/PigeonApplication.java
// public class PigeonApplication extends BaseApplication {
//
// @Override
// public void initConfigs() {
// initSophix();
// Bmob.initialize(this, BmobConfig.APPID);
// }
//
// private void initSophix() {
// String appVersion;
// try {
// appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
// } catch (Exception e) {
// appVersion = "1.0.0";
// }
//
// SophixManager.getInstance().setContext(this)
// .setAppVersion(appVersion)
// .setAesKey(null)
// .setEnableDebug(false)
// .setPatchLoadStatusStub(new PatchLoadStatusListener() {
// @Override
// public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
// // 补丁加载回调通知
// if (code == PatchStatus.CODE_LOAD_SUCCESS) {
// // 表明补丁加载成功
// ToastUtils.showToast(getApplicationContext(),"补丁加载成功");
// } else if (code == PatchStatus.CODE_LOAD_RELAUNCH) {
// // 表明新补丁生效需要重启. 开发者可提示用户或者强制重启;
// // 建议: 用户可以监听进入后台事件, 然后调用killProcessSafely自杀,以此加快应用补丁,详见1.3.2.3
// ToastUtils.showToast(getApplicationContext(),"新补丁生效需要重启");
// SophixManager.getInstance().killProcessSafely();
// } else {
// // 其它错误信息, 查看PatchStatus类说明
// Logger.e("SophixErrorCode:"+code);
// }
// }
// }).initialize();
// SophixManager.getInstance().queryAndLoadNewPatch();
// }
//
//
// }
// Path: app/src/main/java/com/monsterlin/pigeon/utils/SPUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import com.monsterlin.pigeon.application.PigeonApplication;
package com.monsterlin.pigeon.utils;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/13
* @desc : SP工具类
*/
public class SPUtils {
private static final String CONFIG = "CONFIG";
private static SharedPreferences sp;
public static void clear() {
if (sp == null) {
sp = getContext().getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
}
sp.edit().clear().apply();
}
public static Context getContext() { | return PigeonApplication.getContext(); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/base/BaseActivity.java | // Path: app/src/main/java/com/monsterlin/pigeon/common/AppManager.java
// public class AppManager {
//
// // Activity栈
// private static Stack<Activity> activityStack;
// // 单例模式
// private static AppManager instance;
//
// private AppManager() {
//
// }
//
// /**
// * 单一实例
// */
// public static AppManager getAppManager() {
// if (instance == null) {
// instance = new AppManager();
// }
// return instance;
// }
//
// /**
// * 添加Activity到堆栈
// */
// public void addActivity(Activity activity) {
// if (activityStack == null) {
// activityStack = new Stack<>();
// }
// activityStack.add(activity);
// }
//
// /**
// * 获取当前Activity(堆栈中最后一个压入的)
// */
// public Activity currentActivity() {
// return activityStack.lastElement();
// }
//
// /**
// * 结束当前Activity(堆栈中最后一个压入的)
// */
// public void finishActivity() {
// Activity activity = activityStack.lastElement();
// finishActivity(activity);
// }
//
// /**
// * 结束指定的Activity
// */
// public void finishActivity(Activity activity) {
// if (activity != null) {
// activityStack.remove(activity);
// activity.finish();
// }
// }
//
// /**
// * 结束指定类名的Activity
// */
// public void finishActivity(Class<?> cls) {
// for (Activity activity : activityStack) {
// if (activity.getClass().equals(cls)) {
// finishActivity(activity);
// }
// }
// }
//
// /**
// * 结束所有Activity
// */
// public void finishAllActivity() {
// for (int i = 0; i < activityStack.size(); i++) {
// if (null != activityStack.get(i)) {
// activityStack.get(i).finish();
// }
// }
// activityStack.clear();
// }
//
// /**
// * 退出应用程序
// */
// public void AppExit(Context context) {
// try {
// finishAllActivity();
// ActivityManager activityMgr = (ActivityManager) context
// .getSystemService(Context.ACTIVITY_SERVICE);
// activityMgr.killBackgroundProcesses(context.getPackageName());
// System.exit(0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 获取堆栈的大小
// *
// * @return size
// */
// public int getSize() {
// return activityStack.size();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/widget/LoadingDialog.java
// public class LoadingDialog {
//
// private AlertDialog alertDialog;
// private Context mContext;
// public LoadingDialog(Context context) {
// this.mContext = context;
// View view = LayoutInflater.from(mContext).inflate(R.layout.view_alert, null);
// alertDialog = new AlertDialog.Builder(context)
// .setView(view)
// .create();
// alertDialog.setCancelable(false); //这句代码设置这个对话框不能被用户按[返回键]而取消掉
// }
// public void showDialog() {
// alertDialog.show();
// }
// public void dismissDialog() {
// alertDialog.dismiss();
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.SparseArray;
import android.view.View;
import com.monsterlin.pigeon.common.AppManager;
import com.monsterlin.pigeon.widget.LoadingDialog;
import cn.bmob.v3.BmobInstallation; | package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Activity的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {
private SparseArray<View> mViews;
| // Path: app/src/main/java/com/monsterlin/pigeon/common/AppManager.java
// public class AppManager {
//
// // Activity栈
// private static Stack<Activity> activityStack;
// // 单例模式
// private static AppManager instance;
//
// private AppManager() {
//
// }
//
// /**
// * 单一实例
// */
// public static AppManager getAppManager() {
// if (instance == null) {
// instance = new AppManager();
// }
// return instance;
// }
//
// /**
// * 添加Activity到堆栈
// */
// public void addActivity(Activity activity) {
// if (activityStack == null) {
// activityStack = new Stack<>();
// }
// activityStack.add(activity);
// }
//
// /**
// * 获取当前Activity(堆栈中最后一个压入的)
// */
// public Activity currentActivity() {
// return activityStack.lastElement();
// }
//
// /**
// * 结束当前Activity(堆栈中最后一个压入的)
// */
// public void finishActivity() {
// Activity activity = activityStack.lastElement();
// finishActivity(activity);
// }
//
// /**
// * 结束指定的Activity
// */
// public void finishActivity(Activity activity) {
// if (activity != null) {
// activityStack.remove(activity);
// activity.finish();
// }
// }
//
// /**
// * 结束指定类名的Activity
// */
// public void finishActivity(Class<?> cls) {
// for (Activity activity : activityStack) {
// if (activity.getClass().equals(cls)) {
// finishActivity(activity);
// }
// }
// }
//
// /**
// * 结束所有Activity
// */
// public void finishAllActivity() {
// for (int i = 0; i < activityStack.size(); i++) {
// if (null != activityStack.get(i)) {
// activityStack.get(i).finish();
// }
// }
// activityStack.clear();
// }
//
// /**
// * 退出应用程序
// */
// public void AppExit(Context context) {
// try {
// finishAllActivity();
// ActivityManager activityMgr = (ActivityManager) context
// .getSystemService(Context.ACTIVITY_SERVICE);
// activityMgr.killBackgroundProcesses(context.getPackageName());
// System.exit(0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 获取堆栈的大小
// *
// * @return size
// */
// public int getSize() {
// return activityStack.size();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/widget/LoadingDialog.java
// public class LoadingDialog {
//
// private AlertDialog alertDialog;
// private Context mContext;
// public LoadingDialog(Context context) {
// this.mContext = context;
// View view = LayoutInflater.from(mContext).inflate(R.layout.view_alert, null);
// alertDialog = new AlertDialog.Builder(context)
// .setView(view)
// .create();
// alertDialog.setCancelable(false); //这句代码设置这个对话框不能被用户按[返回键]而取消掉
// }
// public void showDialog() {
// alertDialog.show();
// }
// public void dismissDialog() {
// alertDialog.dismiss();
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.SparseArray;
import android.view.View;
import com.monsterlin.pigeon.common.AppManager;
import com.monsterlin.pigeon.widget.LoadingDialog;
import cn.bmob.v3.BmobInstallation;
package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Activity的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {
private SparseArray<View> mViews;
| public LoadingDialog dialog; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/base/BaseActivity.java | // Path: app/src/main/java/com/monsterlin/pigeon/common/AppManager.java
// public class AppManager {
//
// // Activity栈
// private static Stack<Activity> activityStack;
// // 单例模式
// private static AppManager instance;
//
// private AppManager() {
//
// }
//
// /**
// * 单一实例
// */
// public static AppManager getAppManager() {
// if (instance == null) {
// instance = new AppManager();
// }
// return instance;
// }
//
// /**
// * 添加Activity到堆栈
// */
// public void addActivity(Activity activity) {
// if (activityStack == null) {
// activityStack = new Stack<>();
// }
// activityStack.add(activity);
// }
//
// /**
// * 获取当前Activity(堆栈中最后一个压入的)
// */
// public Activity currentActivity() {
// return activityStack.lastElement();
// }
//
// /**
// * 结束当前Activity(堆栈中最后一个压入的)
// */
// public void finishActivity() {
// Activity activity = activityStack.lastElement();
// finishActivity(activity);
// }
//
// /**
// * 结束指定的Activity
// */
// public void finishActivity(Activity activity) {
// if (activity != null) {
// activityStack.remove(activity);
// activity.finish();
// }
// }
//
// /**
// * 结束指定类名的Activity
// */
// public void finishActivity(Class<?> cls) {
// for (Activity activity : activityStack) {
// if (activity.getClass().equals(cls)) {
// finishActivity(activity);
// }
// }
// }
//
// /**
// * 结束所有Activity
// */
// public void finishAllActivity() {
// for (int i = 0; i < activityStack.size(); i++) {
// if (null != activityStack.get(i)) {
// activityStack.get(i).finish();
// }
// }
// activityStack.clear();
// }
//
// /**
// * 退出应用程序
// */
// public void AppExit(Context context) {
// try {
// finishAllActivity();
// ActivityManager activityMgr = (ActivityManager) context
// .getSystemService(Context.ACTIVITY_SERVICE);
// activityMgr.killBackgroundProcesses(context.getPackageName());
// System.exit(0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 获取堆栈的大小
// *
// * @return size
// */
// public int getSize() {
// return activityStack.size();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/widget/LoadingDialog.java
// public class LoadingDialog {
//
// private AlertDialog alertDialog;
// private Context mContext;
// public LoadingDialog(Context context) {
// this.mContext = context;
// View view = LayoutInflater.from(mContext).inflate(R.layout.view_alert, null);
// alertDialog = new AlertDialog.Builder(context)
// .setView(view)
// .create();
// alertDialog.setCancelable(false); //这句代码设置这个对话框不能被用户按[返回键]而取消掉
// }
// public void showDialog() {
// alertDialog.show();
// }
// public void dismissDialog() {
// alertDialog.dismiss();
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.SparseArray;
import android.view.View;
import com.monsterlin.pigeon.common.AppManager;
import com.monsterlin.pigeon.widget.LoadingDialog;
import cn.bmob.v3.BmobInstallation; | package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Activity的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {
private SparseArray<View> mViews;
public LoadingDialog dialog;
public abstract int getLayoutId();
public abstract void initViews();
public abstract void initListener();
public abstract void initData();
public abstract void processClick(View v);
public void onClick(View v) {
processClick(v);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViews = new SparseArray<>();
setContentView(getLayoutId()); | // Path: app/src/main/java/com/monsterlin/pigeon/common/AppManager.java
// public class AppManager {
//
// // Activity栈
// private static Stack<Activity> activityStack;
// // 单例模式
// private static AppManager instance;
//
// private AppManager() {
//
// }
//
// /**
// * 单一实例
// */
// public static AppManager getAppManager() {
// if (instance == null) {
// instance = new AppManager();
// }
// return instance;
// }
//
// /**
// * 添加Activity到堆栈
// */
// public void addActivity(Activity activity) {
// if (activityStack == null) {
// activityStack = new Stack<>();
// }
// activityStack.add(activity);
// }
//
// /**
// * 获取当前Activity(堆栈中最后一个压入的)
// */
// public Activity currentActivity() {
// return activityStack.lastElement();
// }
//
// /**
// * 结束当前Activity(堆栈中最后一个压入的)
// */
// public void finishActivity() {
// Activity activity = activityStack.lastElement();
// finishActivity(activity);
// }
//
// /**
// * 结束指定的Activity
// */
// public void finishActivity(Activity activity) {
// if (activity != null) {
// activityStack.remove(activity);
// activity.finish();
// }
// }
//
// /**
// * 结束指定类名的Activity
// */
// public void finishActivity(Class<?> cls) {
// for (Activity activity : activityStack) {
// if (activity.getClass().equals(cls)) {
// finishActivity(activity);
// }
// }
// }
//
// /**
// * 结束所有Activity
// */
// public void finishAllActivity() {
// for (int i = 0; i < activityStack.size(); i++) {
// if (null != activityStack.get(i)) {
// activityStack.get(i).finish();
// }
// }
// activityStack.clear();
// }
//
// /**
// * 退出应用程序
// */
// public void AppExit(Context context) {
// try {
// finishAllActivity();
// ActivityManager activityMgr = (ActivityManager) context
// .getSystemService(Context.ACTIVITY_SERVICE);
// activityMgr.killBackgroundProcesses(context.getPackageName());
// System.exit(0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 获取堆栈的大小
// *
// * @return size
// */
// public int getSize() {
// return activityStack.size();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/widget/LoadingDialog.java
// public class LoadingDialog {
//
// private AlertDialog alertDialog;
// private Context mContext;
// public LoadingDialog(Context context) {
// this.mContext = context;
// View view = LayoutInflater.from(mContext).inflate(R.layout.view_alert, null);
// alertDialog = new AlertDialog.Builder(context)
// .setView(view)
// .create();
// alertDialog.setCancelable(false); //这句代码设置这个对话框不能被用户按[返回键]而取消掉
// }
// public void showDialog() {
// alertDialog.show();
// }
// public void dismissDialog() {
// alertDialog.dismiss();
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.SparseArray;
import android.view.View;
import com.monsterlin.pigeon.common.AppManager;
import com.monsterlin.pigeon.widget.LoadingDialog;
import cn.bmob.v3.BmobInstallation;
package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Activity的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {
private SparseArray<View> mViews;
public LoadingDialog dialog;
public abstract int getLayoutId();
public abstract void initViews();
public abstract void initListener();
public abstract void initData();
public abstract void processClick(View v);
public void onClick(View v) {
processClick(v);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViews = new SparseArray<>();
setContentView(getLayoutId()); | AppManager.getAppManager().addActivity(this); //添加Activity到堆栈中 |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/view/ToolsFragment.java | // Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
// public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
// private Context mContext ;
// private List<Tools> toolsList;
// private LayoutInflater mInflater ;
//
// public ToolsAdapter(Context mContext, List<Tools> toolsList) {
// this.mContext = mContext;
// this.toolsList = toolsList;
// mInflater=LayoutInflater.from(mContext);
// }
//
// @Override
// public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = mInflater.inflate(R.layout.item_tools,parent,false);
// ToolsVHolder vHolder = new ToolsVHolder(view);
// return vHolder;
// }
//
// @Override
// public void onBindViewHolder(ToolsVHolder holder, final int position) {
// holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
// final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
// if (!TextUtils.isEmpty(iconUrl)){
// Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
// }
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent i = new Intent(mContext, BrowerActivity.class);
// i.putExtra("url",toolsList.get(position).getToolsUrl());
// mContext.startActivity(i);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return toolsList.size();
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
// private boolean isVisible = false;
// private boolean isInitView = false;
// private boolean isFirstLoad = true;
//
// public View convertView;
// private SparseArray<View> mViews;
//
// public abstract int getLayoutId();
//
// public abstract void initViews();
//
// public abstract void initListener();
//
// public abstract void initData();
//
// public abstract void processClick(View v);
//
// @Override
// public void onClick(View v) {
// processClick(v);
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) {
// isVisible = true;
// lazyLoad();
// } else {
// //设置已经不是可见的
// isVisible = false;
// }
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// mViews = new SparseArray<>();
// convertView = inflater.inflate(getLayoutId(), container, false);
// initViews();
//
// isInitView = true;
// lazyLoad();
// return convertView;
// }
//
// //懒加载
// private void lazyLoad() {
// if (!isFirstLoad || !isVisible || !isInitView) {
// //如果不是第一次加载、不是可见的、不是初始化View,则不加载数据
// return;
// }
// //加载数据
// initListener();
// initData();
// //设置已经不是第一次加载
// isFirstLoad = false;
// }
//
// public <E extends View> E findView(int viewId) {
// if (convertView != null) {
// E view = (E) mViews.get(viewId);
// if (view == null) {
// view = (E) convertView.findViewById(viewId);
// mViews.put(viewId, view);
// }
// return view;
// }
// return null;
// }
//
// public <E extends View> void setOnClick(E view){
// view.setOnClickListener(this);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
| import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.adapter.ToolsAdapter;
import com.monsterlin.pigeon.base.BaseFragment;
import com.monsterlin.pigeon.bean.Tools;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.List;
import java.util.concurrent.TimeUnit;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener; | package com.monsterlin.pigeon.view;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/9
* @desc : 工具板块
*/
public class ToolsFragment extends BaseFragment implements View.OnClickListener {
private RecyclerView mRvTools; | // Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
// public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
// private Context mContext ;
// private List<Tools> toolsList;
// private LayoutInflater mInflater ;
//
// public ToolsAdapter(Context mContext, List<Tools> toolsList) {
// this.mContext = mContext;
// this.toolsList = toolsList;
// mInflater=LayoutInflater.from(mContext);
// }
//
// @Override
// public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = mInflater.inflate(R.layout.item_tools,parent,false);
// ToolsVHolder vHolder = new ToolsVHolder(view);
// return vHolder;
// }
//
// @Override
// public void onBindViewHolder(ToolsVHolder holder, final int position) {
// holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
// final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
// if (!TextUtils.isEmpty(iconUrl)){
// Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
// }
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent i = new Intent(mContext, BrowerActivity.class);
// i.putExtra("url",toolsList.get(position).getToolsUrl());
// mContext.startActivity(i);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return toolsList.size();
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
// private boolean isVisible = false;
// private boolean isInitView = false;
// private boolean isFirstLoad = true;
//
// public View convertView;
// private SparseArray<View> mViews;
//
// public abstract int getLayoutId();
//
// public abstract void initViews();
//
// public abstract void initListener();
//
// public abstract void initData();
//
// public abstract void processClick(View v);
//
// @Override
// public void onClick(View v) {
// processClick(v);
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) {
// isVisible = true;
// lazyLoad();
// } else {
// //设置已经不是可见的
// isVisible = false;
// }
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// mViews = new SparseArray<>();
// convertView = inflater.inflate(getLayoutId(), container, false);
// initViews();
//
// isInitView = true;
// lazyLoad();
// return convertView;
// }
//
// //懒加载
// private void lazyLoad() {
// if (!isFirstLoad || !isVisible || !isInitView) {
// //如果不是第一次加载、不是可见的、不是初始化View,则不加载数据
// return;
// }
// //加载数据
// initListener();
// initData();
// //设置已经不是第一次加载
// isFirstLoad = false;
// }
//
// public <E extends View> E findView(int viewId) {
// if (convertView != null) {
// E view = (E) mViews.get(viewId);
// if (view == null) {
// view = (E) convertView.findViewById(viewId);
// mViews.put(viewId, view);
// }
// return view;
// }
// return null;
// }
//
// public <E extends View> void setOnClick(E view){
// view.setOnClickListener(this);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/view/ToolsFragment.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.adapter.ToolsAdapter;
import com.monsterlin.pigeon.base.BaseFragment;
import com.monsterlin.pigeon.bean.Tools;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.List;
import java.util.concurrent.TimeUnit;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;
package com.monsterlin.pigeon.view;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/9
* @desc : 工具板块
*/
public class ToolsFragment extends BaseFragment implements View.OnClickListener {
private RecyclerView mRvTools; | private ToolsAdapter toolsAdapter; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/view/ToolsFragment.java | // Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
// public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
// private Context mContext ;
// private List<Tools> toolsList;
// private LayoutInflater mInflater ;
//
// public ToolsAdapter(Context mContext, List<Tools> toolsList) {
// this.mContext = mContext;
// this.toolsList = toolsList;
// mInflater=LayoutInflater.from(mContext);
// }
//
// @Override
// public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = mInflater.inflate(R.layout.item_tools,parent,false);
// ToolsVHolder vHolder = new ToolsVHolder(view);
// return vHolder;
// }
//
// @Override
// public void onBindViewHolder(ToolsVHolder holder, final int position) {
// holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
// final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
// if (!TextUtils.isEmpty(iconUrl)){
// Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
// }
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent i = new Intent(mContext, BrowerActivity.class);
// i.putExtra("url",toolsList.get(position).getToolsUrl());
// mContext.startActivity(i);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return toolsList.size();
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
// private boolean isVisible = false;
// private boolean isInitView = false;
// private boolean isFirstLoad = true;
//
// public View convertView;
// private SparseArray<View> mViews;
//
// public abstract int getLayoutId();
//
// public abstract void initViews();
//
// public abstract void initListener();
//
// public abstract void initData();
//
// public abstract void processClick(View v);
//
// @Override
// public void onClick(View v) {
// processClick(v);
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) {
// isVisible = true;
// lazyLoad();
// } else {
// //设置已经不是可见的
// isVisible = false;
// }
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// mViews = new SparseArray<>();
// convertView = inflater.inflate(getLayoutId(), container, false);
// initViews();
//
// isInitView = true;
// lazyLoad();
// return convertView;
// }
//
// //懒加载
// private void lazyLoad() {
// if (!isFirstLoad || !isVisible || !isInitView) {
// //如果不是第一次加载、不是可见的、不是初始化View,则不加载数据
// return;
// }
// //加载数据
// initListener();
// initData();
// //设置已经不是第一次加载
// isFirstLoad = false;
// }
//
// public <E extends View> E findView(int viewId) {
// if (convertView != null) {
// E view = (E) mViews.get(viewId);
// if (view == null) {
// view = (E) convertView.findViewById(viewId);
// mViews.put(viewId, view);
// }
// return view;
// }
// return null;
// }
//
// public <E extends View> void setOnClick(E view){
// view.setOnClickListener(this);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
| import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.adapter.ToolsAdapter;
import com.monsterlin.pigeon.base.BaseFragment;
import com.monsterlin.pigeon.bean.Tools;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.List;
import java.util.concurrent.TimeUnit;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener; | package com.monsterlin.pigeon.view;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/9
* @desc : 工具板块
*/
public class ToolsFragment extends BaseFragment implements View.OnClickListener {
private RecyclerView mRvTools;
private ToolsAdapter toolsAdapter; | // Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
// public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
// private Context mContext ;
// private List<Tools> toolsList;
// private LayoutInflater mInflater ;
//
// public ToolsAdapter(Context mContext, List<Tools> toolsList) {
// this.mContext = mContext;
// this.toolsList = toolsList;
// mInflater=LayoutInflater.from(mContext);
// }
//
// @Override
// public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = mInflater.inflate(R.layout.item_tools,parent,false);
// ToolsVHolder vHolder = new ToolsVHolder(view);
// return vHolder;
// }
//
// @Override
// public void onBindViewHolder(ToolsVHolder holder, final int position) {
// holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
// final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
// if (!TextUtils.isEmpty(iconUrl)){
// Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
// }
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent i = new Intent(mContext, BrowerActivity.class);
// i.putExtra("url",toolsList.get(position).getToolsUrl());
// mContext.startActivity(i);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return toolsList.size();
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
// private boolean isVisible = false;
// private boolean isInitView = false;
// private boolean isFirstLoad = true;
//
// public View convertView;
// private SparseArray<View> mViews;
//
// public abstract int getLayoutId();
//
// public abstract void initViews();
//
// public abstract void initListener();
//
// public abstract void initData();
//
// public abstract void processClick(View v);
//
// @Override
// public void onClick(View v) {
// processClick(v);
// }
//
// @Override
// public void setUserVisibleHint(boolean isVisibleToUser) {
// super.setUserVisibleHint(isVisibleToUser);
// if (isVisibleToUser) {
// isVisible = true;
// lazyLoad();
// } else {
// //设置已经不是可见的
// isVisible = false;
// }
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// mViews = new SparseArray<>();
// convertView = inflater.inflate(getLayoutId(), container, false);
// initViews();
//
// isInitView = true;
// lazyLoad();
// return convertView;
// }
//
// //懒加载
// private void lazyLoad() {
// if (!isFirstLoad || !isVisible || !isInitView) {
// //如果不是第一次加载、不是可见的、不是初始化View,则不加载数据
// return;
// }
// //加载数据
// initListener();
// initData();
// //设置已经不是第一次加载
// isFirstLoad = false;
// }
//
// public <E extends View> E findView(int viewId) {
// if (convertView != null) {
// E view = (E) mViews.get(viewId);
// if (view == null) {
// view = (E) convertView.findViewById(viewId);
// mViews.put(viewId, view);
// }
// return view;
// }
// return null;
// }
//
// public <E extends View> void setOnClick(E view){
// view.setOnClickListener(this);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/view/ToolsFragment.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.adapter.ToolsAdapter;
import com.monsterlin.pigeon.base.BaseFragment;
import com.monsterlin.pigeon.bean.Tools;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.List;
import java.util.concurrent.TimeUnit;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;
package com.monsterlin.pigeon.view;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/7/9
* @desc : 工具板块
*/
public class ToolsFragment extends BaseFragment implements View.OnClickListener {
private RecyclerView mRvTools;
private ToolsAdapter toolsAdapter; | private BmobQuery<Tools> query; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/utils/ChatRobotUtils.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Result.java
// public class Result {
// private int code;
// private String text;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/TuLingConfig.java
// public class TuLingConfig {
// public static final String URL = "http://www.tuling123.com/openapi/api";
// public static final String APIKEY = "fcd7f1a8fd0b4048ae880e545d1ccf7b";
// }
| import com.google.gson.Gson;
import com.monsterlin.pigeon.bean.ChatMessage;
import com.monsterlin.pigeon.bean.Result;
import com.monsterlin.pigeon.constant.TuLingConfig;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.Date; | package com.monsterlin.pigeon.utils;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 机器人聊天通信类
*/
public class ChatRobotUtils {
/**
* 发送一个消息,得到返回的消息
* @param msg
* @return
*/
public static ChatMessage sendMessage(String msg)
{
ChatMessage chatMessage = new ChatMessage();
String jsonRes = doGet(msg);
Gson gson = new Gson(); | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Result.java
// public class Result {
// private int code;
// private String text;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/TuLingConfig.java
// public class TuLingConfig {
// public static final String URL = "http://www.tuling123.com/openapi/api";
// public static final String APIKEY = "fcd7f1a8fd0b4048ae880e545d1ccf7b";
// }
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ChatRobotUtils.java
import com.google.gson.Gson;
import com.monsterlin.pigeon.bean.ChatMessage;
import com.monsterlin.pigeon.bean.Result;
import com.monsterlin.pigeon.constant.TuLingConfig;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.Date;
package com.monsterlin.pigeon.utils;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 机器人聊天通信类
*/
public class ChatRobotUtils {
/**
* 发送一个消息,得到返回的消息
* @param msg
* @return
*/
public static ChatMessage sendMessage(String msg)
{
ChatMessage chatMessage = new ChatMessage();
String jsonRes = doGet(msg);
Gson gson = new Gson(); | Result result = null; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/utils/ChatRobotUtils.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Result.java
// public class Result {
// private int code;
// private String text;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/TuLingConfig.java
// public class TuLingConfig {
// public static final String URL = "http://www.tuling123.com/openapi/api";
// public static final String APIKEY = "fcd7f1a8fd0b4048ae880e545d1ccf7b";
// }
| import com.google.gson.Gson;
import com.monsterlin.pigeon.bean.ChatMessage;
import com.monsterlin.pigeon.bean.Result;
import com.monsterlin.pigeon.constant.TuLingConfig;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.Date; | } finally
{
try
{
if (baos != null)
baos.close();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
if (is != null)
{
is.close();
}
} catch (IOException e)
{
e.printStackTrace();
}
}
return result;
}
private static String setParams(String msg)
{
String url = "";
try
{ | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/bean/Result.java
// public class Result {
// private int code;
// private String text;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/constant/TuLingConfig.java
// public class TuLingConfig {
// public static final String URL = "http://www.tuling123.com/openapi/api";
// public static final String APIKEY = "fcd7f1a8fd0b4048ae880e545d1ccf7b";
// }
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ChatRobotUtils.java
import com.google.gson.Gson;
import com.monsterlin.pigeon.bean.ChatMessage;
import com.monsterlin.pigeon.bean.Result;
import com.monsterlin.pigeon.constant.TuLingConfig;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.Date;
} finally
{
try
{
if (baos != null)
baos.close();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
if (is != null)
{
is.close();
}
} catch (IOException e)
{
e.printStackTrace();
}
}
return result;
}
private static String setParams(String msg)
{
String url = "";
try
{ | url = TuLingConfig.URL + "?key=" + TuLingConfig.APIKEY + "&info=" |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/adapter/WeatherNumberAdapter.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/User.java
// public class User extends BmobUser {
// //默认含有的字段为;username , password , email , sessionToken , mobilePhoneNumber
//
// private String nick ; //昵称
// private int age ; //用户年龄
// private int type ; // 0 : 子女 & 1 :父母
// private Boolean isCreate ; //创建家庭
// private Boolean isJoin ; //加入家庭
// private Family family ; //加入的家庭
// private BmobFile userPhoto ; //用户头像
// private String location ; // 地理位置
//
// public String getNick() {
// return nick;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public Boolean getIsCreate() {
// return isCreate;
// }
//
// public void setIsCreate(Boolean create) {
// isCreate = create;
// }
//
// public Boolean getIsJoin() {
// return isJoin;
// }
//
// public void setIsJoin(Boolean join) {
// isJoin = join;
// }
//
// public Family getFamily() {
// return family;
// }
//
// public void setFamily(Family family) {
// this.family = family;
// }
//
// public BmobFile getUserPhoto() {
// return userPhoto;
// }
//
// public void setUserPhoto(BmobFile userPhoto) {
// this.userPhoto = userPhoto;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/WeatherNumberVHolder.java
// public class WeatherNumberVHolder extends RecyclerView.ViewHolder {
// public TextView mTvNick,mTvWeather;
// public CircleImageView mCivUserPhoto ;
// public ImageView mCivSms ;
//
// public WeatherNumberVHolder(View itemView) {
// super(itemView);
// mCivUserPhoto = (CircleImageView) itemView.findViewById(R.id.weather_number_iv_icon);
// mTvNick = (TextView) itemView.findViewById(R.id.weather_number_tv_nick);
// mTvWeather = (TextView) itemView.findViewById(R.id.weather_number_tv_weather);
// mCivSms = (ImageView) itemView.findViewById(R.id.weather_number_iv_sms);
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.User;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.monsterlin.pigeon.vholder.WeatherNumberVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
import cn.bmob.v3.datatype.BmobFile; | String nick = userList.get(position).getNick();
if (!TextUtils.isEmpty(nick)) {
holder.mTvNick.setText(nick);
}
holder.mCivSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doSendSMSTo(userList.get(position).getMobilePhoneNumber());
}
});
String location = userList.get(position).getLocation();
if (!TextUtils.isEmpty(location)) {
WeatherSearchQuery mquery = new WeatherSearchQuery(location, WeatherSearchQuery.WEATHER_TYPE_LIVE);
WeatherSearch mweathersearch = new WeatherSearch(mContext);
mweathersearch.setOnWeatherSearchListener(new WeatherSearch.OnWeatherSearchListener() {
@Override
public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int rCode) {
if (rCode == 1000) {
if (localWeatherLiveResult.getLiveResult() != null) {
LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult();
holder.mTvWeather.setText(weatherlive.getWeather());
} else {
holder.mTvWeather.setText("--");
}
} else { | // Path: app/src/main/java/com/monsterlin/pigeon/bean/User.java
// public class User extends BmobUser {
// //默认含有的字段为;username , password , email , sessionToken , mobilePhoneNumber
//
// private String nick ; //昵称
// private int age ; //用户年龄
// private int type ; // 0 : 子女 & 1 :父母
// private Boolean isCreate ; //创建家庭
// private Boolean isJoin ; //加入家庭
// private Family family ; //加入的家庭
// private BmobFile userPhoto ; //用户头像
// private String location ; // 地理位置
//
// public String getNick() {
// return nick;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public Boolean getIsCreate() {
// return isCreate;
// }
//
// public void setIsCreate(Boolean create) {
// isCreate = create;
// }
//
// public Boolean getIsJoin() {
// return isJoin;
// }
//
// public void setIsJoin(Boolean join) {
// isJoin = join;
// }
//
// public Family getFamily() {
// return family;
// }
//
// public void setFamily(Family family) {
// this.family = family;
// }
//
// public BmobFile getUserPhoto() {
// return userPhoto;
// }
//
// public void setUserPhoto(BmobFile userPhoto) {
// this.userPhoto = userPhoto;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/utils/ToastUtils.java
// public class ToastUtils {
//
// private static View toastRoot;
// private static TextView tv;
// private static Toast mToast;
// private static int DURATION = Toast.LENGTH_SHORT;
//
// public static void showToast(Context context, CharSequence text) {
// toastRoot = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
// mToast = new Toast(context);
// tv = (TextView) toastRoot.findViewById(R.id.tv_toast_tips);
// mToast.setView(toastRoot);
// tv.setText(text);
// mToast.setDuration(DURATION);
// mToast.show();
// }
//
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/WeatherNumberVHolder.java
// public class WeatherNumberVHolder extends RecyclerView.ViewHolder {
// public TextView mTvNick,mTvWeather;
// public CircleImageView mCivUserPhoto ;
// public ImageView mCivSms ;
//
// public WeatherNumberVHolder(View itemView) {
// super(itemView);
// mCivUserPhoto = (CircleImageView) itemView.findViewById(R.id.weather_number_iv_icon);
// mTvNick = (TextView) itemView.findViewById(R.id.weather_number_tv_nick);
// mTvWeather = (TextView) itemView.findViewById(R.id.weather_number_tv_weather);
// mCivSms = (ImageView) itemView.findViewById(R.id.weather_number_iv_sms);
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/adapter/WeatherNumberAdapter.java
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.User;
import com.monsterlin.pigeon.utils.ToastUtils;
import com.monsterlin.pigeon.vholder.WeatherNumberVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
import cn.bmob.v3.datatype.BmobFile;
String nick = userList.get(position).getNick();
if (!TextUtils.isEmpty(nick)) {
holder.mTvNick.setText(nick);
}
holder.mCivSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doSendSMSTo(userList.get(position).getMobilePhoneNumber());
}
});
String location = userList.get(position).getLocation();
if (!TextUtils.isEmpty(location)) {
WeatherSearchQuery mquery = new WeatherSearchQuery(location, WeatherSearchQuery.WEATHER_TYPE_LIVE);
WeatherSearch mweathersearch = new WeatherSearch(mContext);
mweathersearch.setOnWeatherSearchListener(new WeatherSearch.OnWeatherSearchListener() {
@Override
public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int rCode) {
if (rCode == 1000) {
if (localWeatherLiveResult.getLiveResult() != null) {
LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult();
holder.mTvWeather.setText(weatherlive.getWeather());
} else {
holder.mTvWeather.setText("--");
}
} else { | ToastUtils.showToast(mContext, "查询天气异常:" + rCode); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java | // Path: app/src/main/java/com/monsterlin/pigeon/common/CrashHandler.java
// public class CrashHandler implements Thread.UncaughtExceptionHandler {
//
// private static CrashHandler crashHandler = null;
//
// private CrashHandler() {
//
// }
//
// //TODO 这个地方会产生内存泄漏
// public static CrashHandler getInstance() {
//
// if (crashHandler == null) {
// crashHandler = new CrashHandler();
// }
//
// return crashHandler;
//
// }
//
// private Context mContext;
//
// private Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
//
// public void init(Context context) {
// //将CrashHandler作为系统的默认异常处理器
// this.mContext = context;
// defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// Thread.setDefaultUncaughtExceptionHandler(this);
// }
//
// /**
// * 把信息提示汉化,记录日志信息,反馈给后台
// *
// * @param t 进程
// * @param e 异常
// */
//
// @Override
// public void uncaughtException(Thread t, Throwable e) {
// if (isHandler(e)) {
// handlerException(t, e);
// } else {
// //系统默认处理
// defaultUncaughtExceptionHandler.uncaughtException(t, null);
// }
//
// }
//
//
// /**
// * 判断是否需要自己处理
// *
// * @param e 异常
// * @return bollean
// */
// private boolean isHandler(Throwable e) {
// return e != null;
// }
//
// /**
// * 自定义异常处理
// *
// * @param t 进程
// * @param e 异常
// */
// private void handlerException(Thread t, Throwable e) {
// new Thread() {
// @Override
// public void run() {
// Looper.prepare();
// Toast.makeText(mContext, "抱歉,系统出现未知异常,即将退出...",
// Toast.LENGTH_SHORT).show();
// Looper.loop();
// }
// }.start();
//
// collectionException(e);
// try {
// Thread.sleep(2000);
// AppManager.getAppManager().finishAllActivity();
// Process.killProcess(Process.myPid());
// System.exit(0);
// } catch (InterruptedException e1) {
// e1.printStackTrace();
// }
// }
//
// /**
// * 收集奔溃异常信息
// *
// * @param e 异常
// */
// private void collectionException(Throwable e) {
// final String deviceInfo = Build.DEVICE + Build.VERSION.SDK_INT + Build.PRODUCT;
// final String errorInfo = e.getMessage();
// new Thread() {
// @Override
// public void run() {
// Log.e("system error: ", "deviceInfo--->>>" + deviceInfo + "|||"+":errorInfo: " + errorInfo);
// }
// }.start();
//
// }
//
// }
| import android.app.Application;
import android.content.Context;
import android.os.Handler;
import com.monsterlin.pigeon.common.CrashHandler; | package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Application的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseApplication extends Application {
public abstract void initConfigs();
//TODO Context会产生内存泄漏
public static Context context = null;
public static Handler handler = null;
public static Thread mainThread = null;
public static int mainThreadId = 0;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
handler = new Handler();
mainThread = Thread.currentThread();
//自定义异常捕获 | // Path: app/src/main/java/com/monsterlin/pigeon/common/CrashHandler.java
// public class CrashHandler implements Thread.UncaughtExceptionHandler {
//
// private static CrashHandler crashHandler = null;
//
// private CrashHandler() {
//
// }
//
// //TODO 这个地方会产生内存泄漏
// public static CrashHandler getInstance() {
//
// if (crashHandler == null) {
// crashHandler = new CrashHandler();
// }
//
// return crashHandler;
//
// }
//
// private Context mContext;
//
// private Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
//
// public void init(Context context) {
// //将CrashHandler作为系统的默认异常处理器
// this.mContext = context;
// defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// Thread.setDefaultUncaughtExceptionHandler(this);
// }
//
// /**
// * 把信息提示汉化,记录日志信息,反馈给后台
// *
// * @param t 进程
// * @param e 异常
// */
//
// @Override
// public void uncaughtException(Thread t, Throwable e) {
// if (isHandler(e)) {
// handlerException(t, e);
// } else {
// //系统默认处理
// defaultUncaughtExceptionHandler.uncaughtException(t, null);
// }
//
// }
//
//
// /**
// * 判断是否需要自己处理
// *
// * @param e 异常
// * @return bollean
// */
// private boolean isHandler(Throwable e) {
// return e != null;
// }
//
// /**
// * 自定义异常处理
// *
// * @param t 进程
// * @param e 异常
// */
// private void handlerException(Thread t, Throwable e) {
// new Thread() {
// @Override
// public void run() {
// Looper.prepare();
// Toast.makeText(mContext, "抱歉,系统出现未知异常,即将退出...",
// Toast.LENGTH_SHORT).show();
// Looper.loop();
// }
// }.start();
//
// collectionException(e);
// try {
// Thread.sleep(2000);
// AppManager.getAppManager().finishAllActivity();
// Process.killProcess(Process.myPid());
// System.exit(0);
// } catch (InterruptedException e1) {
// e1.printStackTrace();
// }
// }
//
// /**
// * 收集奔溃异常信息
// *
// * @param e 异常
// */
// private void collectionException(Throwable e) {
// final String deviceInfo = Build.DEVICE + Build.VERSION.SDK_INT + Build.PRODUCT;
// final String errorInfo = e.getMessage();
// new Thread() {
// @Override
// public void run() {
// Log.e("system error: ", "deviceInfo--->>>" + deviceInfo + "|||"+":errorInfo: " + errorInfo);
// }
// }.start();
//
// }
//
// }
// Path: app/src/main/java/com/monsterlin/pigeon/base/BaseApplication.java
import android.app.Application;
import android.content.Context;
import android.os.Handler;
import com.monsterlin.pigeon.common.CrashHandler;
package com.monsterlin.pigeon.base;
/**
* @author : Hensen_
* @desc : Application的基类
* @url : http://blog.csdn.net/qq_30379689/article/details/58034750
*/
public abstract class BaseApplication extends Application {
public abstract void initConfigs();
//TODO Context会产生内存泄漏
public static Context context = null;
public static Handler handler = null;
public static Thread mainThread = null;
public static int mainThreadId = 0;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
handler = new Handler();
mainThread = Thread.currentThread();
//自定义异常捕获 | CrashHandler.getInstance().init(this); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/adapter/ChatMessageAdapter.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.ChatMessage;
import java.util.List; | package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 聊天窗口适配器
*/
public class ChatMessageAdapter extends BaseAdapter
{
private LayoutInflater mInflater; | // Path: app/src/main/java/com/monsterlin/pigeon/bean/ChatMessage.java
// public class ChatMessage implements Serializable {
// private String name; //姓名
// private String msg; //消息
// private Type type; //类型 :主要用于区分发送者与接受者
// private Date date; //时间
//
// public enum Type
// {
// INCOMING, OUTCOMING
// }
//
// public ChatMessage() {
//
// }
//
// public ChatMessage(String msg, Type type, Date date) {
// super();
// this.msg = msg;
// this.type = type;
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/adapter/ChatMessageAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.ChatMessage;
import java.util.List;
package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 聊天窗口适配器
*/
public class ChatMessageAdapter extends BaseAdapter
{
private LayoutInflater mInflater; | private List<ChatMessage> mDatas; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/ui/brower/BrowerActivity.java
// public class BrowerActivity extends BaseActivity {
//
// private Toolbar mToolBar;
// private String urlString;
//
// private ProgressWebView mProWebView;
//
// @Override
// public int getLayoutId() {
// return R.layout.activity_web_brower;
// }
//
// @Override
// public void initViews() {
// mToolBar = findView(R.id.common_toolbar);
// initToolBar(mToolBar, "飞鸽", true);
// mProWebView = findView(R.id.brower_pwv);
// }
//
// @Override
// public void initListener() {
//
// }
//
// @Override
// public void initData() {
// urlString = getIntent().getStringExtra("url");
// if (!TextUtils.isEmpty(urlString)){
// mProWebView.getSettings().setJavaScriptEnabled(true);
// mProWebView.loadUrl(urlString);
// }else {
// ToastUtils.showToast(this,"无数据显示");
// }
//
// }
//
// @Override
// public void processClick(View v) {
//
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(keyCode== KeyEvent.KEYCODE_BACK)
// {
// if(mProWebView.canGoBack())
// {
// mProWebView.goBack();//返回上一页面
// return true;
// }
// else
// {
// System.exit(0);//退出程序
// }
// }
// return super.onKeyDown(keyCode, event);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/ToolsVHolder.java
// public class ToolsVHolder extends RecyclerView.ViewHolder {
// public ImageView mIvIcon ;
// public TextView mTvTitle ;
//
// public ToolsVHolder(View itemView) {
// super(itemView);
// mIvIcon= (ImageView) itemView.findViewById(R.id.tools_iv_icon);
// mTvTitle= (TextView) itemView.findViewById(R.id.tools_tv_title);
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Tools;
import com.monsterlin.pigeon.ui.brower.BrowerActivity;
import com.monsterlin.pigeon.vholder.ToolsVHolder;
import com.squareup.picasso.Picasso;
import java.util.List; | package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 工具板块适配器
*/
public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
private Context mContext ; | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/ui/brower/BrowerActivity.java
// public class BrowerActivity extends BaseActivity {
//
// private Toolbar mToolBar;
// private String urlString;
//
// private ProgressWebView mProWebView;
//
// @Override
// public int getLayoutId() {
// return R.layout.activity_web_brower;
// }
//
// @Override
// public void initViews() {
// mToolBar = findView(R.id.common_toolbar);
// initToolBar(mToolBar, "飞鸽", true);
// mProWebView = findView(R.id.brower_pwv);
// }
//
// @Override
// public void initListener() {
//
// }
//
// @Override
// public void initData() {
// urlString = getIntent().getStringExtra("url");
// if (!TextUtils.isEmpty(urlString)){
// mProWebView.getSettings().setJavaScriptEnabled(true);
// mProWebView.loadUrl(urlString);
// }else {
// ToastUtils.showToast(this,"无数据显示");
// }
//
// }
//
// @Override
// public void processClick(View v) {
//
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(keyCode== KeyEvent.KEYCODE_BACK)
// {
// if(mProWebView.canGoBack())
// {
// mProWebView.goBack();//返回上一页面
// return true;
// }
// else
// {
// System.exit(0);//退出程序
// }
// }
// return super.onKeyDown(keyCode, event);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/ToolsVHolder.java
// public class ToolsVHolder extends RecyclerView.ViewHolder {
// public ImageView mIvIcon ;
// public TextView mTvTitle ;
//
// public ToolsVHolder(View itemView) {
// super(itemView);
// mIvIcon= (ImageView) itemView.findViewById(R.id.tools_iv_icon);
// mTvTitle= (TextView) itemView.findViewById(R.id.tools_tv_title);
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Tools;
import com.monsterlin.pigeon.ui.brower.BrowerActivity;
import com.monsterlin.pigeon.vholder.ToolsVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 工具板块适配器
*/
public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
private Context mContext ; | private List<Tools> toolsList; |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/ui/brower/BrowerActivity.java
// public class BrowerActivity extends BaseActivity {
//
// private Toolbar mToolBar;
// private String urlString;
//
// private ProgressWebView mProWebView;
//
// @Override
// public int getLayoutId() {
// return R.layout.activity_web_brower;
// }
//
// @Override
// public void initViews() {
// mToolBar = findView(R.id.common_toolbar);
// initToolBar(mToolBar, "飞鸽", true);
// mProWebView = findView(R.id.brower_pwv);
// }
//
// @Override
// public void initListener() {
//
// }
//
// @Override
// public void initData() {
// urlString = getIntent().getStringExtra("url");
// if (!TextUtils.isEmpty(urlString)){
// mProWebView.getSettings().setJavaScriptEnabled(true);
// mProWebView.loadUrl(urlString);
// }else {
// ToastUtils.showToast(this,"无数据显示");
// }
//
// }
//
// @Override
// public void processClick(View v) {
//
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(keyCode== KeyEvent.KEYCODE_BACK)
// {
// if(mProWebView.canGoBack())
// {
// mProWebView.goBack();//返回上一页面
// return true;
// }
// else
// {
// System.exit(0);//退出程序
// }
// }
// return super.onKeyDown(keyCode, event);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/ToolsVHolder.java
// public class ToolsVHolder extends RecyclerView.ViewHolder {
// public ImageView mIvIcon ;
// public TextView mTvTitle ;
//
// public ToolsVHolder(View itemView) {
// super(itemView);
// mIvIcon= (ImageView) itemView.findViewById(R.id.tools_iv_icon);
// mTvTitle= (TextView) itemView.findViewById(R.id.tools_tv_title);
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Tools;
import com.monsterlin.pigeon.ui.brower.BrowerActivity;
import com.monsterlin.pigeon.vholder.ToolsVHolder;
import com.squareup.picasso.Picasso;
import java.util.List; | package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 工具板块适配器
*/
public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
private Context mContext ;
private List<Tools> toolsList;
private LayoutInflater mInflater ;
public ToolsAdapter(Context mContext, List<Tools> toolsList) {
this.mContext = mContext;
this.toolsList = toolsList;
mInflater=LayoutInflater.from(mContext);
}
@Override
public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_tools,parent,false);
ToolsVHolder vHolder = new ToolsVHolder(view);
return vHolder;
}
@Override
public void onBindViewHolder(ToolsVHolder holder, final int position) {
holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
if (!TextUtils.isEmpty(iconUrl)){
Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Tools.java
// public class Tools extends BmobObject{
// private BmobFile toolsIcon ;
// private String toolsTitle ;
// private String toolsUrl ;
//
//
// public BmobFile getToolsIcon() {
// return toolsIcon;
// }
//
// public void setToolsIcon(BmobFile toolsIcon) {
// this.toolsIcon = toolsIcon;
// }
//
// public String getToolsTitle() {
// return toolsTitle;
// }
//
// public void setToolsTitle(String toolsTitle) {
// this.toolsTitle = toolsTitle;
// }
//
// public String getToolsUrl() {
// return toolsUrl;
// }
//
// public void setToolsUrl(String toolsUrl) {
// this.toolsUrl = toolsUrl;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/ui/brower/BrowerActivity.java
// public class BrowerActivity extends BaseActivity {
//
// private Toolbar mToolBar;
// private String urlString;
//
// private ProgressWebView mProWebView;
//
// @Override
// public int getLayoutId() {
// return R.layout.activity_web_brower;
// }
//
// @Override
// public void initViews() {
// mToolBar = findView(R.id.common_toolbar);
// initToolBar(mToolBar, "飞鸽", true);
// mProWebView = findView(R.id.brower_pwv);
// }
//
// @Override
// public void initListener() {
//
// }
//
// @Override
// public void initData() {
// urlString = getIntent().getStringExtra("url");
// if (!TextUtils.isEmpty(urlString)){
// mProWebView.getSettings().setJavaScriptEnabled(true);
// mProWebView.loadUrl(urlString);
// }else {
// ToastUtils.showToast(this,"无数据显示");
// }
//
// }
//
// @Override
// public void processClick(View v) {
//
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(keyCode== KeyEvent.KEYCODE_BACK)
// {
// if(mProWebView.canGoBack())
// {
// mProWebView.goBack();//返回上一页面
// return true;
// }
// else
// {
// System.exit(0);//退出程序
// }
// }
// return super.onKeyDown(keyCode, event);
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/ToolsVHolder.java
// public class ToolsVHolder extends RecyclerView.ViewHolder {
// public ImageView mIvIcon ;
// public TextView mTvTitle ;
//
// public ToolsVHolder(View itemView) {
// super(itemView);
// mIvIcon= (ImageView) itemView.findViewById(R.id.tools_iv_icon);
// mTvTitle= (TextView) itemView.findViewById(R.id.tools_tv_title);
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/adapter/ToolsAdapter.java
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Tools;
import com.monsterlin.pigeon.ui.brower.BrowerActivity;
import com.monsterlin.pigeon.vholder.ToolsVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/5
* @desc : 工具板块适配器
*/
public class ToolsAdapter extends RecyclerView.Adapter<ToolsVHolder> {
private Context mContext ;
private List<Tools> toolsList;
private LayoutInflater mInflater ;
public ToolsAdapter(Context mContext, List<Tools> toolsList) {
this.mContext = mContext;
this.toolsList = toolsList;
mInflater=LayoutInflater.from(mContext);
}
@Override
public ToolsVHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_tools,parent,false);
ToolsVHolder vHolder = new ToolsVHolder(view);
return vHolder;
}
@Override
public void onBindViewHolder(ToolsVHolder holder, final int position) {
holder.mTvTitle.setText(toolsList.get(position).getToolsTitle());
final String iconUrl = toolsList.get(position).getToolsIcon().getFileUrl();
if (!TextUtils.isEmpty(iconUrl)){
Picasso.with(mContext).load(iconUrl).into(holder.mIvIcon);
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { | Intent i = new Intent(mContext, BrowerActivity.class); |
monsterLin/Pigeon | app/src/main/java/com/monsterlin/pigeon/adapter/StickerAdapter.java | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Sticker.java
// public class Sticker extends BmobObject {
// private String content ;
// private Family family ; //所属家庭
// private User user ; //作者
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public Family getFamily() {
// return family;
// }
//
// public void setFamily(Family family) {
// this.family = family;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/StickerVHolder.java
// public class StickerVHolder extends RecyclerView.ViewHolder {
// public TextView mTvDate , mTvContent ,mTvNick ;
// public CircleImageView mCivUserPhoto ;
// public RelativeLayout mRlSticker;
//
// public StickerVHolder(View itemView) {
// super(itemView);
// mTvDate= (TextView) itemView.findViewById(R.id.sticker_tv_date);
// mTvContent= (TextView) itemView.findViewById(R.id.sticker_tv_content);
// mTvNick= (TextView) itemView.findViewById(R.id.sticker_tv_nick);
// mCivUserPhoto= (CircleImageView) itemView.findViewById(R.id.sticker_civ_userPhoto);
// mRlSticker= (RelativeLayout) itemView.findViewById(R.id.sticker_rl);
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Sticker;
import com.monsterlin.pigeon.vholder.StickerVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
import cn.bmob.v3.datatype.BmobFile; | package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/8
* @desc : 亲情贴适配器
*/
public class StickerAdapter extends RecyclerView.Adapter<StickerVHolder> {
private Context mContext ; | // Path: app/src/main/java/com/monsterlin/pigeon/bean/Sticker.java
// public class Sticker extends BmobObject {
// private String content ;
// private Family family ; //所属家庭
// private User user ; //作者
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public Family getFamily() {
// return family;
// }
//
// public void setFamily(Family family) {
// this.family = family;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: app/src/main/java/com/monsterlin/pigeon/vholder/StickerVHolder.java
// public class StickerVHolder extends RecyclerView.ViewHolder {
// public TextView mTvDate , mTvContent ,mTvNick ;
// public CircleImageView mCivUserPhoto ;
// public RelativeLayout mRlSticker;
//
// public StickerVHolder(View itemView) {
// super(itemView);
// mTvDate= (TextView) itemView.findViewById(R.id.sticker_tv_date);
// mTvContent= (TextView) itemView.findViewById(R.id.sticker_tv_content);
// mTvNick= (TextView) itemView.findViewById(R.id.sticker_tv_nick);
// mCivUserPhoto= (CircleImageView) itemView.findViewById(R.id.sticker_civ_userPhoto);
// mRlSticker= (RelativeLayout) itemView.findViewById(R.id.sticker_rl);
// }
// }
// Path: app/src/main/java/com/monsterlin/pigeon/adapter/StickerAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.monsterlin.pigeon.R;
import com.monsterlin.pigeon.bean.Sticker;
import com.monsterlin.pigeon.vholder.StickerVHolder;
import com.squareup.picasso.Picasso;
import java.util.List;
import cn.bmob.v3.datatype.BmobFile;
package com.monsterlin.pigeon.adapter;
/**
* @author : monsterLin
* @version : 1.0
* @email : monster941025@gmail.com
* @github : https://github.com/monsterLin
* @time : 2017/8/8
* @desc : 亲情贴适配器
*/
public class StickerAdapter extends RecyclerView.Adapter<StickerVHolder> {
private Context mContext ; | private List<Sticker> stickerList ; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/TigrisParser.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class TigrisParser extends BugTrackerParser {
public TigrisParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/TigrisParser.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class TigrisParser extends BugTrackerParser {
public TigrisParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | public List<Bug> getBugs() throws JDOMException, IOException { |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/source/VersionControlManager.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/util/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {
// }
//
// public static void deleteRecursive(File file) {
// if (file.exists()) {
// if (file.isDirectory()) {
// for (File f : file.listFiles()) {
// deleteRecursive(f);
// }
// }
// boolean deleted = file.delete();
// if (deleted)
// System.out.println(" deleted " + file.getAbsolutePath());
// else
// System.out.println(" NOT deleted " + file.getAbsolutePath());
// }
// }
// }
| import java.io.File;
import java.util.List;
import org.apache.tools.ant.DirectoryScanner;
import org.joda.time.DateMidnight;
import org.joda.time.Interval;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.util.FileUtils; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.source;
public abstract class VersionControlManager {
/**
* URL do repositorio.
*/
protected String repository_url;
/**
* Intervalo de tempo para o qual a analise deve ser feita.
*/
protected Interval time_interval;
/**
* Diretorio onde o codigo fonte sera baixado.
*/
protected File src_path;
protected VersionControlManager(String repository_url,
String start_date_str, String end_date_str) {
this.repository_url = repository_url;
this.time_interval = getIntervalFromParams(start_date_str, end_date_str);
}
/**
* Faz o download do codigo do fonte no repositorio, e armazena no local
* passado como parametro (path). Codigo baixado corresponde a versao do
* final do periodo.
*
* @param path
* diretorio onde codigo fonte sera armazenado.
*/
public abstract void downloadCode(File path) throws Exception;
/**
* Faz o download do log do repositorio
*
* @return
*/
public abstract List<Commit> getCommits();
public File getSrcPath() {
return src_path;
}
/**
* Remove as classes de teste do sistema, para que elas nao entrem na
* analise. Todos os diretorios cujo nome comeca com 'test' (test*) serão
* excluídos.
*/
public void removeTestClasses() {
System.out.println("Deleting test folders");
DirectoryScanner scanner = new DirectoryScanner();
String[] includes = { "**/test*" };
scanner.setIncludes(includes);
scanner.setBasedir(src_path);
scanner.setCaseSensitive(false);
scanner.scan();
String[] included_dirs = scanner.getIncludedDirectories();
for (String test_dir : included_dirs) {
File dirToDelete = new File(src_path, test_dir);
if (dirToDelete.exists()) | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/util/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {
// }
//
// public static void deleteRecursive(File file) {
// if (file.exists()) {
// if (file.isDirectory()) {
// for (File f : file.listFiles()) {
// deleteRecursive(f);
// }
// }
// boolean deleted = file.delete();
// if (deleted)
// System.out.println(" deleted " + file.getAbsolutePath());
// else
// System.out.println(" NOT deleted " + file.getAbsolutePath());
// }
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/source/VersionControlManager.java
import java.io.File;
import java.util.List;
import org.apache.tools.ant.DirectoryScanner;
import org.joda.time.DateMidnight;
import org.joda.time.Interval;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.util.FileUtils;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.source;
public abstract class VersionControlManager {
/**
* URL do repositorio.
*/
protected String repository_url;
/**
* Intervalo de tempo para o qual a analise deve ser feita.
*/
protected Interval time_interval;
/**
* Diretorio onde o codigo fonte sera baixado.
*/
protected File src_path;
protected VersionControlManager(String repository_url,
String start_date_str, String end_date_str) {
this.repository_url = repository_url;
this.time_interval = getIntervalFromParams(start_date_str, end_date_str);
}
/**
* Faz o download do codigo do fonte no repositorio, e armazena no local
* passado como parametro (path). Codigo baixado corresponde a versao do
* final do periodo.
*
* @param path
* diretorio onde codigo fonte sera armazenado.
*/
public abstract void downloadCode(File path) throws Exception;
/**
* Faz o download do log do repositorio
*
* @return
*/
public abstract List<Commit> getCommits();
public File getSrcPath() {
return src_path;
}
/**
* Remove as classes de teste do sistema, para que elas nao entrem na
* analise. Todos os diretorios cujo nome comeca com 'test' (test*) serão
* excluídos.
*/
public void removeTestClasses() {
System.out.println("Deleting test folders");
DirectoryScanner scanner = new DirectoryScanner();
String[] includes = { "**/test*" };
scanner.setIncludes(includes);
scanner.setBasedir(src_path);
scanner.setCaseSensitive(false);
scanner.scan();
String[] included_dirs = scanner.getIncludedDirectories();
for (String test_dir : included_dirs) {
File dirToDelete = new File(src_path, test_dir);
if (dirToDelete.exists()) | FileUtils.deleteRecursive(dirToDelete); |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/map/AbstractView.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/AbstractController.java
// public abstract class AbstractController implements Runnable {
//
// protected int numStages;
// protected int completedStages;
//
// protected List<File> failedProjects;
//
// protected String progressMessage;
//
// public AbstractController() {
// this.numStages = 0;
// this.completedStages = 0;
//
// this.failedProjects = new LinkedList<File>();
// }
//
// public int numStages() {
// return this.numStages;
// }
//
// protected void setNumStages(int numStages) {
// this.numStages = numStages;
// }
//
// public int numCompletedStages() {
// return this.completedStages;
// }
//
// protected void addCompletedStage() {
// this.completedStages++;
// }
//
// public List<File> getFailedProjects() {
// return this.failedProjects;
// }
//
// protected void addFailureProject(File failedProject) {
// this.failedProjects.add(failedProject);
// }
//
// public String getProgressMessage() {
// return this.progressMessage;
// }
//
// protected void setProgressMessage(String message) {
// this.progressMessage = message;
// }
//
// protected static void checkResultFolder(String folderName) {
// File resultFolder = new File(folderName);
// if (!resultFolder.exists()) resultFolder.mkdirs();
// }
// }
| import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.AbstractController; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.map;
public abstract class AbstractView extends JInternalFrame {
private static final long serialVersionUID = 4520698614926883560L;
protected Thread progressMonitorThread;
protected javax.swing.JProgressBar progressBar;
protected javax.swing.JButton startExecutionButton;
| // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/AbstractController.java
// public abstract class AbstractController implements Runnable {
//
// protected int numStages;
// protected int completedStages;
//
// protected List<File> failedProjects;
//
// protected String progressMessage;
//
// public AbstractController() {
// this.numStages = 0;
// this.completedStages = 0;
//
// this.failedProjects = new LinkedList<File>();
// }
//
// public int numStages() {
// return this.numStages;
// }
//
// protected void setNumStages(int numStages) {
// this.numStages = numStages;
// }
//
// public int numCompletedStages() {
// return this.completedStages;
// }
//
// protected void addCompletedStage() {
// this.completedStages++;
// }
//
// public List<File> getFailedProjects() {
// return this.failedProjects;
// }
//
// protected void addFailureProject(File failedProject) {
// this.failedProjects.add(failedProject);
// }
//
// public String getProgressMessage() {
// return this.progressMessage;
// }
//
// protected void setProgressMessage(String message) {
// this.progressMessage = message;
// }
//
// protected static void checkResultFolder(String folderName) {
// File resultFolder = new File(folderName);
// if (!resultFolder.exists()) resultFolder.mkdirs();
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/map/AbstractView.java
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.AbstractController;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.map;
public abstract class AbstractView extends JInternalFrame {
private static final long serialVersionUID = 4520698614926883560L;
protected Thread progressMonitorThread;
protected javax.swing.JProgressBar progressBar;
protected javax.swing.JButton startExecutionButton;
| protected AbstractController controller; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicFocus.java
// public class TopicFocus extends AbstractSemanticTopicMetric {
//
// public TopicFocus(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double focus = 0D;
// for (String packageName : this.distributionMap.getPackages())
// focus += this.calculateTopicTouch(topicIndex, packageName) * this.calculatePackageTouch(packageName, topicIndex);
// return focus;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
//
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicSpread.java
// public class TopicSpread extends AbstractSemanticTopicMetric {
//
// public TopicSpread(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double spread = 0D;
// for (String packageName : this.distributionMap.getPackages())
// spread += (this.calculateTopicTouch(topicIndex, packageName) > 0) ? 1 : 0;
// return spread;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
| import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicFocus;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicSpread; | double focus;
TopicInfo(double spread, double focus) {
this.spread = spread;
this.focus = focus;
}
}
public static DistributionMap generateDistributionMap(String projectName,
String[] documentIds, int[][] clusters) {
DistributionMap distributionMap = new DistributionMap(projectName);
for (int i = 0; i < clusters.length; i++) {
for (int documentId : clusters[i]) {
String document = documentIds[documentId];
String packageName = document.substring(0,
document.lastIndexOf(File.separatorChar)).replace(
File.separatorChar, '.');
String className = document;
distributionMap.put(packageName, className, i);
}
}
distributionMap = addSemanticClustersMetrics(distributionMap,
clusters.length);
distributionMap.organize();
return distributionMap;
}
public static DistributionMap addSemanticClustersMetrics(
DistributionMap distributionMap, int numClusters) { | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicFocus.java
// public class TopicFocus extends AbstractSemanticTopicMetric {
//
// public TopicFocus(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double focus = 0D;
// for (String packageName : this.distributionMap.getPackages())
// focus += this.calculateTopicTouch(topicIndex, packageName) * this.calculatePackageTouch(packageName, topicIndex);
// return focus;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
//
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicSpread.java
// public class TopicSpread extends AbstractSemanticTopicMetric {
//
// public TopicSpread(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double spread = 0D;
// for (String packageName : this.distributionMap.getPackages())
// spread += (this.calculateTopicTouch(topicIndex, packageName) > 0) ? 1 : 0;
// return spread;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicFocus;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicSpread;
double focus;
TopicInfo(double spread, double focus) {
this.spread = spread;
this.focus = focus;
}
}
public static DistributionMap generateDistributionMap(String projectName,
String[] documentIds, int[][] clusters) {
DistributionMap distributionMap = new DistributionMap(projectName);
for (int i = 0; i < clusters.length; i++) {
for (int documentId : clusters[i]) {
String document = documentIds[documentId];
String packageName = document.substring(0,
document.lastIndexOf(File.separatorChar)).replace(
File.separatorChar, '.');
String className = document;
distributionMap.put(packageName, className, i);
}
}
distributionMap = addSemanticClustersMetrics(distributionMap,
clusters.length);
distributionMap.organize();
return distributionMap;
}
public static DistributionMap addSemanticClustersMetrics(
DistributionMap distributionMap, int numClusters) { | Map<String, Double> spread = new TopicSpread(distributionMap, |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicFocus.java
// public class TopicFocus extends AbstractSemanticTopicMetric {
//
// public TopicFocus(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double focus = 0D;
// for (String packageName : this.distributionMap.getPackages())
// focus += this.calculateTopicTouch(topicIndex, packageName) * this.calculatePackageTouch(packageName, topicIndex);
// return focus;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
//
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicSpread.java
// public class TopicSpread extends AbstractSemanticTopicMetric {
//
// public TopicSpread(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double spread = 0D;
// for (String packageName : this.distributionMap.getPackages())
// spread += (this.calculateTopicTouch(topicIndex, packageName) > 0) ? 1 : 0;
// return spread;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
| import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicFocus;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicSpread; | TopicInfo(double spread, double focus) {
this.spread = spread;
this.focus = focus;
}
}
public static DistributionMap generateDistributionMap(String projectName,
String[] documentIds, int[][] clusters) {
DistributionMap distributionMap = new DistributionMap(projectName);
for (int i = 0; i < clusters.length; i++) {
for (int documentId : clusters[i]) {
String document = documentIds[documentId];
String packageName = document.substring(0,
document.lastIndexOf(File.separatorChar)).replace(
File.separatorChar, '.');
String className = document;
distributionMap.put(packageName, className, i);
}
}
distributionMap = addSemanticClustersMetrics(distributionMap,
clusters.length);
distributionMap.organize();
return distributionMap;
}
public static DistributionMap addSemanticClustersMetrics(
DistributionMap distributionMap, int numClusters) {
Map<String, Double> spread = new TopicSpread(distributionMap,
numClusters).calculate(); | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicFocus.java
// public class TopicFocus extends AbstractSemanticTopicMetric {
//
// public TopicFocus(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double focus = 0D;
// for (String packageName : this.distributionMap.getPackages())
// focus += this.calculateTopicTouch(topicIndex, packageName) * this.calculatePackageTouch(packageName, topicIndex);
// return focus;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
//
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/TopicSpread.java
// public class TopicSpread extends AbstractSemanticTopicMetric {
//
// public TopicSpread(DistributionMap distributionMap, int numClusters) {
// super(distributionMap, numClusters);
// }
//
// private double calculate(int topicIndex) {
// double spread = 0D;
// for (String packageName : this.distributionMap.getPackages())
// spread += (this.calculateTopicTouch(topicIndex, packageName) > 0) ? 1 : 0;
// return spread;
// }
//
// public Map<String, Double> calculate() {
// Map<String, Double> metricMapping = new HashMap<String, Double>();
// for (int topicIndex = 0; topicIndex < this.numClusters; topicIndex++)
// metricMapping.put(String.valueOf(topicIndex), calculate(topicIndex));
// return metricMapping;
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicFocus;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics.TopicSpread;
TopicInfo(double spread, double focus) {
this.spread = spread;
this.focus = focus;
}
}
public static DistributionMap generateDistributionMap(String projectName,
String[] documentIds, int[][] clusters) {
DistributionMap distributionMap = new DistributionMap(projectName);
for (int i = 0; i < clusters.length; i++) {
for (int documentId : clusters[i]) {
String document = documentIds[documentId];
String packageName = document.substring(0,
document.lastIndexOf(File.separatorChar)).replace(
File.separatorChar, '.');
String className = document;
distributionMap.put(packageName, className, i);
}
}
distributionMap = addSemanticClustersMetrics(distributionMap,
clusters.length);
distributionMap.organize();
return distributionMap;
}
public static DistributionMap addSemanticClustersMetrics(
DistributionMap distributionMap, int numClusters) {
Map<String, Double> spread = new TopicSpread(distributionMap,
numClusters).calculate(); | Map<String, Double> focus = new TopicFocus(distributionMap, numClusters) |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/AbstractSemanticTopicMetric.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
// public class DistributionMap {
// private String projectName;
// private Map<String, List<String>> packageMapping;
// private Map<String, Integer> classMapping;
// private Map<Integer, TopicInfo> topicMapping;
//
// private DistributionMap(String projectName) {
// this.projectName = projectName;
// this.packageMapping = new HashMap<String, List<String>>();
// this.classMapping = new HashMap<String, Integer>();
// this.topicMapping = new HashMap<Integer, TopicInfo>();
// }
//
// public void put(String packageName, String className, int clusterIndex) {
// List<String> classes = this.packageMapping.containsKey(packageName) ? (List<String>) this.packageMapping
// .get(packageName) : new LinkedList<String>();
// classes.add(className);
//
// this.packageMapping.put(packageName, classes);
// this.classMapping.put(className, Integer.valueOf(clusterIndex));
// }
//
// public void put(int clusterIndex, double spread, double focus) {
// this.topicMapping.put(Integer.valueOf(clusterIndex), new TopicInfo(
// spread, focus));
// }
//
// public String getProjectName() {
// return this.projectName;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public List<String> getPackages() {
// List<String> packages = new LinkedList<String>();
// packages.addAll(this.packageMapping.keySet());
//
// Collections.sort(packages, new Comparator() {
//
// @Override
// public int compare(Object package1, Object package2) {
// return Integer.compare(
// ((List<String>) DistributionMap.this.packageMapping
// .get(package2.toString())).size(),
// ((List<String>) DistributionMap.this.packageMapping
// .get(package1.toString())).size());
// }
// });
// return packages;
// }
//
// public List<String> getClasses(String packageName) {
// return (List<String>) this.packageMapping.get(packageName);
// }
//
// public Integer getCluster(String className) {
// return (Integer) this.classMapping.get(className);
// }
//
// public Double getSpread(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).spread);
// }
//
// public Double getFocus(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).focus);
// }
//
// public void organize() {
// for (String packageName : this.packageMapping.keySet()) {
// List<String> classes = (List<String>) this.packageMapping.get(packageName);
// Collections.sort(classes);
// }
// }
//
// static class TopicInfo {
// double spread;
// double focus;
//
// TopicInfo(double spread, double focus) {
// this.spread = spread;
// this.focus = focus;
// }
// }
//
// public static DistributionMap generateDistributionMap(String projectName,
// String[] documentIds, int[][] clusters) {
// DistributionMap distributionMap = new DistributionMap(projectName);
// for (int i = 0; i < clusters.length; i++) {
// for (int documentId : clusters[i]) {
// String document = documentIds[documentId];
// String packageName = document.substring(0,
// document.lastIndexOf(File.separatorChar)).replace(
// File.separatorChar, '.');
// String className = document;
//
// distributionMap.put(packageName, className, i);
// }
// }
// distributionMap = addSemanticClustersMetrics(distributionMap,
// clusters.length);
// distributionMap.organize();
// return distributionMap;
// }
//
// public static DistributionMap addSemanticClustersMetrics(
// DistributionMap distributionMap, int numClusters) {
// Map<String, Double> spread = new TopicSpread(distributionMap,
// numClusters).calculate();
// Map<String, Double> focus = new TopicFocus(distributionMap, numClusters)
// .calculate();
// for (int i = 0; i < numClusters; i++) {
// distributionMap.put(i,
// ((Double) spread.get(String.valueOf(i))).doubleValue(),
// ((Double) focus.get(String.valueOf(i))).doubleValue());
// }
// return distributionMap;
// }
// }
| import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.DistributionMap; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics;
public abstract class AbstractSemanticTopicMetric {
protected int numClusters; | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
// public class DistributionMap {
// private String projectName;
// private Map<String, List<String>> packageMapping;
// private Map<String, Integer> classMapping;
// private Map<Integer, TopicInfo> topicMapping;
//
// private DistributionMap(String projectName) {
// this.projectName = projectName;
// this.packageMapping = new HashMap<String, List<String>>();
// this.classMapping = new HashMap<String, Integer>();
// this.topicMapping = new HashMap<Integer, TopicInfo>();
// }
//
// public void put(String packageName, String className, int clusterIndex) {
// List<String> classes = this.packageMapping.containsKey(packageName) ? (List<String>) this.packageMapping
// .get(packageName) : new LinkedList<String>();
// classes.add(className);
//
// this.packageMapping.put(packageName, classes);
// this.classMapping.put(className, Integer.valueOf(clusterIndex));
// }
//
// public void put(int clusterIndex, double spread, double focus) {
// this.topicMapping.put(Integer.valueOf(clusterIndex), new TopicInfo(
// spread, focus));
// }
//
// public String getProjectName() {
// return this.projectName;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public List<String> getPackages() {
// List<String> packages = new LinkedList<String>();
// packages.addAll(this.packageMapping.keySet());
//
// Collections.sort(packages, new Comparator() {
//
// @Override
// public int compare(Object package1, Object package2) {
// return Integer.compare(
// ((List<String>) DistributionMap.this.packageMapping
// .get(package2.toString())).size(),
// ((List<String>) DistributionMap.this.packageMapping
// .get(package1.toString())).size());
// }
// });
// return packages;
// }
//
// public List<String> getClasses(String packageName) {
// return (List<String>) this.packageMapping.get(packageName);
// }
//
// public Integer getCluster(String className) {
// return (Integer) this.classMapping.get(className);
// }
//
// public Double getSpread(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).spread);
// }
//
// public Double getFocus(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).focus);
// }
//
// public void organize() {
// for (String packageName : this.packageMapping.keySet()) {
// List<String> classes = (List<String>) this.packageMapping.get(packageName);
// Collections.sort(classes);
// }
// }
//
// static class TopicInfo {
// double spread;
// double focus;
//
// TopicInfo(double spread, double focus) {
// this.spread = spread;
// this.focus = focus;
// }
// }
//
// public static DistributionMap generateDistributionMap(String projectName,
// String[] documentIds, int[][] clusters) {
// DistributionMap distributionMap = new DistributionMap(projectName);
// for (int i = 0; i < clusters.length; i++) {
// for (int documentId : clusters[i]) {
// String document = documentIds[documentId];
// String packageName = document.substring(0,
// document.lastIndexOf(File.separatorChar)).replace(
// File.separatorChar, '.');
// String className = document;
//
// distributionMap.put(packageName, className, i);
// }
// }
// distributionMap = addSemanticClustersMetrics(distributionMap,
// clusters.length);
// distributionMap.organize();
// return distributionMap;
// }
//
// public static DistributionMap addSemanticClustersMetrics(
// DistributionMap distributionMap, int numClusters) {
// Map<String, Double> spread = new TopicSpread(distributionMap,
// numClusters).calculate();
// Map<String, Double> focus = new TopicFocus(distributionMap, numClusters)
// .calculate();
// for (int i = 0; i < numClusters; i++) {
// distributionMap.put(i,
// ((Double) spread.get(String.valueOf(i))).doubleValue(),
// ((Double) focus.get(String.valueOf(i))).doubleValue());
// }
// return distributionMap;
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/metrics/AbstractSemanticTopicMetric.java
import java.util.List;
import java.util.Map;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.DistributionMap;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.metrics;
public abstract class AbstractSemanticTopicMetric {
protected int numClusters; | protected DistributionMap distributionMap; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/BugTrackerParser.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
| import java.io.IOException;
import java.util.List;
import org.jdom.JDOMException;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public abstract class BugTrackerParser {
protected String[] filename;
public BugTrackerParser(String[] filename) {
this.filename = filename;
}
| // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/BugTrackerParser.java
import java.io.IOException;
import java.util.List;
import org.jdom.JDOMException;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public abstract class BugTrackerParser {
protected String[] filename;
public BugTrackerParser(String[] filename) {
this.filename = filename;
}
| public abstract List<Bug> getBugs() throws JDOMException, IOException; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/JiraParser.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class JiraParser extends BugTrackerParser {
public JiraParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/JiraParser.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class JiraParser extends BugTrackerParser {
public JiraParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | public List<Bug> getBugs() throws JDOMException, IOException { |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/util/HashCodeUtils.java
// public final class HashCodeUtils {
//
// /**
// * An initial value for a <code>hashCode</code>, to which is added
// * contributions from fields. Using a non-zero value decreases collisons of
// * <code>hashCode</code> values.
// */
// public static final int SEED = 23;
//
// /**
// * booleans.
// */
// public static int hash(int aSeed, boolean aBoolean) {
// return firstTerm(aSeed) + (aBoolean ? 1 : 0);
// }
//
// /**
// * chars.
// */
// public static int hash(int aSeed, char aChar) {
// return firstTerm(aSeed) + aChar;
// }
//
// /**
// * ints.
// */
// public static int hash(int aSeed, int aInt) {
// /*
// * Implementation Note Note that byte and short are handled by this
// * method, through implicit conversion.
// */
// return firstTerm(aSeed) + aInt;
// }
//
// /**
// * longs.
// */
// public static int hash(int aSeed, long aLong) {
// return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32));
// }
//
// /**
// * floats.
// */
// public static int hash(int aSeed, float aFloat) {
// return hash(aSeed, Float.floatToIntBits(aFloat));
// }
//
// /**
// * doubles.
// */
// public static int hash(int aSeed, double aDouble) {
// return hash(aSeed, Double.doubleToLongBits(aDouble));
// }
//
// /**
// * <code>aObject</code> is a possibly-null object field, and possibly an
// * array.
// *
// * If <code>aObject</code> is an array, then each element may be a primitive
// * or a possibly-null object.
// */
// public static int hash(int aSeed, Object aObject) {
// int result = aSeed;
// if (aObject == null) {
// result = hash(result, 0);
// } else if (!isArray(aObject)) {
// result = hash(result, aObject.hashCode());
// } else {
// int length = Array.getLength(aObject);
// for (int idx = 0; idx < length; ++idx) {
// Object item = Array.get(aObject, idx);
// // recursive call!
// result = hash(result, item);
// }
// }
// return result;
// }
//
// // / PRIVATE ///
// private static final int fODD_PRIME_NUMBER = 37;
//
// private static int firstTerm(int aSeed) {
// return fODD_PRIME_NUMBER * aSeed;
// }
//
// private static boolean isArray(Object aObject) {
// return aObject.getClass().isArray();
// }
// }
| import java.util.HashSet;
import java.util.Set;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.util.HashCodeUtils; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug;
public class Bug {
private String id;
private String text;
private Set<String> modifiedFiles;
@Override
public int hashCode() { | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/util/HashCodeUtils.java
// public final class HashCodeUtils {
//
// /**
// * An initial value for a <code>hashCode</code>, to which is added
// * contributions from fields. Using a non-zero value decreases collisons of
// * <code>hashCode</code> values.
// */
// public static final int SEED = 23;
//
// /**
// * booleans.
// */
// public static int hash(int aSeed, boolean aBoolean) {
// return firstTerm(aSeed) + (aBoolean ? 1 : 0);
// }
//
// /**
// * chars.
// */
// public static int hash(int aSeed, char aChar) {
// return firstTerm(aSeed) + aChar;
// }
//
// /**
// * ints.
// */
// public static int hash(int aSeed, int aInt) {
// /*
// * Implementation Note Note that byte and short are handled by this
// * method, through implicit conversion.
// */
// return firstTerm(aSeed) + aInt;
// }
//
// /**
// * longs.
// */
// public static int hash(int aSeed, long aLong) {
// return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32));
// }
//
// /**
// * floats.
// */
// public static int hash(int aSeed, float aFloat) {
// return hash(aSeed, Float.floatToIntBits(aFloat));
// }
//
// /**
// * doubles.
// */
// public static int hash(int aSeed, double aDouble) {
// return hash(aSeed, Double.doubleToLongBits(aDouble));
// }
//
// /**
// * <code>aObject</code> is a possibly-null object field, and possibly an
// * array.
// *
// * If <code>aObject</code> is an array, then each element may be a primitive
// * or a possibly-null object.
// */
// public static int hash(int aSeed, Object aObject) {
// int result = aSeed;
// if (aObject == null) {
// result = hash(result, 0);
// } else if (!isArray(aObject)) {
// result = hash(result, aObject.hashCode());
// } else {
// int length = Array.getLength(aObject);
// for (int idx = 0; idx < length; ++idx) {
// Object item = Array.get(aObject, idx);
// // recursive call!
// result = hash(result, item);
// }
// }
// return result;
// }
//
// // / PRIVATE ///
// private static final int fODD_PRIME_NUMBER = 37;
//
// private static int firstTerm(int aSeed) {
// return fODD_PRIME_NUMBER * aSeed;
// }
//
// private static boolean isArray(Object aObject) {
// return aObject.getClass().isArray();
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
import java.util.HashSet;
import java.util.Set;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.util.HashCodeUtils;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug;
public class Bug {
private String id;
private String text;
private Set<String> modifiedFiles;
@Override
public int hashCode() { | int result = HashCodeUtils.SEED; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/map/DistributionMapPanel.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
// public class DistributionMap {
// private String projectName;
// private Map<String, List<String>> packageMapping;
// private Map<String, Integer> classMapping;
// private Map<Integer, TopicInfo> topicMapping;
//
// private DistributionMap(String projectName) {
// this.projectName = projectName;
// this.packageMapping = new HashMap<String, List<String>>();
// this.classMapping = new HashMap<String, Integer>();
// this.topicMapping = new HashMap<Integer, TopicInfo>();
// }
//
// public void put(String packageName, String className, int clusterIndex) {
// List<String> classes = this.packageMapping.containsKey(packageName) ? (List<String>) this.packageMapping
// .get(packageName) : new LinkedList<String>();
// classes.add(className);
//
// this.packageMapping.put(packageName, classes);
// this.classMapping.put(className, Integer.valueOf(clusterIndex));
// }
//
// public void put(int clusterIndex, double spread, double focus) {
// this.topicMapping.put(Integer.valueOf(clusterIndex), new TopicInfo(
// spread, focus));
// }
//
// public String getProjectName() {
// return this.projectName;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public List<String> getPackages() {
// List<String> packages = new LinkedList<String>();
// packages.addAll(this.packageMapping.keySet());
//
// Collections.sort(packages, new Comparator() {
//
// @Override
// public int compare(Object package1, Object package2) {
// return Integer.compare(
// ((List<String>) DistributionMap.this.packageMapping
// .get(package2.toString())).size(),
// ((List<String>) DistributionMap.this.packageMapping
// .get(package1.toString())).size());
// }
// });
// return packages;
// }
//
// public List<String> getClasses(String packageName) {
// return (List<String>) this.packageMapping.get(packageName);
// }
//
// public Integer getCluster(String className) {
// return (Integer) this.classMapping.get(className);
// }
//
// public Double getSpread(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).spread);
// }
//
// public Double getFocus(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).focus);
// }
//
// public void organize() {
// for (String packageName : this.packageMapping.keySet()) {
// List<String> classes = (List<String>) this.packageMapping.get(packageName);
// Collections.sort(classes);
// }
// }
//
// static class TopicInfo {
// double spread;
// double focus;
//
// TopicInfo(double spread, double focus) {
// this.spread = spread;
// this.focus = focus;
// }
// }
//
// public static DistributionMap generateDistributionMap(String projectName,
// String[] documentIds, int[][] clusters) {
// DistributionMap distributionMap = new DistributionMap(projectName);
// for (int i = 0; i < clusters.length; i++) {
// for (int documentId : clusters[i]) {
// String document = documentIds[documentId];
// String packageName = document.substring(0,
// document.lastIndexOf(File.separatorChar)).replace(
// File.separatorChar, '.');
// String className = document;
//
// distributionMap.put(packageName, className, i);
// }
// }
// distributionMap = addSemanticClustersMetrics(distributionMap,
// clusters.length);
// distributionMap.organize();
// return distributionMap;
// }
//
// public static DistributionMap addSemanticClustersMetrics(
// DistributionMap distributionMap, int numClusters) {
// Map<String, Double> spread = new TopicSpread(distributionMap,
// numClusters).calculate();
// Map<String, Double> focus = new TopicFocus(distributionMap, numClusters)
// .calculate();
// for (int i = 0; i < numClusters; i++) {
// distributionMap.put(i,
// ((Double) spread.get(String.valueOf(i))).doubleValue(),
// ((Double) focus.get(String.valueOf(i))).doubleValue());
// }
// return distributionMap;
// }
// }
| import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.ToolTipManager;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.DistributionMap; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.map;
public class DistributionMapPanel extends JPanel {
private static final long serialVersionUID = 6060506974958934930L;
private static final Integer packageStroke = 3;
private static final Integer packageSpace = 8;
private static final Integer classStroke = 2;
private static final Integer classSpace = 3;
private static final Integer classSize = 17;
private static final Integer maxPackages = 10;
private static final Integer maxClasses = 5; | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/control/DistributionMap.java
// public class DistributionMap {
// private String projectName;
// private Map<String, List<String>> packageMapping;
// private Map<String, Integer> classMapping;
// private Map<Integer, TopicInfo> topicMapping;
//
// private DistributionMap(String projectName) {
// this.projectName = projectName;
// this.packageMapping = new HashMap<String, List<String>>();
// this.classMapping = new HashMap<String, Integer>();
// this.topicMapping = new HashMap<Integer, TopicInfo>();
// }
//
// public void put(String packageName, String className, int clusterIndex) {
// List<String> classes = this.packageMapping.containsKey(packageName) ? (List<String>) this.packageMapping
// .get(packageName) : new LinkedList<String>();
// classes.add(className);
//
// this.packageMapping.put(packageName, classes);
// this.classMapping.put(className, Integer.valueOf(clusterIndex));
// }
//
// public void put(int clusterIndex, double spread, double focus) {
// this.topicMapping.put(Integer.valueOf(clusterIndex), new TopicInfo(
// spread, focus));
// }
//
// public String getProjectName() {
// return this.projectName;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public List<String> getPackages() {
// List<String> packages = new LinkedList<String>();
// packages.addAll(this.packageMapping.keySet());
//
// Collections.sort(packages, new Comparator() {
//
// @Override
// public int compare(Object package1, Object package2) {
// return Integer.compare(
// ((List<String>) DistributionMap.this.packageMapping
// .get(package2.toString())).size(),
// ((List<String>) DistributionMap.this.packageMapping
// .get(package1.toString())).size());
// }
// });
// return packages;
// }
//
// public List<String> getClasses(String packageName) {
// return (List<String>) this.packageMapping.get(packageName);
// }
//
// public Integer getCluster(String className) {
// return (Integer) this.classMapping.get(className);
// }
//
// public Double getSpread(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).spread);
// }
//
// public Double getFocus(int clusterIndex) {
// return Double.valueOf(((TopicInfo) this.topicMapping.get(Integer
// .valueOf(clusterIndex))).focus);
// }
//
// public void organize() {
// for (String packageName : this.packageMapping.keySet()) {
// List<String> classes = (List<String>) this.packageMapping.get(packageName);
// Collections.sort(classes);
// }
// }
//
// static class TopicInfo {
// double spread;
// double focus;
//
// TopicInfo(double spread, double focus) {
// this.spread = spread;
// this.focus = focus;
// }
// }
//
// public static DistributionMap generateDistributionMap(String projectName,
// String[] documentIds, int[][] clusters) {
// DistributionMap distributionMap = new DistributionMap(projectName);
// for (int i = 0; i < clusters.length; i++) {
// for (int documentId : clusters[i]) {
// String document = documentIds[documentId];
// String packageName = document.substring(0,
// document.lastIndexOf(File.separatorChar)).replace(
// File.separatorChar, '.');
// String className = document;
//
// distributionMap.put(packageName, className, i);
// }
// }
// distributionMap = addSemanticClustersMetrics(distributionMap,
// clusters.length);
// distributionMap.organize();
// return distributionMap;
// }
//
// public static DistributionMap addSemanticClustersMetrics(
// DistributionMap distributionMap, int numClusters) {
// Map<String, Double> spread = new TopicSpread(distributionMap,
// numClusters).calculate();
// Map<String, Double> focus = new TopicFocus(distributionMap, numClusters)
// .calculate();
// for (int i = 0; i < numClusters; i++) {
// distributionMap.put(i,
// ((Double) spread.get(String.valueOf(i))).doubleValue(),
// ((Double) focus.get(String.valueOf(i))).doubleValue());
// }
// return distributionMap;
// }
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/distribution/map/DistributionMapPanel.java
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.ToolTipManager;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.control.DistributionMap;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.distribution.map;
public class DistributionMapPanel extends JPanel {
private static final long serialVersionUID = 6060506974958934930L;
private static final Integer packageStroke = 3;
private static final Integer packageSpace = 8;
private static final Integer classStroke = 2;
private static final Integer classSpace = 3;
private static final Integer classSize = 17;
private static final Integer maxPackages = 10;
private static final Integer maxClasses = 5; | private DistributionMap distributionMap; |
aserg-ufmg/ModularityCheck | modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/BugzillaXMLParser.java | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug; | package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class BugzillaXMLParser extends BugTrackerParser {
public BugzillaXMLParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | // Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/Bug.java
// public class Bug {
//
// private String id;
// private String text;
// private Set<String> modifiedFiles;
//
// @Override
// public int hashCode() {
// int result = HashCodeUtils.SEED;
// result = HashCodeUtils.hash(result, id);
// return result;
// }
//
// public Bug(String id) {
// this.id = id;
// text = "";
// modifiedFiles = new HashSet<String>();
// }
//
// public String getId() {
// return id;
// }
//
// public String getText() {
// return text;
// }
//
// public Set<String> getModifiedFiles() {
// return modifiedFiles;
// }
//
// public void addFile(String file) {
// this.modifiedFiles.add(file);
// }
//
// public void addText(String text) {
// this.text += text;
// }
//
// }
// Path: modularitycheck/src/br/ufmg/dcc/labsoft/aserg/modularitycheck/bugparser/model/bug/parser/BugzillaXMLParser.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.Bug;
package br.ufmg.dcc.labsoft.aserg.modularitycheck.bugparser.model.bug.parser;
public class BugzillaXMLParser extends BugTrackerParser {
public BugzillaXMLParser(String[] filename) {
super(filename);
}
@SuppressWarnings("rawtypes")
@Override | public List<Bug> getBugs() throws JDOMException, IOException { |
yangyong915/app | MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/ItemListActivity.java | // Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.activity.simple.dummy.DummyContent;
import java.util.List; | package com.example.administrator.myapplication.activity.simple;
/**
* An activity representing a list of Items. This activity
* has different presentations for handset and tablet-size devices. On
* handsets, the activity presents a list of items, which when touched,
* lead to a {@link ItemDetailActivity} representing
* item details. On tablets, the activity presents the list of items and
* item details side-by-side using two vertical panes.
*/
public class ItemListActivity extends AppCompatActivity {
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
* device.
*/
private boolean mTwoPane;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
View recyclerView = findViewById(R.id.item_list);
assert recyclerView != null;
setupRecyclerView((RecyclerView) recyclerView);
if (findViewById(R.id.item_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-w900dp).
// If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
}
}
private void setupRecyclerView(@NonNull RecyclerView recyclerView) { | // Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
// Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/ItemListActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.activity.simple.dummy.DummyContent;
import java.util.List;
package com.example.administrator.myapplication.activity.simple;
/**
* An activity representing a list of Items. This activity
* has different presentations for handset and tablet-size devices. On
* handsets, the activity presents a list of items, which when touched,
* lead to a {@link ItemDetailActivity} representing
* item details. On tablets, the activity presents the list of items and
* item details side-by-side using two vertical panes.
*/
public class ItemListActivity extends AppCompatActivity {
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
* device.
*/
private boolean mTwoPane;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
View recyclerView = findViewById(R.id.item_list);
assert recyclerView != null;
setupRecyclerView((RecyclerView) recyclerView);
if (findViewById(R.id.item_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-w900dp).
// If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
}
}
private void setupRecyclerView(@NonNull RecyclerView recyclerView) { | recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(DummyContent.ITEMS)); |
yangyong915/app | MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/ItemDetailFragment.java | // Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
| import android.app.Activity;
import android.support.design.widget.CollapsingToolbarLayout;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.activity.simple.dummy.DummyContent; | package com.example.administrator.myapplication.activity.simple;
/**
* A fragment representing a single Item detail screen.
* This fragment is either contained in a {@link ItemListActivity}
* in two-pane mode (on tablets) or a {@link ItemDetailActivity}
* on handsets.
*/
public class ItemDetailFragment extends Fragment {
/**
* The fragment argument representing the item ID that this fragment
* represents.
*/
public static final String ARG_ITEM_ID = "item_id";
/**
* The dummy content this fragment is presenting.
*/ | // Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
// Path: MyApplication/app/src/main/java/com/example/administrator/myapplication/activity/simple/ItemDetailFragment.java
import android.app.Activity;
import android.support.design.widget.CollapsingToolbarLayout;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.activity.simple.dummy.DummyContent;
package com.example.administrator.myapplication.activity.simple;
/**
* A fragment representing a single Item detail screen.
* This fragment is either contained in a {@link ItemListActivity}
* in two-pane mode (on tablets) or a {@link ItemDetailActivity}
* on handsets.
*/
public class ItemDetailFragment extends Fragment {
/**
* The fragment argument representing the item ID that this fragment
* represents.
*/
public static final String ARG_ITEM_ID = "item_id";
/**
* The dummy content this fragment is presenting.
*/ | private DummyContent.DummyItem mItem; |
google/google-authenticator | mobile/blackberry/src/org/bouncycastle/crypto/macs/HMac.java | // Path: mobile/blackberry/src/org/bouncycastle/crypto/ExtendedDigest.java
// public interface ExtendedDigest
// extends Digest
// {
// /**
// * Return the size in bytes of the internal buffer the digest applies it's compression
// * function to.
// *
// * @return byte length of the digests internal buffer.
// */
// public int getByteLength();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/params/KeyParameter.java
// public class KeyParameter
// implements CipherParameters
// {
// private byte[] key;
//
// public KeyParameter(
// byte[] key)
// {
// this(key, 0, key.length);
// }
//
// public KeyParameter(
// byte[] key,
// int keyOff,
// int keyLen)
// {
// this.key = new byte[keyLen];
//
// System.arraycopy(key, keyOff, this.key, 0, keyLen);
// }
//
// public byte[] getKey()
// {
// return key;
// }
// }
| import java.util.Hashtable;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter; | private byte[] outputPad;
private static Hashtable blockLengths;
static
{
blockLengths = new Hashtable();
blockLengths.put("GOST3411", new Integer(32));
blockLengths.put("MD2", new Integer(16));
blockLengths.put("MD4", new Integer(64));
blockLengths.put("MD5", new Integer(64));
blockLengths.put("RIPEMD128", new Integer(64));
blockLengths.put("RIPEMD160", new Integer(64));
blockLengths.put("SHA-1", new Integer(64));
blockLengths.put("SHA-224", new Integer(64));
blockLengths.put("SHA-256", new Integer(64));
blockLengths.put("SHA-384", new Integer(128));
blockLengths.put("SHA-512", new Integer(128));
blockLengths.put("Tiger", new Integer(64));
blockLengths.put("Whirlpool", new Integer(64));
}
private static int getByteLength(
Digest digest)
{ | // Path: mobile/blackberry/src/org/bouncycastle/crypto/ExtendedDigest.java
// public interface ExtendedDigest
// extends Digest
// {
// /**
// * Return the size in bytes of the internal buffer the digest applies it's compression
// * function to.
// *
// * @return byte length of the digests internal buffer.
// */
// public int getByteLength();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/params/KeyParameter.java
// public class KeyParameter
// implements CipherParameters
// {
// private byte[] key;
//
// public KeyParameter(
// byte[] key)
// {
// this(key, 0, key.length);
// }
//
// public KeyParameter(
// byte[] key,
// int keyOff,
// int keyLen)
// {
// this.key = new byte[keyLen];
//
// System.arraycopy(key, keyOff, this.key, 0, keyLen);
// }
//
// public byte[] getKey()
// {
// return key;
// }
// }
// Path: mobile/blackberry/src/org/bouncycastle/crypto/macs/HMac.java
import java.util.Hashtable;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter;
private byte[] outputPad;
private static Hashtable blockLengths;
static
{
blockLengths = new Hashtable();
blockLengths.put("GOST3411", new Integer(32));
blockLengths.put("MD2", new Integer(16));
blockLengths.put("MD4", new Integer(64));
blockLengths.put("MD5", new Integer(64));
blockLengths.put("RIPEMD128", new Integer(64));
blockLengths.put("RIPEMD160", new Integer(64));
blockLengths.put("SHA-1", new Integer(64));
blockLengths.put("SHA-224", new Integer(64));
blockLengths.put("SHA-256", new Integer(64));
blockLengths.put("SHA-384", new Integer(128));
blockLengths.put("SHA-512", new Integer(128));
blockLengths.put("Tiger", new Integer(64));
blockLengths.put("Whirlpool", new Integer(64));
}
private static int getByteLength(
Digest digest)
{ | if (digest instanceof ExtendedDigest) |
google/google-authenticator | mobile/blackberry/src/org/bouncycastle/crypto/macs/HMac.java | // Path: mobile/blackberry/src/org/bouncycastle/crypto/ExtendedDigest.java
// public interface ExtendedDigest
// extends Digest
// {
// /**
// * Return the size in bytes of the internal buffer the digest applies it's compression
// * function to.
// *
// * @return byte length of the digests internal buffer.
// */
// public int getByteLength();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/params/KeyParameter.java
// public class KeyParameter
// implements CipherParameters
// {
// private byte[] key;
//
// public KeyParameter(
// byte[] key)
// {
// this(key, 0, key.length);
// }
//
// public KeyParameter(
// byte[] key,
// int keyOff,
// int keyLen)
// {
// this.key = new byte[keyLen];
//
// System.arraycopy(key, keyOff, this.key, 0, keyLen);
// }
//
// public byte[] getKey()
// {
// return key;
// }
// }
| import java.util.Hashtable;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter; | }
private HMac(
Digest digest,
int byteLength)
{
this.digest = digest;
digestSize = digest.getDigestSize();
this.blockLength = byteLength;
inputPad = new byte[blockLength];
outputPad = new byte[blockLength];
}
public String getAlgorithmName()
{
return digest.getAlgorithmName() + "/HMAC";
}
public Digest getUnderlyingDigest()
{
return digest;
}
public void init(
CipherParameters params)
{
digest.reset();
| // Path: mobile/blackberry/src/org/bouncycastle/crypto/ExtendedDigest.java
// public interface ExtendedDigest
// extends Digest
// {
// /**
// * Return the size in bytes of the internal buffer the digest applies it's compression
// * function to.
// *
// * @return byte length of the digests internal buffer.
// */
// public int getByteLength();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
//
// Path: mobile/blackberry/src/org/bouncycastle/crypto/params/KeyParameter.java
// public class KeyParameter
// implements CipherParameters
// {
// private byte[] key;
//
// public KeyParameter(
// byte[] key)
// {
// this(key, 0, key.length);
// }
//
// public KeyParameter(
// byte[] key,
// int keyOff,
// int keyLen)
// {
// this.key = new byte[keyLen];
//
// System.arraycopy(key, keyOff, this.key, 0, keyLen);
// }
//
// public byte[] getKey()
// {
// return key;
// }
// }
// Path: mobile/blackberry/src/org/bouncycastle/crypto/macs/HMac.java
import java.util.Hashtable;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter;
}
private HMac(
Digest digest,
int byteLength)
{
this.digest = digest;
digestSize = digest.getDigestSize();
this.blockLength = byteLength;
inputPad = new byte[blockLength];
outputPad = new byte[blockLength];
}
public String getAlgorithmName()
{
return digest.getAlgorithmName() + "/HMAC";
}
public Digest getUnderlyingDigest()
{
return digest;
}
public void init(
CipherParameters params)
{
digest.reset();
| byte[] key = ((KeyParameter)params).getKey(); |
google/google-authenticator | mobile/blackberry/src/org/bouncycastle/crypto/digests/SHA1Digest.java | // Path: mobile/blackberry/src/org/bouncycastle/crypto/util/Pack.java
// public abstract class Pack
// {
// public static int bigEndianToInt(byte[] bs, int off)
// {
// int n = bs[ off] << 24;
// n |= (bs[++off] & 0xff) << 16;
// n |= (bs[++off] & 0xff) << 8;
// n |= (bs[++off] & 0xff);
// return n;
// }
//
// public static void intToBigEndian(int n, byte[] bs, int off)
// {
// bs[ off] = (byte)(n >>> 24);
// bs[++off] = (byte)(n >>> 16);
// bs[++off] = (byte)(n >>> 8);
// bs[++off] = (byte)(n );
// }
//
// public static long bigEndianToLong(byte[] bs, int off)
// {
// int hi = bigEndianToInt(bs, off);
// int lo = bigEndianToInt(bs, off + 4);
// return ((long)(hi & 0xffffffffL) << 32) | (long)(lo & 0xffffffffL);
// }
//
// public static void longToBigEndian(long n, byte[] bs, int off)
// {
// intToBigEndian((int)(n >>> 32), bs, off);
// intToBigEndian((int)(n & 0xffffffffL), bs, off + 4);
// }
// }
| import org.bouncycastle.crypto.util.Pack; | int n = in[ inOff] << 24;
n |= (in[++inOff] & 0xff) << 16;
n |= (in[++inOff] & 0xff) << 8;
n |= (in[++inOff] & 0xff);
X[xOff] = n;
if (++xOff == 16)
{
processBlock();
}
}
protected void processLength(
long bitLength)
{
if (xOff > 14)
{
processBlock();
}
X[14] = (int)(bitLength >>> 32);
X[15] = (int)(bitLength & 0xffffffff);
}
public int doFinal(
byte[] out,
int outOff)
{
finish();
| // Path: mobile/blackberry/src/org/bouncycastle/crypto/util/Pack.java
// public abstract class Pack
// {
// public static int bigEndianToInt(byte[] bs, int off)
// {
// int n = bs[ off] << 24;
// n |= (bs[++off] & 0xff) << 16;
// n |= (bs[++off] & 0xff) << 8;
// n |= (bs[++off] & 0xff);
// return n;
// }
//
// public static void intToBigEndian(int n, byte[] bs, int off)
// {
// bs[ off] = (byte)(n >>> 24);
// bs[++off] = (byte)(n >>> 16);
// bs[++off] = (byte)(n >>> 8);
// bs[++off] = (byte)(n );
// }
//
// public static long bigEndianToLong(byte[] bs, int off)
// {
// int hi = bigEndianToInt(bs, off);
// int lo = bigEndianToInt(bs, off + 4);
// return ((long)(hi & 0xffffffffL) << 32) | (long)(lo & 0xffffffffL);
// }
//
// public static void longToBigEndian(long n, byte[] bs, int off)
// {
// intToBigEndian((int)(n >>> 32), bs, off);
// intToBigEndian((int)(n & 0xffffffffL), bs, off + 4);
// }
// }
// Path: mobile/blackberry/src/org/bouncycastle/crypto/digests/SHA1Digest.java
import org.bouncycastle.crypto.util.Pack;
int n = in[ inOff] << 24;
n |= (in[++inOff] & 0xff) << 16;
n |= (in[++inOff] & 0xff) << 8;
n |= (in[++inOff] & 0xff);
X[xOff] = n;
if (++xOff == 16)
{
processBlock();
}
}
protected void processLength(
long bitLength)
{
if (xOff > 14)
{
processBlock();
}
X[14] = (int)(bitLength >>> 32);
X[15] = (int)(bitLength & 0xffffffff);
}
public int doFinal(
byte[] out,
int outOff)
{
finish();
| Pack.intToBigEndian(H1, out, outOff); |
google/google-authenticator | mobile/blackberry/src/com/google/authenticator/blackberry/PasscodeGenerator.java | // Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import org.bouncycastle.crypto.Mac; | /*-
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.authenticator.blackberry;
/**
* An implementation of the HOTP generator specified by RFC 4226. Generates
* short passcodes that may be used in challenge-response protocols or as
* timeout passcodes that are only valid for a short period.
*
* The default passcode is a 6-digit decimal code and the default timeout
* period is 5 minutes.
*/
public class PasscodeGenerator {
/** Default decimal passcode length */
private static final int PASS_CODE_LENGTH = 6;
/** Default passcode timeout period (in seconds) */
private static final int INTERVAL = 30;
/** The number of previous and future intervals to check */
private static final int ADJACENT_INTERVALS = 1;
private static final int PIN_MODULO = pow(10, PASS_CODE_LENGTH);
private static final int pow(int a, int b) {
int result = 1;
for (int i = 0; i < b; i++) {
result *= a;
}
return result;
}
private final Signer signer;
private final int codeLength;
private final int intervalPeriod;
/*
* Using an interface to allow us to inject different signature
* implementations.
*/
interface Signer {
byte[] sign(byte[] data);
}
/**
* @param mac A {@link Mac} used to generate passcodes
*/ | // Path: mobile/blackberry/src/org/bouncycastle/crypto/Mac.java
// public interface Mac
// {
// /**
// * Initialise the MAC.
// *
// * @param params the key and other data required by the MAC.
// * @exception IllegalArgumentException if the params argument is
// * inappropriate.
// */
// public void init(CipherParameters params)
// throws IllegalArgumentException;
//
// /**
// * Return the name of the algorithm the MAC implements.
// *
// * @return the name of the algorithm the MAC implements.
// */
// public String getAlgorithmName();
//
// /**
// * Return the block size for this MAC (in bytes).
// *
// * @return the block size for this MAC in bytes.
// */
// public int getMacSize();
//
// /**
// * add a single byte to the mac for processing.
// *
// * @param in the byte to be processed.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public void update(byte in)
// throws IllegalStateException;
//
// /**
// * @param in the array containing the input.
// * @param inOff the index in the array the data begins at.
// * @param len the length of the input starting at inOff.
// * @exception IllegalStateException if the MAC is not initialised.
// * @exception DataLengthException if there isn't enough data in in.
// */
// public void update(byte[] in, int inOff, int len)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Compute the final stage of the MAC writing the output to the out
// * parameter.
// * <p>
// * doFinal leaves the MAC in the same state it was after the last init.
// *
// * @param out the array the MAC is to be output to.
// * @param outOff the offset into the out buffer the output is to start at.
// * @exception DataLengthException if there isn't enough space in out.
// * @exception IllegalStateException if the MAC is not initialised.
// */
// public int doFinal(byte[] out, int outOff)
// throws DataLengthException, IllegalStateException;
//
// /**
// * Reset the MAC. At the end of resetting the MAC should be in the
// * in the same state it was after the last init (if there was one).
// */
// public void reset();
// }
// Path: mobile/blackberry/src/com/google/authenticator/blackberry/PasscodeGenerator.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import org.bouncycastle.crypto.Mac;
/*-
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.authenticator.blackberry;
/**
* An implementation of the HOTP generator specified by RFC 4226. Generates
* short passcodes that may be used in challenge-response protocols or as
* timeout passcodes that are only valid for a short period.
*
* The default passcode is a 6-digit decimal code and the default timeout
* period is 5 minutes.
*/
public class PasscodeGenerator {
/** Default decimal passcode length */
private static final int PASS_CODE_LENGTH = 6;
/** Default passcode timeout period (in seconds) */
private static final int INTERVAL = 30;
/** The number of previous and future intervals to check */
private static final int ADJACENT_INTERVALS = 1;
private static final int PIN_MODULO = pow(10, PASS_CODE_LENGTH);
private static final int pow(int a, int b) {
int result = 1;
for (int i = 0; i < b; i++) {
result *= a;
}
return result;
}
private final Signer signer;
private final int codeLength;
private final int intervalPeriod;
/*
* Using an interface to allow us to inject different signature
* implementations.
*/
interface Signer {
byte[] sign(byte[] data);
}
/**
* @param mac A {@link Mac} used to generate passcodes
*/ | public PasscodeGenerator(Mac mac) { |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login") | Call<Token> login(@Body Login usr); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login") | Call<Token> login(@Body Login usr); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register") | Call<Token> create(@Body Register register); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo") | Call<StatusResponse> update(@Body Update usr); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo") | Call<StatusResponse> update(@Body Update usr); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo")
Call<StatusResponse> update(@Body Update usr);
//Check Account
@POST("actmanage/confirmAccount") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo")
Call<StatusResponse> update(@Body Update usr);
//Check Account
@POST("actmanage/confirmAccount") | Call<StatusResponse> checkAccount(@Body CheckRegist checkAccount); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
| import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo")
Call<StatusResponse> update(@Body Update usr);
//Check Account
@POST("actmanage/confirmAccount")
Call<StatusResponse> checkAccount(@Body CheckRegist checkAccount);
//CheckNick
@POST("actmanage/confirmNick")
Call<StatusResponse> checkNick(@Body CheckRegist checkNick);
//CheckSchoolAccount
@POST("actmanage/confirmSchool")
Call<StatusResponse> checkSchool(@Body CheckRegist checkSchoolAccount);
//GetUserInfo
@GET("actmanage/getUserInfo") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CheckRegist.java
// public class CheckRegist {
//
// @SerializedName("account")
// public String account;
//
// @SerializedName("nick")
// public String nick;
//
// @SerializedName("schoolAccount")
// public String schoolAccount;
//
// @SerializedName("schoolPwd")
// public String schoolPwd;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Login.java
// public class Login {
//
// @SerializedName("account")
// public String usr_account;
//
// @SerializedName("password")
// public String usr_password;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Register.java
// public class Register {
//
// @SerializedName("email")
// public String usr_email;
//
// @SerializedName("password")
// public String usr_passwd;
//
// @SerializedName("user_group")
// public String usr_group;
//
// @SerializedName("school_account")
// public String school_account;
//
// @SerializedName("school_pwd")
// public String school_pwd;
//
// @SerializedName("nick")
// public String nickname;
//
// @SerializedName("name")
// public String name;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Token.java
// public class Token {
//
// @SerializedName("token")
// public String token;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Update.java
// public class Update {
//
// @SerializedName("password")
// public String password;
//
// @SerializedName("new_school_pwd")
// public String new_spwd;
//
// @SerializedName("new_nick")
// public String new_nick;
//
// @SerializedName("new_password")
// public String new_password;
//
// @SerializedName("new_email")
// public String new_email;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/UserInfoResponse.java
// public class UserInfoResponse {
//
//
// /**
// * name : string
// * nick : string
// * class : string
// * group : student
// */
//
// @SerializedName("name")
// public String name;
// @SerializedName("nick")
// public String nick;
// @SerializedName("class")
// public String classX;
// @SerializedName("group")
// public String group;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/AccountApi.java
import kesshou.android.daanx.util.network.api.holder.CheckRegist;
import kesshou.android.daanx.util.network.api.holder.Login;
import kesshou.android.daanx.util.network.api.holder.Register;
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import kesshou.android.daanx.util.network.api.holder.Token;
import kesshou.android.daanx.util.network.api.holder.Update;
import kesshou.android.daanx.util.network.api.holder.UserInfoResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Account Api interface
*/
public interface AccountApi {
// Login
@POST("actmanage/login")
Call<Token> login(@Body Login usr);
//Register
@POST("actmanage/register")
Call<Token> create(@Body Register register);
// Edit Account
@PUT("actmanage/updateinfo")
Call<StatusResponse> update(@Body Update usr);
//Check Account
@POST("actmanage/confirmAccount")
Call<StatusResponse> checkAccount(@Body CheckRegist checkAccount);
//CheckNick
@POST("actmanage/confirmNick")
Call<StatusResponse> checkNick(@Body CheckRegist checkNick);
//CheckSchoolAccount
@POST("actmanage/confirmSchool")
Call<StatusResponse> checkSchool(@Body CheckRegist checkSchoolAccount);
//GetUserInfo
@GET("actmanage/getUserInfo") | Call<UserInfoResponse> getUserInfo(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar") | Call<List<CalenderResponse>> getCalender(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}") | Call<List<AnnounceResponse>> getAnnounce(@Path("sort") String sort); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}")
Call<List<AnnounceResponse>> getAnnounce(@Path("sort") String sort);
@GET("QandA") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}")
Call<List<AnnounceResponse>> getAnnounce(@Path("sort") String sort);
@GET("QandA") | Call<List<QandaResponse>> getQandA(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}")
Call<List<AnnounceResponse>> getAnnounce(@Path("sort") String sort);
@GET("QandA")
Call<List<QandaResponse>> getQandA();
@GET("relatedlink") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AnnounceResponse.java
// public class AnnounceResponse {
//
//
// @SerializedName("id")
// public int id;
// @SerializedName("key")
// public int key;
// @SerializedName("title")
// public String title;
// @SerializedName("date")
// public String date;
// @SerializedName("body")
// public String body;
// @SerializedName("linked")
// public String linked;
// @SerializedName("author")
// public String author;
// @SerializedName("lifttime")
// public String lifttime;
// @SerializedName("sort")
// public String sort;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// @SerializedName("summary")
// public String summary;
// @SerializedName("file")
// public List<FileBean> file;
//
// public static class FileBean {
// /**
// * id : 551
// * news_key : 785
// * type : file
// * file_name : 2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * file_src : http://ta.taivs.tp.edu.tw/news/upload/1/2aecf5ba03a7410b413b80e8a5123a7d_15459300A00_ATTCH2.pdf
// * createdAt : 2016-12-14T07:23:02.000Z
// * updatedAt : 2016-12-14T07:23:02.000Z
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("news_key")
// public int newsKey;
// @SerializedName("type")
// public String type;
// @SerializedName("file_name")
// public String fileName;
// @SerializedName("file_src")
// public String fileSrc;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/CalenderResponse.java
// public class CalenderResponse{
//
// /**
// * start : 2017/2/13
// * end : 2017/2/14
// * content : (教)第 2 學期開學、正式上課
// */
//
// @SerializedName("start")
// public Date start;
// @SerializedName("end")
// public Date end;
// @SerializedName("content")
// public String content;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/QandaResponse.java
// public class QandaResponse {
//
//
// /**
// * id : 1
// * Q : 你喜歡木棉手札嗎?
// * A : 喜歡
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("Q")
// public String Q;
// @SerializedName("A")
// public String A;
// @SerializedName("createdAt")
// public Object createdAt;
// @SerializedName("updatedAt")
// public Object updatedAt;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/RelatedlinkResponse.java
// public class RelatedlinkResponse {
//
//
// /**
// * id : 1
// * name : 大安高工
// * link : http://www.taivs.tp.edu.tw
// * createdAt : null
// * updatedAt : null
// */
//
// @SerializedName("id")
// public int id;
// @SerializedName("name")
// public String name;
// @SerializedName("link")
// public String link;
// @SerializedName("createdAt")
// public String createdAt;
// @SerializedName("updatedAt")
// public String updatedAt;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/NewsApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AnnounceResponse;
import kesshou.android.daanx.util.network.api.holder.CalenderResponse;
import kesshou.android.daanx.util.network.api.holder.QandaResponse;
import kesshou.android.daanx.util.network.api.holder.RelatedlinkResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Calender Api interface
*/
public interface NewsApi {
@GET("calendar")
Call<List<CalenderResponse>> getCalender();
@GET("announce/{sort}")
Call<List<AnnounceResponse>> getAnnounce(@Path("sort") String sort);
@GET("QandA")
Call<List<QandaResponse>> getQandA();
@GET("relatedlink") | Call<List<RelatedlinkResponse>> getLink(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/MyContextWrapper.java | // Path: app/src/main/java/kesshou/android/daanx/util/LanguageUtil.java
// public class LanguageUtil {
//
//
//
// // public static void setLanguage(Activity activity,String str) {
// // Resources resources = activity.getApplicationContext().getResources();
// // DisplayMetrics dm = resources.getDisplayMetrics();
// // Configuration config = resources.getConfiguration();
// //
// // Locale locale = getLocale(str);
// //
// // if (Build.VERSION.SDK_INT < 17) {
// // config.locale = locale;
// // } else {
// // config.setLocale(locale);
// // }
// // if (Build.VERSION.SDK_INT < 25) {
// // resources.updateConfiguration(config, dm);
// // } else {
// //
// // activity.applyOverrideConfiguration(config);
// // }
// // }
// //
// // public static void setLanguage(Activity activity,Locale locale) {
// // Resources resources = activity.getApplicationContext().getResources();
// // DisplayMetrics dm = resources.getDisplayMetrics();
// // Configuration config = resources.getConfiguration();
// //
// //
// // if (Build.VERSION.SDK_INT < 17) {
// // config.locale = locale;
// // } else {
// // config.setLocale(locale);
// // }
// // if (Build.VERSION.SDK_INT < 25) {
// // resources.updateConfiguration(config, dm);
// // } else {
// // activity.applyOverrideConfiguration(config);
// // }
// // }
//
// private static Locale getLocale(String str){
// Locale locale;
// switch (str) {
// case "Auto":
// locale = Locale.getDefault();
// break;
// case "正體中文":
// locale = Locale.TRADITIONAL_CHINESE;
// break;
// case "English":
// locale = Locale.ENGLISH;
// break;
// default:
// locale = Locale.getDefault();
// }
// return locale;
// }
//
// public static Locale getSetLocale() {
// Realm realm = Realm.getDefaultInstance();
// Setting setting = realm.where(Setting.class).findFirst();
// String str;
// if(setting == null ||setting.locale==null){
// str = "Auto";
// if(setting!=null) {
// realm.beginTransaction();
// setting.locale = "Auto";
// realm.commitTransaction();
// }
// }else {
// str = setting.locale;
// }
// realm.close();
// return getLocale(str);
// }
//
// public static void restart(Activity activity){
// Intent intent = new Intent(activity, activity.getClass());
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
// activity.startActivity(intent);
//
// android.os.Process.killProcess(android.os.Process.myPid());
// System.exit(0);
// }
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration;
import android.os.Build;
import java.util.Locale;
import kesshou.android.daanx.util.LanguageUtil; | package kesshou.android.daanx;
/**
* Created by yoyo930021 on 2017/1/16.
*/
public class MyContextWrapper extends ContextWrapper {
public MyContextWrapper(Context base) {
super(base);
}
@SuppressWarnings("deprecation")
public static ContextWrapper wrap(Context context, String language) {
Configuration config = context.getResources().getConfiguration();
Locale sysLocale = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
sysLocale = getSystemLocale(config);
} else {
sysLocale = getSystemLocaleLegacy(config);
}
if (!language.equals("") && !sysLocale.getLanguage().equals(language)) { | // Path: app/src/main/java/kesshou/android/daanx/util/LanguageUtil.java
// public class LanguageUtil {
//
//
//
// // public static void setLanguage(Activity activity,String str) {
// // Resources resources = activity.getApplicationContext().getResources();
// // DisplayMetrics dm = resources.getDisplayMetrics();
// // Configuration config = resources.getConfiguration();
// //
// // Locale locale = getLocale(str);
// //
// // if (Build.VERSION.SDK_INT < 17) {
// // config.locale = locale;
// // } else {
// // config.setLocale(locale);
// // }
// // if (Build.VERSION.SDK_INT < 25) {
// // resources.updateConfiguration(config, dm);
// // } else {
// //
// // activity.applyOverrideConfiguration(config);
// // }
// // }
// //
// // public static void setLanguage(Activity activity,Locale locale) {
// // Resources resources = activity.getApplicationContext().getResources();
// // DisplayMetrics dm = resources.getDisplayMetrics();
// // Configuration config = resources.getConfiguration();
// //
// //
// // if (Build.VERSION.SDK_INT < 17) {
// // config.locale = locale;
// // } else {
// // config.setLocale(locale);
// // }
// // if (Build.VERSION.SDK_INT < 25) {
// // resources.updateConfiguration(config, dm);
// // } else {
// // activity.applyOverrideConfiguration(config);
// // }
// // }
//
// private static Locale getLocale(String str){
// Locale locale;
// switch (str) {
// case "Auto":
// locale = Locale.getDefault();
// break;
// case "正體中文":
// locale = Locale.TRADITIONAL_CHINESE;
// break;
// case "English":
// locale = Locale.ENGLISH;
// break;
// default:
// locale = Locale.getDefault();
// }
// return locale;
// }
//
// public static Locale getSetLocale() {
// Realm realm = Realm.getDefaultInstance();
// Setting setting = realm.where(Setting.class).findFirst();
// String str;
// if(setting == null ||setting.locale==null){
// str = "Auto";
// if(setting!=null) {
// realm.beginTransaction();
// setting.locale = "Auto";
// realm.commitTransaction();
// }
// }else {
// str = setting.locale;
// }
// realm.close();
// return getLocale(str);
// }
//
// public static void restart(Activity activity){
// Intent intent = new Intent(activity, activity.getClass());
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
// activity.startActivity(intent);
//
// android.os.Process.killProcess(android.os.Process.myPid());
// System.exit(0);
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/MyContextWrapper.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration;
import android.os.Build;
import java.util.Locale;
import kesshou.android.daanx.util.LanguageUtil;
package kesshou.android.daanx;
/**
* Created by yoyo930021 on 2017/1/16.
*/
public class MyContextWrapper extends ContextWrapper {
public MyContextWrapper(Context base) {
super(base);
}
@SuppressWarnings("deprecation")
public static ContextWrapper wrap(Context context, String language) {
Configuration config = context.getResources().getConfiguration();
Locale sysLocale = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
sysLocale = getSystemLocale(config);
} else {
sysLocale = getSystemLocaleLegacy(config);
}
if (!language.equals("") && !sysLocale.getLanguage().equals(language)) { | Locale locale = LanguageUtil.getSetLocale(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/MyApplication.java | // Path: app/src/main/java/kesshou/android/daanx/models/Migration.java
// public class Migration implements RealmMigration {
// @Override
// public void migrate(final DynamicRealm realm, long oldVersion, long newVersion) {
// // During a migration, a DynamicRealm is exposed. A DynamicRealm is an untyped variant of a normal Realm, but
// // with the same object creation and query capabilities.
// // A DynamicRealm uses Strings instead of Class references because the Classes might not even exist or have been
// // renamed.
//
// // Access the Realm schema in order to create, modify or delete classes and their fields.
// RealmSchema schema = realm.getSchema();
//
// if(oldVersion==1){
//
// RealmObjectSchema settingSchema = schema.get("Setting");
//
// settingSchema.addField("locale",String.class)
// .transform(new RealmObjectSchema.Function() {
// @Override
// public void apply(DynamicRealmObject obj) {
// obj.set("locale","Auto");
// }
// });
//
// oldVersion++;
// }
//
// if(oldVersion==2){
//
// RealmObjectSchema cacheSchema = schema.get("NetWorkCache");
//
// cacheSchema.removeField("record").addField("record",String.class);
//
// oldVersion++;
// }
// }
// }
| import android.app.Application;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import kesshou.android.daanx.models.Migration; | package kesshou.android.daanx;
/**
* Created by yoyoIU on 2016/9/17.
*/
public class MyApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name("default.realm")
.schemaVersion(3) | // Path: app/src/main/java/kesshou/android/daanx/models/Migration.java
// public class Migration implements RealmMigration {
// @Override
// public void migrate(final DynamicRealm realm, long oldVersion, long newVersion) {
// // During a migration, a DynamicRealm is exposed. A DynamicRealm is an untyped variant of a normal Realm, but
// // with the same object creation and query capabilities.
// // A DynamicRealm uses Strings instead of Class references because the Classes might not even exist or have been
// // renamed.
//
// // Access the Realm schema in order to create, modify or delete classes and their fields.
// RealmSchema schema = realm.getSchema();
//
// if(oldVersion==1){
//
// RealmObjectSchema settingSchema = schema.get("Setting");
//
// settingSchema.addField("locale",String.class)
// .transform(new RealmObjectSchema.Function() {
// @Override
// public void apply(DynamicRealmObject obj) {
// obj.set("locale","Auto");
// }
// });
//
// oldVersion++;
// }
//
// if(oldVersion==2){
//
// RealmObjectSchema cacheSchema = schema.get("NetWorkCache");
//
// cacheSchema.removeField("record").addField("record",String.class);
//
// oldVersion++;
// }
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/MyApplication.java
import android.app.Application;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import kesshou.android.daanx.models.Migration;
package kesshou.android.daanx;
/**
* Created by yoyoIU on 2016/9/17.
*/
public class MyApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name("default.realm")
.schemaVersion(3) | .migration(new Migration()) |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}") | Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}") | Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus") | Call<AttitudeStatusResponse> getATS(); // Attitude Status |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus")
Call<AttitudeStatusResponse> getATS(); // Attitude Status
@GET("absentstate") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus")
Call<AttitudeStatusResponse> getATS(); // Attitude Status
@GET("absentstate") | Call<List<AbsentstateResponse>> getABS(); //Absent State |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
| import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus")
Call<AttitudeStatusResponse> getATS(); // Attitude Status
@GET("absentstate")
Call<List<AbsentstateResponse>> getABS(); //Absent State
@GET("curriculum") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AbsentstateResponse.java
// public class AbsentstateResponse{
//
//
// /**
// * date : 2016/10/27
// * type : 公
// * class : 五
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("type")
// public String type;
// @SerializedName("class")
// public String classX;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/AttitudeStatusResponse.java
// public class AttitudeStatusResponse{
//
//
// @SerializedName("count")
// public CountBean count;
// @SerializedName("status")
// public List<Attitude> status;
//
// public static class Attitude{
// /**
// * date : 2016/11/03
// * item : 嘉獎1次
// * text : 9-10月閱讀推薦文章達5篇
// */
//
// @SerializedName("date")
// public String date;
// @SerializedName("item")
// public String item;
// @SerializedName("text")
// public String text;
// }
//
// public static class CountBean{
// /**
// * smallcite : 19
// * smallfault : 0
// * middlecite : 7
// * middlefault : 0
// * bigcite : 0
// * bigfault : 0
// */
//
// @SerializedName("smallcite")
// public int smallcite;
// @SerializedName("smallfault")
// public int smallfault;
// @SerializedName("middlecite")
// public int middlecite;
// @SerializedName("middlefault")
// public int middlefault;
// @SerializedName("bigcite")
// public int bigcite;
// @SerializedName("bigfault")
// public int bigfault;
// }
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/HistoryScoreResponse.java
// public class HistoryScoreResponse{
//
//
// /**
// * subject : string
// * type : 必
// * credit : 0
// * score : 0
// * makeup : 0
// * retake : 0
// * qualify : 0
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("type")
// public String type;
// @SerializedName("credit")
// public int credit;
// @SerializedName("score")
// public int score;
// @SerializedName("makeup")
// public int makeup;
// @SerializedName("retake")
// public int retake;
// @SerializedName("qualify")
// public int qualify;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/SectionalExamResponse.java
// public class SectionalExamResponse{
//
// /**
// * subject : 國文
// * first_section : 65
// * second_section : null
// * last_section : null
// * performance : null
// * average : null
// */
//
// @SerializedName("subject")
// public String subject;
// @SerializedName("first_section")
// public int firstSection;
// @SerializedName("second_section")
// public int secondSection;
// @SerializedName("last_section")
// public int lastSection;
// @SerializedName("performance")
// public int performance;
// @SerializedName("average")
// public int average;
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/TimeTableResponse.java
// public class TimeTableResponse {
//
// @SerializedName("week1")
// public List<Week> week1;
// @SerializedName("week2")
// public List<Week> week2;
// @SerializedName("week3")
// public List<Week> week3;
// @SerializedName("week4")
// public List<Week> week4;
// @SerializedName("week5")
// public List<Week> week5;
//
// public static class Week {
// /**
// * start : 8:20
// * end : 9:10
// * subject : 輸配電學
// * teacher : 林志昌
// */
//
// @SerializedName("start")
// public String start;
// @SerializedName("end")
// public String end;
// @SerializedName("subject")
// public String subject;
// @SerializedName("teacher")
// public String teacher;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/InforApi.java
import java.util.List;
import kesshou.android.daanx.util.network.api.holder.AbsentstateResponse;
import kesshou.android.daanx.util.network.api.holder.AttitudeStatusResponse;
import kesshou.android.daanx.util.network.api.holder.HistoryScoreResponse;
import kesshou.android.daanx.util.network.api.holder.SectionalExamResponse;
import kesshou.android.daanx.util.network.api.holder.TimeTableResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package kesshou.android.daanx.util.network.api;
/*
Author: Charles Lien(lienching)
Description: Score Api interface
*/
public interface InforApi {
@GET("scorequery/historyscore/{grade}/{semester}")
Call<List<HistoryScoreResponse>> queryHScore(@Path("grade") int grade, @Path("semester") int semester); // History Score
@GET("scorequery/sectionalexamscore/{semester}")
Call<List<SectionalExamResponse>> querySEScore(@Path("semester") int semester); // Sectional Exam Score
@GET("attitudestatus")
Call<AttitudeStatusResponse> getATS(); // Attitude Status
@GET("absentstate")
Call<List<AbsentstateResponse>> getABS(); //Absent State
@GET("curriculum") | Call<TimeTableResponse> getTimeTable(); //TimeTableResponse |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/api/MenuApi.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
| import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST; | package kesshou.android.daanx.util.network.api;
/**
* Created by yoyoIU on 2016/12/17.
*/
public interface MenuApi {
@FormUrlEncoded
@POST("feedback") | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/StatusResponse.java
// public class StatusResponse extends RealmObject {
//
// @SerializedName("success")
// public String status;
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/MenuApi.java
import kesshou.android.daanx.util.network.api.holder.StatusResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
package kesshou.android.daanx.util.network.api;
/**
* Created by yoyoIU on 2016/12/17.
*/
public interface MenuApi {
@FormUrlEncoded
@POST("feedback") | Call<StatusResponse> postFB(@Field("feedClass") String feedClass,@Field("commit") String commit,@Field("system") String system); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/ActivityUtils.java | // Path: app/src/main/java/kesshou/android/daanx/views/ContentActivity.java
// public class ContentActivity extends BaseActivity {
//
// private FirebaseAnalytics mFirebaseAnalytics;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_content);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// toolbar.setBackgroundColor(Color.TRANSPARENT);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) toolbar.setElevation(0);
// toolbar.setTitle("");
// toolbar.inflateMenu(R.menu.content_toolbar_menu_blue);
// toolbar.setNavigationIcon(R.drawable.btn_back_blue);
// toolbar.setNavigationOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// finish();
// }
// });
//
// // Obtain the FirebaseAnalytics instance.
// mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
//
// // setSupportActionBar(toolbar);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(),R.color.black_transparent));
// // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//
// Bundle bundle = getIntent().getExtras();
//
// TextView title = (TextView) findViewById(R.id.title);
// title.setText(bundle.getString("title"));
// TextView title_help = (TextView) findViewById(R.id.title_help);
// title_help.setText(bundle.getString("title_help"));
//
// final LinearLayout layout = (LinearLayout) findViewById(R.id.content);
// View fragment = ContentRouter.getFragment(bundle.getInt("type"),ContentActivity.this);
// layout.addView(fragment);
//
// LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// fragment.setLayoutParams(layoutParams);
// fragment.requestLayout();
//
// toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// switch (item.getItemId()){
// case R.id.menu_share:
// Bundle bundle = new Bundle();
// bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "Share");
// bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Share");
// bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "fn");
// mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle);
// ViewShareUtils.share(getApplicationContext(),ContentActivity.this,layout);
// break;
// }
// return false;
// }
// });
//
// }
//
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import kesshou.android.daanx.views.ContentActivity; | package kesshou.android.daanx.util;
/**
* Created by yoyoIU on 2016/11/8.
*/
public class ActivityUtils {
public static void openContent(Context context, int type, int title, int titleHelp){
Intent intent = new Intent(); | // Path: app/src/main/java/kesshou/android/daanx/views/ContentActivity.java
// public class ContentActivity extends BaseActivity {
//
// private FirebaseAnalytics mFirebaseAnalytics;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_content);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// toolbar.setBackgroundColor(Color.TRANSPARENT);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) toolbar.setElevation(0);
// toolbar.setTitle("");
// toolbar.inflateMenu(R.menu.content_toolbar_menu_blue);
// toolbar.setNavigationIcon(R.drawable.btn_back_blue);
// toolbar.setNavigationOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// finish();
// }
// });
//
// // Obtain the FirebaseAnalytics instance.
// mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
//
// // setSupportActionBar(toolbar);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(),R.color.black_transparent));
// // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//
// Bundle bundle = getIntent().getExtras();
//
// TextView title = (TextView) findViewById(R.id.title);
// title.setText(bundle.getString("title"));
// TextView title_help = (TextView) findViewById(R.id.title_help);
// title_help.setText(bundle.getString("title_help"));
//
// final LinearLayout layout = (LinearLayout) findViewById(R.id.content);
// View fragment = ContentRouter.getFragment(bundle.getInt("type"),ContentActivity.this);
// layout.addView(fragment);
//
// LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// fragment.setLayoutParams(layoutParams);
// fragment.requestLayout();
//
// toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// switch (item.getItemId()){
// case R.id.menu_share:
// Bundle bundle = new Bundle();
// bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "Share");
// bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Share");
// bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "fn");
// mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle);
// ViewShareUtils.share(getApplicationContext(),ContentActivity.this,layout);
// break;
// }
// return false;
// }
// });
//
// }
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/ActivityUtils.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import kesshou.android.daanx.views.ContentActivity;
package kesshou.android.daanx.util;
/**
* Created by yoyoIU on 2016/11/8.
*/
public class ActivityUtils {
public static void openContent(Context context, int type, int title, int titleHelp){
Intent intent = new Intent(); | intent.setClass(context.getApplicationContext(), ContentActivity.class); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/LanguageUtil.java | // Path: app/src/main/java/kesshou/android/daanx/models/Setting.java
// public class Setting extends RealmObject {
// public boolean logined;
// public String token;
// public String nick;
// public String name;
// public String email;
// public String password;
// public String usr_group;
// public String classX;
// public String locale;
// }
| import android.app.Activity;
import android.content.Intent;
import java.util.Locale;
import io.realm.Realm;
import kesshou.android.daanx.models.Setting; | package kesshou.android.daanx.util;
/**
* Created by yoyo930021 on 2017/1/16.
*/
public class LanguageUtil {
// public static void setLanguage(Activity activity,String str) {
// Resources resources = activity.getApplicationContext().getResources();
// DisplayMetrics dm = resources.getDisplayMetrics();
// Configuration config = resources.getConfiguration();
//
// Locale locale = getLocale(str);
//
// if (Build.VERSION.SDK_INT < 17) {
// config.locale = locale;
// } else {
// config.setLocale(locale);
// }
// if (Build.VERSION.SDK_INT < 25) {
// resources.updateConfiguration(config, dm);
// } else {
//
// activity.applyOverrideConfiguration(config);
// }
// }
//
// public static void setLanguage(Activity activity,Locale locale) {
// Resources resources = activity.getApplicationContext().getResources();
// DisplayMetrics dm = resources.getDisplayMetrics();
// Configuration config = resources.getConfiguration();
//
//
// if (Build.VERSION.SDK_INT < 17) {
// config.locale = locale;
// } else {
// config.setLocale(locale);
// }
// if (Build.VERSION.SDK_INT < 25) {
// resources.updateConfiguration(config, dm);
// } else {
// activity.applyOverrideConfiguration(config);
// }
// }
private static Locale getLocale(String str){
Locale locale;
switch (str) {
case "Auto":
locale = Locale.getDefault();
break;
case "正體中文":
locale = Locale.TRADITIONAL_CHINESE;
break;
case "English":
locale = Locale.ENGLISH;
break;
default:
locale = Locale.getDefault();
}
return locale;
}
public static Locale getSetLocale() {
Realm realm = Realm.getDefaultInstance(); | // Path: app/src/main/java/kesshou/android/daanx/models/Setting.java
// public class Setting extends RealmObject {
// public boolean logined;
// public String token;
// public String nick;
// public String name;
// public String email;
// public String password;
// public String usr_group;
// public String classX;
// public String locale;
// }
// Path: app/src/main/java/kesshou/android/daanx/util/LanguageUtil.java
import android.app.Activity;
import android.content.Intent;
import java.util.Locale;
import io.realm.Realm;
import kesshou.android.daanx.models.Setting;
package kesshou.android.daanx.util;
/**
* Created by yoyo930021 on 2017/1/16.
*/
public class LanguageUtil {
// public static void setLanguage(Activity activity,String str) {
// Resources resources = activity.getApplicationContext().getResources();
// DisplayMetrics dm = resources.getDisplayMetrics();
// Configuration config = resources.getConfiguration();
//
// Locale locale = getLocale(str);
//
// if (Build.VERSION.SDK_INT < 17) {
// config.locale = locale;
// } else {
// config.setLocale(locale);
// }
// if (Build.VERSION.SDK_INT < 25) {
// resources.updateConfiguration(config, dm);
// } else {
//
// activity.applyOverrideConfiguration(config);
// }
// }
//
// public static void setLanguage(Activity activity,Locale locale) {
// Resources resources = activity.getApplicationContext().getResources();
// DisplayMetrics dm = resources.getDisplayMetrics();
// Configuration config = resources.getConfiguration();
//
//
// if (Build.VERSION.SDK_INT < 17) {
// config.locale = locale;
// } else {
// config.setLocale(locale);
// }
// if (Build.VERSION.SDK_INT < 25) {
// resources.updateConfiguration(config, dm);
// } else {
// activity.applyOverrideConfiguration(config);
// }
// }
private static Locale getLocale(String str){
Locale locale;
switch (str) {
case "Auto":
locale = Locale.getDefault();
break;
case "正體中文":
locale = Locale.TRADITIONAL_CHINESE;
break;
case "English":
locale = Locale.ENGLISH;
break;
default:
locale = Locale.getDefault();
}
return locale;
}
public static Locale getSetLocale() {
Realm realm = Realm.getDefaultInstance(); | Setting setting = realm.where(Setting.class).findFirst(); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/ErrorUtils.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java
// public class RetrofitClient {
//
// private static Context mContext;
// private static Gson gson;
//
// private static class RetrofitClientHolder{
// static Retrofit instance = new Retrofit.Builder()
// .baseUrl(Config.getAPIPath())
// .client(OkHttpUtil.getInstance(mContext))
// .addConverterFactory(GsonConverterFactory.create(gson))
// .build();
// }
//
// private RetrofitClient() {
//
// }
//
// public static Retrofit getInstance(Context context){
// if (context != null) {
// mContext = context.getApplicationContext();
// }
//
// gson = new GsonBuilder()
// .setDateFormat("yyyy/MM/dd")
// .serializeNulls()
// .create();
// return RetrofitClientHolder.instance;
// }
//
// }
| import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.lang.annotation.Annotation;
import kesshou.android.daanx.util.network.api.holder.Error;
import kesshou.android.daanx.util.network.client.RetrofitClient;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response; | package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/9/20.
*/
public class ErrorUtils {
private static final String TAG = "NetworkingClient";
| // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java
// public class RetrofitClient {
//
// private static Context mContext;
// private static Gson gson;
//
// private static class RetrofitClientHolder{
// static Retrofit instance = new Retrofit.Builder()
// .baseUrl(Config.getAPIPath())
// .client(OkHttpUtil.getInstance(mContext))
// .addConverterFactory(GsonConverterFactory.create(gson))
// .build();
// }
//
// private RetrofitClient() {
//
// }
//
// public static Retrofit getInstance(Context context){
// if (context != null) {
// mContext = context.getApplicationContext();
// }
//
// gson = new GsonBuilder()
// .setDateFormat("yyyy/MM/dd")
// .serializeNulls()
// .create();
// return RetrofitClientHolder.instance;
// }
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/ErrorUtils.java
import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.lang.annotation.Annotation;
import kesshou.android.daanx.util.network.api.holder.Error;
import kesshou.android.daanx.util.network.client.RetrofitClient;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response;
package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/9/20.
*/
public class ErrorUtils {
private static final String TAG = "NetworkingClient";
| public static Error parseError(Response<?> response, Context context) { |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/ErrorUtils.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java
// public class RetrofitClient {
//
// private static Context mContext;
// private static Gson gson;
//
// private static class RetrofitClientHolder{
// static Retrofit instance = new Retrofit.Builder()
// .baseUrl(Config.getAPIPath())
// .client(OkHttpUtil.getInstance(mContext))
// .addConverterFactory(GsonConverterFactory.create(gson))
// .build();
// }
//
// private RetrofitClient() {
//
// }
//
// public static Retrofit getInstance(Context context){
// if (context != null) {
// mContext = context.getApplicationContext();
// }
//
// gson = new GsonBuilder()
// .setDateFormat("yyyy/MM/dd")
// .serializeNulls()
// .create();
// return RetrofitClientHolder.instance;
// }
//
// }
| import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.lang.annotation.Annotation;
import kesshou.android.daanx.util.network.api.holder.Error;
import kesshou.android.daanx.util.network.client.RetrofitClient;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response; | package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/9/20.
*/
public class ErrorUtils {
private static final String TAG = "NetworkingClient";
public static Error parseError(Response<?> response, Context context) {
Converter<ResponseBody, Error> converter = | // Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java
// public class RetrofitClient {
//
// private static Context mContext;
// private static Gson gson;
//
// private static class RetrofitClientHolder{
// static Retrofit instance = new Retrofit.Builder()
// .baseUrl(Config.getAPIPath())
// .client(OkHttpUtil.getInstance(mContext))
// .addConverterFactory(GsonConverterFactory.create(gson))
// .build();
// }
//
// private RetrofitClient() {
//
// }
//
// public static Retrofit getInstance(Context context){
// if (context != null) {
// mContext = context.getApplicationContext();
// }
//
// gson = new GsonBuilder()
// .setDateFormat("yyyy/MM/dd")
// .serializeNulls()
// .create();
// return RetrofitClientHolder.instance;
// }
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/ErrorUtils.java
import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.lang.annotation.Annotation;
import kesshou.android.daanx.util.network.api.holder.Error;
import kesshou.android.daanx.util.network.client.RetrofitClient;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response;
package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/9/20.
*/
public class ErrorUtils {
private static final String TAG = "NetworkingClient";
public static Error parseError(Response<?> response, Context context) {
Converter<ResponseBody, Error> converter = | RetrofitClient.getInstance(context) |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java | // Path: app/src/main/java/kesshou/android/daanx/util/network/Config.java
// public class Config {
//
// private enum Env {
//
// PROD("kesshou.dacsc.club"),
// DEV("dev.dacsc.club"); // PROD: Production website ,DEV: Developement website
//
//
// public final String host;
//
// Env(String host) {
// this.host = host;
// }
// }
//
// // API Version
// private final static String VERSION = "1";
//
// // Using Env
// private final static Env env = Env.PROD;
//
// public static String getAPIPath() {
// return getAPIPath( Config.env, Config.VERSION);
// }
//
// private static String getAPIPath( Env env, String version ) {
// return "https://"+env.host+"/v"+version+"/";
// }
//
// }
| import android.content.Context;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import kesshou.android.daanx.util.network.Config;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; | package kesshou.android.daanx.util.network.client;
/**
* Created by yoyoIU on 2016/9/19.
*/
public class RetrofitClient {
private static Context mContext;
private static Gson gson;
private static class RetrofitClientHolder{
static Retrofit instance = new Retrofit.Builder() | // Path: app/src/main/java/kesshou/android/daanx/util/network/Config.java
// public class Config {
//
// private enum Env {
//
// PROD("kesshou.dacsc.club"),
// DEV("dev.dacsc.club"); // PROD: Production website ,DEV: Developement website
//
//
// public final String host;
//
// Env(String host) {
// this.host = host;
// }
// }
//
// // API Version
// private final static String VERSION = "1";
//
// // Using Env
// private final static Env env = Env.PROD;
//
// public static String getAPIPath() {
// return getAPIPath( Config.env, Config.VERSION);
// }
//
// private static String getAPIPath( Env env, String version ) {
// return "https://"+env.host+"/v"+version+"/";
// }
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/client/RetrofitClient.java
import android.content.Context;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import kesshou.android.daanx.util.network.Config;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
package kesshou.android.daanx.util.network.client;
/**
* Created by yoyoIU on 2016/9/19.
*/
public class RetrofitClient {
private static Context mContext;
private static Gson gson;
private static class RetrofitClientHolder{
static Retrofit instance = new Retrofit.Builder() | .baseUrl(Config.getAPIPath()) |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/component/DialogUtils.java | // Path: app/src/main/java/kesshou/android/daanx/util/UnitConvert.java
// public class UnitConvert {
//
// /**
// * Covert dp to px
// * @param dp
// * @param context
// * @return pixel
// */
// public static float Dp2Pixel(float dp, Context context){
// float px = dp * getDensity(context.getApplicationContext());
// return px;
// }
// /**
// * Covert px to dp
// * @param px
// * @param context
// * @return dp
// */
// public static float Pixel2Dp(float px, Context context){
// float dp = px / getDensity(context.getApplicationContext());
// return dp;
// }
// /**
// * 取得螢幕密度
// * 120dpi = 0.75
// * 160dpi = 1 (default)
// * 240dpi = 1.5
// * @param context
// * @return
// */
// public static float getDensity(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.density;
// }
//
// public static float getScreenWidth(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.widthPixels;
// }
//
// public static float getScreenHeight(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.heightPixels;
// }
// }
| import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import kesshou.android.daanx.R;
import kesshou.android.daanx.util.UnitConvert; | package kesshou.android.daanx.util.component;
/**
* Created by yoyoIU on 2016/11/7.
*/
public class DialogUtils {
/**
* 得到自定义的progressDialog
* @param context
* @return
*/
public static Dialog createLoadingDialog(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.loading_dialog, null); // 得到加载view
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(context,R.anim.loading_animation); // 加载动画
hyperspaceJumpAnimation.setInterpolator(new LinearInterpolator());
spaceshipImage.startAnimation(hyperspaceJumpAnimation); // 使用ImageView显示动画
Dialog loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog
loadingDialog.setCancelable(false);// 不可以用"返回键"取消
loadingDialog.setContentView(v);
loadingDialog.setTitle("");
Window dialogWindow = loadingDialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER); | // Path: app/src/main/java/kesshou/android/daanx/util/UnitConvert.java
// public class UnitConvert {
//
// /**
// * Covert dp to px
// * @param dp
// * @param context
// * @return pixel
// */
// public static float Dp2Pixel(float dp, Context context){
// float px = dp * getDensity(context.getApplicationContext());
// return px;
// }
// /**
// * Covert px to dp
// * @param px
// * @param context
// * @return dp
// */
// public static float Pixel2Dp(float px, Context context){
// float dp = px / getDensity(context.getApplicationContext());
// return dp;
// }
// /**
// * 取得螢幕密度
// * 120dpi = 0.75
// * 160dpi = 1 (default)
// * 240dpi = 1.5
// * @param context
// * @return
// */
// public static float getDensity(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.density;
// }
//
// public static float getScreenWidth(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.widthPixels;
// }
//
// public static float getScreenHeight(Context context){
// DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
// return metrics.heightPixels;
// }
// }
// Path: app/src/main/java/kesshou/android/daanx/util/component/DialogUtils.java
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import kesshou.android.daanx.R;
import kesshou.android.daanx.util.UnitConvert;
package kesshou.android.daanx.util.component;
/**
* Created by yoyoIU on 2016/11/7.
*/
public class DialogUtils {
/**
* 得到自定义的progressDialog
* @param context
* @return
*/
public static Dialog createLoadingDialog(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.loading_dialog, null); // 得到加载view
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(context,R.anim.loading_animation); // 加载动画
hyperspaceJumpAnimation.setInterpolator(new LinearInterpolator());
spaceshipImage.startAnimation(hyperspaceJumpAnimation); // 使用ImageView显示动画
Dialog loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog
loadingDialog.setCancelable(false);// 不可以用"返回键"取消
loadingDialog.setContentView(v);
loadingDialog.setTitle("");
Window dialogWindow = loadingDialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER); | lp.width = (int)UnitConvert.Dp2Pixel(100,context); // 宽度 |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/MyCallBack.java | // Path: app/src/main/java/kesshou/android/daanx/util/component/ToastUtils.java
// public class ToastUtils {
//
// private static Toast toast;
//
// public static void makeTextAndShow(Context context,String text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity,int textSize) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// TextView textView = (TextView) toast.getView().findViewById(R.id.noti_text);
// textView.setText(text);
// textView.setTextSize(textSize);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
| import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import kesshou.android.daanx.util.component.ToastUtils;
import kesshou.android.daanx.util.network.api.holder.Error;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/11/11.
*/
public abstract class MyCallBack<t> implements Callback<t> {
private Context context;
protected MyCallBack(Context mContext){
context=mContext.getApplicationContext();
}
private void onError(Call<t> call,Response<t> response){ | // Path: app/src/main/java/kesshou/android/daanx/util/component/ToastUtils.java
// public class ToastUtils {
//
// private static Toast toast;
//
// public static void makeTextAndShow(Context context,String text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity,int textSize) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// TextView textView = (TextView) toast.getView().findViewById(R.id.noti_text);
// textView.setText(text);
// textView.setTextSize(textSize);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/MyCallBack.java
import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import kesshou.android.daanx.util.component.ToastUtils;
import kesshou.android.daanx.util.network.api.holder.Error;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/11/11.
*/
public abstract class MyCallBack<t> implements Callback<t> {
private Context context;
protected MyCallBack(Context mContext){
context=mContext.getApplicationContext();
}
private void onError(Call<t> call,Response<t> response){ | Error error = ErrorUtils.parseError(response,context); |
Kesshou/Kesshou-Android | app/src/main/java/kesshou/android/daanx/util/network/MyCallBack.java | // Path: app/src/main/java/kesshou/android/daanx/util/component/ToastUtils.java
// public class ToastUtils {
//
// private static Toast toast;
//
// public static void makeTextAndShow(Context context,String text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity,int textSize) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// TextView textView = (TextView) toast.getView().findViewById(R.id.noti_text);
// textView.setText(text);
// textView.setTextSize(textSize);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
| import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import kesshou.android.daanx.util.component.ToastUtils;
import kesshou.android.daanx.util.network.api.holder.Error;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/11/11.
*/
public abstract class MyCallBack<t> implements Callback<t> {
private Context context;
protected MyCallBack(Context mContext){
context=mContext.getApplicationContext();
}
private void onError(Call<t> call,Response<t> response){
Error error = ErrorUtils.parseError(response,context);
ErrorUtils.logError(error);
switch (error.code){
case 103:
break;
case 500:
break;
case 501:
break;
case 100:
break;
case 102:
break;
default: | // Path: app/src/main/java/kesshou/android/daanx/util/component/ToastUtils.java
// public class ToastUtils {
//
// private static Toast toast;
//
// public static void makeTextAndShow(Context context,String text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP,0,100);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(text);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,int text, int duration,int gravity) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// ((TextView)toast.getView().findViewById(R.id.noti_text)).setText(context.getString(text));
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// public static void makeTextAndShow(Context context,String text, int duration,int gravity,int textSize) {
// if (toast == null) {
// //如果還沒有用過makeText方法,才使用
// toast = new Toast(context);
// LayoutInflater inflater = LayoutInflater.from(context);
// View view = inflater.inflate(R.layout.toast_layout,null);
// toast.setView(view);
// }
// TextView textView = (TextView) toast.getView().findViewById(R.id.noti_text);
// textView.setText(text);
// textView.setTextSize(textSize);
// toast.setDuration(duration);
// toast.setGravity(gravity,0,0);
// toast.show();
// }
//
// }
//
// Path: app/src/main/java/kesshou/android/daanx/util/network/api/holder/Error.java
// public class Error {
//
// @SerializedName("error")
// public String message;
//
// @SerializedName("code")
// public int code;
//
// }
// Path: app/src/main/java/kesshou/android/daanx/util/network/MyCallBack.java
import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import kesshou.android.daanx.util.component.ToastUtils;
import kesshou.android.daanx.util.network.api.holder.Error;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
package kesshou.android.daanx.util.network;
/**
* Created by yoyoIU on 2016/11/11.
*/
public abstract class MyCallBack<t> implements Callback<t> {
private Context context;
protected MyCallBack(Context mContext){
context=mContext.getApplicationContext();
}
private void onError(Call<t> call,Response<t> response){
Error error = ErrorUtils.parseError(response,context);
ErrorUtils.logError(error);
switch (error.code){
case 103:
break;
case 500:
break;
case 501:
break;
case 100:
break;
case 102:
break;
default: | ToastUtils.makeTextAndShow(context,error.message,Toast.LENGTH_LONG,Gravity.CENTER); |
acromusashi/acromusashi-stream | src/test/java/acromusashi/stream/bolt/AmBaseBoltTest.java | // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.spy;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;
import acromusashi.stream.entity.StreamMessage;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import com.google.common.collect.Lists; | // 検証
ArgumentCaptor<Fields> argument = ArgumentCaptor.forClass(Fields.class);
Mockito.verify(mockDeclarer).declare(argument.capture());
Fields argFields = argument.getValue();
assertThat(argFields.size(), equalTo(2));
assertThat(argFields.get(0), equalTo("messageKey"));
assertThat(argFields.get(1), equalTo("messageValue"));
}
/**
* KeyHistoryInfo未保持Tuple受信時、新規KeyHistoryInfoを生成して動作を継続することを確認する。
*
* @target {@link AmBaseBolt#execute(Tuple)}
* @test 新規KeyHistoryInfoを生成して動作を継続することを確認
* condition:: KeyHistoryInfo未保持Tuple受信時
* result:: 新規KeyHistoryInfoを生成して動作を継続することを確認
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testExecute_KeyHistoryInfo未保持Tuple処理確認()
{
// 準備
Mockito.when(this.mockContext.getThisComponentId()).thenReturn("ComponentId");
Mockito.when(this.mockContext.getThisTaskIndex()).thenReturn(0);
AmBaseThroughBolt targetBolt = new AmBaseThroughBolt();
targetBolt.setFields(Lists.newArrayList("Param1"));
targetBolt.prepare(this.mockConfMap, this.mockContext, this.mockCollector);
| // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
// Path: src/test/java/acromusashi/stream/bolt/AmBaseBoltTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.spy;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;
import acromusashi.stream.entity.StreamMessage;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import com.google.common.collect.Lists;
// 検証
ArgumentCaptor<Fields> argument = ArgumentCaptor.forClass(Fields.class);
Mockito.verify(mockDeclarer).declare(argument.capture());
Fields argFields = argument.getValue();
assertThat(argFields.size(), equalTo(2));
assertThat(argFields.get(0), equalTo("messageKey"));
assertThat(argFields.get(1), equalTo("messageValue"));
}
/**
* KeyHistoryInfo未保持Tuple受信時、新規KeyHistoryInfoを生成して動作を継続することを確認する。
*
* @target {@link AmBaseBolt#execute(Tuple)}
* @test 新規KeyHistoryInfoを生成して動作を継続することを確認
* condition:: KeyHistoryInfo未保持Tuple受信時
* result:: 新規KeyHistoryInfoを生成して動作を継続することを確認
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testExecute_KeyHistoryInfo未保持Tuple処理確認()
{
// 準備
Mockito.when(this.mockContext.getThisComponentId()).thenReturn("ComponentId");
Mockito.when(this.mockContext.getThisTaskIndex()).thenReturn(0);
AmBaseThroughBolt targetBolt = new AmBaseThroughBolt();
targetBolt.setFields(Lists.newArrayList("Param1"));
targetBolt.prepare(this.mockConfMap, this.mockContext, this.mockCollector);
| StreamMessage message = new StreamMessage(); |
acromusashi/acromusashi-stream | src/main/java/acromusashi/stream/component/rabbitmq/spout/MessageKeyExtractor.java | // Path: src/main/java/acromusashi/stream/component/rabbitmq/RabbitmqCommunicateException.java
// public class RabbitmqCommunicateException extends IOException
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -2575872766214401504L;
//
// /**
// * パラメータを指定せずにインスタンスを生成する。
// */
// public RabbitmqCommunicateException()
// {
// super();
// }
//
// /**
// * メッセージを指定してインスタンスを生成する。
// *
// * @param message メッセージ
// */
// public RabbitmqCommunicateException(String message)
// {
// super(message);
// }
//
// /**
// * メッセージ、発生原因例外を指定してインスタンスを生成する。
// *
// * @param message メッセージ
// * @param cause 発生原因例外
// */
// public RabbitmqCommunicateException(String message, Throwable cause)
// {
// super(message, cause);
// }
//
// /**
// * 発生原因例外を指定してインスタンスを生成する。
// *
// * @param cause 発生原因例外
// */
// public RabbitmqCommunicateException(Throwable cause)
// {
// super(cause);
// }
// }
| import acromusashi.stream.component.rabbitmq.RabbitmqCommunicateException;
import java.io.Serializable; | /**
* Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved.
* Please read the associated COPYRIGHTS file for more details.
*
* THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd.,
* 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 HOLDER BE LIABLE FOR ANY
* CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package acromusashi.stream.component.rabbitmq.spout;
/**
* RabbitMQコンポーネント<br>
* <br>
* メッセージキーの抽出を行うクラス。<br>
* RabbitMqSpoutを使用する場合、本インタフェースを継承した抽出クラスを作成し、キーの抽出処理を記述すること。
*/
public interface MessageKeyExtractor extends Serializable
{
/**
* 指定したオブジェクトからメッセージキーの抽出を行う。
*
* @param target RabbitMQから取得したオブジェクト
* @return Object キー情報履歴に記録するメッセージキー
* @throws RabbitmqCommunicateException メッセージキーの抽出に失敗した場合
*/ | // Path: src/main/java/acromusashi/stream/component/rabbitmq/RabbitmqCommunicateException.java
// public class RabbitmqCommunicateException extends IOException
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -2575872766214401504L;
//
// /**
// * パラメータを指定せずにインスタンスを生成する。
// */
// public RabbitmqCommunicateException()
// {
// super();
// }
//
// /**
// * メッセージを指定してインスタンスを生成する。
// *
// * @param message メッセージ
// */
// public RabbitmqCommunicateException(String message)
// {
// super(message);
// }
//
// /**
// * メッセージ、発生原因例外を指定してインスタンスを生成する。
// *
// * @param message メッセージ
// * @param cause 発生原因例外
// */
// public RabbitmqCommunicateException(String message, Throwable cause)
// {
// super(message, cause);
// }
//
// /**
// * 発生原因例外を指定してインスタンスを生成する。
// *
// * @param cause 発生原因例外
// */
// public RabbitmqCommunicateException(Throwable cause)
// {
// super(cause);
// }
// }
// Path: src/main/java/acromusashi/stream/component/rabbitmq/spout/MessageKeyExtractor.java
import acromusashi.stream.component.rabbitmq.RabbitmqCommunicateException;
import java.io.Serializable;
/**
* Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved.
* Please read the associated COPYRIGHTS file for more details.
*
* THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd.,
* 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 HOLDER BE LIABLE FOR ANY
* CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package acromusashi.stream.component.rabbitmq.spout;
/**
* RabbitMQコンポーネント<br>
* <br>
* メッセージキーの抽出を行うクラス。<br>
* RabbitMqSpoutを使用する場合、本インタフェースを継承した抽出クラスを作成し、キーの抽出処理を記述すること。
*/
public interface MessageKeyExtractor extends Serializable
{
/**
* 指定したオブジェクトからメッセージキーの抽出を行う。
*
* @param target RabbitMQから取得したオブジェクト
* @return Object キー情報履歴に記録するメッセージキー
* @throws RabbitmqCommunicateException メッセージキーの抽出に失敗した場合
*/ | String extractMessageKey(Object target) throws RabbitmqCommunicateException; |
acromusashi/acromusashi-stream | src/test/java/acromusashi/stream/spout/AmBaseSpoutTest.java | // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import acromusashi.stream.entity.StreamMessage;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields; | OutputFieldsDeclarer mockDeclarer = Mockito.mock(OutputFieldsDeclarer.class);
// 実施
this.target.declareOutputFields(mockDeclarer);
// 検証
ArgumentCaptor<Fields> argument = ArgumentCaptor.forClass(Fields.class);
Mockito.verify(mockDeclarer).declare(argument.capture());
Fields argFields = argument.getValue();
assertThat(argFields.size(), equalTo(2));
assertThat(argFields.get(0), equalTo("messageKey"));
assertThat(argFields.get(1), equalTo("messageValue"));
}
/**
* Emitメソッド呼び出し時(KeyId個別指定)の引数確認を行う。
*
* @target {@link AmBaseSpout#emit(StreamMessage, Object, Object)}
* @test collectorにemitされるTupleはGroupingKey(空文字)、StreamMessageの順となっていること。<br>
* condition:: MessageKey、MessageIdを個別指定してTupleのemitを行う。<br>
* result:: collectorにemitされるTupleはGroupingKey(空文字)、StreamMessageの順となっていること
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testEmit_KeyId個別指定()
{
// 準備
this.target.open(this.mockConfMap, this.mockContext, this.mockCollector);
| // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
// Path: src/test/java/acromusashi/stream/spout/AmBaseSpoutTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import acromusashi.stream.entity.StreamMessage;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
OutputFieldsDeclarer mockDeclarer = Mockito.mock(OutputFieldsDeclarer.class);
// 実施
this.target.declareOutputFields(mockDeclarer);
// 検証
ArgumentCaptor<Fields> argument = ArgumentCaptor.forClass(Fields.class);
Mockito.verify(mockDeclarer).declare(argument.capture());
Fields argFields = argument.getValue();
assertThat(argFields.size(), equalTo(2));
assertThat(argFields.get(0), equalTo("messageKey"));
assertThat(argFields.get(1), equalTo("messageValue"));
}
/**
* Emitメソッド呼び出し時(KeyId個別指定)の引数確認を行う。
*
* @target {@link AmBaseSpout#emit(StreamMessage, Object, Object)}
* @test collectorにemitされるTupleはGroupingKey(空文字)、StreamMessageの順となっていること。<br>
* condition:: MessageKey、MessageIdを個別指定してTupleのemitを行う。<br>
* result:: collectorにemitされるTupleはGroupingKey(空文字)、StreamMessageの順となっていること
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testEmit_KeyId個別指定()
{
// 準備
this.target.open(this.mockConfMap, this.mockContext, this.mockCollector);
| StreamMessage message = new StreamMessage(); |
acromusashi/acromusashi-stream | src/test/java/acromusashi/stream/bolt/AmBaseThroughBolt.java | // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
| import acromusashi.stream.entity.StreamMessage;
import backtype.storm.task.TopologyContext;
import java.util.List;
import java.util.Map; | /**
* Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved.
* Please read the associated COPYRIGHTS file for more details.
*
* THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd.,
* 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 HOLDER BE LIABLE FOR ANY
* CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package acromusashi.stream.bolt;
/**
* 受信したTupleに対して指定したフィールドを抽出して下流に流すStorm-UnitTest用Bolt<br>
*
* @author kimura
*/
public class AmBaseThroughBolt extends AmBaseBolt
{
/** serialVersionUID */
private static final long serialVersionUID = 1668791100773315754L;
/** StreamMessageにつめるメッセージフィールドリスト */
private List<String> fields;
/**
* パラメータを指定せずにインスタンスを生成する。
*/
public AmBaseThroughBolt()
{}
@SuppressWarnings("rawtypes")
@Override
public void onPrepare(Map stormConf, TopologyContext context)
{
// 何もしない
}
/**
* @param fields the fields to set
*/
public void setFields(List<String> fields)
{
this.fields = fields;
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java
// public class StreamMessage implements Serializable
// {
// /** serialVersionUID */
// private static final long serialVersionUID = -7553630425199269093L;
//
// /** Message Header */
// private StreamMessageHeader header;
//
// /** Message Body */
// private Object body;
//
// /**
// * Constructs instance.
// */
// public StreamMessage()
// {
// this.header = new StreamMessageHeader();
// }
//
// /**
// * Constructs instance with Header and body.
// *
// * @param header Message Header
// * @param body Message Body
// */
// public StreamMessage(StreamMessageHeader header, Object body)
// {
// this.header = header;
// this.body = body;
// }
//
// /**
// * @return the header
// */
// public StreamMessageHeader getHeader()
// {
// return this.header;
// }
//
// /**
// * @param header the header to set
// */
// public void setHeader(StreamMessageHeader header)
// {
// this.header = header;
// }
//
// /**
// * @return the body
// */
// public Object getBody()
// {
// return this.body;
// }
//
// /**
// * @param body the body to set
// */
// public void setBody(Object body)
// {
// this.body = body;
// }
//
// /**
// * Add field to message body.
// *
// * @param key key
// * @param value value
// */
// @SuppressWarnings({"unchecked", "rawtypes"})
// public void addField(String key, Object value)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// this.body = Maps.newLinkedHashMap();
// }
//
// ((Map) this.body).put(key, value);
// }
//
// /**
// * Get field from message body.
// *
// * @param key key
// * @return field mapped key
// */
// @SuppressWarnings("rawtypes")
// public Object getField(String key)
// {
// if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false)
// {
// return null;
// }
//
// return ((Map) this.body).get(key);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String toString()
// {
// String result = this.header.toString() + "," + this.body.toString();
// return result;
// }
// }
// Path: src/test/java/acromusashi/stream/bolt/AmBaseThroughBolt.java
import acromusashi.stream.entity.StreamMessage;
import backtype.storm.task.TopologyContext;
import java.util.List;
import java.util.Map;
/**
* Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved.
* Please read the associated COPYRIGHTS file for more details.
*
* THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd.,
* 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 HOLDER BE LIABLE FOR ANY
* CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package acromusashi.stream.bolt;
/**
* 受信したTupleに対して指定したフィールドを抽出して下流に流すStorm-UnitTest用Bolt<br>
*
* @author kimura
*/
public class AmBaseThroughBolt extends AmBaseBolt
{
/** serialVersionUID */
private static final long serialVersionUID = 1668791100773315754L;
/** StreamMessageにつめるメッセージフィールドリスト */
private List<String> fields;
/**
* パラメータを指定せずにインスタンスを生成する。
*/
public AmBaseThroughBolt()
{}
@SuppressWarnings("rawtypes")
@Override
public void onPrepare(Map stormConf, TopologyContext context)
{
// 何もしない
}
/**
* @param fields the fields to set
*/
public void setFields(List<String> fields)
{
this.fields = fields;
}
/**
* {@inheritDoc}
*/
@Override | public void onExecute(StreamMessage input) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.