blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
sequence | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
sequence | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8d73282d37e2d4a0d44f0813705ef016f1bb2f0e | 35,064,113,059,924 | a34aefb0609d2cb6afdb971c65d8fbe48e616f98 | /catalogue-service-micro/src/main/java/eu/nimble/service/catalogue/impl/ProductCategoryController.java | f831a227f911cbec930d96aa15e477c1729ad873 | [
"Apache-2.0"
] | permissive | nimble-platform/catalog-service | https://github.com/nimble-platform/catalog-service | 6963a200f4557761a380c04c95d1128e253cb4b0 | b00333e582bf43bf95762fd61c8a354f0dd1af67 | refs/heads/master | 2023-04-09T23:45:46.046000 | 2022-07-14T12:51:54 | 2022-07-14T12:51:54 | 81,943,995 | 3 | 4 | Apache-2.0 | false | 2023-01-13T01:55:30 | 2017-02-14T12:41:00 | 2022-01-10T12:50:23 | 2023-01-13T01:55:26 | 3,791 | 2 | 4 | 15 | Java | false | false | package eu.nimble.service.catalogue.impl;
import eu.nimble.service.catalogue.category.IndexCategoryService;
import eu.nimble.service.catalogue.category.TaxonomyManager;
import eu.nimble.service.catalogue.category.TaxonomyQueryInterface;
import eu.nimble.service.catalogue.category.eclass.EClassIndexLoader;
import eu.nimble.service.catalogue.config.RoleConfig;
import eu.nimble.service.catalogue.exception.NimbleExceptionMessageCode;
import eu.nimble.service.catalogue.model.category.Category;
import eu.nimble.service.catalogue.model.category.CategoryTreeResponse;
import eu.nimble.service.catalogue.index.ClassIndexClient;
import eu.nimble.service.catalogue.util.SpringBridge;
import eu.nimble.utility.ExecutionContext;
import eu.nimble.utility.exception.NimbleException;
import eu.nimble.utility.validation.IValidationUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* Product category related REST services
*/
@Controller
public class ProductCategoryController {
private static Logger log = LoggerFactory
.getLogger(ProductCategoryController.class);
@Autowired
private TaxonomyManager taxonomyManager;
@Autowired
private IndexCategoryService categoryService;
@Autowired
private ClassIndexClient classIndexClient;
@Autowired
private EClassIndexLoader eClassIndexLoader;
@Autowired
private IValidationUtil validationUtil;
@Autowired
private ExecutionContext executionContext;
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves a list of Category instances. This operation takes a list of category ids and " +
"another list containing corresponding taxonomy ids of each category. See the examples in parameter definitions.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the specified categories successfully", responseContainer = "List", response = Category.class),
@ApiResponse(code = 400, message = "(taxonomyId/categoryId) pairs are not provided; number of elements in taxonomy id and category id lists do not match"),
@ApiResponse(code = 500, message = "Unexpected error while getting categories")
})
@RequestMapping(value = "/categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getSpecificCategories(@ApiParam(value = "Comma-separated category ids to be retrieved e.g. 0173-1#01-BAC439#012,0173-1#01-AJZ694#013", required = true) @RequestParam(required = false) List<String> categoryIds,
@ApiParam(value = "Comma-separated taxonomy ids corresponding to the specified category ids e.g. eClass, eClass", required = true) @RequestParam(required = false) List<String> taxonomyIds,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get categories";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
List<Category> categories = new ArrayList<>();
if (taxonomyIds != null && taxonomyIds.size() > 0 && categoryIds != null && categoryIds.size() > 0) {
// ensure that taxonomy id and category id lists have the same size
if (taxonomyIds.size() != categoryIds.size()) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_PARAMETERS_TO_GET_CATEGORIES.toString());
}
// validate taxonomy ids
for (int i = 0; i < taxonomyIds.size(); i++) {
if(!taxonomyIdExists(taxonomyIds.get(i))){
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(), Arrays.asList(taxonomyIds.get(i)));
}
}
categories = categoryService.getCategories(taxonomyIds, categoryIds);
} else {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_MISSING_PARAMETERS_TO_GET_CATEGORIES.toString());
}
log.info("Completed request to get categories. size: {}", categories.size());
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves a list of Category instances. This method takes a name and taxonomy id." +
" If a valid taxonomy id is provided,then category name is looked for in that taxonomy.If no taxonomy id is " +
" provided,then category name is looked for in all managed taxonomies. See the examples in parameter definitions.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved categories for the specified parameters successfully", responseContainer = "List", response = Category.class),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getCategoriesByName(@ApiParam(value = "A name describing the categories to be retrieved. This parameter does not necessarily have to be the exact name of the category.", required = true) @RequestParam String name,
@ApiParam(value = "Taxonomy id from which categories would be retrieved. If no taxonomy id is specified, all available taxonomies are considered. In addition to the taxonomies ids as returned by getAvailableTaxonomyIds method, 'all' value can be specified in order to get categories from all the taxonomies", required = true) @PathVariable String taxonomyId,
@ApiParam(value = "An indicator for retrieving categories for logistics service or regular products. If not specified, no such distinction is considered.", defaultValue = "false") @RequestParam(required = false,defaultValue = "false") Boolean forLogistics,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get categories by name";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// check whether the taxonomy id is valid or not
if(!(taxonomyId.compareToIgnoreCase("all") == 0 || taxonomyIdExists(taxonomyId))) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<Category> categories = new ArrayList<>();
if(taxonomyId.compareToIgnoreCase("all") == 0 ){
log.info("Getting categories for name: {}", name);
categories.addAll(categoryService.getProductCategories(name,null,forLogistics));
}
else {
log.info("Getting categories for name: {}, taxonomyId: {}", name,taxonomyId);
categories.addAll(categoryService.getProductCategories(name,taxonomyId,forLogistics));
}
log.info("Completed request to get categories by name. size: {}", categories.size());
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the identifiers of the available product category taxonomies")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the identifiers of the available taxonomies successfully", response = String.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Unexpected error while getting identifiers of the available taxonomies")
})
@RequestMapping(value = "/taxonomies/id",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getAvailableTaxonomyIds(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get available taxonomy ids";
executionContext.setRequestLog(requestLog);
List<String> taxonomies = new ArrayList<>();
try {
SpringBridge.getInstance().getTaxonomyManager().getTaxonomiesMap().keySet().forEach(id -> taxonomies.add(id));
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_GET_AVAILABLE_TAXONOMIES.toString(),e);
}
return ResponseEntity.ok(taxonomies);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the map of logistics services and corresponding category uris for the given taxonomy id")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the logistics related services-category uri map successfully"),
@ApiResponse(code = 500, message = "Unexpected error while getting the logistics related services-category map")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/logistics-services",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getLogisticsRelatedServices(@ApiParam(value = "The taxonomy id which is used to retrieve logistic related services. If 'all' value is specified for taxonomy id, then logistic related services for each available taxonomy id are returned.",required = true) @PathVariable(value = "taxonomyId",required = true) String taxonomyId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get the logistics related services-category map for taxonomy id: %s",taxonomyId);
executionContext.setRequestLog(requestLog);
log.info(requestLog);
Map<String,Map<String,String>> logisticServicesCategoryUriMap = categoryService.getLogisticsRelatedServices(taxonomyId);
log.info("Completed request to get the logistics related services-category uri map for taxonomy id: {}", taxonomyId);
return ResponseEntity.ok(logisticServicesCategoryUriMap);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves root categories of the specified taxonomies")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the root categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/root-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getRootCategories(@ApiParam(value = "Taxonomy id from which categories would be retrieved.",required = true) @RequestParam(value = "taxonomyIds") List<String> taxonomyIds,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get root categories for taxonomies: %s", taxonomyIds);
log.info(requestLog);
executionContext.setRequestLog(requestLog);
for (String taxonomyId : taxonomyIds) {
if(!taxonomyIdExists(taxonomyId)){
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(), Collections.singletonList(taxonomyId));
}
}
List<Category> categories = categoryService.getRootCategories(taxonomyIds);
log.info("Completed request to get root categories for taxonomies: %{}", taxonomyIds);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves service of the specified taxonomy")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the service categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/service-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getServiceCategoryUris(@ApiParam(value = "Taxonomy id from which categories would be retrieved.", required = true) @PathVariable String taxonomyId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get service categories for taxonomy: %s", taxonomyId);
log.info(requestLog);
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<String> categoryUris = taxonomyManager.getTaxonomiesMap().get(taxonomyId).getTaxonomy().getServiceRootCategories();
if (categoryUris == null) {
categoryUris = new ArrayList<>();
}
log.info("Completed request to get service categories for taxonomy: {}", taxonomyId);
return ResponseEntity.ok(categoryUris);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves children categories for the specified category")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved children categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id"),
@ApiResponse(code = 404, message = "There does not exist a category with the given id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories/children-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getChildrenCategories(@ApiParam(value = "Taxonomy id containing the category for which children categories to be retrieved", required = true) @PathVariable("taxonomyId") String taxonomyId,
@ApiParam(value = "Category ifd for which the children categories to be retrieved", required = true) @RequestParam("categoryId") String categoryId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to get children categories";
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<Category> categories = categoryService.getChildrenCategories(taxonomyId, categoryId);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the parents of the category and siblings of all the way to the root-level parent" +
" category. For example, considering the MDF Raw category in the eClass taxonomy, the parents list in the response" +
" contains all the categories including the specified category itself: Construction technology >> Wood, timber material" +
" >> Wood fiberboard (MDF, HDF, LDF) >> MDF raw. The categories list contains the list of siblings for each category" +
" specified in the parents list.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the parents of the category and their siblings successfully", response = CategoryTreeResponse.class),
@ApiResponse(code = 400, message = "Invalid taxonomy id"),
@ApiResponse(code = 404, message = "There does not exist a category with the given id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories/tree",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getCategoryTree(@ApiParam(value = "Taxonomy id containing the category for which children categories to be retrieved", required = true) @PathVariable("taxonomyId") String taxonomyId,
@ApiParam(value = "Category ifd for which the children categories to be retrieved", required = true) @RequestParam("categoryId") String categoryId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to get category tree";
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
CategoryTreeResponse categories = categoryService.getCategoryTree(taxonomyId, categoryId);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes eClass resources,i.e. eClass categories and properties.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass resources successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass resources")
})
@RequestMapping(value = "/categories/eClass/index",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity indexEclassResources(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass resources.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken,executionContext.getUserRoles(), RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_RESOURCES.toString());
}
try {
eClassIndexLoader.indexEClassResources();
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_RESOURCES.toString(),e);
}
return ResponseEntity.ok(null);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes the given eClass properties.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass properties successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass properties")
})
@RequestMapping(value = "/categories/eClass/index/properties",
produces = {"application/json"},
method = RequestMethod.POST)
public ResponseEntity indexEclassProperties(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken,
@ApiParam(value = "Identifiers of eClass properties to be indexed") @RequestBody List<String> propertyIds) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass properties.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken,executionContext.getUserRoles(), RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_PROPERTIES.toString());
}
try {
eClassIndexLoader.indexEClassProperties(propertyIds);
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_PROPERTIES.toString(),e);
}
return ResponseEntity.ok(null);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes the given eClass categories.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass categories successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass categories")
})
@RequestMapping(value = "/categories/eClass/index/categories",
produces = {"application/json"},
method = RequestMethod.POST)
public ResponseEntity indexEclassCategories(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken,
@ApiParam(value = "Identifiers of eClass categories to be indexed") @RequestBody List<String> categoryIds) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass categories.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken, executionContext.getUserRoles(),RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_CATEGORIES.toString());
}
try {
eClassIndexLoader.indexEClassCategories(categoryIds);
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_CATEGORIES.toString(),e);
}
return ResponseEntity.ok(null);
}
private boolean taxonomyIdExists(String taxonomyId) {
for(TaxonomyQueryInterface taxonomyQueryInterface: SpringBridge.getInstance().getTaxonomyManager().getTaxonomiesMap().values()){
if(taxonomyQueryInterface.getTaxonomy().getId().compareToIgnoreCase(taxonomyId) == 0){
return true;
}
}
return false;
}
} | UTF-8 | Java | 23,960 | java | ProductCategoryController.java | Java | [] | null | [] | package eu.nimble.service.catalogue.impl;
import eu.nimble.service.catalogue.category.IndexCategoryService;
import eu.nimble.service.catalogue.category.TaxonomyManager;
import eu.nimble.service.catalogue.category.TaxonomyQueryInterface;
import eu.nimble.service.catalogue.category.eclass.EClassIndexLoader;
import eu.nimble.service.catalogue.config.RoleConfig;
import eu.nimble.service.catalogue.exception.NimbleExceptionMessageCode;
import eu.nimble.service.catalogue.model.category.Category;
import eu.nimble.service.catalogue.model.category.CategoryTreeResponse;
import eu.nimble.service.catalogue.index.ClassIndexClient;
import eu.nimble.service.catalogue.util.SpringBridge;
import eu.nimble.utility.ExecutionContext;
import eu.nimble.utility.exception.NimbleException;
import eu.nimble.utility.validation.IValidationUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* Product category related REST services
*/
@Controller
public class ProductCategoryController {
private static Logger log = LoggerFactory
.getLogger(ProductCategoryController.class);
@Autowired
private TaxonomyManager taxonomyManager;
@Autowired
private IndexCategoryService categoryService;
@Autowired
private ClassIndexClient classIndexClient;
@Autowired
private EClassIndexLoader eClassIndexLoader;
@Autowired
private IValidationUtil validationUtil;
@Autowired
private ExecutionContext executionContext;
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves a list of Category instances. This operation takes a list of category ids and " +
"another list containing corresponding taxonomy ids of each category. See the examples in parameter definitions.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the specified categories successfully", responseContainer = "List", response = Category.class),
@ApiResponse(code = 400, message = "(taxonomyId/categoryId) pairs are not provided; number of elements in taxonomy id and category id lists do not match"),
@ApiResponse(code = 500, message = "Unexpected error while getting categories")
})
@RequestMapping(value = "/categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getSpecificCategories(@ApiParam(value = "Comma-separated category ids to be retrieved e.g. 0173-1#01-BAC439#012,0173-1#01-AJZ694#013", required = true) @RequestParam(required = false) List<String> categoryIds,
@ApiParam(value = "Comma-separated taxonomy ids corresponding to the specified category ids e.g. eClass, eClass", required = true) @RequestParam(required = false) List<String> taxonomyIds,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get categories";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
List<Category> categories = new ArrayList<>();
if (taxonomyIds != null && taxonomyIds.size() > 0 && categoryIds != null && categoryIds.size() > 0) {
// ensure that taxonomy id and category id lists have the same size
if (taxonomyIds.size() != categoryIds.size()) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_PARAMETERS_TO_GET_CATEGORIES.toString());
}
// validate taxonomy ids
for (int i = 0; i < taxonomyIds.size(); i++) {
if(!taxonomyIdExists(taxonomyIds.get(i))){
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(), Arrays.asList(taxonomyIds.get(i)));
}
}
categories = categoryService.getCategories(taxonomyIds, categoryIds);
} else {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_MISSING_PARAMETERS_TO_GET_CATEGORIES.toString());
}
log.info("Completed request to get categories. size: {}", categories.size());
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves a list of Category instances. This method takes a name and taxonomy id." +
" If a valid taxonomy id is provided,then category name is looked for in that taxonomy.If no taxonomy id is " +
" provided,then category name is looked for in all managed taxonomies. See the examples in parameter definitions.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved categories for the specified parameters successfully", responseContainer = "List", response = Category.class),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getCategoriesByName(@ApiParam(value = "A name describing the categories to be retrieved. This parameter does not necessarily have to be the exact name of the category.", required = true) @RequestParam String name,
@ApiParam(value = "Taxonomy id from which categories would be retrieved. If no taxonomy id is specified, all available taxonomies are considered. In addition to the taxonomies ids as returned by getAvailableTaxonomyIds method, 'all' value can be specified in order to get categories from all the taxonomies", required = true) @PathVariable String taxonomyId,
@ApiParam(value = "An indicator for retrieving categories for logistics service or regular products. If not specified, no such distinction is considered.", defaultValue = "false") @RequestParam(required = false,defaultValue = "false") Boolean forLogistics,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get categories by name";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// check whether the taxonomy id is valid or not
if(!(taxonomyId.compareToIgnoreCase("all") == 0 || taxonomyIdExists(taxonomyId))) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<Category> categories = new ArrayList<>();
if(taxonomyId.compareToIgnoreCase("all") == 0 ){
log.info("Getting categories for name: {}", name);
categories.addAll(categoryService.getProductCategories(name,null,forLogistics));
}
else {
log.info("Getting categories for name: {}, taxonomyId: {}", name,taxonomyId);
categories.addAll(categoryService.getProductCategories(name,taxonomyId,forLogistics));
}
log.info("Completed request to get categories by name. size: {}", categories.size());
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the identifiers of the available product category taxonomies")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the identifiers of the available taxonomies successfully", response = String.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Unexpected error while getting identifiers of the available taxonomies")
})
@RequestMapping(value = "/taxonomies/id",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getAvailableTaxonomyIds(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog ="Incoming request to get available taxonomy ids";
executionContext.setRequestLog(requestLog);
List<String> taxonomies = new ArrayList<>();
try {
SpringBridge.getInstance().getTaxonomyManager().getTaxonomiesMap().keySet().forEach(id -> taxonomies.add(id));
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_GET_AVAILABLE_TAXONOMIES.toString(),e);
}
return ResponseEntity.ok(taxonomies);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the map of logistics services and corresponding category uris for the given taxonomy id")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the logistics related services-category uri map successfully"),
@ApiResponse(code = 500, message = "Unexpected error while getting the logistics related services-category map")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/logistics-services",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getLogisticsRelatedServices(@ApiParam(value = "The taxonomy id which is used to retrieve logistic related services. If 'all' value is specified for taxonomy id, then logistic related services for each available taxonomy id are returned.",required = true) @PathVariable(value = "taxonomyId",required = true) String taxonomyId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get the logistics related services-category map for taxonomy id: %s",taxonomyId);
executionContext.setRequestLog(requestLog);
log.info(requestLog);
Map<String,Map<String,String>> logisticServicesCategoryUriMap = categoryService.getLogisticsRelatedServices(taxonomyId);
log.info("Completed request to get the logistics related services-category uri map for taxonomy id: {}", taxonomyId);
return ResponseEntity.ok(logisticServicesCategoryUriMap);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves root categories of the specified taxonomies")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the root categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/root-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getRootCategories(@ApiParam(value = "Taxonomy id from which categories would be retrieved.",required = true) @RequestParam(value = "taxonomyIds") List<String> taxonomyIds,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get root categories for taxonomies: %s", taxonomyIds);
log.info(requestLog);
executionContext.setRequestLog(requestLog);
for (String taxonomyId : taxonomyIds) {
if(!taxonomyIdExists(taxonomyId)){
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(), Collections.singletonList(taxonomyId));
}
}
List<Category> categories = categoryService.getRootCategories(taxonomyIds);
log.info("Completed request to get root categories for taxonomies: %{}", taxonomyIds);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves service of the specified taxonomy")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the service categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/service-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getServiceCategoryUris(@ApiParam(value = "Taxonomy id from which categories would be retrieved.", required = true) @PathVariable String taxonomyId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = String.format("Incoming request to get service categories for taxonomy: %s", taxonomyId);
log.info(requestLog);
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<String> categoryUris = taxonomyManager.getTaxonomiesMap().get(taxonomyId).getTaxonomy().getServiceRootCategories();
if (categoryUris == null) {
categoryUris = new ArrayList<>();
}
log.info("Completed request to get service categories for taxonomy: {}", taxonomyId);
return ResponseEntity.ok(categoryUris);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves children categories for the specified category")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved children categories successfully", response = Category.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid taxonomy id"),
@ApiResponse(code = 404, message = "There does not exist a category with the given id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories/children-categories",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getChildrenCategories(@ApiParam(value = "Taxonomy id containing the category for which children categories to be retrieved", required = true) @PathVariable("taxonomyId") String taxonomyId,
@ApiParam(value = "Category ifd for which the children categories to be retrieved", required = true) @RequestParam("categoryId") String categoryId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to get children categories";
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
List<Category> categories = categoryService.getChildrenCategories(taxonomyId, categoryId);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Retrieves the parents of the category and siblings of all the way to the root-level parent" +
" category. For example, considering the MDF Raw category in the eClass taxonomy, the parents list in the response" +
" contains all the categories including the specified category itself: Construction technology >> Wood, timber material" +
" >> Wood fiberboard (MDF, HDF, LDF) >> MDF raw. The categories list contains the list of siblings for each category" +
" specified in the parents list.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Retrieved the parents of the category and their siblings successfully", response = CategoryTreeResponse.class),
@ApiResponse(code = 400, message = "Invalid taxonomy id"),
@ApiResponse(code = 404, message = "There does not exist a category with the given id")
})
@RequestMapping(value = "/taxonomies/{taxonomyId}/categories/tree",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity getCategoryTree(@ApiParam(value = "Taxonomy id containing the category for which children categories to be retrieved", required = true) @PathVariable("taxonomyId") String taxonomyId,
@ApiParam(value = "Category ifd for which the children categories to be retrieved", required = true) @RequestParam("categoryId") String categoryId,
@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to get category tree";
executionContext.setRequestLog(requestLog);
if (!taxonomyIdExists(taxonomyId)) {
throw new NimbleException(NimbleExceptionMessageCode.BAD_REQUEST_INVALID_TAXONOMY.toString(),Arrays.asList(taxonomyId));
}
CategoryTreeResponse categories = categoryService.getCategoryTree(taxonomyId, categoryId);
return ResponseEntity.ok(categories);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes eClass resources,i.e. eClass categories and properties.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass resources successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass resources")
})
@RequestMapping(value = "/categories/eClass/index",
produces = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity indexEclassResources(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass resources.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken,executionContext.getUserRoles(), RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_RESOURCES.toString());
}
try {
eClassIndexLoader.indexEClassResources();
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_RESOURCES.toString(),e);
}
return ResponseEntity.ok(null);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes the given eClass properties.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass properties successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass properties")
})
@RequestMapping(value = "/categories/eClass/index/properties",
produces = {"application/json"},
method = RequestMethod.POST)
public ResponseEntity indexEclassProperties(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken,
@ApiParam(value = "Identifiers of eClass properties to be indexed") @RequestBody List<String> propertyIds) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass properties.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken,executionContext.getUserRoles(), RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_PROPERTIES.toString());
}
try {
eClassIndexLoader.indexEClassProperties(propertyIds);
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_PROPERTIES.toString(),e);
}
return ResponseEntity.ok(null);
}
@CrossOrigin(origins = {"*"})
@ApiOperation(value = "", notes = "Indexes the given eClass categories.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indexed eClass categories successfully"),
@ApiResponse(code = 401, message = "No user exists for the given token"),
@ApiResponse(code = 500, message = "Failed to index eClass categories")
})
@RequestMapping(value = "/categories/eClass/index/categories",
produces = {"application/json"},
method = RequestMethod.POST)
public ResponseEntity indexEclassCategories(@ApiParam(value = "The Bearer token provided by the identity service", required = true) @RequestHeader(value = "Authorization", required = true) String bearerToken,
@ApiParam(value = "Identifiers of eClass categories to be indexed") @RequestBody List<String> categoryIds) {
// set request log of ExecutionContext
String requestLog = "Incoming request to index eClass categories.";
executionContext.setRequestLog(requestLog);
log.info(requestLog);
// validate role
if(!validationUtil.validateRole(bearerToken, executionContext.getUserRoles(),RoleConfig.REQUIRED_ROLES_FOR_ADMIN_OPERATIONS)) {
throw new NimbleException(NimbleExceptionMessageCode.UNAUTHORIZED_INDEX_ECLASS_CATEGORIES.toString());
}
try {
eClassIndexLoader.indexEClassCategories(categoryIds);
} catch (Exception e) {
throw new NimbleException(NimbleExceptionMessageCode.INTERNAL_SERVER_ERROR_INDEX_ECLASS_CATEGORIES.toString(),e);
}
return ResponseEntity.ok(null);
}
private boolean taxonomyIdExists(String taxonomyId) {
for(TaxonomyQueryInterface taxonomyQueryInterface: SpringBridge.getInstance().getTaxonomyManager().getTaxonomiesMap().values()){
if(taxonomyQueryInterface.getTaxonomy().getId().compareToIgnoreCase(taxonomyId) == 0){
return true;
}
}
return false;
}
} | 23,960 | 0.686352 | 0.681427 | 382 | 61.725132 | 60.753304 | 404 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.811518 | false | false | 13 |
ba2cf0d5663e20aad3cd198457d933209bd78e10 | 37,744,172,613,184 | 251c46cb57985340f04aeba92ece8489fd48e9ca | /Java_Practice/src/com/java/practice/SortEmployeesComparable.java | 5b911876ab0786786aebc42886c87f8fe42b8dd8 | [] | no_license | vipul9171/JavaPractice | https://github.com/vipul9171/JavaPractice | f82b60d8717f38ff9c42b0ddd77f56d7e8159e8c | 589ccd99720e94c3741176a28c78ecd87f6f26bf | refs/heads/master | 2023-04-19T08:36:05.020000 | 2021-05-15T20:11:06 | 2021-05-15T20:11:06 | 367,717,646 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.java.practice;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Employee implements Comparable<Employee> {
private int id;
private String name;
private int salary;
public Employee(int id, String name, int salary) {
super();
this.id = id;
this.name = name;
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
@Override
public int compareTo(Employee emp) {
if (id == emp.getId()) {
return 0;
} else {
if (id > emp.getId()) {
return 1;
}
}
return -1;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]";
}
}
public class SortEmployeesComparable {
public static void main(String[] args) {
List<Employee> list = new ArrayList<>();
list.add(new Employee(102, "Employee2", 1002));
list.add(new Employee(101, "Employee1", 1001));
list.add(new Employee(104, "Employee4", 1004));
list.add(new Employee(103, "Employee3", 1003));
System.out.println("List before sorting of elements");
System.out.println(list.toString());
Collections.sort(list);
System.out.println("List After sorting of elements");
System.out.println(list.toString());
}
}
| UTF-8 | Java | 1,574 | java | SortEmployeesComparable.java | Java | [] | null | [] | package com.java.practice;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Employee implements Comparable<Employee> {
private int id;
private String name;
private int salary;
public Employee(int id, String name, int salary) {
super();
this.id = id;
this.name = name;
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
@Override
public int compareTo(Employee emp) {
if (id == emp.getId()) {
return 0;
} else {
if (id > emp.getId()) {
return 1;
}
}
return -1;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]";
}
}
public class SortEmployeesComparable {
public static void main(String[] args) {
List<Employee> list = new ArrayList<>();
list.add(new Employee(102, "Employee2", 1002));
list.add(new Employee(101, "Employee1", 1001));
list.add(new Employee(104, "Employee4", 1004));
list.add(new Employee(103, "Employee3", 1003));
System.out.println("List before sorting of elements");
System.out.println(list.toString());
Collections.sort(list);
System.out.println("List After sorting of elements");
System.out.println(list.toString());
}
}
| 1,574 | 0.625794 | 0.603558 | 79 | 17.924051 | 18.08893 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.658228 | false | false | 13 |
4a7956f3a9b43d8234fe7fbe98608e9f0bdffa4b | 11,776,800,360,715 | d2b4274400022b05b10943c235b280e8e453db84 | /Reflection/Method/src/com/nasimeshomal/Greeting.java | a91ec9bf50241d97a9894f155832c17c832c76c4 | [] | no_license | mhdr/JavaSamples | https://github.com/mhdr/JavaSamples | 22e4fb7aa7b0e193cdf564741c55d431a3ffa073 | 9839da788b6abdfa855dfa36ab10fe1a39ac1c9b | refs/heads/master | 2021-01-13T02:41:40.613000 | 2016-12-30T16:54:26 | 2016-12-30T16:54:26 | 30,691,588 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nasimeshomal;
/**
* Created by Mahmood on 9/7/2014.
*/
public class Greeting {
public void sayHello(String name)
{
System.out.println(this.getGreeting(name));
}
public String getGreeting(String name)
{
return String.format("Hello %s",name);
}
}
| UTF-8 | Java | 302 | java | Greeting.java | Java | [
{
"context": "package com.nasimeshomal;\n\n/**\n * Created by Mahmood on 9/7/2014.\n */\npublic class Greeting {\n\n pub",
"end": 52,
"score": 0.9995561242103577,
"start": 45,
"tag": "NAME",
"value": "Mahmood"
}
] | null | [] | package com.nasimeshomal;
/**
* Created by Mahmood on 9/7/2014.
*/
public class Greeting {
public void sayHello(String name)
{
System.out.println(this.getGreeting(name));
}
public String getGreeting(String name)
{
return String.format("Hello %s",name);
}
}
| 302 | 0.625828 | 0.60596 | 17 | 16.764706 | 17.988655 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.235294 | false | false | 13 |
bd7ed9993d5a759bb42445afbd12191fd5ab73e6 | 11,776,800,362,770 | e9cc793f3e9803b7b57ce17b0667fa8ddfc41098 | /src/com/yzhou9071/Leetcode/N59_SpiralMatrix2.java | 69f687840630f8a6dbe5b613d610f75fbfd4d224 | [] | no_license | yzhou9071/LeetcodeAndAlgorithm | https://github.com/yzhou9071/LeetcodeAndAlgorithm | 2389affbb8cbcf1218a616d1e43b0420c5dabda4 | 95d5e59615e2207d0b83e98ccd4aa889f2f9da30 | refs/heads/master | 2021-01-21T04:55:05.272000 | 2016-06-28T09:28:29 | 2016-06-28T09:28:29 | 52,944,405 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yzhou9071.Leetcode;
public class N59_SpiralMatrix2 {
public int[][] generateMatrix(int n) {
if(n < 0)
return null;
int[][] ret = new int[n][n];
int num = 0;
for(int level=0;level<n/2;level++){
for(int i=level;i<n-1-level;i++)
ret[level][i] = ++num;
for(int i=level;i<n-1-level;i++)
ret[i][n-level-1] = ++num;
for(int i=n-1-level;i>level;i--)
ret[n-1-level][i] = ++num;
for(int i=n-1-level;i>level;i--)
ret[i][level] = ++num;
}
if(n%2 == 1)
ret[n/2][n/2] = ++num;
return ret;
}
}
| UTF-8 | Java | 548 | java | N59_SpiralMatrix2.java | Java | [] | null | [] | package com.yzhou9071.Leetcode;
public class N59_SpiralMatrix2 {
public int[][] generateMatrix(int n) {
if(n < 0)
return null;
int[][] ret = new int[n][n];
int num = 0;
for(int level=0;level<n/2;level++){
for(int i=level;i<n-1-level;i++)
ret[level][i] = ++num;
for(int i=level;i<n-1-level;i++)
ret[i][n-level-1] = ++num;
for(int i=n-1-level;i>level;i--)
ret[n-1-level][i] = ++num;
for(int i=n-1-level;i>level;i--)
ret[i][level] = ++num;
}
if(n%2 == 1)
ret[n/2][n/2] = ++num;
return ret;
}
}
| 548 | 0.547445 | 0.509124 | 24 | 21.833334 | 12.840907 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.958333 | false | false | 13 |
a0be6b76a5562f3c0d028251f1d90b38fb3bf616 | 12,799,002,600,047 | 0bb42a253ef3dade3875fd7469cd394df155b8b3 | /app/src/main/java/ru/yandex/yamblz/domain/mapper/Mapper.java | 76837332324ecbc40ce3ae75f7fc419cc0a5667c | [] | no_license | GretSOX/fragments | https://github.com/GretSOX/fragments | 070e835951b56fec33d478c4297d1b1c13cdb008 | c6c5c750edeaf8e5f1a72db61e142d8afb160ba3 | refs/heads/master | 2017-10-02T23:47:28.229000 | 2016-08-12T07:06:19 | 2016-08-12T07:06:19 | 64,923,164 | 0 | 0 | null | true | 2016-08-04T09:48:18 | 2016-08-04T09:48:18 | 2016-08-02T10:11:12 | 2016-08-03T13:34:04 | 2,245 | 0 | 0 | 0 | null | null | null | package ru.yandex.yamblz.domain.mapper;
import java.util.Collection;
import java.util.List;
/**
* Created by Александр on 10.08.2016.
*/
public interface Mapper<Bad, Good> {
Good improove(Bad bad);
List<Good> improove(List<Bad> bads);
}
| UTF-8 | Java | 259 | java | Mapper.java | Java | [
{
"context": "lection;\nimport java.util.List;\n\n/**\n * Created by Александр on 10.08.2016.\n */\n\npublic interface Mapper<Bad, ",
"end": 121,
"score": 0.9998590350151062,
"start": 112,
"tag": "NAME",
"value": "Александр"
}
] | null | [] | package ru.yandex.yamblz.domain.mapper;
import java.util.Collection;
import java.util.List;
/**
* Created by Александр on 10.08.2016.
*/
public interface Mapper<Bad, Good> {
Good improove(Bad bad);
List<Good> improove(List<Bad> bads);
}
| 259 | 0.704 | 0.672 | 13 | 18.23077 | 16.539713 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 13 |
48882ad0a8e10603a0cb2a8b413b013fa4ea5300 | 24,000,277,317,978 | 4226591afe5e7d10b0895d1a8c2901e6f262c4cc | /src/test/java/com/kakaopay/app/backend/service/ToDoServiceTest.java | e5b42e62648b5a580a92b6cbd639e2ae07456145 | [] | no_license | LeeSiHyung/kakaopay | https://github.com/LeeSiHyung/kakaopay | c93d6ea4f658eee5caa50907457d81f8a211bf05 | d711298b54a9073323f6d1f98c8d259910ede2bc | refs/heads/master | 2020-04-18T08:06:19.405000 | 2019-01-24T15:44:50 | 2019-01-24T15:44:50 | 167,120,178 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kakaopay.app.backend.service;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.transaction.Transactional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.kakaopay.app.backend.exception.ReferenceDataException;
import com.kakaopay.app.backend.model.ToDoList;
import com.kakaopay.app.backend.repository.ToDoListRepository;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({
"file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml",
"file:src/main/webapp/WEB-INF/spring/transaction-context.xml"
})
public class ToDoServiceTest {
@Autowired
private ToDoServiceImp apiService;
@Autowired
private ToDoListRepository toDoListRepository;
ToDoList saveToDo;
@Before
public void setUp() {
toDoListRepository.deleteAll();
saveToDo = new ToDoList("할일0", "Y");
}
//@Test
@Transactional
public void insertTest() {
saveToDo = apiService.insert(saveToDo);
assertThat(toDoListRepository.count(), is(1L));
}
//@Test
@Transactional
public void updateTest() {
saveToDo = apiService.insert(saveToDo);
saveToDo.setTodo("할일0 수정");;
saveToDo = apiService.update(saveToDo);
assertThat(apiService.view(saveToDo.getId()).getTodo(), is("할일0 수정"));
}
//@Test
@Transactional
public void completeTest() {
saveToDo = apiService.insert(saveToDo);
List<ToDoList> saveToDoList = Arrays.asList(
new ToDoList("할일1", "N"),
new ToDoList("할일2", "Y"),
new ToDoList("할일3", "Y"));
saveToDoList = toDoListRepository.save(saveToDoList);
assertThat(toDoListRepository.count(), is(4L));
ToDoList toDoList = apiService.view(saveToDoList.get(0).getId());
toDoList.setComYn("Y");
toDoList = apiService.complete(saveToDo.getId());
assertThat(apiService.view(saveToDo.getId()).getComYn(), is("Y"));
}
@Test
@Transactional
public void completeErrorTest() {
saveToDo.setComYn("N");
long id = apiService.insert(saveToDo).getId();
ToDoList tmp = apiService.insert(new ToDoList("체크@" + id, "N"));
tmp.setComYn("Y");
saveToDo = apiService.complete(tmp.getId());
assertThat(saveToDo.getErrorCode(), is("500"));
}
//@Test
@Transactional
public void viewTest() {
saveToDo = apiService.insert(saveToDo);
ToDoList toDoListUsingId = apiService.view(saveToDo.getId());
assertThat(toDoListUsingId.getId(), is(saveToDo.getId()));
saveToDo.setComYn("Y");
saveToDo = apiService.insert(saveToDo);
assertThat(apiService.view(saveToDo.getId()).getComYn(), is("Y"));
}
//@Test
@Transactional
public void deleteTest() {
saveToDo = apiService.insert(saveToDo);
apiService.delete(saveToDo.getId());
assertNull(apiService.view(saveToDo.getId()));
}
}
| UTF-8 | Java | 3,122 | java | ToDoServiceTest.java | Java | [] | null | [] | package com.kakaopay.app.backend.service;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.transaction.Transactional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.kakaopay.app.backend.exception.ReferenceDataException;
import com.kakaopay.app.backend.model.ToDoList;
import com.kakaopay.app.backend.repository.ToDoListRepository;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({
"file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml",
"file:src/main/webapp/WEB-INF/spring/transaction-context.xml"
})
public class ToDoServiceTest {
@Autowired
private ToDoServiceImp apiService;
@Autowired
private ToDoListRepository toDoListRepository;
ToDoList saveToDo;
@Before
public void setUp() {
toDoListRepository.deleteAll();
saveToDo = new ToDoList("할일0", "Y");
}
//@Test
@Transactional
public void insertTest() {
saveToDo = apiService.insert(saveToDo);
assertThat(toDoListRepository.count(), is(1L));
}
//@Test
@Transactional
public void updateTest() {
saveToDo = apiService.insert(saveToDo);
saveToDo.setTodo("할일0 수정");;
saveToDo = apiService.update(saveToDo);
assertThat(apiService.view(saveToDo.getId()).getTodo(), is("할일0 수정"));
}
//@Test
@Transactional
public void completeTest() {
saveToDo = apiService.insert(saveToDo);
List<ToDoList> saveToDoList = Arrays.asList(
new ToDoList("할일1", "N"),
new ToDoList("할일2", "Y"),
new ToDoList("할일3", "Y"));
saveToDoList = toDoListRepository.save(saveToDoList);
assertThat(toDoListRepository.count(), is(4L));
ToDoList toDoList = apiService.view(saveToDoList.get(0).getId());
toDoList.setComYn("Y");
toDoList = apiService.complete(saveToDo.getId());
assertThat(apiService.view(saveToDo.getId()).getComYn(), is("Y"));
}
@Test
@Transactional
public void completeErrorTest() {
saveToDo.setComYn("N");
long id = apiService.insert(saveToDo).getId();
ToDoList tmp = apiService.insert(new ToDoList("체크@" + id, "N"));
tmp.setComYn("Y");
saveToDo = apiService.complete(tmp.getId());
assertThat(saveToDo.getErrorCode(), is("500"));
}
//@Test
@Transactional
public void viewTest() {
saveToDo = apiService.insert(saveToDo);
ToDoList toDoListUsingId = apiService.view(saveToDo.getId());
assertThat(toDoListUsingId.getId(), is(saveToDo.getId()));
saveToDo.setComYn("Y");
saveToDo = apiService.insert(saveToDo);
assertThat(apiService.view(saveToDo.getId()).getComYn(), is("Y"));
}
//@Test
@Transactional
public void deleteTest() {
saveToDo = apiService.insert(saveToDo);
apiService.delete(saveToDo.getId());
assertNull(apiService.view(saveToDo.getId()));
}
}
| 3,122 | 0.73882 | 0.73396 | 119 | 24.932774 | 22.146469 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.621849 | false | false | 13 |
033f2b8b667f888424a45014d67269d8c7b0e3e3 | 21,380,347,265,711 | b214f96566446763ce5679dd2121ea3d277a9406 | /modules/base/remote-server-api/src/main/java/consulo/remoteServer/configuration/ServerConfiguration.java | 6c08b0e10ac1be69639d7abd1c028e97e93fe534 | [
"Apache-2.0",
"LicenseRef-scancode-jgraph"
] | permissive | consulo/consulo | https://github.com/consulo/consulo | aa340d719d05ac6cbadd3f7d1226cdb678e6c84f | d784f1ef5824b944c1ee3a24a8714edfc5e2b400 | refs/heads/master | 2023-09-06T06:55:04.987000 | 2023-09-01T06:42:16 | 2023-09-01T06:42:16 | 10,116,915 | 680 | 54 | Apache-2.0 | false | 2023-06-05T18:28:51 | 2013-05-17T05:48:18 | 2023-05-27T20:14:55 | 2023-06-05T18:28:50 | 978,666 | 673 | 48 | 69 | Java | false | false | package consulo.remoteServer.configuration;
import consulo.component.persist.PersistentStateComponent;
/**
* @author nik
*/
public abstract class ServerConfiguration {
public abstract PersistentStateComponent<?> getSerializer();
}
| UTF-8 | Java | 237 | java | ServerConfiguration.java | Java | [
{
"context": ".persist.PersistentStateComponent;\n\n/**\n * @author nik\n */\npublic abstract class ServerConfiguration {\n ",
"end": 123,
"score": 0.997285008430481,
"start": 120,
"tag": "USERNAME",
"value": "nik"
}
] | null | [] | package consulo.remoteServer.configuration;
import consulo.component.persist.PersistentStateComponent;
/**
* @author nik
*/
public abstract class ServerConfiguration {
public abstract PersistentStateComponent<?> getSerializer();
}
| 237 | 0.801688 | 0.801688 | 10 | 22.700001 | 24.429695 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 13 |
7901bf328ffbe8442bf26fce406550bb31fc2539 | 21,380,347,267,846 | e595ae8d1f5c0b955f743b585dd520f5f9fb5151 | /app/src/main/java/com/jinke/community/presenter/HouseKeeperPresenter.java | 42d8e4fc6185f46ab31e222977953f6ad026b5c9 | [] | no_license | Brave-wan/JKCommunity-Test | https://github.com/Brave-wan/JKCommunity-Test | 3dbc43c72eaee477d613fd39d01814f8476cfdbb | fd990184cec52273335f5907aa0f995e1b513d3c | refs/heads/master | 2020-04-01T20:28:29.517000 | 2018-11-05T00:44:04 | 2018-11-05T00:44:04 | 153,605,641 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jinke.community.presenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.baidu.mobstat.StatService;
import com.base.util.ToastUtil;
import com.google.gson.Gson;
import com.jinke.community.R;
import com.jinke.community.application.MyApplication;
import com.jinke.community.base.BasePresenter;
import com.jinke.community.bean.BaseUserBean;
import com.jinke.community.bean.DefaultHouseBean;
import com.jinke.community.bean.ParkInfoBean;
import com.jinke.community.bean.ParkingBean;
import com.jinke.community.bean.acachebean.HouseListBean;
import com.jinke.community.bean.acachebean.NoticeListBean;
import com.jinke.community.bean.acachebean.WeatherBean;
import com.jinke.community.bean.home.BannerListBean;
import com.jinke.community.service.IHouseKeeperBiz;
import com.jinke.community.service.impl.HouseKeeperImpl;
import com.jinke.community.service.listener.IHouseKeeperListener;
import com.jinke.community.ui.activity.base.MessageActivity;
import com.jinke.community.ui.activity.broken.PropertyNewsActivity;
import com.jinke.community.ui.activity.control.PassActivity;
import com.jinke.community.ui.activity.house.MyHouseActivity;
import com.jinke.community.ui.activity.payment.PropertyPaymentActivity;
import com.jinke.community.ui.activity.vehicle.MyParkingActivity;
import com.jinke.community.ui.activity.vehicle.VehicleManagementActivity;
import com.jinke.community.ui.activity.web.LifeDetailsActivity;
import com.jinke.community.ui.activity.web.ThirdAuthorizationActivity;
import com.jinke.community.ui.toast.BindHouseDialog;
import com.jinke.community.utils.AnalyUtils;
import com.jinke.community.utils.SharedPreferencesUtils;
import com.jinke.community.view.IHouseKeeperView;
import com.ly.tqdoctor.activity.CheckPhoneAct;
import com.ly.tqdoctor.activity.MainAct;
import com.ly.tqdoctor.activity.PackagedActivity;
import com.ly.tqdoctor.activity.PersonRegisterAct;
import com.ly.tqdoctor.constant.TqDoctorParams;
import com.ly.tqdoctor.entity.UserEntity;
import com.ly.tqdoctor.joggle.CheckUserCallBack;
import com.ly.tqdoctor.joggle.LoginCallBack;
import com.ly.tqdoctor.util.TQDoctorHelper;
import java.util.HashMap;
import java.util.Map;
import www.jinke.com.library.utils.commont.StringUtils;
/**
* Created by root on 17-7-25.
*/
public class HouseKeeperPresenter extends BasePresenter<IHouseKeeperView> implements IHouseKeeperListener, BindHouseDialog.onCallPhoneListener {
private Activity mContext;
private IHouseKeeperBiz houseKeeperBiz;
private BindHouseDialog dialog;
private String communityInfo;
public HouseKeeperPresenter(Activity mContext) {
this.mContext = mContext;
houseKeeperBiz = new HouseKeeperImpl(mContext);
}
public void initBanner() {
HouseListBean.ListBean defaultHouseBean = MyApplication.getInstance().getDefaultHouse();
if (defaultHouseBean != null) {
//获取活动列表
Map<String, String> banner = new HashMap<>();
banner.put("houseId", defaultHouseBean.getHouse_id());
getBannerList(banner);
}
}
//获取默认信息
public void getDefaultData() {
HashMap map = new HashMap();
map.put("accessToken", MyApplication.getBaseUserBean().getAccessToken());
houseKeeperBiz.getDefaultData(map, this);
}
/**
* 获取默认信息成功回调
*/
@Override
public void onDefaultDataNext(DefaultHouseBean bean) {
if (mView != null) {
mView.onDefaultHouse(bean);
BaseUserBean userBean = MyApplication.getBaseUserBean();
userBean.setHouse(StringUtils.isEmpty(bean.getAddress()) ? false : true);
userBean.setIdentity(bean.getIdentity());
userBean.setName(bean.getName());
SharedPreferencesUtils.saveBaseUserBean(mContext, userBean);
SharedPreferencesUtils.clearCommunityId(mContext);
}
}
public void getBannerList(Map<String, String> map) {
if (mView != null) {
houseKeeperBiz.getBannerList(map, this);
}
}
@Override
public void onError(String code, String msg) {
if (mView != null) {
mView.showMsg(msg);
switch (code) {
case "3500":
if (!StringUtils.isEmpty(SharedPreferencesUtils.getCommunityId(mContext))) {
communityInfo = SharedPreferencesUtils.getCommunityId(mContext);
mView.setDefaultData(communityInfo.substring(0, communityInfo.indexOf(",")));
} else {
mView.getHouseListEmpty();
}
break;
case "4007":
mView.getHouseListEmpty();
break;
}
}
}
/**
* 弹框提示绑定房屋
*/
public void showBandingHouseDialog() {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
dialog.show();
} else {
dialog = new BindHouseDialog(mContext, this, "");
dialog.show();
}
}
public void setAnimation(ImageView imageView, int anim) {
if (imageView != null && mContext != null) {
Animation animation = AnimationUtils.loadAnimation(mContext, anim);
imageView.startAnimation(animation);
}
}
@Override
public void onSure(String phone) {
if (mContext != null) {
dialog.dismiss();
mContext.startActivity(new Intent(mContext, MyHouseActivity.class));
}
}
//公告列表
public void getNotice(Map<String, String> call) {
houseKeeperBiz.getNotice(call, this);
}
/**
* 公告列表 成功 回调
*
* @param bean
*/
@Override
public void getNoticeNext(NoticeListBean bean) {
if (mView != null) {
mView.getNoticeNext(bean);
}
}
@Override
public void getOnBannerListNext(BannerListBean info) {
if (mView != null) {
mView.OnBannerListNext(info);
}
}
/**
* 获取天气数据
*
* @param map
*/
public void getWeatheInfo(Map<String, String> map) {
houseKeeperBiz.getWeatheInfo(map, this);//获取天气数据
}
@Override
public void getWeatheInfoNext(WeatherBean bean) {
if (mView != null) {
mView.getWeatheInfoNext(bean);
}
}
/**
* 获取房屋列表
*/
public void getHouseList() {
Map map = new HashMap();
map.put("accessToken", MyApplication.getBaseUserBean().getAccessToken());
houseKeeperBiz.getHouseList(map, this);
}
@Override
public void getHouseListNext(HouseListBean info) {
if (mView != null) {
mView.getHouseListNext(info);
}
}
public String getCommitId() {
String communityId = "";
if (StringUtils.isEmpty(SharedPreferencesUtils.getCommunityId(mContext)) && SharedPreferencesUtils.getDefaultHouseInfo(mContext) != null) {
communityId = SharedPreferencesUtils.getDefaultHouseInfo(mContext).getCommunity_id();
} else {
String communityInfo = SharedPreferencesUtils.getCommunityId(mContext);
communityId = communityInfo.substring(communityInfo.indexOf(",") + 1);
}
return communityId;
}
public void viewOnClick(View view) {
if (view == null)
return;
switch (view.getId()) {
case R.id.tx_message://我的消息
mContext.startActivity(new Intent(mContext, MessageActivity.class));
StatService.onEvent(mContext, "myMessage", "首页-我的消息");
break;
case R.id.img_home_health:
// mContext.startActivity(new Intent(mContext, CheckPhoneAct.class));
getHealthLogin(MyApplication.getBaseUserBean().getPhone());
break;
case R.id.img_house://我的房屋
AnalyUtils.addAnaly(10040);
mContext.startActivity(new Intent(mContext, MyHouseActivity.class));
StatService.onEvent(mContext, "myHouse", "首页-我的房屋");
break;
case R.id.img_cars://我的车辆
AnalyUtils.addAnaly(10052);
StatService.onEvent(mContext, "myCar", "首页-我的车辆");
if (MyApplication.getInstance().getDefaultHouse() != null) {
mContext.startActivity(new Intent(mContext, VehicleManagementActivity.class).putExtra("pageType", 0));
} else {
showBandingHouseDialog();
}
break;
case R.id.img_parking://我的车位
AnalyUtils.addAnaly(10052);
getIsHouse(MyParkingActivity.class);
break;
case R.id.rl_open_door://放行
getIsHouse(PassActivity.class);
StatService.onEvent(mContext, "Release", "首页-放行");
break;
case R.id.rl_payment://缴费中心
getIsHouse(PropertyPaymentActivity.class);
StatService.onEvent(mContext, "paymentCenter", "首页-缴费中心");
break;
case R.id.rl_broken://报事爆料
AnalyUtils.addAnaly(10019);
getIsHouse(PropertyNewsActivity.class);
StatService.onEvent(mContext, "ReportBroke", "首页-报事爆料");
break;
}
}
public void getHealthLogin(String phone) {
if (StringUtils.isEmpty(phone)) {
return;
}
mView.showLoading();
TQDoctorHelper.checkUser(mContext, phone, new CheckUserCallBack() {
@Override
public void onSuccess(String result) {
try {
UserEntity entity = new Gson().fromJson(result, UserEntity.class);
if (null != entity && null != entity.getData()) {
TqDoctorParams.init(entity.getData().getPhone(), entity.getData());
checkDoctorLogin(entity.getData().getUuid());
}
} catch (Exception e) {
e.printStackTrace();
}
mView.hideLoading();
}
@Override
public void onError(String msg) {
mView.hideLoading();
Intent intent = new Intent(mContext, PersonRegisterAct.class);
intent.putExtra("phone", phone);
mContext.startActivityForResult(intent, 100);
}
});
}
/**
* @param uuid
*/
public void checkDoctorLogin(String uuid) {
if (TextUtils.isEmpty(uuid)) {
mContext.startActivity(new Intent(mContext, PackagedActivity.class));
} else {
TQDoctorHelper.doctorLogin(mContext, Long.parseLong(uuid), new LoginCallBack() {//
@Override
public void onSuccess() {
//登录和缓医疗成功
Intent intent = new Intent(mContext, MainAct.class);
mContext.startActivity(intent);
// mContext.startActivity(new Intent(mContext, PackagedActivity.class));
}
@Override
public void onError(String msg) {
Log.e("HHDoctor", "HHDoctor===" + msg);
//登录和缓医疗失败
// mContext.startActivity(new Intent(mContext, PackagedActivity.class));
ToastUtil.showToast(msg);
}
});
}
}
//判断是否有房屋,跳转其他界面
public void getIsHouse(Class activity) {
if (MyApplication.getInstance().getDefaultHouse() != null) {
mContext.startActivity(new Intent(mContext, activity));
} else {
showBandingHouseDialog();
}
}
}
| UTF-8 | Java | 12,369 | java | HouseKeeperPresenter.java | Java | [
{
"context": "rary.utils.commont.StringUtils;\n\n/**\n * Created by root on 17-7-25.\n */\n\npublic class HouseKeeperPresente",
"end": 2503,
"score": 0.9228003025054932,
"start": 2499,
"tag": "USERNAME",
"value": "root"
},
{
"context": "ut(\"accessToken\", MyApplication.getBaseUserBean().getAccessToken());\n houseKeeperBiz.getHouseLis",
"end": 6797,
"score": 0.558615505695343,
"start": 6794,
"tag": "KEY",
"value": "get"
},
{
"context": " onError(String msg) {\n Log.e(\"HHDoctor\", \"HHDoctor===\" + msg);\n //登录和",
"end": 11547,
"score": 0.6944566965103149,
"start": 11539,
"tag": "USERNAME",
"value": "HHDoctor"
}
] | null | [] | package com.jinke.community.presenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.baidu.mobstat.StatService;
import com.base.util.ToastUtil;
import com.google.gson.Gson;
import com.jinke.community.R;
import com.jinke.community.application.MyApplication;
import com.jinke.community.base.BasePresenter;
import com.jinke.community.bean.BaseUserBean;
import com.jinke.community.bean.DefaultHouseBean;
import com.jinke.community.bean.ParkInfoBean;
import com.jinke.community.bean.ParkingBean;
import com.jinke.community.bean.acachebean.HouseListBean;
import com.jinke.community.bean.acachebean.NoticeListBean;
import com.jinke.community.bean.acachebean.WeatherBean;
import com.jinke.community.bean.home.BannerListBean;
import com.jinke.community.service.IHouseKeeperBiz;
import com.jinke.community.service.impl.HouseKeeperImpl;
import com.jinke.community.service.listener.IHouseKeeperListener;
import com.jinke.community.ui.activity.base.MessageActivity;
import com.jinke.community.ui.activity.broken.PropertyNewsActivity;
import com.jinke.community.ui.activity.control.PassActivity;
import com.jinke.community.ui.activity.house.MyHouseActivity;
import com.jinke.community.ui.activity.payment.PropertyPaymentActivity;
import com.jinke.community.ui.activity.vehicle.MyParkingActivity;
import com.jinke.community.ui.activity.vehicle.VehicleManagementActivity;
import com.jinke.community.ui.activity.web.LifeDetailsActivity;
import com.jinke.community.ui.activity.web.ThirdAuthorizationActivity;
import com.jinke.community.ui.toast.BindHouseDialog;
import com.jinke.community.utils.AnalyUtils;
import com.jinke.community.utils.SharedPreferencesUtils;
import com.jinke.community.view.IHouseKeeperView;
import com.ly.tqdoctor.activity.CheckPhoneAct;
import com.ly.tqdoctor.activity.MainAct;
import com.ly.tqdoctor.activity.PackagedActivity;
import com.ly.tqdoctor.activity.PersonRegisterAct;
import com.ly.tqdoctor.constant.TqDoctorParams;
import com.ly.tqdoctor.entity.UserEntity;
import com.ly.tqdoctor.joggle.CheckUserCallBack;
import com.ly.tqdoctor.joggle.LoginCallBack;
import com.ly.tqdoctor.util.TQDoctorHelper;
import java.util.HashMap;
import java.util.Map;
import www.jinke.com.library.utils.commont.StringUtils;
/**
* Created by root on 17-7-25.
*/
public class HouseKeeperPresenter extends BasePresenter<IHouseKeeperView> implements IHouseKeeperListener, BindHouseDialog.onCallPhoneListener {
private Activity mContext;
private IHouseKeeperBiz houseKeeperBiz;
private BindHouseDialog dialog;
private String communityInfo;
public HouseKeeperPresenter(Activity mContext) {
this.mContext = mContext;
houseKeeperBiz = new HouseKeeperImpl(mContext);
}
public void initBanner() {
HouseListBean.ListBean defaultHouseBean = MyApplication.getInstance().getDefaultHouse();
if (defaultHouseBean != null) {
//获取活动列表
Map<String, String> banner = new HashMap<>();
banner.put("houseId", defaultHouseBean.getHouse_id());
getBannerList(banner);
}
}
//获取默认信息
public void getDefaultData() {
HashMap map = new HashMap();
map.put("accessToken", MyApplication.getBaseUserBean().getAccessToken());
houseKeeperBiz.getDefaultData(map, this);
}
/**
* 获取默认信息成功回调
*/
@Override
public void onDefaultDataNext(DefaultHouseBean bean) {
if (mView != null) {
mView.onDefaultHouse(bean);
BaseUserBean userBean = MyApplication.getBaseUserBean();
userBean.setHouse(StringUtils.isEmpty(bean.getAddress()) ? false : true);
userBean.setIdentity(bean.getIdentity());
userBean.setName(bean.getName());
SharedPreferencesUtils.saveBaseUserBean(mContext, userBean);
SharedPreferencesUtils.clearCommunityId(mContext);
}
}
public void getBannerList(Map<String, String> map) {
if (mView != null) {
houseKeeperBiz.getBannerList(map, this);
}
}
@Override
public void onError(String code, String msg) {
if (mView != null) {
mView.showMsg(msg);
switch (code) {
case "3500":
if (!StringUtils.isEmpty(SharedPreferencesUtils.getCommunityId(mContext))) {
communityInfo = SharedPreferencesUtils.getCommunityId(mContext);
mView.setDefaultData(communityInfo.substring(0, communityInfo.indexOf(",")));
} else {
mView.getHouseListEmpty();
}
break;
case "4007":
mView.getHouseListEmpty();
break;
}
}
}
/**
* 弹框提示绑定房屋
*/
public void showBandingHouseDialog() {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
dialog.show();
} else {
dialog = new BindHouseDialog(mContext, this, "");
dialog.show();
}
}
public void setAnimation(ImageView imageView, int anim) {
if (imageView != null && mContext != null) {
Animation animation = AnimationUtils.loadAnimation(mContext, anim);
imageView.startAnimation(animation);
}
}
@Override
public void onSure(String phone) {
if (mContext != null) {
dialog.dismiss();
mContext.startActivity(new Intent(mContext, MyHouseActivity.class));
}
}
//公告列表
public void getNotice(Map<String, String> call) {
houseKeeperBiz.getNotice(call, this);
}
/**
* 公告列表 成功 回调
*
* @param bean
*/
@Override
public void getNoticeNext(NoticeListBean bean) {
if (mView != null) {
mView.getNoticeNext(bean);
}
}
@Override
public void getOnBannerListNext(BannerListBean info) {
if (mView != null) {
mView.OnBannerListNext(info);
}
}
/**
* 获取天气数据
*
* @param map
*/
public void getWeatheInfo(Map<String, String> map) {
houseKeeperBiz.getWeatheInfo(map, this);//获取天气数据
}
@Override
public void getWeatheInfoNext(WeatherBean bean) {
if (mView != null) {
mView.getWeatheInfoNext(bean);
}
}
/**
* 获取房屋列表
*/
public void getHouseList() {
Map map = new HashMap();
map.put("accessToken", MyApplication.getBaseUserBean().getAccessToken());
houseKeeperBiz.getHouseList(map, this);
}
@Override
public void getHouseListNext(HouseListBean info) {
if (mView != null) {
mView.getHouseListNext(info);
}
}
public String getCommitId() {
String communityId = "";
if (StringUtils.isEmpty(SharedPreferencesUtils.getCommunityId(mContext)) && SharedPreferencesUtils.getDefaultHouseInfo(mContext) != null) {
communityId = SharedPreferencesUtils.getDefaultHouseInfo(mContext).getCommunity_id();
} else {
String communityInfo = SharedPreferencesUtils.getCommunityId(mContext);
communityId = communityInfo.substring(communityInfo.indexOf(",") + 1);
}
return communityId;
}
public void viewOnClick(View view) {
if (view == null)
return;
switch (view.getId()) {
case R.id.tx_message://我的消息
mContext.startActivity(new Intent(mContext, MessageActivity.class));
StatService.onEvent(mContext, "myMessage", "首页-我的消息");
break;
case R.id.img_home_health:
// mContext.startActivity(new Intent(mContext, CheckPhoneAct.class));
getHealthLogin(MyApplication.getBaseUserBean().getPhone());
break;
case R.id.img_house://我的房屋
AnalyUtils.addAnaly(10040);
mContext.startActivity(new Intent(mContext, MyHouseActivity.class));
StatService.onEvent(mContext, "myHouse", "首页-我的房屋");
break;
case R.id.img_cars://我的车辆
AnalyUtils.addAnaly(10052);
StatService.onEvent(mContext, "myCar", "首页-我的车辆");
if (MyApplication.getInstance().getDefaultHouse() != null) {
mContext.startActivity(new Intent(mContext, VehicleManagementActivity.class).putExtra("pageType", 0));
} else {
showBandingHouseDialog();
}
break;
case R.id.img_parking://我的车位
AnalyUtils.addAnaly(10052);
getIsHouse(MyParkingActivity.class);
break;
case R.id.rl_open_door://放行
getIsHouse(PassActivity.class);
StatService.onEvent(mContext, "Release", "首页-放行");
break;
case R.id.rl_payment://缴费中心
getIsHouse(PropertyPaymentActivity.class);
StatService.onEvent(mContext, "paymentCenter", "首页-缴费中心");
break;
case R.id.rl_broken://报事爆料
AnalyUtils.addAnaly(10019);
getIsHouse(PropertyNewsActivity.class);
StatService.onEvent(mContext, "ReportBroke", "首页-报事爆料");
break;
}
}
public void getHealthLogin(String phone) {
if (StringUtils.isEmpty(phone)) {
return;
}
mView.showLoading();
TQDoctorHelper.checkUser(mContext, phone, new CheckUserCallBack() {
@Override
public void onSuccess(String result) {
try {
UserEntity entity = new Gson().fromJson(result, UserEntity.class);
if (null != entity && null != entity.getData()) {
TqDoctorParams.init(entity.getData().getPhone(), entity.getData());
checkDoctorLogin(entity.getData().getUuid());
}
} catch (Exception e) {
e.printStackTrace();
}
mView.hideLoading();
}
@Override
public void onError(String msg) {
mView.hideLoading();
Intent intent = new Intent(mContext, PersonRegisterAct.class);
intent.putExtra("phone", phone);
mContext.startActivityForResult(intent, 100);
}
});
}
/**
* @param uuid
*/
public void checkDoctorLogin(String uuid) {
if (TextUtils.isEmpty(uuid)) {
mContext.startActivity(new Intent(mContext, PackagedActivity.class));
} else {
TQDoctorHelper.doctorLogin(mContext, Long.parseLong(uuid), new LoginCallBack() {//
@Override
public void onSuccess() {
//登录和缓医疗成功
Intent intent = new Intent(mContext, MainAct.class);
mContext.startActivity(intent);
// mContext.startActivity(new Intent(mContext, PackagedActivity.class));
}
@Override
public void onError(String msg) {
Log.e("HHDoctor", "HHDoctor===" + msg);
//登录和缓医疗失败
// mContext.startActivity(new Intent(mContext, PackagedActivity.class));
ToastUtil.showToast(msg);
}
});
}
}
//判断是否有房屋,跳转其他界面
public void getIsHouse(Class activity) {
if (MyApplication.getInstance().getDefaultHouse() != null) {
mContext.startActivity(new Intent(mContext, activity));
} else {
showBandingHouseDialog();
}
}
}
| 12,369 | 0.613887 | 0.610655 | 351 | 33.381767 | 27.01339 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.592593 | false | false | 13 |
b1faff83b6b4b77b4cd9ff6c90c5f485a49b17a4 | 13,443,247,692,258 | dc6af428bd417539d268404eaeec025767ac94f8 | /Nic-Tit/src/main/java/com/litt/nic/service/impl/StatusServiceImpl.java | 6b893469e31ec3a4e768ed8f9b1b2cab854914f2 | [] | no_license | WarmedHeart/Nic-Tit | https://github.com/WarmedHeart/Nic-Tit | 7ce21178b1b5a45c3f9c5015fa4326c4c5b4755b | 364420840e01fb8077d38cdb13316eaadcc5e863 | refs/heads/master | 2020-06-21T21:36:58.969000 | 2018-09-24T10:01:30 | 2018-09-24T10:01:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.litt.nic.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.litt.micro.datasourse.DynamicDataSourceHolder;
import com.litt.nic.entity.Status;
import com.litt.nic.mapper.StatusMapper;
import com.litt.nic.service.IStatusService;
@Service
public class StatusServiceImpl implements IStatusService {
@Autowired
private StatusMapper statusmapper;
public Status findById(int id) {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.selectByPrimaryKey(id);
}
@Override
public List<Status> findAllStatus() {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.findAllStatus();
}
@Override
public Status findByName(String name) {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.findByName(name);
}
}
| UTF-8 | Java | 911 | java | StatusServiceImpl.java | Java | [] | null | [] | package com.litt.nic.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.litt.micro.datasourse.DynamicDataSourceHolder;
import com.litt.nic.entity.Status;
import com.litt.nic.mapper.StatusMapper;
import com.litt.nic.service.IStatusService;
@Service
public class StatusServiceImpl implements IStatusService {
@Autowired
private StatusMapper statusmapper;
public Status findById(int id) {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.selectByPrimaryKey(id);
}
@Override
public List<Status> findAllStatus() {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.findAllStatus();
}
@Override
public Status findByName(String name) {
DynamicDataSourceHolder.setDataSource("dataSource1");
return statusmapper.findByName(name);
}
}
| 911 | 0.806806 | 0.803513 | 36 | 24.305555 | 21.966919 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.027778 | false | false | 13 |
3e1afdc9e606ec105d8a5d6abb92ebbb56222063 | 29,892,972,418,736 | 295973ff21d98ff205c4989fc6e039ec59e648d6 | /core/src/main/java/cz/quantumleap/core/security/config/RequestMappingInfoRequestMatcher.java | fe9a6e70dae7fafe0790c13a849f768259b8282d | [] | no_license | vkuzel/Quantum-Leap | https://github.com/vkuzel/Quantum-Leap | 07ccd5642a0ef1e8f8837d312142708905ac56db | 0e6bb27dd4379992c413c6d9e269ac8a797430d3 | refs/heads/master | 2023-08-18T16:15:35.624000 | 2023-08-16T18:15:56 | 2023-08-16T18:15:56 | 106,186,371 | 1 | 0 | null | false | 2022-12-26T19:13:18 | 2017-10-08T15:17:54 | 2021-12-14T20:36:25 | 2022-12-26T19:13:18 | 3,540 | 1 | 0 | 0 | Java | false | false | package cz.quantumleap.core.security.config;
import cz.quantumleap.core.view.WebUtils;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import java.util.List;
public class RequestMappingInfoRequestMatcher implements RequestMatcher {
private final List<RequestMappingInfo> mappingInfo;
public RequestMappingInfoRequestMatcher(List<RequestMappingInfo> mappingInfo) {
this.mappingInfo = mappingInfo;
}
@Override
public boolean matches(HttpServletRequest request) {
if (WebUtils.isDummyRequest(request)) {
return false;
}
WebUtils.cacheRequestPath(request);
for (var requestMappingInfo : mappingInfo) {
if (requestMappingInfo.getMatchingCondition(request) != null) {
return true;
}
}
return false;
}
}
| UTF-8 | Java | 975 | java | RequestMappingInfoRequestMatcher.java | Java | [] | null | [] | package cz.quantumleap.core.security.config;
import cz.quantumleap.core.view.WebUtils;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import java.util.List;
public class RequestMappingInfoRequestMatcher implements RequestMatcher {
private final List<RequestMappingInfo> mappingInfo;
public RequestMappingInfoRequestMatcher(List<RequestMappingInfo> mappingInfo) {
this.mappingInfo = mappingInfo;
}
@Override
public boolean matches(HttpServletRequest request) {
if (WebUtils.isDummyRequest(request)) {
return false;
}
WebUtils.cacheRequestPath(request);
for (var requestMappingInfo : mappingInfo) {
if (requestMappingInfo.getMatchingCondition(request) != null) {
return true;
}
}
return false;
}
}
| 975 | 0.713846 | 0.713846 | 32 | 29.46875 | 26.571817 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 13 |
992a47e0eedfeb41d6600a89baf65e04afa3ff15 | 20,074,677,205,374 | dfd419fd58bbf1dcdff5e29a17bb8fc723c8cfce | /src/main/java/com/itaytas/securityServer/logic/sniffer/jpa/JpaSnifferConfigService.java | 7139f6e6c22aef59e30f1759d2a6fd7dbe18c0a5 | [] | no_license | itaytas/Security-Server | https://github.com/itaytas/Security-Server | 0754f2932cce6752cf5bbf993b502b47f206d428 | abd1b41a925fd421cc1a35b5f1e9b9a2f46239c2 | refs/heads/master | 2022-01-10T12:16:17.656000 | 2019-05-21T10:17:16 | 2019-05-21T10:17:16 | 171,824,178 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.itaytas.securityServer.logic.sniffer.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.itaytas.securityServer.aop.MyLog;
import com.itaytas.securityServer.api.response.ApiResponse;
import com.itaytas.securityServer.api.response.PagedResponse;
import com.itaytas.securityServer.config.AppUtilsAndConstants;
import com.itaytas.securityServer.dal.SnifferConfigDao;
import com.itaytas.securityServer.dal.UserDao;
import com.itaytas.securityServer.logic.sniffer.SnifferConfigEntity;
import com.itaytas.securityServer.logic.sniffer.SnifferConfigService;
@Service
public class JpaSnifferConfigService implements SnifferConfigService{
private SnifferConfigDao snifferConfigDao;
private UserDao userDao;
@Autowired
public JpaSnifferConfigService(SnifferConfigDao snifferConfigDao, UserDao userDao) {
this.snifferConfigDao = snifferConfigDao;
this.userDao = userDao;
}
@Override
@Transactional
@MyLog
public SnifferConfigEntity createInitialSnifferConfigFileForNewUser(String userId) {
if (this.snifferConfigDao.existsByUserId(userId) || !this.userDao.existsById(userId)) {
return null;
}
SnifferConfigEntity entity = new SnifferConfigEntity(userId, AppUtilsAndConstants.DEFAULT_SNIFFER_CONFIG_APPS);
return this.snifferConfigDao.save(entity);
}
@Override
@Transactional(readOnly = true)
@MyLog
public ResponseEntity<?> getSnifferConfigFileByUserId(String userId) {
if (!this.userDao.existsById(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no user with id: " + userId),
HttpStatus.BAD_REQUEST);
}
if(!this.snifferConfigDao.existsByUserId(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "ERROR: No sniffer config file was found for userId: " + userId),
HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<>(
this.snifferConfigDao.findByUserId(userId),
HttpStatus.OK);
}
@Override
@Transactional
@MyLog
public ResponseEntity<?> updateSnifferConfigFileByUserId(String entityId, SnifferConfigEntity entityUpdates) {
if (!this.snifferConfigDao.existsById(entityId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no sniffer config file with id: " + entityId),
HttpStatus.BAD_REQUEST);
}
String userId = entityUpdates.getUserId();
if (!this.userDao.existsById(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no user with id: " + userId),
HttpStatus.BAD_REQUEST);
}
if(!this.snifferConfigDao.existsByUserId(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "ERROR: No sniffer config file was found for userId: " + userId),
HttpStatus.INTERNAL_SERVER_ERROR);
}
SnifferConfigEntity existing = this.snifferConfigDao.findById(entityId).get();
if (!existing.getUserApps().equals(entityUpdates.getUserApps())) {
existing.setUserApps(entityUpdates.getUserApps());
}
SnifferConfigEntity updatedEntity = this.snifferConfigDao.save(existing);
return new ResponseEntity<>(
new ApiResponse(true, "Sniffer config file for userId: " + updatedEntity.getUserId() + " was updated!"),
HttpStatus.CREATED);
}
@Override
@Transactional(readOnly = true)
@MyLog
public PagedResponse<SnifferConfigEntity> getAllSnifferConfigFiles(int page, int size) {
AppUtilsAndConstants.validatePageNumberAndSize(page, size);
Page<SnifferConfigEntity> snifferConfigPage = this.snifferConfigDao
.findAll(PageRequest.of(page, size, Sort.Direction.DESC, "createdAt"));
return new PagedResponse<>(snifferConfigPage.getContent(), snifferConfigPage.getNumber(), snifferConfigPage.getSize(),
snifferConfigPage.getTotalElements(), snifferConfigPage.getTotalPages(), snifferConfigPage.isLast());
}
@Override
@Transactional
@MyLog
public void cleanup() {
this.snifferConfigDao.deleteAll();
}
}
| UTF-8 | Java | 4,348 | java | JpaSnifferConfigService.java | Java | [] | null | [] | package com.itaytas.securityServer.logic.sniffer.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.itaytas.securityServer.aop.MyLog;
import com.itaytas.securityServer.api.response.ApiResponse;
import com.itaytas.securityServer.api.response.PagedResponse;
import com.itaytas.securityServer.config.AppUtilsAndConstants;
import com.itaytas.securityServer.dal.SnifferConfigDao;
import com.itaytas.securityServer.dal.UserDao;
import com.itaytas.securityServer.logic.sniffer.SnifferConfigEntity;
import com.itaytas.securityServer.logic.sniffer.SnifferConfigService;
@Service
public class JpaSnifferConfigService implements SnifferConfigService{
private SnifferConfigDao snifferConfigDao;
private UserDao userDao;
@Autowired
public JpaSnifferConfigService(SnifferConfigDao snifferConfigDao, UserDao userDao) {
this.snifferConfigDao = snifferConfigDao;
this.userDao = userDao;
}
@Override
@Transactional
@MyLog
public SnifferConfigEntity createInitialSnifferConfigFileForNewUser(String userId) {
if (this.snifferConfigDao.existsByUserId(userId) || !this.userDao.existsById(userId)) {
return null;
}
SnifferConfigEntity entity = new SnifferConfigEntity(userId, AppUtilsAndConstants.DEFAULT_SNIFFER_CONFIG_APPS);
return this.snifferConfigDao.save(entity);
}
@Override
@Transactional(readOnly = true)
@MyLog
public ResponseEntity<?> getSnifferConfigFileByUserId(String userId) {
if (!this.userDao.existsById(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no user with id: " + userId),
HttpStatus.BAD_REQUEST);
}
if(!this.snifferConfigDao.existsByUserId(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "ERROR: No sniffer config file was found for userId: " + userId),
HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<>(
this.snifferConfigDao.findByUserId(userId),
HttpStatus.OK);
}
@Override
@Transactional
@MyLog
public ResponseEntity<?> updateSnifferConfigFileByUserId(String entityId, SnifferConfigEntity entityUpdates) {
if (!this.snifferConfigDao.existsById(entityId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no sniffer config file with id: " + entityId),
HttpStatus.BAD_REQUEST);
}
String userId = entityUpdates.getUserId();
if (!this.userDao.existsById(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "There is no user with id: " + userId),
HttpStatus.BAD_REQUEST);
}
if(!this.snifferConfigDao.existsByUserId(userId)) {
return new ResponseEntity<>(
new ApiResponse(false, "ERROR: No sniffer config file was found for userId: " + userId),
HttpStatus.INTERNAL_SERVER_ERROR);
}
SnifferConfigEntity existing = this.snifferConfigDao.findById(entityId).get();
if (!existing.getUserApps().equals(entityUpdates.getUserApps())) {
existing.setUserApps(entityUpdates.getUserApps());
}
SnifferConfigEntity updatedEntity = this.snifferConfigDao.save(existing);
return new ResponseEntity<>(
new ApiResponse(true, "Sniffer config file for userId: " + updatedEntity.getUserId() + " was updated!"),
HttpStatus.CREATED);
}
@Override
@Transactional(readOnly = true)
@MyLog
public PagedResponse<SnifferConfigEntity> getAllSnifferConfigFiles(int page, int size) {
AppUtilsAndConstants.validatePageNumberAndSize(page, size);
Page<SnifferConfigEntity> snifferConfigPage = this.snifferConfigDao
.findAll(PageRequest.of(page, size, Sort.Direction.DESC, "createdAt"));
return new PagedResponse<>(snifferConfigPage.getContent(), snifferConfigPage.getNumber(), snifferConfigPage.getSize(),
snifferConfigPage.getTotalElements(), snifferConfigPage.getTotalPages(), snifferConfigPage.isLast());
}
@Override
@Transactional
@MyLog
public void cleanup() {
this.snifferConfigDao.deleteAll();
}
}
| 4,348 | 0.75828 | 0.75828 | 121 | 34.933884 | 32.058762 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.917355 | false | false | 13 |
63391b1b2563bca9a8d4dd99d23181d8dc51b526 | 20,048,907,383,215 | 70b56f143016866f3506cf1f306b41006e30f3c8 | /src/ExcepcionesMITOCODE/EdadException.java | 3a3dcf2acb895181478a186b09eb35333edfb8ab | [] | no_license | JavaSE1/AplicacionVehiculos | https://github.com/JavaSE1/AplicacionVehiculos | 4d621de26bba8d8e6c03637e493b01ae52e59784 | e6a07f9f64482c02cedb91b0baf6b1874206bbf3 | refs/heads/master | 2021-05-07T15:08:32.309000 | 2018-05-08T09:12:32 | 2018-05-08T09:12:32 | 109,976,229 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ExcepcionesMITOCODE;
public class EdadException extends Exception { //RuntimeException //Error
public EdadException(String mensaje) {
super(mensaje);
}
}
| UTF-8 | Java | 169 | java | EdadException.java | Java | [] | null | [] | package ExcepcionesMITOCODE;
public class EdadException extends Exception { //RuntimeException //Error
public EdadException(String mensaje) {
super(mensaje);
}
}
| 169 | 0.775148 | 0.775148 | 8 | 20.125 | 24.583721 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 13 |
22c53faee9a457f1f33f13dc2f90933e17684be2 | 22,866,405,944,763 | 17f427552edc3b81662cb97bbcd05dd3039ab59c | /src/test/java/test/hifive/model/oa/propertypath/EmailPP.java | 4ff771e38c86425ca612aa37c4e91249c5127c02 | [
"Apache-2.0"
] | permissive | ViaOA/oa-web | https://github.com/ViaOA/oa-web | 61fd23a45450ff9f049e4b3dbd1d3e5e75ca4e00 | ce44f24d1da8041ea5e09ac45d60fb37b2b185ba | refs/heads/master | 2023-07-06T09:45:44.640000 | 2022-12-26T21:46:05 | 2022-12-26T21:46:05 | 179,831,753 | 0 | 0 | Apache-2.0 | false | 2022-12-27T02:00:51 | 2019-04-06T12:39:12 | 2022-03-01T17:30:24 | 2022-12-27T01:39:46 | 2,351 | 0 | 0 | 0 | Java | false | false | // Generated by OABuilder
package test.hifive.model.oa.propertypath;
import test.hifive.model.oa.*;
public class EmailPP {
private static EmployeeAwardPPx employeeAwardConfirm;
private static EmployeeAwardPPx employeeAwardManagerNotify;
private static EmployeeAwardPPx employeeAwardNotify;
private static EmployeeAwardPPx employeeAwardShipped;
private static EmployeeEcardPPx employeeEcardConfirmed;
private static EmployeeEcardPPx employeeEcardDelivered;
private static EmployeeEcardToPPx employeeEcardTo;
private static InspirePPx inspire;
private static InspireApprovalPPx inspireApproval;
private static InspireApprovalPPx inspireApprovalReminder;
private static InspireOrderPPx inspireOrder;
private static InspireRecipientPPx inspireRecipient;
private static InspireRecipientPPx inspireRecipientCompleted;
private static LocationEmailTypePPx locationEmailType;
private static PointsRecordPPx pointsRecord;
private static PointsRequestPPx pointsRequest;
private static ProgramEmailTypePPx programEmailType;
public static EmployeeAwardPPx employeeAwardConfirm() {
if (employeeAwardConfirm == null) employeeAwardConfirm = new EmployeeAwardPPx(Email.P_EmployeeAwardConfirm);
return employeeAwardConfirm;
}
public static EmployeeAwardPPx employeeAwardManagerNotify() {
if (employeeAwardManagerNotify == null) employeeAwardManagerNotify = new EmployeeAwardPPx(Email.P_EmployeeAwardManagerNotify);
return employeeAwardManagerNotify;
}
public static EmployeeAwardPPx employeeAwardNotify() {
if (employeeAwardNotify == null) employeeAwardNotify = new EmployeeAwardPPx(Email.P_EmployeeAwardNotify);
return employeeAwardNotify;
}
public static EmployeeAwardPPx employeeAwardShipped() {
if (employeeAwardShipped == null) employeeAwardShipped = new EmployeeAwardPPx(Email.P_EmployeeAwardShipped);
return employeeAwardShipped;
}
public static EmployeeEcardPPx employeeEcardConfirmed() {
if (employeeEcardConfirmed == null) employeeEcardConfirmed = new EmployeeEcardPPx(Email.P_EmployeeEcardConfirmed);
return employeeEcardConfirmed;
}
public static EmployeeEcardPPx employeeEcardDelivered() {
if (employeeEcardDelivered == null) employeeEcardDelivered = new EmployeeEcardPPx(Email.P_EmployeeEcardDelivered);
return employeeEcardDelivered;
}
public static EmployeeEcardToPPx employeeEcardTo() {
if (employeeEcardTo == null) employeeEcardTo = new EmployeeEcardToPPx(Email.P_EmployeeEcardTo);
return employeeEcardTo;
}
public static InspirePPx inspire() {
if (inspire == null) inspire = new InspirePPx(Email.P_Inspire);
return inspire;
}
public static InspireApprovalPPx inspireApproval() {
if (inspireApproval == null) inspireApproval = new InspireApprovalPPx(Email.P_InspireApproval);
return inspireApproval;
}
public static InspireApprovalPPx inspireApprovalReminder() {
if (inspireApprovalReminder == null) inspireApprovalReminder = new InspireApprovalPPx(Email.P_InspireApprovalReminder);
return inspireApprovalReminder;
}
public static InspireOrderPPx inspireOrder() {
if (inspireOrder == null) inspireOrder = new InspireOrderPPx(Email.P_InspireOrder);
return inspireOrder;
}
public static InspireRecipientPPx inspireRecipient() {
if (inspireRecipient == null) inspireRecipient = new InspireRecipientPPx(Email.P_InspireRecipient);
return inspireRecipient;
}
public static InspireRecipientPPx inspireRecipientCompleted() {
if (inspireRecipientCompleted == null) inspireRecipientCompleted = new InspireRecipientPPx(Email.P_InspireRecipientCompleted);
return inspireRecipientCompleted;
}
public static LocationEmailTypePPx locationEmailType() {
if (locationEmailType == null) locationEmailType = new LocationEmailTypePPx(Email.P_LocationEmailType);
return locationEmailType;
}
public static PointsRecordPPx pointsRecord() {
if (pointsRecord == null) pointsRecord = new PointsRecordPPx(Email.P_PointsRecord);
return pointsRecord;
}
public static PointsRequestPPx pointsRequest() {
if (pointsRequest == null) pointsRequest = new PointsRequestPPx(Email.P_PointsRequest);
return pointsRequest;
}
public static ProgramEmailTypePPx programEmailType() {
if (programEmailType == null) programEmailType = new ProgramEmailTypePPx(Email.P_ProgramEmailType);
return programEmailType;
}
public static String id() {
String s = Email.P_Id;
return s;
}
public static String created() {
String s = Email.P_Created;
return s;
}
public static String fromEmail() {
String s = Email.P_FromEmail;
return s;
}
public static String toEmail() {
String s = Email.P_ToEmail;
return s;
}
public static String ccEmail() {
String s = Email.P_CcEmail;
return s;
}
public static String subject() {
String s = Email.P_Subject;
return s;
}
public static String sentDateTime() {
String s = Email.P_SentDateTime;
return s;
}
public static String cancelDate() {
String s = Email.P_CancelDate;
return s;
}
public static String body() {
String s = Email.P_Body;
return s;
}
public static String attachment() {
String s = Email.P_Attachment;
return s;
}
public static String attachmentName() {
String s = Email.P_AttachmentName;
return s;
}
public static String attachmentMimeType() {
String s = Email.P_AttachmentMimeType;
return s;
}
public static String open() {
String s = Email.P_Open;
return s;
}
public static String sendEmail() {
String s = "sendEmail";
return s;
}
public static String updateEmail() {
String s = "updateEmail";
return s;
}
public static String viewAttachment() {
String s = "viewAttachment";
return s;
}
public static String cancel() {
String s = "cancel";
return s;
}
}
| UTF-8 | Java | 6,379 | java | EmailPP.java | Java | [] | null | [] | // Generated by OABuilder
package test.hifive.model.oa.propertypath;
import test.hifive.model.oa.*;
public class EmailPP {
private static EmployeeAwardPPx employeeAwardConfirm;
private static EmployeeAwardPPx employeeAwardManagerNotify;
private static EmployeeAwardPPx employeeAwardNotify;
private static EmployeeAwardPPx employeeAwardShipped;
private static EmployeeEcardPPx employeeEcardConfirmed;
private static EmployeeEcardPPx employeeEcardDelivered;
private static EmployeeEcardToPPx employeeEcardTo;
private static InspirePPx inspire;
private static InspireApprovalPPx inspireApproval;
private static InspireApprovalPPx inspireApprovalReminder;
private static InspireOrderPPx inspireOrder;
private static InspireRecipientPPx inspireRecipient;
private static InspireRecipientPPx inspireRecipientCompleted;
private static LocationEmailTypePPx locationEmailType;
private static PointsRecordPPx pointsRecord;
private static PointsRequestPPx pointsRequest;
private static ProgramEmailTypePPx programEmailType;
public static EmployeeAwardPPx employeeAwardConfirm() {
if (employeeAwardConfirm == null) employeeAwardConfirm = new EmployeeAwardPPx(Email.P_EmployeeAwardConfirm);
return employeeAwardConfirm;
}
public static EmployeeAwardPPx employeeAwardManagerNotify() {
if (employeeAwardManagerNotify == null) employeeAwardManagerNotify = new EmployeeAwardPPx(Email.P_EmployeeAwardManagerNotify);
return employeeAwardManagerNotify;
}
public static EmployeeAwardPPx employeeAwardNotify() {
if (employeeAwardNotify == null) employeeAwardNotify = new EmployeeAwardPPx(Email.P_EmployeeAwardNotify);
return employeeAwardNotify;
}
public static EmployeeAwardPPx employeeAwardShipped() {
if (employeeAwardShipped == null) employeeAwardShipped = new EmployeeAwardPPx(Email.P_EmployeeAwardShipped);
return employeeAwardShipped;
}
public static EmployeeEcardPPx employeeEcardConfirmed() {
if (employeeEcardConfirmed == null) employeeEcardConfirmed = new EmployeeEcardPPx(Email.P_EmployeeEcardConfirmed);
return employeeEcardConfirmed;
}
public static EmployeeEcardPPx employeeEcardDelivered() {
if (employeeEcardDelivered == null) employeeEcardDelivered = new EmployeeEcardPPx(Email.P_EmployeeEcardDelivered);
return employeeEcardDelivered;
}
public static EmployeeEcardToPPx employeeEcardTo() {
if (employeeEcardTo == null) employeeEcardTo = new EmployeeEcardToPPx(Email.P_EmployeeEcardTo);
return employeeEcardTo;
}
public static InspirePPx inspire() {
if (inspire == null) inspire = new InspirePPx(Email.P_Inspire);
return inspire;
}
public static InspireApprovalPPx inspireApproval() {
if (inspireApproval == null) inspireApproval = new InspireApprovalPPx(Email.P_InspireApproval);
return inspireApproval;
}
public static InspireApprovalPPx inspireApprovalReminder() {
if (inspireApprovalReminder == null) inspireApprovalReminder = new InspireApprovalPPx(Email.P_InspireApprovalReminder);
return inspireApprovalReminder;
}
public static InspireOrderPPx inspireOrder() {
if (inspireOrder == null) inspireOrder = new InspireOrderPPx(Email.P_InspireOrder);
return inspireOrder;
}
public static InspireRecipientPPx inspireRecipient() {
if (inspireRecipient == null) inspireRecipient = new InspireRecipientPPx(Email.P_InspireRecipient);
return inspireRecipient;
}
public static InspireRecipientPPx inspireRecipientCompleted() {
if (inspireRecipientCompleted == null) inspireRecipientCompleted = new InspireRecipientPPx(Email.P_InspireRecipientCompleted);
return inspireRecipientCompleted;
}
public static LocationEmailTypePPx locationEmailType() {
if (locationEmailType == null) locationEmailType = new LocationEmailTypePPx(Email.P_LocationEmailType);
return locationEmailType;
}
public static PointsRecordPPx pointsRecord() {
if (pointsRecord == null) pointsRecord = new PointsRecordPPx(Email.P_PointsRecord);
return pointsRecord;
}
public static PointsRequestPPx pointsRequest() {
if (pointsRequest == null) pointsRequest = new PointsRequestPPx(Email.P_PointsRequest);
return pointsRequest;
}
public static ProgramEmailTypePPx programEmailType() {
if (programEmailType == null) programEmailType = new ProgramEmailTypePPx(Email.P_ProgramEmailType);
return programEmailType;
}
public static String id() {
String s = Email.P_Id;
return s;
}
public static String created() {
String s = Email.P_Created;
return s;
}
public static String fromEmail() {
String s = Email.P_FromEmail;
return s;
}
public static String toEmail() {
String s = Email.P_ToEmail;
return s;
}
public static String ccEmail() {
String s = Email.P_CcEmail;
return s;
}
public static String subject() {
String s = Email.P_Subject;
return s;
}
public static String sentDateTime() {
String s = Email.P_SentDateTime;
return s;
}
public static String cancelDate() {
String s = Email.P_CancelDate;
return s;
}
public static String body() {
String s = Email.P_Body;
return s;
}
public static String attachment() {
String s = Email.P_Attachment;
return s;
}
public static String attachmentName() {
String s = Email.P_AttachmentName;
return s;
}
public static String attachmentMimeType() {
String s = Email.P_AttachmentMimeType;
return s;
}
public static String open() {
String s = Email.P_Open;
return s;
}
public static String sendEmail() {
String s = "sendEmail";
return s;
}
public static String updateEmail() {
String s = "updateEmail";
return s;
}
public static String viewAttachment() {
String s = "viewAttachment";
return s;
}
public static String cancel() {
String s = "cancel";
return s;
}
}
| 6,379 | 0.697915 | 0.697915 | 195 | 31.702564 | 31.810234 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.446154 | false | false | 13 |
0bb8d9de72fc966e372c3a31ba7f438aaccbda76 | 3,470,333,633,048 | d8cfc90ed6dc7be24e1cf4ace9a4eae0c712f512 | /src/main/java/fxmlController/SupportChatClient.java | 3cd0b03118733edaedcca013c08708e42ca7ff31 | [] | no_license | yaldashbz/Project_team-19 | https://github.com/yaldashbz/Project_team-19 | 82b226f74ee5c9d5b57cd726f93c5a23f06af861 | a55410f438eac5f8179ed743c2b9f96cc2f81be4 | refs/heads/master | 2021-05-21T19:10:08.450000 | 2020-07-24T19:29:20 | 2020-07-24T19:29:20 | 288,086,412 | 1 | 0 | null | true | 2020-08-17T04:53:35 | 2020-08-17T04:53:34 | 2020-07-24T19:29:33 | 2020-07-24T19:29:30 | 44,274 | 0 | 0 | 0 | null | false | false | package fxmlController;
import clientController.ServerConnection;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import model.Support;
import server.Request;
import view.App;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static clientController.ServerConnection.*;
import static server.PacketType.EXIT;
import static server.PacketType.SUPPORT_CHAT_BACK;
public class SupportChatClient implements Initializable {
public TextArea see;
public TextField type;
public Button add;
public ScrollPane scrollPane;
public GridPane gridPane;
public String chattingWith;
ExecutorService executor = Executors.newCachedThreadPool ( );
@FXML
private FontAwesomeIcon back;
@FXML
void back ( MouseEvent event ) {
try {
dataOutputStream.writeUTF(toJson(new Request (SUPPORT_CHAT_BACK, null, "")));
} catch (IOException ioException) {
ioException.printStackTrace ( );
}
App.setRoot ( "customerMenu" );
}
@FXML
private void backSizeBig ( MouseEvent mouseEvent ) {
back.setStyle ( "-fx-font-family: FontAwesome; -fx-font-size: 20;-fx-effect: innershadow(gaussian, #17b5ff,75,0,5,0);" );
}
@FXML private void backSizeSmall ( MouseEvent mouseEvent ) {
back.setStyle ( "-fx-font-family: FontAwesome; -fx-font-size: 1em" );
}
@Override
public void initialize ( URL location , ResourceBundle resources ) {
ArrayList< String > onlineSupportsUsername = getAllOnlineSupports ();
int i = 0;
for (String onlineSupportUsername : onlineSupportsUsername) {
Label label = new Label ( onlineSupportUsername );
label.setStyle ( "-fx-font-family: 'Consolas'; -fx-font-size: 20; -fx-font-color: white; -fx-border-color: #225f8e; -fx-background-color: #89b7ff;" );
label.setPrefHeight ( 50 );
GridPane.setHalignment ( label , HPos.CENTER );
gridPane.setGridLinesVisible ( true );
if (i == 0) {
chattingWith = label.getText ();
supportChatOpen ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( chattingWith );
}} );
}
gridPane.add ( label , 0 , i++ );
}
gridPane.getChildren ().forEach ( item -> item.setOnMouseClicked ( event -> {
see.setText ( "" );
chattingWith = ((Label)item).getText ();
supportChatOpen ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( chattingWith );
}} );
} ) );
new Thread ( "Listening Thread" ) {
@Override
public void run () {
try {
while(true) {
String string = dataInputStream.readUTF ( );
if ( string.equals ( "/back/" ) )
break;
else if ( string.startsWith ( "/open/" ) ) {
string = string.substring ( 6 );
}
displayMessage(string);
}
} catch (IOException ioException) {
ioException.printStackTrace ( );
}
}
private void displayMessage ( String string ) {
Task display_message = new Task<Void>() {
@Override
public Void call() throws Exception {
Platform.runLater( () -> see.appendText(string) );
return null;
}
};
executor.execute(display_message);
}
}.start ();
}
public void addAction ( ActionEvent event ) {
String string = type.getText () + '\n';
type.setText ( "" );
supportChatSend ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( string );
add ( chattingWith );
}} );
}
}
| UTF-8 | Java | 4,600 | java | SupportChatClient.java | Java | [] | null | [] | package fxmlController;
import clientController.ServerConnection;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import model.Support;
import server.Request;
import view.App;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static clientController.ServerConnection.*;
import static server.PacketType.EXIT;
import static server.PacketType.SUPPORT_CHAT_BACK;
public class SupportChatClient implements Initializable {
public TextArea see;
public TextField type;
public Button add;
public ScrollPane scrollPane;
public GridPane gridPane;
public String chattingWith;
ExecutorService executor = Executors.newCachedThreadPool ( );
@FXML
private FontAwesomeIcon back;
@FXML
void back ( MouseEvent event ) {
try {
dataOutputStream.writeUTF(toJson(new Request (SUPPORT_CHAT_BACK, null, "")));
} catch (IOException ioException) {
ioException.printStackTrace ( );
}
App.setRoot ( "customerMenu" );
}
@FXML
private void backSizeBig ( MouseEvent mouseEvent ) {
back.setStyle ( "-fx-font-family: FontAwesome; -fx-font-size: 20;-fx-effect: innershadow(gaussian, #17b5ff,75,0,5,0);" );
}
@FXML private void backSizeSmall ( MouseEvent mouseEvent ) {
back.setStyle ( "-fx-font-family: FontAwesome; -fx-font-size: 1em" );
}
@Override
public void initialize ( URL location , ResourceBundle resources ) {
ArrayList< String > onlineSupportsUsername = getAllOnlineSupports ();
int i = 0;
for (String onlineSupportUsername : onlineSupportsUsername) {
Label label = new Label ( onlineSupportUsername );
label.setStyle ( "-fx-font-family: 'Consolas'; -fx-font-size: 20; -fx-font-color: white; -fx-border-color: #225f8e; -fx-background-color: #89b7ff;" );
label.setPrefHeight ( 50 );
GridPane.setHalignment ( label , HPos.CENTER );
gridPane.setGridLinesVisible ( true );
if (i == 0) {
chattingWith = label.getText ();
supportChatOpen ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( chattingWith );
}} );
}
gridPane.add ( label , 0 , i++ );
}
gridPane.getChildren ().forEach ( item -> item.setOnMouseClicked ( event -> {
see.setText ( "" );
chattingWith = ((Label)item).getText ();
supportChatOpen ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( chattingWith );
}} );
} ) );
new Thread ( "Listening Thread" ) {
@Override
public void run () {
try {
while(true) {
String string = dataInputStream.readUTF ( );
if ( string.equals ( "/back/" ) )
break;
else if ( string.startsWith ( "/open/" ) ) {
string = string.substring ( 6 );
}
displayMessage(string);
}
} catch (IOException ioException) {
ioException.printStackTrace ( );
}
}
private void displayMessage ( String string ) {
Task display_message = new Task<Void>() {
@Override
public Void call() throws Exception {
Platform.runLater( () -> see.appendText(string) );
return null;
}
};
executor.execute(display_message);
}
}.start ();
}
public void addAction ( ActionEvent event ) {
String string = type.getText () + '\n';
type.setText ( "" );
supportChatSend ( new ArrayList <String> ( ) {{
add ( "customer" );
add ( string );
add ( chattingWith );
}} );
}
}
| 4,600 | 0.565652 | 0.56 | 142 | 31.394365 | 26.077339 | 162 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.65493 | false | false | 13 |
742ae368643ead36a059bf37d6608fc20a414b18 | 1,142,461,303,192 | f6c9a06cfe7d2d62706cc3a481983691e99c9d69 | /src/main/java/com/games/gameofthree/entity/DuelPlayerSocket.java | a316f18d1dad7e648318815e6134ac1c2b26988d | [] | no_license | ivangfr/gameofthree | https://github.com/ivangfr/gameofthree | a2e9d9d8aae39897332390f69948fe8c81fdd564 | 6ae35f85bf94cdc1f77570278df89586225496e5 | refs/heads/master | 2018-01-09T10:43:55.562000 | 2016-02-21T20:30:01 | 2016-02-21T20:30:01 | 52,226,412 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.games.gameofthree.entity;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import com.games.gameofthree.message.Message;
public class DuelPlayerSocket {
private final String fPlayerId;
private final ObjectOutputStream fOut;
private final ObjectInputStream fIn;
public DuelPlayerSocket(String aPlayerId, Socket socket) throws IOException {
fPlayerId = aPlayerId;
fOut = new ObjectOutputStream(socket.getOutputStream());
fIn = new ObjectInputStream(socket.getInputStream());
}
public String getPlayerId() {
return fPlayerId;
}
public void send(Message message) throws IOException {
fOut.writeObject(message);
fOut.flush();
}
public Message receive() throws ClassNotFoundException, IOException {
return (Message) fIn.readObject();
}
}
| UTF-8 | Java | 853 | java | DuelPlayerSocket.java | Java | [] | null | [] | package com.games.gameofthree.entity;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import com.games.gameofthree.message.Message;
public class DuelPlayerSocket {
private final String fPlayerId;
private final ObjectOutputStream fOut;
private final ObjectInputStream fIn;
public DuelPlayerSocket(String aPlayerId, Socket socket) throws IOException {
fPlayerId = aPlayerId;
fOut = new ObjectOutputStream(socket.getOutputStream());
fIn = new ObjectInputStream(socket.getInputStream());
}
public String getPlayerId() {
return fPlayerId;
}
public void send(Message message) throws IOException {
fOut.writeObject(message);
fOut.flush();
}
public Message receive() throws ClassNotFoundException, IOException {
return (Message) fIn.readObject();
}
}
| 853 | 0.778429 | 0.778429 | 34 | 24.088236 | 22.144403 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.352941 | false | false | 13 |
433a8e0b6d948966ea24e259f2007e632d81cfca | 27,161,373,247,447 | 7c228d81af542859a98f16c1e9fff0792500c984 | /PersonalWorkoutPlannerMobileApp/PersonalWorkoutPlanner/app/src/main/java/edu/lewisu/cs/ivanfonseca/personalworkoutplanner/LaunchActivity.java | 8320ced9a5ae8bf3fc32fb033f4768ab84138e7d | [] | no_license | ivanf05/Java-Projects | https://github.com/ivanf05/Java-Projects | 3707e42e3186bfc805584d01dd0e1a14ffe98e4a | 96b740f836c4ec18fcc6577b83d11a0460938886 | refs/heads/master | 2020-03-17T22:55:13.420000 | 2018-05-22T23:28:55 | 2018-05-22T23:28:55 | 134,023,616 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.lewisu.cs.ivanfonseca.personalworkoutplanner;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
public class LaunchActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DbHelper dbHelper = new DbHelper(this);
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.close();
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_icon,menu);
return true;
}
public void buttonClick(View V){
Intent launchMain = new Intent(this,MainActivity.class);
startActivity(launchMain);
}
public void buttonClick2(View V){
Intent launchMain = new Intent(this,RecycleActivity.class);
startActivity(launchMain);
}
}
| UTF-8 | Java | 1,054 | java | LaunchActivity.java | Java | [] | null | [] | package edu.lewisu.cs.ivanfonseca.personalworkoutplanner;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
public class LaunchActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DbHelper dbHelper = new DbHelper(this);
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.close();
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_icon,menu);
return true;
}
public void buttonClick(View V){
Intent launchMain = new Intent(this,MainActivity.class);
startActivity(launchMain);
}
public void buttonClick2(View V){
Intent launchMain = new Intent(this,RecycleActivity.class);
startActivity(launchMain);
}
}
| 1,054 | 0.717268 | 0.71537 | 34 | 29.970589 | 22.100685 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.617647 | false | false | 13 |
63a6d09e1d1c3d52f4a6a3a511a11c0d23d930b1 | 22,497,038,725,073 | 53b2063a4cd2ae22b61ebe09d292f92f0dc75417 | /applications/appunorganized/appunorganized-plugins/org.csstudio.dct.ui/src/org/csstudio/dct/ui/editor/outline/internal/CopyElementAction.java | 0dcd8fa201bf92778c14c8f43203565f0a70ddc0 | [] | no_license | ATNF/cs-studio | https://github.com/ATNF/cs-studio | 886d6cb2a3d626b761d4486f4243dd04cb21c055 | f3ef004fd1566b8b47161b13a65990e8c741086a | refs/heads/master | 2021-01-21T08:29:54.345000 | 2015-05-29T04:04:33 | 2015-05-29T04:04:33 | 11,189,876 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.csstudio.dct.ui.editor.outline.internal;
import java.util.List;
import org.csstudio.dct.model.IElement;
import org.csstudio.dct.ui.editor.copyandpaste.AbstractElementTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.InstanceTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.PrototypeTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.RecordTransfer;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.PlatformUI;
public class CopyElementAction extends AbstractOutlineAction {
private AbstractElementTransfer[] transferTypes = new AbstractElementTransfer[] { RecordTransfer.getInstance(),
PrototypeTransfer.getInstance(), InstanceTransfer.getInstance() };
@Override
protected Command createCommand(List<IElement> selection) {
assert selection != null;
assert !selection.isEmpty();
Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
for (AbstractElementTransfer transfer : transferTypes) {
if (transfer.getCopyAndPasteStrategy().canCopy(selection)) {
clipboard.setContents(new Object[] { selection }, new Transfer[] { transfer });
return null;
}
}
return null;
}
@Override
protected void afterSelectionChanged(List<IElement> selection, IAction action) {
boolean enabled = false;
for (AbstractElementTransfer transfer : transferTypes) {
enabled |= transfer.getCopyAndPasteStrategy().canCopy(selection);
}
action.setEnabled(enabled);
}
}
| UTF-8 | Java | 1,718 | java | CopyElementAction.java | Java | [] | null | [] | package org.csstudio.dct.ui.editor.outline.internal;
import java.util.List;
import org.csstudio.dct.model.IElement;
import org.csstudio.dct.ui.editor.copyandpaste.AbstractElementTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.InstanceTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.PrototypeTransfer;
import org.csstudio.dct.ui.editor.copyandpaste.RecordTransfer;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.PlatformUI;
public class CopyElementAction extends AbstractOutlineAction {
private AbstractElementTransfer[] transferTypes = new AbstractElementTransfer[] { RecordTransfer.getInstance(),
PrototypeTransfer.getInstance(), InstanceTransfer.getInstance() };
@Override
protected Command createCommand(List<IElement> selection) {
assert selection != null;
assert !selection.isEmpty();
Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
for (AbstractElementTransfer transfer : transferTypes) {
if (transfer.getCopyAndPasteStrategy().canCopy(selection)) {
clipboard.setContents(new Object[] { selection }, new Transfer[] { transfer });
return null;
}
}
return null;
}
@Override
protected void afterSelectionChanged(List<IElement> selection, IAction action) {
boolean enabled = false;
for (AbstractElementTransfer transfer : transferTypes) {
enabled |= transfer.getCopyAndPasteStrategy().canCopy(selection);
}
action.setEnabled(enabled);
}
}
| 1,718 | 0.72177 | 0.72177 | 47 | 35.553192 | 31.135126 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.574468 | false | false | 13 |
d1520999035ceb499b6ca42f39f57e48f7b84533 | 6,708,738,981,023 | 07606cecc7dc6a5c3b85300d75502d2532d29c91 | /src/main/java/jejs/node/Node.java | 55c30a1c6e0ebce68ff1c8a487172a0809799c5f | [] | no_license | luminocean/jexpress | https://github.com/luminocean/jexpress | 934d101f066e1dde6a4f69efddac3f7335033ece | 919fc060d931999377bde840ead2a62eaf113d36 | refs/heads/master | 2021-01-10T07:38:28.718000 | 2016-08-26T06:15:20 | 2016-08-26T06:15:20 | 50,765,732 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package jejs.node;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import jejs.Token;
/**
* 语法树节点类,可以使用数据渲染返回文本
* @author luminocean
*
*/
public class Node {
// 每个node的原始字符串
protected String raw;
// 实际的文本内容
protected String text;
// 子节点的有序列表
public List<Node> children = new ArrayList<>();
public Node(){
this(new Token(""));
}
public Node(Token token){
raw = token.raw;
text = token.value;
}
/**
* 使用context数据来渲染本节点
* @param context
* @return 渲染后的html字符串
*/
public String render(Map<String, Object> context) {
StringBuilder builder = new StringBuilder();
for(Node child: children){
builder.append(child.render(context));
}
return builder.toString();
}
@Override
public String toString(){
if(children.size() == 0) return raw;
StringBuilder builder = new StringBuilder();
builder.append("[");
for(Node n: children){
String str = n.toString();
builder.append(str+',');
}
builder.deleteCharAt(builder.length()-1);
builder.append("]");
return raw + "-" + builder.toString();
}
}
| UTF-8 | Java | 1,200 | java | Node.java | Java | [
{
"context": "jejs.Token;\n\n/**\n * 语法树节点类,可以使用数据渲染返回文本\n * @author luminocean\n *\n */\npublic class Node {\n\t// 每个node的原始字符串\n\tprot",
"end": 162,
"score": 0.999610424041748,
"start": 152,
"tag": "USERNAME",
"value": "luminocean"
}
] | null | [] | package jejs.node;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import jejs.Token;
/**
* 语法树节点类,可以使用数据渲染返回文本
* @author luminocean
*
*/
public class Node {
// 每个node的原始字符串
protected String raw;
// 实际的文本内容
protected String text;
// 子节点的有序列表
public List<Node> children = new ArrayList<>();
public Node(){
this(new Token(""));
}
public Node(Token token){
raw = token.raw;
text = token.value;
}
/**
* 使用context数据来渲染本节点
* @param context
* @return 渲染后的html字符串
*/
public String render(Map<String, Object> context) {
StringBuilder builder = new StringBuilder();
for(Node child: children){
builder.append(child.render(context));
}
return builder.toString();
}
@Override
public String toString(){
if(children.size() == 0) return raw;
StringBuilder builder = new StringBuilder();
builder.append("[");
for(Node n: children){
String str = n.toString();
builder.append(str+',');
}
builder.deleteCharAt(builder.length()-1);
builder.append("]");
return raw + "-" + builder.toString();
}
}
| 1,200 | 0.662662 | 0.660813 | 58 | 17.655172 | 14.299207 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.551724 | false | false | 13 |
4cd4543b813bc32a865718ea8f026781238c4736 | 22,419,729,338,547 | f9533509eb1d2299ce74180638d1119d290b83fd | /backendcommon/src/main/java/roide/common/backend/models/DayEntry.java | 69b4a81b75a588889417a451d922a1eab99c00d5 | [] | no_license | roideuniverse/storyboard-android | https://github.com/roideuniverse/storyboard-android | 931339a8b7a030b6fa3dc90438c925667badb340 | 9ce9b225e1aa901cf6629155409488955d1aed9b | refs/heads/master | 2016-09-23T05:31:49.794000 | 2016-08-17T05:22:36 | 2016-08-17T05:22:36 | 63,011,071 | 2 | 0 | null | false | 2016-08-17T03:59:15 | 2016-07-10T17:43:56 | 2016-07-10T20:28:30 | 2016-08-17T03:59:14 | 406 | 1 | 0 | 3 | Java | null | null | package roide.common.backend.models;
import java.io.Serializable;
import java.util.List;
/**
* Created by roide on 8/13/16.
*/
public interface DayEntry extends Serializable {
Long getAbsoluteDay();
void setAbsoluteDay(Long absoluteDay);
List<Goal> getGoals();
void setGoals(List<Goal> goals);
List<Highlight> getHighlights();
void setHighlights(List<Highlight> highlights);
List<Post> getPosts();
void setPosts(List<Post> posts);
}
| UTF-8 | Java | 476 | java | DayEntry.java | Java | [
{
"context": "lizable;\nimport java.util.List;\n\n/**\n * Created by roide on 8/13/16.\n */\npublic interface DayEntry extends",
"end": 114,
"score": 0.9996365904808044,
"start": 109,
"tag": "USERNAME",
"value": "roide"
}
] | null | [] | package roide.common.backend.models;
import java.io.Serializable;
import java.util.List;
/**
* Created by roide on 8/13/16.
*/
public interface DayEntry extends Serializable {
Long getAbsoluteDay();
void setAbsoluteDay(Long absoluteDay);
List<Goal> getGoals();
void setGoals(List<Goal> goals);
List<Highlight> getHighlights();
void setHighlights(List<Highlight> highlights);
List<Post> getPosts();
void setPosts(List<Post> posts);
}
| 476 | 0.703781 | 0.693277 | 25 | 18.040001 | 17.880671 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44 | false | false | 13 |
15842f3e3df4d39046f194e8d323b8fb13fa4f87 | 17,119,739,647,430 | e446af296375cee846c2d15da935e07c2cf015f8 | /Week1/ContactsManager.java | 435f9871564271b570b3cd29b88b4949838c99fa | [] | no_license | MIA1kl/ContactsManager | https://github.com/MIA1kl/ContactsManager | 0e405e5ca9116079167c29c7ab439850352c9a16 | 0aa470d43ccdc419caaaf2cc9c838e0dbd3bc9e8 | refs/heads/master | 2022-12-08T22:53:08.526000 | 2020-09-14T07:12:10 | 2020-09-14T07:12:10 | 295,333,536 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Week1;
class ContactsManager {
Contact [] people;
int counter;
ContactsManager(){
counter = 0;
people = new Contact[3];
}
void addContact(Contact contact){
people[counter] = contact;
counter++;
}
Contact searchContact(String searchName){
for(int i=0; i<counter; i++){
if(people[i].name.equals(searchName)){
return people[i];
}
}
return null;
}
} | UTF-8 | Java | 509 | java | ContactsManager.java | Java | [] | null | [] | package Week1;
class ContactsManager {
Contact [] people;
int counter;
ContactsManager(){
counter = 0;
people = new Contact[3];
}
void addContact(Contact contact){
people[counter] = contact;
counter++;
}
Contact searchContact(String searchName){
for(int i=0; i<counter; i++){
if(people[i].name.equals(searchName)){
return people[i];
}
}
return null;
}
} | 509 | 0.500982 | 0.493124 | 25 | 18.440001 | 14.737924 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44 | false | false | 13 |
3dc8f4bb713696735ae56c6d99ccbc576592b02c | 14,431,090,182,206 | 289bd6e0145a2396aa7cb47d05e48e42a5bbd221 | /app/src/main/java/com/amirgb/reddittestapp/subjectdetailview/SubjectDetailInteractor.java | ffb4cbb819a23f02fbc03f7e51f6f22821eba332 | [] | no_license | xzamirx/reddittestapp | https://github.com/xzamirx/reddittestapp | 817c3052186647a8f4014d349ea5b347df57061b | 2d940a628589541ac036280df23a5e85a250f83e | refs/heads/master | 2017-12-08T08:24:50.589000 | 2017-01-18T08:10:24 | 2017-01-18T08:10:24 | 79,171,101 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.amirgb.reddittestapp.subjectdetailview;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.widget.ImageView;
import com.amirgb.reddittestapp.DefaultActivity;
import com.amirgb.reddittestapp.RedditTestApplication;
import com.amirgb.reddittestapp.model.Children;
import com.amirgb.reddittestapp.mvp.ISubjectDetailInteractor;
import com.amirgb.reddittestapp.mvp.ISubjectDetailPresenter;
import com.amirgb.reddittestapp.rest.RedditApiService;
import com.amirgb.reddittestapp.util.NetWorkUtils;
import com.squareup.picasso.Callback;
/**
* Created by Amir Granadillo on 17/01/2017.
*/
public class SubjectDetailInteractor implements ISubjectDetailInteractor {
private ISubjectDetailPresenter mSubjectDetailPresenter;
/**
* Constructor
*
* @param iSubjectDetailPresenter
*/
public SubjectDetailInteractor(ISubjectDetailPresenter iSubjectDetailPresenter) {
mSubjectDetailPresenter = iSubjectDetailPresenter;
}
/**
* Gets the subject from the bundle
* @param bundle
*/
@Override
public void getDetail(Bundle bundle) {
mSubjectDetailPresenter.lodDetail((Children) bundle.getSerializable(RedditTestApplication.BUNDLE_SUBJECT));
}
/**
* download the icon picture
* @param defaultActivity
* @param imageView
* @param image
*/
@Override
public void downloadSubjectPicture(DefaultActivity defaultActivity, ImageView imageView, String image) {
RedditApiService.postponeLoadPicture(defaultActivity, imageView, image, true, true, new Callback() {
@Override
public void onSuccess() {
ActivityCompat.startPostponedEnterTransition(defaultActivity);
}
@Override
public void onError() {
ActivityCompat.startPostponedEnterTransition(defaultActivity);
}
});
}
/**
* download the banner picture
* @param defaultActivity
* @param imageView
* @param image
*/
@Override
public void downloadSubjectBanner(DefaultActivity defaultActivity, ImageView imageView, String image) {
RedditApiService.loadPicture(defaultActivity, imageView, image, false, false, (picasso, uri, exception) -> {
});
}
/**
* Check if it has connection
* @return
*/
@Override
public boolean hasConnection() {
return NetWorkUtils.isNetworkAvailable(RedditTestApplication.getInstance());
}
}
| UTF-8 | Java | 2,530 | java | SubjectDetailInteractor.java | Java | [
{
"context": " com.squareup.picasso.Callback;\n\n/**\n * Created by Amir Granadillo on 17/01/2017.\n */\n\npublic class SubjectDetailInt",
"end": 612,
"score": 0.9998701214790344,
"start": 597,
"tag": "NAME",
"value": "Amir Granadillo"
}
] | null | [] | package com.amirgb.reddittestapp.subjectdetailview;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.widget.ImageView;
import com.amirgb.reddittestapp.DefaultActivity;
import com.amirgb.reddittestapp.RedditTestApplication;
import com.amirgb.reddittestapp.model.Children;
import com.amirgb.reddittestapp.mvp.ISubjectDetailInteractor;
import com.amirgb.reddittestapp.mvp.ISubjectDetailPresenter;
import com.amirgb.reddittestapp.rest.RedditApiService;
import com.amirgb.reddittestapp.util.NetWorkUtils;
import com.squareup.picasso.Callback;
/**
* Created by <NAME> on 17/01/2017.
*/
public class SubjectDetailInteractor implements ISubjectDetailInteractor {
private ISubjectDetailPresenter mSubjectDetailPresenter;
/**
* Constructor
*
* @param iSubjectDetailPresenter
*/
public SubjectDetailInteractor(ISubjectDetailPresenter iSubjectDetailPresenter) {
mSubjectDetailPresenter = iSubjectDetailPresenter;
}
/**
* Gets the subject from the bundle
* @param bundle
*/
@Override
public void getDetail(Bundle bundle) {
mSubjectDetailPresenter.lodDetail((Children) bundle.getSerializable(RedditTestApplication.BUNDLE_SUBJECT));
}
/**
* download the icon picture
* @param defaultActivity
* @param imageView
* @param image
*/
@Override
public void downloadSubjectPicture(DefaultActivity defaultActivity, ImageView imageView, String image) {
RedditApiService.postponeLoadPicture(defaultActivity, imageView, image, true, true, new Callback() {
@Override
public void onSuccess() {
ActivityCompat.startPostponedEnterTransition(defaultActivity);
}
@Override
public void onError() {
ActivityCompat.startPostponedEnterTransition(defaultActivity);
}
});
}
/**
* download the banner picture
* @param defaultActivity
* @param imageView
* @param image
*/
@Override
public void downloadSubjectBanner(DefaultActivity defaultActivity, ImageView imageView, String image) {
RedditApiService.loadPicture(defaultActivity, imageView, image, false, false, (picasso, uri, exception) -> {
});
}
/**
* Check if it has connection
* @return
*/
@Override
public boolean hasConnection() {
return NetWorkUtils.isNetworkAvailable(RedditTestApplication.getInstance());
}
}
| 2,521 | 0.704743 | 0.701186 | 82 | 29.853659 | 30.446724 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.439024 | false | false | 13 |
d095c7503725d08153325163e159e5cfc1439aa0 | 33,423,435,557,686 | b50ac2d583fd8a858188dcf66293ce8fa2071c87 | /Variable.java | a52bfba54efb6e7fcac428f85e6fbd83f44d8ab8 | [] | no_license | SNLan/SAT-CDCL | https://github.com/SNLan/SAT-CDCL | da399ffbf0eb6d21da586f56adab1636700c10e5 | 38b862f13a8527325b4e3e9813ca312d249d9c68 | refs/heads/master | 2021-01-12T07:39:50.538000 | 2017-04-04T19:55:15 | 2017-04-04T19:55:15 | 76,995,069 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package satsolving.blatt06.dataStructure;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Optional;
import java.util.Stack;
import java.util.Vector;
import satsolving.blatt06.dataStructure.Clause.ClauseState;
/**
* A variable.
*
* @param <E>
*
*/
public class Variable {
/* Assignment states of a variable */
public enum State {
TRUE, FALSE, OPEN
};
/* Current assignment */
private State state;
/* Variable ID (range from 1 to n) */
private int id;
/* Activity of the variable */
private float activity = 0;
/* the level in which this unit clause be assigned. */
private int level;
/*
* the reason why is a variable in this clause been assigned. Decision is
* null
*/
private Clause resaon = null;
/*
* if the variable is now in a clause watched, then the clause is in this
* Vector
*/
private Vector<Clause> watched = new Vector<>();
public Vector<Clause> getWatched() {
return watched;
}
/**
* Creates a variable with the given ID.
*
* @param id
* ID of the variable
*/
public Variable(int id) {
this.id = id;
this.state = State.OPEN;
}
/**
* Returns the current assignment state of this variable.
*
* @return current assignment state
*/
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
/**
* Returns the ID of this variable.
*
* @return ID of this variable
*/
public int getId() {
return id;
}
/**
* @param val
* to be assign
* @param variables
* the map of variables
* @param units
* store the unit clause
* @return after assignments, if a clause is empty, then return this clause,
* otherwise return null
*/
public Clause assign(boolean val, HashMap<Integer, Variable> variables, Vector<Clause> units, int level,
Stack<Variable> stack) {
// assign value to this variable
if (val) {
this.state = State.TRUE;
} else {
this.state = State.FALSE;
}
if (this.getId() == 32 && level == 4) {
System.out.println("debug here");
}
this.level = level;
stack.push(this);
System.out.println("set variable " + this.getId() + " = " + this.state);
Clause emptyClause = null;
int beMovedLit;
// store clause whose watched literal has been moved
Vector<Clause> movedClause = new Vector<>();
ClauseState cState;
// the watched list of this variable
Iterator<Clause> iterator = getWatched().iterator();
Clause c = null;
while (iterator.hasNext()) {
cState = null;
c = iterator.next();
// the literal in c should be moved, lit1 or lit2
beMovedLit = Math.abs(c.getLit1()) == this.id ? c.getLit1() : c.getLit2();
if (c.getState().equals(ClauseState.UNIT)) {
if ((beMovedLit > 0 && val) || (beMovedLit < 0 && !val)) {
cState = ClauseState.SAT;
if(this.resaon == null){
//this.resaon = c;
Optional<Clause> optional = units.stream().filter(clause -> clause.getState().equals(ClauseState.UNIT)).findFirst();
if(optional.isPresent()){
this.resaon = optional.get();
}
}
} else if ((beMovedLit > 0 && !val) || (beMovedLit < 0 && val)) {
cState = ClauseState.EMPTY;
}
} else if (((beMovedLit > 0 && !val) || (beMovedLit < 0 && val)) && !c.getState().equals(ClauseState.SAT)) {
cState = c.reWatch(variables, beMovedLit, movedClause);
//if(cState.equals(ClauseState.UNIT)){
System.out.println("after rewatch the State of the " + c.toString() + " is " + cState);
//}
} else {
c.setState(ClauseState.SAT);
}
if (cState == ClauseState.EMPTY) {
c.setState(ClauseState.EMPTY);
if (emptyClause == null) {
emptyClause = c;
}
} else if (cState == ClauseState.UNIT) {
c.setState(ClauseState.UNIT);
units.add(c);
} else if (cState == ClauseState.SAT) {
c.setState(ClauseState.SAT);
}
}
this.getWatched().removeAll(movedClause);
return emptyClause;
}
/**
* clean the state, reason, level to the initial value the watched list
*/
public void clean(HashMap<Integer, Variable> variables, ClauseSet cs) {
this.resaon = null;
this.level = -1;
this.state = State.OPEN;
ClauseState newState = ClauseState.SUCCESS;
cs.getClauses().stream().filter(clause -> clause.containsVar(this)).forEach(clause -> {
// newState = ClauseState.SUCCESS;
if (clause.getState() == ClauseState.SAT) {
boolean flag = clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.anyMatch(lit -> clause.checkLiteralState(lit, variables).equals(State.TRUE));
if (flag) {
clause.setState(ClauseState.SAT);
}else if(clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.allMatch(lit -> clause.checkLiteralState(lit, variables).equals(State.FALSE)
&& !clause.appearsMore(this))){
clause.setState(ClauseState.UNIT);
}else {
clause.setState(ClauseState.SUCCESS);
}
} else if (clause.getState() == ClauseState.UNIT) {
// if we continual pop some elements, should check if those
// elements exist in the same clause.
// except this variable, if exists a variable with state OPEN,
// then should be set to SUCCESS. otherwise, UNIT
if (clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.anyMatch(lit -> variables.get(Math.abs(lit)).getState().equals(State.OPEN))) {
clause.setState(ClauseState.SUCCESS);
} else {
clause.setState(ClauseState.UNIT);
}
} else {
clause.setState(ClauseState.SUCCESS);
}
});
}
public float getActivity() {
return activity;
}
public void setActivity(float activity) {
this.activity = activity;
}
/*
* increase activity by multi 1.1 if a new learned clause contains this
* variable
*/
public void increaseActivity() {
this.activity *= 1.10;
}
/*
* decrease activity by multi 0.95 if this variable was chose by CDCL
* algorithmus
*/
public void decreaseActivity() {
this.activity = (float) (this.activity * 0.95);
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public Clause getResaon() {
return resaon;
}
@Override
public String toString() {
String res = "[" + this.id + " - " + state + " - " + this.activity + " - " + this.level + " - " + this.resaon;
return res + "]\n";
}
} | UTF-8 | Java | 6,418 | java | Variable.java | Java | [] | null | [] | package satsolving.blatt06.dataStructure;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Optional;
import java.util.Stack;
import java.util.Vector;
import satsolving.blatt06.dataStructure.Clause.ClauseState;
/**
* A variable.
*
* @param <E>
*
*/
public class Variable {
/* Assignment states of a variable */
public enum State {
TRUE, FALSE, OPEN
};
/* Current assignment */
private State state;
/* Variable ID (range from 1 to n) */
private int id;
/* Activity of the variable */
private float activity = 0;
/* the level in which this unit clause be assigned. */
private int level;
/*
* the reason why is a variable in this clause been assigned. Decision is
* null
*/
private Clause resaon = null;
/*
* if the variable is now in a clause watched, then the clause is in this
* Vector
*/
private Vector<Clause> watched = new Vector<>();
public Vector<Clause> getWatched() {
return watched;
}
/**
* Creates a variable with the given ID.
*
* @param id
* ID of the variable
*/
public Variable(int id) {
this.id = id;
this.state = State.OPEN;
}
/**
* Returns the current assignment state of this variable.
*
* @return current assignment state
*/
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
/**
* Returns the ID of this variable.
*
* @return ID of this variable
*/
public int getId() {
return id;
}
/**
* @param val
* to be assign
* @param variables
* the map of variables
* @param units
* store the unit clause
* @return after assignments, if a clause is empty, then return this clause,
* otherwise return null
*/
public Clause assign(boolean val, HashMap<Integer, Variable> variables, Vector<Clause> units, int level,
Stack<Variable> stack) {
// assign value to this variable
if (val) {
this.state = State.TRUE;
} else {
this.state = State.FALSE;
}
if (this.getId() == 32 && level == 4) {
System.out.println("debug here");
}
this.level = level;
stack.push(this);
System.out.println("set variable " + this.getId() + " = " + this.state);
Clause emptyClause = null;
int beMovedLit;
// store clause whose watched literal has been moved
Vector<Clause> movedClause = new Vector<>();
ClauseState cState;
// the watched list of this variable
Iterator<Clause> iterator = getWatched().iterator();
Clause c = null;
while (iterator.hasNext()) {
cState = null;
c = iterator.next();
// the literal in c should be moved, lit1 or lit2
beMovedLit = Math.abs(c.getLit1()) == this.id ? c.getLit1() : c.getLit2();
if (c.getState().equals(ClauseState.UNIT)) {
if ((beMovedLit > 0 && val) || (beMovedLit < 0 && !val)) {
cState = ClauseState.SAT;
if(this.resaon == null){
//this.resaon = c;
Optional<Clause> optional = units.stream().filter(clause -> clause.getState().equals(ClauseState.UNIT)).findFirst();
if(optional.isPresent()){
this.resaon = optional.get();
}
}
} else if ((beMovedLit > 0 && !val) || (beMovedLit < 0 && val)) {
cState = ClauseState.EMPTY;
}
} else if (((beMovedLit > 0 && !val) || (beMovedLit < 0 && val)) && !c.getState().equals(ClauseState.SAT)) {
cState = c.reWatch(variables, beMovedLit, movedClause);
//if(cState.equals(ClauseState.UNIT)){
System.out.println("after rewatch the State of the " + c.toString() + " is " + cState);
//}
} else {
c.setState(ClauseState.SAT);
}
if (cState == ClauseState.EMPTY) {
c.setState(ClauseState.EMPTY);
if (emptyClause == null) {
emptyClause = c;
}
} else if (cState == ClauseState.UNIT) {
c.setState(ClauseState.UNIT);
units.add(c);
} else if (cState == ClauseState.SAT) {
c.setState(ClauseState.SAT);
}
}
this.getWatched().removeAll(movedClause);
return emptyClause;
}
/**
* clean the state, reason, level to the initial value the watched list
*/
public void clean(HashMap<Integer, Variable> variables, ClauseSet cs) {
this.resaon = null;
this.level = -1;
this.state = State.OPEN;
ClauseState newState = ClauseState.SUCCESS;
cs.getClauses().stream().filter(clause -> clause.containsVar(this)).forEach(clause -> {
// newState = ClauseState.SUCCESS;
if (clause.getState() == ClauseState.SAT) {
boolean flag = clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.anyMatch(lit -> clause.checkLiteralState(lit, variables).equals(State.TRUE));
if (flag) {
clause.setState(ClauseState.SAT);
}else if(clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.allMatch(lit -> clause.checkLiteralState(lit, variables).equals(State.FALSE)
&& !clause.appearsMore(this))){
clause.setState(ClauseState.UNIT);
}else {
clause.setState(ClauseState.SUCCESS);
}
} else if (clause.getState() == ClauseState.UNIT) {
// if we continual pop some elements, should check if those
// elements exist in the same clause.
// except this variable, if exists a variable with state OPEN,
// then should be set to SUCCESS. otherwise, UNIT
if (clause.getLiterals().stream().filter(lit -> Math.abs(lit) != this.id)
.anyMatch(lit -> variables.get(Math.abs(lit)).getState().equals(State.OPEN))) {
clause.setState(ClauseState.SUCCESS);
} else {
clause.setState(ClauseState.UNIT);
}
} else {
clause.setState(ClauseState.SUCCESS);
}
});
}
public float getActivity() {
return activity;
}
public void setActivity(float activity) {
this.activity = activity;
}
/*
* increase activity by multi 1.1 if a new learned clause contains this
* variable
*/
public void increaseActivity() {
this.activity *= 1.10;
}
/*
* decrease activity by multi 0.95 if this variable was chose by CDCL
* algorithmus
*/
public void decreaseActivity() {
this.activity = (float) (this.activity * 0.95);
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public Clause getResaon() {
return resaon;
}
@Override
public String toString() {
String res = "[" + this.id + " - " + state + " - " + this.activity + " - " + this.level + " - " + this.resaon;
return res + "]\n";
}
} | 6,418 | 0.640075 | 0.635089 | 249 | 24.779116 | 25.117144 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.26506 | false | false | 13 |
faa6e6586a315c86c353fe3d8c60b7e539228794 | 32,908,039,474,183 | 4d706e51a134427fc25e5d01c7216829d0a8fbbd | /dz/src/FinalProject/Dates.java | 20f98d9ef051d79c915a66c7b290a5d968965df2 | [] | no_license | Tanyayasiuk/JavaPVT | https://github.com/Tanyayasiuk/JavaPVT | 9659f91724f989107eb1058f07b0c095df2e40f7 | 1015f439bf0d44c0bc045ff31b7455c9e21e7d7b | refs/heads/master | 2021-01-21T21:09:35.263000 | 2017-07-12T11:19:24 | 2017-07-12T11:19:24 | 92,312,252 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package FinalProject;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class Dates {
public static Date stringToDate(String string){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
Date date = null;
try {
date = format.parse(string);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
public static String dateFormatted(String dateString){
return new SimpleDateFormat("EEEEE, dd MMMMM yyyy, HH:mm", Locale.getDefault()).format(stringToDate(dateString));
}
}
| UTF-8 | Java | 636 | java | Dates.java | Java | [] | null | [] | package FinalProject;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class Dates {
public static Date stringToDate(String string){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
Date date = null;
try {
date = format.parse(string);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
public static String dateFormatted(String dateString){
return new SimpleDateFormat("EEEEE, dd MMMMM yyyy, HH:mm", Locale.getDefault()).format(stringToDate(dateString));
}
}
| 636 | 0.647799 | 0.647799 | 24 | 25.5 | 28.407745 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.541667 | false | false | 13 |
303d0e841590628facd084debdfac2dc70ccd9b9 | 23,046,794,577,033 | 84617c47b4d6f4b229e7814155beacf467e36cbf | /app/src/main/java/com/example/hemantkatariya/imageuploading/network/AppUtils.java | 5c1cd4e63f2af6d65e8884166d0918891a272bc0 | [] | no_license | morristech/Upload-Image-Multiple-Libraires | https://github.com/morristech/Upload-Image-Multiple-Libraires | d21d4c0ff5810ee0f1407e49e4d297060191e829 | e712e4662bfa809fd087093f2077ae8f3ff12856 | refs/heads/master | 2020-03-17T08:11:43.746000 | 2017-11-08T12:30:55 | 2017-11-08T12:30:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.hemantkatariya.imageuploading.network;
/**
* Created by Hemant Katariya on 11/8/2017.
*/
public class AppUtils {
public static final String URL_Upload = "http://192.168.x.x/upload";
public static final String URL_UploadRetrofit = "http://192.168.x.x/";
public static final String Token = "Bearer 0d79e839-15d1-4a45-84e0-46760b9b29a9";
}
| UTF-8 | Java | 375 | java | AppUtils.java | Java | [
{
"context": "atariya.imageuploading.network;\n\n/**\n * Created by Hemant Katariya on 11/8/2017.\n */\n\npublic class AppUtils {\n\n p",
"end": 93,
"score": 0.999893307685852,
"start": 78,
"tag": "NAME",
"value": "Hemant Katariya"
},
{
"context": "8.x.x/\";\n\n public static final String Token = \"Bearer 0d79e839-15d1-4a45-84e0-46760b9b29a9\";\n}\n",
"end": 335,
"score": 0.6433181762695312,
"start": 327,
"tag": "KEY",
"value": "Bearer 0"
},
{
"context": "\n\n public static final String Token = \"Bearer 0d79e839-15d1-4a45-84e0-46760b9b29a9\";\n}\n",
"end": 370,
"score": 0.8264684677124023,
"start": 335,
"tag": "PASSWORD",
"value": "d79e839-15d1-4a45-84e0-46760b9b29a9"
}
] | null | [] | package com.example.hemantkatariya.imageuploading.network;
/**
* Created by <NAME> on 11/8/2017.
*/
public class AppUtils {
public static final String URL_Upload = "http://192.168.x.x/upload";
public static final String URL_UploadRetrofit = "http://192.168.x.x/";
public static final String Token = "Bearer 0<PASSWORD>";
}
| 341 | 0.722667 | 0.608 | 13 | 27.846153 | 32.303478 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 13 |
df035e2641c6d2e70da2c1c3dd378a3af12c2034 | 1,099,511,637,874 | d0861ff0fac1d8f22f1ab9d2d14e3f0745dadb2b | /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MainTeleOpNoCorrection.java | adbb1651241d3056031ae4fc3eea4ed00103ce08 | [] | no_license | allenlinsh/skystone-qualifiers | https://github.com/allenlinsh/skystone-qualifiers | 1642fde0baf284fd2c5e018981ee5577043e0217 | 645fae129d1ccf0da408f84e69e49abb5ee749d0 | refs/heads/master | 2023-03-05T23:33:43.417000 | 2021-02-14T23:11:06 | 2021-02-14T23:11:06 | 219,931,237 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.firstinspires.ftc.teamcode;
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder;
import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
@TeleOp
public class MainTeleOpNoCorrection extends LinearOpMode {
private BNO055IMU imu;
private DcMotor leftBackMotor;
private DcMotor rightBackMotor;
private DcMotor leftFrontMotor;
private DcMotor rightFrontMotor;
private DcMotor gripMotor;
private DcMotor armMotor;
private Servo leftServo;
private Servo rightServo;
private Servo leftSkystoneServo;
private Servo rightSkystoneServo;
private ColorSensor leftColorSensor;
private ColorSensor rightColorSensor;
private DigitalChannel topLimit, bottomLimit;
Orientation lastAngles = new Orientation();
double globalAngle, power = 0, correction;
double leftServoState, rightServoState, leftSkystoneServoState, rightSkystoneServoState;
double leftColorThreshold, rightColorThreshold;
@Override
public void runOpMode() {
imu = hardwareMap.get(BNO055IMU.class, "imu");
leftBackMotor = hardwareMap.get(DcMotor.class, "leftBackMotor");
rightBackMotor = hardwareMap.get(DcMotor.class, "rightBackMotor");
leftFrontMotor = hardwareMap.get(DcMotor.class, "leftFrontMotor");
rightFrontMotor = hardwareMap.get(DcMotor.class, "rightFrontMotor");
gripMotor = hardwareMap.get(DcMotor.class, "gripMotor");
armMotor = hardwareMap.get(DcMotor.class, "armMotor");
leftServo = hardwareMap.get(Servo.class, "leftServo");
rightServo = hardwareMap.get(Servo.class, "rightServo");
leftSkystoneServo = hardwareMap.get(Servo.class, "leftSkystoneServo");
rightSkystoneServo = hardwareMap.get(Servo.class, "rightSkystoneServo");
leftColorSensor = hardwareMap.get(ColorSensor.class, "leftColorSensor");
rightColorSensor = hardwareMap.get(ColorSensor.class, "rightColorSensor");
topLimit = hardwareMap.get(DigitalChannel.class, "topLimit");
bottomLimit = hardwareMap.get(DigitalChannel.class, "bottomLimit");
// set motor direction
rightBackMotor.setDirection(DcMotorSimple.Direction.REVERSE);
rightFrontMotor.setDirection(DcMotorSimple.Direction.REVERSE);
armMotor.setDirection(DcMotorSimple.Direction.REVERSE);
gripMotor.setDirection(DcMotorSimple.Direction.REVERSE);
// set motor zero power behavior
armMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
gripMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
leftBackMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
rightBackMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
leftFrontMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
rightFrontMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
// set motor mode
leftBackMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
rightBackMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
leftFrontMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
rightFrontMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
// initialize servos
hookOff();
leftSkystoneServoState = 0.52;
rightSkystoneServoState = 0.98;
leftSkystoneServo.setPosition(leftSkystoneServoState);
rightSkystoneServo.setPosition(rightSkystoneServoState);
// initialize imu
BNO055IMU.Parameters imuParameters = new BNO055IMU.Parameters();
imuParameters.angleUnit = BNO055IMU.AngleUnit.DEGREES;
imuParameters.accelUnit = BNO055IMU.AccelUnit.METERS_PERSEC_PERSEC;
imuParameters.loggingEnabled = false;
imu.initialize(imuParameters);
telemetry.addData("Status", "Initializing...");
telemetry.update();
// make sure the imu gyro is calibrated before continuing.
while (!isStopRequested() && !imu.isGyroCalibrated())
{
sleep(50);
idle();
}
telemetry.addData("Status", "Initialized");
telemetry.update();
// wait for the game to start
waitForStart();
telemetry.addData("Status", "Running");
double driveAxial = 0;
double driveLateral = 0;
double driveYaw = 0;
double gripPower = 0;
double armPower = 0;
double leftBackPower = 0;
double rightBackPower = 0;
double leftFrontPower = 0;
double rightFrontPower = 0;
boolean noStart = true;
// run until the end of the match
while (opModeIsActive()) {
noStart = !(this.gamepad1.start || this.gamepad2.start);
telemetry.addData("1 imu heading", lastAngles.firstAngle);
telemetry.addData("2 global heading", globalAngle);
telemetry.addData("3 correction", correction);
telemetry.addData("4 leftBackPower", leftBackPower);
telemetry.addData("5 rightBackPower", rightBackPower);
telemetry.addData("6 leftFrontPower", leftFrontPower);
telemetry.addData("7 rightFrontPower", rightBackPower);
telemetry.addData("8 gripPower", gripPower);
telemetry.addData("9 armPower", armPower);
telemetry.update();
// assign controller power values
driveAxial = 0;
driveLateral = 0;
driveYaw = 0;
armPower = 0;
gripPower = 0;
if (this.gamepad1.right_bumper) {
hookOn();
}
else if (this.gamepad1.left_bumper) {
hookOff();
}
if (this.gamepad2.right_bumper) {
// grip hold
gripPower = 0.3;
}
else if (this.gamepad2.left_bumper) {
// grip release
gripPower = -0.3;
}
if (noStart && this.gamepad2.x) {
if (leftSkystoneServo.getPosition() < 0.98) {
leftSkystoneOn();
}
else if (leftSkystoneServo.getPosition() > 0.52){
leftSkystoneOff();
}
shortPause();
}
else if (noStart && this.gamepad2.b) {
if (rightSkystoneServo.getPosition() > 0.52) {
rightSkystoneOn();
}
else if (rightSkystoneServo.getPosition() < 0.98) {
rightSkystoneOff();
}
shortPause();
}
if (this.gamepad1.left_stick_y == 0 && this.gamepad1.left_stick_x == 0 && this.gamepad1.right_stick_x == 0) {
// dpad_left = slow left
if (gamepad1.dpad_left) {
driveLateral = -0.5;
}
// dpad_right = slow right
if (gamepad1.dpad_right) {
driveLateral = 0.5;
}
// dpad_up = slow forward
if (gamepad1.dpad_up) {
driveAxial = -0.25;
}
// dpad_down = slow backward
if (gamepad1.dpad_down) {
driveAxial = 0.25;
}
// x = slow rotate ccw
if (noStart && gamepad1.x) {
driveYaw = -0.35;
}
// b = slow rotate cw
if (noStart && gamepad1.b) {
driveYaw = 0.35;
}
}
else {
// set axial movement to logarithmic values and set a dead zone
driveAxial = this.gamepad1.left_stick_y;
if (Math.abs(driveAxial) < Math.sqrt(0.1)) {
driveAxial = 0;
}
else {
driveAxial = driveAxial * 110 /127;
driveAxial = driveAxial * driveAxial * Math.signum(driveAxial) / 1.0;
}
// set lateral movement to logarithmic values and set a dead zone
driveLateral = this.gamepad1.left_stick_x;
if (Math.abs(driveLateral) < Math.sqrt(0.1)) {
driveLateral = 0;
}
else {
driveLateral = driveLateral * 100 / 127;
driveLateral = driveLateral * driveLateral * Math.signum(driveLateral) / 1.0;
}
// set yaw movement to logarithmic values and set a dead zone
driveYaw = this.gamepad1.right_stick_x;
if (Math.abs(driveYaw) < Math.sqrt(0.1)) {
driveYaw = 0;
}
else {
driveYaw = driveYaw * 110 / 127;
driveYaw = driveYaw * driveYaw * Math.signum(driveYaw) / 1.0;
}
}
leftBackPower = -driveLateral - driveAxial + driveYaw;
rightBackPower = driveLateral - driveAxial - driveYaw;
leftFrontPower = driveLateral - driveAxial + driveYaw;
rightFrontPower = -driveLateral - driveAxial - driveYaw;
if (this.gamepad1.left_stick_y != 0 || this.gamepad1.left_stick_x != 0 || this.gamepad1.right_stick_x != 0 || this. gamepad1.dpad_up || this. gamepad1.dpad_down || this. gamepad1.dpad_left || this. gamepad1.dpad_right || this. gamepad1.x || this. gamepad1.b) {
leftBackMotor.setPower(leftBackPower);
rightBackMotor.setPower(rightBackPower);
leftFrontMotor.setPower(leftFrontPower);
rightFrontMotor.setPower(rightFrontPower);
}
else {
leftBackMotor.setPower(0);
rightBackMotor.setPower(0);
leftFrontMotor.setPower(0);
rightFrontMotor.setPower(0);
}
armPower = this.gamepad2.left_stick_y;
// arm stops if top limit is on and arm is moving backward
// or if bottom limit is on and arm is moving forward
if ((armPower > 0 && topPressed()) || (armPower < 0 && bottomPressed())) {
armMotor.setPower(0);
}
else {
armMotor.setPower(armPower);
}
gripMotor.setPower(gripPower);
leftServo.setPosition(leftServoState);
rightServo.setPosition(rightServoState);
rightSkystoneServo.setPosition(rightSkystoneServoState);
leftSkystoneServo.setPosition(leftSkystoneServoState);
}
}
public void shortPause() {
sleep(150);
}
public void hookOn() {
leftServoState = 1;
rightServoState = 0;
}
public void hookOff() {
leftServoState = 0.1;
rightServoState = 0.9;
}
public void leftSkystoneOn() {
leftSkystoneServoState = 0.98;
}
public void rightSkystoneOn() {
rightSkystoneServoState = 0.52;
}
public void leftSkystoneOff() {
leftSkystoneServoState = 0.52;
}
public void rightSkystoneOff() {
rightSkystoneServoState = 0.98;
}
public boolean topPressed() {
return !topLimit.getState();
}
public boolean bottomPressed() {
return !bottomLimit.getState();
}
}
| UTF-8 | Java | 12,143 | java | MainTeleOpNoCorrection.java | Java | [] | null | [] | package org.firstinspires.ftc.teamcode;
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder;
import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
@TeleOp
public class MainTeleOpNoCorrection extends LinearOpMode {
private BNO055IMU imu;
private DcMotor leftBackMotor;
private DcMotor rightBackMotor;
private DcMotor leftFrontMotor;
private DcMotor rightFrontMotor;
private DcMotor gripMotor;
private DcMotor armMotor;
private Servo leftServo;
private Servo rightServo;
private Servo leftSkystoneServo;
private Servo rightSkystoneServo;
private ColorSensor leftColorSensor;
private ColorSensor rightColorSensor;
private DigitalChannel topLimit, bottomLimit;
Orientation lastAngles = new Orientation();
double globalAngle, power = 0, correction;
double leftServoState, rightServoState, leftSkystoneServoState, rightSkystoneServoState;
double leftColorThreshold, rightColorThreshold;
@Override
public void runOpMode() {
imu = hardwareMap.get(BNO055IMU.class, "imu");
leftBackMotor = hardwareMap.get(DcMotor.class, "leftBackMotor");
rightBackMotor = hardwareMap.get(DcMotor.class, "rightBackMotor");
leftFrontMotor = hardwareMap.get(DcMotor.class, "leftFrontMotor");
rightFrontMotor = hardwareMap.get(DcMotor.class, "rightFrontMotor");
gripMotor = hardwareMap.get(DcMotor.class, "gripMotor");
armMotor = hardwareMap.get(DcMotor.class, "armMotor");
leftServo = hardwareMap.get(Servo.class, "leftServo");
rightServo = hardwareMap.get(Servo.class, "rightServo");
leftSkystoneServo = hardwareMap.get(Servo.class, "leftSkystoneServo");
rightSkystoneServo = hardwareMap.get(Servo.class, "rightSkystoneServo");
leftColorSensor = hardwareMap.get(ColorSensor.class, "leftColorSensor");
rightColorSensor = hardwareMap.get(ColorSensor.class, "rightColorSensor");
topLimit = hardwareMap.get(DigitalChannel.class, "topLimit");
bottomLimit = hardwareMap.get(DigitalChannel.class, "bottomLimit");
// set motor direction
rightBackMotor.setDirection(DcMotorSimple.Direction.REVERSE);
rightFrontMotor.setDirection(DcMotorSimple.Direction.REVERSE);
armMotor.setDirection(DcMotorSimple.Direction.REVERSE);
gripMotor.setDirection(DcMotorSimple.Direction.REVERSE);
// set motor zero power behavior
armMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
gripMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
leftBackMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
rightBackMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
leftFrontMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
rightFrontMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
// set motor mode
leftBackMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
rightBackMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
leftFrontMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
rightFrontMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
// initialize servos
hookOff();
leftSkystoneServoState = 0.52;
rightSkystoneServoState = 0.98;
leftSkystoneServo.setPosition(leftSkystoneServoState);
rightSkystoneServo.setPosition(rightSkystoneServoState);
// initialize imu
BNO055IMU.Parameters imuParameters = new BNO055IMU.Parameters();
imuParameters.angleUnit = BNO055IMU.AngleUnit.DEGREES;
imuParameters.accelUnit = BNO055IMU.AccelUnit.METERS_PERSEC_PERSEC;
imuParameters.loggingEnabled = false;
imu.initialize(imuParameters);
telemetry.addData("Status", "Initializing...");
telemetry.update();
// make sure the imu gyro is calibrated before continuing.
while (!isStopRequested() && !imu.isGyroCalibrated())
{
sleep(50);
idle();
}
telemetry.addData("Status", "Initialized");
telemetry.update();
// wait for the game to start
waitForStart();
telemetry.addData("Status", "Running");
double driveAxial = 0;
double driveLateral = 0;
double driveYaw = 0;
double gripPower = 0;
double armPower = 0;
double leftBackPower = 0;
double rightBackPower = 0;
double leftFrontPower = 0;
double rightFrontPower = 0;
boolean noStart = true;
// run until the end of the match
while (opModeIsActive()) {
noStart = !(this.gamepad1.start || this.gamepad2.start);
telemetry.addData("1 imu heading", lastAngles.firstAngle);
telemetry.addData("2 global heading", globalAngle);
telemetry.addData("3 correction", correction);
telemetry.addData("4 leftBackPower", leftBackPower);
telemetry.addData("5 rightBackPower", rightBackPower);
telemetry.addData("6 leftFrontPower", leftFrontPower);
telemetry.addData("7 rightFrontPower", rightBackPower);
telemetry.addData("8 gripPower", gripPower);
telemetry.addData("9 armPower", armPower);
telemetry.update();
// assign controller power values
driveAxial = 0;
driveLateral = 0;
driveYaw = 0;
armPower = 0;
gripPower = 0;
if (this.gamepad1.right_bumper) {
hookOn();
}
else if (this.gamepad1.left_bumper) {
hookOff();
}
if (this.gamepad2.right_bumper) {
// grip hold
gripPower = 0.3;
}
else if (this.gamepad2.left_bumper) {
// grip release
gripPower = -0.3;
}
if (noStart && this.gamepad2.x) {
if (leftSkystoneServo.getPosition() < 0.98) {
leftSkystoneOn();
}
else if (leftSkystoneServo.getPosition() > 0.52){
leftSkystoneOff();
}
shortPause();
}
else if (noStart && this.gamepad2.b) {
if (rightSkystoneServo.getPosition() > 0.52) {
rightSkystoneOn();
}
else if (rightSkystoneServo.getPosition() < 0.98) {
rightSkystoneOff();
}
shortPause();
}
if (this.gamepad1.left_stick_y == 0 && this.gamepad1.left_stick_x == 0 && this.gamepad1.right_stick_x == 0) {
// dpad_left = slow left
if (gamepad1.dpad_left) {
driveLateral = -0.5;
}
// dpad_right = slow right
if (gamepad1.dpad_right) {
driveLateral = 0.5;
}
// dpad_up = slow forward
if (gamepad1.dpad_up) {
driveAxial = -0.25;
}
// dpad_down = slow backward
if (gamepad1.dpad_down) {
driveAxial = 0.25;
}
// x = slow rotate ccw
if (noStart && gamepad1.x) {
driveYaw = -0.35;
}
// b = slow rotate cw
if (noStart && gamepad1.b) {
driveYaw = 0.35;
}
}
else {
// set axial movement to logarithmic values and set a dead zone
driveAxial = this.gamepad1.left_stick_y;
if (Math.abs(driveAxial) < Math.sqrt(0.1)) {
driveAxial = 0;
}
else {
driveAxial = driveAxial * 110 /127;
driveAxial = driveAxial * driveAxial * Math.signum(driveAxial) / 1.0;
}
// set lateral movement to logarithmic values and set a dead zone
driveLateral = this.gamepad1.left_stick_x;
if (Math.abs(driveLateral) < Math.sqrt(0.1)) {
driveLateral = 0;
}
else {
driveLateral = driveLateral * 100 / 127;
driveLateral = driveLateral * driveLateral * Math.signum(driveLateral) / 1.0;
}
// set yaw movement to logarithmic values and set a dead zone
driveYaw = this.gamepad1.right_stick_x;
if (Math.abs(driveYaw) < Math.sqrt(0.1)) {
driveYaw = 0;
}
else {
driveYaw = driveYaw * 110 / 127;
driveYaw = driveYaw * driveYaw * Math.signum(driveYaw) / 1.0;
}
}
leftBackPower = -driveLateral - driveAxial + driveYaw;
rightBackPower = driveLateral - driveAxial - driveYaw;
leftFrontPower = driveLateral - driveAxial + driveYaw;
rightFrontPower = -driveLateral - driveAxial - driveYaw;
if (this.gamepad1.left_stick_y != 0 || this.gamepad1.left_stick_x != 0 || this.gamepad1.right_stick_x != 0 || this. gamepad1.dpad_up || this. gamepad1.dpad_down || this. gamepad1.dpad_left || this. gamepad1.dpad_right || this. gamepad1.x || this. gamepad1.b) {
leftBackMotor.setPower(leftBackPower);
rightBackMotor.setPower(rightBackPower);
leftFrontMotor.setPower(leftFrontPower);
rightFrontMotor.setPower(rightFrontPower);
}
else {
leftBackMotor.setPower(0);
rightBackMotor.setPower(0);
leftFrontMotor.setPower(0);
rightFrontMotor.setPower(0);
}
armPower = this.gamepad2.left_stick_y;
// arm stops if top limit is on and arm is moving backward
// or if bottom limit is on and arm is moving forward
if ((armPower > 0 && topPressed()) || (armPower < 0 && bottomPressed())) {
armMotor.setPower(0);
}
else {
armMotor.setPower(armPower);
}
gripMotor.setPower(gripPower);
leftServo.setPosition(leftServoState);
rightServo.setPosition(rightServoState);
rightSkystoneServo.setPosition(rightSkystoneServoState);
leftSkystoneServo.setPosition(leftSkystoneServoState);
}
}
public void shortPause() {
sleep(150);
}
public void hookOn() {
leftServoState = 1;
rightServoState = 0;
}
public void hookOff() {
leftServoState = 0.1;
rightServoState = 0.9;
}
public void leftSkystoneOn() {
leftSkystoneServoState = 0.98;
}
public void rightSkystoneOn() {
rightSkystoneServoState = 0.52;
}
public void leftSkystoneOff() {
leftSkystoneServoState = 0.52;
}
public void rightSkystoneOff() {
rightSkystoneServoState = 0.98;
}
public boolean topPressed() {
return !topLimit.getState();
}
public boolean bottomPressed() {
return !bottomLimit.getState();
}
}
| 12,143 | 0.586346 | 0.571358 | 296 | 40.023647 | 27.739792 | 272 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733108 | false | false | 13 |
8c084c615dbd15ff9bae6a09ee06a54c9ece781a | 3,693,671,938,597 | cc10014ec1df1791dba27cebfe4ec973ceaf9a6b | /src/asbridge/me/uk/gcopy/services/FileCopyService.java | f5d183bc4a8c1c1d725deb3eb000e5f798b37ca1 | [] | no_license | dasbrid/FileCopy | https://github.com/dasbrid/FileCopy | 2a6299b1776a28839575024d2cf233848dc7a234 | 48004672fff17f674b8a7c51e41d83e198201e42 | refs/heads/master | 2016-08-07T17:52:58.256000 | 2015-03-24T14:14:47 | 2015-03-24T14:14:47 | 31,549,441 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package asbridge.me.uk.gcopy.services;
import android.app.*;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import asbridge.me.uk.gcopy.helpers.SharedPreferencesHelper;
import asbridge.me.uk.gcopy.R;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;
import android.support.v4.app.NotificationCompat;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by David on 01/03/2015.
*/
public class FileCopyService extends IntentService {
private final String TAG = "FileCopyService";
public static final String FILE_COPY_INTENT_KEY_ORIGINFILEPATH = "asbridge.me.filecopyservice.INTENT_KEY_ORIGINFILEPATH";
public static final String FILE_COPY_INTENT_KEY_FILENAME = "asbridge.me.filecopyservice.INTENT_KEY_FILENAME";
public static final String FILE_COPY_INTENT_KEY_BUCKET = "asbridge.me.filecopyservice.INTENT_KEY_BUCKET";
public static final String FILE_COPY_INTENT_KEY_DATETAKEN = "asbridge.me.filecopyservice.INTENT_KEY_DATETAKEN";
public FileCopyService() {
super(FileCopyService.class.getName());
}
@Override
protected void onHandleIntent(Intent fileCopyIntent) {
// Gets data from the incoming Intent
String originfilepath = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_ORIGINFILEPATH);
String filename = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_FILENAME);
String bucket = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_BUCKET);
if (bucket == null) bucket = "";
Long dateTaken = fileCopyIntent.getLongExtra(FILE_COPY_INTENT_KEY_DATETAKEN, -1L);
sendNotificationStartCopy(filename);
boolean success = true;
if(!SharedPreferencesHelper.isDemoMode(getApplicationContext()))
success = copyFileWithSamba(originfilepath, filename, dateTaken, bucket);
if (success)
sendNotificationCopyComplete(filename);
else
sendNotificationCopyFailed(filename);
}
private void sendNotificationStartCopy(String filename)
{
sendNotificationCompat(filename, "Starting copy");
}
private void sendNotificationCopyComplete(String filename)
{
sendNotificationCompat(filename, "Copy finished");
}
private void sendNotificationCopyFailed(String filename)
{
sendNotificationCompat (filename, "Copy failed");
}
private void sendNotificationCompat(String filename, String message) {
//Intent intent = new Intent(getApplicationContext(), GCopyActivity.class);
//intent.putExtra("filename", filename);
// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("File " + filename)
.setStyle(new NotificationCompat.BigTextStyle().bigText("FileCopy"))
.setAutoCancel(true)
.setContentText(message);
//.setContentIntent(pendingIntent);
// using has as notification id allows us to update the notification later on.
Notification n = mBuilder.build();
int filehash = hashfilename(filename);
Log.v(TAG, "Send Notification " + message + " for " + filename + ":" + filehash);
mNotificationManager.notify(filehash, n);
}
public static int hashfilename(String filename) {
int result = 0;
int power = 1;
for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i);
result += (int)c * power;
power *= 2;
}
result = result % 10000;
return result;
}
private boolean copyFileWithSamba(String originfilepath, String filename, Long dateTakenLong, String bucket)
{
boolean successful;
final String USER_NAME = SharedPreferencesHelper.getSmbUser(getApplicationContext());
final String PASSWORD = SharedPreferencesHelper.getSmbPwd(getApplicationContext());
final boolean ADDFILENAMEINFO = SharedPreferencesHelper.addFilenameInfo(getApplicationContext());
String datetakenString;
if (dateTakenLong > 0L) {
Date dateTaken = new Date(dateTakenLong);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
datetakenString = formatter.format(dateTaken);
}
else {
datetakenString = null;
}
// have to use the ip address
// e.g. final String NETWORK_FOLDER = "smb://192.168.1.1/SharedFolder/";
final String NETWORK_FOLDER = SharedPreferencesHelper.getSmbNetworkFolder(getApplicationContext());
try {
String user = USER_NAME + ":" + PASSWORD;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, USER_NAME, PASSWORD);
String filenameinfo = "";
if (ADDFILENAMEINFO) {
if (datetakenString != null) {
filenameinfo = datetakenString;
}
filenameinfo = filenameinfo + "_";
if (!bucket.isEmpty()) {
filenameinfo += bucket;
}
filenameinfo = filenameinfo + "_";
}
String path = NETWORK_FOLDER + filenameinfo + filename;
Log.v(TAG, "copyFile " + filename + " for " + user + "to" + path);
SmbFile sFile = new SmbFile(path, auth);
InputStream in = new FileInputStream(originfilepath + "/" + filename);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
// Copy the bits from instream to samba outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
sfos.write(buf, 0, len);
}
in.close();
sfos.close();
successful = true;
Log.v(TAG, "Successful " + successful);
} catch (Exception e) {
successful = false;
e.printStackTrace();
}
return successful;
}
}
| UTF-8 | Java | 6,427 | java | FileCopyService.java | Java | [
{
"context": "eFormat;\nimport java.util.Date;\n\n/**\n * Created by David on 01/03/2015.\n */\npublic class FileCopyService e",
"end": 502,
"score": 0.7791846394538879,
"start": 497,
"tag": "NAME",
"value": "David"
},
{
"context": " // e.g. final String NETWORK_FOLDER = \"smb://192.168.1.1/SharedFolder/\";\n final String NETWORK_FOLD",
"end": 4858,
"score": 0.9996658563613892,
"start": 4847,
"tag": "IP_ADDRESS",
"value": "192.168.1.1"
},
{
"context": "ontext());\n try {\n String user = USER_NAME + \":\" + PASSWORD;\n NtlmPasswordAuthent",
"end": 5032,
"score": 0.9806224703788757,
"start": 5023,
"tag": "USERNAME",
"value": "USER_NAME"
}
] | null | [] | package asbridge.me.uk.gcopy.services;
import android.app.*;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import asbridge.me.uk.gcopy.helpers.SharedPreferencesHelper;
import asbridge.me.uk.gcopy.R;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;
import android.support.v4.app.NotificationCompat;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by David on 01/03/2015.
*/
public class FileCopyService extends IntentService {
private final String TAG = "FileCopyService";
public static final String FILE_COPY_INTENT_KEY_ORIGINFILEPATH = "asbridge.me.filecopyservice.INTENT_KEY_ORIGINFILEPATH";
public static final String FILE_COPY_INTENT_KEY_FILENAME = "asbridge.me.filecopyservice.INTENT_KEY_FILENAME";
public static final String FILE_COPY_INTENT_KEY_BUCKET = "asbridge.me.filecopyservice.INTENT_KEY_BUCKET";
public static final String FILE_COPY_INTENT_KEY_DATETAKEN = "asbridge.me.filecopyservice.INTENT_KEY_DATETAKEN";
public FileCopyService() {
super(FileCopyService.class.getName());
}
@Override
protected void onHandleIntent(Intent fileCopyIntent) {
// Gets data from the incoming Intent
String originfilepath = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_ORIGINFILEPATH);
String filename = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_FILENAME);
String bucket = fileCopyIntent.getStringExtra(FILE_COPY_INTENT_KEY_BUCKET);
if (bucket == null) bucket = "";
Long dateTaken = fileCopyIntent.getLongExtra(FILE_COPY_INTENT_KEY_DATETAKEN, -1L);
sendNotificationStartCopy(filename);
boolean success = true;
if(!SharedPreferencesHelper.isDemoMode(getApplicationContext()))
success = copyFileWithSamba(originfilepath, filename, dateTaken, bucket);
if (success)
sendNotificationCopyComplete(filename);
else
sendNotificationCopyFailed(filename);
}
private void sendNotificationStartCopy(String filename)
{
sendNotificationCompat(filename, "Starting copy");
}
private void sendNotificationCopyComplete(String filename)
{
sendNotificationCompat(filename, "Copy finished");
}
private void sendNotificationCopyFailed(String filename)
{
sendNotificationCompat (filename, "Copy failed");
}
private void sendNotificationCompat(String filename, String message) {
//Intent intent = new Intent(getApplicationContext(), GCopyActivity.class);
//intent.putExtra("filename", filename);
// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("File " + filename)
.setStyle(new NotificationCompat.BigTextStyle().bigText("FileCopy"))
.setAutoCancel(true)
.setContentText(message);
//.setContentIntent(pendingIntent);
// using has as notification id allows us to update the notification later on.
Notification n = mBuilder.build();
int filehash = hashfilename(filename);
Log.v(TAG, "Send Notification " + message + " for " + filename + ":" + filehash);
mNotificationManager.notify(filehash, n);
}
public static int hashfilename(String filename) {
int result = 0;
int power = 1;
for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i);
result += (int)c * power;
power *= 2;
}
result = result % 10000;
return result;
}
private boolean copyFileWithSamba(String originfilepath, String filename, Long dateTakenLong, String bucket)
{
boolean successful;
final String USER_NAME = SharedPreferencesHelper.getSmbUser(getApplicationContext());
final String PASSWORD = SharedPreferencesHelper.getSmbPwd(getApplicationContext());
final boolean ADDFILENAMEINFO = SharedPreferencesHelper.addFilenameInfo(getApplicationContext());
String datetakenString;
if (dateTakenLong > 0L) {
Date dateTaken = new Date(dateTakenLong);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
datetakenString = formatter.format(dateTaken);
}
else {
datetakenString = null;
}
// have to use the ip address
// e.g. final String NETWORK_FOLDER = "smb://192.168.1.1/SharedFolder/";
final String NETWORK_FOLDER = SharedPreferencesHelper.getSmbNetworkFolder(getApplicationContext());
try {
String user = USER_NAME + ":" + PASSWORD;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, USER_NAME, PASSWORD);
String filenameinfo = "";
if (ADDFILENAMEINFO) {
if (datetakenString != null) {
filenameinfo = datetakenString;
}
filenameinfo = filenameinfo + "_";
if (!bucket.isEmpty()) {
filenameinfo += bucket;
}
filenameinfo = filenameinfo + "_";
}
String path = NETWORK_FOLDER + filenameinfo + filename;
Log.v(TAG, "copyFile " + filename + " for " + user + "to" + path);
SmbFile sFile = new SmbFile(path, auth);
InputStream in = new FileInputStream(originfilepath + "/" + filename);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
// Copy the bits from instream to samba outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
sfos.write(buf, 0, len);
}
in.close();
sfos.close();
successful = true;
Log.v(TAG, "Successful " + successful);
} catch (Exception e) {
successful = false;
e.printStackTrace();
}
return successful;
}
}
| 6,427 | 0.643224 | 0.637623 | 167 | 37.485031 | 31.581821 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.658683 | false | false | 13 |
552a2fdb8c0c2471a8d4ce64cee8f621366de95d | 18,975,165,515,388 | 980e324bf0b91c0aaaf1e3679a46c152fbc36957 | /com.moser.products/src/main/java/com/moser/products/cdi/producer/EntityManagerProducer.java | 155df86bdebcad2e7b14623d8dae180188ea6b7d | [] | no_license | n-moser/Products | https://github.com/n-moser/Products | df69da395d23eb5736f51d74a822fc944100a0b6 | 9997c2ac5d9d4afb97e2edfb41b995d8553166a5 | refs/heads/master | 2021-05-27T22:26:10.851000 | 2012-12-11T22:02:38 | 2012-12-11T22:02:38 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2012 PRODYNA AG.
*/
package com.moser.products.cdi.producer;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
* EntityManagerProducer
*
* @author @author Nicolas Moser <nicolas.moser@prodyna.de>
*/
public class EntityManagerProducer {
@Produces
@PersistenceContext(unitName = "productsPu")
private EntityManager entityManager;
}
| UTF-8 | Java | 466 | java | EntityManagerProducer.java | Java | [
{
"context": "\n * EntityManagerProducer\r\n * \r\n * @author @author Nicolas Moser <nicolas.moser@prodyna.de>\r\n */\r\npublic cla",
"end": 283,
"score": 0.9998781085014343,
"start": 270,
"tag": "NAME",
"value": "Nicolas Moser"
},
{
"context": "oducer\r\n * \r\n * @author @author Nicolas Moser <nicolas.moser@prodyna.de>\r\n */\r\npublic class EntityManagerProducer {\r\n\r",
"end": 312,
"score": 0.9997932314872742,
"start": 288,
"tag": "EMAIL",
"value": "nicolas.moser@prodyna.de"
}
] | null | [] | /*
* Copyright 2012 PRODYNA AG.
*/
package com.moser.products.cdi.producer;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
* EntityManagerProducer
*
* @author @author <NAME> <<EMAIL>>
*/
public class EntityManagerProducer {
@Produces
@PersistenceContext(unitName = "productsPu")
private EntityManager entityManager;
}
| 442 | 0.740343 | 0.73176 | 21 | 20.190475 | 20.20047 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47619 | false | false | 13 |
3c8ac7d5ffdac54c13fadb8de644d85826596d6b | 13,159,779,861,775 | f69d284e406fc7ab03998080f312a864d824dcc1 | /app/src/main/java/div/craigabyss/khmrtstatus/MainActivity.java | dd9ed8d7af4cf18ec399108dfce148043ca5d2ef | [] | no_license | craigabyss/KHMRTStatus | https://github.com/craigabyss/KHMRTStatus | 30271b014db7fbc00652a1732a14c0d42ffad5e7 | 2df5d0f33816972c4d4290bce0f5025bf66477f3 | refs/heads/master | 2016-08-06T14:23:19.779000 | 2015-03-09T16:15:09 | 2015-03-09T16:15:09 | 31,906,692 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package div.craigabyss.khmrtstatus;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
public class MainActivity extends ActionBarActivity {
private TextView textResult;
private RequestQueue requestQueue;
private void initialComponent() {
textResult = (TextView)findViewById(R.id.textResult);
requestQueue = Volley.newRequestQueue(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity_layout);
initialComponent();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void btnHttpTest_OnClick(View view) {
refresh();
}
private void refresh() {
StringRequest stringReq = new StringRequest(
"http://data.kaohsiung.gov.tw/Opendata/MrtJsonGet.aspx?site=107",
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
textResult.setText(captureTarget(response));
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
textResult.setText("Gonwan in the house");
}
});
this.requestQueue.add(stringReq);
}
private String captureTarget(String str){
int jsonStart = str.indexOf("{");
int jsonEnd = str.lastIndexOf("}");
if(jsonEnd>=0 && jsonStart>=0)
return str.substring(jsonStart, jsonEnd+1);
else
return str;
}
}
| UTF-8 | Java | 2,686 | java | MainActivity.java | Java | [] | null | [] | package div.craigabyss.khmrtstatus;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
public class MainActivity extends ActionBarActivity {
private TextView textResult;
private RequestQueue requestQueue;
private void initialComponent() {
textResult = (TextView)findViewById(R.id.textResult);
requestQueue = Volley.newRequestQueue(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity_layout);
initialComponent();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void btnHttpTest_OnClick(View view) {
refresh();
}
private void refresh() {
StringRequest stringReq = new StringRequest(
"http://data.kaohsiung.gov.tw/Opendata/MrtJsonGet.aspx?site=107",
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
textResult.setText(captureTarget(response));
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
textResult.setText("Gonwan in the house");
}
});
this.requestQueue.add(stringReq);
}
private String captureTarget(String str){
int jsonStart = str.indexOf("{");
int jsonEnd = str.lastIndexOf("}");
if(jsonEnd>=0 && jsonStart>=0)
return str.substring(jsonStart, jsonEnd+1);
else
return str;
}
}
| 2,686 | 0.641102 | 0.638496 | 92 | 28.195652 | 23.087376 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.423913 | false | false | 13 |
88fe671780d8bce578ae3bf3e9926d64c4592edf | 27,504,970,579,429 | 2adce309943dac8b502f841e4c31145d8222b7d5 | /zzx-shardingsphere/zzx-db-read-write-java/src/main/java/com/zzx/sharding/config/MasterProp.java | ca4d5a3e8e6a82a239470c1af2338d33296d811a | [] | no_license | danielzhou888/springcloud-zzx | https://github.com/danielzhou888/springcloud-zzx | 5abd019efa2a754049a72fc7315286007b2c7c6a | ed55d0e648a8acca87ffe742c5bf464dff48c25a | refs/heads/master | 2023-06-23T13:47:42.744000 | 2023-04-09T19:21:48 | 2023-04-09T19:21:48 | 188,683,737 | 0 | 1 | null | false | 2023-06-14T22:25:41 | 2019-05-26T13:02:39 | 2023-03-29T12:13:41 | 2023-06-14T22:25:41 | 11,890 | 0 | 1 | 25 | Roff | false | false | package com.zzx.sharding.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author zhouzhixiang
* @company 叮当快药科技集团有限公司
* @Date 2020-03-15
*/
@ConfigurationProperties(prefix = "spring.shardingsphere.datasource.master")
@Data
public class MasterProp {
private String url;
private String username;
private String password;
private String type;
private String driverClassName;
}
| UTF-8 | Java | 486 | java | MasterProp.java | Java | [
{
"context": "roperties.ConfigurationProperties;\n\n/**\n * @author zhouzhixiang\n * @company 叮当快药科技集团有限公司\n * @Date 2020-03-15\n */\n",
"end": 158,
"score": 0.7960445880889893,
"start": 146,
"tag": "USERNAME",
"value": "zhouzhixiang"
}
] | null | [] | package com.zzx.sharding.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author zhouzhixiang
* @company 叮当快药科技集团有限公司
* @Date 2020-03-15
*/
@ConfigurationProperties(prefix = "spring.shardingsphere.datasource.master")
@Data
public class MasterProp {
private String url;
private String username;
private String password;
private String type;
private String driverClassName;
}
| 486 | 0.764069 | 0.746753 | 19 | 23.31579 | 21.138771 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false | 13 |
5d581da7922facb36f2fd9122737dc9c59e9c07f | 21,775,484,197,468 | fce478d30b1d83fba462857445400a26ca127949 | /src/Juice.java | cc3dfa0ee12baf1b15f4985a014127be0e823871 | [] | no_license | TheDropOne/Laba8 | https://github.com/TheDropOne/Laba8 | ad3e4a18eb58581358df71623334809deaeb554c | c963be599c41fa96251b90e451f9a469c8b1144c | refs/heads/master | 2020-07-02T17:15:54.904000 | 2016-11-24T18:07:26 | 2016-11-24T18:07:26 | 74,289,358 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.List;
/**
* Created by Semen on 20-Nov-16.
*/
public class Juice {
private List<String> ingredients;
public Juice(List<String> ingredients) {
this.ingredients = ingredients;
}
public List<String> getIngredients() {
return ingredients;
}
}
| UTF-8 | Java | 298 | java | Juice.java | Java | [
{
"context": "import java.util.List;\n\n/**\n * Created by Semen on 20-Nov-16.\n */\npublic class Juice {\n privat",
"end": 47,
"score": 0.9987521171569824,
"start": 42,
"tag": "NAME",
"value": "Semen"
}
] | null | [] | import java.util.List;
/**
* Created by Semen on 20-Nov-16.
*/
public class Juice {
private List<String> ingredients;
public Juice(List<String> ingredients) {
this.ingredients = ingredients;
}
public List<String> getIngredients() {
return ingredients;
}
}
| 298 | 0.637584 | 0.624161 | 16 | 17.5625 | 16.631929 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 13 |
8f10578a4d93ea33f5f20268b2d061032a8a1f4c | 28,561,532,522,462 | a4d8e3f3ab4adb205b434fc0687911e7845d02c3 | /MercurioJpa/src/model/Logger.java | e6bbefd9da2a4bc9cc8e22de9bd29fb70e1107f6 | [] | no_license | mviali/Mercurio | https://github.com/mviali/Mercurio | c5181e064046caa3ad853ae68917bd153037e5df | 17992bf3eb582e87bdb10ba980796ff93f1b74bc | refs/heads/master | 2021-01-18T22:46:52.848000 | 2016-07-12T15:02:02 | 2016-07-12T15:02:02 | 63,164,099 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the logger database table.
*
*/
@Entity
@Table(name="logger")
@NamedQuery(name="Logger.findAll", query="SELECT l FROM Logger l")
public class Logger implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@Lob
private String response;
private int status;
private String url;
private String userName;
public Logger() {
}
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
public String getResponse() {
return this.response;
}
public void setResponse(String response) {
this.response = response;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
} | UTF-8 | Java | 1,194 | java | Logger.java | Java | [
{
"context": " setUserName(String userName) {\r\n\t\tthis.userName = userName;\r\n\t}\r\n\r\n}",
"end": 1184,
"score": 0.9720221757888794,
"start": 1176,
"tag": "USERNAME",
"value": "userName"
}
] | null | [] | package model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the logger database table.
*
*/
@Entity
@Table(name="logger")
@NamedQuery(name="Logger.findAll", query="SELECT l FROM Logger l")
public class Logger implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@Lob
private String response;
private int status;
private String url;
private String userName;
public Logger() {
}
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
public String getResponse() {
return this.response;
}
public void setResponse(String response) {
this.response = response;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
} | 1,194 | 0.659129 | 0.658291 | 73 | 14.383562 | 16.029621 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.972603 | false | false | 13 |
34f43d09b2faad7dc9f332c870e7d2560777ee4a | 18,648,748,005,701 | 419479dd32913c32c65bfc439f36b699bfcd1347 | /src/eknoware/component/board/manager/dao/MsInfoBoardDAOImpl.java | 27a9afa977039965f1ea50475f585b8b684af544 | [] | no_license | jiman94/gplus.2001 | https://github.com/jiman94/gplus.2001 | c08af0aa34d428e276d7d0aebb9a9bd7a4ae38f6 | 2e6b54949388b886c6d39efad7ee481f1f31683a | refs/heads/master | 2021-01-01T19:46:44.969000 | 2014-01-08T23:31:27 | 2014-01-08T23:31:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package eknoware.component.board.manager.dao;
import java.io.File;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import eknoware.commlib.util.Utility;
import eknoware.commlib.util.ReplaceUtil;
import eknoware.component.board.manager.upload.UploadTbMng;
import eknoware.component.board.dao.*;
import java.util.*;
import eknoware.commlib.comm.*;
import eknoware.commlib.db.*;
import eknoware.commlib.exception.*;
import eknoware.commlib.lib.*;
import eknoware.commlib.log.*;
import eknoware.commlib.util.*;
import eknoware.commlib.log.GCmLog;
public class MsInfoBoardDAOImpl implements InfoBoardDAO
{
private static final String QUERY1 = "select skin,tbTitle,attach_key,editmode,image_allow,tbCnt,tbInfoStatus from tablemng where tbName=?";
private static final String QUERY2 = "select count(seq) cnt from tablemnginfo where tbName = ?";
private static final String QUERY3 = "Select top 15 seq,readnum,writeday,viewSelect,title from tablemnginfo where tbName = ? and seq <= ? order by seq desc";
private static final String QUERY4 = "select title,content,imgInfo,writeday,readnum from tablemnginfo where seq = ?";
private static final String QUERY5 = "insert into tablemnginfo (tbName,seq,title,readnum,writeday,imgInfo,viewSelect,content) values(?,?,?,0,getdate(),?,0,?)";
private static final String QUERY6 = "update tablemnginfo set title=?,imgInfo=?,content=? where seq = ? ";
private static final String QUERY7 = "insert into downloadmnginfo (tbName,seq,fileName,fileSize,downCnt) values(?,?,?,?,0)";
private static final String QUERY8 = "select max(seq) as seq from tablemnginfo";
private static final String QUERY9 = "delete from downloadmnginfo where tbidx = ?";
private static final String QUERY10 = "update tablemnginfo set viewSelect = ? where seq = ?";
private static final String QUERY11 = "select filename from downloadmnginfo where tbName = ? and seq =? order by tbidx";
private static final String QUERY12 = "delete from tablemnginfo where seq = ?";
private static final String QUERY13 = "delete from downloadmnginfo where tbName = ? and seq = ?";
private static final String QUERY14 = "update tablemnginfo set readnum = readnum + 1 where seq = ?";
private static final String QUERY15 = "insert into tablemng (tbName,tbCnt,skin,tbTitle,tbInfoStatus,attach_key,editmode,image_allow) values(?,0,'1','°Ô½ÃÆÇ','0','0','0','0')";
private static final String QUERY16 = "select fileName from downloadmnginfo where tbName = ? order by tbidx";
private static final String QUERY17 = "select imgInfo from tablemnginfo where tbName = ? ";
private static final String QUERY18 = "select tbName,tbCnt,tbInfoStatus from tablemng order by tbName";
private static final String QUERY19 = "SELECT count(*) FROM sysobjects where name = ?";
private static final String QUERY20 = "select skin,tbTitle,tbInfoStatus,attach_key,editmode,image_allow from tablemng where tbName=?";
private static final String QUERY21 = "update tablemng set tbTitle=?,skin=?,tbInfoStatus=?,attach_key=?,editmode=?,image_allow=? where tbName=?";
public SkinTable getSkinData(String tableName) throws Exception
{
SkinTable sTable = new SkinTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY1);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSkinData : " + QUERY1 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
sTable.setSkin(rs.getString("skin"));
sTable.setTbTitle(rs.getString("tbTitle"));
sTable.setAttach_key(rs.getString("attach_key"));
sTable.setEditmode(rs.getString("editmode"));
sTable.setImage_allow(rs.getString("image_allow"));
sTable.setTbCnt(rs.getInt("tbCnt"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSkinData : " + e.getMessage());
}
conn.close();
}
return sTable;
}
public int getListCount(String tableName) throws Exception
{
int recordCount = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY2);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListCount : " + QUERY2 );
rs = pstmt.executeQuery();
if(rs.next()) recordCount = rs.getInt("cnt");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return recordCount;
}
public List getListData(String tableName,int gotoPage,int pageSize) throws Exception
{
int start = pageSize*(gotoPage-1)+1;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
String query = "select min(seq) AS Expr1 from (select top "+start+" seq from tablemnginfo where tbName = ? order by seq desc) as DERIVEDTBL";
int pageTopNum = 0;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + query );
rs = pstmt.executeQuery();
if(rs.next()) pageTopNum = rs.getInt("Expr1");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + e.getMessage());
}
conn.close();
}
List listData = new ArrayList();
InfoTable iTable = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY3);
pstmt.setString(1,tableName);
pstmt.setInt(2,pageTopNum);
rs = pstmt.executeQuery();
while (rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public List getListData(String tableName,int gotoPage,int pageSize,int recordCount) throws Exception
{
int start = pageSize*gotoPage;
if (start > recordCount) pageSize -= (start-recordCount);
StringBuffer query = new StringBuffer();
query.append("select seq,readnum,writeday,viewSelect,title from (select top ");
query.append(pageSize+" seq,readnum,writeday,viewSelect,title from (select top ");
query.append(start+" seq,readnum,writeday,viewSelect,title from tablemnginfo");
query.append(" where tbName = ? order by seq desc) as DERIVEDTBL order by seq)as DERIVEDTBL order by seq desc");
List listData = new ArrayList();
InfoTable iTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + query.toString() );
rs = pstmt.executeQuery();
while(rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public int getSearchCount(String tableName,String search,String findword) throws Exception
{
int recordCount = 0;
String query = "select count(seq) recordCount from tablemnginfo where tbName = ? and " + search + " like ? ";
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchCount : " + query );
rs = pstmt.executeQuery();
if(rs.next()) recordCount = rs.getInt("recordCount");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSearchCount : " + e.getMessage());
}
conn.close();
}
return recordCount;
}
public List getSearchData(String tableName,String search,String findword,int gotoPage,int pageSize) throws Exception
{
int start = pageSize*(gotoPage-1)+1;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
String query = "select min(seq) AS Expr1 from (select top "+start+" seq from tablemnginfo where tbName = ? and "+ search +" like ? order by seq desc) as DERIVEDTBL";
int pageTopNum = 0;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchCount : " + query );
rs = pstmt.executeQuery();
if(rs.next()) pageTopNum = rs.getInt("Expr1");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
List listData = new ArrayList();
query = "Select top 15 seq,readnum,writeday,viewSelect,title from tablemnginfo where tbName = ? and seq <= ? and "+ search +" like ? order by seq desc";
InfoTable iTable = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setInt(2,pageTopNum);
pstmt.setString(3,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchData : " + query );
rs = pstmt.executeQuery();
while (rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return listData;
}
public List getSearchData(String tableName,String search,String findword,
int gotoPage,int pageSize,int recordCount) throws Exception
{
int start = pageSize*gotoPage;
if (start > recordCount) pageSize -= (start-recordCount);
StringBuffer query = new StringBuffer();
query.append("select seq,readnum,writeday,viewSelect,title from (select top ");
query.append(pageSize+" seq,readnum,writeday,viewSelect,title from (select top ");
query.append(start+" seq,readnum,writeday,viewSelect,title from tablemnginfo");
query.append(" where tbName = ? and "+ search +" like ? order by seq desc) as DERIVEDTBL");
query.append(" order by seq)as DERIVEDTBL order by seq desc");
List listData = new ArrayList();
InfoTable iTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchData : " + query );
rs = pstmt.executeQuery();
while(rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return listData;
}
public InfoTable getInfoData(int seq) throws Exception
{
InfoTable iTable = new InfoTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY4);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getInfoData : " + QUERY4 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
iTable.setTitle(rs.getString("title"));
iTable.setContent(rs.getString("content"));
iTable.setImgInfo(rs.getString("imgInfo"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setReadnum(rs.getInt("readnum"));
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getInfoData : " + e.getMessage());
}
conn.close();
}
return iTable;
}
public List getDownloadData(String tableName, String tbName, int seq) throws Exception
{
List downloadData = new ArrayList();
String query = "select tbidx,fileName,fileSize,downCnt from "+tableName+" where tbName = ? and seq=?";
DownloadTable dTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tbName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getDownloadData : " + query );
rs = pstmt.executeQuery();
while (rs.next()){
dTable = new DownloadTable();
dTable.setTbidx(rs.getInt("tbidx"));
dTable.setFileName(rs.getString("fileName"));
dTable.setFileSize(rs.getString("fileSize"));
dTable.setDownCnt(rs.getInt("downCnt"));
downloadData.add(dTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" OraPhotoDAOImpl::getDownloadData : " + e.getMessage());
}
conn.close();
}
return downloadData;
}
public void insertQuery(UploadTbMng up) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY5);
pstmt.setString(1,up.getTableName());
pstmt.setInt(2,up.getSeq());
pstmt.setString(3,up.getTitle());
pstmt.setString(4,up.getImgInfo());
pstmt.setString(5,up.getContent());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertQuery : " + QUERY5 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertQuery : " + e.getMessage());
}
conn.close();
}
}
public void update(UploadTbMng up) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY6);
pstmt.setString(1,up.getTitle());
pstmt.setString(2,up.getImgInfo());
pstmt.setString(3,up.getContent());
pstmt.setInt(4,up.getSeq());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::update : " + QUERY6 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::update : " + e.getMessage());
}
conn.close();
}
}
public void insertFile(String tableName,int seq,String filename,String filesize) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY7);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
pstmt.setString(3,filename);
pstmt.setString(4,filesize);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertFile : " + QUERY7 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertFile : " + e.getMessage());
}
conn.close();
}
}
public int maxSeq() throws Exception
{
int id = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY8);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::maxSeq : " + QUERY8 );
rs = pstmt.executeQuery();
if(rs.next()){
id = rs.getInt("seq")+1;
}else{
id = 1;
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::maxSeq : " + e.getMessage());
}
conn.close();
}
return id;
}
public void deleteFile(int tbidx) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY9);
pstmt.setInt(1,tbidx);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteFile : " + QUERY9 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteFile : " + e.getMessage());
}
conn.close();
}
}
public void alterViewStatus(String viewSelect, int seq) throws Exception
{
String alterValue = "0";
if (viewSelect.equals("0")) alterValue = "1";
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY10);
pstmt.setString(1,alterValue);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::alterViewStatus : " + QUERY10 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" OraPhotoDAOImpl::alterViewStatus : " + e.getMessage());
}
conn.close();
}
}
public void deleteAllFile(String tableName,int seq,String saveDir) throws Exception
{
String filename = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY11);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteAllFile : " + QUERY11 );
rs = pstmt.executeQuery();
while (rs.next()){
filename = rs.getString("filename");
if (filename.length() > 3) {
File delFile = new File(saveDir+filename);
if (delFile.exists()) delFile.delete();
}
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteAllFile : " + e.getMessage());
}
conn.close();
}
}
public void delete(int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY12);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::delete : " + QUERY12 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::delete : " + e.getMessage());
}
conn.close();
}
}
public void deleteDownload(String tableName, int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY13);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteDownload : " + QUERY13 );
pstmt.executeUpdate();
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteDownload : " + e.getMessage());
}
conn.close();
}
}
public void doHitPlus(int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY14);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::doHitPlus : " + QUERY14 );
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::doHitPlus : " + e.getMessage());
}
conn.close();
}
}
public void createTable(String tableName) throws Exception
{
StringBuffer query = new StringBuffer();
query.append("CREATE TABLE "+tableName+"(");
query.append("seq int NOT NULL ,");
query.append("re_level tinyint NOT NULL ,");
query.append("re_step int NOT NULL PRIMARY KEY,");
query.append("name varchar(20) NOT NULL ,");
query.append("title varchar(100) NOT NULL ,");
query.append("content text NOT NULL ,");
query.append("pwd varchar(10) NOT NULL ,");
query.append("email varchar(50) NULL ,");
query.append("homepage varchar(100) NULL ,");
query.append("readnum int NOT NULL ,");
query.append("tag char(1) NOT NULL ,");
query.append("writeday datetime NOT NULL DEFAULT (getdate()),");
query.append("ip varchar(24) NOT NULL ,");
query.append("imgInfo varchar(300) NULL ,");
query.append("relativeCnt int NOT NULL) ");
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::createTable : " + query.toString());
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::createTable : " + e.getMessage());
}
conn.close();
}
String qry = "CREATE INDEX [IX_"+tableName+"] ON "+tableName+"([seq]) ON [PRIMARY]";
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(qry);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::createTable : " + qry );
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::createTable : " + e.getMessage());
}
conn.close();
}
}
public void insertInfo(String tableName) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY15);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertInfo : " + QUERY15 );
pstmt.executeUpdate();
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertInfo : " + e.getMessage());
}
conn.close();
}
}
public void dropTable(String tableName) throws Exception
{
String query = "drop TABLE "+tableName;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::dropTable : " + query );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::dropTable : " + e.getMessage());
}
conn.close();
}
}
public void deleteTable(String tableName,String tbName) throws Exception
{
String query = "delete from "+tableName+" where tbName = ?";
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tbName);
GCmLog.writeLog(" deleteTable ::deleteTable : " + query );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" deleteTable::deleteTable : " + e.getMessage());
}
conn.close();
}
}
public void infoFileDelete(String delInfoDir,String tbName) throws Exception
{
File delFile = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY16);
pstmt.setString(1,tbName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::infoFileDelete : " + QUERY16 );
rs = pstmt.executeQuery();
while (rs.next()){
delFile = new File(delInfoDir + rs.getString("fileName").trim());
if (delFile.exists()) delFile.delete();
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::infoFileDelete : " + e.getMessage());
}
conn.close();
}
}
public void infoImgDelete(String delImgDir,String tbName) throws Exception
{
String imgInfo = "";
File delImg = null;
Vector vec = new Vector();
int vecLen = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY17);
pstmt.setString(1,tbName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::infoImgDelete : " + QUERY17 );
rs = pstmt.executeQuery();
while (rs.next()){
if (rs.getString("imgInfo") != null && !rs.getString("imgInfo").equals(""))
vec.addElement(rs.getString("imgInfo").trim());
}
vecLen = vec.size();
for (int rowcounter=0;rowcounter<vecLen;rowcounter++){
imgInfo = vec.elementAt(rowcounter).toString();
StringTokenizer st = new StringTokenizer(imgInfo,"/");
while (st.hasMoreTokens()) {
delImg = new File(delImgDir+st.nextElement());
if (delImg.exists()) delImg.delete();
}
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::infoImgDelete : " + e.getMessage());
}
conn.close();
}
}
public List getTableData() throws Exception
{
List listData = new ArrayList();
SkinTable sTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY18);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getTableData : " + QUERY18 );
rs = pstmt.executeQuery();
while (rs.next()){
sTable = new SkinTable();
sTable.setTbName(rs.getString("tbName"));
sTable.setTbCnt(rs.getInt("tbCnt"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
listData.add(sTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getTableData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public boolean checkTablePermission(String id) throws Exception
{
boolean cnt = false;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY19);
pstmt.setString(1,id);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::checkTablePermission : " + QUERY19 );
rs = pstmt.executeQuery();
if(rs.next()){
if(rs.getInt(1)>0) cnt = true;
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::checkTablePermission : " + e.getMessage());
}
conn.close();
}
return cnt;
}
public SkinTable getSkinDataInfo(String tableName) throws Exception
{
SkinTable sTable = new SkinTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY20);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSkinDataInfo : " + QUERY20 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
sTable.setSkin(rs.getString("skin"));
sTable.setTbTitle(rs.getString("tbTitle"));
sTable.setAttach_key(rs.getString("attach_key"));
sTable.setEditmode(rs.getString("editmode"));
sTable.setImage_allow(rs.getString("image_allow"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSkinDataInfo : " + e.getMessage());
}
conn.close();
}
return sTable;
}
public void doSkinUpdate(SkinTable sTable) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY21);
pstmt.setString(1,sTable.getTbTitle());
pstmt.setString(2,sTable.getSkin());
pstmt.setString(3,sTable.getTbInfoStatus());
pstmt.setString(4,sTable.getAttach_key());
pstmt.setString(5,sTable.getEditmode());
pstmt.setString(6,sTable.getImage_allow());
pstmt.setString(7,sTable.getTbName());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::doSkinUpdate : " + QUERY21 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::doSkinUpdate : " + e.getMessage());
}
conn.close();
}
}
}
| WINDOWS-1252 | Java | 38,488 | java | MsInfoBoardDAOImpl.java | Java | [] | null | [] |
package eknoware.component.board.manager.dao;
import java.io.File;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import eknoware.commlib.util.Utility;
import eknoware.commlib.util.ReplaceUtil;
import eknoware.component.board.manager.upload.UploadTbMng;
import eknoware.component.board.dao.*;
import java.util.*;
import eknoware.commlib.comm.*;
import eknoware.commlib.db.*;
import eknoware.commlib.exception.*;
import eknoware.commlib.lib.*;
import eknoware.commlib.log.*;
import eknoware.commlib.util.*;
import eknoware.commlib.log.GCmLog;
public class MsInfoBoardDAOImpl implements InfoBoardDAO
{
private static final String QUERY1 = "select skin,tbTitle,attach_key,editmode,image_allow,tbCnt,tbInfoStatus from tablemng where tbName=?";
private static final String QUERY2 = "select count(seq) cnt from tablemnginfo where tbName = ?";
private static final String QUERY3 = "Select top 15 seq,readnum,writeday,viewSelect,title from tablemnginfo where tbName = ? and seq <= ? order by seq desc";
private static final String QUERY4 = "select title,content,imgInfo,writeday,readnum from tablemnginfo where seq = ?";
private static final String QUERY5 = "insert into tablemnginfo (tbName,seq,title,readnum,writeday,imgInfo,viewSelect,content) values(?,?,?,0,getdate(),?,0,?)";
private static final String QUERY6 = "update tablemnginfo set title=?,imgInfo=?,content=? where seq = ? ";
private static final String QUERY7 = "insert into downloadmnginfo (tbName,seq,fileName,fileSize,downCnt) values(?,?,?,?,0)";
private static final String QUERY8 = "select max(seq) as seq from tablemnginfo";
private static final String QUERY9 = "delete from downloadmnginfo where tbidx = ?";
private static final String QUERY10 = "update tablemnginfo set viewSelect = ? where seq = ?";
private static final String QUERY11 = "select filename from downloadmnginfo where tbName = ? and seq =? order by tbidx";
private static final String QUERY12 = "delete from tablemnginfo where seq = ?";
private static final String QUERY13 = "delete from downloadmnginfo where tbName = ? and seq = ?";
private static final String QUERY14 = "update tablemnginfo set readnum = readnum + 1 where seq = ?";
private static final String QUERY15 = "insert into tablemng (tbName,tbCnt,skin,tbTitle,tbInfoStatus,attach_key,editmode,image_allow) values(?,0,'1','°Ô½ÃÆÇ','0','0','0','0')";
private static final String QUERY16 = "select fileName from downloadmnginfo where tbName = ? order by tbidx";
private static final String QUERY17 = "select imgInfo from tablemnginfo where tbName = ? ";
private static final String QUERY18 = "select tbName,tbCnt,tbInfoStatus from tablemng order by tbName";
private static final String QUERY19 = "SELECT count(*) FROM sysobjects where name = ?";
private static final String QUERY20 = "select skin,tbTitle,tbInfoStatus,attach_key,editmode,image_allow from tablemng where tbName=?";
private static final String QUERY21 = "update tablemng set tbTitle=?,skin=?,tbInfoStatus=?,attach_key=?,editmode=?,image_allow=? where tbName=?";
public SkinTable getSkinData(String tableName) throws Exception
{
SkinTable sTable = new SkinTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY1);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSkinData : " + QUERY1 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
sTable.setSkin(rs.getString("skin"));
sTable.setTbTitle(rs.getString("tbTitle"));
sTable.setAttach_key(rs.getString("attach_key"));
sTable.setEditmode(rs.getString("editmode"));
sTable.setImage_allow(rs.getString("image_allow"));
sTable.setTbCnt(rs.getInt("tbCnt"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSkinData : " + e.getMessage());
}
conn.close();
}
return sTable;
}
public int getListCount(String tableName) throws Exception
{
int recordCount = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY2);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListCount : " + QUERY2 );
rs = pstmt.executeQuery();
if(rs.next()) recordCount = rs.getInt("cnt");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return recordCount;
}
public List getListData(String tableName,int gotoPage,int pageSize) throws Exception
{
int start = pageSize*(gotoPage-1)+1;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
String query = "select min(seq) AS Expr1 from (select top "+start+" seq from tablemnginfo where tbName = ? order by seq desc) as DERIVEDTBL";
int pageTopNum = 0;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + query );
rs = pstmt.executeQuery();
if(rs.next()) pageTopNum = rs.getInt("Expr1");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + e.getMessage());
}
conn.close();
}
List listData = new ArrayList();
InfoTable iTable = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY3);
pstmt.setString(1,tableName);
pstmt.setInt(2,pageTopNum);
rs = pstmt.executeQuery();
while (rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public List getListData(String tableName,int gotoPage,int pageSize,int recordCount) throws Exception
{
int start = pageSize*gotoPage;
if (start > recordCount) pageSize -= (start-recordCount);
StringBuffer query = new StringBuffer();
query.append("select seq,readnum,writeday,viewSelect,title from (select top ");
query.append(pageSize+" seq,readnum,writeday,viewSelect,title from (select top ");
query.append(start+" seq,readnum,writeday,viewSelect,title from tablemnginfo");
query.append(" where tbName = ? order by seq desc) as DERIVEDTBL order by seq)as DERIVEDTBL order by seq desc");
List listData = new ArrayList();
InfoTable iTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getListData : " + query.toString() );
rs = pstmt.executeQuery();
while(rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public int getSearchCount(String tableName,String search,String findword) throws Exception
{
int recordCount = 0;
String query = "select count(seq) recordCount from tablemnginfo where tbName = ? and " + search + " like ? ";
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchCount : " + query );
rs = pstmt.executeQuery();
if(rs.next()) recordCount = rs.getInt("recordCount");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSearchCount : " + e.getMessage());
}
conn.close();
}
return recordCount;
}
public List getSearchData(String tableName,String search,String findword,int gotoPage,int pageSize) throws Exception
{
int start = pageSize*(gotoPage-1)+1;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
String query = "select min(seq) AS Expr1 from (select top "+start+" seq from tablemnginfo where tbName = ? and "+ search +" like ? order by seq desc) as DERIVEDTBL";
int pageTopNum = 0;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchCount : " + query );
rs = pstmt.executeQuery();
if(rs.next()) pageTopNum = rs.getInt("Expr1");
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
List listData = new ArrayList();
query = "Select top 15 seq,readnum,writeday,viewSelect,title from tablemnginfo where tbName = ? and seq <= ? and "+ search +" like ? order by seq desc";
InfoTable iTable = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tableName);
pstmt.setInt(2,pageTopNum);
pstmt.setString(3,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchData : " + query );
rs = pstmt.executeQuery();
while (rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return listData;
}
public List getSearchData(String tableName,String search,String findword,
int gotoPage,int pageSize,int recordCount) throws Exception
{
int start = pageSize*gotoPage;
if (start > recordCount) pageSize -= (start-recordCount);
StringBuffer query = new StringBuffer();
query.append("select seq,readnum,writeday,viewSelect,title from (select top ");
query.append(pageSize+" seq,readnum,writeday,viewSelect,title from (select top ");
query.append(start+" seq,readnum,writeday,viewSelect,title from tablemnginfo");
query.append(" where tbName = ? and "+ search +" like ? order by seq desc) as DERIVEDTBL");
query.append(" order by seq)as DERIVEDTBL order by seq desc");
List listData = new ArrayList();
InfoTable iTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
pstmt.setString(1,tableName);
pstmt.setString(2,"%"+findword+"%");
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSearchData : " + query );
rs = pstmt.executeQuery();
while(rs.next()){
iTable = new InfoTable();
iTable.setSeq(rs.getInt("seq"));
iTable.setReadnum(rs.getInt("readnum"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setViewSelect(rs.getString("viewSelect"));
iTable.setTitle(Utility.getTitleLimit(ReplaceUtil.encodeHTMLSpecialChar(rs.getString("title"),14),38));
listData.add(iTable);
}
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getListCount : " + e.getMessage());
}
conn.close();
}
return listData;
}
public InfoTable getInfoData(int seq) throws Exception
{
InfoTable iTable = new InfoTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY4);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getInfoData : " + QUERY4 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
iTable.setTitle(rs.getString("title"));
iTable.setContent(rs.getString("content"));
iTable.setImgInfo(rs.getString("imgInfo"));
iTable.setWriteday(rs.getTimestamp("writeday"));
iTable.setReadnum(rs.getInt("readnum"));
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getInfoData : " + e.getMessage());
}
conn.close();
}
return iTable;
}
public List getDownloadData(String tableName, String tbName, int seq) throws Exception
{
List downloadData = new ArrayList();
String query = "select tbidx,fileName,fileSize,downCnt from "+tableName+" where tbName = ? and seq=?";
DownloadTable dTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tbName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getDownloadData : " + query );
rs = pstmt.executeQuery();
while (rs.next()){
dTable = new DownloadTable();
dTable.setTbidx(rs.getInt("tbidx"));
dTable.setFileName(rs.getString("fileName"));
dTable.setFileSize(rs.getString("fileSize"));
dTable.setDownCnt(rs.getInt("downCnt"));
downloadData.add(dTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" OraPhotoDAOImpl::getDownloadData : " + e.getMessage());
}
conn.close();
}
return downloadData;
}
public void insertQuery(UploadTbMng up) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY5);
pstmt.setString(1,up.getTableName());
pstmt.setInt(2,up.getSeq());
pstmt.setString(3,up.getTitle());
pstmt.setString(4,up.getImgInfo());
pstmt.setString(5,up.getContent());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertQuery : " + QUERY5 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertQuery : " + e.getMessage());
}
conn.close();
}
}
public void update(UploadTbMng up) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY6);
pstmt.setString(1,up.getTitle());
pstmt.setString(2,up.getImgInfo());
pstmt.setString(3,up.getContent());
pstmt.setInt(4,up.getSeq());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::update : " + QUERY6 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::update : " + e.getMessage());
}
conn.close();
}
}
public void insertFile(String tableName,int seq,String filename,String filesize) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY7);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
pstmt.setString(3,filename);
pstmt.setString(4,filesize);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertFile : " + QUERY7 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertFile : " + e.getMessage());
}
conn.close();
}
}
public int maxSeq() throws Exception
{
int id = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY8);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::maxSeq : " + QUERY8 );
rs = pstmt.executeQuery();
if(rs.next()){
id = rs.getInt("seq")+1;
}else{
id = 1;
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::maxSeq : " + e.getMessage());
}
conn.close();
}
return id;
}
public void deleteFile(int tbidx) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY9);
pstmt.setInt(1,tbidx);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteFile : " + QUERY9 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteFile : " + e.getMessage());
}
conn.close();
}
}
public void alterViewStatus(String viewSelect, int seq) throws Exception
{
String alterValue = "0";
if (viewSelect.equals("0")) alterValue = "1";
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY10);
pstmt.setString(1,alterValue);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::alterViewStatus : " + QUERY10 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" OraPhotoDAOImpl::alterViewStatus : " + e.getMessage());
}
conn.close();
}
}
public void deleteAllFile(String tableName,int seq,String saveDir) throws Exception
{
String filename = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY11);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteAllFile : " + QUERY11 );
rs = pstmt.executeQuery();
while (rs.next()){
filename = rs.getString("filename");
if (filename.length() > 3) {
File delFile = new File(saveDir+filename);
if (delFile.exists()) delFile.delete();
}
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteAllFile : " + e.getMessage());
}
conn.close();
}
}
public void delete(int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY12);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::delete : " + QUERY12 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::delete : " + e.getMessage());
}
conn.close();
}
}
public void deleteDownload(String tableName, int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY13);
pstmt.setString(1,tableName);
pstmt.setInt(2,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::deleteDownload : " + QUERY13 );
pstmt.executeUpdate();
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::deleteDownload : " + e.getMessage());
}
conn.close();
}
}
public void doHitPlus(int seq) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY14);
pstmt.setInt(1,seq);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::doHitPlus : " + QUERY14 );
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::doHitPlus : " + e.getMessage());
}
conn.close();
}
}
public void createTable(String tableName) throws Exception
{
StringBuffer query = new StringBuffer();
query.append("CREATE TABLE "+tableName+"(");
query.append("seq int NOT NULL ,");
query.append("re_level tinyint NOT NULL ,");
query.append("re_step int NOT NULL PRIMARY KEY,");
query.append("name varchar(20) NOT NULL ,");
query.append("title varchar(100) NOT NULL ,");
query.append("content text NOT NULL ,");
query.append("pwd varchar(10) NOT NULL ,");
query.append("email varchar(50) NULL ,");
query.append("homepage varchar(100) NULL ,");
query.append("readnum int NOT NULL ,");
query.append("tag char(1) NOT NULL ,");
query.append("writeday datetime NOT NULL DEFAULT (getdate()),");
query.append("ip varchar(24) NOT NULL ,");
query.append("imgInfo varchar(300) NULL ,");
query.append("relativeCnt int NOT NULL) ");
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query.toString());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::createTable : " + query.toString());
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::createTable : " + e.getMessage());
}
conn.close();
}
String qry = "CREATE INDEX [IX_"+tableName+"] ON "+tableName+"([seq]) ON [PRIMARY]";
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(qry);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::createTable : " + qry );
pstmt.executeUpdate();
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::createTable : " + e.getMessage());
}
conn.close();
}
}
public void insertInfo(String tableName) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY15);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::insertInfo : " + QUERY15 );
pstmt.executeUpdate();
} finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::insertInfo : " + e.getMessage());
}
conn.close();
}
}
public void dropTable(String tableName) throws Exception
{
String query = "drop TABLE "+tableName;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::dropTable : " + query );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::dropTable : " + e.getMessage());
}
conn.close();
}
}
public void deleteTable(String tableName,String tbName) throws Exception
{
String query = "delete from "+tableName+" where tbName = ?";
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(query);
pstmt.setString(1,tbName);
GCmLog.writeLog(" deleteTable ::deleteTable : " + query );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" deleteTable::deleteTable : " + e.getMessage());
}
conn.close();
}
}
public void infoFileDelete(String delInfoDir,String tbName) throws Exception
{
File delFile = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY16);
pstmt.setString(1,tbName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::infoFileDelete : " + QUERY16 );
rs = pstmt.executeQuery();
while (rs.next()){
delFile = new File(delInfoDir + rs.getString("fileName").trim());
if (delFile.exists()) delFile.delete();
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::infoFileDelete : " + e.getMessage());
}
conn.close();
}
}
public void infoImgDelete(String delImgDir,String tbName) throws Exception
{
String imgInfo = "";
File delImg = null;
Vector vec = new Vector();
int vecLen = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY17);
pstmt.setString(1,tbName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::infoImgDelete : " + QUERY17 );
rs = pstmt.executeQuery();
while (rs.next()){
if (rs.getString("imgInfo") != null && !rs.getString("imgInfo").equals(""))
vec.addElement(rs.getString("imgInfo").trim());
}
vecLen = vec.size();
for (int rowcounter=0;rowcounter<vecLen;rowcounter++){
imgInfo = vec.elementAt(rowcounter).toString();
StringTokenizer st = new StringTokenizer(imgInfo,"/");
while (st.hasMoreTokens()) {
delImg = new File(delImgDir+st.nextElement());
if (delImg.exists()) delImg.delete();
}
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::infoImgDelete : " + e.getMessage());
}
conn.close();
}
}
public List getTableData() throws Exception
{
List listData = new ArrayList();
SkinTable sTable = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY18);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getTableData : " + QUERY18 );
rs = pstmt.executeQuery();
while (rs.next()){
sTable = new SkinTable();
sTable.setTbName(rs.getString("tbName"));
sTable.setTbCnt(rs.getInt("tbCnt"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
listData.add(sTable);
}
} finally {
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getTableData : " + e.getMessage());
}
conn.close();
}
return listData;
}
public boolean checkTablePermission(String id) throws Exception
{
boolean cnt = false;
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY19);
pstmt.setString(1,id);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::checkTablePermission : " + QUERY19 );
rs = pstmt.executeQuery();
if(rs.next()){
if(rs.getInt(1)>0) cnt = true;
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::checkTablePermission : " + e.getMessage());
}
conn.close();
}
return cnt;
}
public SkinTable getSkinDataInfo(String tableName) throws Exception
{
SkinTable sTable = new SkinTable();
ResultSet rs = null;
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY20);
pstmt.setString(1,tableName);
GCmLog.writeLog(" MsInfoBoardDAOImpl ::getSkinDataInfo : " + QUERY20 );
rs = pstmt.executeQuery();
if (rs !=null && rs.next()) {
sTable.setSkin(rs.getString("skin"));
sTable.setTbTitle(rs.getString("tbTitle"));
sTable.setAttach_key(rs.getString("attach_key"));
sTable.setEditmode(rs.getString("editmode"));
sTable.setImage_allow(rs.getString("image_allow"));
sTable.setTbInfoStatus(rs.getString("tbInfoStatus"));
}
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::getSkinDataInfo : " + e.getMessage());
}
conn.close();
}
return sTable;
}
public void doSkinUpdate(SkinTable sTable) throws Exception
{
PreparedStatement pstmt = null;
GCmConnection conn = null;
try{
conn = GCmDbManager.getInstance().getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(QUERY21);
pstmt.setString(1,sTable.getTbTitle());
pstmt.setString(2,sTable.getSkin());
pstmt.setString(3,sTable.getTbInfoStatus());
pstmt.setString(4,sTable.getAttach_key());
pstmt.setString(5,sTable.getEditmode());
pstmt.setString(6,sTable.getImage_allow());
pstmt.setString(7,sTable.getTbName());
GCmLog.writeLog(" MsInfoBoardDAOImpl ::doSkinUpdate : " + QUERY21 );
pstmt.executeUpdate();
}finally{
try {
pstmt.close();
conn.commit();
}
catch (SQLException e) {
GCmLog.writeLog(" MsInfoBoardDAOImpl::doSkinUpdate : " + e.getMessage());
}
conn.close();
}
}
}
| 38,488 | 0.555143 | 0.549348 | 1,061 | 34.267673 | 27.766258 | 179 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.466541 | false | false | 13 |
59beaa6d7a96b5e40ecb304562a51d9aa7d3b40d | 7,370,163,890,706 | 2a53f7d268ad2feb33ea7984a952eabcc3548277 | /biz/src/main/java/cn/tcr/biz/student/UserExtController.java | d9ff918c4f3a1a463318f08d8f931e6c5f169218 | [] | no_license | Tu0609/education2.0 | https://github.com/Tu0609/education2.0 | 05d71647a838a5e3dd2adea397531db3eb65ea12 | a00fe76900da15fbc8156c50fde2e9f29f419e21 | refs/heads/master | 2022-12-03T17:23:42.189000 | 2020-08-05T01:55:42 | 2020-08-05T01:55:42 | 285,151,291 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.tcr.biz.student;
import cn.tcr.biz.sys.util.FinalClass;
import cn.tcr.util.ResultUtil;
import cn.tcr.util.vo.student.QueryStudent;
import cn.tcr.util.vo.student.UserExtCommon;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.xml.transform.Result;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
/**
* @author TuTu
* @date 2020/6/20 15:54
*/
@RestController
@Slf4j
public class UserExtController {
private static final String STUDENT_URL = "http://education-student";
@Autowired
private RestTemplate restTemplate;
@PostMapping("/user/pc/user/ext/list")
public ResultUtil getStudentInfoPage(@RequestBody QueryStudent queryStudent) {
UserExtCommon[] forObject = restTemplate.postForObject(STUDENT_URL + "/users/pc/user/ext/list", queryStudent ,UserExtCommon[].class);
List<UserExtCommon> list = Arrays.asList(forObject);
return ResultUtil.success(list);
}
@PutMapping("/user/pc/platform/update")
public ResultUtil updateStudent(@RequestBody UserExtCommon userExt) {
restTemplate.put(STUDENT_URL + "/users/pc/platform/update", userExt);
return ResultUtil.success("删除成功!");
}
}
| UTF-8 | Java | 1,453 | java | UserExtController.java | Java | [
{
"context": "til.Arrays;\nimport java.util.List;\n\n/**\n * @author TuTu\n * @date 2020/6/20 15:54\n */\n@RestController\n@Slf",
"end": 600,
"score": 0.989502489566803,
"start": 596,
"tag": "NAME",
"value": "TuTu"
}
] | null | [] | package cn.tcr.biz.student;
import cn.tcr.biz.sys.util.FinalClass;
import cn.tcr.util.ResultUtil;
import cn.tcr.util.vo.student.QueryStudent;
import cn.tcr.util.vo.student.UserExtCommon;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.xml.transform.Result;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
/**
* @author TuTu
* @date 2020/6/20 15:54
*/
@RestController
@Slf4j
public class UserExtController {
private static final String STUDENT_URL = "http://education-student";
@Autowired
private RestTemplate restTemplate;
@PostMapping("/user/pc/user/ext/list")
public ResultUtil getStudentInfoPage(@RequestBody QueryStudent queryStudent) {
UserExtCommon[] forObject = restTemplate.postForObject(STUDENT_URL + "/users/pc/user/ext/list", queryStudent ,UserExtCommon[].class);
List<UserExtCommon> list = Arrays.asList(forObject);
return ResultUtil.success(list);
}
@PutMapping("/user/pc/platform/update")
public ResultUtil updateStudent(@RequestBody UserExtCommon userExt) {
restTemplate.put(STUDENT_URL + "/users/pc/platform/update", userExt);
return ResultUtil.success("删除成功!");
}
}
| 1,453 | 0.752599 | 0.742897 | 44 | 31.795454 | 28.770708 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.568182 | false | false | 13 |
f5630b36253d6ceaedd54e390688a486557d3c9f | 8,065,948,590,503 | 4c70fbb1647940df6afc8d136b0fe7a101510a18 | /src/main/java/vn/edu/fpt/service/generic/ActiveEntityService.java | d47a8e96c7660a43f823e1eafe6f85af41ad8c78 | [] | no_license | taivtse/fpoly-semester5-java5 | https://github.com/taivtse/fpoly-semester5-java5 | 4515263da50b1216791bd37a484df97d01b01197 | a9918e9859abb8cf1209761c0f86484d9073be8b | refs/heads/master | 2022-06-08T20:38:58.616000 | 2019-05-07T09:41:26 | 2019-05-07T09:41:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package vn.edu.fpt.service.generic;
import vn.edu.fpt.dto.DtoMarker;
import java.io.Serializable;
import java.util.List;
public interface ActiveEntityService<ID extends Serializable, T extends DtoMarker<ID>> extends GenericService<ID, T> {
List<T> findAllActive();
void updateToUnActive(T dto) throws Exception;
void updateToUnActiveById(ID id) throws Exception;
T saveWithActiveStatus(T dto) throws Exception;
T updateWithActiveStatus(T dto) throws Exception;
}
| UTF-8 | Java | 490 | java | ActiveEntityService.java | Java | [] | null | [] | package vn.edu.fpt.service.generic;
import vn.edu.fpt.dto.DtoMarker;
import java.io.Serializable;
import java.util.List;
public interface ActiveEntityService<ID extends Serializable, T extends DtoMarker<ID>> extends GenericService<ID, T> {
List<T> findAllActive();
void updateToUnActive(T dto) throws Exception;
void updateToUnActiveById(ID id) throws Exception;
T saveWithActiveStatus(T dto) throws Exception;
T updateWithActiveStatus(T dto) throws Exception;
}
| 490 | 0.769388 | 0.769388 | 18 | 26.222221 | 30.436739 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.611111 | false | false | 13 |
a89ee2e0770bde46ef922781980f930988b93ca1 | 28,664,611,762,010 | 1fe582d477796d7719e7d59d135cb970b2dbee63 | /dynamo-modules/dynamo-util/src/main/java/net/breezeware/dynamo/util/form/Form.java | e7deb3c78d3a0d914382ee2695a03945be69d2c8 | [] | no_license | deepak-palanichamy/dynamo-framework | https://github.com/deepak-palanichamy/dynamo-framework | f96588166d3476d591d388104ef0cb642b22454f | 43435319a60fcc5c6a0af0b71fa58a37c465a009 | refs/heads/master | 2023-07-18T12:38:51.089000 | 2021-07-16T11:00:18 | 2021-07-16T11:00:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.breezeware.dynamo.util.form;
import java.io.Serializable;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
/**
* Represents a single Form.
* @author Karthik Muthukumaraswamy
*/
public class Form implements Serializable {
private static final long serialVersionUID = 1L;
@Expose
private List<FormField> formFields;
public List<FormField> getFormFields() {
return formFields;
}
public void setFormFields(List<FormField> formFields) {
this.formFields = formFields;
}
public String toString() {
return new Gson().toJson(this);
}
} | UTF-8 | Java | 654 | java | Form.java | Java | [
{
"context": "pose;\n\n/**\n * Represents a single Form.\n * @author Karthik Muthukumaraswamy\n */\npublic class Form implements Serializable {\n ",
"end": 236,
"score": 0.9998882412910461,
"start": 212,
"tag": "NAME",
"value": "Karthik Muthukumaraswamy"
}
] | null | [] | package net.breezeware.dynamo.util.form;
import java.io.Serializable;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
/**
* Represents a single Form.
* @author <NAME>
*/
public class Form implements Serializable {
private static final long serialVersionUID = 1L;
@Expose
private List<FormField> formFields;
public List<FormField> getFormFields() {
return formFields;
}
public void setFormFields(List<FormField> formFields) {
this.formFields = formFields;
}
public String toString() {
return new Gson().toJson(this);
}
} | 636 | 0.701835 | 0.700306 | 30 | 20.833334 | 18.776018 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
d36b80ccc5fcaed98a9dcaec4fa4765a7bd781f2 | 28,664,611,762,793 | 974d36aff8c688b64c325f6dcb621e72d50eec2a | /ch03/011/MyMain.java | 0ff2dbc4fdcc9b67d82f6898bd9db120eb101978 | [] | no_license | 9501sam/Java_Home_Work_NTCU | https://github.com/9501sam/Java_Home_Work_NTCU | 16e6384170ded8a855e3a8c382a87807b27e18d6 | 0a4f52dbf5b19c57765d046d9a3eff1155c2b638 | refs/heads/master | 2023-02-18T00:48:58.365000 | 2021-01-18T11:45:39 | 2021-01-18T11:45:39 | 308,005,848 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class MyMain{
public static void main(String arga[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int g = 0;
int h = 0;
int i = 0;
boolean end = false;
for(g = 0; g <= 9; g++){
for(h = 0; h <= 9; h++){
for(i = 0; i <= 9; i++){
if(a*100 + b*10 + c*11 + g*100 + h == e*1100 + i*10 + d){
end = true;
}
if(end){
break;
}
}
if(end){
break;
}
}
if(end){
break;
}
}
if(i == 10){
System.out.print(-1);
}else{
System.out.println(g);
System.out.println(h);
System.out.print(i);
}
}
}
| UTF-8 | Java | 729 | java | MyMain.java | Java | [] | null | [] | import java.util.Scanner;
public class MyMain{
public static void main(String arga[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int g = 0;
int h = 0;
int i = 0;
boolean end = false;
for(g = 0; g <= 9; g++){
for(h = 0; h <= 9; h++){
for(i = 0; i <= 9; i++){
if(a*100 + b*10 + c*11 + g*100 + h == e*1100 + i*10 + d){
end = true;
}
if(end){
break;
}
}
if(end){
break;
}
}
if(end){
break;
}
}
if(i == 10){
System.out.print(-1);
}else{
System.out.println(g);
System.out.println(h);
System.out.print(i);
}
}
}
| 729 | 0.48011 | 0.441701 | 44 | 15.568182 | 12.507085 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.181818 | false | false | 13 |
0ba32b526b4d26fc59ca897f350242a5c92bf6de | 26,792,005,995,471 | f4eca0f31825da7eba8a6dfe91eae90406beff83 | /src/at/ac/foop/pacman/domain/PacmanColor.java | b030e61123f240afb96811924cc27e1cca692726 | [] | no_license | metaloph1l/pacman | https://github.com/metaloph1l/pacman | 5ef5674fc63758811708135add32b286a301c1fc | 7686b506d9306171040a5e59b164dff62931d348 | refs/heads/master | 2016-09-05T15:22:59.888000 | 2012-07-05T12:14:12 | 2012-07-05T12:14:12 | 3,786,253 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package at.ac.foop.pacman.domain;
public enum PacmanColor {
RED,
BLUE,
GREEN
} | UTF-8 | Java | 82 | java | PacmanColor.java | Java | [] | null | [] | package at.ac.foop.pacman.domain;
public enum PacmanColor {
RED,
BLUE,
GREEN
} | 82 | 0.731707 | 0.731707 | 7 | 10.857142 | 11.873483 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false | 13 |
29b6bd9ea078d914699eda14323daf607a7c9f80 | 15,573,551,424,955 | 579cc435dcd060c2396de274ca39e183674294c6 | /Hospital/Main.java | 1fb385c270e9a06fdd8e10080b084539334db289 | [] | no_license | galkovsky/DuzenkoDmitriy | https://github.com/galkovsky/DuzenkoDmitriy | 36113985e74e52d3d052686a62055aed5a0abe0a | 599c3c97e0089f1780a5738320a51849e88ef36e | refs/heads/master | 2021-01-18T14:31:28.904000 | 2015-03-16T23:55:23 | 2015-03-16T23:55:23 | 31,773,177 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
/**
* Created by Дмитрий on 11.03.2015.7
*/
public class Main {
public static void main (String [] args){
Hospital hospital = new Hospital();
boolean endCycle = false;
while (!endCycle) {
System.out.println(" Press 1 – to add doctor");
System.out.println(" Press 2 – to add patient");
System.out.println(" Press 3 – yo heal patient");
System.out.println(" Press 0 – End cycle");
Scanner scanner = new Scanner (System.in);
int userChoice = scanner.nextInt();
switch (userChoice) {
case 1:
Doctor doctor = new Doctor(40, new String[]{"Болит горло", "Болят глаза"}, 15);
hospital.receiveDoctor(doctor);
break;
case 2:
Patient patient1 = new Patient(60, 30, false, "Болит горло", " Patient1 ");
Patient patient2 = new Patient(50, 25, false, "Болят глаза", " Patient2 ");
hospital.receivePatient(patient1);
hospital.receivePatient(patient2);
break;
case 3:
hospital.heal();
hospital.releasePatient();
break;
case 0:
endCycle = true;
System.out.println("Хуууух, закончилось...");
}
}
}
}
| UTF-8 | Java | 1,615 | java | Main.java | Java | [
{
"context": "import java.util.Scanner;\r\n\r\n/**\r\n * Created by Дмитрий on 11.03.2015.7\r\n */\r\npublic class Main {\r\n pu",
"end": 55,
"score": 0.9998792409896851,
"start": 48,
"tag": "NAME",
"value": "Дмитрий"
},
{
"context": " Doctor doctor = new Doctor(40, new String[]{\"Болит горло\", \"Болят глаза\"}, 15);\r\n hospi",
"end": 755,
"score": 0.9998295307159424,
"start": 744,
"tag": "NAME",
"value": "Болит горло"
},
{
"context": "tor = new Doctor(40, new String[]{\"Болит горло\", \"Болят глаза\"}, 15);\r\n hospital.receiveDoct",
"end": 770,
"score": 0.9998077154159546,
"start": 759,
"tag": "NAME",
"value": "Болят глаза"
},
{
"context": " Patient patient1 = new Patient(60, 30, false, \"Болит горло\", \" Patient1 \");\r\n Patient pat",
"end": 970,
"score": 0.9998301863670349,
"start": 959,
"tag": "NAME",
"value": "Болит горло"
},
{
"context": " Patient patient2 = new Patient(50, 25, false, \"Болят глаза\", \" Patient2 \");\r\n\r\n hospital.",
"end": 1067,
"score": 0.9998302459716797,
"start": 1056,
"tag": "NAME",
"value": "Болят глаза"
}
] | null | [] | import java.util.Scanner;
/**
* Created by Дмитрий on 11.03.2015.7
*/
public class Main {
public static void main (String [] args){
Hospital hospital = new Hospital();
boolean endCycle = false;
while (!endCycle) {
System.out.println(" Press 1 – to add doctor");
System.out.println(" Press 2 – to add patient");
System.out.println(" Press 3 – yo heal patient");
System.out.println(" Press 0 – End cycle");
Scanner scanner = new Scanner (System.in);
int userChoice = scanner.nextInt();
switch (userChoice) {
case 1:
Doctor doctor = new Doctor(40, new String[]{"<NAME>", "<NAME>"}, 15);
hospital.receiveDoctor(doctor);
break;
case 2:
Patient patient1 = new Patient(60, 30, false, "<NAME>", " Patient1 ");
Patient patient2 = new Patient(50, 25, false, "<NAME>", " Patient2 ");
hospital.receivePatient(patient1);
hospital.receivePatient(patient2);
break;
case 3:
hospital.heal();
hospital.releasePatient();
break;
case 0:
endCycle = true;
System.out.println("Хуууух, закончилось...");
}
}
}
}
| 1,555 | 0.465975 | 0.443292 | 55 | 26.054546 | 27.104792 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.618182 | false | false | 13 |
ae85a648ff7a5c514532e880b19e0c9a949a4f6b | 28,681,791,622,476 | 5415e5eb2b00ec183c95d25226d793dc89bc5775 | /src/EKPL2/HomeWork/February23_FactoryDesign/AbstractClass/PackagingDesign.java | 0120c69179db34e1e47aef0cdab7f3b846217bf2 | [] | no_license | DimasSheldon/Java | https://github.com/DimasSheldon/Java | 80c7a16d369943bc4c033ee1209beae56c3c8626 | 9d357c551e0679f22b70b8d01737ce5f17f54118 | refs/heads/master | 2020-03-17T05:07:22.509000 | 2018-05-14T05:37:32 | 2018-05-14T05:37:32 | 133,303,112 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package EKPL2.HomeWork.February23_FactoryDesign.AbstractClass;
/**
* Created by Sheldon on 2/22/2017.
* An abstraction class of packaging design.
* Design of a packaging can be come from different shape type (e.g. cylinder, cube, or cuboid),
* all of shape has size and thickness property, but with its specific composition.
*/
public abstract class PackagingDesign {
protected String size;
protected int thickness;
/**
* A method to genereate size composition of package object in centimeters.
* @return the size composition
*/
public abstract String getSize();
/**
* A method to generate packaging design information
* @return the packaging design information
*/
public String info() {
return "Package type\t\t: " + getClass().getSimpleName() +
"\nPackage size\t\t: " + getSize() +
"\nPackage thickness\t: " + Integer.toString(thickness) + "mm";
}
} | UTF-8 | Java | 920 | java | PackagingDesign.java | Java | [
{
"context": "23_FactoryDesign.AbstractClass;\n\n/**\n * Created by Sheldon on 2/22/2017.\n * An abstraction class of packagin",
"end": 89,
"score": 0.9996399879455566,
"start": 82,
"tag": "NAME",
"value": "Sheldon"
}
] | null | [] | package EKPL2.HomeWork.February23_FactoryDesign.AbstractClass;
/**
* Created by Sheldon on 2/22/2017.
* An abstraction class of packaging design.
* Design of a packaging can be come from different shape type (e.g. cylinder, cube, or cuboid),
* all of shape has size and thickness property, but with its specific composition.
*/
public abstract class PackagingDesign {
protected String size;
protected int thickness;
/**
* A method to genereate size composition of package object in centimeters.
* @return the size composition
*/
public abstract String getSize();
/**
* A method to generate packaging design information
* @return the packaging design information
*/
public String info() {
return "Package type\t\t: " + getClass().getSimpleName() +
"\nPackage size\t\t: " + getSize() +
"\nPackage thickness\t: " + Integer.toString(thickness) + "mm";
}
} | 920 | 0.693478 | 0.682609 | 29 | 30.758621 | 28.832041 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.310345 | false | false | 13 |
64fdaf9da1eba7297d75799ca479a60ff2960fa6 | 28,681,791,621,107 | a93ae3acb79341c0f78a7f7af38f64908d23928c | /src/main/java/com/scm/dashboard/persistence/domain/TJob.java | 4b7cbcee1b78711fdb4949a0b9cbec327ab6710a | [] | no_license | j29yang/Scheduler | https://github.com/j29yang/Scheduler | cae6e3e307f051a2e1d2d59bdbea434f34276157 | d474204f367f97d4d11ef52e623f556cdffe5893 | refs/heads/master | 2021-01-21T03:55:58.761000 | 2017-08-31T14:30:01 | 2017-08-31T14:30:01 | 101,902,968 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.scm.dashboard.persistence.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* table job.
*
* @author l58wang
*/
@Entity
@Table(name = "t_job")
public class TJob implements Serializable {
private static final long serialVersionUID = 1972354302305632445L;
public TJob() {
super();
}
public TJob(String jobName, String path, Long projectId, String projectName, TServer server) {
super();
this.jobName = jobName;
this.path = path;
this.projectId = projectId;
this.projectName = projectName;
this.server = server;
this.threshold = 24;
this.watch = true;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "job_name")
private String jobName;
@Column(name = "path")
private String path;
@Column(name = "project_id")
private Long projectId;
@Column(name = "project_name")
private String projectName;
@Column(name = "watch")
private boolean watch;
@Column(name = "parse_issue")
private boolean parseIssue;
@Column(name = "auto_close")
private boolean autoClose;
@Column(name = "version_count_once")
private boolean versionCountOnce;
@Column(name = "threshold")
private int threshold;
@Column(name = "is_attach", nullable = false)
private Integer isAttach;
@ManyToOne()//fetch=FetchType.LAZY
@JoinColumn(referencedColumnName = "id",name = "server_id")
private TServer server;
@Column(name = "deleted", nullable = false)
private int deleted;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
public Long getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public boolean isWatch() {
return watch;
}
public void setWatch(boolean watch) {
this.watch = watch;
}
public boolean isParseIssue() {
return parseIssue;
}
public void setParseIssue(boolean parseIssue) {
this.parseIssue = parseIssue;
}
public boolean isVersionCountOnce() {
return versionCountOnce;
}
public void setVersionCountOnce(boolean versionCountOnce) {
this.versionCountOnce = versionCountOnce;
}
public int getThreshold() {
return threshold;
}
public void setThreshold(int threshold) {
this.threshold = threshold;
}
public Integer getIsAttach() {
return isAttach;
}
public void setIsAttach(Integer isAttach) {
this.isAttach = isAttach;
}
public TServer getServer() {
return server;
}
public void setServer(TServer server) {
this.server = server;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public int getDeleted() {
return deleted;
}
public void setDeleted(int deleted) {
this.deleted = deleted;
}
public boolean isAutoClose() {
return autoClose;
}
public void setAutoClose(boolean autoClose) {
this.autoClose = autoClose;
}
@Override
public String toString() {
return "TJob [id=" + id + ", jobName=" + jobName + ", branch="
+ ", server=" + ", watch=" + watch + ", threshold="
+ threshold + "]";
}
}
| UTF-8 | Java | 3,597 | java | TJob.java | Java | [
{
"context": "rsistence.Table;\n\n/**\n * table job.\n * \n * @author l58wang\n */\n@Entity\n@Table(name = \"t_job\")\npublic class T",
"end": 400,
"score": 0.999297022819519,
"start": 393,
"tag": "USERNAME",
"value": "l58wang"
}
] | null | [] | package com.scm.dashboard.persistence.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* table job.
*
* @author l58wang
*/
@Entity
@Table(name = "t_job")
public class TJob implements Serializable {
private static final long serialVersionUID = 1972354302305632445L;
public TJob() {
super();
}
public TJob(String jobName, String path, Long projectId, String projectName, TServer server) {
super();
this.jobName = jobName;
this.path = path;
this.projectId = projectId;
this.projectName = projectName;
this.server = server;
this.threshold = 24;
this.watch = true;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "job_name")
private String jobName;
@Column(name = "path")
private String path;
@Column(name = "project_id")
private Long projectId;
@Column(name = "project_name")
private String projectName;
@Column(name = "watch")
private boolean watch;
@Column(name = "parse_issue")
private boolean parseIssue;
@Column(name = "auto_close")
private boolean autoClose;
@Column(name = "version_count_once")
private boolean versionCountOnce;
@Column(name = "threshold")
private int threshold;
@Column(name = "is_attach", nullable = false)
private Integer isAttach;
@ManyToOne()//fetch=FetchType.LAZY
@JoinColumn(referencedColumnName = "id",name = "server_id")
private TServer server;
@Column(name = "deleted", nullable = false)
private int deleted;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
public Long getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public boolean isWatch() {
return watch;
}
public void setWatch(boolean watch) {
this.watch = watch;
}
public boolean isParseIssue() {
return parseIssue;
}
public void setParseIssue(boolean parseIssue) {
this.parseIssue = parseIssue;
}
public boolean isVersionCountOnce() {
return versionCountOnce;
}
public void setVersionCountOnce(boolean versionCountOnce) {
this.versionCountOnce = versionCountOnce;
}
public int getThreshold() {
return threshold;
}
public void setThreshold(int threshold) {
this.threshold = threshold;
}
public Integer getIsAttach() {
return isAttach;
}
public void setIsAttach(Integer isAttach) {
this.isAttach = isAttach;
}
public TServer getServer() {
return server;
}
public void setServer(TServer server) {
this.server = server;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public int getDeleted() {
return deleted;
}
public void setDeleted(int deleted) {
this.deleted = deleted;
}
public boolean isAutoClose() {
return autoClose;
}
public void setAutoClose(boolean autoClose) {
this.autoClose = autoClose;
}
@Override
public String toString() {
return "TJob [id=" + id + ", jobName=" + jobName + ", branch="
+ ", server=" + ", watch=" + watch + ", threshold="
+ threshold + "]";
}
}
| 3,597 | 0.707256 | 0.700862 | 191 | 17.83246 | 17.461197 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.298429 | false | false | 13 |
38acb148fd2b1fc54d35993598b092f8a761efd3 | 3,015,067,091,853 | 29bb2aea545be0c75d49d7d058a62bfdde9933b4 | /src/com/mypractice/lecture_20/linkedlist/ClientLinkedList.java | e031dbe36ecc74ab9ed900c0b57d2c18cbe8d945 | [] | no_license | AshishRalh/DataStructureInJava | https://github.com/AshishRalh/DataStructureInJava | bfe57b47891810bd19ee5bd6d4cc05a2676a5f70 | 4425a625e892aac8b82d4b8fe1c39052f3f4e218 | refs/heads/master | 2023-04-04T02:23:48.220000 | 2021-04-13T19:46:02 | 2021-04-13T19:46:02 | 349,233,224 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mypractice.lecture_20.linkedlist;
public class ClientLinkedList {
public static void main(String[] args) {
LinkedList list=new LinkedList();
list.insertFirst("mohit");
list.display();
list.insertLast("mohini");
list.insertLast("amit");
list.insertLast("neha");
list.display();
list.insert("richa",2);
list.insert("richa",5);
list.display();
list.removeFirst();
list.display();
System.out.println(list.mid());
list.remove(2);
System.out.println(list.findIndex("neha"));
System.out.println(list.mid());
list.display();
}
}
| UTF-8 | Java | 703 | java | ClientLinkedList.java | Java | [
{
"context": "list=new LinkedList();\r\n list.insertFirst(\"mohit\");\r\n list.display();\r\n list.insertL",
"end": 204,
"score": 0.9994828104972839,
"start": 199,
"tag": "NAME",
"value": "mohit"
},
{
"context": " list.display();\r\n list.insertLast(\"mohini\");\r\n list.insertLast(\"amit\");\r\n lis",
"end": 265,
"score": 0.9995970726013184,
"start": 259,
"tag": "NAME",
"value": "mohini"
},
{
"context": "t.insertLast(\"mohini\");\r\n list.insertLast(\"amit\");\r\n list.insertLast(\"neha\");\r\n lis",
"end": 299,
"score": 0.99944007396698,
"start": 295,
"tag": "NAME",
"value": "amit"
},
{
"context": "ist.insertLast(\"amit\");\r\n list.insertLast(\"neha\");\r\n list.display();\r\n list.insert(",
"end": 333,
"score": 0.9993493556976318,
"start": 329,
"tag": "NAME",
"value": "neha"
},
{
"context": ");\r\n list.display();\r\n list.insert(\"richa\",2);\r\n list.insert(\"richa\",5);\r\n li",
"end": 389,
"score": 0.9996809959411621,
"start": 384,
"tag": "NAME",
"value": "richa"
},
{
"context": " list.insert(\"richa\",2);\r\n list.insert(\"richa\",5);\r\n list.display();\r\n list.remov",
"end": 422,
"score": 0.9996727705001831,
"start": 417,
"tag": "NAME",
"value": "richa"
}
] | null | [] | package com.mypractice.lecture_20.linkedlist;
public class ClientLinkedList {
public static void main(String[] args) {
LinkedList list=new LinkedList();
list.insertFirst("mohit");
list.display();
list.insertLast("mohini");
list.insertLast("amit");
list.insertLast("neha");
list.display();
list.insert("richa",2);
list.insert("richa",5);
list.display();
list.removeFirst();
list.display();
System.out.println(list.mid());
list.remove(2);
System.out.println(list.findIndex("neha"));
System.out.println(list.mid());
list.display();
}
}
| 703 | 0.556188 | 0.549075 | 24 | 27.291666 | 13.815689 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false | 13 |
b9e0e7f599a6f1ce6d936c36b9f5a37ee65157c4 | 15,444,702,434,509 | def387221512bd84f422866301b3f39a7574373b | /backend/src/main/java/com/ssafy/api/service/dong/DongService.java | 58aba01e6dfe2b2a8459a947f0615a2b665a1e5f | [] | no_license | npnppn/Visualizing-crime-big-data | https://github.com/npnppn/Visualizing-crime-big-data | 07f83770c5dea92d905ac8aa8f54a7920010822d | 205963095085228cd5844579238d0b77f55a3a3f | refs/heads/master | 2023-08-19T05:05:03.346000 | 2021-10-11T16:52:12 | 2021-10-11T16:52:12 | 414,595,184 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ssafy.api.service.dong;
import com.ssafy.api.response.dong.SafetyRankingGetRes;
import com.ssafy.api.response.dong.SpaceRankingGetRes;
import com.ssafy.api.response.space.SpaceCountGetRes;
import com.ssafy.db.dto.dong.GetDongListDto;
import com.ssafy.db.mapping.DongNameMapping;
import com.ssafy.db.mapping.LatLngMapping;
import javassist.NotFoundException;
import java.util.List;
public interface DongService {
DongNameMapping getGuNameByDong(Long id) throws NotFoundException;
List<GetDongListDto> getDongList(Long id) throws NotFoundException;
SafetyRankingGetRes getSafetyRanking(Long id) throws NotFoundException;
SpaceRankingGetRes getSpaceRanking(Long id) throws NotFoundException;
LatLngMapping getLatLng(Long id) throws NotFoundException;
}
| UTF-8 | Java | 787 | java | DongService.java | Java | [] | null | [] | package com.ssafy.api.service.dong;
import com.ssafy.api.response.dong.SafetyRankingGetRes;
import com.ssafy.api.response.dong.SpaceRankingGetRes;
import com.ssafy.api.response.space.SpaceCountGetRes;
import com.ssafy.db.dto.dong.GetDongListDto;
import com.ssafy.db.mapping.DongNameMapping;
import com.ssafy.db.mapping.LatLngMapping;
import javassist.NotFoundException;
import java.util.List;
public interface DongService {
DongNameMapping getGuNameByDong(Long id) throws NotFoundException;
List<GetDongListDto> getDongList(Long id) throws NotFoundException;
SafetyRankingGetRes getSafetyRanking(Long id) throws NotFoundException;
SpaceRankingGetRes getSpaceRanking(Long id) throws NotFoundException;
LatLngMapping getLatLng(Long id) throws NotFoundException;
}
| 787 | 0.827192 | 0.827192 | 21 | 36.476189 | 26.743258 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 13 |
e66b87a77e970274e7093dee2f3ecb32225e6bed | 18,253,611,076,886 | 326a71d7557f3560611df02c4f56d1d691a87620 | /TestProject/src/com/cybage/spring/dao/TodoDAO.java | a05b630f46b339ee8a5a20a52c804ca9162863be | [] | no_license | VipulThakrar/MyRepo | https://github.com/VipulThakrar/MyRepo | e15db9744bc26719a1f6e5e522cc5b77a0da1596 | 52e540aa5a5f355cf678a54d7f1c520195ace3e9 | refs/heads/master | 2020-03-31T13:28:22.013000 | 2018-10-09T13:37:22 | 2018-10-09T13:37:22 | 152,257,015 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.cybage.spring.dao;
import java.util.List;
import com.cybage.spring.entity.Todo;
public interface TodoDAO {
List<Todo> getAllTodos();
void save(Todo todo);
void update(Todo todo);
void delete(Todo todo);
}
| UTF-8 | Java | 225 | java | TodoDAO.java | Java | [] | null | [] | package com.cybage.spring.dao;
import java.util.List;
import com.cybage.spring.entity.Todo;
public interface TodoDAO {
List<Todo> getAllTodos();
void save(Todo todo);
void update(Todo todo);
void delete(Todo todo);
}
| 225 | 0.742222 | 0.742222 | 13 | 16.307692 | 13.25713 | 37 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.846154 | false | false | 13 |
274d415384a31c6a042358a9252a9cd3a586f5ff | 23,725,399,360,829 | 0aea23e690d401136ad90901047672502abb194f | /src/main/java/com/sandman/common/enums/IBaseEnum.java | 126097b3eb7946d9e2107fd1a1ea20eef439529c | [] | no_license | Sandaman2015/SpringBootStarter | https://github.com/Sandaman2015/SpringBootStarter | bbdfd6ddaafc6cd7dcae86e7e3fc7926af56ecc7 | 6c00e4c75ef60c1be24d27acbf9175126103f679 | refs/heads/master | 2023-07-14T23:01:54.391000 | 2021-08-12T06:54:53 | 2021-08-12T06:54:53 | 395,224,706 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (C), 2021, com.netease
* FileName: IBaseEnum
* Author: wb.zhangchengwei01
* Date: 2021/7/16 15:11
* Description: Mybatis的通用枚举封装
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.sandman.common.enums;
import com.baomidou.mybatisplus.annotation.IEnum;
import java.io.Serializable;
/**
* Mybatis的通用枚举封装〉<br>
*
* @param <T> extends genericity
* @author wb.zhangchengwei01
* @version 1.0.0
* @since 2021/7/16
*/
public interface IBaseEnum<T extends Serializable> extends IEnum<T> {
/**
* get enums description
*
* @return description
*/
String getDesc();
/**
* get enum name
*
* @return name
*/
String getName();
}
| UTF-8 | Java | 853 | java | IBaseEnum.java | Java | [
{
"context": "1, com.netease\n * FileName: IBaseEnum\n * Author: wb.zhangchengwei01\n * Date: 2021/7/16 15:11\n * Description: Myba",
"end": 93,
"score": 0.9994860887527466,
"start": 75,
"tag": "USERNAME",
"value": "wb.zhangchengwei01"
},
{
"context": "br>\n *\n * @param <T> extends genericity\n * @author wb.zhangchengwei01\n * @version 1.0.0\n * @since 2021/7/16\n */\npublic ",
"end": 494,
"score": 0.9996322393417358,
"start": 476,
"tag": "USERNAME",
"value": "wb.zhangchengwei01"
}
] | null | [] | /*
* Copyright (C), 2021, com.netease
* FileName: IBaseEnum
* Author: wb.zhangchengwei01
* Date: 2021/7/16 15:11
* Description: Mybatis的通用枚举封装
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.sandman.common.enums;
import com.baomidou.mybatisplus.annotation.IEnum;
import java.io.Serializable;
/**
* Mybatis的通用枚举封装〉<br>
*
* @param <T> extends genericity
* @author wb.zhangchengwei01
* @version 1.0.0
* @since 2021/7/16
*/
public interface IBaseEnum<T extends Serializable> extends IEnum<T> {
/**
* get enums description
*
* @return description
*/
String getDesc();
/**
* get enum name
*
* @return name
*/
String getName();
}
| 853 | 0.582183 | 0.545797 | 39 | 19.435898 | 17.343874 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.179487 | false | false | 13 |
5228ace7382f16ca5a2844bb3b67170b837823fa | 9,191,230,051,674 | f134d1629baac7412603a5449877b415f5153b05 | /basic/src/main/java/net/happyonroad/util/serializer/JmxObjectNameSerializer.java | 2711d6bceed05cf9d644869a44beeed1cf71a0ed | [] | no_license | Kadvin/spring-service-components | https://github.com/Kadvin/spring-service-components | ebb381237cfd03e92d1ddcbdef85c64401100227 | df206c7f7fc720c66b952b873ec3afe40cdf7ff4 | refs/heads/master | 2021-01-01T18:34:15.234000 | 2016-02-12T15:03:11 | 2016-02-12T15:03:11 | 27,476,179 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.happyonroad.util.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import javax.management.ObjectName;
import java.io.IOException;
/**
* <h1>javax.management.ObjectName Serializer</h1>
*
* @author Jay Xiong
*/
public class JmxObjectNameSerializer extends StdScalarSerializer<ObjectName> {
public JmxObjectNameSerializer() {
super(ObjectName.class);
}
@Override
public void serialize(ObjectName value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeStartObject();
jgen.writeObjectField("canonicalName", value.getCanonicalName());
jgen.writeEndObject();
}
}
| UTF-8 | Java | 809 | java | JmxObjectNameSerializer.java | Java | [
{
"context": "anagement.ObjectName Serializer</h1>\n *\n * @author Jay Xiong\n */\npublic class JmxObjectNameSerializer extends ",
"end": 360,
"score": 0.9998730421066284,
"start": 351,
"tag": "NAME",
"value": "Jay Xiong"
}
] | null | [] | package net.happyonroad.util.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import javax.management.ObjectName;
import java.io.IOException;
/**
* <h1>javax.management.ObjectName Serializer</h1>
*
* @author <NAME>
*/
public class JmxObjectNameSerializer extends StdScalarSerializer<ObjectName> {
public JmxObjectNameSerializer() {
super(ObjectName.class);
}
@Override
public void serialize(ObjectName value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeStartObject();
jgen.writeObjectField("canonicalName", value.getCanonicalName());
jgen.writeEndObject();
}
}
| 806 | 0.749073 | 0.746601 | 27 | 28.962963 | 26.700647 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.481481 | false | false | 13 |
a1a3aed661caa62b21d91d4f0238c0c7af741098 | 6,390,911,348,667 | c9e2035df0aa14ff2415250338540fcb2b9bf8d1 | /sealtalk/src/main/java/com/caesar/rongcloudspeed/adapter/LessonLikeAdapter.java | 3e326bf3c83e2ab14b947439bf18710351251876 | [] | no_license | xmong123/sealtalk-android-speers | https://github.com/xmong123/sealtalk-android-speers | 614052fb4108a4aed680bb86adbedc17684246a3 | 7bdfe4c2926d6ef52cf8fe0a06662f8b2bfaac14 | refs/heads/master | 2021-08-15T18:43:24.445000 | 2020-12-08T04:42:46 | 2020-12-08T04:42:46 | 230,228,818 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.caesar.rongcloudspeed.adapter;
import android.content.Context;
import com.caesar.rongcloudspeed.R;
import com.caesar.rongcloudspeed.bean.PostsArticleBaseBean;
import com.caesar.rongcloudspeed.data.UserOrder;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
/**
* 文 件 名: AnimationAdapter
* 创 建 人: Allen
* 创建日期: 16/12/24 15:33
* 邮 箱: AllenCoder@126.com
* 修改时间:
* 修改备注:
*/
public class LessonLikeAdapter extends BaseQuickAdapter<PostsArticleBaseBean, BaseViewHolder> {
private Context context;
public LessonLikeAdapter(Context context, List data) {
super(R.layout.item_lesson_video_careview, data);
this.context=context;
}
@Override
protected void convert(BaseViewHolder helper, PostsArticleBaseBean bean) {
String titleString = bean.getPost_title();
String priceString = bean.getPost_price();
if(priceString.startsWith( "0.0" )){
helper.setText( R.id.lessonMoney, "课程免费" );
}else{
helper.setText( R.id.lessonMoney, "¥"+priceString+"元" );
}
helper.setText( R.id.item_title, titleString );
}
}
| UTF-8 | Java | 1,269 | java | LessonLikeAdapter.java | Java | [
{
"context": "il.List;\n\n/**\n * 文 件 名: AnimationAdapter\n * 创 建 人: Allen\n * 创建日期: 16/12/24 15:33\n * 邮 箱: AllenCoder@126.",
"end": 401,
"score": 0.9975995421409607,
"start": 396,
"tag": "NAME",
"value": "Allen"
},
{
"context": "\n * 创 建 人: Allen\n * 创建日期: 16/12/24 15:33\n * 邮 箱: AllenCoder@126.com\n * 修改时间:\n * 修改备注:\n */\npublic class LessonLikeAdap",
"end": 454,
"score": 0.9998942613601685,
"start": 436,
"tag": "EMAIL",
"value": "AllenCoder@126.com"
}
] | null | [] | package com.caesar.rongcloudspeed.adapter;
import android.content.Context;
import com.caesar.rongcloudspeed.R;
import com.caesar.rongcloudspeed.bean.PostsArticleBaseBean;
import com.caesar.rongcloudspeed.data.UserOrder;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
/**
* 文 件 名: AnimationAdapter
* 创 建 人: Allen
* 创建日期: 16/12/24 15:33
* 邮 箱: <EMAIL>
* 修改时间:
* 修改备注:
*/
public class LessonLikeAdapter extends BaseQuickAdapter<PostsArticleBaseBean, BaseViewHolder> {
private Context context;
public LessonLikeAdapter(Context context, List data) {
super(R.layout.item_lesson_video_careview, data);
this.context=context;
}
@Override
protected void convert(BaseViewHolder helper, PostsArticleBaseBean bean) {
String titleString = bean.getPost_title();
String priceString = bean.getPost_price();
if(priceString.startsWith( "0.0" )){
helper.setText( R.id.lessonMoney, "课程免费" );
}else{
helper.setText( R.id.lessonMoney, "¥"+priceString+"元" );
}
helper.setText( R.id.item_title, titleString );
}
}
| 1,258 | 0.698269 | 0.685903 | 41 | 28.585365 | 25.310728 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.560976 | false | false | 13 |
5e26ca6df515a5db94516688edb359722f005b2c | 8,873,402,439,983 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/33/33_ba77278e7b29409be93a93e913b601e57a28d722/TrafikantenSearch/33_ba77278e7b29409be93a93e913b601e57a28d722_TrafikantenSearch_t.java | b114afebe03048308a5b0880aa659cb39c176954 | [] | no_license | zhongxingyu/Seer | https://github.com/zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false | /**
* Copyright (C) 2009 Anders Aagaard <aagaande@gmail.com>
*
* 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 com.neuron.trafikanten.dataProviders.trafikanten;
import java.io.InputStream;
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import uk.me.jstott.jcoord.LatLng;
import uk.me.jstott.jcoord.UTMRef;
import android.content.res.Resources;
import android.util.Log;
import com.neuron.trafikanten.HelperFunctions;
import com.neuron.trafikanten.R;
import com.neuron.trafikanten.dataProviders.ISearchProvider;
import com.neuron.trafikanten.dataProviders.ISearchProvider.SearchProviderHandler;
import com.neuron.trafikanten.dataSets.SearchStationData;
public class TrafikantenSearch implements ISearchProvider {
private static final String TAG = "Trafikanten-TrafikantenSearch";
private SearchProviderHandler handler;
private Resources resources;
private TrafikantenSearchThread thread;
public TrafikantenSearch(Resources resources, SearchProviderHandler handler) {
this.handler = handler;
this.resources = resources;
}
/*
* Kill off running thread to stop current search.
*/
@Override
public void Stop() {
if (thread != null) {
thread.interrupt();
thread = null;
}
}
/*
* Initiate a search of string query
*/
@Override
public void Search(String query) {
Stop();
Log.i(TAG,"Searching for station " + query);
thread = new TrafikantenSearchThread(resources, handler, query);
handler.onStarted();
thread.start();
}
/*
* Initiate a search of coordinates
*/
@Override
public void Search(double latitude, double longitude) {
Stop();
Log.i(TAG,"Searching for coordinates " + latitude + " " + longitude);
thread = new TrafikantenSearchThread(resources, handler, latitude, longitude);
handler.onStarted();
thread.start();
}
}
class TrafikantenSearchThread extends Thread implements Runnable {
//private static final String TAG = "Trafikanten-T-SearchThread";
private SearchProviderHandler handler;
private Resources resources;
private String query;
private double latitude;
private double longitude;
public TrafikantenSearchThread(Resources resources, SearchProviderHandler handler, String query) {
this.handler = handler;
this.resources = resources;
this.query = query;
}
public TrafikantenSearchThread(Resources resources, SearchProviderHandler handler, double latitude, double longitude) {
this.handler = handler;
this.resources = resources;
this.latitude = latitude;
this.longitude = longitude;
}
/*
* Run current thread.
* This function setups the url and the xmlreader, and passes data to the SearchHandler.
*/
public void run() {
try {
InputStream result;
if (query != null) {
/*
* Setup URL for a normal station search query.
*/
result = HelperFunctions.soapRequest(resources, R.raw.getmatches, new String[]{query}, Trafikanten.API_URL);
} else {
/*
* Setup URL for coordinate search.
*/
final LatLng latLong = new LatLng(latitude, longitude);
final UTMRef utmRef = latLong.toUTMRef();
final String urlString = "http://reis.trafikanten.no/topp2009/getcloseststops.aspx?x="+ (int)utmRef.getEasting() + "&y="+ (int) utmRef.getNorthing() + "&proposals=10";
final URL url = new URL(urlString);
result = url.openStream();
}
/*
* Setup SAXParser and XMLReader
*/
final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
final SAXParser parser = parserFactory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
reader.setContentHandler(new SearchHandler(handler));
reader.parse(new InputSource(result));
} catch(Exception e) {
/*
* All exceptions except thread interruptions are passed to callback.
*/
if (e.getClass() == InterruptedException.class)
return;
/*
* Send exception
*/
final Exception sendException = e;
handler.post(new Runnable() {
@Override
public void run() {
handler.onError(sendException);
}
});
}
}
}
/*
* Search XML Parser
*/
class SearchHandler extends DefaultHandler {
private SearchStationData station;
private SearchProviderHandler handler;
/*
* Temporary variables for parsing.
*/
private boolean inPlace = false;
//private boolean inZone = false;
private boolean inX = false;
private boolean inY = false;
private boolean inID = false;
private boolean inName = false;
private boolean inDistrict = false;
private boolean inType = false;
private boolean inStops = false;
private boolean inWalkingDistance = false;
// Ignore is used to ignore anything except type Stop.
private boolean ignore = false;
//Temporary variable for character data:
private StringBuffer buffer = new StringBuffer();
public SearchHandler(SearchProviderHandler handler)
{
this.handler = handler;
}
/*
* This searches stopName for address, and puts address in extra (the next line).
* As station names are sometimes StationName (address)
*/
private void searchForAddress() {
final String stopName = station.stopName;
int startAddress = stopName.indexOf('(');
if (startAddress < 0) {
return;
} else {
String address = stopName.substring(startAddress + 1, stopName.length() - 1);
station.stopName = stopName.substring(0, startAddress - 1);
if (address.startsWith("i "))
address = address.substring(2);
station.extra = address;
}
}
/*
* End of document, call onCompleted with complete stationList
*/
@Override
public void endDocument() throws SAXException {
handler.post(new Runnable() {
@Override
public void run() {
handler.onFinished();
}
});
}
@Override
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
if (ignore) return;
if (inStops) return;
if (!inPlace) {
if (localName.equals("Place")) {
inPlace = true;
station = new SearchStationData();
}
} else {
if (localName.equals("X")) {
inX = true;
} else if (localName.equals("Y")) {
inY = true;
} else if (localName.equals("ID")) {
inID = true;
} else if (localName.equals("Name")) {
inName = true;
} else if (localName.equals("District")) {
inDistrict = true;
} else if (localName.equals("Type")) {
inType = true;
} else if (localName.equals("Stops")) {
inStops = true;
} else if (localName.equals("WalkingDistance")) {
inWalkingDistance = true;
}
}
}
@Override
public void endElement(String namespaceURI, String localName, String qName) {
if (!inPlace) return;
if (localName.equals("Place")) {
/*
* on StopMatch we're at the end, and we need to add the station to the station list.
*/
inPlace = false;
if (!ignore) {
final SearchStationData sendData = station;
handler.post(new Runnable() {
@Override
public void run() {
handler.onData(sendData);
}
});
}
ignore = false;
} else {
if (ignore) return;
if (inX && localName.equals("X")) {
inX = false;
station.utmCoords[0] = Integer.parseInt(buffer.toString());
} else if (inY && localName.equals("Y")) {
inY = false;
station.utmCoords[1] = Integer.parseInt(buffer.toString());
} else if (inID && localName.equals("ID")) {
inID = false;
station.stationId = Integer.parseInt(buffer.toString());
} else if (inName && localName.equals("Name")) {
inName = false;
station.stopName = buffer.toString();
searchForAddress();
} else if (inDistrict && localName.equals("District")) {
inDistrict = false;
if (station.extra == null) {
station.extra = buffer.toString();
} else {
station.extra = station.extra + ", " + buffer.toString();
}
} else if (inType && localName.equals("Type")) {
inType = false;
//Log.d("DEBUG CODE","Type : " + new String(ch, start, length) + " " + ch[0] + " " + length);
if (buffer.length() != 4 && !buffer.toString().equals("Stop")) {
//Log.d("DEBUG CODE"," - Ignoring");
ignore = true;
}
} else if (inStops && localName.equals("Stops")) {
inStops = false;
} else if (inWalkingDistance && localName.equals("WalkingDistance")) {
inWalkingDistance = false;
station.walkingDistance = Integer.parseInt(buffer.toString());
}
}
buffer.setLength(0);
}
@Override
public void characters(char ch[], int start, int length) {
if (ignore) return;
if (inX || inY || inID || inName || inDistrict || inType || inWalkingDistance) {
buffer.append(ch, start, length);
}
}
}
| UTF-8 | Java | 10,246 | java | 33_ba77278e7b29409be93a93e913b601e57a28d722_TrafikantenSearch_t.java | Java | [
{
"context": " /**\n * Copyright (C) 2009 Anders Aagaard <aagaande@gmail.com>\n *\n * This program is fr",
"end": 46,
"score": 0.9998759031295776,
"start": 32,
"tag": "NAME",
"value": "Anders Aagaard"
},
{
"context": " /**\n * Copyright (C) 2009 Anders Aagaard <aagaande@gmail.com>\n *\n * This program is free software: you can",
"end": 66,
"score": 0.9999285340309143,
"start": 48,
"tag": "EMAIL",
"value": "aagaande@gmail.com"
}
] | null | [] | /**
* Copyright (C) 2009 <NAME> <<EMAIL>>
*
* 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 com.neuron.trafikanten.dataProviders.trafikanten;
import java.io.InputStream;
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import uk.me.jstott.jcoord.LatLng;
import uk.me.jstott.jcoord.UTMRef;
import android.content.res.Resources;
import android.util.Log;
import com.neuron.trafikanten.HelperFunctions;
import com.neuron.trafikanten.R;
import com.neuron.trafikanten.dataProviders.ISearchProvider;
import com.neuron.trafikanten.dataProviders.ISearchProvider.SearchProviderHandler;
import com.neuron.trafikanten.dataSets.SearchStationData;
public class TrafikantenSearch implements ISearchProvider {
private static final String TAG = "Trafikanten-TrafikantenSearch";
private SearchProviderHandler handler;
private Resources resources;
private TrafikantenSearchThread thread;
public TrafikantenSearch(Resources resources, SearchProviderHandler handler) {
this.handler = handler;
this.resources = resources;
}
/*
* Kill off running thread to stop current search.
*/
@Override
public void Stop() {
if (thread != null) {
thread.interrupt();
thread = null;
}
}
/*
* Initiate a search of string query
*/
@Override
public void Search(String query) {
Stop();
Log.i(TAG,"Searching for station " + query);
thread = new TrafikantenSearchThread(resources, handler, query);
handler.onStarted();
thread.start();
}
/*
* Initiate a search of coordinates
*/
@Override
public void Search(double latitude, double longitude) {
Stop();
Log.i(TAG,"Searching for coordinates " + latitude + " " + longitude);
thread = new TrafikantenSearchThread(resources, handler, latitude, longitude);
handler.onStarted();
thread.start();
}
}
class TrafikantenSearchThread extends Thread implements Runnable {
//private static final String TAG = "Trafikanten-T-SearchThread";
private SearchProviderHandler handler;
private Resources resources;
private String query;
private double latitude;
private double longitude;
public TrafikantenSearchThread(Resources resources, SearchProviderHandler handler, String query) {
this.handler = handler;
this.resources = resources;
this.query = query;
}
public TrafikantenSearchThread(Resources resources, SearchProviderHandler handler, double latitude, double longitude) {
this.handler = handler;
this.resources = resources;
this.latitude = latitude;
this.longitude = longitude;
}
/*
* Run current thread.
* This function setups the url and the xmlreader, and passes data to the SearchHandler.
*/
public void run() {
try {
InputStream result;
if (query != null) {
/*
* Setup URL for a normal station search query.
*/
result = HelperFunctions.soapRequest(resources, R.raw.getmatches, new String[]{query}, Trafikanten.API_URL);
} else {
/*
* Setup URL for coordinate search.
*/
final LatLng latLong = new LatLng(latitude, longitude);
final UTMRef utmRef = latLong.toUTMRef();
final String urlString = "http://reis.trafikanten.no/topp2009/getcloseststops.aspx?x="+ (int)utmRef.getEasting() + "&y="+ (int) utmRef.getNorthing() + "&proposals=10";
final URL url = new URL(urlString);
result = url.openStream();
}
/*
* Setup SAXParser and XMLReader
*/
final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
final SAXParser parser = parserFactory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
reader.setContentHandler(new SearchHandler(handler));
reader.parse(new InputSource(result));
} catch(Exception e) {
/*
* All exceptions except thread interruptions are passed to callback.
*/
if (e.getClass() == InterruptedException.class)
return;
/*
* Send exception
*/
final Exception sendException = e;
handler.post(new Runnable() {
@Override
public void run() {
handler.onError(sendException);
}
});
}
}
}
/*
* Search XML Parser
*/
class SearchHandler extends DefaultHandler {
private SearchStationData station;
private SearchProviderHandler handler;
/*
* Temporary variables for parsing.
*/
private boolean inPlace = false;
//private boolean inZone = false;
private boolean inX = false;
private boolean inY = false;
private boolean inID = false;
private boolean inName = false;
private boolean inDistrict = false;
private boolean inType = false;
private boolean inStops = false;
private boolean inWalkingDistance = false;
// Ignore is used to ignore anything except type Stop.
private boolean ignore = false;
//Temporary variable for character data:
private StringBuffer buffer = new StringBuffer();
public SearchHandler(SearchProviderHandler handler)
{
this.handler = handler;
}
/*
* This searches stopName for address, and puts address in extra (the next line).
* As station names are sometimes StationName (address)
*/
private void searchForAddress() {
final String stopName = station.stopName;
int startAddress = stopName.indexOf('(');
if (startAddress < 0) {
return;
} else {
String address = stopName.substring(startAddress + 1, stopName.length() - 1);
station.stopName = stopName.substring(0, startAddress - 1);
if (address.startsWith("i "))
address = address.substring(2);
station.extra = address;
}
}
/*
* End of document, call onCompleted with complete stationList
*/
@Override
public void endDocument() throws SAXException {
handler.post(new Runnable() {
@Override
public void run() {
handler.onFinished();
}
});
}
@Override
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
if (ignore) return;
if (inStops) return;
if (!inPlace) {
if (localName.equals("Place")) {
inPlace = true;
station = new SearchStationData();
}
} else {
if (localName.equals("X")) {
inX = true;
} else if (localName.equals("Y")) {
inY = true;
} else if (localName.equals("ID")) {
inID = true;
} else if (localName.equals("Name")) {
inName = true;
} else if (localName.equals("District")) {
inDistrict = true;
} else if (localName.equals("Type")) {
inType = true;
} else if (localName.equals("Stops")) {
inStops = true;
} else if (localName.equals("WalkingDistance")) {
inWalkingDistance = true;
}
}
}
@Override
public void endElement(String namespaceURI, String localName, String qName) {
if (!inPlace) return;
if (localName.equals("Place")) {
/*
* on StopMatch we're at the end, and we need to add the station to the station list.
*/
inPlace = false;
if (!ignore) {
final SearchStationData sendData = station;
handler.post(new Runnable() {
@Override
public void run() {
handler.onData(sendData);
}
});
}
ignore = false;
} else {
if (ignore) return;
if (inX && localName.equals("X")) {
inX = false;
station.utmCoords[0] = Integer.parseInt(buffer.toString());
} else if (inY && localName.equals("Y")) {
inY = false;
station.utmCoords[1] = Integer.parseInt(buffer.toString());
} else if (inID && localName.equals("ID")) {
inID = false;
station.stationId = Integer.parseInt(buffer.toString());
} else if (inName && localName.equals("Name")) {
inName = false;
station.stopName = buffer.toString();
searchForAddress();
} else if (inDistrict && localName.equals("District")) {
inDistrict = false;
if (station.extra == null) {
station.extra = buffer.toString();
} else {
station.extra = station.extra + ", " + buffer.toString();
}
} else if (inType && localName.equals("Type")) {
inType = false;
//Log.d("DEBUG CODE","Type : " + new String(ch, start, length) + " " + ch[0] + " " + length);
if (buffer.length() != 4 && !buffer.toString().equals("Stop")) {
//Log.d("DEBUG CODE"," - Ignoring");
ignore = true;
}
} else if (inStops && localName.equals("Stops")) {
inStops = false;
} else if (inWalkingDistance && localName.equals("WalkingDistance")) {
inWalkingDistance = false;
station.walkingDistance = Integer.parseInt(buffer.toString());
}
}
buffer.setLength(0);
}
@Override
public void characters(char ch[], int start, int length) {
if (ignore) return;
if (inX || inY || inID || inName || inDistrict || inType || inWalkingDistance) {
buffer.append(ch, start, length);
}
}
}
| 10,227 | 0.632149 | 0.630002 | 328 | 30.234756 | 25.904428 | 172 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.051829 | false | false | 13 |
1638e47eea56703c21c7f8559963cc2483e58e09 | 17,643,725,657,140 | 68750cc0f0999dbf2890875186c4b4f8492dc9fc | /src/main/java/br/com/colmeia/model/persistence/dao/TipoAtividadeDAO.java | 4b743d718498017472ef123d72ff3b6c69f515f7 | [] | no_license | JoseAntonioPdosSantos/C.O.L.M.E.I.A | https://github.com/JoseAntonioPdosSantos/C.O.L.M.E.I.A | 3d963c0085170c825e35b47744cb31e0c7bad015 | 7cef6344ac62a5f69a4cf4540aac60f36ef184c1 | refs/heads/master | 2021-01-21T12:47:15.607000 | 2016-03-27T00:50:52 | 2016-03-27T00:50:52 | 39,336,883 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.colmeia.model.persistence.dao;
import br.com.colmeia.model.persistence.dao.generics.GenericDAO;
import br.com.colmeia.model.persistence.entity.TipoAtividade;
public interface TipoAtividadeDAO extends GenericDAO<TipoAtividade, Long>{
}
| UTF-8 | Java | 263 | java | TipoAtividadeDAO.java | Java | [] | null | [] | package br.com.colmeia.model.persistence.dao;
import br.com.colmeia.model.persistence.dao.generics.GenericDAO;
import br.com.colmeia.model.persistence.entity.TipoAtividade;
public interface TipoAtividadeDAO extends GenericDAO<TipoAtividade, Long>{
}
| 263 | 0.802281 | 0.802281 | 9 | 27.222221 | 31.000996 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 13 |
fcf25f83eb86fbe56caa1ac772702bf6fff8d53d | 19,043,885,014,020 | 83a9b6b4a39bd62981a766f546c634797bfcd495 | /crawl/src/test/java/xyz/wheretolive/crawl/foodMarket/kaufland/KauflandCrawlerTest.java | a790ad3769840b2e4740836fbde2ae37cee4eef9 | [
"Apache-2.0"
] | permissive | matejferenc/wheretolive | https://github.com/matejferenc/wheretolive | f5ed659d257fce8aba8137b09e00ec5851f542db | b2b698ba2baadcfca12da38ad11d7108e870f585 | refs/heads/master | 2016-12-12T17:33:36.111000 | 2016-11-16T19:15:52 | 2016-11-16T19:15:52 | 44,750,588 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package xyz.wheretolive.crawl.foodMarket.kaufland;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.wheretolive.core.domain.MapObject;
import xyz.wheretolive.crawl.IntegrationTest;
import xyz.wheretolive.crawl.foodMarket.kaufland.KauflandCrawler;
import java.util.Collection;
import static org.junit.Assert.assertTrue;
public class KauflandCrawlerTest extends IntegrationTest {
@Autowired
KauflandCrawler kauflandCrawler;
@Test
public void test() {
Collection<MapObject> crawl = kauflandCrawler.crawl();
assertTrue(crawl.size() > 0);
}
}
| UTF-8 | Java | 636 | java | KauflandCrawlerTest.java | Java | [] | null | [] | package xyz.wheretolive.crawl.foodMarket.kaufland;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.wheretolive.core.domain.MapObject;
import xyz.wheretolive.crawl.IntegrationTest;
import xyz.wheretolive.crawl.foodMarket.kaufland.KauflandCrawler;
import java.util.Collection;
import static org.junit.Assert.assertTrue;
public class KauflandCrawlerTest extends IntegrationTest {
@Autowired
KauflandCrawler kauflandCrawler;
@Test
public void test() {
Collection<MapObject> crawl = kauflandCrawler.crawl();
assertTrue(crawl.size() > 0);
}
}
| 636 | 0.765723 | 0.764151 | 23 | 26.652174 | 22.933949 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478261 | false | false | 13 |
5ed6323faec7baec398de84dd8463888882aaf08 | 19,043,885,011,135 | 8414f3a74e268168f193c2987676e27fc86b47e8 | /app/src/main/java/com/englishlearn/myapplication/data/source/remote/bmob/service/RetrofitService.java | e04261839083b281432e0139cb328bc8c24e080c | [] | no_license | yanzhilong/MyApplication | https://github.com/yanzhilong/MyApplication | 054c0c46a072c8664894bed589fdff3bfcc9fcd2 | 5ac410e3459b9ab1aa534399ae77fab66a471162 | refs/heads/master | 2020-04-12T08:51:52.810000 | 2017-01-08T23:53:55 | 2017-01-08T23:53:55 | 63,490,394 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.englishlearn.myapplication.data.source.remote.bmob.service;
import com.englishlearn.myapplication.data.BmobFile;
import com.englishlearn.myapplication.data.Dict;
import com.englishlearn.myapplication.data.Grammar;
import com.englishlearn.myapplication.data.PhoneticsSymbols;
import com.englishlearn.myapplication.data.PhoneticsVoice;
import com.englishlearn.myapplication.data.Sentence;
import com.englishlearn.myapplication.data.SentenceCollect;
import com.englishlearn.myapplication.data.SentenceCollectGroup;
import com.englishlearn.myapplication.data.SentenceGroup;
import com.englishlearn.myapplication.data.SentenceGroupCollect;
import com.englishlearn.myapplication.data.Tractate;
import com.englishlearn.myapplication.data.TractateCollect;
import com.englishlearn.myapplication.data.TractateCollectGroup;
import com.englishlearn.myapplication.data.TractateGroup;
import com.englishlearn.myapplication.data.TractateGroupCollect;
import com.englishlearn.myapplication.data.TractateType;
import com.englishlearn.myapplication.data.User;
import com.englishlearn.myapplication.data.Word;
import com.englishlearn.myapplication.data.WordCollect;
import com.englishlearn.myapplication.data.WordGroup;
import com.englishlearn.myapplication.data.WordGroupCollect;
import com.englishlearn.myapplication.data.source.remote.bmob.BatchRequest;
import com.englishlearn.myapplication.data.source.remote.bmob.BmobCreateOrLoginUserByPhoneRequest;
import com.englishlearn.myapplication.data.source.remote.bmob.DictResult;
import com.englishlearn.myapplication.data.source.remote.bmob.EmailVerify;
import com.englishlearn.myapplication.data.source.remote.bmob.GrammarResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetEmail;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetMobile;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetOldPwd;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsSymbolsResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsSymbolsVoicesResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsVoiceResult;
import com.englishlearn.myapplication.data.source.remote.bmob.QuerySmsResult;
import com.englishlearn.myapplication.data.source.remote.bmob.RequestSmsCode;
import com.englishlearn.myapplication.data.source.remote.bmob.RequestSmsCodeResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceCollectGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SmsCodeVerify;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateCollectGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateTypeResult;
import com.englishlearn.myapplication.data.source.remote.bmob.UserResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordResult;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;
import rx.Observable;
/**
* Created by yanzl on 16-8-11.
*/
public interface RetrofitService {
String BMOBAPI = "https://api.bmob.cn";
//指操作数据
@POST("/1/batch")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> batchPost(@Body BatchRequest batchRequest);
//用户模块****************************************************************************
//注册用户
@POST("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<User>> createUserRx(@Body User user);
//注册或登陆用户(手机号+验证码)
@POST("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<User>> createOrLoginUserByPhoneRx(@Body BmobCreateOrLoginUserByPhoneRequest bmobCreateOrLoginUserByPhoneRequest);
//修改用户
@PUT("/1/users/{objectId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<User>> updateUserRx(@Header("X-Bmob-Session-Token") String sessionToken,@Path("objectId")String objectId, @Body User user);
//登陆用户(用户名密码)
@GET("/1/login")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<User>> loginRx(@Query("username") String username,@Query("password") String password);
//根据Id获取用户
@GET("/1/users/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<User>> getUserByIdRx(@Path("id") String id);
//根据用户名获取用户,或者邮箱,手机
@GET("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<UserResult>> getUserByNameRx(@Query("where")String usernameJson);
/**
* 通过邮件重置密码
* @param passwordResetEmail
* @return
*/
@POST("/1/requestPasswordReset")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByEmail(@Body PasswordResetEmail passwordResetEmail);
/**
* 通过手机验证码重置密码
* @param smsCode
* @param passwordResetMobile
* @return
*/
@PUT("/1/resetPasswordBySmsCode/{smsCode}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByMobile(@Path("smsCode")String smsCode, @Body PasswordResetMobile passwordResetMobile);
/**
* 修改密码,使用旧密码
* @param sessionToken
* @param objectId
* @param passwordResetOldPwd
* @return
*/
@PUT("/1/updateUserPassword/{objectId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByOldPassword(@Header("X-Bmob-Session-Token") String sessionToken, @Path("objectId")String objectId, @Body PasswordResetOldPwd passwordResetOldPwd);
/**
* 请求短信验证码
* @param requestSmsCode
* @return
*/
@POST("/1/requestSmsCode")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<RequestSmsCodeResult>> requestSmsCode(@Body RequestSmsCode requestSmsCode);
/**
* 查询短信发送状态
* @param smsId
* @return
*/
@GET("/1/querySms/{smsId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<QuerySmsResult> querySms(@Path("smsId")String smsId);
/**
* 验证邮箱
* @param emailVerify
* @return
*/
@POST("/1/requestEmailVerify")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> emailVerify(@Body EmailVerify emailVerify);
/**
* 验证短信验证码
* @param smsCodeVerify
* @return
*/
@POST("/1/verifySmsCode/{smsCode}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> smsCodeVerify(@Path("smsCode") String smsCode,@Body SmsCodeVerify smsCodeVerify);
//音标模块****************************************************************************
//增加音标
@POST("/1/classes/PhoneticsSymbols")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<PhoneticsSymbols>> addPhoneticsSymbols(@Body PhoneticsSymbols phoneticsSymbols);
//删除音标
@DELETE("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deletePhoneticsSymbolsById(@Path("id") String id);
//修改音标
@PUT("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updatePhoneticsSymbolsRxById(@Path("id") String id,@Body PhoneticsSymbols phoneticsSymbols);
//根据id获取音标
@GET("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<PhoneticsSymbols>> getPhoneticsSymbolsRxById(@Path("id") String id);
//获取所有音标
@GET("/1/classes/PhoneticsSymbols?include=wordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<PhoneticsSymbolsResult>> getPhoneticsSymbolsRx();
//音标单词模块****************************************************************************
//增加音标单词
@POST("/1/classes/PhoneticsVoice")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<PhoneticsVoice>> addPhoneticsSymbolsVoice(@Body PhoneticsVoice phoneticsSymbolsVoice);
//删除音标单词
@DELETE("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deletePhoneticsSymbolsVoiceById(@Path("id") String id);
//修改音标单词
@PUT("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updatePhoneticsSymbolsVoiceRxById(@Path("id") String id, @Body PhoneticsVoice phoneticsSymbolsVoice);
//根据id获取音标单词
@GET("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<PhoneticsVoice>> getPhoneticsSymbolsVoiceRxById(@Path("id") String phoneticsSymbolsVoiceId);
//根据id获取音标单词
@GET("/1/classes/PhoneticsVoice/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<PhoneticsVoiceResult>> getPhoneticsSymbolsVoiceRx(@Query("limit") int limit, @Query("skip")int skip);
//根据音标id获取音标单词
@GET("/1/classes/PhoneticsVoice/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<PhoneticsSymbolsVoicesResult>> getPhoneticsSymbolsVoicesRx(@Query("where")String phoneticsSymbolsIdjson);
//文章分类模块****************************************************************************
//增加文章分类
@POST("/1/classes/TractateType")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateType>> addTractateType(@Body TractateType tractateType);
//删除文章分类
@DELETE("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteTractateTypeById(@Path("id") String id);
//修改文章分类
@PUT("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateTypeRxById(@Path("id") String id,@Body TractateType tractateType);
//根据id获取文章分类
@GET("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<TractateType>> getTractateTypeRxById(@Path("id") String id);
//获取所有文章分类
@GET("/1/classes/TractateType")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateTypeResult>> getTractateTypeRx();
//单词模块****************************************************************************
//添加单词
@POST("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<Word>> addWord(@Body Word word);
//删除单词
@DELETE("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteWordById(@Path("id") String id);
//修改单词
@PUT("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateWordRxById(@Path("id") String id,@Body Word word);
//根据id获取单词
@GET("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<Word>> getWordRxById(@Path("id") String id);
//根据名称获取单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordRxByName(@Query("where")String wordjson);
//获取所有的单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordsRx();
//获取所有的单词
@GET("/1/classes/Word?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordsRx(@Query("limit")int limit, @Query("skip")int skip);
//获取符合条件的所有的单词
@GET("/1/classes/Word?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordsRx(@Query("where") String wordson, @Query("limit")int limit, @Query("skip")int skip);
//查询音标关联收藏分组的所有单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordsRxByPhoneticsId( @Query("where") String phoneticsJson);
//查询收藏分组的所有单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordResult>> getWordsRxByWordGroupId( @Query("where") String wordgroupidJson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 如果您的查询条件某个列值要匹配另一个查询的返回值,举例有一个队伍(Team)保存了每个城市的得分情况且用户表中有一列为用户家乡(hometown), 您可以创建一个查询来寻找用户的家乡是得分大于0.5的城市的所有运动员, 就像这样查询:
curl -X GET \
-H "X-Bmob-Application-Id: Your Application ID" \
-H "X-Bmob-REST-API-Key: Your REST API Key" \
-G \
--data-urlencode 'where={"hometown":{"$select":{"query":{"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}' \
https://api.bmob.cn/1/users
反之查询Team中得分小于等于0.5的城市的所有运动员,构造查询如下:
curl -X GET \
-H "X-Bmob-Application-Id: Your Application ID" \
-H "X-Bmob-REST-API-Key: Your REST API Key" \
-G \
--data-urlencode 'where={"hometown":{"$dontSelect":{"query":{"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}' \
https://api.bmob.cn/1/users
* @param
* @return
*/
//句子模块****************************************************************************
//添加句子
@POST("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<Sentence>> addSentenceRx(@Body Sentence sentence);
//删除句子
@DELETE("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteSentenceRxById(@Path("id") String id);
//修改句子
@PUT("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentencRxById(@Path("id") String id,@Body Sentence sentence);
//根据Id获取句子(Observable)
@GET("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<Sentence>> getSentenceRxById(@Path("id") String id);
/**
* 获取所有句子(分页)
* @param limit 取几条
* @param skip 从第几条开始取
* @return
*/
@GET("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRx(@Query("limit") int limit, @Query("skip")int skip);
/**
* 分页搜索自定义的正则
* @param regex 搜索的单词
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRx(@Query("where") String regex, @Query("limit")int limit, @Query("skip")int skip);
//查询句子分组的所有句子
@GET("/1/classes/Sentence?include=sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRxBySentenceGroupId( @Query("where") String sentencegroupidJson, @Query("limit")int limit, @Query("skip")int skip);
//语法模块****************************************************************************
//添加语法
@POST("/1/classes/Grammar")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<Grammar>> addGrammarRx(@Body Grammar grammar);
//删除語法
@DELETE("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteGrammarRxById(@Path("id") String id);
//修改讲法
@PUT("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateGrammarRxById(@Path("id") String id,@Body Grammar grammar);
//根据Id获取语法(Observable)
@GET("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<Grammar>> getGrammarRxById(@Path("id") String id);
//获取所有语法
@GET("/1/classes/Grammar?include=wordGroup,sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx();
/**
* 获取所有语法(分页)
* @return
*/
@GET("/1/classes/Grammar?include=wordGroup,sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx(@Query("limit") int limit, @Query("skip")int skip);
/**
* 分页搜索自定义的正则
* @param regex 搜索的单词
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Grammar")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx(@Query("where") String regex, @Query("limit")int limit, @Query("skip")int skip);
//文章模块****************************************************************************
//添加文章
@POST("/1/classes/Tractate")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<Tractate>> addTractate(@Body Tractate tractate);
//删除文章
@DELETE("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteTractateRxById(@Path("id") String id);
//修改文章
@PUT("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateRxById(@Path("id") String id,@Body Tractate tractate);
//根据文章id获取文章
@GET("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<Tractate>> getTractateRxById(@Path("id") String id);
//根据分类id获取文章列表分页展示
@GET("/1/classes/Tractate")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateResult>> getTractateRxByTractateTypeId(@Query("where")String tractatetypeidjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据分类id,关键词的正则,获取文章列表分页展示
* @param tractategroupidjson 搜索的tractatetypeid
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Tractate?include=userId,tractatetypeId,tractateGroupId&order=sort")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<TractateResult>> getTractateRxByTractateGroupId(@Query("where") String tractategroupidjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据分类id,关键词的正则,获取文章列表分页展示
* @param serachjson 搜索的tractatetypeid
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Tractate?include=userId,tractatetypeId,tractateGroupId&order=sort")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<TractateResult>> getTractatesRx(@Query("where") String serachjson, @Query("limit")int limit, @Query("skip")int skip);
//单词收藏分组模块****************************************************************************
//添加单词收藏分组
@POST("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<WordGroup>> addWordGroup(@Body WordGroup wordGroup);
//修改单词收藏分组
@PUT("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateWordGroupRxById(@Path("id") String id,@Body WordGroup wordGroup);
//删除单词收藏分组
@DELETE("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteWordGroupRxById(@Path("id") String id);
//根据id获取单词收藏分组
@GET("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<WordGroup>> getWordGroupRxById(@Path("id") String id);
//根据userId获取单词收藏分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getWordGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取用户所收藏的单词分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getCollectWordGroupRxByUserId(@Query("where")String collectAnduserIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取单词收藏分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getWordGroupRxByUserId(@Query("where")String userIdjson);
//获取所有公开的单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/WordGroup?include=user&order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getWordGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/WordGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getWordGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//单词分組收藏模块****************************************************************************
//添加单词分組收藏
@POST("/1/classes/WordGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<WordGroupCollect>> addWordGroupCollect(@Body WordGroupCollect wordGroupCollect);
//删除单词分組收藏
@DELETE("/1/classes/WordGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteWordGroupCollectRxById(@Path("id") String id);
//根据userId获取单词分組收藏,分页展示
@GET("/1/classes/WordGroupCollect?include=wordGroup,user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupCollectResult>> getWordGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和单詞wvxe获取单词分組收藏,分页展示
@GET("/1/classes/WordGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupCollectResult>> getWordGroupCollectRxByUserIdAndwordGroupId(@Query("where")String userIdjson);
//句子分组模块****************************************************************************
//添加句子分组
@POST("/1/classes/SentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceGroup>> addSentenceGroup(@Body SentenceGroup sentenceGroup);
//修改句子分组
@PUT("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentenceGroupRxById(@Path("id") String id,@Body SentenceGroup sentenceGroup);
//删除句子分组
@DELETE("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteSentenceGroupRxById(@Path("id") String id);
//根据id获取句子分组
@GET("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<SentenceGroup>> getSentenceGroupRxById(@Path("id") String id);
//根据userId获取句子分组,分页展示
@GET("/1/classes/SentenceGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取句子分组,分页展示
@GET("/1/classes/SentenceGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 获取所有公开的句子分组
* @param openjson 公开的json
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/SentenceGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordGroupResult>> getSentenceGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//句子收藏分组模块****************************************************************************
//添加句子收藏分组
@POST("/1/classes/SentenceCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceCollectGroup>> addSentenceCollectGroup(@Body SentenceCollectGroup sentenceCollectGroup);
//修改句子收藏分组
@PUT("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentenceCollectGroupRxById(@Path("id") String id,@Body SentenceCollectGroup sentenceCollectGroup);
//删除句子收藏分组
@DELETE("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteSentenceCollectGroupRxById(@Path("id") String id);
//根据id获取句子收藏分组
@GET("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<SentenceCollectGroup>> getSentenceCollectGroupRxById(@Path("id") String id);
//根据userId获取句子收藏分组,分页展示
@GET("/1/classes/SentenceCollectGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceCollectGroupResult>> getSentenceCollectGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取句子收藏分组,分页展示
@GET("/1/classes/SentenceCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceCollectGroupResult>> getSentenceCollectGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//句子分組收藏模块****************************************************************************
//添加句子分組收藏
@POST("/1/classes/SentenceGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceGroupCollect>> addSentenceGroupCollect(@Body SentenceGroupCollect sentenceGroupCollect);
//删除句子分組收藏
@DELETE("/1/classes/SentenceGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteSentenceGroupCollectRxById(@Path("id") String id);
//根据userId获取句子分組收藏
@GET("/1/classes/SentenceGroupCollect?include=sentenceGroup,user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceGroupCollectResult>> getSentenceGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和单詞wvxe获取单词分組收藏,分页展示
@GET("/1/classes/SentenceGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceGroupCollectResult>> getSentenceGroupCollectRxByUserIdAndsentenceGroupId(@Query("where")String userIdAndwordgroupIdjson);
//文章收藏分组模块****************************************************************************
//添加文章收藏分组
@POST("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateGroup>> addTractateGroup(@Body TractateGroup tractateGroup);
//修改文章收藏分组
@PUT("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateGroupRxById(@Path("id") String id,@Body TractateGroup tractateGroup);
//删除文章收藏分组
@DELETE("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteTractateGroupRxById(@Path("id") String id);
//根据userId获取文章收藏分组
@GET("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupResult>> getTractateGroupsRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取文章收藏分组
@GET("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupResult>> getTractateGroupsRxByUserId(@Query("where")String userIdjson);
//根据id获取文章收藏分组
@GET("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<TractateGroup>> getTractateGroupRxById(@Path("id") String id);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/TractateGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupResult>> getTractateGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/TractateGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupResult>> getTractateGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//文章收藏分组模块****************************************************************************
//添加文章收藏分组
@POST("/1/classes/TractateCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateCollectGroup>> addTractateCollectGroup(@Body TractateCollectGroup tractateCollectGroup);
//修改文章收藏分组
@PUT("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateCollectGroupRxById(@Path("id") String id,@Body TractateCollectGroup tractateCollectGroup);
//删除文章收藏分组
@DELETE("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteTractateCollectGroupRxById(@Path("id") String id);
//根据id获取文章收藏分组
@GET("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<TractateCollectGroup>> getTractateCollectGroupRxById(@Path("id") String id);
//根据userId获取文章收藏分组,分页展示
@GET("/1/classes/TractateCollectGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateCollectGroupResult>> getTractateCollectGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取文章收藏分组,分页展示
@GET("/1/classes/TractateCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateCollectGroupResult>> getTractateCollectGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//文章分組收藏模块****************************************************************************
//增加文章分組收藏
@POST("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateGroupCollect>> addTractateGroupCollect(@Body TractateGroupCollect tractateGroupCollect);
//删除文章分組收藏
@DELETE("/1/classes/TractateGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteTractateGroupCollectRxById(@Path("id") String id);
//根据userId获取文章分组收藏分页展示
@GET("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupCollectResult>> getTractateGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和句子分组id获取文章分组收藏分页展示(一般是只返回一个的)
@GET("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateGroupCollectResult>> getTractateGroupCollectRxByUserIdAndsentenceGroupId(@Query("where")String userIdAndtractategroupIdjson);
//单词收藏模块****************************************************************************
//添加单词收藏
@POST("/1/classes/WordCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<WordCollect>> addWordCollect(@Body WordCollect wordCollect);
//删除单词收藏
@DELETE("/1/classes/WordCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteWordCollectRxById(@Path("id") String id);
/**
* 根据userId和单词分組Id获取单词收藏,分页
* @param userIdwordgroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/WordCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordCollectResult>> getWordCollectRxByUserIdAndWordGroupId(@Query("where")String userIdwordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据单词分組Id获取单词收藏,分页
* @param wordgroupIdjson 单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/WordCollect?include=word,wordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<WordCollectResult>> getWordCollectRxByWordGroupId(@Query("where")String wordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//句子收藏模块****************************************************************************
//添加句子收藏
@POST("/1/classes/SentenceCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<SentenceCollect>> addSentenceCollect(@Body SentenceCollect sentenceCollect);
//删除句子收藏
@DELETE("/1/classes/SentenceCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteSentenceCollectRxById(@Path("id") String id);
/**
* 根据userId和句子分組Id获取句子收藏,分页
* @param userIdsentencegroupIdjson userId和句子分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceCollect?include=sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceCollectResult>> getSentenceCollectRxByUserIdAndSentenceGroupId(@Query("where")String userIdsentencegroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据userId和句子分組Id获取句子收藏,分页
* @param userIdsentencegroupIdjson userId和句子分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceCollect?include=sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<SentenceCollectResult>> getSentenceCollectRxBySentenceCollectGroupId(@Query("where")String userIdsentencegroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//文章收藏模块****************************************************************************
//添加文章收藏
@POST("/1/classes/TractateCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<TractateCollect>> addTractateCollect(@Body TractateCollect tractateCollect);
//删除文章收藏
@DELETE("/1/classes/TractateCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<ResponseBody>> deleteTractateCollectRxById(@Path("id") String id);
/**
* 根据userId和文章分組Id获取文章,分页
* @param userIdwordgroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/TractateCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateCollectResult>> getTractateCollectRxByUserIdAndTractateGroupId(@Query("where")String userIdwordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据tractateCollectGroupId获取文章,分页
* @param tractateCollectGroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/TractateCollect?include=tractateId")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09"
})
Observable<Response<TractateCollectResult>> getTractateCollectRxByTractateCollectGroupId(@Query("where")String tractateCollectGroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//上传模块****************************************************************************
@Multipart
@POST("/2/files/{fileName}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
})
Observable<Response<BmobFile>> uploadFile(@Path("fileName") String fileName, @Part MultipartBody.Part filecontenttype,@Header("Content-Type") String type);
@DELETE("/2/files/{cdnName}/{url}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteFile(@Path("cdnName")String cdnName, @Path("url") String url);
//下载文件
@GET("/resource/example.zip")
Call<ResponseBody> downloadFile();
//下载文件自定义url
@GET
Call<ResponseBody> downloadFile(@Url String fileUrl);
//词典模块****************************************************************************
@POST("/1/classes/Dict")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<Dict>> addDict(@Body Dict dict);
//删除词典
@DELETE("/1/classes/Dict/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteDictById(@Path("id") String id);
//修改音标
@PUT("/1/classes/Dict/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateDictRxById(@Path("id") String id,@Body Dict dict);
//获取所有音标
@GET("/1/classes/Dict/?order=order")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09",
"Content-Type: application/json"
})
Observable<Response<DictResult>> getDicts();
}
| UTF-8 | Java | 58,549 | java | RetrofitService.java | Java | [
{
"context": "http.Url;\nimport rx.Observable;\n\n/**\n * Created by yanzl on 16-8-11.\n */\npublic interface RetrofitService ",
"end": 4333,
"score": 0.9996519088745117,
"start": 4328,
"tag": "USERNAME",
"value": "yanzl"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 4618,
"score": 0.9997460842132568,
"start": 4586,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 5030,
"score": 0.999746561050415,
"start": 4998,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 5345,
"score": 0.9997221827507019,
"start": 5313,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 5735,
"score": 0.999727725982666,
"start": 5703,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 6130,
"score": 0.999724805355072,
"start": 6098,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "})\n Observable<Response<User>> loginRx(@Query(\"username\") String username,@Query(\"password\") String passw",
"end": 6240,
"score": 0.6555008292198181,
"start": 6232,
"tag": "USERNAME",
"value": "username"
},
{
"context": "ders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 6398,
"score": 0.5381740927696228,
"start": 6397,
"tag": "KEY",
"value": "3"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 6407,
"score": 0.7234110236167908,
"start": 6406,
"tag": "KEY",
"value": "6"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<User>> getUserByI",
"end": 6491,
"score": 0.9997264742851257,
"start": 6459,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<UserResult>> getU",
"end": 6767,
"score": 0.9997326731681824,
"start": 6735,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 7137,
"score": 0.9997148513793945,
"start": 7105,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 7606,
"score": 0.9997275471687317,
"start": 7574,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 8134,
"score": 0.9997220039367676,
"start": 8102,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 8649,
"score": 0.999714195728302,
"start": 8617,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 9058,
"score": 0.9997355341911316,
"start": 9026,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 9370,
"score": 0.9996268153190613,
"start": 9338,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 9439,
"score": 0.9997312426567078,
"start": 9407,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 9845,
"score": 0.9997391700744629,
"start": 9813,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 10314,
"score": 0.9997367858886719,
"start": 10282,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 10687,
"score": 0.9997355937957764,
"start": 10655,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 10950,
"score": 0.6277093887329102,
"start": 10945,
"tag": "KEY",
"value": "18803"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 10952,
"score": 0.6290841102600098,
"start": 10951,
"tag": "KEY",
"value": "9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 10962,
"score": 0.5981765389442444,
"start": 10955,
"tag": "KEY",
"value": "1956c99"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 10974,
"score": 0.66953045129776,
"start": 10966,
"tag": "KEY",
"value": "96fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 11043,
"score": 0.9997137188911438,
"start": 11011,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 11354,
"score": 0.6931678652763367,
"start": 11347,
"tag": "KEY",
"value": "18803d9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 11361,
"score": 0.617276668548584,
"start": 11357,
"tag": "KEY",
"value": "1956"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 11364,
"score": 0.569017231464386,
"start": 11362,
"tag": "KEY",
"value": "99"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 11376,
"score": 0.5967477560043335,
"start": 11369,
"tag": "KEY",
"value": "6fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<PhoneticsSymbols",
"end": 11445,
"score": 0.9997031092643738,
"start": 11413,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 11703,
"score": 0.8363193869590759,
"start": 11672,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 11772,
"score": 0.9997150301933289,
"start": 11740,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 12113,
"score": 0.9269513487815857,
"start": 12097,
"tag": "KEY",
"value": "2b18803d9dbb1956"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 12116,
"score": 0.9325818419456482,
"start": 12114,
"tag": "KEY",
"value": "99"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2",
"end": 12120,
"score": 0.6930884122848511,
"start": 12118,
"tag": "KEY",
"value": "78"
},
{
"context": "\"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 12126,
"score": 0.8642444610595703,
"start": 12122,
"tag": "KEY",
"value": "fe44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 12197,
"score": 0.9997098445892334,
"start": 12165,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "ders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 12483,
"score": 0.5770624279975891,
"start": 12482,
"tag": "KEY",
"value": "3"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 12507,
"score": 0.7171974778175354,
"start": 12488,
"tag": "KEY",
"value": "1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 12576,
"score": 0.9997050166130066,
"start": 12544,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 12937,
"score": 0.9997076988220215,
"start": 12905,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "fbfd6ca09\",\n \"Content-Type: application/json\",\n })\n Observable<Response<ResponseBody>> u",
"end": 12983,
"score": 0.992017388343811,
"start": 12979,
"tag": "KEY",
"value": "json"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<PhoneticsVoice>>",
"end": 13348,
"score": 0.9997038841247559,
"start": 13316,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 13593,
"score": 0.6951707005500793,
"start": 13587,
"tag": "KEY",
"value": "8803d9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 13600,
"score": 0.6109290719032288,
"start": 13596,
"tag": "KEY",
"value": "1956"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 13603,
"score": 0.5760889649391174,
"start": 13601,
"tag": "KEY",
"value": "99"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<PhoneticsVoiceRe",
"end": 13684,
"score": 0.9996992945671082,
"start": 13652,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 13962,
"score": 0.7604725360870361,
"start": 13931,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<PhoneticsSymbols",
"end": 14031,
"score": 0.9997119903564453,
"start": 13999,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "ders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 14373,
"score": 0.5368320941925049,
"start": 14372,
"tag": "KEY",
"value": "3"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 14375,
"score": 0.5980538129806519,
"start": 14374,
"tag": "KEY",
"value": "9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 14382,
"score": 0.5864976644515991,
"start": 14378,
"tag": "KEY",
"value": "1956"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2a",
"end": 14390,
"score": 0.505499541759491,
"start": 14389,
"tag": "KEY",
"value": "9"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 14466,
"score": 0.9997107982635498,
"start": 14434,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-R",
"end": 14726,
"score": 0.5298364758491516,
"start": 14725,
"tag": "KEY",
"value": "8"
},
{
"context": "ders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 14728,
"score": 0.5683041214942932,
"start": 14727,
"tag": "KEY",
"value": "3"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API",
"end": 14733,
"score": 0.5491193532943726,
"start": 14729,
"tag": "KEY",
"value": "9dbb"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 14737,
"score": 0.5781865119934082,
"start": 14735,
"tag": "KEY",
"value": "56"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 14752,
"score": 0.9986668825149536,
"start": 14748,
"tag": "KEY",
"value": "4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 14821,
"score": 0.9997081756591797,
"start": 14789,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 15170,
"score": 0.999713659286499,
"start": 15138,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<TractateType>> g",
"end": 15558,
"score": 0.9997127056121826,
"start": 15526,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 15857,
"score": 0.9997091293334961,
"start": 15825,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-R",
"end": 16164,
"score": 0.5461536645889282,
"start": 16163,
"tag": "KEY",
"value": "8"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 16168,
"score": 0.507367730140686,
"start": 16167,
"tag": "KEY",
"value": "9"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 16259,
"score": 0.9997200965881348,
"start": 16227,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-R",
"end": 16477,
"score": 0.5538488030433655,
"start": 16476,
"tag": "KEY",
"value": "8"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 16481,
"score": 0.5073519349098206,
"start": 16480,
"tag": "KEY",
"value": "9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-",
"end": 16485,
"score": 0.5228481292724609,
"start": 16484,
"tag": "KEY",
"value": "1"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 16488,
"score": 0.5915944576263428,
"start": 16486,
"tag": "KEY",
"value": "56"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 16572,
"score": 0.9997196793556213,
"start": 16540,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda278",
"end": 16833,
"score": 0.7880398035049438,
"start": 16803,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe446"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 16903,
"score": 0.9997198581695557,
"start": 16871,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 17158,
"score": 0.576317310333252,
"start": 17157,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b",
"end": 17179,
"score": 0.6308545470237732,
"start": 17159,
"tag": "KEY",
"value": "18803d9dbb1956c99ef7"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 17186,
"score": 0.5476487874984741,
"start": 17181,
"tag": "KEY",
"value": "6fe44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<Word>> getWordRx",
"end": 17257,
"score": 0.9997184872627258,
"start": 17225,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-R",
"end": 17437,
"score": 0.599640429019928,
"start": 17436,
"tag": "KEY",
"value": "8"
},
{
"context": "rs({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 17441,
"score": 0.5921992659568787,
"start": 17440,
"tag": "KEY",
"value": "9"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 17532,
"score": 0.9997218251228333,
"start": 17500,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 17724,
"score": 0.6066364645957947,
"start": 17723,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 17732,
"score": 0.8051812052726746,
"start": 17725,
"tag": "KEY",
"value": "18803d9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 17742,
"score": 0.6529471278190613,
"start": 17735,
"tag": "KEY",
"value": "1956c99"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 17752,
"score": 0.6107401847839355,
"start": 17750,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 17823,
"score": 0.9997190833091736,
"start": 17791,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 17996,
"score": 0.6980620622634888,
"start": 17995,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 18004,
"score": 0.6861670613288879,
"start": 17997,
"tag": "KEY",
"value": "18803d9"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 18011,
"score": 0.534435510635376,
"start": 18009,
"tag": "KEY",
"value": "56"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 18024,
"score": 0.7839008569717407,
"start": 18022,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 18095,
"score": 0.9997292160987854,
"start": 18063,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 18352,
"score": 0.9690548777580261,
"start": 18321,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 18421,
"score": 0.9997259974479675,
"start": 18389,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 18765,
"score": 0.9996798634529114,
"start": 18733,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordResult>> getW",
"end": 19075,
"score": 0.9996888637542725,
"start": 19043,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 20249,
"score": 0.6326983571052551,
"start": 20246,
"tag": "KEY",
"value": "803"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 20261,
"score": 0.6050142049789429,
"start": 20256,
"tag": "KEY",
"value": "56c99"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 20271,
"score": 0.5840718746185303,
"start": 20269,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 20342,
"score": 0.999720573425293,
"start": 20310,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 20578,
"score": 0.6426052451133728,
"start": 20577,
"tag": "KEY",
"value": "2"
},
{
"context": "Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 20586,
"score": 0.6751860976219177,
"start": 20580,
"tag": "KEY",
"value": "8803d9"
},
{
"context": "\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-",
"end": 20590,
"score": 0.5226916074752808,
"start": 20589,
"tag": "KEY",
"value": "1"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key:",
"end": 20594,
"score": 0.6408914923667908,
"start": 20591,
"tag": "KEY",
"value": "56c"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 20596,
"score": 0.5918024182319641,
"start": 20595,
"tag": "KEY",
"value": "9"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 20608,
"score": 0.6650809049606323,
"start": 20604,
"tag": "KEY",
"value": "4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 20677,
"score": 0.9997200965881348,
"start": 20645,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 20904,
"score": 0.9578566551208496,
"start": 20873,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 20973,
"score": 0.9997143745422363,
"start": 20941,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<Sentence>> getSen",
"end": 21354,
"score": 0.9997024536132812,
"start": 21322,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 21725,
"score": 0.9997090697288513,
"start": 21693,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 22197,
"score": 0.9997121691703796,
"start": 22165,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 22546,
"score": 0.9992808699607849,
"start": 22514,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 22615,
"score": 0.9997146725654602,
"start": 22583,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 23054,
"score": 0.9784619212150574,
"start": 23022,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 23123,
"score": 0.9997192025184631,
"start": 23091,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 23384,
"score": 0.9869544506072998,
"start": 23353,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 23453,
"score": 0.9997212290763855,
"start": 23421,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 23678,
"score": 0.9805144667625427,
"start": 23646,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 23747,
"score": 0.9997212886810303,
"start": 23715,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<Grammar>> getGram",
"end": 24125,
"score": 0.9996845126152039,
"start": 24093,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 24438,
"score": 0.9996914863586426,
"start": 24406,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 24815,
"score": 0.9996970295906067,
"start": 24783,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda278",
"end": 25214,
"score": 0.828299343585968,
"start": 25201,
"tag": "KEY",
"value": "99ef7896fe446"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 25284,
"score": 0.99973064661026,
"start": 25252,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "ders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-RES",
"end": 25667,
"score": 0.5307018756866455,
"start": 25666,
"tag": "KEY",
"value": "3"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 25676,
"score": 0.5305131673812866,
"start": 25674,
"tag": "KEY",
"value": "56"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 25689,
"score": 0.5228675603866577,
"start": 25687,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 25760,
"score": 0.9997248649597168,
"start": 25728,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 26024,
"score": 0.6785566806793213,
"start": 25993,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 26093,
"score": 0.9997287392616272,
"start": 26061,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 26320,
"score": 0.7991981506347656,
"start": 26289,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 26389,
"score": 0.9997286796569824,
"start": 26357,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<Tractate>> getTra",
"end": 26761,
"score": 0.9996902346611023,
"start": 26729,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 26972,
"score": 0.5452860593795776,
"start": 26970,
"tag": "KEY",
"value": "56"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 26985,
"score": 0.6126874089241028,
"start": 26983,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateResult>> ",
"end": 27056,
"score": 0.9997005462646484,
"start": 27024,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 27536,
"score": 0.6130958199501038,
"start": 27535,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 27566,
"score": 0.8061407208442688,
"start": 27537,
"tag": "KEY",
"value": "18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<TractateResult>>",
"end": 27635,
"score": 0.9996885657310486,
"start": 27603,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<TractateResult>>",
"end": 28211,
"score": 0.9997257590293884,
"start": 28179,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 28657,
"score": 0.9997272491455078,
"start": 28625,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 28996,
"score": 0.9997202754020691,
"start": 28964,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 29274,
"score": 0.5839380621910095,
"start": 29273,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 29282,
"score": 0.7017335891723633,
"start": 29275,
"tag": "KEY",
"value": "18803d9"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 29289,
"score": 0.5650231242179871,
"start": 29287,
"tag": "KEY",
"value": "56"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 29292,
"score": 0.5537973046302795,
"start": 29291,
"tag": "KEY",
"value": "9"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 29302,
"score": 0.6773042678833008,
"start": 29300,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 29373,
"score": 0.9996998906135559,
"start": 29341,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 29610,
"score": 0.9123507142066956,
"start": 29579,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<WordGroup>> getW",
"end": 29679,
"score": 0.9997056126594543,
"start": 29647,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 29890,
"score": 0.6508944630622864,
"start": 29885,
"tag": "KEY",
"value": "803d9"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Ke",
"end": 29896,
"score": 0.514618456363678,
"start": 29895,
"tag": "KEY",
"value": "5"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 29981,
"score": 0.999705970287323,
"start": 29949,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key:",
"end": 30275,
"score": 0.6584034562110901,
"start": 30261,
"tag": "KEY",
"value": "8803d9dbb1956c"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 30277,
"score": 0.6214765906333923,
"start": 30276,
"tag": "KEY",
"value": "9"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda278",
"end": 30288,
"score": 0.5747344493865967,
"start": 30279,
"tag": "KEY",
"value": "7896fe446"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 30358,
"score": 0.9997029304504395,
"start": 30326,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 30748,
"score": 0.9997358918190002,
"start": 30716,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 31108,
"score": 0.9997192025184631,
"start": 31076,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 31506,
"score": 0.9997234344482422,
"start": 31474,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-",
"end": 31887,
"score": 0.6885486245155334,
"start": 31881,
"tag": "KEY",
"value": "8803d9"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 31894,
"score": 0.5934956073760986,
"start": 31892,
"tag": "KEY",
"value": "56"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 31897,
"score": 0.5065402984619141,
"start": 31896,
"tag": "KEY",
"value": "9"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 31978,
"score": 0.9997026324272156,
"start": 31946,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 32256,
"score": 0.5360665917396545,
"start": 32255,
"tag": "KEY",
"value": "2"
},
{
"context": "Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-",
"end": 32268,
"score": 0.6514480710029602,
"start": 32258,
"tag": "KEY",
"value": "8803d9dbb1"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key",
"end": 32271,
"score": 0.6441630721092224,
"start": 32269,
"tag": "KEY",
"value": "56"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 32274,
"score": 0.567241370677948,
"start": 32272,
"tag": "KEY",
"value": "99"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2ad",
"end": 32280,
"score": 0.5060214400291443,
"start": 32279,
"tag": "KEY",
"value": "6"
},
{
"context": "-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 32284,
"score": 0.5291930437088013,
"start": 32282,
"tag": "KEY",
"value": "44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 32355,
"score": 0.9997096657752991,
"start": 32323,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupCollectR",
"end": 32701,
"score": 0.9997055530548096,
"start": 32669,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 33003,
"score": 0.537113606929779,
"start": 33002,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4",
"end": 33021,
"score": 0.7206377387046814,
"start": 33004,
"tag": "KEY",
"value": "18803d9dbb1956c99"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 33033,
"score": 0.8363754749298096,
"start": 33023,
"tag": "KEY",
"value": "7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupCollectR",
"end": 33102,
"score": 0.999727725982666,
"start": 33070,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 33534,
"score": 0.9997121691703796,
"start": 33502,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 33891,
"score": 0.9997218251228333,
"start": 33859,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 34282,
"score": 0.9997226595878601,
"start": 34250,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "eaders({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-R",
"end": 34500,
"score": 0.5300680994987488,
"start": 34499,
"tag": "KEY",
"value": "8"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<SentenceGroup>> ",
"end": 34595,
"score": 0.9997022747993469,
"start": 34563,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceGroupResu",
"end": 34921,
"score": 0.9996865391731262,
"start": 34889,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceGroupResu",
"end": 35268,
"score": 0.9997159838676453,
"start": 35236,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceGroupResu",
"end": 35773,
"score": 0.9997117519378662,
"start": 35741,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordGroupResult>>",
"end": 36183,
"score": 0.9997184872627258,
"start": 36151,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 36664,
"score": 0.9997182488441467,
"start": 36632,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 37058,
"score": 0.9997223019599915,
"start": 37026,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 37479,
"score": 0.9997153282165527,
"start": 37447,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<SentenceCollectG",
"end": 37808,
"score": 0.9996957778930664,
"start": 37776,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceCollectGr",
"end": 38157,
"score": 0.9997151494026184,
"start": 38125,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 38445,
"score": 0.9990039467811584,
"start": 38438,
"tag": "KEY",
"value": "6fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceCollectGr",
"end": 38514,
"score": 0.9997279047966003,
"start": 38482,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 39001,
"score": 0.999725341796875,
"start": 38969,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 39398,
"score": 0.9997257590293884,
"start": 39366,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceGroupColl",
"end": 39751,
"score": 0.9997215270996094,
"start": 39719,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceGroupColl",
"end": 40165,
"score": 0.9996922612190247,
"start": 40133,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 40626,
"score": 0.9996848106384277,
"start": 40594,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 40985,
"score": 0.9996945858001709,
"start": 40953,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 41309,
"score": 0.9995476007461548,
"start": 41277,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 41378,
"score": 0.9997186660766602,
"start": 41346,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupResu",
"end": 41690,
"score": 0.9997127056121826,
"start": 41658,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupResu",
"end": 42072,
"score": 0.9997279644012451,
"start": 42040,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<TractateGroup>> ",
"end": 42406,
"score": 0.9997200965881348,
"start": 42374,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupResu",
"end": 42748,
"score": 0.9997139573097229,
"start": 42716,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupResu",
"end": 43170,
"score": 0.9997046589851379,
"start": 43138,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 43642,
"score": 0.9997096061706543,
"start": 43610,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 44036,
"score": 0.9997086524963379,
"start": 44004,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 44457,
"score": 0.9997060298919678,
"start": 44425,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<TractateCollectG",
"end": 44786,
"score": 0.9997076988220215,
"start": 44754,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateCollectGr",
"end": 45135,
"score": 0.9996926188468933,
"start": 45103,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateCollectGr",
"end": 45492,
"score": 0.9997205138206482,
"start": 45460,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 46006,
"score": 0.9997181296348572,
"start": 45974,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 46403,
"score": 0.9997174143791199,
"start": 46371,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupColl",
"end": 46733,
"score": 0.9997250437736511,
"start": 46701,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateGroupColl",
"end": 47157,
"score": 0.9997069239616394,
"start": 47125,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 47618,
"score": 0.9997281432151794,
"start": 47586,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 47899,
"score": 0.9997413158416748,
"start": 47868,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 47968,
"score": 0.999710738658905,
"start": 47936,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordCollectResult",
"end": 48416,
"score": 0.9997184872627258,
"start": 48384,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<WordCollectResult",
"end": 48957,
"score": 0.9997186064720154,
"start": 48925,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bm",
"end": 49328,
"score": 0.6063166260719299,
"start": 49327,
"tag": "KEY",
"value": "2"
},
{
"context": "@Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2",
"end": 49350,
"score": 0.6630357503890991,
"start": 49329,
"tag": "KEY",
"value": "18803d9dbb1956c99ef78"
},
{
"context": " \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda27",
"end": 49356,
"score": 0.6164447665214539,
"start": 49351,
"tag": "KEY",
"value": "6fe44"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 49427,
"score": 0.9997043609619141,
"start": 49395,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 49797,
"score": 0.9996832013130188,
"start": 49765,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceCollectRe",
"end": 50274,
"score": 0.999701201915741,
"start": 50242,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<SentenceCollectRe",
"end": 50855,
"score": 0.9996793866157532,
"start": 50823,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 51356,
"score": 0.9996932148933411,
"start": 51324,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n })\n Observable<Response<ResponseBody>> d",
"end": 51726,
"score": 0.9996940493583679,
"start": 51694,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 52111,
"score": 0.9859315156936646,
"start": 52079,
"tag": "KEY",
"value": "02b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateCollectRe",
"end": 52180,
"score": 0.9997068047523499,
"start": 52148,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\"\n })\n Observable<Response<TractateCollectRe",
"end": 52765,
"score": 0.9996905326843262,
"start": 52733,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n\n\n })\n Observable<Response<BmobFile>> upl",
"end": 53258,
"score": 0.9997112154960632,
"start": 53226,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": " @Headers({\n \"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785",
"end": 53557,
"score": 0.999724805355072,
"start": 53526,
"tag": "KEY",
"value": "2b18803d9dbb1956c99ef7896fe4466"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n\n ",
"end": 53626,
"score": 0.9997024536132812,
"start": 53594,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 54232,
"score": 0.9997007846832275,
"start": 54200,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 54545,
"score": 0.9997053146362305,
"start": 54513,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\",\n ",
"end": 54877,
"score": 0.9997045397758484,
"start": 54845,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
},
{
"context": "9ef7896fe4466\",\n \"X-Bmob-REST-API-Key: 4c7b2adda2785883c546efdfbfd6ca09\",\n \"Content-Type: application/json\"\n ",
"end": 55236,
"score": 0.9997091293334961,
"start": 55204,
"tag": "KEY",
"value": "4c7b2adda2785883c546efdfbfd6ca09"
}
] | null | [] | package com.englishlearn.myapplication.data.source.remote.bmob.service;
import com.englishlearn.myapplication.data.BmobFile;
import com.englishlearn.myapplication.data.Dict;
import com.englishlearn.myapplication.data.Grammar;
import com.englishlearn.myapplication.data.PhoneticsSymbols;
import com.englishlearn.myapplication.data.PhoneticsVoice;
import com.englishlearn.myapplication.data.Sentence;
import com.englishlearn.myapplication.data.SentenceCollect;
import com.englishlearn.myapplication.data.SentenceCollectGroup;
import com.englishlearn.myapplication.data.SentenceGroup;
import com.englishlearn.myapplication.data.SentenceGroupCollect;
import com.englishlearn.myapplication.data.Tractate;
import com.englishlearn.myapplication.data.TractateCollect;
import com.englishlearn.myapplication.data.TractateCollectGroup;
import com.englishlearn.myapplication.data.TractateGroup;
import com.englishlearn.myapplication.data.TractateGroupCollect;
import com.englishlearn.myapplication.data.TractateType;
import com.englishlearn.myapplication.data.User;
import com.englishlearn.myapplication.data.Word;
import com.englishlearn.myapplication.data.WordCollect;
import com.englishlearn.myapplication.data.WordGroup;
import com.englishlearn.myapplication.data.WordGroupCollect;
import com.englishlearn.myapplication.data.source.remote.bmob.BatchRequest;
import com.englishlearn.myapplication.data.source.remote.bmob.BmobCreateOrLoginUserByPhoneRequest;
import com.englishlearn.myapplication.data.source.remote.bmob.DictResult;
import com.englishlearn.myapplication.data.source.remote.bmob.EmailVerify;
import com.englishlearn.myapplication.data.source.remote.bmob.GrammarResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetEmail;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetMobile;
import com.englishlearn.myapplication.data.source.remote.bmob.PasswordResetOldPwd;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsSymbolsResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsSymbolsVoicesResult;
import com.englishlearn.myapplication.data.source.remote.bmob.PhoneticsVoiceResult;
import com.englishlearn.myapplication.data.source.remote.bmob.QuerySmsResult;
import com.englishlearn.myapplication.data.source.remote.bmob.RequestSmsCode;
import com.englishlearn.myapplication.data.source.remote.bmob.RequestSmsCodeResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceCollectGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SentenceResult;
import com.englishlearn.myapplication.data.source.remote.bmob.SmsCodeVerify;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateCollectGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateResult;
import com.englishlearn.myapplication.data.source.remote.bmob.TractateTypeResult;
import com.englishlearn.myapplication.data.source.remote.bmob.UserResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordGroupCollectResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordGroupResult;
import com.englishlearn.myapplication.data.source.remote.bmob.WordResult;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;
import rx.Observable;
/**
* Created by yanzl on 16-8-11.
*/
public interface RetrofitService {
String BMOBAPI = "https://api.bmob.cn";
//指操作数据
@POST("/1/batch")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> batchPost(@Body BatchRequest batchRequest);
//用户模块****************************************************************************
//注册用户
@POST("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<User>> createUserRx(@Body User user);
//注册或登陆用户(手机号+验证码)
@POST("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<User>> createOrLoginUserByPhoneRx(@Body BmobCreateOrLoginUserByPhoneRequest bmobCreateOrLoginUserByPhoneRequest);
//修改用户
@PUT("/1/users/{objectId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<User>> updateUserRx(@Header("X-Bmob-Session-Token") String sessionToken,@Path("objectId")String objectId, @Body User user);
//登陆用户(用户名密码)
@GET("/1/login")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<User>> loginRx(@Query("username") String username,@Query("password") String password);
//根据Id获取用户
@GET("/1/users/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<User>> getUserByIdRx(@Path("id") String id);
//根据用户名获取用户,或者邮箱,手机
@GET("/1/users")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<UserResult>> getUserByNameRx(@Query("where")String usernameJson);
/**
* 通过邮件重置密码
* @param passwordResetEmail
* @return
*/
@POST("/1/requestPasswordReset")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByEmail(@Body PasswordResetEmail passwordResetEmail);
/**
* 通过手机验证码重置密码
* @param smsCode
* @param passwordResetMobile
* @return
*/
@PUT("/1/resetPasswordBySmsCode/{smsCode}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByMobile(@Path("smsCode")String smsCode, @Body PasswordResetMobile passwordResetMobile);
/**
* 修改密码,使用旧密码
* @param sessionToken
* @param objectId
* @param passwordResetOldPwd
* @return
*/
@PUT("/1/updateUserPassword/{objectId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> passwordResetByOldPassword(@Header("X-Bmob-Session-Token") String sessionToken, @Path("objectId")String objectId, @Body PasswordResetOldPwd passwordResetOldPwd);
/**
* 请求短信验证码
* @param requestSmsCode
* @return
*/
@POST("/1/requestSmsCode")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<RequestSmsCodeResult>> requestSmsCode(@Body RequestSmsCode requestSmsCode);
/**
* 查询短信发送状态
* @param smsId
* @return
*/
@GET("/1/querySms/{smsId}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<QuerySmsResult> querySms(@Path("smsId")String smsId);
/**
* 验证邮箱
* @param emailVerify
* @return
*/
@POST("/1/requestEmailVerify")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> emailVerify(@Body EmailVerify emailVerify);
/**
* 验证短信验证码
* @param smsCodeVerify
* @return
*/
@POST("/1/verifySmsCode/{smsCode}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> smsCodeVerify(@Path("smsCode") String smsCode,@Body SmsCodeVerify smsCodeVerify);
//音标模块****************************************************************************
//增加音标
@POST("/1/classes/PhoneticsSymbols")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<PhoneticsSymbols>> addPhoneticsSymbols(@Body PhoneticsSymbols phoneticsSymbols);
//删除音标
@DELETE("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deletePhoneticsSymbolsById(@Path("id") String id);
//修改音标
@PUT("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updatePhoneticsSymbolsRxById(@Path("id") String id,@Body PhoneticsSymbols phoneticsSymbols);
//根据id获取音标
@GET("/1/classes/PhoneticsSymbols/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<PhoneticsSymbols>> getPhoneticsSymbolsRxById(@Path("id") String id);
//获取所有音标
@GET("/1/classes/PhoneticsSymbols?include=wordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<PhoneticsSymbolsResult>> getPhoneticsSymbolsRx();
//音标单词模块****************************************************************************
//增加音标单词
@POST("/1/classes/PhoneticsVoice")
@Headers({
"X-Bmob-Application-Id: 0<KEY>c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<PhoneticsVoice>> addPhoneticsSymbolsVoice(@Body PhoneticsVoice phoneticsSymbolsVoice);
//删除音标单词
@DELETE("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deletePhoneticsSymbolsVoiceById(@Path("id") String id);
//修改音标单词
@PUT("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updatePhoneticsSymbolsVoiceRxById(@Path("id") String id, @Body PhoneticsVoice phoneticsSymbolsVoice);
//根据id获取音标单词
@GET("/1/classes/PhoneticsVoice/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<PhoneticsVoice>> getPhoneticsSymbolsVoiceRxById(@Path("id") String phoneticsSymbolsVoiceId);
//根据id获取音标单词
@GET("/1/classes/PhoneticsVoice/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<PhoneticsVoiceResult>> getPhoneticsSymbolsVoiceRx(@Query("limit") int limit, @Query("skip")int skip);
//根据音标id获取音标单词
@GET("/1/classes/PhoneticsVoice/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<PhoneticsSymbolsVoicesResult>> getPhoneticsSymbolsVoicesRx(@Query("where")String phoneticsSymbolsIdjson);
//文章分类模块****************************************************************************
//增加文章分类
@POST("/1/classes/TractateType")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateType>> addTractateType(@Body TractateType tractateType);
//删除文章分类
@DELETE("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteTractateTypeById(@Path("id") String id);
//修改文章分类
@PUT("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateTypeRxById(@Path("id") String id,@Body TractateType tractateType);
//根据id获取文章分类
@GET("/1/classes/TractateType/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<TractateType>> getTractateTypeRxById(@Path("id") String id);
//获取所有文章分类
@GET("/1/classes/TractateType")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateTypeResult>> getTractateTypeRx();
//单词模块****************************************************************************
//添加单词
@POST("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<Word>> addWord(@Body Word word);
//删除单词
@DELETE("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteWordById(@Path("id") String id);
//修改单词
@PUT("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateWordRxById(@Path("id") String id,@Body Word word);
//根据id获取单词
@GET("/1/classes/Word/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<Word>> getWordRxById(@Path("id") String id);
//根据名称获取单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordRxByName(@Query("where")String wordjson);
//获取所有的单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordsRx();
//获取所有的单词
@GET("/1/classes/Word?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordsRx(@Query("limit")int limit, @Query("skip")int skip);
//获取符合条件的所有的单词
@GET("/1/classes/Word?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordsRx(@Query("where") String wordson, @Query("limit")int limit, @Query("skip")int skip);
//查询音标关联收藏分组的所有单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordsRxByPhoneticsId( @Query("where") String phoneticsJson);
//查询收藏分组的所有单词
@GET("/1/classes/Word")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordResult>> getWordsRxByWordGroupId( @Query("where") String wordgroupidJson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 如果您的查询条件某个列值要匹配另一个查询的返回值,举例有一个队伍(Team)保存了每个城市的得分情况且用户表中有一列为用户家乡(hometown), 您可以创建一个查询来寻找用户的家乡是得分大于0.5的城市的所有运动员, 就像这样查询:
curl -X GET \
-H "X-Bmob-Application-Id: Your Application ID" \
-H "X-Bmob-REST-API-Key: Your REST API Key" \
-G \
--data-urlencode 'where={"hometown":{"$select":{"query":{"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}' \
https://api.bmob.cn/1/users
反之查询Team中得分小于等于0.5的城市的所有运动员,构造查询如下:
curl -X GET \
-H "X-Bmob-Application-Id: Your Application ID" \
-H "X-Bmob-REST-API-Key: Your REST API Key" \
-G \
--data-urlencode 'where={"hometown":{"$dontSelect":{"query":{"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}' \
https://api.bmob.cn/1/users
* @param
* @return
*/
//句子模块****************************************************************************
//添加句子
@POST("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<Sentence>> addSentenceRx(@Body Sentence sentence);
//删除句子
@DELETE("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteSentenceRxById(@Path("id") String id);
//修改句子
@PUT("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentencRxById(@Path("id") String id,@Body Sentence sentence);
//根据Id获取句子(Observable)
@GET("/1/classes/Sentence/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<Sentence>> getSentenceRxById(@Path("id") String id);
/**
* 获取所有句子(分页)
* @param limit 取几条
* @param skip 从第几条开始取
* @return
*/
@GET("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRx(@Query("limit") int limit, @Query("skip")int skip);
/**
* 分页搜索自定义的正则
* @param regex 搜索的单词
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRx(@Query("where") String regex, @Query("limit")int limit, @Query("skip")int skip);
//查询句子分组的所有句子
@GET("/1/classes/Sentence?include=sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceResult>> getSentencesRxBySentenceGroupId( @Query("where") String sentencegroupidJson, @Query("limit")int limit, @Query("skip")int skip);
//语法模块****************************************************************************
//添加语法
@POST("/1/classes/Grammar")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<Grammar>> addGrammarRx(@Body Grammar grammar);
//删除語法
@DELETE("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteGrammarRxById(@Path("id") String id);
//修改讲法
@PUT("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateGrammarRxById(@Path("id") String id,@Body Grammar grammar);
//根据Id获取语法(Observable)
@GET("/1/classes/Grammar/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<Grammar>> getGrammarRxById(@Path("id") String id);
//获取所有语法
@GET("/1/classes/Grammar?include=wordGroup,sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx();
/**
* 获取所有语法(分页)
* @return
*/
@GET("/1/classes/Grammar?include=wordGroup,sentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx(@Query("limit") int limit, @Query("skip")int skip);
/**
* 分页搜索自定义的正则
* @param regex 搜索的单词
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Grammar")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<GrammarResult>> getGrammarsRx(@Query("where") String regex, @Query("limit")int limit, @Query("skip")int skip);
//文章模块****************************************************************************
//添加文章
@POST("/1/classes/Tractate")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<Tractate>> addTractate(@Body Tractate tractate);
//删除文章
@DELETE("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteTractateRxById(@Path("id") String id);
//修改文章
@PUT("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateRxById(@Path("id") String id,@Body Tractate tractate);
//根据文章id获取文章
@GET("/1/classes/Tractate/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<Tractate>> getTractateRxById(@Path("id") String id);
//根据分类id获取文章列表分页展示
@GET("/1/classes/Tractate")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateResult>> getTractateRxByTractateTypeId(@Query("where")String tractatetypeidjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据分类id,关键词的正则,获取文章列表分页展示
* @param tractategroupidjson 搜索的tractatetypeid
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Tractate?include=userId,tractatetypeId,tractateGroupId&order=sort")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<TractateResult>> getTractateRxByTractateGroupId(@Query("where") String tractategroupidjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据分类id,关键词的正则,获取文章列表分页展示
* @param serachjson 搜索的tractatetypeid
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/Tractate?include=userId,tractatetypeId,tractateGroupId&order=sort")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<TractateResult>> getTractatesRx(@Query("where") String serachjson, @Query("limit")int limit, @Query("skip")int skip);
//单词收藏分组模块****************************************************************************
//添加单词收藏分组
@POST("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<WordGroup>> addWordGroup(@Body WordGroup wordGroup);
//修改单词收藏分组
@PUT("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateWordGroupRxById(@Path("id") String id,@Body WordGroup wordGroup);
//删除单词收藏分组
@DELETE("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteWordGroupRxById(@Path("id") String id);
//根据id获取单词收藏分组
@GET("/1/classes/WordGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<WordGroup>> getWordGroupRxById(@Path("id") String id);
//根据userId获取单词收藏分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getWordGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取用户所收藏的单词分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b1<KEY>99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getCollectWordGroupRxByUserId(@Query("where")String collectAnduserIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取单词收藏分组分页展示
@GET("/1/classes/WordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getWordGroupRxByUserId(@Query("where")String userIdjson);
//获取所有公开的单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/WordGroup?include=user&order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getWordGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/WordGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getWordGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//单词分組收藏模块****************************************************************************
//添加单词分組收藏
@POST("/1/classes/WordGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<WordGroupCollect>> addWordGroupCollect(@Body WordGroupCollect wordGroupCollect);
//删除单词分組收藏
@DELETE("/1/classes/WordGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteWordGroupCollectRxById(@Path("id") String id);
//根据userId获取单词分組收藏,分页展示
@GET("/1/classes/WordGroupCollect?include=wordGroup,user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupCollectResult>> getWordGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和单詞wvxe获取单词分組收藏,分页展示
@GET("/1/classes/WordGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b<KEY>ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupCollectResult>> getWordGroupCollectRxByUserIdAndwordGroupId(@Query("where")String userIdjson);
//句子分组模块****************************************************************************
//添加句子分组
@POST("/1/classes/SentenceGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceGroup>> addSentenceGroup(@Body SentenceGroup sentenceGroup);
//修改句子分组
@PUT("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentenceGroupRxById(@Path("id") String id,@Body SentenceGroup sentenceGroup);
//删除句子分组
@DELETE("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteSentenceGroupRxById(@Path("id") String id);
//根据id获取句子分组
@GET("/1/classes/SentenceGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<SentenceGroup>> getSentenceGroupRxById(@Path("id") String id);
//根据userId获取句子分组,分页展示
@GET("/1/classes/SentenceGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取句子分组,分页展示
@GET("/1/classes/SentenceGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 获取所有公开的句子分组
* @param openjson 公开的json
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceGroupResult>> getSentenceGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/SentenceGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordGroupResult>> getSentenceGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//句子收藏分组模块****************************************************************************
//添加句子收藏分组
@POST("/1/classes/SentenceCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceCollectGroup>> addSentenceCollectGroup(@Body SentenceCollectGroup sentenceCollectGroup);
//修改句子收藏分组
@PUT("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateSentenceCollectGroupRxById(@Path("id") String id,@Body SentenceCollectGroup sentenceCollectGroup);
//删除句子收藏分组
@DELETE("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteSentenceCollectGroupRxById(@Path("id") String id);
//根据id获取句子收藏分组
@GET("/1/classes/SentenceCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<SentenceCollectGroup>> getSentenceCollectGroupRxById(@Path("id") String id);
//根据userId获取句子收藏分组,分页展示
@GET("/1/classes/SentenceCollectGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceCollectGroupResult>> getSentenceCollectGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取句子收藏分组,分页展示
@GET("/1/classes/SentenceCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceCollectGroupResult>> getSentenceCollectGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//句子分組收藏模块****************************************************************************
//添加句子分組收藏
@POST("/1/classes/SentenceGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceGroupCollect>> addSentenceGroupCollect(@Body SentenceGroupCollect sentenceGroupCollect);
//删除句子分組收藏
@DELETE("/1/classes/SentenceGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteSentenceGroupCollectRxById(@Path("id") String id);
//根据userId获取句子分組收藏
@GET("/1/classes/SentenceGroupCollect?include=sentenceGroup,user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceGroupCollectResult>> getSentenceGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和单詞wvxe获取单词分組收藏,分页展示
@GET("/1/classes/SentenceGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceGroupCollectResult>> getSentenceGroupCollectRxByUserIdAndsentenceGroupId(@Query("where")String userIdAndwordgroupIdjson);
//文章收藏分组模块****************************************************************************
//添加文章收藏分组
@POST("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateGroup>> addTractateGroup(@Body TractateGroup tractateGroup);
//修改文章收藏分组
@PUT("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateGroupRxById(@Path("id") String id,@Body TractateGroup tractateGroup);
//删除文章收藏分组
@DELETE("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteTractateGroupRxById(@Path("id") String id);
//根据userId获取文章收藏分组
@GET("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupResult>> getTractateGroupsRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId获取文章收藏分组
@GET("/1/classes/TractateGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupResult>> getTractateGroupsRxByUserId(@Query("where")String userIdjson);
//根据id获取文章收藏分组
@GET("/1/classes/TractateGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<TractateGroup>> getTractateGroupRxById(@Path("id") String id);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/TractateGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupResult>> getTractateGroupsByOpenAndNotCollectRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//获取所有公开的未收藏单词分组分页展示,按时间降序(从近到远)
@GET("/1/classes/TractateGroup?order=-createdAt")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupResult>> getTractateGroupsByOpenRx(@Query("where") String openjson, @Query("limit")int limit, @Query("skip")int skip);
//文章收藏分组模块****************************************************************************
//添加文章收藏分组
@POST("/1/classes/TractateCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateCollectGroup>> addTractateCollectGroup(@Body TractateCollectGroup tractateCollectGroup);
//修改文章收藏分组
@PUT("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateTractateCollectGroupRxById(@Path("id") String id,@Body TractateCollectGroup tractateCollectGroup);
//删除文章收藏分组
@DELETE("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteTractateCollectGroupRxById(@Path("id") String id);
//根据id获取文章收藏分组
@GET("/1/classes/TractateCollectGroup/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<TractateCollectGroup>> getTractateCollectGroupRxById(@Path("id") String id);
//根据userId获取文章收藏分组,分页展示
@GET("/1/classes/TractateCollectGroup?include=user")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateCollectGroupResult>> getTractateCollectGroupRxByUserId(@Query("where")String userIdjson);
//根据userId获取文章收藏分组,分页展示
@GET("/1/classes/TractateCollectGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateCollectGroupResult>> getTractateCollectGroupRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//文章分組收藏模块****************************************************************************
//增加文章分組收藏
@POST("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateGroupCollect>> addTractateGroupCollect(@Body TractateGroupCollect tractateGroupCollect);
//删除文章分組收藏
@DELETE("/1/classes/TractateGroupCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteTractateGroupCollectRxById(@Path("id") String id);
//根据userId获取文章分组收藏分页展示
@GET("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupCollectResult>> getTractateGroupCollectRxByUserId(@Query("where")String userIdjson, @Query("limit")int limit, @Query("skip")int skip);
//根据userId和句子分组id获取文章分组收藏分页展示(一般是只返回一个的)
@GET("/1/classes/TractateGroupCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateGroupCollectResult>> getTractateGroupCollectRxByUserIdAndsentenceGroupId(@Query("where")String userIdAndtractategroupIdjson);
//单词收藏模块****************************************************************************
//添加单词收藏
@POST("/1/classes/WordCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<WordCollect>> addWordCollect(@Body WordCollect wordCollect);
//删除单词收藏
@DELETE("/1/classes/WordCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteWordCollectRxById(@Path("id") String id);
/**
* 根据userId和单词分組Id获取单词收藏,分页
* @param userIdwordgroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/WordCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordCollectResult>> getWordCollectRxByUserIdAndWordGroupId(@Query("where")String userIdwordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据单词分組Id获取单词收藏,分页
* @param wordgroupIdjson 单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/WordCollect?include=word,wordGroup")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<WordCollectResult>> getWordCollectRxByWordGroupId(@Query("where")String wordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//句子收藏模块****************************************************************************
//添加句子收藏
@POST("/1/classes/SentenceCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<SentenceCollect>> addSentenceCollect(@Body SentenceCollect sentenceCollect);
//删除句子收藏
@DELETE("/1/classes/SentenceCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteSentenceCollectRxById(@Path("id") String id);
/**
* 根据userId和句子分組Id获取句子收藏,分页
* @param userIdsentencegroupIdjson userId和句子分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceCollect?include=sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceCollectResult>> getSentenceCollectRxByUserIdAndSentenceGroupId(@Query("where")String userIdsentencegroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据userId和句子分組Id获取句子收藏,分页
* @param userIdsentencegroupIdjson userId和句子分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/SentenceCollect?include=sentence")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<SentenceCollectResult>> getSentenceCollectRxBySentenceCollectGroupId(@Query("where")String userIdsentencegroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//文章收藏模块****************************************************************************
//添加文章收藏
@POST("/1/classes/TractateCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<TractateCollect>> addTractateCollect(@Body TractateCollect tractateCollect);
//删除文章收藏
@DELETE("/1/classes/TractateCollect/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<ResponseBody>> deleteTractateCollectRxById(@Path("id") String id);
/**
* 根据userId和文章分組Id获取文章,分页
* @param userIdwordgroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/TractateCollect")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateCollectResult>> getTractateCollectRxByUserIdAndTractateGroupId(@Query("where")String userIdwordgroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
/**
* 根据tractateCollectGroupId获取文章,分页
* @param tractateCollectGroupIdjson userId和单词分組Id
* @param limit 取几条
* @param skip 从第几条取
* @return
*/
@GET("/1/classes/TractateCollect?include=tractateId")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>"
})
Observable<Response<TractateCollectResult>> getTractateCollectRxByTractateCollectGroupId(@Query("where")String tractateCollectGroupIdjson, @Query("limit")int limit, @Query("skip")int skip);
//上传模块****************************************************************************
@Multipart
@POST("/2/files/{fileName}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
})
Observable<Response<BmobFile>> uploadFile(@Path("fileName") String fileName, @Part MultipartBody.Part filecontenttype,@Header("Content-Type") String type);
@DELETE("/2/files/{cdnName}/{url}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteFile(@Path("cdnName")String cdnName, @Path("url") String url);
//下载文件
@GET("/resource/example.zip")
Call<ResponseBody> downloadFile();
//下载文件自定义url
@GET
Call<ResponseBody> downloadFile(@Url String fileUrl);
//词典模块****************************************************************************
@POST("/1/classes/Dict")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<Dict>> addDict(@Body Dict dict);
//删除词典
@DELETE("/1/classes/Dict/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<ResponseBody>> deleteDictById(@Path("id") String id);
//修改音标
@PUT("/1/classes/Dict/{id}/")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json",
})
Observable<Response<ResponseBody>> updateDictRxById(@Path("id") String id,@Body Dict dict);
//获取所有音标
@GET("/1/classes/Dict/?order=order")
@Headers({
"X-Bmob-Application-Id: 02b18803d9dbb1956c99ef7896fe4466",
"X-Bmob-REST-API-Key: <KEY>",
"Content-Type: application/json"
})
Observable<Response<DictResult>> getDicts();
}
| 55,061 | 0.668016 | 0.577255 | 1,427 | 37.782761 | 37.455177 | 200 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.379117 | false | false | 13 |
1c795b38bb1d002187360ae7218f7feff4803e96 | 25,348,896,986,660 | f6da995cca6ad4faa415cebac914dbec773128da | /test/src/main/java/com/lcc/demo/design_patterns/Task1.java | bed409f8c40f119c0a6ad34bc939acbabc543f23 | [] | no_license | lcc929/lcc-demo | https://github.com/lcc929/lcc-demo | ceaeac1b9a9e25815b1780dc6ade65c92a449daa | ee24c6be19277ac5a7d690bcdaea3a1a31fa3828 | refs/heads/master | 2020-04-02T21:41:15.773000 | 2019-06-30T18:11:34 | 2019-06-30T18:11:34 | 154,808,410 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lcc.demo.design_patterns;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
* @author lcc
* @version 2019-06-01
*/
public class Task1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入第一个数");
String firstNum = scanner.next();
if (firstNum == null || "".equals(firstNum)) {
throw new IllegalArgumentException();
}
Double firstNumber = Double.valueOf(firstNum);
System.out.println("请输入以下操作符: +、-、*、/");
String operation = scanner.next();
if (operation == null || "".equals(operation)) {
throw new IllegalArgumentException();
}
Operation op = OperationFactory.getOperation(operation);
System.out.println("请输入第二个数");
String secondNum = scanner.next();
if (secondNum == null || "".equals(secondNum)) {
throw new IllegalArgumentException();
}
Double secondNumber = Double.valueOf(secondNum);
Double result = op.calculate(firstNumber, secondNumber);
System.out.println(result);
}
static class OperationFactory {
private static final Map<String, Operation> OPERATION_MAP = new HashMap<>();
static {
OPERATION_MAP.put("+", new Plus());
OPERATION_MAP.put("-", new Minus());
OPERATION_MAP.put("*", new Multiply());
OPERATION_MAP.put("/", new Divide());
}
static Operation getOperation(String operation) {
Operation op = OPERATION_MAP.get(operation);
if (op == null) {
throw new IllegalArgumentException("操作符输入错误");
}
return op;
}
static class Plus implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.add(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Minus implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.subtract(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Multiply implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.multiply(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Divide implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
if (0D == secondNum) {
throw new IllegalArgumentException("被除数不可为0");
}
return new BigDecimal(firstNum.toString())
.divide(new BigDecimal(secondNum.toString()), RoundingMode.HALF_UP)
.doubleValue();
}
}
}
interface Operation {
Double calculate(Double firstNum, Double secondNum);
}
}
| UTF-8 | Java | 3,081 | java | Task1.java | Java | [
{
"context": "til.Map;\nimport java.util.Scanner;\n\n/**\n * @author lcc\n * @version 2019-06-01\n */\npublic class Task1 {\n\n",
"end": 192,
"score": 0.9996287226676941,
"start": 189,
"tag": "USERNAME",
"value": "lcc"
}
] | null | [] | package com.lcc.demo.design_patterns;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
* @author lcc
* @version 2019-06-01
*/
public class Task1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入第一个数");
String firstNum = scanner.next();
if (firstNum == null || "".equals(firstNum)) {
throw new IllegalArgumentException();
}
Double firstNumber = Double.valueOf(firstNum);
System.out.println("请输入以下操作符: +、-、*、/");
String operation = scanner.next();
if (operation == null || "".equals(operation)) {
throw new IllegalArgumentException();
}
Operation op = OperationFactory.getOperation(operation);
System.out.println("请输入第二个数");
String secondNum = scanner.next();
if (secondNum == null || "".equals(secondNum)) {
throw new IllegalArgumentException();
}
Double secondNumber = Double.valueOf(secondNum);
Double result = op.calculate(firstNumber, secondNumber);
System.out.println(result);
}
static class OperationFactory {
private static final Map<String, Operation> OPERATION_MAP = new HashMap<>();
static {
OPERATION_MAP.put("+", new Plus());
OPERATION_MAP.put("-", new Minus());
OPERATION_MAP.put("*", new Multiply());
OPERATION_MAP.put("/", new Divide());
}
static Operation getOperation(String operation) {
Operation op = OPERATION_MAP.get(operation);
if (op == null) {
throw new IllegalArgumentException("操作符输入错误");
}
return op;
}
static class Plus implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.add(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Minus implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.subtract(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Multiply implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
return new BigDecimal(firstNum.toString())
.multiply(new BigDecimal(secondNum.toString()))
.doubleValue();
}
}
static class Divide implements Operation {
@Override
public Double calculate(Double firstNum, Double secondNum) {
if (0D == secondNum) {
throw new IllegalArgumentException("被除数不可为0");
}
return new BigDecimal(firstNum.toString())
.divide(new BigDecimal(secondNum.toString()), RoundingMode.HALF_UP)
.doubleValue();
}
}
}
interface Operation {
Double calculate(Double firstNum, Double secondNum);
}
}
| 3,081 | 0.639268 | 0.635607 | 107 | 27.084112 | 22.557972 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.495327 | false | false | 13 |
b6550179b60959d252e97f57ca4d8cd9286104d4 | 18,176,301,656,847 | 1dc44fbd22c344fe8ecfa0cca363dfcd1f160b92 | /src/br/com/tremn/crm/model/entity/enumeration/Gender.java | 55c39310552934d1a7c2c045f0e5a801a454fef4 | [] | no_license | solkam/TremnCRM | https://github.com/solkam/TremnCRM | 4d6ecd9a3f442c731592c2c0f300cfb766ed2dce | 1ab381b338c96cea1f1b78c42605a0ed919dd569 | refs/heads/master | 2020-12-09T19:37:09.659000 | 2016-08-23T00:50:03 | 2016-08-23T00:50:03 | 29,858,931 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.tremn.crm.model.entity.enumeration;
/**
* Representa os generos
* @author Solkam
* @since 01 FEV 2015
*/
public enum Gender {
M("Masculino")
,
F("Feminino")
;
private final String description;
private Gender(String d) {
this.description = d;
}
public String getDescription() {
return description;
}
}
| UTF-8 | Java | 372 | java | Gender.java | Java | [
{
"context": "tion;\r\n\r\n/**\r\n * Representa os generos\r\n * @author Solkam\r\n * @since 01 FEV 2015\r\n */\r\npublic enum Gender {",
"end": 102,
"score": 0.9994469285011292,
"start": 96,
"tag": "NAME",
"value": "Solkam"
}
] | null | [] | package br.com.tremn.crm.model.entity.enumeration;
/**
* Representa os generos
* @author Solkam
* @since 01 FEV 2015
*/
public enum Gender {
M("Masculino")
,
F("Feminino")
;
private final String description;
private Gender(String d) {
this.description = d;
}
public String getDescription() {
return description;
}
}
| 372 | 0.61828 | 0.602151 | 27 | 11.777778 | 13.422848 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.851852 | false | false | 13 |
6ed2377c298a849da5d572bc87ae5d95f2334f20 | 18,176,301,655,519 | 3248fd584afbec2a8e1d2c1405b10466238492db | /KnapsackNew/src/mhs/knapsack/KnapLog.java | 1379103322772e764dc4a5d675153a0f92f91ff4 | [] | no_license | EpistemikJava/mhs | https://github.com/EpistemikJava/mhs | 6f59064933493e266228ae32ad0b5d09d6fe4c90 | 30fa062950e5a8ad74bf34c24942f03ef45716c6 | refs/heads/master | 2020-03-21T11:14:58.244000 | 2019-01-04T21:02:50 | 2019-01-04T21:02:50 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* ***************************************************************************************
Mark Sattolo (epistemik@gmail.com)
-----------------------------------------------
$File: //depot/Eclipse/Java/workspace/KnapsackNew/src/mhs/knapsack/KnapLog.java $
$Revision: #5 $
$Change: 58 $
$DateTime: 2011/02/02 11:56:15 $
git version created Mar 22, 2014.
*************************************************************************************** */
package mhs.knapsack;
import java.text.DateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.logging.*;
/**
* Manage logging for the package
* @author Mark Sattolo
* @version $Revision: #5 $
*/
class KnapLogManager
{
/**
* USUAL Constructor <br>
* Set up my Logger and Handler(s) and initiate logging at the startup Level
* @param level - initial log {@link Level} received from {@link KnapSack#KnapSack(String[])}
* @see KnapLogger#getNewLogger
* @see FileHandler
* @see Handler#setFormatter
*/
KnapLogManager( String level )
{
try
{
setLevel( Level.parse(level) );
}
catch( Exception e )
{
System.err.println( "Problem with parameter for initial Log Level: " + e.toString() );
setLevel( DEFAULT_LEVEL );
}
// get Logger
myLogger = KnapLogger.getNewLogger( getClass().getName() );
try
{
/*
xmlHandler = new FileHandler( LOG_SUBFOLDER + Launcher.PROJECT_NAME + LOG_ROLLOVER_SPEC + XML_LOGFILE_TYPE ,
LOGFILE_MAX_BYTES, MAX_NUM_LOG_FILES );
xmlHandler.setFormatter( new XMLFormatter() );
//*/
textHandler = new FileHandler( LOG_SUBFOLDER + KnapSack.PROJECT_NAME + LOG_ROLLOVER_SPEC + TEXT_LOGFILE_TYPE ,
LOGFILE_MAX_BYTES, MAX_NUM_LOG_FILES );
}
catch( Exception e )
{
System.err.println( "FileHandler exception: " + e );
}
if( textHandler != null )
{
try
{
textHandler.setFormatter( new KnapFormatter() );
// Send logger output to our FileHandler.
myLogger.addHandler( textHandler );
}
catch( Exception e )
{
System.err.println( "textHandler exception: " + e );
}
}
else
System.err.println( "\t>> PROBLEM: textHandler is NULL!" );
// Set the level of detail that gets logged.
myLogger.setLevel( currentLevel );
}// CONSTRUCTOR
/** @return private static {@link KnapLogger} <var>myLogger</var> */
protected KnapLogger getLogger()
{ return myLogger ; }
/** @return private static {@link Level} <var>currentLevel</var> */
protected Level getLevel()
{ return currentLevel ;}
/** @param level - {@link java.util.logging.Level} */
protected void setLevel( Level level )
{
currentLevel = level ;
intLevel = currentLevel.intValue();
}
/**
* @param level - {@link java.util.logging.Level}
* @return at this Level or more
*/
protected static boolean atLevel( Level level )
{
return intLevel <= level.intValue();
}
/** @return EXACTLY at {@link Level#SEVERE} */
static boolean severe() { return currentLevel.equals( Level.SEVERE ); }
/** @return at {@link Level#WARNING} or lower */
static boolean warning() { return atLevel( Level.WARNING ); }
/** @return at {@link Level#CONFIG} or lower */
static boolean config() { return atLevel( Level.CONFIG ); }
/** @return at {@link Level#INFO} or lower */
static boolean info() { return atLevel( Level.INFO ); }
/** @return at {@link Level#FINE} or lower */
static boolean fine() { return atLevel( Level.FINE ); }
/** @return at {@link Level#FINER} or lower */
static boolean finer() { return atLevel( Level.FINER ); }
/** @return at {@link Level#FINEST} or lower */
static boolean finest() { return atLevel( Level.FINEST ); }
/**
* Increase the amount of information logged <br>
* - which means we must decrease the {@link Level} of <var>myLogger</var> <br>
* - wrap around when reach base level
* @return {@link Level} <var>currentLevel</var>
*/
protected Level moreLogging()
{
if( intLevel == Level.FINEST.intValue() )
intLevel = Level.SEVERE.intValue(); // wrap around to HIGHEST (least amount of logging) setting
else
if( intLevel == Level.CONFIG.intValue() )
intLevel = Level.FINE.intValue(); // jump gap b/n CONFIG & FINE
else
intLevel -= 100 ; // go down to a finer (more logging) setting
currentLevel = Level.parse( Integer.toString(intLevel) );
myLogger.setLevel( currentLevel );
myLogger.severe( "Log level is NOW at " + currentLevel );
return currentLevel ;
}// LogControl.incLevel()
String myname() { return getClass().getSimpleName(); }
void listLoggers()
{
Enumeration<String> e = LogManager.getLogManager().getLoggerNames();
while( e.hasMoreElements() )
myLogger.appendln( e.nextElement() );
myLogger.send( currentLevel );
}
void reportLevel()
{
myLogger.severe( "Current log level is " + currentLevel );
}
/** default value */
static final int
MAX_NUM_LOG_FILES = 256 ,
LOGFILE_MAX_BYTES = ( 4 * 1024 * 1024 );
/** default {@link Level} */
static final Level
INIT_LEVEL = Level.SEVERE , // Level to print initialization messages.
DEFAULT_LEVEL = Level.WARNING ; // If no value passed to Constructor from KnapSack.
/** default Log name parameter */
static final String
LOG_SUBFOLDER = "logs/" ,
LOG_ROLLOVER_SPEC = "%u-%g" ,
XML_LOGFILE_TYPE = ".xml" ,
TEXT_LOGFILE_TYPE = ".log" ;
/** @see KnapLogger */
private static KnapLogger myLogger ;
/** @see FileHandler */
private static FileHandler textHandler ;//, xmlHandler ;
/** current {@link Level} */
private static Level currentLevel ;
/** integer value of {@link #currentLevel} */
private static int intLevel ;
}// class KnapLogManager
/* ========================================================================================================================== */
/**
* Perform all the actual logging operations
* @author Mark Sattolo
* @see java.util.logging.Logger
*/
class KnapLogger extends Logger
{
/*
* C O N S T R U C T O R S
*****************************************************************************************************************/
/**
* USUAL constructor - just calls the super equivalent
* @param name - may be <var>null</var>
* @param resourceBundleName - may be <var>null</var>
* @see Logger#Logger(String,String)
*/
private KnapLogger( String name, String resourceBundleName )
{
super( name, resourceBundleName );
}
/*
* M E T H O D S
*****************************************************************************************************************/
// =============================================================================================================
// I N T E R F A C E
// =============================================================================================================
/**
* Allow other package classes to create a {@link Logger} <br>
* - adds this new {@link Logger} to the {@link LogManager} namespace
*
* @param name - identify the {@link Logger}
* @return the <b>new</b> {@link Logger}
* @see LogManager#addLogger(Logger)
*/
protected static synchronized KnapLogger getNewLogger( String name )
{
KnapLogger mylogger = new KnapLogger( name, null );
LogManager.getLogManager().addLogger( mylogger );
return mylogger ;
}// KnapLogger.getNewLogger()
/**
* Prepare and send a {@link LogRecord} with data from the log buffer
*
* @param level - {@link Level} to log at
*/
protected void send( Level level )
{
if( buffer.length() == 0 )
return ;
getCallerClassAndMethodName();
LogRecord lr = getRecord( level, buffer.toString() );
clean();
sendRecord( lr );
}// KnapLogger.send()
/**
* Add data to the log buffer
*
* @param msg - data String
*/
protected synchronized void append( String msg )
{ buffer.append( msg ); }
/**
* Add data to the log buffer with a terminating newline
*
* @param msg - data String
*/
protected void appendln( String msg )
{ append( msg + "\n" ); }
/** Add a newline to the log buffer */
protected void appendnl()
{ append( "\n" ); }
/** <b>Remove</b> <em>ALL</em> data in the log buffer */
protected void clean()
{ buffer.delete( 0, buffer.length() ); }
/**
* Log the submitted info at the current level
*
* @param s - info to print
*/
public void log( String s )
{
log( KnapSack.currentLevel, s );
}
/*/ for debugging
@Override
public void log( LogRecord record )
{
System.out.println( "---------------------------------------------------" );
System.out.println( "record Message is '" + record.getMessage() + "'" );
System.out.println( "record Class caller is '" + record.getSourceClassName() + "'" );
System.out.println( "record Method caller is '" + record.getSourceMethodName() + "'" );
super.log( record );
}
//*/
// =============================================================================================================
// P R I V A T E
// =============================================================================================================
/**
* Provide a <b>new</b> {@link LogRecord} with Caller class and method name info
*
* @param level - {@link Level} to log at
* @param msg - info to insert in the {@link LogRecord}
* @return the produced {@link LogRecord}
*/
private LogRecord getRecord( Level level, String msg )
{
LogRecord lr = new LogRecord( (level == null ? KnapLogManager.DEFAULT_LEVEL : level), msg );
lr.setSourceClassName( callclass );
lr.setSourceMethodName( callmethod );
return lr ;
}// KnapLogger.getRecord()
/**
* Actually send the {@link LogRecord} to the logging handler
*
* @param lr - {@link LogRecord} to send
* @see Logger#log(LogRecord)
*/
private synchronized void sendRecord( LogRecord lr )
{
callclass = null ;
callmethod = null ;
super.log( lr );
}// KnapLogger.sendRecord()
/**
* Get the name of the {@link Class} and <em>Method</em> that called {@link KnapLogger}
*
* @see Throwable#getStackTrace
* @see StackTraceElement#getClassName
* @see StackTraceElement#getMethodName
*/
private void getCallerClassAndMethodName()
{
Throwable t = new Throwable();
StackTraceElement[] elements = t.getStackTrace();
if( elements.length < 3 )
callclass = callmethod = strUNKNOWN ;
else
{
callclass = elements[2].getClassName();
callmethod = elements[2].getMethodName();
}
}// KnapLogger.getCallerClassAndMethodName()
/*
* F I E L D S
*****************************************************************************************************************/
/** Class calling the Logger */
private String callclass = null ;
/** Method calling the Logger */
private String callmethod = null ;
/**
* Store info from multiple {@link KnapLogger#append} or {@link KnapLogger#appendln} calls <br>
* - i.e. do a 'bulk send'
* @see StringBuilder
*/
private StringBuilder buffer = new StringBuilder( 1024 );
/** default if cannot get method or class name */
static final String strUNKNOWN = "unknown" ;
}// class KnapLogger
/* ========================================================================================================================== */
/**
* Do all the actual formatting of {@link LogRecord}s for {@link KnapLogger}
*
* @author Mark Sattolo
* @see java.util.logging.Formatter
*/
class KnapFormatter extends Formatter
{
/**
* Instructions on how to format a {@link LogRecord}
*
* @see Formatter#format
*/
@Override
public String format( LogRecord record )
{
return( record.getLevel() + rec + (++count) + nl + record.getSourceClassName() + sp
+ record.getSourceMethodName() + mi + nl + record.getMessage() + nl + nl );
}
/**
* Printed at the beginning of a Log file
*
* @see Formatter#getHead
*/
@Override
public String getHead( Handler h )
{
return( head + DateFormat.getDateTimeInstance().format( new Date() ) + nl + div + nl + nl );
}
/**
* Printed at the end of a Log file
*
* @see Formatter#getTail
*/
@Override
public String getTail( Handler h )
{
return( div + nl + tail + DateFormat.getDateTimeInstance().format( new Date() ) + nl );
}
/** Number of times {@link KnapFormatter#format(LogRecord)} has been called */
private int count ;
/** useful String constant */
static String sp = " " ,
nl = "\n" ,
mi = "()" , // method indicator
div = "=================================================================" ,
head = "KnapsackNew START" + nl ,
rec = ": KnapsackNew record #" ,
tail = "KnapsackNew END" + nl ;
}// Class KnapFormatter
| UTF-8 | Java | 14,007 | java | KnapLog.java | Java | [
{
"context": "********************************************\r\n \r\n Mark Sattolo (epistemik@gmail.com)\r\n -------------------------",
"end": 109,
"score": 0.9998821020126343,
"start": 97,
"tag": "NAME",
"value": "Mark Sattolo"
},
{
"context": "*****************************\r\n \r\n Mark Sattolo (epistemik@gmail.com)\r\n ----------------------------------------------",
"end": 130,
"score": 0.9999312162399292,
"start": 111,
"tag": "EMAIL",
"value": "epistemik@gmail.com"
},
{
"context": "**\r\n * Manage logging for the package\r\n * @author Mark Sattolo\r\n * @version $Revision: #5 $\r\n */\r\nclass KnapLogM",
"end": 687,
"score": 0.9998770356178284,
"start": 675,
"tag": "NAME",
"value": "Mark Sattolo"
},
{
"context": "orm all the actual logging operations\r\n * @author Mark Sattolo\r\n * @see java.util.logging.Logger\r\n */\r\nclass Kn",
"end": 6559,
"score": 0.999868631362915,
"start": 6547,
"tag": "NAME",
"value": "Mark Sattolo"
},
{
"context": "Record}s for {@link KnapLogger}\r\n * \r\n * @author Mark Sattolo\r\n * @see java.util.logging.Formatter\r\n */\r\nclass",
"end": 12514,
"score": 0.9998500347137451,
"start": 12502,
"tag": "NAME",
"value": "Mark Sattolo"
}
] | null | [] | /* ***************************************************************************************
<NAME> (<EMAIL>)
-----------------------------------------------
$File: //depot/Eclipse/Java/workspace/KnapsackNew/src/mhs/knapsack/KnapLog.java $
$Revision: #5 $
$Change: 58 $
$DateTime: 2011/02/02 11:56:15 $
git version created Mar 22, 2014.
*************************************************************************************** */
package mhs.knapsack;
import java.text.DateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.logging.*;
/**
* Manage logging for the package
* @author <NAME>
* @version $Revision: #5 $
*/
class KnapLogManager
{
/**
* USUAL Constructor <br>
* Set up my Logger and Handler(s) and initiate logging at the startup Level
* @param level - initial log {@link Level} received from {@link KnapSack#KnapSack(String[])}
* @see KnapLogger#getNewLogger
* @see FileHandler
* @see Handler#setFormatter
*/
KnapLogManager( String level )
{
try
{
setLevel( Level.parse(level) );
}
catch( Exception e )
{
System.err.println( "Problem with parameter for initial Log Level: " + e.toString() );
setLevel( DEFAULT_LEVEL );
}
// get Logger
myLogger = KnapLogger.getNewLogger( getClass().getName() );
try
{
/*
xmlHandler = new FileHandler( LOG_SUBFOLDER + Launcher.PROJECT_NAME + LOG_ROLLOVER_SPEC + XML_LOGFILE_TYPE ,
LOGFILE_MAX_BYTES, MAX_NUM_LOG_FILES );
xmlHandler.setFormatter( new XMLFormatter() );
//*/
textHandler = new FileHandler( LOG_SUBFOLDER + KnapSack.PROJECT_NAME + LOG_ROLLOVER_SPEC + TEXT_LOGFILE_TYPE ,
LOGFILE_MAX_BYTES, MAX_NUM_LOG_FILES );
}
catch( Exception e )
{
System.err.println( "FileHandler exception: " + e );
}
if( textHandler != null )
{
try
{
textHandler.setFormatter( new KnapFormatter() );
// Send logger output to our FileHandler.
myLogger.addHandler( textHandler );
}
catch( Exception e )
{
System.err.println( "textHandler exception: " + e );
}
}
else
System.err.println( "\t>> PROBLEM: textHandler is NULL!" );
// Set the level of detail that gets logged.
myLogger.setLevel( currentLevel );
}// CONSTRUCTOR
/** @return private static {@link KnapLogger} <var>myLogger</var> */
protected KnapLogger getLogger()
{ return myLogger ; }
/** @return private static {@link Level} <var>currentLevel</var> */
protected Level getLevel()
{ return currentLevel ;}
/** @param level - {@link java.util.logging.Level} */
protected void setLevel( Level level )
{
currentLevel = level ;
intLevel = currentLevel.intValue();
}
/**
* @param level - {@link java.util.logging.Level}
* @return at this Level or more
*/
protected static boolean atLevel( Level level )
{
return intLevel <= level.intValue();
}
/** @return EXACTLY at {@link Level#SEVERE} */
static boolean severe() { return currentLevel.equals( Level.SEVERE ); }
/** @return at {@link Level#WARNING} or lower */
static boolean warning() { return atLevel( Level.WARNING ); }
/** @return at {@link Level#CONFIG} or lower */
static boolean config() { return atLevel( Level.CONFIG ); }
/** @return at {@link Level#INFO} or lower */
static boolean info() { return atLevel( Level.INFO ); }
/** @return at {@link Level#FINE} or lower */
static boolean fine() { return atLevel( Level.FINE ); }
/** @return at {@link Level#FINER} or lower */
static boolean finer() { return atLevel( Level.FINER ); }
/** @return at {@link Level#FINEST} or lower */
static boolean finest() { return atLevel( Level.FINEST ); }
/**
* Increase the amount of information logged <br>
* - which means we must decrease the {@link Level} of <var>myLogger</var> <br>
* - wrap around when reach base level
* @return {@link Level} <var>currentLevel</var>
*/
protected Level moreLogging()
{
if( intLevel == Level.FINEST.intValue() )
intLevel = Level.SEVERE.intValue(); // wrap around to HIGHEST (least amount of logging) setting
else
if( intLevel == Level.CONFIG.intValue() )
intLevel = Level.FINE.intValue(); // jump gap b/n CONFIG & FINE
else
intLevel -= 100 ; // go down to a finer (more logging) setting
currentLevel = Level.parse( Integer.toString(intLevel) );
myLogger.setLevel( currentLevel );
myLogger.severe( "Log level is NOW at " + currentLevel );
return currentLevel ;
}// LogControl.incLevel()
String myname() { return getClass().getSimpleName(); }
void listLoggers()
{
Enumeration<String> e = LogManager.getLogManager().getLoggerNames();
while( e.hasMoreElements() )
myLogger.appendln( e.nextElement() );
myLogger.send( currentLevel );
}
void reportLevel()
{
myLogger.severe( "Current log level is " + currentLevel );
}
/** default value */
static final int
MAX_NUM_LOG_FILES = 256 ,
LOGFILE_MAX_BYTES = ( 4 * 1024 * 1024 );
/** default {@link Level} */
static final Level
INIT_LEVEL = Level.SEVERE , // Level to print initialization messages.
DEFAULT_LEVEL = Level.WARNING ; // If no value passed to Constructor from KnapSack.
/** default Log name parameter */
static final String
LOG_SUBFOLDER = "logs/" ,
LOG_ROLLOVER_SPEC = "%u-%g" ,
XML_LOGFILE_TYPE = ".xml" ,
TEXT_LOGFILE_TYPE = ".log" ;
/** @see KnapLogger */
private static KnapLogger myLogger ;
/** @see FileHandler */
private static FileHandler textHandler ;//, xmlHandler ;
/** current {@link Level} */
private static Level currentLevel ;
/** integer value of {@link #currentLevel} */
private static int intLevel ;
}// class KnapLogManager
/* ========================================================================================================================== */
/**
* Perform all the actual logging operations
* @author <NAME>
* @see java.util.logging.Logger
*/
class KnapLogger extends Logger
{
/*
* C O N S T R U C T O R S
*****************************************************************************************************************/
/**
* USUAL constructor - just calls the super equivalent
* @param name - may be <var>null</var>
* @param resourceBundleName - may be <var>null</var>
* @see Logger#Logger(String,String)
*/
private KnapLogger( String name, String resourceBundleName )
{
super( name, resourceBundleName );
}
/*
* M E T H O D S
*****************************************************************************************************************/
// =============================================================================================================
// I N T E R F A C E
// =============================================================================================================
/**
* Allow other package classes to create a {@link Logger} <br>
* - adds this new {@link Logger} to the {@link LogManager} namespace
*
* @param name - identify the {@link Logger}
* @return the <b>new</b> {@link Logger}
* @see LogManager#addLogger(Logger)
*/
protected static synchronized KnapLogger getNewLogger( String name )
{
KnapLogger mylogger = new KnapLogger( name, null );
LogManager.getLogManager().addLogger( mylogger );
return mylogger ;
}// KnapLogger.getNewLogger()
/**
* Prepare and send a {@link LogRecord} with data from the log buffer
*
* @param level - {@link Level} to log at
*/
protected void send( Level level )
{
if( buffer.length() == 0 )
return ;
getCallerClassAndMethodName();
LogRecord lr = getRecord( level, buffer.toString() );
clean();
sendRecord( lr );
}// KnapLogger.send()
/**
* Add data to the log buffer
*
* @param msg - data String
*/
protected synchronized void append( String msg )
{ buffer.append( msg ); }
/**
* Add data to the log buffer with a terminating newline
*
* @param msg - data String
*/
protected void appendln( String msg )
{ append( msg + "\n" ); }
/** Add a newline to the log buffer */
protected void appendnl()
{ append( "\n" ); }
/** <b>Remove</b> <em>ALL</em> data in the log buffer */
protected void clean()
{ buffer.delete( 0, buffer.length() ); }
/**
* Log the submitted info at the current level
*
* @param s - info to print
*/
public void log( String s )
{
log( KnapSack.currentLevel, s );
}
/*/ for debugging
@Override
public void log( LogRecord record )
{
System.out.println( "---------------------------------------------------" );
System.out.println( "record Message is '" + record.getMessage() + "'" );
System.out.println( "record Class caller is '" + record.getSourceClassName() + "'" );
System.out.println( "record Method caller is '" + record.getSourceMethodName() + "'" );
super.log( record );
}
//*/
// =============================================================================================================
// P R I V A T E
// =============================================================================================================
/**
* Provide a <b>new</b> {@link LogRecord} with Caller class and method name info
*
* @param level - {@link Level} to log at
* @param msg - info to insert in the {@link LogRecord}
* @return the produced {@link LogRecord}
*/
private LogRecord getRecord( Level level, String msg )
{
LogRecord lr = new LogRecord( (level == null ? KnapLogManager.DEFAULT_LEVEL : level), msg );
lr.setSourceClassName( callclass );
lr.setSourceMethodName( callmethod );
return lr ;
}// KnapLogger.getRecord()
/**
* Actually send the {@link LogRecord} to the logging handler
*
* @param lr - {@link LogRecord} to send
* @see Logger#log(LogRecord)
*/
private synchronized void sendRecord( LogRecord lr )
{
callclass = null ;
callmethod = null ;
super.log( lr );
}// KnapLogger.sendRecord()
/**
* Get the name of the {@link Class} and <em>Method</em> that called {@link KnapLogger}
*
* @see Throwable#getStackTrace
* @see StackTraceElement#getClassName
* @see StackTraceElement#getMethodName
*/
private void getCallerClassAndMethodName()
{
Throwable t = new Throwable();
StackTraceElement[] elements = t.getStackTrace();
if( elements.length < 3 )
callclass = callmethod = strUNKNOWN ;
else
{
callclass = elements[2].getClassName();
callmethod = elements[2].getMethodName();
}
}// KnapLogger.getCallerClassAndMethodName()
/*
* F I E L D S
*****************************************************************************************************************/
/** Class calling the Logger */
private String callclass = null ;
/** Method calling the Logger */
private String callmethod = null ;
/**
* Store info from multiple {@link KnapLogger#append} or {@link KnapLogger#appendln} calls <br>
* - i.e. do a 'bulk send'
* @see StringBuilder
*/
private StringBuilder buffer = new StringBuilder( 1024 );
/** default if cannot get method or class name */
static final String strUNKNOWN = "unknown" ;
}// class KnapLogger
/* ========================================================================================================================== */
/**
* Do all the actual formatting of {@link LogRecord}s for {@link KnapLogger}
*
* @author <NAME>
* @see java.util.logging.Formatter
*/
class KnapFormatter extends Formatter
{
/**
* Instructions on how to format a {@link LogRecord}
*
* @see Formatter#format
*/
@Override
public String format( LogRecord record )
{
return( record.getLevel() + rec + (++count) + nl + record.getSourceClassName() + sp
+ record.getSourceMethodName() + mi + nl + record.getMessage() + nl + nl );
}
/**
* Printed at the beginning of a Log file
*
* @see Formatter#getHead
*/
@Override
public String getHead( Handler h )
{
return( head + DateFormat.getDateTimeInstance().format( new Date() ) + nl + div + nl + nl );
}
/**
* Printed at the end of a Log file
*
* @see Formatter#getTail
*/
@Override
public String getTail( Handler h )
{
return( div + nl + tail + DateFormat.getDateTimeInstance().format( new Date() ) + nl );
}
/** Number of times {@link KnapFormatter#format(LogRecord)} has been called */
private int count ;
/** useful String constant */
static String sp = " " ,
nl = "\n" ,
mi = "()" , // method indicator
div = "=================================================================" ,
head = "KnapsackNew START" + nl ,
rec = ": KnapsackNew record #" ,
tail = "KnapsackNew END" + nl ;
}// Class KnapFormatter
| 13,971 | 0.52231 | 0.518883 | 444 | 29.547297 | 28.749147 | 128 | false | false | 0 | 0 | 0 | 0 | 122 | 0.057971 | 0.261261 | false | false | 13 |
aa9f225c8c43efabb9a51f5298c5551248340407 | 21,036,749,885,038 | f5e7ee9ac9c15b08598868734f94400b3f61f94a | /JavaPracticePrograms/StringCheck.java | 4f8cf759b82be2d205856714af72dec600d97c05 | [] | no_license | Rohancherukuri/MyPrograms | https://github.com/Rohancherukuri/MyPrograms | d19b81d1f22d55e031c85ff623a8a5cc09049140 | 7ca1a8e5e5420466fc569228aae4969b5e2e9f3a | refs/heads/master | 2022-06-09T23:15:31.237000 | 2020-05-07T05:18:30 | 2020-05-07T05:18:30 | 260,430,952 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // Checking a word in a given sentence
import java.util.*;
class StringCheck
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a sentence: ");
String n=sc.nextLine();
System.out.print("Enter a word to be searched: ");
String w=sc.nextLine();
boolean c=n.contains(w);
System.out.println(c);
if(c==true)
System.out.println("The word "+w+" is present in the sentence");
else
System.out.println("The word "+w+" is not present in the sentence");
}
}
| UTF-8 | Java | 524 | java | StringCheck.java | Java | [] | null | [] | // Checking a word in a given sentence
import java.util.*;
class StringCheck
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a sentence: ");
String n=sc.nextLine();
System.out.print("Enter a word to be searched: ");
String w=sc.nextLine();
boolean c=n.contains(w);
System.out.println(c);
if(c==true)
System.out.println("The word "+w+" is present in the sentence");
else
System.out.println("The word "+w+" is not present in the sentence");
}
}
| 524 | 0.677481 | 0.677481 | 19 | 26.578947 | 20.673695 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.947368 | false | false | 13 |
a0669628f9e0c88006970394df9ded36629a7be1 | 3,238,405,344,376 | 173e5b8b5ea75d2641e696d562e7a6536b5e4c55 | /src/main/java/org/andork/walls/SegmentParseExpectedException.java | 42f854bc1c9ea9e93aaf195c756dda1ae0fa3c33 | [] | no_license | wallscavesurvey/dewalls-java | https://github.com/wallscavesurvey/dewalls-java | 251b3501a3b16681a2533e4e8eeae397a3375cf1 | daa78e8383b675891185ccef91bbb2bea6b3a75a | refs/heads/master | 2021-11-22T23:34:17.783000 | 2021-07-19T14:38:06 | 2021-07-19T14:38:06 | 89,753,160 | 0 | 0 | null | false | 2020-10-13T00:50:41 | 2017-04-29T00:00:37 | 2020-04-01T18:30:31 | 2020-10-13T00:50:40 | 132 | 0 | 0 | 1 | Java | false | false | package org.andork.walls;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.andork.segment.Segment;
import org.andork.segment.SegmentParseException;
public class SegmentParseExpectedException extends SegmentParseException {
private static final long serialVersionUID = -5243227002158898703L;
private final Set<String> expectedItems;
public SegmentParseExpectedException(Segment segment, String... expectedItems) {
this(segment, Arrays.asList(expectedItems));
}
public SegmentParseExpectedException(Segment segment, Collection<String> expectedItems) {
super(createMessage(segment, expectedItems), segment);
this.expectedItems = Collections.unmodifiableSet(new LinkedHashSet<>(expectedItems));
}
public Set<String> expectedItems() {
return expectedItems;
}
private static String createMessage(Segment segment, Collection<String> expectedItems) {
StringBuilder message = new StringBuilder("error: Expected ");
if (expectedItems.size() == 1) {
message.append('"').append(expectedItems.iterator().next()).append("\"\n");
} else {
message.append("one of:");
for (String s : expectedItems) {
message.append("\n ").append(s);
}
}
return message.toString();
}
}
| UTF-8 | Java | 1,304 | java | SegmentParseExpectedException.java | Java | [] | null | [] | package org.andork.walls;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.andork.segment.Segment;
import org.andork.segment.SegmentParseException;
public class SegmentParseExpectedException extends SegmentParseException {
private static final long serialVersionUID = -5243227002158898703L;
private final Set<String> expectedItems;
public SegmentParseExpectedException(Segment segment, String... expectedItems) {
this(segment, Arrays.asList(expectedItems));
}
public SegmentParseExpectedException(Segment segment, Collection<String> expectedItems) {
super(createMessage(segment, expectedItems), segment);
this.expectedItems = Collections.unmodifiableSet(new LinkedHashSet<>(expectedItems));
}
public Set<String> expectedItems() {
return expectedItems;
}
private static String createMessage(Segment segment, Collection<String> expectedItems) {
StringBuilder message = new StringBuilder("error: Expected ");
if (expectedItems.size() == 1) {
message.append('"').append(expectedItems.iterator().next()).append("\"\n");
} else {
message.append("one of:");
for (String s : expectedItems) {
message.append("\n ").append(s);
}
}
return message.toString();
}
}
| 1,304 | 0.76227 | 0.746933 | 41 | 30.804878 | 28.610266 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.682927 | false | false | 13 |
ffc99dc3dc4caaeae32e9985e58882c76d460279 | 14,826,227,106,222 | 032cf5221542965e41c9ce8c170272be1b1d2db1 | /src/domain/server/listeners/PlayerListChangedListener.java | 83d3f2712a112b44bb8a3eabc9a5c7edb1fe2b65 | [] | no_license | umt2846/OOP_Project_Monopoly | https://github.com/umt2846/OOP_Project_Monopoly | 6e4e3d50217fd73d48f7bf5a70401ab806656d29 | 2ebb50f9b50a2ffc815b18a7f76af5bcd9b8714f | refs/heads/master | 2021-04-05T05:30:15.884000 | 2019-01-07T14:35:09 | 2019-01-07T14:35:09 | 248,524,145 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package domain.server.listeners;
import java.util.ArrayList;
public interface PlayerListChangedListener {
void onPlayerListChangedEvent(ArrayList<String> selectedColors);
}
| UTF-8 | Java | 179 | java | PlayerListChangedListener.java | Java | [] | null | [] | package domain.server.listeners;
import java.util.ArrayList;
public interface PlayerListChangedListener {
void onPlayerListChangedEvent(ArrayList<String> selectedColors);
}
| 179 | 0.826816 | 0.826816 | 7 | 24.571428 | 24.165247 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 13 |
199bd8eca8b2c4b3622f79160a42e87c33df1cf6 | 20,529,943,745,865 | 742f3a39fd520ffc807260d54714ae098e056262 | /service/src/main/java/com/sdpt/beacon/service/MainServiceApplication.java | 00c0c965f0144c8ea72f1032721d429c62ab5f3f | [] | no_license | Case-PT/beacon | https://github.com/Case-PT/beacon | 6f034b2369633628b06eff56c26f27cd01b11e4e | 5cfe274a1e18fb29e29c3675f97997bb74c1f9a8 | refs/heads/master | 2021-08-08T19:08:57.089000 | 2017-11-10T23:40:47 | 2017-11-10T23:40:47 | 106,617,609 | 1 | 8 | null | false | 2017-11-10T23:40:48 | 2017-10-11T22:51:38 | 2017-10-26T22:02:26 | 2017-11-10T23:40:47 | 54 | 1 | 7 | 0 | Java | false | null | package com.sdpt.beacon.service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class MainServiceApplication {
public static void main(String[] args) {
SpringApplication.run(MainServiceApplication.class, args);
}
@RequestMapping("/")
public String home() {
return "Go to <a href = \"/hello\">hello form</a>";
}
}
| UTF-8 | Java | 597 | java | MainServiceApplication.java | Java | [] | null | [] | package com.sdpt.beacon.service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class MainServiceApplication {
public static void main(String[] args) {
SpringApplication.run(MainServiceApplication.class, args);
}
@RequestMapping("/")
public String home() {
return "Go to <a href = \"/hello\">hello form</a>";
}
}
| 597 | 0.758794 | 0.758794 | 19 | 30.421053 | 24.502022 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false | 13 |
3540e7ce3e2bd026748bce52e26fcd6ff90c6c25 | 9,216,999,846,200 | 46d2f16aa4db23b62862a607a59661cd4f6c7e2f | /src/com/sebastardo/Etapa2/Pedido.java | 178e6273a7ce6f1400faa36dd557bef396851046 | [] | no_license | sebastardo/FlotaDeRodados | https://github.com/sebastardo/FlotaDeRodados | 0d71fca360b6c5b52e2e3d6c3b8317514f4cf096 | ae7ccf9ac74715bf9435b5b3caf0842c8f628dd0 | refs/heads/master | 2022-04-10T14:55:02.173000 | 2020-03-30T04:24:33 | 2020-03-30T04:24:33 | 249,355,231 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.sebastardo.Etapa2;
import com.sebastardo.Etapa1.Rodado;
import java.util.Set;
/**
*
* @author Sebastian
*
*
* Agregar al modelo los pedidos de translados que se generan en la municipalidad.
* Cada pedido especifica: la distancia a recorrer (expresada en kilómetros), el tiempo máximo en que se puede hacer el viaje (expresado en horas),
* la cantidad de pasajeros a transportar, y también un conjunto de colores incompatibles, o sea, que los pasajeros rechazan hacer el viaje en autos de esos colores.
* La velocidad requerida de un pedido es el resultado de dividir la cantidad de kilómetros por el tiempo máximo.
* P.ej. si para un pedido de un viaje de 480 kilómetros se indica como tiempo máximo 6 horas, entonces la velocidad
* requerida de este pedido es de 80 kms/hora (480 / 6 = 80).
*
* Agregar la capacidad de preguntar si un auto puede satisfacer un pedido, enviándole un mensaje al viaje con el auto como parámetro.
*
* Para que un auto pueda satisfacer un pedido se tienen que dar tres condiciones:
*
* que la velocidad máxima del auto sea al menos 10 km/h mayor a la velocidad requerida del pedido;
* que la capacidad del auto dé para la cantidad de pasajeros del viaje; y
* que el auto no sea de un color incompatible para el viaje.
*
* P.ej. consideremos al auto al que llamamos cachito en el test de la etapa 1 (recordemos: capacidad 4 pasajeros, velocidad máxima 150 km/h, color rojo).
*
* este auto puede satisfacer un pedido de 960 kms con tiempo máximo de 8 horas (lo que da una velocidad requerida de 120 km/h), para 4 pasajeros donde
* los colores incompatibles son azul y negro.
* si agregamos el rojo a los colores incompatibles, o cambiamos la cantidad de pasajeros a 6, entonces cachito ya no puede satisfacer el pedido.
* lo mismo si cambiamos el tiempo máximo a 6 horas, porque eso nos daría una velocidad requerida de 160 km/h.
*
*/
public class Pedido {
private int distanciaARecorrer;
private int tiempoMaximo;
private int cantidadPasajeros;
private Set<String> coloresIncompatibles;
public Pedido(int distanciaARecorrer, int tiempoMaximo, int cantidadPasajeros, Set<String> coloresIncompatibles) {
this.distanciaARecorrer = distanciaARecorrer;
this.tiempoMaximo = tiempoMaximo;
this.cantidadPasajeros = cantidadPasajeros;
this.coloresIncompatibles = coloresIncompatibles;
}
public boolean autoSatisfactorio(Rodado auto){
if(distanciaARecorrer/tiempoMaximo + 10 > auto.getVelocidad())
return false;
if(cantidadPasajeros > auto.getCapacidad())
return false;
if(coloresIncompatibles.stream().anyMatch(c->c.equals(auto.getColor())))
return false;
return true;
}
public int getCantidadPasajeros() {
return cantidadPasajeros;
}
public Set<String> getColoresIncompatibles() {
return coloresIncompatibles;
}
@Override
public String toString() {
return "Pedido{" + "distanciaARecorrer=" + distanciaARecorrer + ", tiempoMaximo=" + tiempoMaximo + ", cantidadPasajeros=" + cantidadPasajeros + ", coloresIncompatibles=" + coloresIncompatibles + '}';
}
}
| UTF-8 | Java | 3,525 | java | Pedido.java | Java | [
{
"context": "ado;\r\nimport java.util.Set;\r\n\r\n/**\r\n *\r\n * @author Sebastian\r\n * \r\n *\r\n * Agregar al modelo los pedidos de tra",
"end": 316,
"score": 0.999756932258606,
"start": 307,
"tag": "NAME",
"value": "Sebastian"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.sebastardo.Etapa2;
import com.sebastardo.Etapa1.Rodado;
import java.util.Set;
/**
*
* @author Sebastian
*
*
* Agregar al modelo los pedidos de translados que se generan en la municipalidad.
* Cada pedido especifica: la distancia a recorrer (expresada en kilómetros), el tiempo máximo en que se puede hacer el viaje (expresado en horas),
* la cantidad de pasajeros a transportar, y también un conjunto de colores incompatibles, o sea, que los pasajeros rechazan hacer el viaje en autos de esos colores.
* La velocidad requerida de un pedido es el resultado de dividir la cantidad de kilómetros por el tiempo máximo.
* P.ej. si para un pedido de un viaje de 480 kilómetros se indica como tiempo máximo 6 horas, entonces la velocidad
* requerida de este pedido es de 80 kms/hora (480 / 6 = 80).
*
* Agregar la capacidad de preguntar si un auto puede satisfacer un pedido, enviándole un mensaje al viaje con el auto como parámetro.
*
* Para que un auto pueda satisfacer un pedido se tienen que dar tres condiciones:
*
* que la velocidad máxima del auto sea al menos 10 km/h mayor a la velocidad requerida del pedido;
* que la capacidad del auto dé para la cantidad de pasajeros del viaje; y
* que el auto no sea de un color incompatible para el viaje.
*
* P.ej. consideremos al auto al que llamamos cachito en el test de la etapa 1 (recordemos: capacidad 4 pasajeros, velocidad máxima 150 km/h, color rojo).
*
* este auto puede satisfacer un pedido de 960 kms con tiempo máximo de 8 horas (lo que da una velocidad requerida de 120 km/h), para 4 pasajeros donde
* los colores incompatibles son azul y negro.
* si agregamos el rojo a los colores incompatibles, o cambiamos la cantidad de pasajeros a 6, entonces cachito ya no puede satisfacer el pedido.
* lo mismo si cambiamos el tiempo máximo a 6 horas, porque eso nos daría una velocidad requerida de 160 km/h.
*
*/
public class Pedido {
private int distanciaARecorrer;
private int tiempoMaximo;
private int cantidadPasajeros;
private Set<String> coloresIncompatibles;
public Pedido(int distanciaARecorrer, int tiempoMaximo, int cantidadPasajeros, Set<String> coloresIncompatibles) {
this.distanciaARecorrer = distanciaARecorrer;
this.tiempoMaximo = tiempoMaximo;
this.cantidadPasajeros = cantidadPasajeros;
this.coloresIncompatibles = coloresIncompatibles;
}
public boolean autoSatisfactorio(Rodado auto){
if(distanciaARecorrer/tiempoMaximo + 10 > auto.getVelocidad())
return false;
if(cantidadPasajeros > auto.getCapacidad())
return false;
if(coloresIncompatibles.stream().anyMatch(c->c.equals(auto.getColor())))
return false;
return true;
}
public int getCantidadPasajeros() {
return cantidadPasajeros;
}
public Set<String> getColoresIncompatibles() {
return coloresIncompatibles;
}
@Override
public String toString() {
return "Pedido{" + "distanciaARecorrer=" + distanciaARecorrer + ", tiempoMaximo=" + tiempoMaximo + ", cantidadPasajeros=" + cantidadPasajeros + ", coloresIncompatibles=" + coloresIncompatibles + '}';
}
}
| 3,525 | 0.705413 | 0.695157 | 79 | 42.430378 | 48.373726 | 207 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.531646 | false | false | 13 |
b16bd2cc712a71575ac2665f8933069b08a4be94 | 29,918,742,197,077 | 602f46e2d85ed571b0f40b8a1da83a5d6e6d424d | /android/ijkmediademo/src/com/ntian/videoplayer/MoviesContentAcitivity.java | e6869b107f4fb31a7043011b333ca712a41c2d9d | [] | no_license | champagneguo/Video | https://github.com/champagneguo/Video | 8fa27f2bed474469ac766396b762229700bdd364 | d02bb39daf351d0f60bc1c0fe021b4878fbf6be3 | refs/heads/master | 2021-01-10T13:31:31.668000 | 2015-06-03T13:01:17 | 2015-06-03T13:01:17 | 36,364,691 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ntian.videoplayer;
import java.io.File;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.provider.MediaStore.MediaColumns;
import android.provider.MediaStore.Video.Media;
import android.provider.MediaStore.Video.VideoColumns;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.ntian.videoplayer.greendao.DaoMaster;
import com.ntian.videoplayer.greendao.DaoMaster.DevOpenHelper;
import com.ntian.videoplayer.greendao.DaoSession;
import com.ntian.videoplayer.greendao.VideoScanRecordsDao;
public class MoviesContentAcitivity extends Activity implements
OnItemClickListener, android.view.View.OnClickListener {
private String TAG = "MoviesContentAcitivity";
private GridView mGridView;
private Button mBack, mEdit, mCancle, mSeltect, mDelete, mCancelSelected;
private ImageView mBackArrow;
private LinearLayout mLinearLayout;
private FrameLayout mFrameLayout1, mFrameLayout2;
private static final Uri VIDEO_URI = Media.EXTERNAL_CONTENT_URI;
private static final String[] PROJECTION = new String[] { BaseColumns._ID,
MediaColumns.DISPLAY_NAME, VideoColumns.DATE_TAKEN,
VideoColumns.DURATION, MediaColumns.MIME_TYPE, MediaColumns.DATA,
MediaColumns.SIZE, Media.IS_DRM, MediaColumns.DATE_MODIFIED /*
* ,
* Media
* .
* STEREO_TYPE
*/};
private static final int INDEX_ID = 0;
private static final int INDEX_DISPLAY_NAME = 1;
private static final int INDEX_TAKEN_DATE = 2;
private static final int INDEX_DRUATION = 3;
private static final int INDEX_MIME_TYPE = 4;
private static final int INDEX_DATA = 5;
private static final int INDEX_FILE_SIZE = 6;
private static final int INDEX_IS_DRM = 7;
private static final int INDEX_DATE_MODIFIED = 8;
private static final int INDEX_SUPPORT_3D = 9;
private static final String ORDER_COLUMN = VideoColumns.DATE_TAKEN
+ " DESC, " + BaseColumns._ID + " DESC ";
private MovieListAdapter mAdapter;
// private static final int MENU_DELETE_ALL = 1;
private static final int MENU_DELETE_ONE = 2;
private static final int MENU_PROPERTY = 3;
private static final int MENU_DRM_DETAIL = 4;
private static final String KEY_LOGO_BITMAP = "logo-bitmap";
private static final String KEY_TREAT_UP_AS_BACK = "treat-up-as-back";
private static final String EXTRA_ALL_VIDEO_FOLDER = "mediatek.intent.extra.ALL_VIDEO_FOLDER";
private static final String EXTRA_ENABLE_VIDEO_LIST = "mediatek.intent.extra.ENABLE_VIDEO_LIST";
private ProgressDialog mProgressDialog;
private static String[] sExternalStoragePaths;
private CachedVideoInfo mCachedVideoInfo;
private boolean Flag_Clickable = true;
private int mArrayClicked[];
private Long mBase_ID[];
private int count = 0;
private ProgressDialog mmProgressDialog;
private int mDeleteCount = 0;
private SQLiteDatabase db;
private DaoMaster daoMaster;
private DaoSession daoSession;
private VideoScanRecordsDao videoScanRecordsDao;
private boolean mGridLongClicked = true;
private VideoObserver mObserver;
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_movies_content);
mGridView = (GridView) findViewById(R.id.activity_movies_content_gv);
mBack = (Button) findViewById(R.id.activity_movies_content_back);
mBackArrow = (ImageView) findViewById(R.id.activity_movies_content_backarrow);
mEdit = (Button) findViewById(R.id.activity_movies_content_edit);
mCancle = (Button) findViewById(R.id.activity_movies_content_cancle);
mSeltect = (Button) findViewById(R.id.activity_moviescontent_allselceted);
mCancelSelected = (Button) findViewById(R.id.activity_moviescontent_cancleaselceted);
mDelete = (Button) findViewById(R.id.activity_movicescontent_delete);
mLinearLayout = (LinearLayout) findViewById(R.id.activity_moviescontent_linearbottom);
mFrameLayout1 = (FrameLayout) findViewById(R.id.FrameLayout1);
mFrameLayout2 = (FrameLayout) findViewById(R.id.FrameLayout2);
mBack.setOnClickListener(this);
mBackArrow.setOnClickListener(this);
mEdit.setOnClickListener(this);
mCancle.setOnClickListener(this);
mSeltect.setOnClickListener(this);
mCancelSelected.setOnClickListener(this);
mLinearLayout.setOnClickListener(this);
mDelete.setOnClickListener(this);
final StorageManager storageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
sExternalStoragePaths = storageManager.getVolumePaths();
Log.e(TAG, "onCreate:sExternalStoragePaths:" + sExternalStoragePaths);
mObserver = new VideoObserver(new Handler());
DevOpenHelper myHelper = new DevOpenHelper(this, "records.db", null);
db = myHelper.getWritableDatabase();
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
videoScanRecordsDao = daoSession.getVideoScanRecordsDao();
mAdapter = new MovieListAdapter(this,
R.layout.activity_moviescontent_gv, null, new String[] {},
new int[] {});
Log.e(TAG, "onCreate:mAdapter:" + mAdapter);
mGridView.setAdapter(mAdapter);
mGridView.setOnScrollListener(mAdapter);
mGridView.setOnItemClickListener(this);
// mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
mGridView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
if (mGridLongClicked == true) {
// 进入编辑状态
setIntoEdit(position);
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
if (mArrayClicked[position] == 1) {
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
}
if (RecentRecordActivity.count == (RecentRecordActivity.RecordList_Count - 1)) {
setCancleAllDelete();
}
}
mAdapter.notifyDataSetChanged();
}
if (mGridLongClicked == false) {
}
return true;
}
});
// registerForContextMenu(mGridView);
registerStorageListener();
refreshSdStatus(MtkUtils.isMediaMounted(MoviesContentAcitivity.this));
// mThumbnailCache = new ThumbnailCache(this);
// mThumbnailCache.addListener(mAdapter);
mCachedVideoInfo = new CachedVideoInfo();
MtkLog.v(TAG, "onCreate(" + savedInstanceState + ")");
this.getContentResolver().registerContentObserver(VIDEO_URI, true,
mObserver);
Log.e(TAG, "onCreate()----------->>>>>>");
}
private void refreshMovieList() {
mAdapter.getQueryHandler().removeCallbacks(null);
mAdapter.getQueryHandler().startQuery(0, null, VIDEO_URI, PROJECTION,
null, null, ORDER_COLUMN);
}
private void registerStorageListener() {
final IntentFilter iFilter = new IntentFilter();
iFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
iFilter.addAction(Intent.ACTION_MEDIA_EJECT);
iFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
iFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
iFilter.addDataScheme("file");
registerReceiver(mStorageListener, iFilter);
}
private final BroadcastReceiver mStorageListener = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
MtkLog.v(TAG, "mStorageListener.onReceive(" + intent + ")");
final String action = intent.getAction();
if (Intent.ACTION_MEDIA_SCANNER_STARTED.equals(action)) {
refreshSdStatus(MtkUtils
.isMediaMounted(MoviesContentAcitivity.this));
} else if (Intent.ACTION_MEDIA_SCANNER_FINISHED.equals(action)) {
refreshSdStatus(MtkUtils
.isMediaMounted(MoviesContentAcitivity.this));
} else if (Intent.ACTION_MEDIA_UNMOUNTED.equals(action)
|| Intent.ACTION_MEDIA_EJECT.equals(action)) {
if (intent.hasExtra(StorageVolume.EXTRA_STORAGE_VOLUME)) {
final StorageVolume storage = (StorageVolume) intent
.getParcelableExtra(StorageVolume.EXTRA_STORAGE_VOLUME);
if (storage != null
&& storage.getPath().equals(
sExternalStoragePaths[0])) {
refreshSdStatus(false);
mAdapter.changeCursor(null);
} // else contentObserver will listen it.
MtkLog.v(TAG, "mStorageListener.onReceive() eject storage="
+ (storage == null ? "null" : storage.getPath()));
}
}
};
};
private void refreshSdStatus(final boolean mounted) {
MtkLog.v(TAG, "refreshSdStatus(" + mounted + ")");
if (mounted) {
if (MtkUtils.isMediaScanning(this)) {
MtkLog.v(TAG, "refreshSdStatus() isMediaScanning true");
showScanningProgress();
MtkUtils.disableSpinnerState(this);
} else {
MtkLog.v(TAG, "refreshSdStatus() isMediaScanning false");
hideScanningProgress();
refreshMovieList();
MtkUtils.enableSpinnerState(this);
}
} else {
hideScanningProgress();
closeActivity();
MtkUtils.disableSpinnerState(this);
}
}
private void closeActivity() {
AlertDialog.Builder builder = new AlertDialog.Builder(
MoviesContentAcitivity.this);
builder.setTitle("提示信息");
builder.setMessage("SD尚未加载,请退出。");
builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
});
builder.create().show();
}
private void showScanningProgress() {
showProgress(getString(R.string.scanning), new OnCancelListener() {
@Override
public void onCancel(final DialogInterface dialog) {
MtkLog.v(TAG, "mProgressDialog.onCancel()");
hideScanningProgress();
finish();
}
});
}
private void hideScanningProgress() {
hideProgress();
}
private void showProgress(final String message,
final OnCancelListener cancelListener) {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.setCancelable(cancelListener != null);
mProgressDialog.setOnCancelListener(cancelListener);
mProgressDialog.setMessage(message);
}
mProgressDialog.show();
}
private void hideProgress() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
if (Flag_Clickable == true) {
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
final Intent intent = new Intent(Intent.ACTION_VIEW);
String mime = "video/*";
if (!(holder.mMimetype == null || "".equals(holder.mMimetype
.trim()))) {
mime = holder.mMimetype;
}
intent.setDataAndType(
ContentUris.withAppendedId(VIDEO_URI, holder.mId), mime);
intent.putExtra("mBase_ID", holder.mId);
intent.putExtra("video_path", holder.mData);
intent.putExtra(EXTRA_ALL_VIDEO_FOLDER, true);
intent.putExtra(KEY_TREAT_UP_AS_BACK, true);
intent.putExtra(EXTRA_ENABLE_VIDEO_LIST, true);
intent.putExtra("mTitle", holder.mTitle);
intent.putExtra("mDuration", holder.mDuration);
intent.putExtra("mDateModified", holder.mDateModified);
intent.putExtra("mIsDrm", holder.mIsDrm);
intent.putExtra("mSupport3D", holder.mSupport3D);
intent.putExtra(KEY_LOGO_BITMAP, BitmapFactory.decodeResource(
getResources(), R.drawable.ic_video_app));
intent.setComponent(new ComponentName("com.ntian.videoplayer",
"com.ntian.videoplayer.VideoPlayerActivity")); // add by
// ChMX
try {
startActivity(intent);
} catch (final ActivityNotFoundException e) {
e.printStackTrace();
}
}
} else if (Flag_Clickable == false) {
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
if (mArrayClicked[position] == 1) {
mArrayClicked[position] = 0;
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.VISIBLE);
count--;
} else if (mArrayClicked[position] == 0) {
mArrayClicked[position] = 1;
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
count++;
}
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
Log.e(TAG, "OnItemCount-->>>" + count);
if (count == (mAdapter.getCount() - 1)) {
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
}
if (count == (mAdapter.getCount())) {
mCancelSelected.setVisibility(View.VISIBLE);
mSeltect.setVisibility(View.GONE);
}
}
}
MtkLog.v(TAG, "onItemClick(" + position + ", " + id + ") ");
}
// @Override
// public void onCreateContextMenu(final ContextMenu menu, final View v,
// final ContextMenuInfo menuInfo) {
// super.onCreateContextMenu(menu, v, menuInfo);
// final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
// final Object obj = info.targetView.getTag();
// ViewHolder holder = null;
// if (obj instanceof ViewHolder) {
// holder = (ViewHolder) obj;
// menu.setHeaderTitle(holder.mTitle);
// menu.add(0, MENU_DELETE_ONE, 0, R.string.delete);
// menu.add(0, MENU_PROPERTY, 0, R.string.media_detail);
// if (MtkUtils.isSupportDrm() && holder.mIsDrm) {
// menu.add(0, MENU_DRM_DETAIL, 0,
// com.mediatek.R.string.drm_protectioninfo_title);
// }
// }
// }
@Override
public boolean onContextItemSelected(final MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
final Object obj = info.targetView.getTag();
ViewHolder holder = null;
if (obj instanceof ViewHolder) {
holder = (ViewHolder) obj;
}
if (holder == null) {
MtkLog.w(TAG, "wrong context item info " + info);
return true;
}
switch (item.getItemId()) {
case MENU_DELETE_ONE:
showDelete(holder.clone());
return true;
case MENU_PROPERTY:
showDetail(holder.clone());
return true;
case MENU_DRM_DETAIL:
if (MtkUtils.isSupportDrm()) {
MtkUtils.showDrmDetails(this, holder.mData);
}
break;
default:
break;
}
return super.onContextItemSelected(item);
}
private void showDetail(final ViewHolder holder) {
final DetailDialog detailDialog = new DetailDialog(this, holder);
detailDialog.setTitle(R.string.media_detail);
detailDialog.show();
}
private void showDelete(final ViewHolder holder) {
MtkLog.v(TAG, "showDelete(" + holder + ")");
new AlertDialog.Builder(this)
.setTitle(R.string.delete)
.setMessage(getString(R.string.delete_tip, holder.mTitle))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
MtkLog.v(TAG, "Delete.onClick() " + holder);
new DeleteTask(holder).execute();
}
}).setNegativeButton(android.R.string.cancel, null).create()
.show();
}
public class DeleteTask extends AsyncTask<Void, Void, Void> {
private final ViewHolder mHolder;
public DeleteTask(final ViewHolder holder) {
mHolder = holder;
}
@Override
protected void onPreExecute() {
showDeleteProgress(getString(R.string.delete_progress,
mHolder.mTitle));
}
@Override
protected void onPostExecute(final Void result) {
hideDeleteProgress();
}
private void showDeleteProgress(final String message) {
showProgress(message, null);
}
private void hideDeleteProgress() {
hideProgress();
}
@Override
protected Void doInBackground(final Void... params) {
final ViewHolder holder = mHolder;
if (holder == null) {
MtkLog.w(TAG, "DeleteTask.doInBackground holder=" + holder);
} else {
int count = 0;
try {
count = getContentResolver().delete(
ContentUris.withAppendedId(VIDEO_URI, holder.mId),
null, null);
} catch (final SQLiteException e) {
e.printStackTrace();
}
MtkLog.v(TAG, "DeleteTask.doInBackground delete count=" + count);
}
return null;
}
}
class MovieListAdapter extends SimpleCursorAdapter implements
/* ThumbnailCache.ThumbnailStateListener, */OnScrollListener {
private static final String TAG = "MovieListAdapter";
private final QueryHandler mQueryHandler;
private final ArrayList<ViewHolder> mCachedHolder = new ArrayList<ViewHolder>();
private static final String VALUE_IS_DRM = "1";
QueryHandler getQueryHandler() {
return mQueryHandler;
}
@SuppressWarnings("deprecation")
public MovieListAdapter(final Context context, final int layout,
final Cursor c, final String[] from, final int[] to) {
super(context, layout, c, from, to);
mQueryHandler = new QueryHandler(getContentResolver());
}
@Override
public void notifyDataSetChanged() {
// TODO Auto-generated method stub
super.notifyDataSetChanged();
if (isEmpty()) {
mEdit.setVisibility(View.GONE);
mFrameLayout1.setVisibility(View.GONE);
mFrameLayout2.setVisibility(View.VISIBLE);
} else {
mEdit.setVisibility(View.VISIBLE);
mFrameLayout1.setVisibility(View.VISIBLE);
mFrameLayout2.setVisibility(View.GONE);
}
}
@Override
public View newView(final Context context, final Cursor cursor,
final ViewGroup parent) {
final View view = super.newView(context, cursor, parent);
final ViewHolder holder = new ViewHolder();
holder.mIcon = (SimpleDraweeView) view
.findViewById(R.id.activity_moviescontent_gv_image);
holder.mTitleView = (TextView) view
.findViewById(R.id.activity_moviescontent_gv_name);
// holder.mFileSizeView = (TextView)
// view.findViewById(R.id.item_date);
holder.mDurationView = (TextView) view
.findViewById(R.id.activity_moviescontent_gv_time);
holder.mImageView_grey = (ImageView) view
.findViewById(R.id.activity_moviescontent_gv_image_nor);
holder.mImageView_Blue = (ImageView) view
.findViewById(R.id.activity_moviescontent_gv_image_sel);
// int width = mThumbnailCache.getDefaultThumbnailWidth();
// int height = mThumbnailCache.getDefaultThumbnailHeight();
holder.mFastDrawable = new FastBitmapDrawable(155, 98);
view.setTag(holder);
mCachedHolder.add(holder);
MtkLog.v(TAG,
"newView() mCachedHolder.size()=" + mCachedHolder.size());
return view;
}
/*
* public void onChanged(final long rowId, final int type, final Bitmap
* drawable) {
*
* Log.e(TAG,
* "ThumbnailCache.ThumbnailStateListener:onChanged------------" +
* rowId); MtkLog.v(TAG, "onChanged(" + rowId + ", " + type + ", " +
* drawable + ")"); for (final ViewHolder holder : mCachedHolder) { if
* (holder.mId == rowId) { refreshThumbnail(holder); break; } } }
*/
public void clearCachedHolder() {
mCachedHolder.clear();
}
@Override
public void bindView(final View view, final Context context,
final Cursor cursor) {
final ViewHolder holder = (ViewHolder) view.getTag();
holder.mId = cursor.getLong(INDEX_ID);
holder.mTitle = cursor.getString(INDEX_DISPLAY_NAME);
holder.mDateTaken = cursor.getLong(INDEX_TAKEN_DATE);
holder.mMimetype = cursor.getString(INDEX_MIME_TYPE);
holder.mData = cursor.getString(INDEX_DATA);
holder.mFileSize = cursor.getLong(INDEX_FILE_SIZE);
holder.mDuration = cursor.getLong(INDEX_DRUATION);
holder.mIsDrm = VALUE_IS_DRM.equals(cursor.getString(INDEX_IS_DRM));
holder.mDateModified = cursor.getLong(INDEX_DATE_MODIFIED);
//holder.mSupport3D = MtkUtils.isStereo3D(cursor
//.getInt(INDEX_SUPPORT_3D));
holder.mTitleView.setText(holder.mTitle);
if (Flag_Clickable == false) {
if (mArrayClicked[cursor.getPosition()] == 0) {
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.VISIBLE);
}
if (mArrayClicked[cursor.getPosition()] == 1) {
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
}
}
if (Flag_Clickable == true) {
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.GONE);
}
// holder.mFileSizeView.setText(mCachedVideoInfo.getFileSize(
// MoviesContentAcitivity.this, holder.mFileSize));
holder.mDurationView.setText(mCachedVideoInfo
.getDuration(holder.mDuration));
String path = VideoApplication.mThumbnailPath.get(holder.mId);
if (path != null) {
Uri uri = Uri.fromFile(new File(path));
holder.mIcon.setImageURI(uri);
} else {
Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail(
mContext.getContentResolver(), holder.mId, 1999,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
holder.mIcon.setImageBitmap(bitmap);
}
// holder.mIcon.setImageURI(uri);
// refreshThumbnail(holder);
MtkLog.v(TAG, "bindeView() " + holder);
}
@Override
public void changeCursor(final Cursor c) {
Log.e(TAG, "changeCursor---->>" + c);
super.changeCursor(c);
}
@Override
protected void onContentChanged() {
Log.e(TAG, "onContentChanged:--->>" + getCursor());
mQueryHandler.onQueryComplete(0, null, getCursor());
super.onContentChanged();
}
class QueryHandler extends AsyncQueryHandler {
QueryHandler(final ContentResolver cr) {
super(cr);
}
@Override
protected void onQueryComplete(final int token,
final Object cookie, final Cursor cursor) {
MtkLog.v(TAG, "onQueryComplete(" + token + "," + cookie + ","
+ cursor + ")");
MtkUtils.disableSpinnerState(MoviesContentAcitivity.this);
if (cursor == null || cursor.getCount() == 0) {
// 当数据库没有找到数据时,或cursor找不到
if (cursor == null) {
final AlertDialog.Builder builder = new Builder(
MoviesContentAcitivity.this);
builder.setTitle("温馨提示:");
builder.setMessage("视频文件查询失败");
builder.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
finish();
}
});
builder.create().show();
}
if (cursor != null) { // to observe database change
changeCursor(cursor);
}
} else {
changeCursor(cursor);
}
if (cursor != null) {
MtkLog.v(TAG, "onQueryComplete() end");
}
}
@Override
protected void onDeleteComplete(int token, Object cookie, int result) {
// TODO Auto-generated method stub
super.onDeleteComplete(token, cookie, result);
if (result > 0) {
mDeleteCount--;
Log.e(TAG, "onDeleteComplete----------->" + mDeleteCount);
if (mDeleteCount == 0) {
mmProgressDialog.dismiss();
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
notifyDataSetChanged();
Toast.makeText(MoviesContentAcitivity.this, "删除完成",
Toast.LENGTH_SHORT).show();
}
}
}
}
@Override
public void onScroll(final AbsListView view,
final int firstVisibleItem, final int visibleItemCount,
final int totalItemCount) {
}
private boolean mFling = false;
@Override
public void onScrollStateChanged(final AbsListView view,
final int scrollState) {
switch (scrollState) {
case OnScrollListener.SCROLL_STATE_IDLE:
mFling = false;
// notify data changed to load bitmap from mediastore.
notifyDataSetChanged();
break;
case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
mFling = false;
break;
case OnScrollListener.SCROLL_STATE_FLING:
mFling = true;
break;
default:
break;
}
MtkLog.v(TAG, "onScrollStateChanged(" + scrollState + ") mFling="
+ mFling);
}
}
public class ViewHolder {
long mId;
String mTitle;
String mMimetype;
String mData;
long mDuration;
long mDateTaken;
long mFileSize;
boolean mIsDrm;
long mDateModified;
boolean mSupport3D;
SimpleDraweeView mIcon;
ImageView mImageView_grey;
ImageView mImageView_Blue;
TextView mTitleView;
TextView mFileSizeView;
TextView mDurationView;
FastBitmapDrawable mFastDrawable;
@Override
public String toString() {
return new StringBuilder().append("ViewHolder(mId=").append(mId)
.append(", mTitle=").append(mTitle).append(", mDuration=")
.append(mDuration).append(", mIsDrm=").append(mIsDrm)
.append(", mData=").append(mData).append(", mDateModified")
.append(mDateModified).append(", mFileSize=")
.append(mFileSize).append(", mSupport3D=")
.append(mSupport3D).append(")").toString();
}
/**
* just clone info
*/
@Override
protected ViewHolder clone() {
final ViewHolder holder = new ViewHolder();
holder.mId = mId;
holder.mTitle = mTitle;
holder.mMimetype = mMimetype;
holder.mData = mData;
holder.mDuration = mDuration;
holder.mDateTaken = mDateTaken;
holder.mFileSize = mFileSize;
holder.mIsDrm = mIsDrm;
holder.mDateModified = mDateModified;
holder.mSupport3D = mSupport3D;
return holder;
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
unregisterReceiver(mStorageListener);
if (db != null) {
db.close();
db = null;
}
mGridLongClicked = true;
this.getContentResolver().unregisterContentObserver(mObserver);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.activity_movies_content_back:
finish();
break;
case R.id.activity_movies_content_backarrow:
finish();
break;
case R.id.activity_movies_content_edit:
mEdit.setVisibility(View.GONE);
mCancle.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = false;
mGridLongClicked = false;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
// 将MediaID存入数组;
Cursor cursor = mAdapter.getCursor();
cursor.moveToFirst();
int j = 0;
do {
mBase_ID[j++] = cursor.getLong(INDEX_ID);
} while (cursor.moveToNext());
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->" + count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_movies_content_cancle:
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
mGridLongClicked = true;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->" + count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
case R.id.activity_moviescontent_allselceted:
count = mAdapter.getCount();
mArrayClicked = new int[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 1;
}
mAdapter.notifyDataSetChanged();
mCancelSelected.setVisibility(View.VISIBLE);
mSeltect.setVisibility(View.GONE);
Log.e(TAG, "R.id.activity_moviescontent_allselceted:count--->"
+ count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_moviescontent_cancleaselceted:
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
}
mAdapter.notifyDataSetChanged();
mSeltect.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
Log.e(TAG, "R.id.activity_moviescontent_cancleaselceted:count--->"
+ count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_movicescontent_delete:
if (count == 0) {
Toast.makeText(MoviesContentAcitivity.this, "尚未选中删除条目",
Toast.LENGTH_SHORT).show();
} else {
AlertDialog.Builder builder = new Builder(
MoviesContentAcitivity.this);
builder.setTitle("温馨提示");
builder.setMessage("确认删除" + count + "条记录?");
builder.setPositiveButton("确认", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
mmProgressDialog = new ProgressDialog(
MoviesContentAcitivity.this);
mmProgressDialog.setMessage("正在删除,请稍等...");
mmProgressDialog.show();
for (int i = 0; i < mAdapter.getCount(); i++) {
if (mArrayClicked[i] == 1) {
// long _ID = -1L;
mAdapter.getQueryHandler().startDelete(0, null,
VIDEO_URI, BaseColumns._ID + " = ?",
new String[] { "" + mBase_ID[i] });
mDeleteCount++;
Log.e(TAG,
"startDelete:mDeleteCount------->>>>"
+ mDeleteCount);
// _ID = mFindRecordByID(mBase_ID[i]);
// if (_ID > -1) {
// videoScanRecordsDao.deleteByKey(_ID);
// }
}
}
}
});
builder.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.create().show();
}
break;
default:
break;
}
}
public void setIntoEdit(int position) {
mEdit.setVisibility(View.GONE);
mCancle.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = false;
mGridLongClicked = false;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
if (i == position) {
mArrayClicked[i] = 1;
count++;
}
}
// 将MediaID存入数组;
Cursor cursor = mAdapter.getCursor();
cursor.moveToFirst();
int j = 0;
do {
mBase_ID[j++] = cursor.getLong(INDEX_ID);
} while (cursor.moveToNext());
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
}
// 取消全选后操作
public void setCancleAllDelete() {
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
}
// // 根据mBase_ID值查询ID值;
// private long mFindRecordByID(Long mBase_ID) {
// Log.e(TAG, "mFindRecordByID()---------------->>" + mBase_ID);
// long _id = -1;
// QueryBuilder<VideoScanRecords> qb = videoScanRecordsDao.queryBuilder();
// qb.where(VideoScanRecordsDao.Properties.Base_ID.eq(mBase_ID));
// if (qb.buildCount().count() > 0) {
// _id = qb.list().get(0).getId();
// }
// return _id;
//
// }
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.e(TAG, "onResume()::------>>>>>>>");
Cursor c = getContentResolver().query(
MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, null, null,
null, null);
c.moveToFirst();
VideoApplication.mThumbnailPath.clear();
while (!c.isAfterLast()) {
long id = c.getLong(c
.getColumnIndex(MediaStore.Video.Thumbnails.VIDEO_ID));
String path = c.getString(c
.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
Log.e("NTVideoPlayer", "id " + id + " path " + path);
VideoApplication.mThumbnailPath.put(id, path);
c.moveToNext();
}
Log.e(TAG, "c.size()::::::::" + c.getCount());
c.close();
c = null;
Log.e(TAG, "onResume:END!!!");
}
private final class VideoObserver extends ContentObserver {
public VideoObserver(Handler handler) {
super(handler);
// TODO Auto-generated constructor stub
}
@Override
public void onChange(boolean selfChange) {
// TODO Auto-generated method stub
super.onChange(selfChange);
Log.e(TAG, "onChanger-------------------..........>>>>");
if (Flag_Clickable == false) {
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
mGridLongClicked = true;
count = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->"
+ count);
mDelete.setText(MoviesContentAcitivity.this.getResources()
.getText(R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
}
Cursor c = getContentResolver().query(
MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, null,
null, null, null);
c.moveToFirst();
VideoApplication.mThumbnailPath.clear();
while (!c.isAfterLast()) {
long id = c.getLong(c
.getColumnIndex(MediaStore.Video.Thumbnails.VIDEO_ID));
String path = c.getString(c
.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
Log.d("NTVideoPlayer", "id " + id + " path " + path);
VideoApplication.mThumbnailPath.put(id, path);
c.moveToNext();
}
c.close();
}
}
}
| UTF-8 | Java | 36,241 | java | MoviesContentAcitivity.java | Java | [
{
"context": "oPlayerActivity\")); // add by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// ChMX\n\t\t\t\ttry {\n\t\t\t\t\tstartActivity(intent);\n\t\t\t\t} catch",
"end": 13743,
"score": 0.7036411762237549,
"start": 13739,
"tag": "NAME",
"value": "ChMX"
}
] | null | [] | package com.ntian.videoplayer;
import java.io.File;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.provider.MediaStore.MediaColumns;
import android.provider.MediaStore.Video.Media;
import android.provider.MediaStore.Video.VideoColumns;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.ntian.videoplayer.greendao.DaoMaster;
import com.ntian.videoplayer.greendao.DaoMaster.DevOpenHelper;
import com.ntian.videoplayer.greendao.DaoSession;
import com.ntian.videoplayer.greendao.VideoScanRecordsDao;
public class MoviesContentAcitivity extends Activity implements
OnItemClickListener, android.view.View.OnClickListener {
private String TAG = "MoviesContentAcitivity";
private GridView mGridView;
private Button mBack, mEdit, mCancle, mSeltect, mDelete, mCancelSelected;
private ImageView mBackArrow;
private LinearLayout mLinearLayout;
private FrameLayout mFrameLayout1, mFrameLayout2;
private static final Uri VIDEO_URI = Media.EXTERNAL_CONTENT_URI;
private static final String[] PROJECTION = new String[] { BaseColumns._ID,
MediaColumns.DISPLAY_NAME, VideoColumns.DATE_TAKEN,
VideoColumns.DURATION, MediaColumns.MIME_TYPE, MediaColumns.DATA,
MediaColumns.SIZE, Media.IS_DRM, MediaColumns.DATE_MODIFIED /*
* ,
* Media
* .
* STEREO_TYPE
*/};
private static final int INDEX_ID = 0;
private static final int INDEX_DISPLAY_NAME = 1;
private static final int INDEX_TAKEN_DATE = 2;
private static final int INDEX_DRUATION = 3;
private static final int INDEX_MIME_TYPE = 4;
private static final int INDEX_DATA = 5;
private static final int INDEX_FILE_SIZE = 6;
private static final int INDEX_IS_DRM = 7;
private static final int INDEX_DATE_MODIFIED = 8;
private static final int INDEX_SUPPORT_3D = 9;
private static final String ORDER_COLUMN = VideoColumns.DATE_TAKEN
+ " DESC, " + BaseColumns._ID + " DESC ";
private MovieListAdapter mAdapter;
// private static final int MENU_DELETE_ALL = 1;
private static final int MENU_DELETE_ONE = 2;
private static final int MENU_PROPERTY = 3;
private static final int MENU_DRM_DETAIL = 4;
private static final String KEY_LOGO_BITMAP = "logo-bitmap";
private static final String KEY_TREAT_UP_AS_BACK = "treat-up-as-back";
private static final String EXTRA_ALL_VIDEO_FOLDER = "mediatek.intent.extra.ALL_VIDEO_FOLDER";
private static final String EXTRA_ENABLE_VIDEO_LIST = "mediatek.intent.extra.ENABLE_VIDEO_LIST";
private ProgressDialog mProgressDialog;
private static String[] sExternalStoragePaths;
private CachedVideoInfo mCachedVideoInfo;
private boolean Flag_Clickable = true;
private int mArrayClicked[];
private Long mBase_ID[];
private int count = 0;
private ProgressDialog mmProgressDialog;
private int mDeleteCount = 0;
private SQLiteDatabase db;
private DaoMaster daoMaster;
private DaoSession daoSession;
private VideoScanRecordsDao videoScanRecordsDao;
private boolean mGridLongClicked = true;
private VideoObserver mObserver;
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_movies_content);
mGridView = (GridView) findViewById(R.id.activity_movies_content_gv);
mBack = (Button) findViewById(R.id.activity_movies_content_back);
mBackArrow = (ImageView) findViewById(R.id.activity_movies_content_backarrow);
mEdit = (Button) findViewById(R.id.activity_movies_content_edit);
mCancle = (Button) findViewById(R.id.activity_movies_content_cancle);
mSeltect = (Button) findViewById(R.id.activity_moviescontent_allselceted);
mCancelSelected = (Button) findViewById(R.id.activity_moviescontent_cancleaselceted);
mDelete = (Button) findViewById(R.id.activity_movicescontent_delete);
mLinearLayout = (LinearLayout) findViewById(R.id.activity_moviescontent_linearbottom);
mFrameLayout1 = (FrameLayout) findViewById(R.id.FrameLayout1);
mFrameLayout2 = (FrameLayout) findViewById(R.id.FrameLayout2);
mBack.setOnClickListener(this);
mBackArrow.setOnClickListener(this);
mEdit.setOnClickListener(this);
mCancle.setOnClickListener(this);
mSeltect.setOnClickListener(this);
mCancelSelected.setOnClickListener(this);
mLinearLayout.setOnClickListener(this);
mDelete.setOnClickListener(this);
final StorageManager storageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
sExternalStoragePaths = storageManager.getVolumePaths();
Log.e(TAG, "onCreate:sExternalStoragePaths:" + sExternalStoragePaths);
mObserver = new VideoObserver(new Handler());
DevOpenHelper myHelper = new DevOpenHelper(this, "records.db", null);
db = myHelper.getWritableDatabase();
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
videoScanRecordsDao = daoSession.getVideoScanRecordsDao();
mAdapter = new MovieListAdapter(this,
R.layout.activity_moviescontent_gv, null, new String[] {},
new int[] {});
Log.e(TAG, "onCreate:mAdapter:" + mAdapter);
mGridView.setAdapter(mAdapter);
mGridView.setOnScrollListener(mAdapter);
mGridView.setOnItemClickListener(this);
// mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
mGridView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
if (mGridLongClicked == true) {
// 进入编辑状态
setIntoEdit(position);
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
if (mArrayClicked[position] == 1) {
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
}
if (RecentRecordActivity.count == (RecentRecordActivity.RecordList_Count - 1)) {
setCancleAllDelete();
}
}
mAdapter.notifyDataSetChanged();
}
if (mGridLongClicked == false) {
}
return true;
}
});
// registerForContextMenu(mGridView);
registerStorageListener();
refreshSdStatus(MtkUtils.isMediaMounted(MoviesContentAcitivity.this));
// mThumbnailCache = new ThumbnailCache(this);
// mThumbnailCache.addListener(mAdapter);
mCachedVideoInfo = new CachedVideoInfo();
MtkLog.v(TAG, "onCreate(" + savedInstanceState + ")");
this.getContentResolver().registerContentObserver(VIDEO_URI, true,
mObserver);
Log.e(TAG, "onCreate()----------->>>>>>");
}
private void refreshMovieList() {
mAdapter.getQueryHandler().removeCallbacks(null);
mAdapter.getQueryHandler().startQuery(0, null, VIDEO_URI, PROJECTION,
null, null, ORDER_COLUMN);
}
private void registerStorageListener() {
final IntentFilter iFilter = new IntentFilter();
iFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
iFilter.addAction(Intent.ACTION_MEDIA_EJECT);
iFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
iFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
iFilter.addDataScheme("file");
registerReceiver(mStorageListener, iFilter);
}
private final BroadcastReceiver mStorageListener = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
MtkLog.v(TAG, "mStorageListener.onReceive(" + intent + ")");
final String action = intent.getAction();
if (Intent.ACTION_MEDIA_SCANNER_STARTED.equals(action)) {
refreshSdStatus(MtkUtils
.isMediaMounted(MoviesContentAcitivity.this));
} else if (Intent.ACTION_MEDIA_SCANNER_FINISHED.equals(action)) {
refreshSdStatus(MtkUtils
.isMediaMounted(MoviesContentAcitivity.this));
} else if (Intent.ACTION_MEDIA_UNMOUNTED.equals(action)
|| Intent.ACTION_MEDIA_EJECT.equals(action)) {
if (intent.hasExtra(StorageVolume.EXTRA_STORAGE_VOLUME)) {
final StorageVolume storage = (StorageVolume) intent
.getParcelableExtra(StorageVolume.EXTRA_STORAGE_VOLUME);
if (storage != null
&& storage.getPath().equals(
sExternalStoragePaths[0])) {
refreshSdStatus(false);
mAdapter.changeCursor(null);
} // else contentObserver will listen it.
MtkLog.v(TAG, "mStorageListener.onReceive() eject storage="
+ (storage == null ? "null" : storage.getPath()));
}
}
};
};
private void refreshSdStatus(final boolean mounted) {
MtkLog.v(TAG, "refreshSdStatus(" + mounted + ")");
if (mounted) {
if (MtkUtils.isMediaScanning(this)) {
MtkLog.v(TAG, "refreshSdStatus() isMediaScanning true");
showScanningProgress();
MtkUtils.disableSpinnerState(this);
} else {
MtkLog.v(TAG, "refreshSdStatus() isMediaScanning false");
hideScanningProgress();
refreshMovieList();
MtkUtils.enableSpinnerState(this);
}
} else {
hideScanningProgress();
closeActivity();
MtkUtils.disableSpinnerState(this);
}
}
private void closeActivity() {
AlertDialog.Builder builder = new AlertDialog.Builder(
MoviesContentAcitivity.this);
builder.setTitle("提示信息");
builder.setMessage("SD尚未加载,请退出。");
builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
});
builder.create().show();
}
private void showScanningProgress() {
showProgress(getString(R.string.scanning), new OnCancelListener() {
@Override
public void onCancel(final DialogInterface dialog) {
MtkLog.v(TAG, "mProgressDialog.onCancel()");
hideScanningProgress();
finish();
}
});
}
private void hideScanningProgress() {
hideProgress();
}
private void showProgress(final String message,
final OnCancelListener cancelListener) {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.setCancelable(cancelListener != null);
mProgressDialog.setOnCancelListener(cancelListener);
mProgressDialog.setMessage(message);
}
mProgressDialog.show();
}
private void hideProgress() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
if (Flag_Clickable == true) {
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
final Intent intent = new Intent(Intent.ACTION_VIEW);
String mime = "video/*";
if (!(holder.mMimetype == null || "".equals(holder.mMimetype
.trim()))) {
mime = holder.mMimetype;
}
intent.setDataAndType(
ContentUris.withAppendedId(VIDEO_URI, holder.mId), mime);
intent.putExtra("mBase_ID", holder.mId);
intent.putExtra("video_path", holder.mData);
intent.putExtra(EXTRA_ALL_VIDEO_FOLDER, true);
intent.putExtra(KEY_TREAT_UP_AS_BACK, true);
intent.putExtra(EXTRA_ENABLE_VIDEO_LIST, true);
intent.putExtra("mTitle", holder.mTitle);
intent.putExtra("mDuration", holder.mDuration);
intent.putExtra("mDateModified", holder.mDateModified);
intent.putExtra("mIsDrm", holder.mIsDrm);
intent.putExtra("mSupport3D", holder.mSupport3D);
intent.putExtra(KEY_LOGO_BITMAP, BitmapFactory.decodeResource(
getResources(), R.drawable.ic_video_app));
intent.setComponent(new ComponentName("com.ntian.videoplayer",
"com.ntian.videoplayer.VideoPlayerActivity")); // add by
// ChMX
try {
startActivity(intent);
} catch (final ActivityNotFoundException e) {
e.printStackTrace();
}
}
} else if (Flag_Clickable == false) {
final Object o = view.getTag();
ViewHolder holder = null;
if (o instanceof ViewHolder) {
holder = (ViewHolder) o;
if (mArrayClicked[position] == 1) {
mArrayClicked[position] = 0;
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.VISIBLE);
count--;
} else if (mArrayClicked[position] == 0) {
mArrayClicked[position] = 1;
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
count++;
}
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
Log.e(TAG, "OnItemCount-->>>" + count);
if (count == (mAdapter.getCount() - 1)) {
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
}
if (count == (mAdapter.getCount())) {
mCancelSelected.setVisibility(View.VISIBLE);
mSeltect.setVisibility(View.GONE);
}
}
}
MtkLog.v(TAG, "onItemClick(" + position + ", " + id + ") ");
}
// @Override
// public void onCreateContextMenu(final ContextMenu menu, final View v,
// final ContextMenuInfo menuInfo) {
// super.onCreateContextMenu(menu, v, menuInfo);
// final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
// final Object obj = info.targetView.getTag();
// ViewHolder holder = null;
// if (obj instanceof ViewHolder) {
// holder = (ViewHolder) obj;
// menu.setHeaderTitle(holder.mTitle);
// menu.add(0, MENU_DELETE_ONE, 0, R.string.delete);
// menu.add(0, MENU_PROPERTY, 0, R.string.media_detail);
// if (MtkUtils.isSupportDrm() && holder.mIsDrm) {
// menu.add(0, MENU_DRM_DETAIL, 0,
// com.mediatek.R.string.drm_protectioninfo_title);
// }
// }
// }
@Override
public boolean onContextItemSelected(final MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
final Object obj = info.targetView.getTag();
ViewHolder holder = null;
if (obj instanceof ViewHolder) {
holder = (ViewHolder) obj;
}
if (holder == null) {
MtkLog.w(TAG, "wrong context item info " + info);
return true;
}
switch (item.getItemId()) {
case MENU_DELETE_ONE:
showDelete(holder.clone());
return true;
case MENU_PROPERTY:
showDetail(holder.clone());
return true;
case MENU_DRM_DETAIL:
if (MtkUtils.isSupportDrm()) {
MtkUtils.showDrmDetails(this, holder.mData);
}
break;
default:
break;
}
return super.onContextItemSelected(item);
}
private void showDetail(final ViewHolder holder) {
final DetailDialog detailDialog = new DetailDialog(this, holder);
detailDialog.setTitle(R.string.media_detail);
detailDialog.show();
}
private void showDelete(final ViewHolder holder) {
MtkLog.v(TAG, "showDelete(" + holder + ")");
new AlertDialog.Builder(this)
.setTitle(R.string.delete)
.setMessage(getString(R.string.delete_tip, holder.mTitle))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
MtkLog.v(TAG, "Delete.onClick() " + holder);
new DeleteTask(holder).execute();
}
}).setNegativeButton(android.R.string.cancel, null).create()
.show();
}
public class DeleteTask extends AsyncTask<Void, Void, Void> {
private final ViewHolder mHolder;
public DeleteTask(final ViewHolder holder) {
mHolder = holder;
}
@Override
protected void onPreExecute() {
showDeleteProgress(getString(R.string.delete_progress,
mHolder.mTitle));
}
@Override
protected void onPostExecute(final Void result) {
hideDeleteProgress();
}
private void showDeleteProgress(final String message) {
showProgress(message, null);
}
private void hideDeleteProgress() {
hideProgress();
}
@Override
protected Void doInBackground(final Void... params) {
final ViewHolder holder = mHolder;
if (holder == null) {
MtkLog.w(TAG, "DeleteTask.doInBackground holder=" + holder);
} else {
int count = 0;
try {
count = getContentResolver().delete(
ContentUris.withAppendedId(VIDEO_URI, holder.mId),
null, null);
} catch (final SQLiteException e) {
e.printStackTrace();
}
MtkLog.v(TAG, "DeleteTask.doInBackground delete count=" + count);
}
return null;
}
}
class MovieListAdapter extends SimpleCursorAdapter implements
/* ThumbnailCache.ThumbnailStateListener, */OnScrollListener {
private static final String TAG = "MovieListAdapter";
private final QueryHandler mQueryHandler;
private final ArrayList<ViewHolder> mCachedHolder = new ArrayList<ViewHolder>();
private static final String VALUE_IS_DRM = "1";
QueryHandler getQueryHandler() {
return mQueryHandler;
}
@SuppressWarnings("deprecation")
public MovieListAdapter(final Context context, final int layout,
final Cursor c, final String[] from, final int[] to) {
super(context, layout, c, from, to);
mQueryHandler = new QueryHandler(getContentResolver());
}
@Override
public void notifyDataSetChanged() {
// TODO Auto-generated method stub
super.notifyDataSetChanged();
if (isEmpty()) {
mEdit.setVisibility(View.GONE);
mFrameLayout1.setVisibility(View.GONE);
mFrameLayout2.setVisibility(View.VISIBLE);
} else {
mEdit.setVisibility(View.VISIBLE);
mFrameLayout1.setVisibility(View.VISIBLE);
mFrameLayout2.setVisibility(View.GONE);
}
}
@Override
public View newView(final Context context, final Cursor cursor,
final ViewGroup parent) {
final View view = super.newView(context, cursor, parent);
final ViewHolder holder = new ViewHolder();
holder.mIcon = (SimpleDraweeView) view
.findViewById(R.id.activity_moviescontent_gv_image);
holder.mTitleView = (TextView) view
.findViewById(R.id.activity_moviescontent_gv_name);
// holder.mFileSizeView = (TextView)
// view.findViewById(R.id.item_date);
holder.mDurationView = (TextView) view
.findViewById(R.id.activity_moviescontent_gv_time);
holder.mImageView_grey = (ImageView) view
.findViewById(R.id.activity_moviescontent_gv_image_nor);
holder.mImageView_Blue = (ImageView) view
.findViewById(R.id.activity_moviescontent_gv_image_sel);
// int width = mThumbnailCache.getDefaultThumbnailWidth();
// int height = mThumbnailCache.getDefaultThumbnailHeight();
holder.mFastDrawable = new FastBitmapDrawable(155, 98);
view.setTag(holder);
mCachedHolder.add(holder);
MtkLog.v(TAG,
"newView() mCachedHolder.size()=" + mCachedHolder.size());
return view;
}
/*
* public void onChanged(final long rowId, final int type, final Bitmap
* drawable) {
*
* Log.e(TAG,
* "ThumbnailCache.ThumbnailStateListener:onChanged------------" +
* rowId); MtkLog.v(TAG, "onChanged(" + rowId + ", " + type + ", " +
* drawable + ")"); for (final ViewHolder holder : mCachedHolder) { if
* (holder.mId == rowId) { refreshThumbnail(holder); break; } } }
*/
public void clearCachedHolder() {
mCachedHolder.clear();
}
@Override
public void bindView(final View view, final Context context,
final Cursor cursor) {
final ViewHolder holder = (ViewHolder) view.getTag();
holder.mId = cursor.getLong(INDEX_ID);
holder.mTitle = cursor.getString(INDEX_DISPLAY_NAME);
holder.mDateTaken = cursor.getLong(INDEX_TAKEN_DATE);
holder.mMimetype = cursor.getString(INDEX_MIME_TYPE);
holder.mData = cursor.getString(INDEX_DATA);
holder.mFileSize = cursor.getLong(INDEX_FILE_SIZE);
holder.mDuration = cursor.getLong(INDEX_DRUATION);
holder.mIsDrm = VALUE_IS_DRM.equals(cursor.getString(INDEX_IS_DRM));
holder.mDateModified = cursor.getLong(INDEX_DATE_MODIFIED);
//holder.mSupport3D = MtkUtils.isStereo3D(cursor
//.getInt(INDEX_SUPPORT_3D));
holder.mTitleView.setText(holder.mTitle);
if (Flag_Clickable == false) {
if (mArrayClicked[cursor.getPosition()] == 0) {
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.VISIBLE);
}
if (mArrayClicked[cursor.getPosition()] == 1) {
holder.mImageView_Blue.setVisibility(View.VISIBLE);
holder.mImageView_grey.setVisibility(View.GONE);
}
}
if (Flag_Clickable == true) {
holder.mImageView_Blue.setVisibility(View.GONE);
holder.mImageView_grey.setVisibility(View.GONE);
}
// holder.mFileSizeView.setText(mCachedVideoInfo.getFileSize(
// MoviesContentAcitivity.this, holder.mFileSize));
holder.mDurationView.setText(mCachedVideoInfo
.getDuration(holder.mDuration));
String path = VideoApplication.mThumbnailPath.get(holder.mId);
if (path != null) {
Uri uri = Uri.fromFile(new File(path));
holder.mIcon.setImageURI(uri);
} else {
Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail(
mContext.getContentResolver(), holder.mId, 1999,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
holder.mIcon.setImageBitmap(bitmap);
}
// holder.mIcon.setImageURI(uri);
// refreshThumbnail(holder);
MtkLog.v(TAG, "bindeView() " + holder);
}
@Override
public void changeCursor(final Cursor c) {
Log.e(TAG, "changeCursor---->>" + c);
super.changeCursor(c);
}
@Override
protected void onContentChanged() {
Log.e(TAG, "onContentChanged:--->>" + getCursor());
mQueryHandler.onQueryComplete(0, null, getCursor());
super.onContentChanged();
}
class QueryHandler extends AsyncQueryHandler {
QueryHandler(final ContentResolver cr) {
super(cr);
}
@Override
protected void onQueryComplete(final int token,
final Object cookie, final Cursor cursor) {
MtkLog.v(TAG, "onQueryComplete(" + token + "," + cookie + ","
+ cursor + ")");
MtkUtils.disableSpinnerState(MoviesContentAcitivity.this);
if (cursor == null || cursor.getCount() == 0) {
// 当数据库没有找到数据时,或cursor找不到
if (cursor == null) {
final AlertDialog.Builder builder = new Builder(
MoviesContentAcitivity.this);
builder.setTitle("温馨提示:");
builder.setMessage("视频文件查询失败");
builder.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
finish();
}
});
builder.create().show();
}
if (cursor != null) { // to observe database change
changeCursor(cursor);
}
} else {
changeCursor(cursor);
}
if (cursor != null) {
MtkLog.v(TAG, "onQueryComplete() end");
}
}
@Override
protected void onDeleteComplete(int token, Object cookie, int result) {
// TODO Auto-generated method stub
super.onDeleteComplete(token, cookie, result);
if (result > 0) {
mDeleteCount--;
Log.e(TAG, "onDeleteComplete----------->" + mDeleteCount);
if (mDeleteCount == 0) {
mmProgressDialog.dismiss();
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
notifyDataSetChanged();
Toast.makeText(MoviesContentAcitivity.this, "删除完成",
Toast.LENGTH_SHORT).show();
}
}
}
}
@Override
public void onScroll(final AbsListView view,
final int firstVisibleItem, final int visibleItemCount,
final int totalItemCount) {
}
private boolean mFling = false;
@Override
public void onScrollStateChanged(final AbsListView view,
final int scrollState) {
switch (scrollState) {
case OnScrollListener.SCROLL_STATE_IDLE:
mFling = false;
// notify data changed to load bitmap from mediastore.
notifyDataSetChanged();
break;
case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
mFling = false;
break;
case OnScrollListener.SCROLL_STATE_FLING:
mFling = true;
break;
default:
break;
}
MtkLog.v(TAG, "onScrollStateChanged(" + scrollState + ") mFling="
+ mFling);
}
}
public class ViewHolder {
long mId;
String mTitle;
String mMimetype;
String mData;
long mDuration;
long mDateTaken;
long mFileSize;
boolean mIsDrm;
long mDateModified;
boolean mSupport3D;
SimpleDraweeView mIcon;
ImageView mImageView_grey;
ImageView mImageView_Blue;
TextView mTitleView;
TextView mFileSizeView;
TextView mDurationView;
FastBitmapDrawable mFastDrawable;
@Override
public String toString() {
return new StringBuilder().append("ViewHolder(mId=").append(mId)
.append(", mTitle=").append(mTitle).append(", mDuration=")
.append(mDuration).append(", mIsDrm=").append(mIsDrm)
.append(", mData=").append(mData).append(", mDateModified")
.append(mDateModified).append(", mFileSize=")
.append(mFileSize).append(", mSupport3D=")
.append(mSupport3D).append(")").toString();
}
/**
* just clone info
*/
@Override
protected ViewHolder clone() {
final ViewHolder holder = new ViewHolder();
holder.mId = mId;
holder.mTitle = mTitle;
holder.mMimetype = mMimetype;
holder.mData = mData;
holder.mDuration = mDuration;
holder.mDateTaken = mDateTaken;
holder.mFileSize = mFileSize;
holder.mIsDrm = mIsDrm;
holder.mDateModified = mDateModified;
holder.mSupport3D = mSupport3D;
return holder;
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
unregisterReceiver(mStorageListener);
if (db != null) {
db.close();
db = null;
}
mGridLongClicked = true;
this.getContentResolver().unregisterContentObserver(mObserver);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.activity_movies_content_back:
finish();
break;
case R.id.activity_movies_content_backarrow:
finish();
break;
case R.id.activity_movies_content_edit:
mEdit.setVisibility(View.GONE);
mCancle.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = false;
mGridLongClicked = false;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
// 将MediaID存入数组;
Cursor cursor = mAdapter.getCursor();
cursor.moveToFirst();
int j = 0;
do {
mBase_ID[j++] = cursor.getLong(INDEX_ID);
} while (cursor.moveToNext());
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->" + count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_movies_content_cancle:
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
mGridLongClicked = true;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->" + count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
case R.id.activity_moviescontent_allselceted:
count = mAdapter.getCount();
mArrayClicked = new int[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 1;
}
mAdapter.notifyDataSetChanged();
mCancelSelected.setVisibility(View.VISIBLE);
mSeltect.setVisibility(View.GONE);
Log.e(TAG, "R.id.activity_moviescontent_allselceted:count--->"
+ count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_moviescontent_cancleaselceted:
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
}
mAdapter.notifyDataSetChanged();
mSeltect.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
Log.e(TAG, "R.id.activity_moviescontent_cancleaselceted:count--->"
+ count);
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
break;
case R.id.activity_movicescontent_delete:
if (count == 0) {
Toast.makeText(MoviesContentAcitivity.this, "尚未选中删除条目",
Toast.LENGTH_SHORT).show();
} else {
AlertDialog.Builder builder = new Builder(
MoviesContentAcitivity.this);
builder.setTitle("温馨提示");
builder.setMessage("确认删除" + count + "条记录?");
builder.setPositiveButton("确认", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
mmProgressDialog = new ProgressDialog(
MoviesContentAcitivity.this);
mmProgressDialog.setMessage("正在删除,请稍等...");
mmProgressDialog.show();
for (int i = 0; i < mAdapter.getCount(); i++) {
if (mArrayClicked[i] == 1) {
// long _ID = -1L;
mAdapter.getQueryHandler().startDelete(0, null,
VIDEO_URI, BaseColumns._ID + " = ?",
new String[] { "" + mBase_ID[i] });
mDeleteCount++;
Log.e(TAG,
"startDelete:mDeleteCount------->>>>"
+ mDeleteCount);
// _ID = mFindRecordByID(mBase_ID[i]);
// if (_ID > -1) {
// videoScanRecordsDao.deleteByKey(_ID);
// }
}
}
}
});
builder.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.create().show();
}
break;
default:
break;
}
}
public void setIntoEdit(int position) {
mEdit.setVisibility(View.GONE);
mCancle.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.VISIBLE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = false;
mGridLongClicked = false;
count = 0;
mArrayClicked = new int[mAdapter.getCount()];
mBase_ID = new Long[mAdapter.getCount()];
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
if (i == position) {
mArrayClicked[i] = 1;
count++;
}
}
// 将MediaID存入数组;
Cursor cursor = mAdapter.getCursor();
cursor.moveToFirst();
int j = 0;
do {
mBase_ID[j++] = cursor.getLong(INDEX_ID);
} while (cursor.moveToNext());
mDelete.setText(this.getResources().getText(
R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
}
// 取消全选后操作
public void setCancleAllDelete() {
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
}
// // 根据mBase_ID值查询ID值;
// private long mFindRecordByID(Long mBase_ID) {
// Log.e(TAG, "mFindRecordByID()---------------->>" + mBase_ID);
// long _id = -1;
// QueryBuilder<VideoScanRecords> qb = videoScanRecordsDao.queryBuilder();
// qb.where(VideoScanRecordsDao.Properties.Base_ID.eq(mBase_ID));
// if (qb.buildCount().count() > 0) {
// _id = qb.list().get(0).getId();
// }
// return _id;
//
// }
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.e(TAG, "onResume()::------>>>>>>>");
Cursor c = getContentResolver().query(
MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, null, null,
null, null);
c.moveToFirst();
VideoApplication.mThumbnailPath.clear();
while (!c.isAfterLast()) {
long id = c.getLong(c
.getColumnIndex(MediaStore.Video.Thumbnails.VIDEO_ID));
String path = c.getString(c
.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
Log.e("NTVideoPlayer", "id " + id + " path " + path);
VideoApplication.mThumbnailPath.put(id, path);
c.moveToNext();
}
Log.e(TAG, "c.size()::::::::" + c.getCount());
c.close();
c = null;
Log.e(TAG, "onResume:END!!!");
}
private final class VideoObserver extends ContentObserver {
public VideoObserver(Handler handler) {
super(handler);
// TODO Auto-generated constructor stub
}
@Override
public void onChange(boolean selfChange) {
// TODO Auto-generated method stub
super.onChange(selfChange);
Log.e(TAG, "onChanger-------------------..........>>>>");
if (Flag_Clickable == false) {
mCancle.setVisibility(View.GONE);
mEdit.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
mCancelSelected.setVisibility(View.GONE);
mSeltect.setVisibility(View.VISIBLE);
Flag_Clickable = true;
mGridLongClicked = true;
count = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
mArrayClicked[i] = 0;
mBase_ID[i] = -1L;
}
mAdapter.notifyDataSetChanged();
Log.e(TAG, "R.id.activity_movies_content_edit:count--->"
+ count);
mDelete.setText(MoviesContentAcitivity.this.getResources()
.getText(R.string.activity_moviescontent_delete)
+ " ( " + count + " )");
}
Cursor c = getContentResolver().query(
MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, null,
null, null, null);
c.moveToFirst();
VideoApplication.mThumbnailPath.clear();
while (!c.isAfterLast()) {
long id = c.getLong(c
.getColumnIndex(MediaStore.Video.Thumbnails.VIDEO_ID));
String path = c.getString(c
.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
Log.d("NTVideoPlayer", "id " + id + " path " + path);
VideoApplication.mThumbnailPath.put(id, path);
c.moveToNext();
}
c.close();
}
}
}
| 36,241 | 0.697487 | 0.694683 | 1,163 | 29.967325 | 21.757175 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.313843 | false | false | 13 |
a4c6fa673d8a33ef0f016282f239cd38b8c72982 | 7,679,401,560,363 | 65238f5b57a2ef8d5b390809fa35dbb8fb074dd9 | /src/com/planbetter/constant/TaskConstant.java | a249282893362eab990910513a3b0e60f720f42c | [] | no_license | weixchangxbao/PlanBetter | https://github.com/weixchangxbao/PlanBetter | 7523dcde1790c408c8574717190eecd385ba1310 | 578d76f30f5df7438e85350392c9dde395ed7751 | refs/heads/master | 2021-01-21T01:20:04.047000 | 2012-11-03T15:22:11 | 2012-11-03T15:22:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.planbetter.constant;
public class TaskConstant {
public static final int RANK_FIRST = 4;
public static final int RANK_SECOND = 3;
public static final int RANK_THIRD = 2;
public static final int RANK_FOURTH = 1;
public static final int TIME_ALERT = 1;
public static final int NO_TIME_ALERT = 0;
public static final int TASK_NOT_COMPLETE = 0;
public static final int TASK_COMPLETE = 1;
public static final int INIT_REPEAT_DAYS = 1;
public static final int NOT_FUTURE = 0;
public static final int IS_FUTURE = 1;
public static final int IS_PARENT = 0;
}
| UTF-8 | Java | 585 | java | TaskConstant.java | Java | [] | null | [] | package com.planbetter.constant;
public class TaskConstant {
public static final int RANK_FIRST = 4;
public static final int RANK_SECOND = 3;
public static final int RANK_THIRD = 2;
public static final int RANK_FOURTH = 1;
public static final int TIME_ALERT = 1;
public static final int NO_TIME_ALERT = 0;
public static final int TASK_NOT_COMPLETE = 0;
public static final int TASK_COMPLETE = 1;
public static final int INIT_REPEAT_DAYS = 1;
public static final int NOT_FUTURE = 0;
public static final int IS_FUTURE = 1;
public static final int IS_PARENT = 0;
}
| 585 | 0.729915 | 0.709402 | 21 | 26.857143 | 18.820671 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.428571 | false | false | 13 |
c781ffac51b5a584dc120d7c2aded7001696ef96 | 25,116,968,809,101 | 2ced3c3bcf4885dc4bc0676ce50c996a73e3b7a7 | /src/java/com/pb/morpc/daf/FpWorker.java | a2baca91972bbfed54f0715b2f2e814cf4054def | [] | no_license | wsp-sag/morpc | https://github.com/wsp-sag/morpc | 9f0f793abbcc43aa496c092a2e93e29bb4c2b71d | 8106c58a29191a3cabe07c3fc4ba99920e74a1fb | refs/heads/master | 2021-06-01T06:52:24.737000 | 2014-01-16T00:33:22 | 2014-01-16T00:33:22 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pb.morpc.daf;
/**
* @author Jim Hicks
*
* worker class for running free parking eligibility choice for
* a list of tours in a distributed environment.
*/
import com.pb.common.daf.Message;
import com.pb.common.daf.MessageProcessingTask;
import com.pb.morpc.models.FreeParkingEligibility;
import com.pb.morpc.structures.Household;
import java.util.HashMap;
import org.apache.log4j.Logger;
public class FpWorker extends MessageProcessingTask implements java.io.Serializable {
private static boolean LOGGING = true;
private static Logger logger = Logger.getLogger("com.pb.morpc.models");
private Household[] hhList = null;
private FreeParkingEligibility fpModel = null;
private HashMap propertyMap = null;
private String modelServer = "FpModelServer";
public FpWorker () {
if (LOGGING)
logger.info( "FpWorker constructor: " + this.name + "[" + Thread.currentThread().getId() + "]" + "().");
}
public void onStart() {
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " onStart().");
// ask the free parking model server for start info including the propertyMap
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " asking for START_INFO from " + modelServer + "." );
Message msg = createMessage();
msg.setId( MessageID.SEND_START_INFO );
sendTo( modelServer, msg );
}
public void onMessage(Message msg) {
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " onMessage() id=" + msg.getId() + ", sent by " + msg.getSender() + "." );
Message newMessage = null;
//Do some work ...
int messageReturnType = respondToMessage(msg);
if ( messageReturnType > 0 ) {
//Send a response back to the server
if (messageReturnType == MessageID.RESULTS_ID)
newMessage = createResultsMessage();
else if (messageReturnType == MessageID.FINISHED_ID)
newMessage = createFinishedMessage();
else if (messageReturnType == MessageID.EXIT_ID)
fpModel = null;
if (newMessage != null)
replyToSender(newMessage);
}
}
private int respondToMessage (Message msg) {
int returnValue=0;
if ( msg.getSender().equals(modelServer) ) {
if (msg.getId().equals(MessageID.START_INFO)) {
propertyMap = (HashMap)msg.getValue( MessageID.PROPERTY_MAP_KEY );
if (LOGGING)
logger.info (this.getName() + " building fpModel object.");
fpModel = new FreeParkingEligibility(propertyMap);
Message sendWorkMsg = createMessage();
sendWorkMsg.setId(MessageID.SEND_WORK);
sendWorkMsg.setIntValue( MessageID.TOUR_CATEGORY_KEY, 0 );
sendWorkMsg.setValue( MessageID.TOUR_TYPES_KEY, null );
sendTo( "HhArrayServer", sendWorkMsg );
}
else if ( msg.getId().equals( MessageID.RELEASE_MEMORY ) || msg.getId().equals( MessageID.EXIT ) ) {
if (LOGGING)
logger.info (this.getName() + " releasing memory after getting " + msg.getId() + " from " + msg.getSender() );
fpModel = null;
propertyMap = null;
hhList = null;
}
}
else {
// this message should contain an array of Household objects to process
if ( msg.getId().equals( MessageID.HOUSEHOLD_LIST ) ) {
// retrieve the contents of the message:
hhList = (Household[])msg.getValue( MessageID.HOUSEHOLD_LIST_KEY );
// if the list is null, no more hhs left to process;
// otherwise, put the household objects from the message into an array for processing.
if ( hhList != null ) {
// run the free parking eligibility model for the tours in these households
if (LOGGING)
logger.info ( this.getName() + " processing household ids: " + hhList[0].getID() + " to " + hhList[hhList.length-1].getID() );
fpModel.runFreeParkingEligibility (hhList);
returnValue = MessageID.RESULTS_ID;
}
else {
returnValue = MessageID.FINISHED_ID;
}
}
}
return returnValue;
}
private Message createFinishedMessage () {
Message newMessage = createMessage();
newMessage.setId( MessageID.FINISHED );
sendTo (modelServer, newMessage);
return null;
}
private Message createResultsMessage () {
Message newMessage = createMessage();
newMessage.setId( MessageID.RESULTS );
newMessage.setIntValue( MessageID.TOUR_CATEGORY_KEY, 0 );
newMessage.setValue( MessageID.TOUR_TYPES_KEY, null );
newMessage.setValue( MessageID.HOUSEHOLD_LIST_KEY, hhList );
return newMessage;
}
}
| UTF-8 | Java | 4,778 | java | FpWorker.java | Java | [
{
"context": "package com.pb.morpc.daf;\r\n\r\n/**\r\n * @author Jim Hicks\r\n *\r\n * worker class for running free parking eli",
"end": 54,
"score": 0.9997332096099854,
"start": 45,
"tag": "NAME",
"value": "Jim Hicks"
}
] | null | [] | package com.pb.morpc.daf;
/**
* @author <NAME>
*
* worker class for running free parking eligibility choice for
* a list of tours in a distributed environment.
*/
import com.pb.common.daf.Message;
import com.pb.common.daf.MessageProcessingTask;
import com.pb.morpc.models.FreeParkingEligibility;
import com.pb.morpc.structures.Household;
import java.util.HashMap;
import org.apache.log4j.Logger;
public class FpWorker extends MessageProcessingTask implements java.io.Serializable {
private static boolean LOGGING = true;
private static Logger logger = Logger.getLogger("com.pb.morpc.models");
private Household[] hhList = null;
private FreeParkingEligibility fpModel = null;
private HashMap propertyMap = null;
private String modelServer = "FpModelServer";
public FpWorker () {
if (LOGGING)
logger.info( "FpWorker constructor: " + this.name + "[" + Thread.currentThread().getId() + "]" + "().");
}
public void onStart() {
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " onStart().");
// ask the free parking model server for start info including the propertyMap
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " asking for START_INFO from " + modelServer + "." );
Message msg = createMessage();
msg.setId( MessageID.SEND_START_INFO );
sendTo( modelServer, msg );
}
public void onMessage(Message msg) {
if (LOGGING)
logger.info( this.name + "[" + Thread.currentThread().getId() + "]" + " onMessage() id=" + msg.getId() + ", sent by " + msg.getSender() + "." );
Message newMessage = null;
//Do some work ...
int messageReturnType = respondToMessage(msg);
if ( messageReturnType > 0 ) {
//Send a response back to the server
if (messageReturnType == MessageID.RESULTS_ID)
newMessage = createResultsMessage();
else if (messageReturnType == MessageID.FINISHED_ID)
newMessage = createFinishedMessage();
else if (messageReturnType == MessageID.EXIT_ID)
fpModel = null;
if (newMessage != null)
replyToSender(newMessage);
}
}
private int respondToMessage (Message msg) {
int returnValue=0;
if ( msg.getSender().equals(modelServer) ) {
if (msg.getId().equals(MessageID.START_INFO)) {
propertyMap = (HashMap)msg.getValue( MessageID.PROPERTY_MAP_KEY );
if (LOGGING)
logger.info (this.getName() + " building fpModel object.");
fpModel = new FreeParkingEligibility(propertyMap);
Message sendWorkMsg = createMessage();
sendWorkMsg.setId(MessageID.SEND_WORK);
sendWorkMsg.setIntValue( MessageID.TOUR_CATEGORY_KEY, 0 );
sendWorkMsg.setValue( MessageID.TOUR_TYPES_KEY, null );
sendTo( "HhArrayServer", sendWorkMsg );
}
else if ( msg.getId().equals( MessageID.RELEASE_MEMORY ) || msg.getId().equals( MessageID.EXIT ) ) {
if (LOGGING)
logger.info (this.getName() + " releasing memory after getting " + msg.getId() + " from " + msg.getSender() );
fpModel = null;
propertyMap = null;
hhList = null;
}
}
else {
// this message should contain an array of Household objects to process
if ( msg.getId().equals( MessageID.HOUSEHOLD_LIST ) ) {
// retrieve the contents of the message:
hhList = (Household[])msg.getValue( MessageID.HOUSEHOLD_LIST_KEY );
// if the list is null, no more hhs left to process;
// otherwise, put the household objects from the message into an array for processing.
if ( hhList != null ) {
// run the free parking eligibility model for the tours in these households
if (LOGGING)
logger.info ( this.getName() + " processing household ids: " + hhList[0].getID() + " to " + hhList[hhList.length-1].getID() );
fpModel.runFreeParkingEligibility (hhList);
returnValue = MessageID.RESULTS_ID;
}
else {
returnValue = MessageID.FINISHED_ID;
}
}
}
return returnValue;
}
private Message createFinishedMessage () {
Message newMessage = createMessage();
newMessage.setId( MessageID.FINISHED );
sendTo (modelServer, newMessage);
return null;
}
private Message createResultsMessage () {
Message newMessage = createMessage();
newMessage.setId( MessageID.RESULTS );
newMessage.setIntValue( MessageID.TOUR_CATEGORY_KEY, 0 );
newMessage.setValue( MessageID.TOUR_TYPES_KEY, null );
newMessage.setValue( MessageID.HOUSEHOLD_LIST_KEY, hhList );
return newMessage;
}
}
| 4,775 | 0.635831 | 0.634366 | 187 | 23.550802 | 29.942215 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.026738 | false | false | 13 |
1aeea3f23e413149cc750f32ec8a23761eda3131 | 22,643,067,599,221 | 8db8714847872d0a67898b4255ac0f6a92c42978 | /fitpay/src/main/java/com/fitpay/android/api/models/ImageAssetWithOptionsReference.java | 1c77ebd4b04af60df91377403463a24199ba1e97 | [
"MIT"
] | permissive | fitpay/fitpay-android-sdk | https://github.com/fitpay/fitpay-android-sdk | 4ff0c264c31c2afcae420c399a85b032aa87c113 | c07729b259a51495fe79875a022c29dc81f89840 | refs/heads/develop | 2021-04-06T01:38:53.092000 | 2020-04-06T19:36:24 | 2020-04-06T19:36:24 | 48,443,654 | 10 | 6 | MIT | false | 2020-04-06T18:55:52 | 2015-12-22T16:57:18 | 2020-04-02T14:04:22 | 2020-04-06T18:55:51 | 8,860 | 8 | 5 | 0 | Java | false | false | package com.fitpay.android.api.models;
import android.net.Uri;
import android.os.Parcel;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Image asset reference
*/
public final class ImageAssetWithOptionsReference extends ImageAssetReference {
public String getUrl(ImageAssetOptions options) {
Uri uri = Uri.parse(getUrl());
final Set<String> oldParams = new HashSet<>(uri.getQueryParameterNames());
final Uri.Builder newUri = uri.buildUpon().clearQuery();
Map<String, String> paramsMap = options.getParamToValueMap();
for (ImageAssetOptions.ImageAssetParams p : ImageAssetOptions.ImageAssetParams.values()) {
oldParams.remove(p.value);
if (null != paramsMap.get(p.value)) {
newUri.appendQueryParameter(p.value, paramsMap.get(p.value));
}
}
for (String param : oldParams) {
newUri.appendQueryParameter(param, uri.getQueryParameter(param));
}
return newUri.build().toString();
}
@Override
public int describeContents() {
return 0;
}
public ImageAssetWithOptionsReference() {
}
protected ImageAssetWithOptionsReference(Parcel in) {
super(in);
}
public static final Creator<ImageAssetWithOptionsReference> CREATOR = new Creator<ImageAssetWithOptionsReference>() {
@Override
public ImageAssetWithOptionsReference createFromParcel(Parcel source) {
return new ImageAssetWithOptionsReference(source);
}
@Override
public ImageAssetWithOptionsReference[] newArray(int size) {
return new ImageAssetWithOptionsReference[size];
}
};
}
| UTF-8 | Java | 1,734 | java | ImageAssetWithOptionsReference.java | Java | [] | null | [] | package com.fitpay.android.api.models;
import android.net.Uri;
import android.os.Parcel;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Image asset reference
*/
public final class ImageAssetWithOptionsReference extends ImageAssetReference {
public String getUrl(ImageAssetOptions options) {
Uri uri = Uri.parse(getUrl());
final Set<String> oldParams = new HashSet<>(uri.getQueryParameterNames());
final Uri.Builder newUri = uri.buildUpon().clearQuery();
Map<String, String> paramsMap = options.getParamToValueMap();
for (ImageAssetOptions.ImageAssetParams p : ImageAssetOptions.ImageAssetParams.values()) {
oldParams.remove(p.value);
if (null != paramsMap.get(p.value)) {
newUri.appendQueryParameter(p.value, paramsMap.get(p.value));
}
}
for (String param : oldParams) {
newUri.appendQueryParameter(param, uri.getQueryParameter(param));
}
return newUri.build().toString();
}
@Override
public int describeContents() {
return 0;
}
public ImageAssetWithOptionsReference() {
}
protected ImageAssetWithOptionsReference(Parcel in) {
super(in);
}
public static final Creator<ImageAssetWithOptionsReference> CREATOR = new Creator<ImageAssetWithOptionsReference>() {
@Override
public ImageAssetWithOptionsReference createFromParcel(Parcel source) {
return new ImageAssetWithOptionsReference(source);
}
@Override
public ImageAssetWithOptionsReference[] newArray(int size) {
return new ImageAssetWithOptionsReference[size];
}
};
}
| 1,734 | 0.66609 | 0.665513 | 61 | 27.426229 | 30.004622 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.360656 | false | false | 13 |
ad4b60ef142471dd206eabf21cee0ae807a12651 | 33,956,011,448,452 | af4bd5d37f0c9b68e7ea0341eda784f7cd3d24a6 | /JavaCoreBook/src/java/main/test1/TestFor.java | b4300dd0d69607693c8323e16255c6c68dfd4354 | [] | no_license | haizei616/JavaLeanTest | https://github.com/haizei616/JavaLeanTest | 4d566aacfc5a2ec51b54e756b610f22455aba11b | 622edcf95e1ddab86aade73b6adeded39769614d | refs/heads/master | 2020-03-23T15:50:06.760000 | 2018-07-24T09:37:07 | 2018-07-24T09:37:07 | 141,777,573 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.test1;
public class TestFor {
public static void main(String[] args) {
String[] name = {"aa","bb","cc"};
for (String na:name) {
System.out.println("name:" + na);
}
}
}
| UTF-8 | Java | 236 | java | TestFor.java | Java | [] | null | [] | package main.test1;
public class TestFor {
public static void main(String[] args) {
String[] name = {"aa","bb","cc"};
for (String na:name) {
System.out.println("name:" + na);
}
}
}
| 236 | 0.495763 | 0.491525 | 12 | 18.666666 | 16.774651 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 13 |
4c5593f402f904255c9d710956927ffbaf5ee6f4 | 1,425,929,163,970 | 3d3e413e7a802a7629bbc2ef8d49e68eeaf61ad2 | /src/controller/AddFriendServlet.java | ade4ce6eb95eeb7604c41c5e5ca87059cbc22c83 | [] | no_license | Belitili/ChatApp---Project-Webapplicaties | https://github.com/Belitili/ChatApp---Project-Webapplicaties | a7603c364ea398f0ff0a6fcfb26c76408ed7c8b2 | f5c09998b962e1fc8963052d603a817aec45116f | refs/heads/master | 2021-01-01T04:48:01.969000 | 2017-07-14T15:40:45 | 2017-07-14T15:40:45 | 97,248,702 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import db.UserDB;
import model.User;
/**
* Servlet implementation class AddFriendServlet
* !! @MultipartConfig is because of FormData used in addFriend.js
*/
@WebServlet("/AddFriendServlet")
@MultipartConfig
public class AddFriendServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public AddFriendServlet() {
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String friendToAdd = request.getParameter("friendToAdd");
HttpSession session = request.getSession();
User currentUser = (User) session.getAttribute("user");
String returnMessage;
if (session.getAttribute("username").equals(friendToAdd)) {
returnMessage = "You can't add yourself.";
} else {
UserDB userDB = UserDB.getDB();
User user = userDB.get(friendToAdd);
if (user==null) {
returnMessage = "No user found by that username.";
} else {
boolean alreadyfriends = false;
ArrayList<User> friends = currentUser.getFriends();
for (User friend: friends) {
if (friend.getUsername().equals(friendToAdd)) {
alreadyfriends = true;
}
}
if (alreadyfriends) {
returnMessage = friendToAdd + " is already your friend.";
} else {
currentUser.addFriend(user);
user.addFriend(userDB.get(currentUser.getUsername()));
returnMessage = "User '" + friendToAdd + "' added to your friend list.";
}
}
}
response.getWriter().write(returnMessage);
}
}
| UTF-8 | Java | 2,278 | java | AddFriendServlet.java | Java | [] | null | [] | package controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import db.UserDB;
import model.User;
/**
* Servlet implementation class AddFriendServlet
* !! @MultipartConfig is because of FormData used in addFriend.js
*/
@WebServlet("/AddFriendServlet")
@MultipartConfig
public class AddFriendServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public AddFriendServlet() {
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String friendToAdd = request.getParameter("friendToAdd");
HttpSession session = request.getSession();
User currentUser = (User) session.getAttribute("user");
String returnMessage;
if (session.getAttribute("username").equals(friendToAdd)) {
returnMessage = "You can't add yourself.";
} else {
UserDB userDB = UserDB.getDB();
User user = userDB.get(friendToAdd);
if (user==null) {
returnMessage = "No user found by that username.";
} else {
boolean alreadyfriends = false;
ArrayList<User> friends = currentUser.getFriends();
for (User friend: friends) {
if (friend.getUsername().equals(friendToAdd)) {
alreadyfriends = true;
}
}
if (alreadyfriends) {
returnMessage = friendToAdd + " is already your friend.";
} else {
currentUser.addFriend(user);
user.addFriend(userDB.get(currentUser.getUsername()));
returnMessage = "User '" + friendToAdd + "' added to your friend list.";
}
}
}
response.getWriter().write(returnMessage);
}
}
| 2,278 | 0.725637 | 0.725198 | 77 | 28.584415 | 27.288906 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.077922 | false | false | 13 |
1292d266d6e2987d880439312544cee9e7a89ce8 | 9,680,856,346,445 | b088a817fb2f97ec4eebb829cef8133682db617f | /app/src/main/java/com/example/sabbib/rxjava/image/ImageObservableActivity.java | 7478a9901de0c9d3f2976bef536b7cc22d16793a | [] | no_license | chowii/RxAndroid | https://github.com/chowii/RxAndroid | 407d8ebc1ac737900d5a18bd9246a59037cecd7b | 6946744b656e5e2f6b2f78f9c91648acae01151a | refs/heads/master | 2021-01-20T10:24:19.337000 | 2017-05-08T03:14:16 | 2017-05-08T03:14:16 | 90,353,168 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.sabbib.rxjava.image;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import com.example.sabbib.rxjava.R;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func0;
import rx.schedulers.Schedulers;
import static android.os.Environment.DIRECTORY_PICTURES;
public class ImageObservableActivity extends AppCompatActivity {
final private String TAG = this.getClass().getSimpleName() + " LOGGING";
String url = "http://cdn.wallpapersafari.com/82/41/LamTJp.jpg";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_observable);
final ImageView iv1 = (ImageView) findViewById(R.id.imageView);
getBitmapObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Subscriber<Bitmap>(){
@Override
public void onCompleted(){
}
@Override
public void onError(Throwable e){
}
@Override
public void onNext(Bitmap imageBitmap){
iv1.setImageBitmap(imageBitmap);
saveImageFromBitmap(imageBitmap);
Log.d(TAG, "image set");
}
});
}
private void saveImageFromBitmap(Bitmap imageBitmap) {
File imageFile = getOutputPath();
if (imageFile == null) {
Log.e(TAG, "Error saving file, Check permissions");
return;
}
try {
FileOutputStream fos = new FileOutputStream(imageFile);
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
} catch (FileNotFoundException fnfe) {
Log.e(TAG, "File not found, check permission " + fnfe.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
private File getOutputPath(){
File storageDir = new File(getApplicationContext().getExternalFilesDirs(DIRECTORY_PICTURES).toString());
if(!storageDir.exists()) if(!storageDir.mkdirs()) return null;
String imageFileName = url.substring(url.lastIndexOf('/') + 1).split("\\?")[0].split("#")[0];
File image = new File(storageDir.getPath() + File.separator + imageFileName);
return image;
}
@Nullable
public InputStream getImageStream() throws IOException{
try {
InputStream is = new java.net.URL(url).openStream();
return is;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Nullable
public Bitmap getBitmapFromInputStream(InputStream imageStream) throws IOException{
Bitmap image = BitmapFactory.decodeStream(imageStream);
imageStream.close();
return image;
}
public Observable<Bitmap> getBitmapObservable(){
return Observable.defer(new Func0<Observable<Bitmap>>() {
@Override
public Observable<Bitmap> call(){
try{
return Observable.just(getBitmapFromInputStream(getImageStream()));
}catch (IOException ioe){
ioe.printStackTrace();
return null;
}
}
});
}
}
| UTF-8 | Java | 3,884 | java | ImageObservableActivity.java | Java | [] | null | [] | package com.example.sabbib.rxjava.image;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import com.example.sabbib.rxjava.R;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func0;
import rx.schedulers.Schedulers;
import static android.os.Environment.DIRECTORY_PICTURES;
public class ImageObservableActivity extends AppCompatActivity {
final private String TAG = this.getClass().getSimpleName() + " LOGGING";
String url = "http://cdn.wallpapersafari.com/82/41/LamTJp.jpg";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_observable);
final ImageView iv1 = (ImageView) findViewById(R.id.imageView);
getBitmapObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Subscriber<Bitmap>(){
@Override
public void onCompleted(){
}
@Override
public void onError(Throwable e){
}
@Override
public void onNext(Bitmap imageBitmap){
iv1.setImageBitmap(imageBitmap);
saveImageFromBitmap(imageBitmap);
Log.d(TAG, "image set");
}
});
}
private void saveImageFromBitmap(Bitmap imageBitmap) {
File imageFile = getOutputPath();
if (imageFile == null) {
Log.e(TAG, "Error saving file, Check permissions");
return;
}
try {
FileOutputStream fos = new FileOutputStream(imageFile);
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
} catch (FileNotFoundException fnfe) {
Log.e(TAG, "File not found, check permission " + fnfe.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
private File getOutputPath(){
File storageDir = new File(getApplicationContext().getExternalFilesDirs(DIRECTORY_PICTURES).toString());
if(!storageDir.exists()) if(!storageDir.mkdirs()) return null;
String imageFileName = url.substring(url.lastIndexOf('/') + 1).split("\\?")[0].split("#")[0];
File image = new File(storageDir.getPath() + File.separator + imageFileName);
return image;
}
@Nullable
public InputStream getImageStream() throws IOException{
try {
InputStream is = new java.net.URL(url).openStream();
return is;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Nullable
public Bitmap getBitmapFromInputStream(InputStream imageStream) throws IOException{
Bitmap image = BitmapFactory.decodeStream(imageStream);
imageStream.close();
return image;
}
public Observable<Bitmap> getBitmapObservable(){
return Observable.defer(new Func0<Observable<Bitmap>>() {
@Override
public Observable<Bitmap> call(){
try{
return Observable.just(getBitmapFromInputStream(getImageStream()));
}catch (IOException ioe){
ioe.printStackTrace();
return null;
}
}
});
}
}
| 3,884 | 0.608136 | 0.604274 | 127 | 29.582678 | 25.918844 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.472441 | false | false | 13 |
529e62a71b2144ce75d0ebc5a0e73a7ff67a8dcb | 33,088,428,098,380 | f7d7d3e4aef35e8ca27fd5a0a2ae9ee904b28813 | /Week_03/LowestCommonAncestor.java | 765f7562b7b2bc0f7ea990f1c4ddbd133a0e4b42 | [] | no_license | Magic-SuperStar/algorithm008-class02 | https://github.com/Magic-SuperStar/algorithm008-class02 | 75865567e98be730074424334bbfc8003c5d7f15 | 851d4d3b1bf736cb368110838d353d0a0cc17f49 | refs/heads/master | 2022-07-08T23:59:13.142000 | 2020-05-10T15:57:38 | 2020-05-10T15:57:38 | 256,958,244 | 0 | 0 | null | true | 2020-04-19T09:14:42 | 2020-04-19T09:14:42 | 2020-04-15T08:17:02 | 2020-04-10T04:43:37 | 2 | 0 | 0 | 0 | null | false | false | package org.geekbang.ljz.Week_03;
import org.junit.Test;
public class LowestCommonAncestor {
@Test
public void TestLowestCommonAncestor() {
//3,5,1,6,2,0,8,null,null,7,4
TreeNode root = null;
TreeNode p = null;
TreeNode q = null;
TreeNode node = lowestCommonAncestor(root, p, q);
}
//递归终结条件:recursion terminator
// if(level>max_level){
// procees_result
// return ;
// }
//处理当前层逻辑:procees logic in current level
// process(level,data...);
//下探到下一层:drill level
// resursion(level,p1...);
//清理当前:reserse the current level status if needed
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
//p,q,是否存在于root
//然后 遍历 公共的root
//找到最近的root
//终止条件:recursion terminator
if (root == null || root == p || root == q) return root;
//处理当前层逻辑:process logic in the current level
TreeNode left = lowestCommonAncestor(root.left, p, q);
TreeNode right = lowestCommonAncestor(root.right, p, q);
if (left == null) {
return right;
}
if (right == null) {
return left;
}
return root;
}
}
| UTF-8 | Java | 1,342 | java | LowestCommonAncestor.java | Java | [] | null | [] | package org.geekbang.ljz.Week_03;
import org.junit.Test;
public class LowestCommonAncestor {
@Test
public void TestLowestCommonAncestor() {
//3,5,1,6,2,0,8,null,null,7,4
TreeNode root = null;
TreeNode p = null;
TreeNode q = null;
TreeNode node = lowestCommonAncestor(root, p, q);
}
//递归终结条件:recursion terminator
// if(level>max_level){
// procees_result
// return ;
// }
//处理当前层逻辑:procees logic in current level
// process(level,data...);
//下探到下一层:drill level
// resursion(level,p1...);
//清理当前:reserse the current level status if needed
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
//p,q,是否存在于root
//然后 遍历 公共的root
//找到最近的root
//终止条件:recursion terminator
if (root == null || root == p || root == q) return root;
//处理当前层逻辑:process logic in the current level
TreeNode left = lowestCommonAncestor(root.left, p, q);
TreeNode right = lowestCommonAncestor(root.right, p, q);
if (left == null) {
return right;
}
if (right == null) {
return left;
}
return root;
}
}
| 1,342 | 0.580619 | 0.570847 | 43 | 27.55814 | 19.399475 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.953488 | false | false | 13 |
2456f6d7eb6fe5440d5146976d552fbb74dc27ad | 28,922,309,839,770 | 24f7fed177f6b686ca2f4c71f37241440e9e740b | /util/GNUMAP_Comb.java | 4984f430c2f56c683daff65f4ff769890f1ed9fc | [] | no_license | NatachaPL/LLC-Read-Mapping-Pipeline | https://github.com/NatachaPL/LLC-Read-Mapping-Pipeline | a47e3424af4eb4c0da80b88f836927ef2eb004d4 | 7b02282878ac997e07fe7793c4be31c251ec4fd3 | refs/heads/master | 2021-01-10T15:52:23.233000 | 2015-09-27T14:32:07 | 2015-09-27T14:32:07 | 43,245,085 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package util;
import java.util.Set;
import java.util.TreeSet;
import core.Genome;
import core.Read;
/**
* Display results after the score processing create for GNUMAP.
*/
public class GNUMAP_Comb extends Combiner{
private final float threshold = Float.parseFloat(LLCProperties.p.getProperty("threshold"));
Set<PositionScore_P> sorted = new TreeSet<PositionScore_P>();
public GNUMAP_Comb(Genome genome, Read read, int k) {
super(genome, read, k);
}
/**
* @param threshold
*
* Normalizations of the scores according with GNUMAP
*/
private void GNUMAP_normalization(float threshold){
float sum = 0;
for(AlignerResult ar : temp_res){
sum += ar.getScore();
}
for(AlignerResult ar : temp_res){
if(ar.getScore()/sum >= threshold)
sorted.add(new PositionScore_P(ar));
}
temp_res.clear();
}
protected void results_display() {
GNUMAP_normalization(threshold);
results.addAll(sorted);
if(DEBUG)
for(PositionScore p : results){
System.out.println(p);
}
}
}
| UTF-8 | Java | 1,047 | java | GNUMAP_Comb.java | Java | [] | null | [] | package util;
import java.util.Set;
import java.util.TreeSet;
import core.Genome;
import core.Read;
/**
* Display results after the score processing create for GNUMAP.
*/
public class GNUMAP_Comb extends Combiner{
private final float threshold = Float.parseFloat(LLCProperties.p.getProperty("threshold"));
Set<PositionScore_P> sorted = new TreeSet<PositionScore_P>();
public GNUMAP_Comb(Genome genome, Read read, int k) {
super(genome, read, k);
}
/**
* @param threshold
*
* Normalizations of the scores according with GNUMAP
*/
private void GNUMAP_normalization(float threshold){
float sum = 0;
for(AlignerResult ar : temp_res){
sum += ar.getScore();
}
for(AlignerResult ar : temp_res){
if(ar.getScore()/sum >= threshold)
sorted.add(new PositionScore_P(ar));
}
temp_res.clear();
}
protected void results_display() {
GNUMAP_normalization(threshold);
results.addAll(sorted);
if(DEBUG)
for(PositionScore p : results){
System.out.println(p);
}
}
}
| 1,047 | 0.673352 | 0.672397 | 54 | 18.388889 | 21.031208 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.759259 | false | false | 13 |
92a4e8c4a76e88b36e8e0c4e33953114d137a34f | 25,142,738,552,885 | a34e43cbb3cced9c64647133a28e67e297e9a1b9 | /zxl_exchange_microservice/zxl_service_user/src/main/java/com/whoiszxl/user/client/impl/CommonClientImpl.java | 7548a70ed617110dac53bd1cf314c42b1711ccf1 | [
"Apache-2.0"
] | permissive | whoiszxl/BohemianRhapsody | https://github.com/whoiszxl/BohemianRhapsody | 9c4ed24eb992d1a74d9f9f47b114787e5ae95d5f | f269118da2ddee75b38e8a55dba916d7a38bbe5f | refs/heads/master | 2022-03-27T11:05:06.838000 | 2020-01-20T03:13:02 | 2020-01-20T03:13:02 | 197,508,626 | 7 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.whoiszxl.user.client.impl;
import com.whoiszxl.base.entity.Result;
import com.whoiszxl.user.client.CommonClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description: CommonClient熔断器
* @author: whoiszxl
* @create: 2019-08-12
**/
@Component
public class CommonClientImpl implements CommonClient {
@Override
public Result<List<Object>> findAll() {
return Result.buildError("hystrix start.");
}
}
| UTF-8 | Java | 477 | java | CommonClientImpl.java | Java | [
{
"context": "\n\n/**\n * @description: CommonClient熔断器\n * @author: whoiszxl\n * @create: 2019-08-12\n **/\n@Component\npublic cla",
"end": 257,
"score": 0.9996355175971985,
"start": 249,
"tag": "USERNAME",
"value": "whoiszxl"
}
] | null | [] | package com.whoiszxl.user.client.impl;
import com.whoiszxl.base.entity.Result;
import com.whoiszxl.user.client.CommonClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description: CommonClient熔断器
* @author: whoiszxl
* @create: 2019-08-12
**/
@Component
public class CommonClientImpl implements CommonClient {
@Override
public Result<List<Object>> findAll() {
return Result.buildError("hystrix start.");
}
}
| 477 | 0.738854 | 0.721868 | 20 | 22.549999 | 19.119297 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 13 |
077db147a9fe39401ce08603d841c87ff91fcf57 | 27,479,200,765,714 | b457bc64d21ed7c6751a02c3c57af913c7a35a96 | /src/String/SlidingWindow/lc76.java | b8fd670978d11f2dcb149fb784c48cbf33d0305f | [] | no_license | superjustin0316/LeetCode1-300 | https://github.com/superjustin0316/LeetCode1-300 | 19efbe09a62e6ed5c8ad4a1864d8e72b617b2310 | 749e789246ced5a9f4f64ab08493f2c47dbcfc9b | refs/heads/master | 2023-02-05T20:05:14.162000 | 2020-12-18T04:19:51 | 2020-12-18T04:19:51 | 317,082,865 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package String.SlidingWindow;
public class lc76 {
//O(n) O(1)
public static String lc76(String s, String t){
int[] cnt = new int[128];//128个字符(数字+ 字母)
for( char c : t.toCharArray()){
cnt[c]++;
//charAt(index);这个方法返回的是char类型,char类型可以隐式的转换成int类型
}
int from = 0;
int total = t.length();
int min = Integer.MAX_VALUE;
for (int i = 0, j = 0; i < s.length(); i++) {
/**
* cnt[t.charAt(i)]++ t的字符++
* cnt[s.charAt(i)]>0 s.charAt(i) 在 t 中出现过
* i 从前向后 j 记录起点
* t出现的字符 = 0;t未出现的字符 < 0
*/
if (cnt[s.charAt(i)] > 0) total--;
cnt[s.charAt(i)]-- ;
while (total == 0){
if (i - j + 1 < min){
//更新最小值min
min = i - j + 1;
from = j;
}
/**
* cnt[s.charAt(j)]>0 是t中的字符先大于0
* 往后遍历,看是否有t中的字符出现
*/
cnt[s.charAt(j)]++;
if (cnt[s.charAt(j)] > 0) total++;
j++;
}
}
return (min == Integer.MAX_VALUE)? "":s.substring(from,from+min);
}
}
| UTF-8 | Java | 1,431 | java | lc76.java | Java | [] | null | [] | package String.SlidingWindow;
public class lc76 {
//O(n) O(1)
public static String lc76(String s, String t){
int[] cnt = new int[128];//128个字符(数字+ 字母)
for( char c : t.toCharArray()){
cnt[c]++;
//charAt(index);这个方法返回的是char类型,char类型可以隐式的转换成int类型
}
int from = 0;
int total = t.length();
int min = Integer.MAX_VALUE;
for (int i = 0, j = 0; i < s.length(); i++) {
/**
* cnt[t.charAt(i)]++ t的字符++
* cnt[s.charAt(i)]>0 s.charAt(i) 在 t 中出现过
* i 从前向后 j 记录起点
* t出现的字符 = 0;t未出现的字符 < 0
*/
if (cnt[s.charAt(i)] > 0) total--;
cnt[s.charAt(i)]-- ;
while (total == 0){
if (i - j + 1 < min){
//更新最小值min
min = i - j + 1;
from = j;
}
/**
* cnt[s.charAt(j)]>0 是t中的字符先大于0
* 往后遍历,看是否有t中的字符出现
*/
cnt[s.charAt(j)]++;
if (cnt[s.charAt(j)] > 0) total++;
j++;
}
}
return (min == Integer.MAX_VALUE)? "":s.substring(from,from+min);
}
}
| 1,431 | 0.385657 | 0.366534 | 42 | 28.880953 | 17.611147 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47619 | false | false | 13 |
f2093f37efe5f957f6c3b9c6209396cb70c7ccab | 11,673,721,171,811 | 07d805c6b80878f0173080c225fc9055435fb078 | /搜索/src/子集/子集1.java | e262f4cee1bc82e02a7761bebcf70393767a31db | [] | no_license | pxf1997/LeetCode--Algorithm | https://github.com/pxf1997/LeetCode--Algorithm | e264f1f8c966e4dcf538bb7a727b65e0f82b117f | 0077d58dbf48b37cefa095d99f29fdfa3032c9ff | refs/heads/master | 2023-07-20T06:52:08.428000 | 2021-08-31T12:15:49 | 2021-08-31T12:15:49 | 401,691,036 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package 子集;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author pxf
* @create 2021-05-11 15:19
*/
public class 子集1 {
public static void main(String[] args) {
Solution solution = new Solution();
List<List<Integer>> subsets = solution.subsets(new int[]{1, 2, 3});
System.out.println("输出 => " + subsets);
}
private static class Solution {
public List<List<Integer>> subsets(int[] nums) {
Arrays.sort(nums);
List<List<Integer>> res = new ArrayList<>();
List<Integer> path = new ArrayList<>();
//思路----不同的子集大小
for (int size = 0; size <= nums.length; size++) {
System.out.println("size = " + size);
backtracking(nums, 0, size, res, path); //小性质--每次回溯后,path为空
System.out.println();
}
return res;
}
private void backtracking(int[] nums, int begin, int size, List<List<Integer>> res, List<Integer> path) {
if (path.size() == size) {
System.out.println("递归结束:" + path);
res.add(new ArrayList<>(path));
return;
}
for (int i = begin; i < nums.length; i++) {
//添加
path.add(nums[i]);
System.out.println("递归之前 => " + path + " 剩余个数:" + (size - path.size()));
//不允许重复
backtracking(nums, i + 1, size, res, path);
//删除
path.remove(path.size() - 1);
System.out.println("递归之后 => " + path);
}
}
}
}
| UTF-8 | Java | 1,760 | java | 子集1.java | Java | [
{
"context": "til.Arrays;\nimport java.util.List;\n\n/**\n * @author pxf\n * @create 2021-05-11 15:19\n */\npublic class 子集1 ",
"end": 109,
"score": 0.999680757522583,
"start": 106,
"tag": "USERNAME",
"value": "pxf"
}
] | null | [] | package 子集;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author pxf
* @create 2021-05-11 15:19
*/
public class 子集1 {
public static void main(String[] args) {
Solution solution = new Solution();
List<List<Integer>> subsets = solution.subsets(new int[]{1, 2, 3});
System.out.println("输出 => " + subsets);
}
private static class Solution {
public List<List<Integer>> subsets(int[] nums) {
Arrays.sort(nums);
List<List<Integer>> res = new ArrayList<>();
List<Integer> path = new ArrayList<>();
//思路----不同的子集大小
for (int size = 0; size <= nums.length; size++) {
System.out.println("size = " + size);
backtracking(nums, 0, size, res, path); //小性质--每次回溯后,path为空
System.out.println();
}
return res;
}
private void backtracking(int[] nums, int begin, int size, List<List<Integer>> res, List<Integer> path) {
if (path.size() == size) {
System.out.println("递归结束:" + path);
res.add(new ArrayList<>(path));
return;
}
for (int i = begin; i < nums.length; i++) {
//添加
path.add(nums[i]);
System.out.println("递归之前 => " + path + " 剩余个数:" + (size - path.size()));
//不允许重复
backtracking(nums, i + 1, size, res, path);
//删除
path.remove(path.size() - 1);
System.out.println("递归之后 => " + path);
}
}
}
}
| 1,760 | 0.483112 | 0.471049 | 57 | 28.087719 | 25.72887 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.701754 | false | false | 13 |
ab6331c7e1cde10bbd4f89578bc397f4bb41b943 | 27,831,388,127,987 | aa26661faaff08acb5f2fb3f21582079c0be083a | /src/twitter4j/MainTwitter.java | 4b366b778f25b8f0945d51d24f3fc494e7c395b7 | [] | no_license | LM7/Tesi | https://github.com/LM7/Tesi | 178b2e554631ce5fed836808df98a1bf06c81724 | aaffd402202d436e0616e8d7f419a4cfec5fc26c | refs/heads/master | 2016-09-05T11:29:30.353000 | 2015-12-23T11:19:17 | 2015-12-23T11:19:17 | 42,769,662 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package twitter4j;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import twitter4j.IDs;
import twitter4j.Paging;
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.ResponseList;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.ConfigurationBuilder;
public class MainTwitter {
private String consumerKey = "";
private String consumerSecret = "";
private String accessToken = "";
private String accessSecret = "";
private ConfigurationBuilder cb;
private TwitterFactory tf;
private Twitter twitter;
public MainTwitter() {
cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(this.consumerKey)
.setOAuthConsumerSecret(this.consumerSecret)
.setOAuthAccessToken(this.accessToken)
.setOAuthAccessTokenSecret(this.accessSecret);
this.tf = new TwitterFactory(this.cb.build());
this.twitter = this.tf.getInstance();
}
public Twitter getTwitter() {
return twitter;
}
public void setTwitter(Twitter twitter) {
this.twitter = twitter;
}
public ResponseList<Status> tweetsUserPagingNumber(String user, int paging, int numTweet) throws TwitterException {
Twitter twitter = this.getTwitter();
ResponseList<Status> stati = null;
stati = twitter.getUserTimeline(user, new Paging(paging,numTweet));
return stati;
}
/*
* Resituisce tweets associati ad un user: lingua, data e testo (numeroTweet: max 200)
* UTILIZZATO PER IL TWEETPAST
*/
public ResponseList<Status> tweetsOfUser(String user, int numeroTweet) throws TwitterException, FileNotFoundException, IOException {
//PrintWriter outTOU = new PrintWriter("tweetsOfUser.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
ResponseList<Status> stati = null;
stati = twitter.getUserTimeline(user, new Paging(1,numeroTweet)); //cambiando il paging posso risalire agli stati pi�� vecchi
/*for (Status stato: stati) {
//outTOU.println("LINGUA: "+stato.getLang());
//outTOU.println("DATA: "+ stato.getCreatedAt());
//outTOU.println("TWEET: "+stato.getText());
//System.out.println(stato.getText());
}*/
//outTOU.close();
//System.out.println("DONE");
return stati;
}
public HashMap<String,ArrayList<String>> userFollowersOnTopic(String stato, String user, String dataStart) throws TwitterException, FileNotFoundException, UnsupportedEncodingException {
PrintWriter outMT = new PrintWriter("mtFollowers.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
//Twitter twitter = this.getTwitter();
//Trovo gli stati associati a una query
System.out.println("--------------TWEET DELL'USER------------");
outMT.println("--------------TWEET DELL'USER------------");
ArrayList<String> stati = new ArrayList<String>();
String statoFinale = stato+" from:"+user;
stati = this.query(statoFinale, 100, dataStart); //"#Totti from:LM791"; "2015-07-20"
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinale);
for (int i = 0; i<stati.size(); i++) {
outMT.println(stati.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
// Trovo i followers associati a un utente
System.out.println("---------------FOLLOWER--------------------");
outMT.println("---------------FOLLOWER--------------------");
ArrayList<String> followers = new ArrayList<String>();
followers = this.followersOfUser(user, 15); //LM791
System.out.println("TUTTI I FOLLOWERS DI: "+user);
for (int i = 0; i<followers.size(); i++) {
outMT.println(followers.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
//Trovo gli stati di tali followers con la stessa query
ArrayList<String> appoggioStatiFollowers = new ArrayList<String>();
HashMap<String,ArrayList<String>> followersToTweets = new HashMap<String,ArrayList<String>>();
int lungFollowers = followers.size();
System.out.println("(((((((TWEET FOLLOWER))))))))");
outMT.println("(((((((TWEET FOLLOWER))))))))");
for (int i = 0; i < lungFollowers; i++) {
String statoFinaleFol = stato+" from:"+followers.get(i);
appoggioStatiFollowers = this.query(statoFinaleFol, 100, dataStart);
System.out.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
for (int k = 0; k<appoggioStatiFollowers.size(); k++) {
outMT.println(appoggioStatiFollowers.get(k));
}
followersToTweets.put(followers.get(i), appoggioStatiFollowers); //mappa follower:tutti i suoi stati/tweet su quella query/topic
}
System.out.println("(((((((MAPPA CREATA))))))))");
outMT.println("(((((((MAPPA CREATA))))))))");
//Stampa
System.out.println("--------------STAMPA FINALE--------------------");
outMT.println("--------------STAMPA FINALE--------------------");
for (String follower: followersToTweets.keySet()) {
System.out.println("FOLLOWER: "+follower);
outMT.println("FOLLOWER: "+follower);
System.out.println("TWEETS:");
outMT.println("TWEETS:");
for (String tweet: followersToTweets.get(follower)) {
System.out.println(tweet);
outMT.println(tweet);
}
}
System.out.println("-------------------THE END----------------------");
outMT.println("-------------------THE END----------------------");
outMT.close();
return followersToTweets;
}
public HashMap<String,ArrayList<String>> userFollowingsOnTopic(String stato, String user, String dataStart) throws TwitterException, FileNotFoundException, UnsupportedEncodingException {
PrintWriter outMT = new PrintWriter("mtFollowings.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
//Twitter twitter = this.getTwitter();
//Trovo gli stati associati a una query
System.out.println("--------------TWEET DELL'USER------------");
outMT.println("--------------TWEET DELL'USER------------");
ArrayList<String> stati = new ArrayList<String>();
String statoFinale = stato+" from:"+user;
stati = this.query(statoFinale, 100, dataStart); //"#Totti from:user"; "2015-07-20"
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinale);
for (int i = 0; i<stati.size(); i++) {
outMT.println(stati.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
// Trovo i following associati a un utente
System.out.println("---------------FOLLOWING--------------------");
outMT.println("---------------FOLLOWING--------------------");
ArrayList<String> followings = new ArrayList<String>();
followings = this.followingsOfUser(user); //LM791
System.out.println("TUTTI I FOLLOWINGS DI: "+user);
for (int i = 0; i<followings.size(); i++) {
outMT.println(followings.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
//Trovo gli stati di tali followers con la stessa query
ArrayList<String> appoggioStatiFollowers = new ArrayList<String>();
HashMap<String,ArrayList<String>> followingToTweets = new HashMap<String,ArrayList<String>>();
int lungFollowing = followings.size();
System.out.println("(((((((TWEET FOLLOWING))))))))");
outMT.println("(((((((TWEET FOLLOWING))))))))");
for (int i = 0; i < lungFollowing; i++) {
String statoFinaleFol = stato+" from:"+followings.get(i);
appoggioStatiFollowers = this.query(statoFinaleFol, 100, dataStart);
System.out.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
for (int k = 0; k<appoggioStatiFollowers.size(); k++) {
outMT.println(appoggioStatiFollowers.get(k));
}
followingToTweets.put(followings.get(i), appoggioStatiFollowers); //mappa follower:tutti i suoi stati/tweet su quella query/topic
}
System.out.println("(((((((MAPPA CREATA))))))))");
outMT.println("(((((((MAPPA CREATA))))))))");
//Stampa
System.out.println("--------------STAMPA FINALE--------------------");
outMT.println("--------------STAMPA FINALE--------------------");
for (String following: followingToTweets.keySet()) {
System.out.println("FOLLOWING: "+following);
outMT.println("FOLLOWING: "+following);
System.out.println("TWEETS:");
outMT.println("TWEETS:");
for (String tweet: followingToTweets.get(following)) {
System.out.println(tweet);
outMT.println(tweet);
}
}
System.out.println("-------------------THE END----------------------");
outMT.println("-------------------THE END----------------------");
outMT.close();
return followingToTweets;
}
//i followers con FollowersList
public ArrayList<String> followersOfUser(String user, int numFollowers) throws TwitterException {
ArrayList<String> followers = new ArrayList<String>();
PagableResponseList<User> followersUser = null;
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
long cursor = -1;
System.out.println("LOADING");
int j = 0;
do {
System.out.println("CURSOR:"+cursor);
followersUser = twitter.getFollowersList(user, cursor, numFollowers);
//System.out.println("FATTO");
j = j + 200; //j = j+200
//System.out.println("J"+j);
for (User utente: followersUser) {
followers.add(utente.getScreenName()); // qui il nome con @
}
System.out.println("GETNEXT "+followersUser.getNextCursor()); //il prossimo cursor
}
while ((cursor = followersUser.getNextCursor()) != 0 && j < 3000); //j < 3000
/*System.out.println("I FOLLOWERS DI: "+user);
for (int i = 0; i<followers.size(); i++) {
System.out.println(followers.get(i));
System.out.println(i);
}*/
return followers;
}
//i followings con l'id
public ArrayList<String> followingsOfUser(String user) throws TwitterException {
ArrayList<String> followings = new ArrayList<String>();
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
long cursor = -1;
IDs ids;
System.out.println("Listing following's ids.");
do {
ids = twitter.getFriendsIDs(user, cursor);
for (long id : ids.getIDs()) {
User utente = twitter.showUser(id);
//followers.add(utente.getName()); // salvo i followers in una lista, qui il nome
followings.add(utente.getScreenName()); // qui il nome con @
}
}
while ((cursor = ids.getNextCursor()) != 0);
System.out.println("TUTTI I FOLLOWINGS DI: "+user);
for (int i = 0; i<followings.size(); i++) {
System.out.println(followings.get(i));
}
return followings;
}
private ArrayList<String> query(String stato, int limite, String dataStart) throws TwitterException {
ArrayList<String> tweets = new ArrayList<String>();
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
/*String stato1 = "#Totti"; //FRIEND is to be replaced by your choice of search key
String stato2 = "#Roma";*/
Query query = new Query(stato); //+" OR "+ stato2
query.count(limite); // Limit of resultset
query.setSince(dataStart); // Start date of search
//query.setUntil("2015-07-14"); //il limite temporale sembrerebbe al massimo 7-8 giorni nel passato
QueryResult result = twitter.search(query);
System.out.println("Count : " + result.getTweets().size()) ;
for (Status tweet : result.getTweets()) {
//provare il getLang()
//System.out.println("text : " + tweet.getText());
tweets.add(tweet.getText());
}
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
for (int i = 0; i<tweets.size(); i++) {
System.out.println(tweets.get(i));
}
return tweets;
}
private void updateStatus(String latestStatus) {
try {
//MainTwitter esempi = new MainTwitter();
Twitter twitter = this.getTwitter();
System.out.println(twitter.getScreenName());
Status status = twitter.updateStatus(latestStatus);
System.out.println("Successfully updated the status to [" + status.getText() + "].");
}
catch (TwitterException te) {
te.printStackTrace();
System.exit(-1);
}
}
public Status newStatus(String text) throws TwitterException {
Twitter twitter = this.getTwitter();
Status status = twitter.updateStatus(text);
return status;
}
public static void main(String[] args) throws TwitterException, IOException {
MainTwitter mt = new MainTwitter();
//Twitter twitter = mt.getTwitter();
String stato = "Forza Roma #Totti #ASR";
mt.updateStatus(stato);
//String query = "#Totti";
String user = ""; //
//String dataStart = "2015-09-01";
//mt.followingsOfUser(user);
//mt.userFollowersOnTopic(query, user, dataStart);
//mt.query(query, 100, dataStart);
mt.followersOfUser(user, 50);
//mt.tweetsOfUser(user, 50);
}
}
| UTF-8 | Java | 13,520 | java | MainTwitter.java | Java | [
{
"context": ";\n\t\tfollowers = this.followersOfUser(user, 15); //LM791\n\t\tSystem.out.println(\"TUTTI I FOLLOWERS DI: \"+use",
"end": 3845,
"score": 0.9787728190422058,
"start": 3840,
"tag": "USERNAME",
"value": "LM791"
},
{
"context": "();\n\t\tfollowings = this.followingsOfUser(user); //LM791\n\t\tSystem.out.println(\"TUTTI I FOLLOWINGS DI: \"+us",
"end": 7191,
"score": 0.9816972017288208,
"start": 7186,
"tag": "USERNAME",
"value": "LM791"
}
] | null | [] | package twitter4j;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import twitter4j.IDs;
import twitter4j.Paging;
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.ResponseList;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.ConfigurationBuilder;
public class MainTwitter {
private String consumerKey = "";
private String consumerSecret = "";
private String accessToken = "";
private String accessSecret = "";
private ConfigurationBuilder cb;
private TwitterFactory tf;
private Twitter twitter;
public MainTwitter() {
cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(this.consumerKey)
.setOAuthConsumerSecret(this.consumerSecret)
.setOAuthAccessToken(this.accessToken)
.setOAuthAccessTokenSecret(this.accessSecret);
this.tf = new TwitterFactory(this.cb.build());
this.twitter = this.tf.getInstance();
}
public Twitter getTwitter() {
return twitter;
}
public void setTwitter(Twitter twitter) {
this.twitter = twitter;
}
public ResponseList<Status> tweetsUserPagingNumber(String user, int paging, int numTweet) throws TwitterException {
Twitter twitter = this.getTwitter();
ResponseList<Status> stati = null;
stati = twitter.getUserTimeline(user, new Paging(paging,numTweet));
return stati;
}
/*
* Resituisce tweets associati ad un user: lingua, data e testo (numeroTweet: max 200)
* UTILIZZATO PER IL TWEETPAST
*/
public ResponseList<Status> tweetsOfUser(String user, int numeroTweet) throws TwitterException, FileNotFoundException, IOException {
//PrintWriter outTOU = new PrintWriter("tweetsOfUser.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
ResponseList<Status> stati = null;
stati = twitter.getUserTimeline(user, new Paging(1,numeroTweet)); //cambiando il paging posso risalire agli stati pi�� vecchi
/*for (Status stato: stati) {
//outTOU.println("LINGUA: "+stato.getLang());
//outTOU.println("DATA: "+ stato.getCreatedAt());
//outTOU.println("TWEET: "+stato.getText());
//System.out.println(stato.getText());
}*/
//outTOU.close();
//System.out.println("DONE");
return stati;
}
public HashMap<String,ArrayList<String>> userFollowersOnTopic(String stato, String user, String dataStart) throws TwitterException, FileNotFoundException, UnsupportedEncodingException {
PrintWriter outMT = new PrintWriter("mtFollowers.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
//Twitter twitter = this.getTwitter();
//Trovo gli stati associati a una query
System.out.println("--------------TWEET DELL'USER------------");
outMT.println("--------------TWEET DELL'USER------------");
ArrayList<String> stati = new ArrayList<String>();
String statoFinale = stato+" from:"+user;
stati = this.query(statoFinale, 100, dataStart); //"#Totti from:LM791"; "2015-07-20"
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinale);
for (int i = 0; i<stati.size(); i++) {
outMT.println(stati.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
// Trovo i followers associati a un utente
System.out.println("---------------FOLLOWER--------------------");
outMT.println("---------------FOLLOWER--------------------");
ArrayList<String> followers = new ArrayList<String>();
followers = this.followersOfUser(user, 15); //LM791
System.out.println("TUTTI I FOLLOWERS DI: "+user);
for (int i = 0; i<followers.size(); i++) {
outMT.println(followers.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
//Trovo gli stati di tali followers con la stessa query
ArrayList<String> appoggioStatiFollowers = new ArrayList<String>();
HashMap<String,ArrayList<String>> followersToTweets = new HashMap<String,ArrayList<String>>();
int lungFollowers = followers.size();
System.out.println("(((((((TWEET FOLLOWER))))))))");
outMT.println("(((((((TWEET FOLLOWER))))))))");
for (int i = 0; i < lungFollowers; i++) {
String statoFinaleFol = stato+" from:"+followers.get(i);
appoggioStatiFollowers = this.query(statoFinaleFol, 100, dataStart);
System.out.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
for (int k = 0; k<appoggioStatiFollowers.size(); k++) {
outMT.println(appoggioStatiFollowers.get(k));
}
followersToTweets.put(followers.get(i), appoggioStatiFollowers); //mappa follower:tutti i suoi stati/tweet su quella query/topic
}
System.out.println("(((((((MAPPA CREATA))))))))");
outMT.println("(((((((MAPPA CREATA))))))))");
//Stampa
System.out.println("--------------STAMPA FINALE--------------------");
outMT.println("--------------STAMPA FINALE--------------------");
for (String follower: followersToTweets.keySet()) {
System.out.println("FOLLOWER: "+follower);
outMT.println("FOLLOWER: "+follower);
System.out.println("TWEETS:");
outMT.println("TWEETS:");
for (String tweet: followersToTweets.get(follower)) {
System.out.println(tweet);
outMT.println(tweet);
}
}
System.out.println("-------------------THE END----------------------");
outMT.println("-------------------THE END----------------------");
outMT.close();
return followersToTweets;
}
public HashMap<String,ArrayList<String>> userFollowingsOnTopic(String stato, String user, String dataStart) throws TwitterException, FileNotFoundException, UnsupportedEncodingException {
PrintWriter outMT = new PrintWriter("mtFollowings.txt", "UTF-8");
//MainTwitter mt = new MainTwitter();
//Twitter twitter = this.getTwitter();
//Trovo gli stati associati a una query
System.out.println("--------------TWEET DELL'USER------------");
outMT.println("--------------TWEET DELL'USER------------");
ArrayList<String> stati = new ArrayList<String>();
String statoFinale = stato+" from:"+user;
stati = this.query(statoFinale, 100, dataStart); //"#Totti from:user"; "2015-07-20"
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinale);
for (int i = 0; i<stati.size(); i++) {
outMT.println(stati.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
// Trovo i following associati a un utente
System.out.println("---------------FOLLOWING--------------------");
outMT.println("---------------FOLLOWING--------------------");
ArrayList<String> followings = new ArrayList<String>();
followings = this.followingsOfUser(user); //LM791
System.out.println("TUTTI I FOLLOWINGS DI: "+user);
for (int i = 0; i<followings.size(); i++) {
outMT.println(followings.get(i));
}
System.out.println("-----------------------------------------");
outMT.println("-----------------------------------------");
//Trovo gli stati di tali followers con la stessa query
ArrayList<String> appoggioStatiFollowers = new ArrayList<String>();
HashMap<String,ArrayList<String>> followingToTweets = new HashMap<String,ArrayList<String>>();
int lungFollowing = followings.size();
System.out.println("(((((((TWEET FOLLOWING))))))))");
outMT.println("(((((((TWEET FOLLOWING))))))))");
for (int i = 0; i < lungFollowing; i++) {
String statoFinaleFol = stato+" from:"+followings.get(i);
appoggioStatiFollowers = this.query(statoFinaleFol, 100, dataStart);
System.out.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
outMT.println("TUTTI I TWEET ASSOCIATI A: "+statoFinaleFol);
for (int k = 0; k<appoggioStatiFollowers.size(); k++) {
outMT.println(appoggioStatiFollowers.get(k));
}
followingToTweets.put(followings.get(i), appoggioStatiFollowers); //mappa follower:tutti i suoi stati/tweet su quella query/topic
}
System.out.println("(((((((MAPPA CREATA))))))))");
outMT.println("(((((((MAPPA CREATA))))))))");
//Stampa
System.out.println("--------------STAMPA FINALE--------------------");
outMT.println("--------------STAMPA FINALE--------------------");
for (String following: followingToTweets.keySet()) {
System.out.println("FOLLOWING: "+following);
outMT.println("FOLLOWING: "+following);
System.out.println("TWEETS:");
outMT.println("TWEETS:");
for (String tweet: followingToTweets.get(following)) {
System.out.println(tweet);
outMT.println(tweet);
}
}
System.out.println("-------------------THE END----------------------");
outMT.println("-------------------THE END----------------------");
outMT.close();
return followingToTweets;
}
//i followers con FollowersList
public ArrayList<String> followersOfUser(String user, int numFollowers) throws TwitterException {
ArrayList<String> followers = new ArrayList<String>();
PagableResponseList<User> followersUser = null;
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
long cursor = -1;
System.out.println("LOADING");
int j = 0;
do {
System.out.println("CURSOR:"+cursor);
followersUser = twitter.getFollowersList(user, cursor, numFollowers);
//System.out.println("FATTO");
j = j + 200; //j = j+200
//System.out.println("J"+j);
for (User utente: followersUser) {
followers.add(utente.getScreenName()); // qui il nome con @
}
System.out.println("GETNEXT "+followersUser.getNextCursor()); //il prossimo cursor
}
while ((cursor = followersUser.getNextCursor()) != 0 && j < 3000); //j < 3000
/*System.out.println("I FOLLOWERS DI: "+user);
for (int i = 0; i<followers.size(); i++) {
System.out.println(followers.get(i));
System.out.println(i);
}*/
return followers;
}
//i followings con l'id
public ArrayList<String> followingsOfUser(String user) throws TwitterException {
ArrayList<String> followings = new ArrayList<String>();
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
long cursor = -1;
IDs ids;
System.out.println("Listing following's ids.");
do {
ids = twitter.getFriendsIDs(user, cursor);
for (long id : ids.getIDs()) {
User utente = twitter.showUser(id);
//followers.add(utente.getName()); // salvo i followers in una lista, qui il nome
followings.add(utente.getScreenName()); // qui il nome con @
}
}
while ((cursor = ids.getNextCursor()) != 0);
System.out.println("TUTTI I FOLLOWINGS DI: "+user);
for (int i = 0; i<followings.size(); i++) {
System.out.println(followings.get(i));
}
return followings;
}
private ArrayList<String> query(String stato, int limite, String dataStart) throws TwitterException {
ArrayList<String> tweets = new ArrayList<String>();
//MainTwitter mt = new MainTwitter();
Twitter twitter = this.getTwitter();
/*String stato1 = "#Totti"; //FRIEND is to be replaced by your choice of search key
String stato2 = "#Roma";*/
Query query = new Query(stato); //+" OR "+ stato2
query.count(limite); // Limit of resultset
query.setSince(dataStart); // Start date of search
//query.setUntil("2015-07-14"); //il limite temporale sembrerebbe al massimo 7-8 giorni nel passato
QueryResult result = twitter.search(query);
System.out.println("Count : " + result.getTweets().size()) ;
for (Status tweet : result.getTweets()) {
//provare il getLang()
//System.out.println("text : " + tweet.getText());
tweets.add(tweet.getText());
}
System.out.println("TUTTI I TWEET ASSOCIATI A: "+stato);
for (int i = 0; i<tweets.size(); i++) {
System.out.println(tweets.get(i));
}
return tweets;
}
private void updateStatus(String latestStatus) {
try {
//MainTwitter esempi = new MainTwitter();
Twitter twitter = this.getTwitter();
System.out.println(twitter.getScreenName());
Status status = twitter.updateStatus(latestStatus);
System.out.println("Successfully updated the status to [" + status.getText() + "].");
}
catch (TwitterException te) {
te.printStackTrace();
System.exit(-1);
}
}
public Status newStatus(String text) throws TwitterException {
Twitter twitter = this.getTwitter();
Status status = twitter.updateStatus(text);
return status;
}
public static void main(String[] args) throws TwitterException, IOException {
MainTwitter mt = new MainTwitter();
//Twitter twitter = mt.getTwitter();
String stato = "Forza Roma #Totti #ASR";
mt.updateStatus(stato);
//String query = "#Totti";
String user = ""; //
//String dataStart = "2015-09-01";
//mt.followingsOfUser(user);
//mt.userFollowersOnTopic(query, user, dataStart);
//mt.query(query, 100, dataStart);
mt.followersOfUser(user, 50);
//mt.tweetsOfUser(user, 50);
}
}
| 13,520 | 0.630808 | 0.622152 | 349 | 37.716331 | 29.212242 | 187 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.398281 | false | false | 13 |
38eb0962731a18fca7067e2c27cdf59f8b9d35dd | 16,758,962,457,366 | 7487e61c0cb3ea25c4fed9c722fe1b063aa5ed8c | /jscrapy-core/src/main/java/cn/spark2fire/jscrapy/Task.java | 9430bdec13d395c53b8d83486874ec88927f142b | [
"Apache-2.0"
] | permissive | spark2fire/jscrapy | https://github.com/spark2fire/jscrapy | acac87e76cc0155ece55c9428d76099e09d99859 | f4990edd14204aba4378a5fa4629618d97ebb32f | refs/heads/main | 2023-03-18T00:56:48.864000 | 2021-03-08T09:53:38 | 2021-03-08T09:53:38 | 343,688,114 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.spark2fire.jscrapy;
import cn.spark2fire.jscrapy.pipeline.Pipeline;
import cn.spark2fire.jscrapy.scheduler.Scheduler;
/**
* Interface for identifying different tasks.<br>
*
* @author code4crafter@gmail.com <br>
* @since 0.1.0
* @see Scheduler
* @see Pipeline
*/
public interface Task {
/**
* unique id for a task.
*
* @return uuid
*/
public String getUUID();
/**
* site of a task
*
* @return site
*/
public Site getSite();
}
| UTF-8 | Java | 504 | java | Task.java | Java | [
{
"context": "for identifying different tasks.<br>\n *\n * @author code4crafter@gmail.com <br>\n * @since 0.1.0\n * @see Scheduler\n * @see Pi",
"end": 221,
"score": 0.9999300241470337,
"start": 199,
"tag": "EMAIL",
"value": "code4crafter@gmail.com"
}
] | null | [] | package cn.spark2fire.jscrapy;
import cn.spark2fire.jscrapy.pipeline.Pipeline;
import cn.spark2fire.jscrapy.scheduler.Scheduler;
/**
* Interface for identifying different tasks.<br>
*
* @author <EMAIL> <br>
* @since 0.1.0
* @see Scheduler
* @see Pipeline
*/
public interface Task {
/**
* unique id for a task.
*
* @return uuid
*/
public String getUUID();
/**
* site of a task
*
* @return site
*/
public Site getSite();
}
| 489 | 0.615079 | 0.60119 | 30 | 15.8 | 15.124814 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 13 |
d7c79021e1106e811de04edbb009e11ae985ee58 | 33,560,874,516,347 | 2089e80014f289e0d632e2cc8ded1b820dc82b61 | /odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/util/JsonUtils.java | c98aa7552c11067e39f74243ba94faca1f4e62d9 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | apache/olingo-odata2 | https://github.com/apache/olingo-odata2 | a0e489101a6173734934eb9dd1b592f0ca284f49 | bed23e77f9735c0094b5784aa0d7e3ee972018be | refs/heads/master | 2023-08-25T06:05:34.246000 | 2022-10-23T06:54:29 | 2022-11-30T17:01:41 | 18,830,102 | 45 | 96 | Apache-2.0 | false | 2023-09-03T07:44:00 | 2014-04-16T07:00:07 | 2022-12-13T10:34:31 | 2023-09-03T07:43:58 | 6,956 | 38 | 75 | 9 | Java | false | false | /*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.util;
import java.io.IOException;
import org.apache.olingo.odata2.api.ep.EntityProviderException;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
public class JsonUtils {
public static String createODataContextValueForTombstone(final String entitySetName) {
return FormatJson.DELTA_CONTEXT_PREFIX + entitySetName + FormatJson.DELTA_CONTEXT_POSTFIX;
}
public static int startJson(final JsonReader reader) throws EntityProviderException {
// The enclosing "d" and "results" are optional - so we cannot check for the presence
// but we have to read over them in case they are present.
JsonToken token;
try {
token = reader.peek();
int openJsonObjects = 0;
if (JsonToken.BEGIN_OBJECT == token) {
reader.beginObject();
openJsonObjects++;
token = reader.peek();
if (JsonToken.NAME == token) {
String name = reader.nextName();
if (!("d".equals(name) ^ "results".equals(name))) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, name +
" not expected, only d or results");
}
}
token = reader.peek();
if (JsonToken.BEGIN_OBJECT == token) {
reader.beginObject();
openJsonObjects++;
} else if (JsonToken.BEGIN_ARRAY == token) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, "Array not expected");
}
}
return openJsonObjects;
} catch (IOException e) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, e);
}
}
public static boolean endJson(final JsonReader reader, final int openJsonObjects) throws IOException,
EntityProviderException {
for (int closedJsonObjects = 0; closedJsonObjects < openJsonObjects; closedJsonObjects++) {
reader.endObject();
}
return reader.peek() == JsonToken.END_DOCUMENT;
}
}
| UTF-8 | Java | 3,017 | java | JsonUtils.java | Java | [] | null | [] | /*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.util;
import java.io.IOException;
import org.apache.olingo.odata2.api.ep.EntityProviderException;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
public class JsonUtils {
public static String createODataContextValueForTombstone(final String entitySetName) {
return FormatJson.DELTA_CONTEXT_PREFIX + entitySetName + FormatJson.DELTA_CONTEXT_POSTFIX;
}
public static int startJson(final JsonReader reader) throws EntityProviderException {
// The enclosing "d" and "results" are optional - so we cannot check for the presence
// but we have to read over them in case they are present.
JsonToken token;
try {
token = reader.peek();
int openJsonObjects = 0;
if (JsonToken.BEGIN_OBJECT == token) {
reader.beginObject();
openJsonObjects++;
token = reader.peek();
if (JsonToken.NAME == token) {
String name = reader.nextName();
if (!("d".equals(name) ^ "results".equals(name))) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, name +
" not expected, only d or results");
}
}
token = reader.peek();
if (JsonToken.BEGIN_OBJECT == token) {
reader.beginObject();
openJsonObjects++;
} else if (JsonToken.BEGIN_ARRAY == token) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, "Array not expected");
}
}
return openJsonObjects;
} catch (IOException e) {
// TODO I18N
throw new EntityProviderException(EntityProviderException.COMMON, e);
}
}
public static boolean endJson(final JsonReader reader, final int openJsonObjects) throws IOException,
EntityProviderException {
for (int closedJsonObjects = 0; closedJsonObjects < openJsonObjects; closedJsonObjects++) {
reader.endObject();
}
return reader.peek() == JsonToken.END_DOCUMENT;
}
}
| 3,017 | 0.652966 | 0.648326 | 79 | 37.189873 | 29.292967 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.443038 | false | false | 13 |
bd1d7ddaae79d23f6e245566ac23003ae1b0f5ea | 7,524,782,762,830 | b3f6651cee7c8719fab5f8e5715c0a9b3ec2268e | /IdeaProjects/tiketandroid/app/src/main/java/com/example/tiketandroid/app/TambahTiket.java | 9d5f16364a94ae413d1e823cccd489fa170ef4db | [] | no_license | asywalulfikri/Material-Design | https://github.com/asywalulfikri/Material-Design | a4a9d975df64df6395949ff9f783693d968e806d | c889821a9d1978980da774d8ee2f82597bf905ed | refs/heads/master | 2016-08-12T03:22:38.371000 | 2016-04-17T13:19:38 | 2016-04-17T13:19:38 | 45,507,845 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.tiketandroid.app;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import java.net.URL;
import java.util.ArrayList;
/**
* Created by Toshiba on 4/16/2016.
*/
public class TambahTiket extends AppCompatActivity {
private EditText subjec, isi, telpon;
private TextView nama, email;
Button simpan;
public final static String SP = "sharedAt";
private boolean mIsLoading = false;
String subjek, isii, phone;
HttpManager httpManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input);
telpon = (EditText) findViewById(R.id.txttlpn);
subjec = (EditText) findViewById(R.id.txtsubject);
isi = (EditText) findViewById(R.id.txtisi);
simpan = (Button) findViewById(R.id.btnsubmit);
simpan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subjek = subjec.getText().toString();
isii = isi.getText().toString();
phone = telpon.getText().toString();
if (subjek.equals("") || isii.equals("")) {
Toast.makeText(getApplicationContext(), "Please complete this form", Toast.LENGTH_SHORT).show();
}
new postReg().execute();
}
});
updateview();
}
public void updateview() {
SharedPreferences getId = getApplicationContext().getSharedPreferences(SP, 0);
nama = (TextView) findViewById(R.id.txtnama);
email = (TextView) findViewById(R.id.txtemail);
nama.setText(getId.getString("username", "username"));
email.setText(getId.getString("email", "email"));
}
public class postReg extends AsyncTask<String, Void, String> {
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = new ProgressDialog(TambahTiket.this);
dialog.setMessage("Proses Simpan");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
@Override
protected String doInBackground(String... params) {
SharedPreferences getIduser = getApplicationContext().getSharedPreferences(SP, 0);
String iduser = getIduser.getString("iduser", "Nothing");
String url = "http://tiketsupporting.esy.es/restful/tambahtiket.php";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("nama", iduser));
nameValuePairs.add(new BasicNameValuePair("phone", phone));
nameValuePairs.add(new BasicNameValuePair("subject", subjek));
nameValuePairs.add(new BasicNameValuePair("isi", isii));
try {
httpManager.postContentParameters(url,nameValuePairs);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String result) {
dialog.dismiss();
Toast.makeText(TambahTiket.this, "Post success", Toast.LENGTH_SHORT).show();
}
}
@SuppressWarnings("deprecation")
public void onClick(View v ) {
showDialog(0);
}
}
| UTF-8 | Java | 3,961 | java | TambahTiket.java | Java | [
{
"context": "RL;\nimport java.util.ArrayList;\n\n/**\n * Created by Toshiba on 4/16/2016.\n */\npublic class TambahTiket exten",
"end": 590,
"score": 0.9991090893745422,
"start": 583,
"tag": "NAME",
"value": "Toshiba"
},
{
"context": " nama.setText(getId.getString(\"username\", \"username\"));\n email.setText(getId.getString(\"email\"",
"end": 2152,
"score": 0.9996592998504639,
"start": 2144,
"tag": "USERNAME",
"value": "username"
}
] | null | [] | package com.example.tiketandroid.app;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import java.net.URL;
import java.util.ArrayList;
/**
* Created by Toshiba on 4/16/2016.
*/
public class TambahTiket extends AppCompatActivity {
private EditText subjec, isi, telpon;
private TextView nama, email;
Button simpan;
public final static String SP = "sharedAt";
private boolean mIsLoading = false;
String subjek, isii, phone;
HttpManager httpManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input);
telpon = (EditText) findViewById(R.id.txttlpn);
subjec = (EditText) findViewById(R.id.txtsubject);
isi = (EditText) findViewById(R.id.txtisi);
simpan = (Button) findViewById(R.id.btnsubmit);
simpan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subjek = subjec.getText().toString();
isii = isi.getText().toString();
phone = telpon.getText().toString();
if (subjek.equals("") || isii.equals("")) {
Toast.makeText(getApplicationContext(), "Please complete this form", Toast.LENGTH_SHORT).show();
}
new postReg().execute();
}
});
updateview();
}
public void updateview() {
SharedPreferences getId = getApplicationContext().getSharedPreferences(SP, 0);
nama = (TextView) findViewById(R.id.txtnama);
email = (TextView) findViewById(R.id.txtemail);
nama.setText(getId.getString("username", "username"));
email.setText(getId.getString("email", "email"));
}
public class postReg extends AsyncTask<String, Void, String> {
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = new ProgressDialog(TambahTiket.this);
dialog.setMessage("Proses Simpan");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
@Override
protected String doInBackground(String... params) {
SharedPreferences getIduser = getApplicationContext().getSharedPreferences(SP, 0);
String iduser = getIduser.getString("iduser", "Nothing");
String url = "http://tiketsupporting.esy.es/restful/tambahtiket.php";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("nama", iduser));
nameValuePairs.add(new BasicNameValuePair("phone", phone));
nameValuePairs.add(new BasicNameValuePair("subject", subjek));
nameValuePairs.add(new BasicNameValuePair("isi", isii));
try {
httpManager.postContentParameters(url,nameValuePairs);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String result) {
dialog.dismiss();
Toast.makeText(TambahTiket.this, "Post success", Toast.LENGTH_SHORT).show();
}
}
@SuppressWarnings("deprecation")
public void onClick(View v ) {
showDialog(0);
}
}
| 3,961 | 0.632416 | 0.629639 | 133 | 28.781956 | 26.111197 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.646617 | false | false | 13 |
00dfd3fa1290abf33f324d7d791151a79519c311 | 21,706,764,766,122 | bbda88236d31f6418ac04947f8c1ad41c12d7006 | /dip/dhcp/impl/src/main/java/org/opendaylight/dhcp/util/MetaDataUtil.java | d004c82a75fcae22e5ab1a611916beefc30708b3 | [] | no_license | chengguozhen/jcode | https://github.com/chengguozhen/jcode | 7aa2346f9aed8cd9a6892778706be7adef1901d4 | 9eddaae42caf5462c7244f41c9acaee3dba57252 | refs/heads/master | 2021-04-15T10:16:43.555000 | 2018-03-24T03:34:15 | 2018-03-24T03:34:52 | 126,565,905 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.dhcp.util;
import java.math.BigInteger;
public class MetaDataUtil {
public static final BigInteger METADATA_MASK_VRFID = new BigInteger("00000000FFFFFFFF", 16);
public static final BigInteger METADATA_MASK_LPORT_TAG = new BigInteger("1FFFFF0000000000", 16);
public static final BigInteger METADATA_MASK_SERVICE = new BigInteger("000000FFFF000000", 16);
public static final BigInteger METADATA_MASK_SERVICE_INDEX = new BigInteger("E000000000000000", 16);
public static final BigInteger METADATA_MASK_LPORT_WRITE = new BigInteger("00FFFF0000000000", 16);
public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16);
public static final BigInteger METADATA_MASK_LABEL_ITM = new BigInteger("40FFFFFF000000FF", 16);
public static final BigInteger METADA_MASK_TUNNEL_ID = new BigInteger("00000000FFFFFF00", 16);
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag));
}
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex,
BigInteger serviceMetaData) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag)).or(serviceMetaData);
}
public static BigInteger getServiceIndexMetaData(int serviceIndex) {
return new BigInteger("7", 16).and(BigInteger.valueOf(serviceIndex)).shiftLeft(61);
}
public static BigInteger getLportTagMetaData(int lportTag) {
return new BigInteger("1FFFFF", 16).and(BigInteger.valueOf(lportTag)).shiftLeft(40);
}
public static BigInteger getMetaDataMaskForLPortDispatcher() {
return METADATA_MASK_SERVICE_INDEX.or(METADATA_MASK_LPORT_TAG);
}
public static BigInteger getMetadataLPort(int lPortTag) {
return (new BigInteger("FFFF", 16).and(BigInteger.valueOf(lPortTag))).shiftLeft(40);
}
public static BigInteger getLportFromMetadata(BigInteger metadata) {
return (metadata.and(METADATA_MASK_LPORT_TAG)).shiftRight(40);
}
public static int getElanTagFromMetadata(BigInteger metadata) {
return (((metadata.and(MetaDataUtil.METADATA_MASK_SERVICE)).
shiftRight(24))).intValue();
}
public static BigInteger getMetaDataMaskForLPortDispatcher(BigInteger metadataMaskForServiceIndex,
BigInteger metadataMaskForLPortTag, BigInteger metadataMaskForService) {
return metadataMaskForServiceIndex.or(metadataMaskForLPortTag).or(metadataMaskForService);
}
/**
* For the tunnel id with VNI and valid-vni-flag set, the most significant byte
* should have 08. So, shifting 08 to 7 bytes (56 bits) and the result is OR-ed with
* VNI being shifted to 1 byte.
*/
public static BigInteger getTunnelIdWithValidVniBitAndVniSet(int vni) {
return BigInteger.valueOf(0X08).shiftLeft(56).or(BigInteger.valueOf(vni).shiftLeft(8));
}
}
| UTF-8 | Java | 3,474 | java | MetaDataUtil.java | Java | [
{
"context": "/*\n * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All righ",
"end": 36,
"score": 0.858539879322052,
"start": 25,
"tag": "NAME",
"value": "Ericsson In"
}
] | null | [] | /*
* Copyright (c) 2015 <NAME>dia Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.dhcp.util;
import java.math.BigInteger;
public class MetaDataUtil {
public static final BigInteger METADATA_MASK_VRFID = new BigInteger("00000000FFFFFFFF", 16);
public static final BigInteger METADATA_MASK_LPORT_TAG = new BigInteger("1FFFFF0000000000", 16);
public static final BigInteger METADATA_MASK_SERVICE = new BigInteger("000000FFFF000000", 16);
public static final BigInteger METADATA_MASK_SERVICE_INDEX = new BigInteger("E000000000000000", 16);
public static final BigInteger METADATA_MASK_LPORT_WRITE = new BigInteger("00FFFF0000000000", 16);
public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16);
public static final BigInteger METADATA_MASK_LABEL_ITM = new BigInteger("40FFFFFF000000FF", 16);
public static final BigInteger METADA_MASK_TUNNEL_ID = new BigInteger("00000000FFFFFF00", 16);
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag));
}
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex,
BigInteger serviceMetaData) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag)).or(serviceMetaData);
}
public static BigInteger getServiceIndexMetaData(int serviceIndex) {
return new BigInteger("7", 16).and(BigInteger.valueOf(serviceIndex)).shiftLeft(61);
}
public static BigInteger getLportTagMetaData(int lportTag) {
return new BigInteger("1FFFFF", 16).and(BigInteger.valueOf(lportTag)).shiftLeft(40);
}
public static BigInteger getMetaDataMaskForLPortDispatcher() {
return METADATA_MASK_SERVICE_INDEX.or(METADATA_MASK_LPORT_TAG);
}
public static BigInteger getMetadataLPort(int lPortTag) {
return (new BigInteger("FFFF", 16).and(BigInteger.valueOf(lPortTag))).shiftLeft(40);
}
public static BigInteger getLportFromMetadata(BigInteger metadata) {
return (metadata.and(METADATA_MASK_LPORT_TAG)).shiftRight(40);
}
public static int getElanTagFromMetadata(BigInteger metadata) {
return (((metadata.and(MetaDataUtil.METADATA_MASK_SERVICE)).
shiftRight(24))).intValue();
}
public static BigInteger getMetaDataMaskForLPortDispatcher(BigInteger metadataMaskForServiceIndex,
BigInteger metadataMaskForLPortTag, BigInteger metadataMaskForService) {
return metadataMaskForServiceIndex.or(metadataMaskForLPortTag).or(metadataMaskForService);
}
/**
* For the tunnel id with VNI and valid-vni-flag set, the most significant byte
* should have 08. So, shifting 08 to 7 bytes (56 bits) and the result is OR-ed with
* VNI being shifted to 1 byte.
*/
public static BigInteger getTunnelIdWithValidVniBitAndVniSet(int vni) {
return BigInteger.valueOf(0X08).shiftLeft(56).or(BigInteger.valueOf(vni).shiftLeft(8));
}
}
| 3,469 | 0.724237 | 0.683362 | 69 | 49.347828 | 42.782166 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.565217 | false | false | 13 |
420761fcdf59320f16f710a4a715620e66f1b189 | 816,043,787,969 | 5ebb1d3d4b7e54d016a43d522a3a09a6318555e3 | /Euler/Java/src/main/java/euler/Problem72.java | 3e0b32895a1eb3168f0a0d7e1703d2b89a7afd70 | [] | no_license | redhill42/MMA | https://github.com/redhill42/MMA | 3af2c4ba5a972f1697b054057b1bfca7fc540f5c | 1cf0354d43ade6669678a171f8bab01695c075b0 | refs/heads/master | 2021-04-26T22:57:04.401000 | 2018-09-01T02:27:03 | 2018-09-01T02:27:03 | 123,901,653 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package euler;
import static euler.algo.Sublinear.totientSum;
public final class Problem72 {
private Problem72() {}
public static long solve(int n) {
return totientSum(n) - 1;
}
public static void main(String[] args) {
int n = 1_000_000;
if (args.length > 0)
n = Integer.parseInt(args[0]);
System.out.println(solve(n));
}
}
| UTF-8 | Java | 392 | java | Problem72.java | Java | [] | null | [] | package euler;
import static euler.algo.Sublinear.totientSum;
public final class Problem72 {
private Problem72() {}
public static long solve(int n) {
return totientSum(n) - 1;
}
public static void main(String[] args) {
int n = 1_000_000;
if (args.length > 0)
n = Integer.parseInt(args[0]);
System.out.println(solve(n));
}
}
| 392 | 0.594388 | 0.558673 | 18 | 20.777779 | 16.92321 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
64f97b18e71c9ea53030bd8a8647e452304d01bd | 816,043,788,633 | a0959aeac39af34bc61c6e2156a146c369117d1d | /examples/rmi/ex7-PassingArgsInRMI/Client.java | 0ffa05b756c437499debcea80ee33d4cca0c0f06 | [] | no_license | BoiseState/CS455-resources | https://github.com/BoiseState/CS455-resources | 0688b96189fc96bcd969fdfc01d880f2c7c2c860 | 6603e77ae0160b8e80ba9a41a6f9e5aba0ec680d | refs/heads/master | 2023-04-06T04:34:54.835000 | 2023-03-15T00:56:54 | 2023-03-15T00:56:54 | 49,302,586 | 19 | 12 | null | false | 2023-03-15T00:56:56 | 2016-01-08T23:33:45 | 2023-03-01T22:09:00 | 2023-03-15T00:56:54 | 70,009 | 15 | 6 | 0 | null | false | false | import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
* The entire point of this program is to show how parameters are passed in RMI.
*
* @author atulepbe
* @author amit
*
*/
public class Client
{
private final static String CLIENT_STUB_INTERFACE = "Service";
private final static String HOST = "localhost";
private static Doodle doodie = new Doodle();
public Client() {
}
private void startThread() {
new Thread(new PrintingThread()).start();
}
public static void main(String args[]) {
if (System.getSecurityManager() == null) System.setSecurityManager(new SecurityManager());
try {
String name = CLIENT_STUB_INTERFACE;
Registry registry = LocateRegistry.getRegistry(HOST);
Service serve = (Service) registry.lookup(name);
Client temp = new Client();
temp.startThread();
System.out.println("Client: sending request to server");
serve.execute(doodie);
System.out.println("Client: received response from server");
} catch (Exception e) {
System.err.println("Client: sadface :(");
e.printStackTrace();
}
}
private class PrintingThread implements Runnable
{
@Override
public void run() {
while (true) {
System.out.println(Client.doodie);
try {
Thread.sleep(1000); // sleep for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
| UTF-8 | Java | 1,649 | java | Client.java | Java | [
{
"context": "w how parameters are passed in RMI.\n * \n * @author atulepbe\n * @author amit\n *\n */\npublic class Client\n{\n ",
"end": 185,
"score": 0.9991185665130615,
"start": 177,
"tag": "USERNAME",
"value": "atulepbe"
},
{
"context": " passed in RMI.\n * \n * @author atulepbe\n * @author amit\n *\n */\npublic class Client\n{\n private final st",
"end": 201,
"score": 0.7969696521759033,
"start": 197,
"tag": "USERNAME",
"value": "amit"
}
] | null | [] | import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
* The entire point of this program is to show how parameters are passed in RMI.
*
* @author atulepbe
* @author amit
*
*/
public class Client
{
private final static String CLIENT_STUB_INTERFACE = "Service";
private final static String HOST = "localhost";
private static Doodle doodie = new Doodle();
public Client() {
}
private void startThread() {
new Thread(new PrintingThread()).start();
}
public static void main(String args[]) {
if (System.getSecurityManager() == null) System.setSecurityManager(new SecurityManager());
try {
String name = CLIENT_STUB_INTERFACE;
Registry registry = LocateRegistry.getRegistry(HOST);
Service serve = (Service) registry.lookup(name);
Client temp = new Client();
temp.startThread();
System.out.println("Client: sending request to server");
serve.execute(doodie);
System.out.println("Client: received response from server");
} catch (Exception e) {
System.err.println("Client: sadface :(");
e.printStackTrace();
}
}
private class PrintingThread implements Runnable
{
@Override
public void run() {
while (true) {
System.out.println(Client.doodie);
try {
Thread.sleep(1000); // sleep for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
| 1,649 | 0.576107 | 0.573075 | 57 | 27.929825 | 24.702339 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.350877 | false | false | 13 |
f82790db1da6d257e192bf9e06889ab93938c823 | 26,276,609,978,270 | 2f1e2724fa9145d13f04fcc92958558a8cba7360 | /nst-web-api/src/test/java/cn/gdeng/nst/web/controller/test/MemberCarControllerTest.java | ad8f0f2cf82ee876e00cbe5562c3b18384c7bd13 | [] | no_license | winall898/gd-nst | https://github.com/winall898/gd-nst | 078b35183f21eda794d8c01ac486e0f107770bac | de87ee80128b9aab34e359e0b365c04458e646ad | refs/heads/master | 2021-01-25T08:00:50.556000 | 2017-06-08T06:19:18 | 2017-06-08T06:19:18 | 93,695,982 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.gdeng.nst.web.controller.test;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import cn.gdeng.nst.util.server.HttpClientUtil;
import cn.gdeng.nst.util.web.api.Des3;
import junit.framework.TestCase;
public class MemberCarControllerTest extends TestCase {
private static String publicUrl = "http://localhost:8880/nst-web-api/memberCarApi/";
// 查询用户承运车辆
public void queryMemberCarrierCarList() throws Exception {
long a = System.currentTimeMillis();
String url = publicUrl + "queryMemberCarrierCarList";
Map<String, Object> map = new HashMap<String, Object>();
map.put("memberId", "280082");
Gson gson = new Gson();
String requestData = Des3.encode(gson.toJson(map));
Map<String, Object> map2 = new HashMap<>();
map2.put("param", requestData);
String reponseData = HttpClientUtil.doGet(url, map2);
System.out.println(Des3.decode(reponseData) + "最终结果");
long b = System.currentTimeMillis();
System.out.println(b - a);
}
// 修改用户车辆为承运车辆
public void updateMemberCarrierCar() throws Exception {
long a = System.currentTimeMillis();
String url = publicUrl + "updateMemberCarrierCar";
Map<String, Object> map = new HashMap<String, Object>();
map.put("memberId", "324985");
map.put("id", "66756");
Gson gson = new Gson();
String requestData = Des3.encode(gson.toJson(map));
Map<String, Object> map2 = new HashMap<>();
map2.put("param", requestData);
String reponseData = HttpClientUtil.doGet(url, map2);
System.out.println(Des3.decode(reponseData) + "最终结果");
long b = System.currentTimeMillis();
System.out.println(b - a);
}
}
| UTF-8 | Java | 1,678 | java | MemberCarControllerTest.java | Java | [] | null | [] | package cn.gdeng.nst.web.controller.test;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import cn.gdeng.nst.util.server.HttpClientUtil;
import cn.gdeng.nst.util.web.api.Des3;
import junit.framework.TestCase;
public class MemberCarControllerTest extends TestCase {
private static String publicUrl = "http://localhost:8880/nst-web-api/memberCarApi/";
// 查询用户承运车辆
public void queryMemberCarrierCarList() throws Exception {
long a = System.currentTimeMillis();
String url = publicUrl + "queryMemberCarrierCarList";
Map<String, Object> map = new HashMap<String, Object>();
map.put("memberId", "280082");
Gson gson = new Gson();
String requestData = Des3.encode(gson.toJson(map));
Map<String, Object> map2 = new HashMap<>();
map2.put("param", requestData);
String reponseData = HttpClientUtil.doGet(url, map2);
System.out.println(Des3.decode(reponseData) + "最终结果");
long b = System.currentTimeMillis();
System.out.println(b - a);
}
// 修改用户车辆为承运车辆
public void updateMemberCarrierCar() throws Exception {
long a = System.currentTimeMillis();
String url = publicUrl + "updateMemberCarrierCar";
Map<String, Object> map = new HashMap<String, Object>();
map.put("memberId", "324985");
map.put("id", "66756");
Gson gson = new Gson();
String requestData = Des3.encode(gson.toJson(map));
Map<String, Object> map2 = new HashMap<>();
map2.put("param", requestData);
String reponseData = HttpClientUtil.doGet(url, map2);
System.out.println(Des3.decode(reponseData) + "最终结果");
long b = System.currentTimeMillis();
System.out.println(b - a);
}
}
| 1,678 | 0.720443 | 0.700739 | 49 | 32.142857 | 21.534027 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.142857 | false | false | 13 |
f341d2ef3c37c174380cb1332d6a89fa83f9d662 | 31,928,786,934,878 | 9cdf8e4723c6e74d0b8db1bf1170757b58a7cbf3 | /app/src/main/java/com/snail/rxjavademo/rxjava/obeservable/ObservableOnSubscribe.java | 7f248a796fca05601d9437ce9a74090bb3f87af0 | [] | no_license | S-Snail/RxJavaDemo | https://github.com/S-Snail/RxJavaDemo | bf4a6befd03aeda84748490ded81ac549969c20a | 40dcee97c48d149030343fcdae718b504324c5e1 | refs/heads/master | 2023-05-10T00:42:14.970000 | 2021-06-03T16:22:15 | 2021-06-03T16:22:15 | 315,970,859 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.snail.rxjavademo.rxjava.obeservable;
import com.snail.rxjavademo.rxjava.obeservable.emitter.Emitter;
/**
* 将发射器Emitter和Observable绑定到一起
*/
public interface ObservableOnSubscribe<T> {
void subscribe(Emitter<T> emitter);
}
| UTF-8 | Java | 260 | java | ObservableOnSubscribe.java | Java | [] | null | [] | package com.snail.rxjavademo.rxjava.obeservable;
import com.snail.rxjavademo.rxjava.obeservable.emitter.Emitter;
/**
* 将发射器Emitter和Observable绑定到一起
*/
public interface ObservableOnSubscribe<T> {
void subscribe(Emitter<T> emitter);
}
| 260 | 0.7875 | 0.7875 | 10 | 23 | 22.960836 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 13 |
5b1d002ff79c363739cd5fa58bb4f733d166099b | 38,414,187,506,299 | 1c3bc30d0b467a745a936dbcb0f7cc4344ba1a4b | /src/test/java/listeners/DriverCloseListener.java | 04babe111031072d1d5f8567c90d51109947655b | [] | no_license | diazolin88/wiley | https://github.com/diazolin88/wiley | 6a2b414429334831d4a5beee04847ddc83903a72 | a3039af702ef1d01c2338396c52008237ff5cea9 | refs/heads/master | 2023-04-16T13:11:54.641000 | 2018-05-09T01:03:55 | 2018-05-09T01:03:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package listeners;
import org.openqa.selenium.WebDriver;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import selenium.Browser;
/**
* Created by Alek on 08.05.2018.
*/
public class DriverCloseListener implements ITestListener{
@Override
public void onTestStart(ITestResult iTestResult) {
}
@Override
public void onTestSuccess(ITestResult iTestResult) {
}
@Override
public void onTestFailure(ITestResult iTestResult) {
}
@Override
public void onTestSkipped(ITestResult iTestResult) {
}
@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {
}
@Override
public void onStart(ITestContext iTestContext) {
}
@Override
public void onFinish(ITestContext iTestContext) {
WebDriver webDriver = Browser.getDriver();
if (webDriver != null) {
try {
webDriver.quit();
} catch (Exception ignored) {
} finally {
Browser.setDriver(null);
}
}
}
}
| UTF-8 | Java | 1,117 | java | DriverCloseListener.java | Java | [
{
"context": "esult;\nimport selenium.Browser;\n\n/**\n * Created by Alek on 08.05.2018.\n */\npublic class DriverCloseLis",
"end": 199,
"score": 0.5753296613693237,
"start": 198,
"tag": "NAME",
"value": "A"
},
{
"context": "ult;\nimport selenium.Browser;\n\n/**\n * Created by Alek on 08.05.2018.\n */\npublic class DriverCloseListen",
"end": 202,
"score": 0.7156583070755005,
"start": 199,
"tag": "USERNAME",
"value": "lek"
}
] | null | [] | package listeners;
import org.openqa.selenium.WebDriver;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import selenium.Browser;
/**
* Created by Alek on 08.05.2018.
*/
public class DriverCloseListener implements ITestListener{
@Override
public void onTestStart(ITestResult iTestResult) {
}
@Override
public void onTestSuccess(ITestResult iTestResult) {
}
@Override
public void onTestFailure(ITestResult iTestResult) {
}
@Override
public void onTestSkipped(ITestResult iTestResult) {
}
@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {
}
@Override
public void onStart(ITestContext iTestContext) {
}
@Override
public void onFinish(ITestContext iTestContext) {
WebDriver webDriver = Browser.getDriver();
if (webDriver != null) {
try {
webDriver.quit();
} catch (Exception ignored) {
} finally {
Browser.setDriver(null);
}
}
}
}
| 1,117 | 0.649955 | 0.642793 | 55 | 19.309092 | 20.818586 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.163636 | false | false | 13 |
080d4964cb3ac2446e793c76f4a94d205eff2416 | 7,095,286,014,883 | a1c6c5be506126070d14f5de67f25abbb4931e98 | /twelve-days/src/main/java/TwelveDays.java | dec0b144401e2422bb3fbfa4bc4a1decfab2f09d | [] | no_license | Cheri-Deepa/Exercism | https://github.com/Cheri-Deepa/Exercism | 2438562246ee53e66411cd9b8950f9e84f3722a6 | c048279dff8c4dc843ca7dd95c46b7128a1ec5a6 | refs/heads/master | 2020-06-15T23:24:50.958000 | 2019-07-21T03:20:37 | 2019-07-21T03:20:37 | 195,419,834 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | class TwelveDays {
private final String days[] = {"first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth"};
String verse(int verseNumber) {
String stanza = String.format("On the %s day of Christmas my true love gave to me: ",days[verseNumber-1]);
switch(verseNumber)
{
case 12 : stanza+="twelve Drummers Drumming, " ;
case 11 : stanza+="eleven Pipers Piping, " ;
case 10 : stanza+="ten Lords-a-Leaping, " ;
case 9 : stanza+="nine Ladies Dancing, " ;
case 8 : stanza+="eight Maids-a-Milking, " ;
case 7 : stanza+="seven Swans-a-Swimming, ";
case 6 : stanza+="six Geese-a-Laying, ";
case 5 : stanza+="five Gold Rings, ";
case 4 : stanza+="four Calling Birds, " ;
case 3 : stanza+="three French Hens, ";
case 2: stanza+="two Turtle Doves, and ";
case 1: stanza+="a Partridge in a Pear Tree.\n";
}
return stanza;
}
String verses(int startVerse, int endVerse) {
String stanzas ="";
for(int i=startVerse;i<=endVerse;i++) {
stanzas += verse(i);
if (i<endVerse)
stanzas+= "\n";
}
return stanzas;
}
String sing() {
return verses(1,12);
}
} | UTF-8 | Java | 1,399 | java | TwelveDays.java | Java | [] | null | [] | class TwelveDays {
private final String days[] = {"first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth"};
String verse(int verseNumber) {
String stanza = String.format("On the %s day of Christmas my true love gave to me: ",days[verseNumber-1]);
switch(verseNumber)
{
case 12 : stanza+="twelve Drummers Drumming, " ;
case 11 : stanza+="eleven Pipers Piping, " ;
case 10 : stanza+="ten Lords-a-Leaping, " ;
case 9 : stanza+="nine Ladies Dancing, " ;
case 8 : stanza+="eight Maids-a-Milking, " ;
case 7 : stanza+="seven Swans-a-Swimming, ";
case 6 : stanza+="six Geese-a-Laying, ";
case 5 : stanza+="five Gold Rings, ";
case 4 : stanza+="four Calling Birds, " ;
case 3 : stanza+="three French Hens, ";
case 2: stanza+="two Turtle Doves, and ";
case 1: stanza+="a Partridge in a Pear Tree.\n";
}
return stanza;
}
String verses(int startVerse, int endVerse) {
String stanzas ="";
for(int i=startVerse;i<=endVerse;i++) {
stanzas += verse(i);
if (i<endVerse)
stanzas+= "\n";
}
return stanzas;
}
String sing() {
return verses(1,12);
}
} | 1,399 | 0.520372 | 0.506791 | 49 | 27.571428 | 30.564753 | 142 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.959184 | false | false | 13 |
287bfe17fce062a08544240685ae820c5b0e87d9 | 154,618,879,967 | a562775e3c3ba705eda8fac626b7c389217c3986 | /src/Main.java | 84df2b900447884fac24614b4579dfb123e28af5 | [] | no_license | Temirlan-tech/HW2.7 | https://github.com/Temirlan-tech/HW2.7 | 30d20ce7e5cce5c6e1e645d00b25eaf9839664d6 | bfa7213a7fe00eb9fb5e57d656463b41b96f0b76 | refs/heads/master | 2023-01-09T04:48:37.415000 | 2020-11-11T12:41:50 | 2020-11-11T12:41:50 | 311,967,393 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scannerA = new Scanner(System.in);
ArrayList<String> c = new ArrayList<>();
ArrayList<String> a = new ArrayList<>();
int A = 0;
while (A != 5) {
a.add(scannerA.next());
A++;
}
Iterator<String> iterA = a.iterator();
while (iterA.hasNext()) {
System.out.print(iterA.next() + " ");
}
Scanner scannerB = new Scanner(System.in);
ArrayList<String> b = new ArrayList<>();
int B = 0;
while (B != 5) {
b.add(scannerB.next());
B++;
}
Collections.reverse(b);
Iterator<String> iterB = b.iterator();
iterA = a.iterator();
Iterator<String> iterC = c.iterator();
while (iterA.hasNext() && iterB.hasNext()) {
c.add(iterA.next());
c.add(iterB.next());
}
iterC = c.iterator();
while (iterC.hasNext()){
String q1 = iterC.next();
System.out.println(q1);
}
Comparator<String> comp1 = (o1, o2) -> {
Integer f1 = o1.length();
Integer f2 = o2.length();
return f1.compareTo(f2);
};
c.sort(comp1);
}
}
| UTF-8 | Java | 1,333 | java | Main.java | Java | [] | null | [] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scannerA = new Scanner(System.in);
ArrayList<String> c = new ArrayList<>();
ArrayList<String> a = new ArrayList<>();
int A = 0;
while (A != 5) {
a.add(scannerA.next());
A++;
}
Iterator<String> iterA = a.iterator();
while (iterA.hasNext()) {
System.out.print(iterA.next() + " ");
}
Scanner scannerB = new Scanner(System.in);
ArrayList<String> b = new ArrayList<>();
int B = 0;
while (B != 5) {
b.add(scannerB.next());
B++;
}
Collections.reverse(b);
Iterator<String> iterB = b.iterator();
iterA = a.iterator();
Iterator<String> iterC = c.iterator();
while (iterA.hasNext() && iterB.hasNext()) {
c.add(iterA.next());
c.add(iterB.next());
}
iterC = c.iterator();
while (iterC.hasNext()){
String q1 = iterC.next();
System.out.println(q1);
}
Comparator<String> comp1 = (o1, o2) -> {
Integer f1 = o1.length();
Integer f2 = o2.length();
return f1.compareTo(f2);
};
c.sort(comp1);
}
}
| 1,333 | 0.474869 | 0.462866 | 52 | 24.634615 | 17.498383 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.557692 | false | false | 13 |
7b44659c5d41e3448dfc148e203dc2bf7564a546 | 28,028,956,619,710 | 6a6cd61360800d16f1d4b4cf208da3a28c6466a4 | /ssf-client/src/main/java/com/jiaxy/ssf/transport/client/ClientTransportFactory.java | 167b60a4bce16251096eefab90688f51a7dfe689 | [] | no_license | taobaorun/SSF | https://github.com/taobaorun/SSF | 76a2b1e4ef1a047469069ad7d0966027be6c57a0 | ac4f6a9f403801d3c2691b2577ecf37d6fabbbd0 | refs/heads/master | 2021-01-21T04:48:20.019000 | 2016-05-19T02:06:11 | 2016-05-19T02:06:11 | 53,925,968 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jiaxy.ssf.transport.client;
import com.jiaxy.ssf.common.ProtocolType;
import com.jiaxy.ssf.config.ClientTransportConfig;
import com.jiaxy.ssf.util.NetUtil;
import io.netty.channel.Channel;
import java.net.InetSocketAddress;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Title: <br>
* <p>
* Description: <br>
* </p>
*
* @author <a href=mailto:taobaorun@gmail.com>wutao</a>
*
* @since 2016/03/23 13:59
*/
public class ClientTransportFactory {
/**
* one connection is shared by ip and port and protocol
*/
private final static ConcurrentHashMap<ClientTransportKey,ClientTransportContainer> connectionPool = new ConcurrentHashMap<ClientTransportKey, ClientTransportContainer>();
/**
* counter of one connection is using
*/
private final static ConcurrentHashMap<ClientTransport,AtomicInteger> connectionRefCount = new ConcurrentHashMap<ClientTransport,AtomicInteger>();
public static ClientTransport getClientTransport(ClientTransportKey key,Channel channel){
ClientTransportContainer ctc = connectionPool.get(key);
if ( ctc == null ){
ctc = new ClientTransportContainer();
ClientTransportContainer oldCtc = connectionPool.putIfAbsent(key,ctc);
if ( oldCtc != null ){
ctc = oldCtc;
}
}
if ( !ctc.isInitialized() ){
synchronized ( ctc ){
if ( !ctc.isInitialized() ){
ClientTransport clientTransport = createClientTransport(key,channel);
ctc.setClientTransport(clientTransport);
connectionRefCount.putIfAbsent(clientTransport,new AtomicInteger(0));
}
}
}
return ctc.getClientTransport();
}
public static ClientTransport getClientTransport(ClientTransportKey key,ClientTransportConfig clientTransportConfig){
ClientTransportContainer ctc = connectionPool.get(key);
if ( ctc == null ){
ctc = new ClientTransportContainer();
ClientTransportContainer oldCtc = connectionPool.putIfAbsent(key,ctc);
if ( oldCtc != null ){
ctc = oldCtc;
}
}
if ( !ctc.isInitialized() ){
synchronized ( ctc ){
if ( !ctc.isInitialized() ){
ClientTransport clientTransport = createClientTransport(key,clientTransportConfig);
ctc.setClientTransport(clientTransport);
//connect the server
clientTransport.connect();
connectionRefCount.putIfAbsent(clientTransport,new AtomicInteger(0));
}
}
}
return ctc.getClientTransport();
}
public static void releaseClientTransport(ClientTransportKey key,ClientTransport clientTransport,int timeout){
if ( clientTransport == null ){
return;
}
AtomicInteger count = connectionRefCount.get(clientTransport);
if ( count == null ){
connectionPool.remove(key);
clientTransport.disConnect();
return;
}
if ( count.get() <= 0 ){
connectionPool.remove(key);
clientTransport.disConnect();
}
}
public static void releaseClientTransportDirectly(ClientTransportKey key){
ClientTransportContainer cc = connectionPool.remove(key);
if (cc != null && cc.getClientTransport() != null){
connectionPool.remove(cc.getClientTransport());
connectionRefCount.remove(cc.getClientTransport());
}
}
public static ClientTransportKey buildKey(ProtocolType protocolType, String ip, int port){
return new ClientTransportKey(protocolType,ip,port);
}
private static ClientTransport createClientTransport(ClientTransportKey key,ClientTransportConfig clientTransportConfig){
ClientTransport clientTransport = null;
switch ( key.protocolType ){
case SSF:
clientTransport = new SSFClientTransport(key.ip,key.port,clientTransportConfig);
break;
default:
clientTransport = new SSFClientTransport(key.ip,key.port,clientTransportConfig);
break;
}
return clientTransport;
}
private static ClientTransport createClientTransport(ClientTransportKey key,Channel channel){
ClientTransport clientTransport = null;
switch ( key.protocolType ){
case SSF:
clientTransport = new SSFClientTransport(key.ip,key.port,channel);
break;
default:
clientTransport = new SSFClientTransport(key.ip,key.port,channel);
break;
}
return clientTransport;
}
public static class ClientTransportKey {
private ProtocolType protocolType;
private String ip;
private int port;
public ClientTransportKey(ProtocolType protocolType, String ip, int port) {
this.protocolType = protocolType;
this.ip = ip;
this.port = port;
}
public ProtocolType getProtocolType() {
return protocolType;
}
public void setProtocolType(ProtocolType protocolType) {
this.protocolType = protocolType;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ClientTransportKey that = (ClientTransportKey) o;
if (port != that.port) return false;
if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false;
if (protocolType != that.protocolType) return false;
return true;
}
@Override
public int hashCode() {
int result = protocolType != null ? protocolType.hashCode() : 0;
result = 31 * result + (ip != null ? ip.hashCode() : 0);
result = 31 * result + port;
return result;
}
}
static class ClientTransportContainer{
private ClientTransport clientTransport;
public ClientTransportContainer() {
}
public boolean isInitialized(){
if ( clientTransport != null && clientTransport.isConnected() ){
return true;
} else {
return false;
}
}
public ClientTransport getClientTransport() {
return clientTransport;
}
public void setClientTransport(ClientTransport clientTransport) {
this.clientTransport = clientTransport;
}
}
}
| UTF-8 | Java | 7,113 | java | ClientTransportFactory.java | Java | [
{
"context": "iption: <br>\n * </p>\n *\n * @author <a href=mailto:taobaorun@gmail.com>wutao</a>\n *\n * @since 2016/03/23 13:59\n */\npubli",
"end": 439,
"score": 0.9999231696128845,
"start": 420,
"tag": "EMAIL",
"value": "taobaorun@gmail.com"
},
{
"context": "\n *\n * @author <a href=mailto:taobaorun@gmail.com>wutao</a>\n *\n * @since 2016/03/23 13:59\n */\npublic clas",
"end": 445,
"score": 0.9883012771606445,
"start": 440,
"tag": "USERNAME",
"value": "wutao"
}
] | null | [] | package com.jiaxy.ssf.transport.client;
import com.jiaxy.ssf.common.ProtocolType;
import com.jiaxy.ssf.config.ClientTransportConfig;
import com.jiaxy.ssf.util.NetUtil;
import io.netty.channel.Channel;
import java.net.InetSocketAddress;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Title: <br>
* <p>
* Description: <br>
* </p>
*
* @author <a href=mailto:<EMAIL>>wutao</a>
*
* @since 2016/03/23 13:59
*/
public class ClientTransportFactory {
/**
* one connection is shared by ip and port and protocol
*/
private final static ConcurrentHashMap<ClientTransportKey,ClientTransportContainer> connectionPool = new ConcurrentHashMap<ClientTransportKey, ClientTransportContainer>();
/**
* counter of one connection is using
*/
private final static ConcurrentHashMap<ClientTransport,AtomicInteger> connectionRefCount = new ConcurrentHashMap<ClientTransport,AtomicInteger>();
public static ClientTransport getClientTransport(ClientTransportKey key,Channel channel){
ClientTransportContainer ctc = connectionPool.get(key);
if ( ctc == null ){
ctc = new ClientTransportContainer();
ClientTransportContainer oldCtc = connectionPool.putIfAbsent(key,ctc);
if ( oldCtc != null ){
ctc = oldCtc;
}
}
if ( !ctc.isInitialized() ){
synchronized ( ctc ){
if ( !ctc.isInitialized() ){
ClientTransport clientTransport = createClientTransport(key,channel);
ctc.setClientTransport(clientTransport);
connectionRefCount.putIfAbsent(clientTransport,new AtomicInteger(0));
}
}
}
return ctc.getClientTransport();
}
public static ClientTransport getClientTransport(ClientTransportKey key,ClientTransportConfig clientTransportConfig){
ClientTransportContainer ctc = connectionPool.get(key);
if ( ctc == null ){
ctc = new ClientTransportContainer();
ClientTransportContainer oldCtc = connectionPool.putIfAbsent(key,ctc);
if ( oldCtc != null ){
ctc = oldCtc;
}
}
if ( !ctc.isInitialized() ){
synchronized ( ctc ){
if ( !ctc.isInitialized() ){
ClientTransport clientTransport = createClientTransport(key,clientTransportConfig);
ctc.setClientTransport(clientTransport);
//connect the server
clientTransport.connect();
connectionRefCount.putIfAbsent(clientTransport,new AtomicInteger(0));
}
}
}
return ctc.getClientTransport();
}
public static void releaseClientTransport(ClientTransportKey key,ClientTransport clientTransport,int timeout){
if ( clientTransport == null ){
return;
}
AtomicInteger count = connectionRefCount.get(clientTransport);
if ( count == null ){
connectionPool.remove(key);
clientTransport.disConnect();
return;
}
if ( count.get() <= 0 ){
connectionPool.remove(key);
clientTransport.disConnect();
}
}
public static void releaseClientTransportDirectly(ClientTransportKey key){
ClientTransportContainer cc = connectionPool.remove(key);
if (cc != null && cc.getClientTransport() != null){
connectionPool.remove(cc.getClientTransport());
connectionRefCount.remove(cc.getClientTransport());
}
}
public static ClientTransportKey buildKey(ProtocolType protocolType, String ip, int port){
return new ClientTransportKey(protocolType,ip,port);
}
private static ClientTransport createClientTransport(ClientTransportKey key,ClientTransportConfig clientTransportConfig){
ClientTransport clientTransport = null;
switch ( key.protocolType ){
case SSF:
clientTransport = new SSFClientTransport(key.ip,key.port,clientTransportConfig);
break;
default:
clientTransport = new SSFClientTransport(key.ip,key.port,clientTransportConfig);
break;
}
return clientTransport;
}
private static ClientTransport createClientTransport(ClientTransportKey key,Channel channel){
ClientTransport clientTransport = null;
switch ( key.protocolType ){
case SSF:
clientTransport = new SSFClientTransport(key.ip,key.port,channel);
break;
default:
clientTransport = new SSFClientTransport(key.ip,key.port,channel);
break;
}
return clientTransport;
}
public static class ClientTransportKey {
private ProtocolType protocolType;
private String ip;
private int port;
public ClientTransportKey(ProtocolType protocolType, String ip, int port) {
this.protocolType = protocolType;
this.ip = ip;
this.port = port;
}
public ProtocolType getProtocolType() {
return protocolType;
}
public void setProtocolType(ProtocolType protocolType) {
this.protocolType = protocolType;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ClientTransportKey that = (ClientTransportKey) o;
if (port != that.port) return false;
if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false;
if (protocolType != that.protocolType) return false;
return true;
}
@Override
public int hashCode() {
int result = protocolType != null ? protocolType.hashCode() : 0;
result = 31 * result + (ip != null ? ip.hashCode() : 0);
result = 31 * result + port;
return result;
}
}
static class ClientTransportContainer{
private ClientTransport clientTransport;
public ClientTransportContainer() {
}
public boolean isInitialized(){
if ( clientTransport != null && clientTransport.isConnected() ){
return true;
} else {
return false;
}
}
public ClientTransport getClientTransport() {
return clientTransport;
}
public void setClientTransport(ClientTransport clientTransport) {
this.clientTransport = clientTransport;
}
}
}
| 7,101 | 0.601575 | 0.598622 | 223 | 30.89686 | 30.754389 | 175 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.493274 | false | false | 13 |
a96cdb599401240c12af44521aa084a7da4876c7 | 28,449,863,411,977 | 99f318fc0e4e71ae31092f25cfcd37c785861966 | /Home_assignment/Day4Home/src/module-info.java | 43d038d7bdad0e3638498805c5ba7a68ae4e061c | [] | no_license | Priya-9/hsbc-training | https://github.com/Priya-9/hsbc-training | c53ce6b5cfb17233b4dc37a341cfbb1d149c931a | 57a05d3ef6e91dfb1723fd7b643f32f62b26292d | refs/heads/master | 2022-12-19T07:59:15.571000 | 2020-10-01T14:07:05 | 2020-10-01T14:07:05 | 295,713,683 | 0 | 0 | null | true | 2020-09-15T12:00:58 | 2020-09-15T12:00:58 | 2020-09-14T07:24:59 | 2020-09-15T10:50:57 | 0 | 0 | 0 | 0 | null | false | false | module Day4Home {
} | UTF-8 | Java | 19 | java | module-info.java | Java | [] | null | [] | module Day4Home {
} | 19 | 0.736842 | 0.684211 | 2 | 9 | 8 | 17 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 13 |
aa895d2b7f7922ee8ddec9ea8bd211ad32717834 | 14,233,521,649,043 | 0467cc3ec14154df39ec64cd2db4aade7bf04293 | /src/test/java/org/gmjm/stereotype/property/PropertyTest.java | 48b0f6e2929dab5373d73caf99532315c2d74352 | [] | no_license | aglassman/JStereotype | https://github.com/aglassman/JStereotype | ecbc9d713671487546dde1a4f5db0d060eeb04c6 | 188eaf57750962b7c4e8fd52adc9ee34c800211f | refs/heads/master | 2020-12-24T14:44:46.851000 | 2016-01-21T04:20:26 | 2016-01-21T04:20:26 | 34,326,187 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.gmjm.stereotype.property;
import static org.junit.Assert.*;
import org.junit.Test;
public class PropertyTest {
public static class MyObj {
Property<Float> friction;
Object obj;
}
@Test()
public void testPropertyConstructorProperty_valid() throws NoSuchFieldException, SecurityException
{
PropertyDescriptor pd = new PropertyDescriptor("friction", MyObj.class);
assertEquals(Property.class,pd.getPropertyClass());
}
@Test()
public void testPropertyConstructor_valid() throws NoSuchFieldException, SecurityException
{
PropertyDescriptor pd = new PropertyDescriptor("obj", MyObj.class);
assertEquals(Object.class,pd.getPropertyClass());
}
}
| UTF-8 | Java | 716 | java | PropertyTest.java | Java | [] | null | [] | package org.gmjm.stereotype.property;
import static org.junit.Assert.*;
import org.junit.Test;
public class PropertyTest {
public static class MyObj {
Property<Float> friction;
Object obj;
}
@Test()
public void testPropertyConstructorProperty_valid() throws NoSuchFieldException, SecurityException
{
PropertyDescriptor pd = new PropertyDescriptor("friction", MyObj.class);
assertEquals(Property.class,pd.getPropertyClass());
}
@Test()
public void testPropertyConstructor_valid() throws NoSuchFieldException, SecurityException
{
PropertyDescriptor pd = new PropertyDescriptor("obj", MyObj.class);
assertEquals(Object.class,pd.getPropertyClass());
}
}
| 716 | 0.734637 | 0.734637 | 29 | 22.689655 | 28.954308 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.517241 | false | false | 13 |
7975e341af51974af76969204eb11491ceb8d323 | 24,567,212,963,158 | daf4239c73b2de6ba746ffcd1089826012eba58a | /dangjia-group/dangjia-master/dangjia-service-master/src/main/java/com/dangjia/acg/mapper/activity/IActivityParticipantMapper.java | 244946fe4426eaae73463c830a8a38ae9b27632d | [] | no_license | moutainhigh/dangjia | https://github.com/moutainhigh/dangjia | bd54a7c92f8a5e52a94b8e5302452eac1ca860b3 | 3232ff357a44bf9e3ddfcfef66c491ab4048d0b6 | refs/heads/master | 2022-04-09T18:05:45.276000 | 2020-03-15T06:41:35 | 2020-03-15T06:41:35 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dangjia.acg.mapper.activity;
import com.dangjia.acg.modle.activity.ActivityParticipant;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
/**
* Created with IntelliJ IDEA.
* author: qiyuxiang
* Date: 2018/11/13 0031
* Time: 17:01
*/
@Repository
public interface IActivityParticipantMapper extends Mapper<ActivityParticipant> {
}
| UTF-8 | Java | 389 | java | IActivityParticipantMapper.java | Java | [
{
"context": "er;\n\n/**\n * Created with IntelliJ IDEA.\n * author: qiyuxiang\n * Date: 2018/11/13 0031\n * Time: 17:01\n */\n@Repo",
"end": 247,
"score": 0.9991908073425293,
"start": 238,
"tag": "USERNAME",
"value": "qiyuxiang"
}
] | null | [] | package com.dangjia.acg.mapper.activity;
import com.dangjia.acg.modle.activity.ActivityParticipant;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
/**
* Created with IntelliJ IDEA.
* author: qiyuxiang
* Date: 2018/11/13 0031
* Time: 17:01
*/
@Repository
public interface IActivityParticipantMapper extends Mapper<ActivityParticipant> {
}
| 389 | 0.789203 | 0.748072 | 16 | 23.3125 | 23.668858 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 13 |
53fa5adad81977ff9274dac1dba830f83256bd34 | 19,086,834,689,328 | 5ba4fc8d11ce84bab5f6d464b81150596bdf2516 | /src/main/java/com/imyzone/Application.java | 02287916a3ed1a6b702903d26f345f1abc69d42c | [] | no_license | fangchenhui3/springbootProject | https://github.com/fangchenhui3/springbootProject | 0ac4c5d9b4f26eb67c392befbd483ba488dd3aa1 | 5f847208aad0dd046a8e6f6377a27b96391b968f | refs/heads/master | 2021-06-29T02:58:20.848000 | 2017-09-15T03:02:47 | 2017-09-15T03:02:47 | 103,248,812 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.imyzone;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/**
* Titie:
* Description:
* JDK:
* Tomcat:
* Author: fangchenhui
* CreateTime:2017/6/15 22:32
* version: 1.0
**/
/*@SpringBootApplication
@MapperScan("com.imyzone.dao")//映射mapper和dao
public class Application extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}*/
| UTF-8 | Java | 875 | java | Application.java | Java | [
{
"context": "tie:\n * Description:\n * JDK:\n * Tomcat:\n * Author: fangchenhui\n * CreateTime:2017/6/15 22:32\n * version: 1.0\n **",
"end": 404,
"score": 0.9994694590568542,
"start": 393,
"tag": "USERNAME",
"value": "fangchenhui"
}
] | null | [] | package com.imyzone;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/**
* Titie:
* Description:
* JDK:
* Tomcat:
* Author: fangchenhui
* CreateTime:2017/6/15 22:32
* version: 1.0
**/
/*@SpringBootApplication
@MapperScan("com.imyzone.dao")//映射mapper和dao
public class Application extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}*/
| 875 | 0.780207 | 0.765247 | 29 | 28.965517 | 26.927082 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.310345 | false | false | 13 |
5a19cff6bc2532282e67763fe2c577ae8fd7e6c9 | 3,891,240,393,525 | 32c41daf6c0dcf50d6136c7eae9b83588ee59c34 | /src/main/java/com/douzone/jblog/service/PostService.java | 1ced2f88727bf0d74a4d0575c2ce41747f571a44 | [] | no_license | tlaworms77/jblog | https://github.com/tlaworms77/jblog | a6741049eb7465f259a2ac2e41300506ae749223 | dbcf7c2b75221b68dc1e306a7262c07ab5530fa9 | refs/heads/master | 2020-04-27T09:14:40.233000 | 2019-03-20T11:05:55 | 2019-03-20T11:05:55 | 174,206,666 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.douzone.jblog.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.douzone.jblog.repository.PostDao;
import com.douzone.jblog.vo.PostVo;
@Service
public class PostService {
@Autowired
private PostDao postDao;
public void write(PostVo postVo, long category) {
postVo.setCategoryNo(category);
boolean result = 1 == postDao.write(postVo);
if(!result)
return ;
System.out.println("PostService's write result : " + result);
}
public int getAmountByCategoryNo(long categoryNo) {
return postDao.getAmountByCategoryNo(categoryNo);
}
public PostVo getPostByUser(String id) {
// TODO Auto-generated method stub
return null;
}
public List<PostVo> getPostBasicList(String id) {
return postDao.getBasicList(id);
}
public Long getBasicNo(Long categoryNo) {
return postDao.getNo(categoryNo);
}
}
| UTF-8 | Java | 1,015 | java | PostService.java | Java | [] | null | [] | package com.douzone.jblog.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.douzone.jblog.repository.PostDao;
import com.douzone.jblog.vo.PostVo;
@Service
public class PostService {
@Autowired
private PostDao postDao;
public void write(PostVo postVo, long category) {
postVo.setCategoryNo(category);
boolean result = 1 == postDao.write(postVo);
if(!result)
return ;
System.out.println("PostService's write result : " + result);
}
public int getAmountByCategoryNo(long categoryNo) {
return postDao.getAmountByCategoryNo(categoryNo);
}
public PostVo getPostByUser(String id) {
// TODO Auto-generated method stub
return null;
}
public List<PostVo> getPostBasicList(String id) {
return postDao.getBasicList(id);
}
public Long getBasicNo(Long categoryNo) {
return postDao.getNo(categoryNo);
}
}
| 1,015 | 0.724138 | 0.723153 | 45 | 20.555555 | 20.560539 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 13 |
65c70ad0cd25d4074d59ceeac66c55767c52c34f | 38,044,820,330,498 | 7ea0dd7835f424482817522cd0057bb00388c20e | /DemoProjects/CompositeApp/src/java/beans/UserBean.java | 902f0d65a989cf5268c85fedf128e3ed0a392bdc | [] | no_license | tusharbhadak/JavaSampleProjects | https://github.com/tusharbhadak/JavaSampleProjects | e3181c43bfb3fc7d9184958f9bd82950d48178f1 | e3b65150ab4f29c3ddc987c0352689de5fb83c3f | refs/heads/master | 2021-05-26T00:47:34.414000 | 2020-04-08T04:52:29 | 2020-04-08T04:52:29 | 253,986,897 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package beans;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
/**
*
* @author root
*/
@Named(value = "userBean")
@RequestScoped
public class UserBean {
String uname;
String pass;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String login()
{
return "result";
}
/**
* Creates a new instance of UserBean
*/
public UserBean() {
}
}
| UTF-8 | Java | 829 | java | UserBean.java | Java | [
{
"context": "terprise.context.RequestScoped;\n\n/**\n *\n * @author root\n */\n@Named(value = \"userBean\")\n@RequestScoped\npub",
"end": 298,
"score": 0.998866081237793,
"start": 294,
"tag": "USERNAME",
"value": "root"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package beans;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
/**
*
* @author root
*/
@Named(value = "userBean")
@RequestScoped
public class UserBean {
String uname;
String pass;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String login()
{
return "result";
}
/**
* Creates a new instance of UserBean
*/
public UserBean() {
}
}
| 829 | 0.61158 | 0.61158 | 47 | 16.638298 | 17.181665 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.276596 | false | false | 13 |
63082fe7c3ba04e374c373f8884441676dba6b39 | 31,619,549,301,037 | 61f5e1cb7011501d7fb6d34a6cc32235c4127a4e | /src/main/java/com/patrickangle/commons/observable/collections/ObservableMapListener.java | 9c51a6499bf3ea6f2ca96f7c9d40f60335d20012 | [] | no_license | patrickangle/PACommons | https://github.com/patrickangle/PACommons | 45551103bf662aa80a17a6e5b97e211987d7734a | 0b04583f2d587ccf72b87db98940ac30514b4dbd | refs/heads/master | 2022-04-10T00:29:27.619000 | 2020-03-17T22:07:52 | 2020-03-17T22:07:52 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (C) 2006-2007 Sun Microsystems, Inc. All rights reserved. Use is
* subject to license terms.
*/
package com.patrickangle.commons.observable.collections;
import java.beans.PropertyChangeEvent;
import java.util.Map.Entry;
import java.util.Set;
/**
* Notification types from an {@code ObservableMap}.
*
* @author sky
*/
public interface ObservableMapListener<K, V> {
public void entryAdded(ObservableMap<K, V> map, K key, V value);
public void entryRemoved(ObservableMap<K, V> map, K key, V value);
public void entryReplaced(ObservableMap<K, V> map, K key, V oldValue, V newValue);
public void entryPropertyChanged(ObservableMap<K, V> map, K key, V value, PropertyChangeEvent propertyChangeEvent);
//
//
// /**
// * Notification that the value of an existing key has changed.
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// * @param lastValue the previous value
// */
// public void mapKeyValueChanged(ObservableMap map, Object key,
// Object lastValue);
//
// /**
// * Notification that a key has been added.
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// */
// public void mapKeyAdded(ObservableMap map, Object key);
//
// /**
// * Notification that a key has been removed
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// * @param value value for key before key was removed
// */
// public void mapKeyRemoved(ObservableMap map, Object key, Object value);
//
// // PENDING: should we special case clear?
//
// public static final int NON_CONSECUTIVE_INDEXES = Integer.MIN_VALUE;
//
// public void elementsAdded(ObservableList<E> list, int startIndex, int length, List<E> newElements);
// public void elementsRemoved(ObservableList<E> list, int startIndex, int length, List<E> oldElements);
// public void elementReplaced(ObservableList<E> list, int index, E oldElement, E newElement);
// public void elementPropertyChanged(ObservableList<E> list, int index, E element, PropertyChangeEvent proeprtyChangeEvent);
}
| UTF-8 | Java | 2,228 | java | ObservableMapListener.java | Java | [
{
"context": "types from an {@code ObservableMap}.\n *\n * @author sky\n */\npublic interface ObservableMapListener<K, V> ",
"end": 337,
"score": 0.9968689680099487,
"start": 334,
"tag": "USERNAME",
"value": "sky"
}
] | null | [] | /*
* Copyright (C) 2006-2007 Sun Microsystems, Inc. All rights reserved. Use is
* subject to license terms.
*/
package com.patrickangle.commons.observable.collections;
import java.beans.PropertyChangeEvent;
import java.util.Map.Entry;
import java.util.Set;
/**
* Notification types from an {@code ObservableMap}.
*
* @author sky
*/
public interface ObservableMapListener<K, V> {
public void entryAdded(ObservableMap<K, V> map, K key, V value);
public void entryRemoved(ObservableMap<K, V> map, K key, V value);
public void entryReplaced(ObservableMap<K, V> map, K key, V oldValue, V newValue);
public void entryPropertyChanged(ObservableMap<K, V> map, K key, V value, PropertyChangeEvent propertyChangeEvent);
//
//
// /**
// * Notification that the value of an existing key has changed.
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// * @param lastValue the previous value
// */
// public void mapKeyValueChanged(ObservableMap map, Object key,
// Object lastValue);
//
// /**
// * Notification that a key has been added.
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// */
// public void mapKeyAdded(ObservableMap map, Object key);
//
// /**
// * Notification that a key has been removed
// *
// * @param map the {@code ObservableMap} that changed
// * @param key the key
// * @param value value for key before key was removed
// */
// public void mapKeyRemoved(ObservableMap map, Object key, Object value);
//
// // PENDING: should we special case clear?
//
// public static final int NON_CONSECUTIVE_INDEXES = Integer.MIN_VALUE;
//
// public void elementsAdded(ObservableList<E> list, int startIndex, int length, List<E> newElements);
// public void elementsRemoved(ObservableList<E> list, int startIndex, int length, List<E> oldElements);
// public void elementReplaced(ObservableList<E> list, int index, E oldElement, E newElement);
// public void elementPropertyChanged(ObservableList<E> list, int index, E element, PropertyChangeEvent proeprtyChangeEvent);
}
| 2,228 | 0.66921 | 0.665619 | 60 | 36.133335 | 34.431801 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.816667 | false | false | 13 |
cf15cf348c1bd8e82f7e41607e13abfac1441946 | 39,359,080,322,416 | eaec4795e768f4631df4fae050fd95276cd3e01b | /src/cmps252/HW4_2/UnitTesting/record_4453.java | 73ee7cc848e88fcde51e4c7baf86e6f8b67739b9 | [
"MIT"
] | permissive | baraabilal/cmps252_hw4.2 | https://github.com/baraabilal/cmps252_hw4.2 | debf5ae34ce6a7ff8d3bce21b0345874223093bc | c436f6ae764de35562cf103b049abd7fe8826b2b | refs/heads/main | 2023-01-04T13:02:13.126000 | 2020-11-03T16:32:35 | 2020-11-03T16:32:35 | 307,839,669 | 1 | 0 | MIT | true | 2020-10-27T22:07:57 | 2020-10-27T22:07:56 | 2020-10-26T06:59:09 | 2020-10-27T21:51:13 | 3,559 | 0 | 0 | 0 | null | false | false | package cmps252.HW4_2.UnitTesting;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileNotFoundException;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import cmps252.HW4_2.Customer;
import cmps252.HW4_2.FileParser;
@Tag("44")
class Record_4453 {
private static List<Customer> customers;
@BeforeAll
public static void init() throws FileNotFoundException {
customers = FileParser.getCustomers(Configuration.CSV_File);
}
@Test
@DisplayName("Record 4453: FirstName is Darryl")
void FirstNameOfRecord4453() {
assertEquals("Darryl", customers.get(4452).getFirstName());
}
@Test
@DisplayName("Record 4453: LastName is Hoschouer")
void LastNameOfRecord4453() {
assertEquals("Hoschouer", customers.get(4452).getLastName());
}
@Test
@DisplayName("Record 4453: Company is House Of Flowers & Designs")
void CompanyOfRecord4453() {
assertEquals("House Of Flowers & Designs", customers.get(4452).getCompany());
}
@Test
@DisplayName("Record 4453: Address is 495 Schuyler Ave")
void AddressOfRecord4453() {
assertEquals("495 Schuyler Ave", customers.get(4452).getAddress());
}
@Test
@DisplayName("Record 4453: City is Kearny")
void CityOfRecord4453() {
assertEquals("Kearny", customers.get(4452).getCity());
}
@Test
@DisplayName("Record 4453: County is Hudson")
void CountyOfRecord4453() {
assertEquals("Hudson", customers.get(4452).getCounty());
}
@Test
@DisplayName("Record 4453: State is NJ")
void StateOfRecord4453() {
assertEquals("NJ", customers.get(4452).getState());
}
@Test
@DisplayName("Record 4453: ZIP is 7032")
void ZIPOfRecord4453() {
assertEquals("7032", customers.get(4452).getZIP());
}
@Test
@DisplayName("Record 4453: Phone is 201-955-3781")
void PhoneOfRecord4453() {
assertEquals("201-955-3781", customers.get(4452).getPhone());
}
@Test
@DisplayName("Record 4453: Fax is 201-955-5449")
void FaxOfRecord4453() {
assertEquals("201-955-5449", customers.get(4452).getFax());
}
@Test
@DisplayName("Record 4453: Email is darryl@hoschouer.com")
void EmailOfRecord4453() {
assertEquals("darryl@hoschouer.com", customers.get(4452).getEmail());
}
@Test
@DisplayName("Record 4453: Web is http://www.darrylhoschouer.com")
void WebOfRecord4453() {
assertEquals("http://www.darrylhoschouer.com", customers.get(4452).getWeb());
}
}
| UTF-8 | Java | 2,462 | java | record_4453.java | Java | [
{
"context": "}\n\n\t@Test\n\t@DisplayName(\"Record 4453: FirstName is Darryl\")\n\tvoid FirstNameOfRecord4453() {\n\t\tassertEquals(",
"end": 630,
"score": 0.9998404383659363,
"start": 624,
"tag": "NAME",
"value": "Darryl"
},
{
"context": ")\n\tvoid FirstNameOfRecord4453() {\n\t\tassertEquals(\"Darryl\", customers.get(4452).getFirstName());\n\t}\n\n\t@Test",
"end": 687,
"score": 0.9998373985290527,
"start": 681,
"tag": "NAME",
"value": "Darryl"
},
{
"context": "\t}\n\n\t@Test\n\t@DisplayName(\"Record 4453: LastName is Hoschouer\")\n\tvoid LastNameOfRecord4453() {\n\t\tassertEquals(\"",
"end": 787,
"score": 0.9998602867126465,
"start": 778,
"tag": "NAME",
"value": "Hoschouer"
},
{
"context": "\")\n\tvoid LastNameOfRecord4453() {\n\t\tassertEquals(\"Hoschouer\", customers.get(4452).getLastName());\n\t}\n\n\t@Test\n",
"end": 846,
"score": 0.9998533129692078,
"start": 837,
"tag": "NAME",
"value": "Hoschouer"
},
{
"context": ");\n\t}\n\n\t@Test\n\t@DisplayName(\"Record 4453: Email is darryl@hoschouer.com\")\n\tvoid EmailOfRecord4453() {\n\t\tassertEquals(\"dar",
"end": 2169,
"score": 0.9999308586120605,
"start": 2149,
"tag": "EMAIL",
"value": "darryl@hoschouer.com"
},
{
"context": "com\")\n\tvoid EmailOfRecord4453() {\n\t\tassertEquals(\"darryl@hoschouer.com\", customers.get(4452).getEmail());\n\t}\n\n\t@Test\n\t@D",
"end": 2236,
"score": 0.9999300241470337,
"start": 2216,
"tag": "EMAIL",
"value": "darryl@hoschouer.com"
}
] | null | [] | package cmps252.HW4_2.UnitTesting;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileNotFoundException;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import cmps252.HW4_2.Customer;
import cmps252.HW4_2.FileParser;
@Tag("44")
class Record_4453 {
private static List<Customer> customers;
@BeforeAll
public static void init() throws FileNotFoundException {
customers = FileParser.getCustomers(Configuration.CSV_File);
}
@Test
@DisplayName("Record 4453: FirstName is Darryl")
void FirstNameOfRecord4453() {
assertEquals("Darryl", customers.get(4452).getFirstName());
}
@Test
@DisplayName("Record 4453: LastName is Hoschouer")
void LastNameOfRecord4453() {
assertEquals("Hoschouer", customers.get(4452).getLastName());
}
@Test
@DisplayName("Record 4453: Company is House Of Flowers & Designs")
void CompanyOfRecord4453() {
assertEquals("House Of Flowers & Designs", customers.get(4452).getCompany());
}
@Test
@DisplayName("Record 4453: Address is 495 Schuyler Ave")
void AddressOfRecord4453() {
assertEquals("495 Schuyler Ave", customers.get(4452).getAddress());
}
@Test
@DisplayName("Record 4453: City is Kearny")
void CityOfRecord4453() {
assertEquals("Kearny", customers.get(4452).getCity());
}
@Test
@DisplayName("Record 4453: County is Hudson")
void CountyOfRecord4453() {
assertEquals("Hudson", customers.get(4452).getCounty());
}
@Test
@DisplayName("Record 4453: State is NJ")
void StateOfRecord4453() {
assertEquals("NJ", customers.get(4452).getState());
}
@Test
@DisplayName("Record 4453: ZIP is 7032")
void ZIPOfRecord4453() {
assertEquals("7032", customers.get(4452).getZIP());
}
@Test
@DisplayName("Record 4453: Phone is 201-955-3781")
void PhoneOfRecord4453() {
assertEquals("201-955-3781", customers.get(4452).getPhone());
}
@Test
@DisplayName("Record 4453: Fax is 201-955-5449")
void FaxOfRecord4453() {
assertEquals("201-955-5449", customers.get(4452).getFax());
}
@Test
@DisplayName("Record 4453: Email is <EMAIL>")
void EmailOfRecord4453() {
assertEquals("<EMAIL>", customers.get(4452).getEmail());
}
@Test
@DisplayName("Record 4453: Web is http://www.darrylhoschouer.com")
void WebOfRecord4453() {
assertEquals("http://www.darrylhoschouer.com", customers.get(4452).getWeb());
}
}
| 2,436 | 0.731519 | 0.642567 | 95 | 24.915789 | 24.196417 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 13 |
28990021b089484d35dff3e77667fc1304ab475d | 6,219,112,710,969 | 455ba7edfec69776247e4d545dc3a42f4959b966 | /src/RahulShetti.java | a35b4a11fedc6612137142847c2ea831932a188c | [] | no_license | ashishchimurkar/Udemy | https://github.com/ashishchimurkar/Udemy | d831a5c90c75cbf79651b80d283d2fd989608a2a | ad144b38577bab79d9be2e6f9f7517349423a975 | refs/heads/master | 2023-06-17T07:06:00.062000 | 2021-07-15T18:22:24 | 2021-07-15T18:22:24 | 386,388,010 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
public class RahulShetti {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"D:\\ATT Tool\\Selenium Testing\\Udemy\\driver\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://rahulshettyacademy.com/dropdownsPractise/");
// TestCase#1: To Select Country code from Autosuggestive drop down
driver.findElement(By.id("autosuggest")).sendKeys("ind");
Thread.sleep(3000);
List<WebElement> options = driver.findElements(By.cssSelector("li[class='ui-menu-item'] a"));
for (WebElement option : options) {
if (option.getText().equalsIgnoreCase("india"))
{
option.click();
break;
}
}
// TestCase#2: To select drop down button
driver.findElement(By.id("ctl00_mainContent_rbtnl_Trip_0")).click();
// TestCase#3 : To select drop down option {From to To city option}
driver.findElement(By.xpath("//input[@id='ctl00_mainContent_ddl_originStation1_CTXT']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//a[@text='Ahmedabad (AMD)']")).click();
Thread.sleep(2000);
// driver.findElement(By.xpath("(//a[@text='Goa (GOI)'])[2]")).click();
driver.findElement(
By.xpath("//*[@id='glsctl00_mainContent_ddl_destinationStation1_CTNR'] //a[@text='Goa (GOI)']"))
.click();
// Test Case#4 : Current Date selection from calendar
// driver.findElement(By.id("ctl00_mainContent_view_date1")).click();
Thread.sleep(2000);
driver.findElement(By.cssSelector(".ui-state-default.ui-state-highlight")).click();
if (driver.findElement(By.id("Div1")).getAttribute("Style").contains("0.5")) {
System.out.println("Its Disabled");
Assert.assertTrue(true);
} else {
Assert.assertFalse(false);
}
// TestCase#5 : To select No of person and currency
WebElement staticChoices = driver.findElement(By.name("ctl00$mainContent$DropDownListCurrency"));
/*
* WebElement staticCurrency =
* driver.findElement(By.id("ctl00_mainContent_DropDownListCurrency"));
*
* Select dropdown = new Select(staticCurrency);
*
* dropdown.selectByIndex(2); System.out.println(
* dropdown.getFirstSelectedOption().getText());
*/
Select drop1 = new Select(staticChoices);
drop1.selectByValue("USD");
Thread.sleep(2000);
String str1 = drop1.getFirstSelectedOption().getText();
System.out.println(str1);
driver.findElement(By.id("divpaxinfo")).click();
Thread.sleep(2000);
for (int i = 1; i < 5; i++) {
driver.findElement(By.id("hrefIncAdt")).click();
}
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
// To check assertion or validation
Assert.assertEquals(driver.findElement(By.id("divpaxinfo")).getText(), "5 Adult");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='btnclosepaxoption']")).click();
// System.out.println(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
// TestCase#6 :To select checkbox
Assert.assertFalse(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).click();
// System.out.println(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
Assert.assertTrue(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
// System.out.println(driver.findElements(By.cssSelector("input[type='checkbox']")).size());
Assert.assertEquals(driver.findElements(By.cssSelector("input[type='checkbox']")).size(), 6);
Thread.sleep(2000);
// TestCase#7: To select search button
driver.findElement(By.xpath("//input[@id='ctl00_mainContent_btn_FindFlights']")).click();
}
}
| UTF-8 | Java | 4,127 | java | RahulShetti.java | Java | [] | null | [] |
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
public class RahulShetti {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"D:\\ATT Tool\\Selenium Testing\\Udemy\\driver\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://rahulshettyacademy.com/dropdownsPractise/");
// TestCase#1: To Select Country code from Autosuggestive drop down
driver.findElement(By.id("autosuggest")).sendKeys("ind");
Thread.sleep(3000);
List<WebElement> options = driver.findElements(By.cssSelector("li[class='ui-menu-item'] a"));
for (WebElement option : options) {
if (option.getText().equalsIgnoreCase("india"))
{
option.click();
break;
}
}
// TestCase#2: To select drop down button
driver.findElement(By.id("ctl00_mainContent_rbtnl_Trip_0")).click();
// TestCase#3 : To select drop down option {From to To city option}
driver.findElement(By.xpath("//input[@id='ctl00_mainContent_ddl_originStation1_CTXT']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//a[@text='Ahmedabad (AMD)']")).click();
Thread.sleep(2000);
// driver.findElement(By.xpath("(//a[@text='Goa (GOI)'])[2]")).click();
driver.findElement(
By.xpath("//*[@id='glsctl00_mainContent_ddl_destinationStation1_CTNR'] //a[@text='Goa (GOI)']"))
.click();
// Test Case#4 : Current Date selection from calendar
// driver.findElement(By.id("ctl00_mainContent_view_date1")).click();
Thread.sleep(2000);
driver.findElement(By.cssSelector(".ui-state-default.ui-state-highlight")).click();
if (driver.findElement(By.id("Div1")).getAttribute("Style").contains("0.5")) {
System.out.println("Its Disabled");
Assert.assertTrue(true);
} else {
Assert.assertFalse(false);
}
// TestCase#5 : To select No of person and currency
WebElement staticChoices = driver.findElement(By.name("ctl00$mainContent$DropDownListCurrency"));
/*
* WebElement staticCurrency =
* driver.findElement(By.id("ctl00_mainContent_DropDownListCurrency"));
*
* Select dropdown = new Select(staticCurrency);
*
* dropdown.selectByIndex(2); System.out.println(
* dropdown.getFirstSelectedOption().getText());
*/
Select drop1 = new Select(staticChoices);
drop1.selectByValue("USD");
Thread.sleep(2000);
String str1 = drop1.getFirstSelectedOption().getText();
System.out.println(str1);
driver.findElement(By.id("divpaxinfo")).click();
Thread.sleep(2000);
for (int i = 1; i < 5; i++) {
driver.findElement(By.id("hrefIncAdt")).click();
}
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
// To check assertion or validation
Assert.assertEquals(driver.findElement(By.id("divpaxinfo")).getText(), "5 Adult");
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='btnclosepaxoption']")).click();
// System.out.println(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
// TestCase#6 :To select checkbox
Assert.assertFalse(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).click();
// System.out.println(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
Assert.assertTrue(driver.findElement(By.id("ctl00_mainContent_chk_friendsandfamily")).isSelected());
// System.out.println(driver.findElements(By.cssSelector("input[type='checkbox']")).size());
Assert.assertEquals(driver.findElements(By.cssSelector("input[type='checkbox']")).size(), 6);
Thread.sleep(2000);
// TestCase#7: To select search button
driver.findElement(By.xpath("//input[@id='ctl00_mainContent_btn_FindFlights']")).click();
}
}
| 4,127 | 0.690574 | 0.670947 | 119 | 32.663864 | 33.276855 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.882353 | false | false | 13 |
0edd621b9c02cf33b83ccfd7ba53c1890a176c7a | 38,800,734,569,908 | abf1b393c908db4f3dc2f49d5844276f5c4cd754 | /app/src/main/java/com/tamberlab/newz/neaybycities/Cities.java | 07e3247bdbff93c49498ebf899f1fd2896df17df | [] | no_license | ambitamber/Newz | https://github.com/ambitamber/Newz | 94d4c5d3ffca1d640a12a5ffcd83b665b2b2a036 | 56e93e5506ca29ec96ca2d0aaeb16d9c5969dc42 | refs/heads/master | 2023-01-31T13:22:42.526000 | 2020-12-13T22:27:42 | 2020-12-13T22:27:42 | 275,151,423 | 0 | 0 | null | false | 2020-08-28T19:12:48 | 2020-06-26T12:31:35 | 2020-08-28T19:01:24 | 2020-08-28T19:12:27 | 12,090 | 0 | 0 | 1 | Java | false | false | package com.tamberlab.newz.neaybycities;
public class Cities {
private String city_ID;
private String cityName;
private String Image_url;
public String getCity_ID() {
return city_ID;
}
public void setCity_ID(String city_ID) {
this.city_ID = city_ID;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getImage_url() {
return Image_url;
}
public void setImage_url(String image_url) {
Image_url = image_url;
}
}
| UTF-8 | Java | 611 | java | Cities.java | Java | [] | null | [] | package com.tamberlab.newz.neaybycities;
public class Cities {
private String city_ID;
private String cityName;
private String Image_url;
public String getCity_ID() {
return city_ID;
}
public void setCity_ID(String city_ID) {
this.city_ID = city_ID;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getImage_url() {
return Image_url;
}
public void setImage_url(String image_url) {
Image_url = image_url;
}
}
| 611 | 0.610475 | 0.610475 | 32 | 18.09375 | 16.177452 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 13 |
2ae18fab17fe34c43693de7277276ac9cc8f5059 | 38,319,698,229,083 | 0c1c0c17223740338099289718d34ec7837e2933 | /miracle-domain/src/main/java/com/depromeet/domain/record/repository/RecordRepositoryCustomImpl.java | 3032d73d9dc2aa1d048ce85f4133c1df8d159dcc | [] | no_license | depromeet/miracle-backend | https://github.com/depromeet/miracle-backend | 10b4041fe5fb8713cc2dcded94fff96bbd344351 | 31e3dc4eb9e77acd01b1e5cd76f693f217b6dfd3 | refs/heads/develop | 2022-12-19T05:30:39.219000 | 2020-09-19T20:31:24 | 2020-09-19T20:31:24 | 281,444,375 | 4 | 3 | null | false | 2020-09-16T02:56:18 | 2020-07-21T16:07:04 | 2020-09-13T10:33:41 | 2020-09-16T02:56:17 | 385 | 3 | 0 | 1 | Java | false | false | package com.depromeet.domain.record.repository;
import com.depromeet.domain.record.Record;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime;
import java.util.List;
import static com.depromeet.domain.record.QRecord.record;
@RequiredArgsConstructor
public class RecordRepositoryCustomImpl implements RecordRepositoryCustom {
private final JPAQueryFactory queryFactory;
@Override
public Record findByMemberIdAndScheduleIdAndStartTime(Long memberId, Long scheduleId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
return queryFactory.selectFrom(record)
.where(
record.memberId.eq(memberId),
record.scheduleId.eq(scheduleId),
record.dateTimeInterval.startDateTime.eq(startDateTime),
record.dateTimeInterval.endDateTime.eq(endDateTime)
).fetchOne();
}
@Override
public List<Record> findRecordBetween(Long memberId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
return queryFactory.selectFrom(record)
.orderBy(record.dateTimeInterval.startDateTime.asc(), record.dateTimeInterval.endDateTime.asc())
.where(
record.memberId.eq(memberId),
record.dateTimeInterval.startDateTime.before(endDateTime),
record.dateTimeInterval.endDateTime.after(startDateTime)
).fetch();
}
}
| UTF-8 | Java | 1,474 | java | RecordRepositoryCustomImpl.java | Java | [] | null | [] | package com.depromeet.domain.record.repository;
import com.depromeet.domain.record.Record;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime;
import java.util.List;
import static com.depromeet.domain.record.QRecord.record;
@RequiredArgsConstructor
public class RecordRepositoryCustomImpl implements RecordRepositoryCustom {
private final JPAQueryFactory queryFactory;
@Override
public Record findByMemberIdAndScheduleIdAndStartTime(Long memberId, Long scheduleId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
return queryFactory.selectFrom(record)
.where(
record.memberId.eq(memberId),
record.scheduleId.eq(scheduleId),
record.dateTimeInterval.startDateTime.eq(startDateTime),
record.dateTimeInterval.endDateTime.eq(endDateTime)
).fetchOne();
}
@Override
public List<Record> findRecordBetween(Long memberId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
return queryFactory.selectFrom(record)
.orderBy(record.dateTimeInterval.startDateTime.asc(), record.dateTimeInterval.endDateTime.asc())
.where(
record.memberId.eq(memberId),
record.dateTimeInterval.startDateTime.before(endDateTime),
record.dateTimeInterval.endDateTime.after(startDateTime)
).fetch();
}
}
| 1,474 | 0.71981 | 0.71981 | 39 | 36.794872 | 34.807293 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 13 |
ff1c2add68d6203a66970b6f72e4b3a08ee0c8ca | 38,809,324,525,431 | 82aa1472ee18e0a189d0832b52844a8d797503a5 | /the_nature_of_code/Flock/Vehicel.pde | 7a3fd3f2864066e6e52e192e7669e9c9d87149a1 | [] | no_license | ikws4/CreatetiveCoding-Processing | https://github.com/ikws4/CreatetiveCoding-Processing | e167f6d716395c3133608edf91f9ecf0d8da3c5f | 2a8a844d3526613e368f0b343c1fcaa5cf8c5c7e | refs/heads/main | 2023-08-03T13:20:13.585000 | 2021-10-06T10:16:37 | 2021-10-06T10:16:37 | 367,619,560 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // vim:filetype=java
class Vehicel {
PVector pos;
PVector vel;
PVector acc;
float maxSpeed;
float maxForce;
float radius;
Vehicel(PVector pos) {
this.pos = pos;
this.vel = new PVector(random(-1, 1), random(-1, 1));
this.acc = new PVector(0, 0);
this.maxSpeed = 1;
this.maxForce = 0.1;
this.radius = 100;
}
void seek(PVector target) {
PVector desire = PVector.sub(target, pos);
float dist = desire.mag();
if (dist < radius) {
desire.setMag(dist / radius * maxSpeed);
} else {
desire.setMag(maxSpeed);
}
PVector steer = PVector.sub(desire, vel);
steer.limit(maxForce);
applyForce(steer);
}
void applyForce(PVector force) {
acc.add(force);
}
void update() {
vel.add(acc);
pos.add(vel);
acc.mult(0);
}
void draw() {
fill(150);
stroke(100);
pushMatrix();
translate(pos.x, pos.y);
rotate(vel.heading() + HALF_PI);
triangle(0, -10,
5, 10,
-5, 10);
popMatrix();
}
}
| UTF-8 | Java | 1,037 | pde | Vehicel.pde | Java | [] | null | [] | // vim:filetype=java
class Vehicel {
PVector pos;
PVector vel;
PVector acc;
float maxSpeed;
float maxForce;
float radius;
Vehicel(PVector pos) {
this.pos = pos;
this.vel = new PVector(random(-1, 1), random(-1, 1));
this.acc = new PVector(0, 0);
this.maxSpeed = 1;
this.maxForce = 0.1;
this.radius = 100;
}
void seek(PVector target) {
PVector desire = PVector.sub(target, pos);
float dist = desire.mag();
if (dist < radius) {
desire.setMag(dist / radius * maxSpeed);
} else {
desire.setMag(maxSpeed);
}
PVector steer = PVector.sub(desire, vel);
steer.limit(maxForce);
applyForce(steer);
}
void applyForce(PVector force) {
acc.add(force);
}
void update() {
vel.add(acc);
pos.add(vel);
acc.mult(0);
}
void draw() {
fill(150);
stroke(100);
pushMatrix();
translate(pos.x, pos.y);
rotate(vel.heading() + HALF_PI);
triangle(0, -10,
5, 10,
-5, 10);
popMatrix();
}
}
| 1,037 | 0.565092 | 0.538091 | 56 | 17.517857 | 13.148861 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 13 |
774e88e6dd43e6e88e9240eeac8f3dbbc97f1014 | 8,572,754,739,454 | b7e91d1f4e35c7131b84db898105724b6b4d14e4 | /Projetos/Versões Anteriores/Vaucangraph3/src/main/java/vaucangraph/BarraMenu/BarraMenuViewModel.java | 42a8b0380af76ec14a8718276eb5c817875e5e82 | [
"Apache-2.0"
] | permissive | Alex-Vieira/VaucangraphFx | https://github.com/Alex-Vieira/VaucangraphFx | ddc4dd62733b06a46ec85b8bf1f3ebf914e5c2b0 | 4109f24fb25140d98d61bdb00efda528d2d2c5b8 | refs/heads/master | 2020-03-27T14:10:37.426000 | 2019-08-04T00:07:53 | 2019-08-04T00:07:53 | 146,648,103 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package vaucangraph.BarraMenu;
import de.saxsys.mvvmfx.ViewModel;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
public class BarraMenuViewModel implements ViewModel {
public void BarraMenuView(){
}
} | UTF-8 | Java | 391 | java | BarraMenuViewModel.java | Java | [] | null | [] | package vaucangraph.BarraMenu;
import de.saxsys.mvvmfx.ViewModel;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
public class BarraMenuViewModel implements ViewModel {
public void BarraMenuView(){
}
} | 391 | 0.828645 | 0.828645 | 16 | 23.5 | 19.264605 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 4 |
8e04016473bce2b3d1f41bdf8e8eae55dfae5e8f | 16,346,645,574,557 | 5f4c93571ff379334d55e72294dee8fe0d28c156 | /src/test/java/tests/LitecartTests.java | 928a737b05861f300f04a9e5bc4bd958f40fa250 | [] | no_license | harasimenko/gl-litecart-gui-test-framework | https://github.com/harasimenko/gl-litecart-gui-test-framework | e0e88329e071f09e6d51423acc5fca1547b66da5 | 460b6d30fc273c3634e198f29276201b1eac63ae | refs/heads/master | 2020-04-29T08:03:51.657000 | 2019-04-09T18:33:26 | 2019-04-09T18:33:26 | 175,973,544 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tests;
import org.testng.annotations.Test;
import pagefactory.pages.enums.Tab;
import pagefactory.pages.enums.TabBullet;
import steps.*;
import static steps.BaseSteps.openPage;
public class LitecartTests extends BaseTest {
final private String liteCartAdminUrl = "http://localhost/litecart/admin";
final private String ordersUrl = "http://localhost/litecart/en/";
@Test
public void leftMenuNavigationTest() {
LiteCartSteps liteCartSteps = new LiteCartSteps();
LoginSteps loginSteps = new LoginSteps();
String login = "admin";
String password = "admin";
openPage(liteCartAdminUrl);
loginSteps.login(login, password);
liteCartSteps.clickTab(Tab.APPEARENCE);
liteCartSteps.clickTabBullet(TabBullet.TEMPLATE);
liteCartSteps.verifyHeaderDisplayed("Template");
liteCartSteps.clickTabBullet(TabBullet.LOGOTYPE);
liteCartSteps.verifyHeaderDisplayed("Logotype");
liteCartSteps.clickTab(Tab.CATALOG);
liteCartSteps.clickTabBullet(TabBullet.CATALOG);
liteCartSteps.verifyHeaderDisplayed("Catalog");
liteCartSteps.clickTab(Tab.COUNTRIES);
liteCartSteps.verifyHeaderDisplayed("Countries");
}
@Test
public void addAndRemoveFromTheCartTest() {
ShopMainPageSteps shopMainPageSteps = new ShopMainPageSteps();
ProductPageSteps productPageSteps = new ProductPageSteps();
CheckoutPageSteps checkoutPageSteps = new CheckoutPageSteps();
openPage(ordersUrl);
shopMainPageSteps.openFirstProduct();
productPageSteps.addProductToCart();
productPageSteps.clickLitecartLogo();
shopMainPageSteps.openFirstProduct();
productPageSteps.addProductToCart();
productPageSteps.clickLitecartLogo();
shopMainPageSteps.clickCheckoutLink();
checkoutPageSteps.removeFirstItem();
checkoutPageSteps.clickRemoveForFirstItem();
checkoutPageSteps.verifyOrdersTableIsHidden();
}
}
| UTF-8 | Java | 2,029 | java | LitecartTests.java | Java | [
{
"context": "teps = new LoginSteps();\n\n String login = \"admin\";\n String password = \"admin\";\n\n ope",
"end": 577,
"score": 0.9993010759353638,
"start": 572,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "tring login = \"admin\";\n String password = \"admin\";\n\n openPage(liteCartAdminUrl);\n lo",
"end": 612,
"score": 0.9991846680641174,
"start": 607,
"tag": "PASSWORD",
"value": "admin"
}
] | null | [] | package tests;
import org.testng.annotations.Test;
import pagefactory.pages.enums.Tab;
import pagefactory.pages.enums.TabBullet;
import steps.*;
import static steps.BaseSteps.openPage;
public class LitecartTests extends BaseTest {
final private String liteCartAdminUrl = "http://localhost/litecart/admin";
final private String ordersUrl = "http://localhost/litecart/en/";
@Test
public void leftMenuNavigationTest() {
LiteCartSteps liteCartSteps = new LiteCartSteps();
LoginSteps loginSteps = new LoginSteps();
String login = "admin";
String password = "<PASSWORD>";
openPage(liteCartAdminUrl);
loginSteps.login(login, password);
liteCartSteps.clickTab(Tab.APPEARENCE);
liteCartSteps.clickTabBullet(TabBullet.TEMPLATE);
liteCartSteps.verifyHeaderDisplayed("Template");
liteCartSteps.clickTabBullet(TabBullet.LOGOTYPE);
liteCartSteps.verifyHeaderDisplayed("Logotype");
liteCartSteps.clickTab(Tab.CATALOG);
liteCartSteps.clickTabBullet(TabBullet.CATALOG);
liteCartSteps.verifyHeaderDisplayed("Catalog");
liteCartSteps.clickTab(Tab.COUNTRIES);
liteCartSteps.verifyHeaderDisplayed("Countries");
}
@Test
public void addAndRemoveFromTheCartTest() {
ShopMainPageSteps shopMainPageSteps = new ShopMainPageSteps();
ProductPageSteps productPageSteps = new ProductPageSteps();
CheckoutPageSteps checkoutPageSteps = new CheckoutPageSteps();
openPage(ordersUrl);
shopMainPageSteps.openFirstProduct();
productPageSteps.addProductToCart();
productPageSteps.clickLitecartLogo();
shopMainPageSteps.openFirstProduct();
productPageSteps.addProductToCart();
productPageSteps.clickLitecartLogo();
shopMainPageSteps.clickCheckoutLink();
checkoutPageSteps.removeFirstItem();
checkoutPageSteps.clickRemoveForFirstItem();
checkoutPageSteps.verifyOrdersTableIsHidden();
}
}
| 2,034 | 0.718581 | 0.718581 | 61 | 32.262295 | 24.180267 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.639344 | false | false | 4 |
66c5fd646dda45cf957feeffbde26a3ac2efd9a9 | 10,402,410,836,508 | f793f0c7311fa64b36683b5abeb97a40837835d4 | /src/main/java/com/tang2988/gold/console/module/info/dao/MediaDaoImpl.java | 136f283b35d6a029879619fb576421fee638285a | [] | no_license | tang2988/console-pc | https://github.com/tang2988/console-pc | 20e4e589ddb9e7590d643aa6409cc81fd6875846 | fcece03e8fd90588b866f564a3f06ecd0c3e06bd | refs/heads/master | 2021-01-19T15:08:40.260000 | 2018-01-08T16:42:41 | 2018-01-08T16:42:41 | 100,945,561 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tang2988.gold.console.module.info.dao;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.alibaba.druid.pool.DruidDataSource;
import com.tang2988.gold.console.module.sys.entity.Media;
@Repository("mediaDaoImpl")
public class MediaDaoImpl implements MediaDao {
@Autowired
DruidDataSource dataSource;
public List<Media> findAll(){
List<Media> list = new ArrayList<Media>();
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select * from t_media";
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql);
for(Map<String, Object> map:list2){
Media media = new Media();
try {
BeanUtils.populate(media, map);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
list.add(media);
}
return list;
}
public List<Map<String, Object>> findAllall(){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select mediaId,picture,content,title,DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') as time from t_media";
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql);
return list2;
}
public Map<String, Object> findById(Long mediaId){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select * from t_media where mediaId = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql , new Object[]{mediaId});
return list.get(0);
}
public List<Media> queryForPage(int pageNo,int pageSize ) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
List<Media> list = new ArrayList<Media>();
int offset = pageSize*(pageNo-1);
String sql = "select * from t_media LIMIT "+offset +","+pageSize;
System.out.println(sql);
List<Map<String, Object>> map = jdbcTemplate.queryForList(sql);
System.out.println(map);
for(Map<String, Object> map1:map){
Media media = new Media();
try {
BeanUtils.populate(media, map1);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
list.add(media);
}
return list;
}
public Long findCount() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select count(1) from t_media";
Long aa = jdbcTemplate.queryForObject(sql, Long.class);
return aa;
}
public Media add(Media media){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "INSERT INTO t_media (picture,content,title,time) VALUES(?,?,?,?)";
int tiaoshu = jdbcTemplate.update(sql,media.getPicture(),media.getContent(),media.getTitle(),media.getTime());
return media;
}
public Integer Modificationofnews(Media media){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "update t_media SET picture=?,content=?,title=?,time=? WHERE mediaId = ?";
int modifnews = jdbcTemplate.update(sql,media.getPicture(),media.getContent(),media.getTitle(),media.getTime(),media.getMediaId());
return modifnews;
}
}
| UTF-8 | Java | 3,371 | java | MediaDaoImpl.java | Java | [] | null | [] | package com.tang2988.gold.console.module.info.dao;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.alibaba.druid.pool.DruidDataSource;
import com.tang2988.gold.console.module.sys.entity.Media;
@Repository("mediaDaoImpl")
public class MediaDaoImpl implements MediaDao {
@Autowired
DruidDataSource dataSource;
public List<Media> findAll(){
List<Media> list = new ArrayList<Media>();
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select * from t_media";
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql);
for(Map<String, Object> map:list2){
Media media = new Media();
try {
BeanUtils.populate(media, map);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
list.add(media);
}
return list;
}
public List<Map<String, Object>> findAllall(){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select mediaId,picture,content,title,DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') as time from t_media";
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql);
return list2;
}
public Map<String, Object> findById(Long mediaId){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select * from t_media where mediaId = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql , new Object[]{mediaId});
return list.get(0);
}
public List<Media> queryForPage(int pageNo,int pageSize ) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
List<Media> list = new ArrayList<Media>();
int offset = pageSize*(pageNo-1);
String sql = "select * from t_media LIMIT "+offset +","+pageSize;
System.out.println(sql);
List<Map<String, Object>> map = jdbcTemplate.queryForList(sql);
System.out.println(map);
for(Map<String, Object> map1:map){
Media media = new Media();
try {
BeanUtils.populate(media, map1);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
list.add(media);
}
return list;
}
public Long findCount() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "select count(1) from t_media";
Long aa = jdbcTemplate.queryForObject(sql, Long.class);
return aa;
}
public Media add(Media media){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "INSERT INTO t_media (picture,content,title,time) VALUES(?,?,?,?)";
int tiaoshu = jdbcTemplate.update(sql,media.getPicture(),media.getContent(),media.getTitle(),media.getTime());
return media;
}
public Integer Modificationofnews(Media media){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "update t_media SET picture=?,content=?,title=?,time=? WHERE mediaId = ?";
int modifnews = jdbcTemplate.update(sql,media.getPicture(),media.getContent(),media.getTitle(),media.getTime(),media.getMediaId());
return modifnews;
}
}
| 3,371 | 0.715811 | 0.710768 | 111 | 29.36937 | 28.349152 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.432432 | false | false | 4 |
a3944e0edf0ae09d6b50214ee613e7cb36fd756e | 5,987,184,448,089 | 774e886191d9340d730dbbb6f9b76ae99ec3d02f | /becs/src/main/java/com/siemens/becs/toolbox/ForEach.java | da8498fbf1341ba86ebe278eff24d1d2c0369df2 | [] | no_license | rebootersat/integration | https://github.com/rebootersat/integration | c05c33d29cddaae18a7fd86cfd826c7ea29ffe84 | 9ea834779807febc36157d133859796333062f72 | refs/heads/master | 2021-01-15T00:37:30.059000 | 2020-03-03T13:46:23 | 2020-03-03T13:46:23 | 242,815,241 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.siemens.becs.toolbox;
import java.util.List;
import java.util.function.Consumer;
import com.siemens.becs.objects.Log;
import com.siemens.becs.objects.ObjectService;
import com.siemens.becs.objects.Row;
import com.siemens.becs.transformation.Mapping;
import com.siemens.becs.variables.Variable;
import com.siemens.becs.variables.Variables;
public class ForEach {
private List<Mapping> mappings;
private ObjectService objectService;
public ForEach(ObjectService objectService) {
this.objectService = objectService;
}
public ForEach(ObjectService objectService, List<Row> rows, SetValue setVal) {
this.mappings = setVal.getMappings();
this.objectService = objectService;
}
public void read(Consumer<Row> consumer) {
objectService.getData().forEach(row -> {
consumer.accept(row);
});
}
public void read(List<Log> logs) {
objectService.getData().forEach(row->{
row.getColumnValues().forEach(col ->{
logs.forEach(log ->{
String message = log.getMessages();
System.out.println("Before "+ message);
message = message.replaceAll("("+col.getName()+")", col.getValue());
System.out.println("After"+ message);
});
});
});
}
public void iterate(Consumer<List<Variable>> consumer) {
objectService.getData().forEach(row -> {
row.getColumnValues().forEach(col -> {
Mapping mapping = getMapping(col.getName());
Variables.updateValue(mapping.getSrcCol(), col.getValue());
});
consumer.accept(Variables.getVariables());
});
}
private Mapping getMapping(String srcName) {
for (int i = 0; i < mappings.size(); i++) {
if (mappings.get(i).getSrcCol().equals(srcName))
return mappings.get(i);
}
return null;
}
}
| UTF-8 | Java | 1,773 | java | ForEach.java | Java | [] | null | [] | package com.siemens.becs.toolbox;
import java.util.List;
import java.util.function.Consumer;
import com.siemens.becs.objects.Log;
import com.siemens.becs.objects.ObjectService;
import com.siemens.becs.objects.Row;
import com.siemens.becs.transformation.Mapping;
import com.siemens.becs.variables.Variable;
import com.siemens.becs.variables.Variables;
public class ForEach {
private List<Mapping> mappings;
private ObjectService objectService;
public ForEach(ObjectService objectService) {
this.objectService = objectService;
}
public ForEach(ObjectService objectService, List<Row> rows, SetValue setVal) {
this.mappings = setVal.getMappings();
this.objectService = objectService;
}
public void read(Consumer<Row> consumer) {
objectService.getData().forEach(row -> {
consumer.accept(row);
});
}
public void read(List<Log> logs) {
objectService.getData().forEach(row->{
row.getColumnValues().forEach(col ->{
logs.forEach(log ->{
String message = log.getMessages();
System.out.println("Before "+ message);
message = message.replaceAll("("+col.getName()+")", col.getValue());
System.out.println("After"+ message);
});
});
});
}
public void iterate(Consumer<List<Variable>> consumer) {
objectService.getData().forEach(row -> {
row.getColumnValues().forEach(col -> {
Mapping mapping = getMapping(col.getName());
Variables.updateValue(mapping.getSrcCol(), col.getValue());
});
consumer.accept(Variables.getVariables());
});
}
private Mapping getMapping(String srcName) {
for (int i = 0; i < mappings.size(); i++) {
if (mappings.get(i).getSrcCol().equals(srcName))
return mappings.get(i);
}
return null;
}
}
| 1,773 | 0.681895 | 0.681331 | 63 | 26.142857 | 21.289282 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.15873 | false | false | 4 |
feaf71b3554354c63d3dd273cab37d84f11ddd4f | 23,295,902,677,497 | c4efdc876e2983af0cec04f6ac5f78de29310973 | /buffwriter_trywithresources.java | 0e3e3e823db0a42f210ab6be70304b082e48133c | [] | no_license | dennytron/java_notes | https://github.com/dennytron/java_notes | 8f6fbad1d3dc4add7c045fac5114172ef2d0476d | 0da085d375b2ac6bb8ae6f1c97530320cf0e9212 | refs/heads/master | 2021-09-21T21:03:57.991000 | 2018-08-31T12:36:55 | 2018-08-31T12:36:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package x.x;
import java.io.BufferedWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class App {
public static void main(String[] args) throws Exception {
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("c:/users/x/Desktop/some_test.txt"),
Charset.forName("UTF-8"))) {
bw.write("nobody");
bw.newLine();
bw.write("does");
bw.newLine();
bw.write("it");
bw.newLine();
bw.write("better");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 818 | java | buffwriter_trywithresources.java | Java | [] | null | [] | package x.x;
import java.io.BufferedWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class App {
public static void main(String[] args) throws Exception {
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("c:/users/x/Desktop/some_test.txt"),
Charset.forName("UTF-8"))) {
bw.write("nobody");
bw.newLine();
bw.write("does");
bw.newLine();
bw.write("it");
bw.newLine();
bw.write("better");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
| 818 | 0.564792 | 0.56357 | 28 | 28.214285 | 22.358055 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.642857 | false | false | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.