blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
โ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e9b7d296803ed86cb4dc695c520794aad342172 | 6c75d64557f71f20291e4191d4081c0c3e4795e8 | /Proyectos/upcdew-deportivoapp/src/java/com/upc/deportivo/services/ExamenFisicoService.java | f3ce3d9180330fdc6ce02773dbe3473d5f944186 | [] | no_license | andrepin29/faces | afbbc1780f9d4cbaaf50f736c002ce25af27d5cc | fbba871b35da47d898888ed9d1bc4c21eb796a8c | refs/heads/master | 2020-03-27T18:42:37.404212 | 2017-06-15T17:54:47 | 2017-06-15T17:54:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 887 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.upc.deportivo.services;
import com.upc.deportivo.model.ExamenFisicoBean;
import java.util.List;
/**
*
* @author USUARIO
*/
public interface ExamenFisicoService {
public List<ExamenFisicoBean> agregarExamenFisico(ExamenFisicoBean examenFisicos);
public List<ExamenFisicoBean> eliminarExamenFisico(ExamenFisicoBean examenFisicos);
public List<ExamenFisicoBean> modificarExamenFisico(ExamenFisicoBean examenFisicos);
public ExamenFisicoBean obtenerExamenFisico();
public List<ExamenFisicoBean> getExamenFisicosImplement(ExamenFisicoBean examenFisicos);
public void setExamenFisicosImplement(List<ExamenFisicoBean> examenFisicos);
public List<ExamenFisicoBean> BuscarExamenFisico(String nombreJugador);
public void deshabilitarBolean();
}
| [
"[email protected]"
] | |
01d366b19526dda989a02b804f1ce3dfb58d031b | 488efa264942e1e9bd5fe8d26b31d06cb39c9dd7 | /src/java/com/persistencia/controller/UsuarioJpaController.java | e508d896f77808b4a39a62bafac10aeec6c8b27f | [] | no_license | GuillerVks/EmpleadosJPA | 62d32afeb7b84949e27da48156edb13263a6329c | 90b83c3ac0b56ddef632807ebba82189f24ca9ce | refs/heads/master | 2020-04-06T11:25:02.826461 | 2014-04-16T19:14:44 | 2014-04-16T19:14:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,428 | java | /*
* 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.persistencia.controller;
import com.persistencia.Usuario;
import com.persistencia.controller.exceptions.NonexistentEntityException;
import com.persistencia.controller.exceptions.RollbackFailureException;
import java.io.Serializable;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.transaction.UserTransaction;
/**
*
* @author alumno
*/
public class UsuarioJpaController implements Serializable {
public UsuarioJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Usuario usuario) throws RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(usuario);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(Usuario usuario) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
usuario = em.merge(usuario);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = usuario.getIdUsuario();
if (findUsuario(id) == null) {
throw new NonexistentEntityException("The usuario with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Integer id) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Usuario usuario;
try {
usuario = em.getReference(Usuario.class, id);
usuario.getIdUsuario();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The usuario with id " + id + " no longer exists.", enfe);
}
em.remove(usuario);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public List<Usuario> findUsuarioEntities() {
return findUsuarioEntities(true, -1, -1);
}
public List<Usuario> findUsuarioEntities(int maxResults, int firstResult) {
return findUsuarioEntities(false, maxResults, firstResult);
}
private List<Usuario> findUsuarioEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(Usuario.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Usuario findUsuario(Integer id) {
EntityManager em = getEntityManager();
try {
return em.find(Usuario.class, id);
} finally {
em.close();
}
}
public int getUsuarioCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<Usuario> rt = cq.from(Usuario.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
| [
"alumno@A03CLI13"
] | alumno@A03CLI13 |
954d2f6aaa03a3a1c4526430a07a3e5376a1bebf | f5ed1810c70971adbb457bbac52425b1248a607f | /app/src/main/java/kr/co/tjeit/facebookcopy/data/FriendRequestData.java | 8ec8a699d780ad0fa4b97706951fdde5fe4dbb56 | [] | no_license | Iksang/FaceBookCopy | 594c7539ec4c527d6f29e9e75ff522d50d9c5879 | cee54118131971f125a3b246b4f3b894d9e23dd6 | refs/heads/master | 2021-01-02T09:47:03.108769 | 2017-08-09T08:51:18 | 2017-08-09T08:51:18 | 99,302,430 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 959 | java | package kr.co.tjeit.facebookcopy.data;
/**
* Created by tjoeun on 2017-08-08.
*/
public class FriendRequestData {
private String imagePath;
private int commonFreindsCount;
private String name;
public FriendRequestData() {
}
public FriendRequestData(String imagePath, int commonFreindsCount, String name) {
this.imagePath = imagePath;
this.commonFreindsCount = commonFreindsCount;
this.name = name;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
public int getCommonFreindsCount() {
return commonFreindsCount;
}
public void setCommonFreindsCount(int commonFreindsCount) {
this.commonFreindsCount = commonFreindsCount;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| [
"chekfrla486"
] | chekfrla486 |
8dd4129ffe25847b591668157a0875d0728af2ae | c1752f0b3a57ed2fea04c203aacde6ea16cddc6c | /src/main/java/com/test/myapp/config/LoggingConfiguration.java | 3d724e76f636947d5f45d8de056670ac8d5b7660 | [] | no_license | satishtamilan/jhipster-sample-tsb | 09a1db1b7efcf0fe04d3965b9572d3802de75608 | 4f9a409da32d420ee91b9f0af161cc80c15b8491 | refs/heads/main | 2023-03-10T03:28:32.003784 | 2021-02-25T06:48:56 | 2021-02-25T06:48:56 | 331,312,581 | 0 | 0 | null | 2021-02-25T06:48:57 | 2021-01-20T13:18:27 | Java | UTF-8 | Java | false | false | 2,316 | java | package com.test.myapp.config;
import static io.github.jhipster.config.logging.LoggingUtils.*;
import ch.qos.logback.classic.LoggerContext;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.jhipster.config.JHipsterProperties;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.BuildProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
/*
* Configures the console and Logstash log appenders from the app properties
*/
@Configuration
@RefreshScope
public class LoggingConfiguration {
public LoggingConfiguration(
@Value("${spring.application.name}") String appName,
@Value("${server.port}") String serverPort,
JHipsterProperties jHipsterProperties,
ObjectProvider<BuildProperties> buildProperties,
ObjectMapper mapper
)
throws JsonProcessingException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
Map<String, String> map = new HashMap<>();
map.put("app_name", appName);
map.put("app_port", serverPort);
buildProperties.ifAvailable(it -> map.put("version", it.getVersion()));
String customFields = mapper.writeValueAsString(map);
JHipsterProperties.Logging loggingProperties = jHipsterProperties.getLogging();
JHipsterProperties.Logging.Logstash logstashProperties = loggingProperties.getLogstash();
if (loggingProperties.isUseJsonFormat()) {
addJsonConsoleAppender(context, customFields);
}
if (logstashProperties.isEnabled()) {
addLogstashTcpSocketAppender(context, customFields, logstashProperties);
}
if (loggingProperties.isUseJsonFormat() || logstashProperties.isEnabled()) {
addContextListener(context, customFields, loggingProperties);
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
setMetricsMarkerLogbackFilter(context, loggingProperties.isUseJsonFormat());
}
}
}
| [
"[email protected]"
] | |
a83759780bb177a89fc851aaa0c949e0098d1668 | 4c97410bd875e5d0d69becb59337a25c67665f2e | /app/src/androidTest/java/com/caatuern/liellison/myapplication/ExampleInstrumentedTest.java | 487c26b973268145eaa89d99752038364e3ce633 | [] | no_license | caatUERN/ValidacaoCertificados | ac85d0366c5e9e4edc911c28e844c65321d0afc2 | 246f58660fcf4bec7a6e363cd5b15534b74674b7 | refs/heads/master | 2021-01-01T19:48:55.342029 | 2017-07-28T23:50:49 | 2017-07-28T23:50:49 | 98,696,025 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 776 | java | package com.caatuern.liellison.myapplication;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.caatuern.liellison.myapplication", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
0076baeb34219f24c86d86694b2456b8af42a509 | d6fde5b17d715978b41305465a6762e4f7726d1c | /src/main/java/com/sevelli/mvc/data/custom/CustomArgumentResolver.java | c6fa29546a62cc924abb392cc08e150ef2254842 | [] | no_license | jwg666/portal | 50f52c50e5190ca958cf381bc04ebf1efdaca4f0 | 9150f514f584929d92eb344f72d4eae67069f7a3 | refs/heads/master | 2021-01-23T18:21:47.598086 | 2015-04-15T07:28:23 | 2015-04-15T07:28:23 | 33,979,518 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 992 | java | package com.sevelli.mvc.data.custom;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
public class CustomArgumentResolver implements HandlerMethodArgumentResolver {
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterAnnotation(RequestAttribute.class) != null;
}
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
RequestAttribute attr = parameter.getParameterAnnotation(RequestAttribute.class);
return webRequest.getAttribute(attr.value(), WebRequest.SCOPE_REQUEST);
}
}
| [
"[email protected]"
] | |
31ee80ce5980bafedbde3b6247a568481c6f55cf | fe031a59e9b6e87403ccdb8ca01650408386e73c | /sangjun0126/src/main/java/com/jjun0126/sangjunlee0126/HomeController.java | 2671775014d361b5c7dfe5740e4bee7c64777e79 | [] | no_license | jjun0126/sangjunlee0126 | e1d60239c6d08bcc5fc775ca0b9915e9ab0fb75d | 13548c545a9602dc3cae07b877224c858f8ae117 | refs/heads/master | 2022-12-23T11:19:31.268636 | 2020-03-22T13:13:58 | 2020-03-22T13:13:58 | 249,161,318 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,089 | java | package com.jjun0126.sangjunlee0126;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* Handles requests for the application home page.
*/
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
}
| [
"[email protected]"
] | |
5e6290ef0372108b7093b82d96d0fa43e4cc804f | bcbc629a17f401c668da884b57c116fabceae46a | /APP/app/src/test/java/com/carlosvspaixao/bank/ExampleUnitTest.java | 5b591b18ff3ac04bb690c51d5ca4acb77665ebc9 | [] | no_license | paixaoDev/TesteAndroidv2 | 4f06c77d0f691442cc51932b53a7100f17f0b439 | ea505257fbc1664834fd537c0e915e21d0e8acff | refs/heads/master | 2022-11-11T14:10:28.462718 | 2020-06-28T17:25:47 | 2020-06-28T17:25:47 | 272,838,175 | 0 | 0 | null | 2020-06-17T00:08:40 | 2020-06-17T00:08:39 | null | UTF-8 | Java | false | false | 384 | java | package com.carlosvspaixao.bank;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
50b6881d6dfe694fb6b90c7e18a9455435512590 | 5654ab1b2cba5d9b203ed55529b38ac2659e9e89 | /src/ReadProp.java | 19ae2eadab917f05fc18ad9277cfc5c1ae9834fe | [] | no_license | TapanAdhikari/Webdriver_practice | 2d988187e7a3e7bb3aac32bae11217167af40a91 | 77e9ff754c469590debd20a2fcfae5e76c00ce4a | refs/heads/master | 2021-05-16T02:59:09.793067 | 2019-09-21T15:08:11 | 2019-09-21T15:08:11 | 9,538,403 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,198 | java | import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ReadProp {
static WebDriver driver;
public static void main(String[] args) throws IOException {
Properties prop = new Properties();
FileInputStream ip = new FileInputStream(System.getProperty("user.dir") + "\\src\\config.properties");
// System.getProperty("user.dir") gives current project directory = D:\\My
// Software\\SELENIUM_JAVA\\Day 1 in WebDriver 3
// or use D:\\My Software\\SELENIUM_JAVA\\Day 1 in WebDriver
// 3\\src\\config.properties
prop.load(ip);
System.out.println(prop.getProperty("browser"));
System.out.println(prop.getProperty("pass"));
String browserName = prop.getProperty("browser");
if (browserName.equals("chrome")) {
System.setProperty("webdriver.chrome.driver",
"D:\\My Software\\My Jar Files\\Drivers\\browser\\chromedriver.exe");
driver = new ChromeDriver();
} else if (browserName.equals("ff")) {
driver = new FirefoxDriver();
}
driver.manage().window().maximize();
}
}
| [
"[email protected]"
] | |
0c957d7f4aed4684289995118d6637260827c121 | c40b3369d0e0a53ec4cf425aa2e7c5f04c6ed860 | /class08java/Television.java | a46e46791d91b6315c321a15c9ead6bb726a2cff | [] | no_license | huduny/python | 09d95bd2b2e1ff96cbf25574bf5ce063e645515c | fb014ec6dc5a4a63e10bb9fd42cbbe038c0c86b1 | refs/heads/main | 2023-08-16T21:42:46.748535 | 2021-09-25T12:00:28 | 2021-09-25T12:00:28 | 389,066,159 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 658 | java | package CHAPTER8.chapter8_1;
public class Television implements RemoteControl {
private int volume;
@Override
public void turnOn() {
System.out.println("tv๋ฅผ ์ผญ๋๋ค.");
}
@Override
public void turnOff() {
System.out.println("ํฐ๋น๋ฅผ ๋๋๋ค");
}
@Override
public void setVolume(int volume) {
if (volume > RemoteControl.MAC_VOLUME) {
this.volume = RemoteControl.MAC_VOLUME;
}else if ( volume < RemoteControl.MAC_VOLUME ) {
this.volume = RemoteControl.MIN_VOLUME;
}else {
this.volume = volume;
} System.out.println("ํ์ฌ ๋ณผ๋ฅจ์: " + this.volume);
}
}
| [
"[email protected]"
] | |
7fa8b2b02feeb596b89ea81758c36d6670e08c56 | b04230c3551e81de44098dc193e75d948202a68f | /shoppingbackend/src/main/java/com/dm/spring/shoppingbackend/daoimpl/CategoryDAOImpl.java | 9c73632cf175b6c0f93cd06f07e948f9d0debff0 | [] | no_license | dhavalpatel651/online-shopping | a2c7a1d9d724e3b870fbdce5f3243072c899014f | c08b6b01a08eb03446621e16beb5e77030c4b5b3 | refs/heads/master | 2020-04-25T14:44:08.001138 | 2019-03-04T11:39:34 | 2019-03-04T11:39:34 | 172,851,798 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,418 | java | package com.dm.spring.shoppingbackend.daoimpl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.dm.spring.shoppingbackend.dao.CategoryDAO;
import com.dm.spring.shoppingbackend.dto.Category;
@Repository("categoryDAO")
public class CategoryDAOImpl implements CategoryDAO {
private static List<Category> categories = new ArrayList<>();
static
{
Category category = new Category();
category.setId(1);
category.setName("Laptop");
category.setDescription("Overview of Laptops");
category.setImageURL("CAT_1.png");
categories.add(category);
category = new Category();
category.setId(2);
category.setName("Mobile");
category.setDescription("Overview of Mobile");
category.setImageURL("CAT_2.png");
categories.add(category);
category = new Category();
category.setId(3);
category.setName("LED TV");
category.setDescription("Overview of LED TV");
category.setImageURL("CAT_3.png");
categories.add(category);
}
@Override
public List<Category> list() {
// TODO Auto-generated method stub
return categories;
}
@Override
public Category get(int id) {
// TODO Auto-generated method stub
for(Category category : categories)
{
if(category.getId() ==id)
return category;
}
return null;
}
}
| [
"[email protected]"
] | |
abeeaa8a699c64a501f6306f9fb5a6f83a136c44 | 36a452389b77deb9add5b03f5d99d62cdd109791 | /src/java/br/cesjf/lpwsd/dao/ProfessorJpaController.java | 6a54c59d2d645efbabe383f00fb227b84e68bd12 | [] | no_license | cesjf-lph/house-cup-grupo-4-lpwsd | ef52bce8d3f164e51b990a4708b0efee7fdd3dc1 | bd271ee7f7a7c8cf62bab2fbfd763e2231d55115 | refs/heads/master | 2020-05-29T14:36:04.250664 | 2016-10-27T01:37:22 | 2016-10-27T01:37:22 | 65,862,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,443 | java | /*
* 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 br.cesjf.lpwsd.dao;
import br.cesjf.lpwsd.Professor;
import br.cesjf.lpwsd.dao.exceptions.NonexistentEntityException;
import br.cesjf.lpwsd.dao.exceptions.RollbackFailureException;
import java.io.Serializable;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.transaction.UserTransaction;
/**
*
* @author aluno
*/
public class ProfessorJpaController implements Serializable {
public ProfessorJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Professor professor) throws RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(professor);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(Professor professor) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
professor = em.merge(professor);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = professor.getId();
if (findProfessor(id) == null) {
throw new NonexistentEntityException("The professor with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Professor professor;
try {
professor = em.getReference(Professor.class, id);
professor.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The professor with id " + id + " no longer exists.", enfe);
}
em.remove(professor);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public List<Professor> findProfessorEntities() {
return findProfessorEntities(true, -1, -1);
}
public List<Professor> findProfessorEntities(int maxResults, int firstResult) {
return findProfessorEntities(false, maxResults, firstResult);
}
private List<Professor> findProfessorEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(Professor.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Professor findProfessor(Long id) {
EntityManager em = getEntityManager();
try {
return em.find(Professor.class, id);
} finally {
em.close();
}
}
public int getProfessorCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<Professor> rt = cq.from(Professor.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
| [
"[email protected]"
] | |
e77727cab37d2ae0c18534197fae5d2e17615727 | 36f651cbc4491753e2f7f814ad56c63ddefc2af4 | /src/main/java/jit/gwm/stuattd/service/apply/impl/AttdDraftServiceImpl.java | 0187578d509086817f33a45202e78645af8cf99d | [] | no_license | AltairAo/stuattdweb-Maven-Webapp | 9faab7a4ae4854710f429efc5e64581cbe4b0f67 | 26f51e810dec0c0500a641cdaae83e79159c7792 | refs/heads/master | 2021-01-13T00:50:08.967131 | 2016-02-17T14:43:50 | 2016-02-17T14:43:50 | 51,929,304 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,409 | java | package jit.gwm.stuattd.service.apply.impl;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.stuattd.model.sys.Attachment;
import com.stuattd.model.sys.Stuattd;
import core.service.BaseService;
import jit.gwm.stuattd.dao.apply.AqjxxDao;
import jit.gwm.stuattd.dao.apply.AttdDraftDao;
import jit.gwm.stuattd.model.Aqjxx;
import jit.gwm.stuattd.service.apply.AttdDraftService;
import com.stuattd.dao.sys.AttachmentDao;
@Service
public class AttdDraftServiceImpl extends BaseService<Aqjxx> implements
AttdDraftService {
private AqjxxDao aqjxxDao;
private AttdDraftDao attdDraftDao;
@Resource
public void setAqjxxDao(AqjxxDao aqjxxDao) {
this.aqjxxDao = aqjxxDao;
this.dao = aqjxxDao;
}
@Resource
public void setAttdDraftDao(AttdDraftDao AttdDraftDao) {
this.attdDraftDao = AttdDraftDao;
this.dao = AttdDraftDao;
}
@Override
public List<Aqjxx> getTotalFromCgx(Long xsjbxxId) {
return (attdDraftDao).getTotalFromCgx(xsjbxxId);
}
@Override
public List<Aqjxx> getInfoByCondition(Long xsjbxxId, String kssj,
String jssj) {
return (attdDraftDao).getInfoByCondition(xsjbxxId, kssj, jssj);
}
}
| [
"[email protected]"
] | |
b6f2c526e23f983835e1c9a53060f502b26150c3 | ebbb1e3ccf5379b2eed2352975ab0f7674a90e2b | /java/com/hardcastle/honeysuckervendor/Utils/MyNotificationManager.java | d7be60b12d0489136b7800956fcef7f94c7aa188 | [] | no_license | ajayingle1234/toilet-finder | 2cc80c2cefa70f8339d02b0c0ed8774e4edfc096 | 073c64e3a9f04f3c3b07a47290b9e20dcd2198e1 | refs/heads/master | 2020-11-25T09:44:22.973249 | 2019-12-17T11:43:24 | 2019-12-17T11:43:24 | 228,603,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,193 | java | package com.hardcastle.honeysuckervendor.Utils;
/**
* Created by hardcastle on 1/12/17.
*/import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.text.Html;
import com.hardcastle.honeysuckervendor.R;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Created by Shantanu on 26-12-2016.
*/
public class MyNotificationManager {
public static final int ID_BIG_NOTIFICATION = 234;
public static final int ID_SMALL_NOTIFICATION = 235;
private Context mCtx;
Uri soundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
public MyNotificationManager(Context mCtx) {
this.mCtx = mCtx;
}
//the method will show a big notification with an image
//parameters are title for message title, message for message text, url of the big image and an intent that will open
//when you will tap on the notification
public void showBigNotification(String title, String message, String url, Intent intent) {
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mCtx,
ID_BIG_NOTIFICATION,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
bigPictureStyle.setBigContentTitle(title);
bigPictureStyle.setSummaryText(Html.fromHtml(message).toString());
//bigPictureStyle.bigPicture(getBitmapFromURL(url));
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
Notification notification;
notification = mBuilder.setSmallIcon(R.drawable.ic_launcher_round).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentIntent(resultPendingIntent)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setSmallIcon(R.drawable.ic_launcher_round)
.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.drawable.ic_launcher_round))
.setContentText(message)
.setSound(soundUri)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setLights(Color.CYAN, 3000, 2000)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(ID_BIG_NOTIFICATION, notification);
}
//the method will show a small notification
//parameters are title for message title, message for message text and an intent that will open
//when you will tap on the notification
public void showSmallNotification(String title, String message, Intent intent){
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mCtx,
ID_SMALL_NOTIFICATION,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
Notification notification;
notification = mBuilder.setSmallIcon(R.drawable.ic_launcher_round).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentIntent(resultPendingIntent)
.setContentTitle(title)
.setSmallIcon(R.drawable.ic_launcher_round)
.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.drawable.ic_launcher_round))
.setContentText(message)
.setSound(soundUri)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setLights(Color.CYAN, 3000, 3000)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(ID_SMALL_NOTIFICATION, notification);
}
//The method will return Bitmap from an image URL
private Bitmap getBitmapFromURL(String strURL) {
try {
URL url = new URL(strURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
| [
"[email protected]"
] | |
dd3b68dcbeffce1c464afd37bb4b9225f2c80a13 | 447bb4d469c77f97eb5c7a86d961787dac39ad98 | /parttern/src/main/java/com/lkf/parttern/proxy/dynamic/jdk/JDKAccountProxyFactoryTest.java | d59bceb970c07d5ad88dc057f7da91276285df0f | [] | no_license | liukaifeng/lkf-java | ceb90c865f94d39f23d694d7eb45204f4ff49752 | 619f3483ad8bae05a15d40d6cf2307c67f41d16e | refs/heads/master | 2022-12-24T15:53:32.346122 | 2020-03-17T00:49:39 | 2020-03-17T00:49:39 | 124,631,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 500 | java | package com.lkf.parttern.proxy.dynamic.jdk;
import com.lkf.parttern.proxy.dynamic.Account;
import com.lkf.parttern.proxy.dynamic.AccountImpl;
/**
* jdkๅจๆไปฃ็ๆต่ฏ
*/
public class JDKAccountProxyFactoryTest {
public static void main(String[] args) {
Account account = (Account) new JDKAccountProxyFactory().bind(new AccountImpl());
account.queryAccountBalance();
System.out.println("***************************");
account.updateAccountBalance();
}
}
| [
"[email protected]"
] | |
f0a900c6f3f9fe26ebfb02ab450e81c238d140c1 | 1165b675bfc50899e79ea1ed9ef2cf2477dd0275 | /app/src/main/java/br/com/futeboldospais/futeboldospais/rest/ResultadoRest.java | b89673df81000572f77b058e58111725ffd38d93 | [] | no_license | luis-a-neto/FutebolPaisAndroid | a7fcf66c99aeb69eb3620323fd3d9448f478f6db | e224f19e98531e95a9ff96d192a61dc0c8060b7b | refs/heads/master | 2021-01-20T09:29:17.229571 | 2017-11-14T02:33:11 | 2017-11-14T02:33:11 | 101,596,284 | 0 | 0 | null | 2017-09-24T04:27:23 | 2017-08-28T02:30:28 | Java | UTF-8 | Java | false | false | 1,322 | java | package br.com.futeboldospais.futeboldospais.rest;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* Created by Daniel Almeida on 17/10/2017.
* Classe rest
*/
public class ResultadoRest {
/**
* @author Daniel Almeida
* Mรฉtodo utilizado para baixar o conteรบdo em formato json do arquivo .txt no servidor
* @param urlBase Inicio padrรฃo da url do site www.futeboldospais.com.br/campeonatoXXXX/json
* @return String no formato JSONArray
* @throws Exception TimeoutException
*/
public String getResultado(String urlBase) throws Exception {
String rs;
String url = urlBase + "jogos.txt";
OkHttpClient client = new OkHttpClient.Builder().connectTimeout(10000, TimeUnit.MILLISECONDS).readTimeout(5000,
TimeUnit.MILLISECONDS).writeTimeout(5000, TimeUnit.MILLISECONDS).build();
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute();
if(client.connectTimeoutMillis() <= 10000 && client.readTimeoutMillis() <= 5000) {
rs = response.body().string();
}
else{
rs = null;
}
return rs;
}
}
| [
"[email protected]"
] | |
04c1fd395e229718a019fc754a9a5d8d37622ee9 | 93e378d69f9428763ae6e6d1db0dcf3351ea44bc | /spring-demo-annotations/src/com/luv2code/springdemo/DatabaseFortuneService.java | b5449e7c9266ad32d243ed1a6b1cc2416356f9e5 | [] | no_license | JeetThakur/SpringAndSpringBoot | d3f467bfd82e581fcb3f1a211fe9425909e6807e | 7bf76897ba36e6565ca48cd31fa30f1e22242ed6 | refs/heads/master | 2022-11-09T19:37:30.905246 | 2020-06-19T15:39:10 | 2020-06-19T15:39:10 | 273,522,989 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 258 | java | package com.luv2code.springdemo;
import org.springframework.stereotype.Component;
@Component
public class DatabaseFortuneService implements FortuneService {
@Override
public String getFortune() {
// TODO Auto-generated method stub
return null;
}
}
| [
"[email protected]"
] | |
474a83a06023a1ba66a057a76168cd51168ac53f | 02064a921fd2a4e317e16286b0fee1e3955341db | /src/main/java/fr/ird/dropper/ers/syc/service/SingleInstanceLock_InjecteurERS3.java | 7afa8000261d15e10c188ba72e033e46364689b6 | [] | no_license | OB7-IRD/ers-dropper-syc | 3401ecf657b859ec1fbb9101e408fe545cabd309 | 5007976d22551c98000d953215b623f166b1708e | refs/heads/master | 2023-01-25T00:41:29.595757 | 2020-12-01T21:39:56 | 2020-12-01T21:39:56 | 195,354,620 | 0 | 0 | null | 2020-12-01T20:42:02 | 2019-07-05T06:50:00 | Java | UTF-8 | Java | false | false | 1,291 | java | package fr.ird.dropper.ers.syc.service;
import java.io.File;
import java.io.IOException;
/**
* This static class is in charge of file-locking the program so no more than
* one instance can be run at the same time.
*
* @author nirei
*/
public class SingleInstanceLock_InjecteurERS3 {
private static final String LOCK_FILEPATH = System.getProperty("java.io.tmpdir") + File.separator + "injecteur_SEZ_ERS3.lock";
private static final File lock = new File(LOCK_FILEPATH);
private static boolean locked = false;
private SingleInstanceLock_InjecteurERS3() {
}
/**
* Creates the lock file if it's not present and requests its deletion on
* program termination or informs that the program is already running if
* that's the case.
*
* @return true - if the operation was succesful or if the program already
* has the lock.<br>
* false - if the program is already running
* @throws IOException if the lock file cannot be created.
*/
public static boolean lock() throws IOException {
if (locked) {
return true;
}
if (lock.exists()) {
return false;
}
lock.createNewFile();
lock.deleteOnExit();
locked = true;
return true;
}
}
| [
"[email protected]"
] | |
16a48ab14201b6a854b669f7a2628f58c5e670da | eb460695a7c48bef932aca0c22c8774fa8873e88 | /JavaBasic/BasicGrammar/ArrayTest.java | 03920a988e40b231dc3d4754770868b522471c73 | [] | no_license | 1065464173/java-language-basic | 71fd4b00594dab14f84bc5228a33aeca38d87fb2 | ff187e09c5eba8f96e9b779e40aa737c64cb31ce | refs/heads/master | 2023-07-06T21:28:38.155074 | 2021-08-14T14:34:01 | 2021-08-14T14:34:01 | 395,994,933 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,845 | java | import java.util.Arrays;
/*
* @Author: Sxuet
* @Date: 2021-05-15 16:17:58
* @LastEditTime: 2021-05-16 15:16:11
* @LastEditors: Sxuet
* @FilePath: /Javasource_SGG/BasicGrammar/ArrayTest.java
* @Description:
*/
public class ArrayTest {
public static void main(String[] args) {
/* ไธ็ปดๆฐ็ป้ป่ฎคๅๅงๅๅผ */
{
// int[] nums = new int[5];//0
// double[] nums = new double[5];//0.0
// char[] nums = new char[5];//0|'/u0000'
// boolean[] nums = new boolean[5];//false
String[] nums = new String[5];// null ไธๆฏ โnullโ
System.out.println("ไธ็ปดๆฐ็ป็้ๅ๏ผ");
for (String i : nums) {
System.out.print(i + " ");
}
System.out.println();
}
/* ไบ็ปดๆฐ็ป */
{
// ้ๆๅๅงๅ
int[][] nums1 = new int[][] { { 1, 2, 3 }, { 1, 2 }, { 2 } };
// ๅจๆๅๅงๅ
int[][] nums2 = new int[5][];
nums2[1] = new int[1];
// int[][] nums3 = new int[5][2];
// int[] nums4[] = new int[1][1];
// int nums5[][] = new int[1][1];
// ้ๅไบ็ปดๆฐ็ป
System.out.println("ไบ็ปดๆฐ็ป็้ๅ๏ผ");
for (int i = 0; i < nums1.length; i++) {
System.out.println("ๅคๅฑๅ
็ด ๏ผ" + nums1[i]);
for (int j = 0; j < nums1[i].length; j++) {
System.out.print(nums1[i][j] + " ");
}
System.out.println();
}
}
/* ๆจ่พไธ่ง */
{
System.out.println("ๆจ่พไธ่ง๏ผ");
int[][] yh = new int[10][];
for (int i = 0; i < yh.length; i++) {
yh[i] = new int[i + 1];
yh[i][0] = yh[i][i] = 1;
for (int j = 1; j < yh[i].length - 1; j++) {
yh[i][j] = yh[i - 1][j - 1] + yh[i - 1][j];
// if (j==0) {
// yh[i][j]=1;
// } else if(j==yh[i].length-1){
// yh[i][j]=1;
// }else{
// yh[i][j]=yh[i-1][j-1]+yh[i-1][j];
// }
}
}
// ้ๅ
for (int i = 0; i < yh.length; i++) {
for (int j = 0; j < yh[i].length; j++) {
System.out.print(yh[i][j] + "\t");
}
System.out.println();
}
}
/* ๆฐ็ป็ๅคๅถ */
{
System.out.println("ๆฐ็ป็ๅคๅถ๏ผ");
int[] arr1 = new int[] { 2, 3, 5, 7, 11, 17, 19 };
int[] arr2 = new int[arr1.length];
System.out.print("arr1:");
for (int i = 0; i < arr1.length; i++) {
System.out.print(arr1[i] + " ");
}
System.out.print("\narr2:");
for (int i = 0; i < arr1.length; i++) {
if (i % 2 == 0) {
arr2[i] = i;
} else {
arr2[i] = arr1[i];
}
System.out.print(arr2[i] + " ");
}
System.out.println();
// System.out.println("\narr2length:"+arr2.length);
}
/* ๆฐ็ป็ๅ่ฝฌ */
{
System.out.println("ๆฐ็ป็ๅ่ฝฌ๏ผ");
int[] arr = new int[] { 1, 2, 3, 4, 5 };
for (int i = 0; i < arr.length / 2; i++) {
arr[i] = arr[i] ^ arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = arr[i] ^ arr[arr.length - 1 - i];
arr[i] = arr[i] ^ arr[arr.length - 1 - i];
}
for (int i : arr) {
System.out.print(i);
}
System.out.println();
}
/* ๆฅๆพ */
{
// ้กบๅบๆฅๆพ
System.out.println("้กบๅบๆฅๆพ๏ผ");
String[] sarr = new String[] { "AA", "BB", "CC", "DD", "FF" };
String s = "AA";
boolean isflag = true;
for (int i = 0; i < sarr.length; i++) {
if (s == sarr[i]) {
System.out.println("ๆพๅฐไบ๏ผไธบๆฐ็ป็็ฌฌ" + (i + 1) + "ไธชๅ
็ด ");
isflag = false;
break;
}
}
if (isflag) {
System.out.println("ๆฒกๆๆพๅฐใใ");
}
// ไบๅๆณๆฅๆพ๏ผๆๅๆฅๆพ ๅๆๆๅบ
System.out.println("ไบๅๆณๆฅๆพ๏ผ");
int[] arr = new int[] { 1, 2, 3, 4, 5 };
int dest = 26;
int head = 0;
int end = arr.length - 1;
boolean isflag1 = true;
while (head <= end) {
int middle = (head + end) / 2;
if (dest == arr[middle]) {
isflag1 = false;
System.out.println("ๆพๅฐไบ๏ผไธบๆฐ็ป็็ฌฌ" + (middle+1) + "ไธชๅ
็ด ");
break;
} else if (dest < arr[middle]) {
end = middle - 1;
} else {
head = middle + 1;
}
}
if (isflag1) {
System.out.println("ๅพ้ๆพๆฒกๆๆพๅฐ");
}
}
/*ARRAYSๅทฅๅ
ท็ฑป */
{
//equals
int[] arr1 = new int[]{1,2,3};
int[] arr2 = new int[]{1,2,3};
System.out.println(Arrays.equals(arr1,arr2));
Arrays.fill(arr1, 10);
Arrays.sort(arr2);
System.out.println(Arrays.binarySearch(arr2, 3));
System.out.println(Arrays.toString(arr2));
System.out.println(Arrays.toString(arr1));
}
}
}
| [
"[email protected]"
] | |
72d56c99c04db37efeac612ebb13a03b9a897c3d | 3ab68e36e311c78b6b346aa9895c9c4742b326ba | /lib/mallet/src/cc/mallet/pipe/SimpleTokenizer.java | cc2daa47ea185248ee5c1c8533caa7b50acb9218 | [
"Apache-2.0",
"CPL-1.0"
] | permissive | kostagiolasn/NucleosomePatternClassifier | aefd7586ef05aea48a8d0d231937ba787c4afd47 | afa6c9d7ac236f3c72173c199eddd7f59792063f | refs/heads/master | 2020-04-05T18:58:19.783860 | 2018-04-10T23:42:29 | 2018-04-10T23:42:29 | 52,922,770 | 3 | 2 | Apache-2.0 | 2018-04-10T23:42:30 | 2016-03-02T01:14:27 | Java | UTF-8 | Java | false | false | 4,646 | java | package cc.mallet.pipe;
import cc.mallet.types.*;
import java.util.HashSet;
import java.util.ArrayList;
import java.io.*;
/**
* A simple unicode tokenizer that accepts sequences of letters
* as tokens.
*/
public class SimpleTokenizer extends Pipe {
public static final int USE_EMPTY_STOPLIST = 0;
public static final int USE_DEFAULT_ENGLISH_STOPLIST = 1;
protected HashSet<String> stoplist;
public SimpleTokenizer(int languageFlag) {
stoplist = new HashSet<String>();
if (languageFlag == USE_DEFAULT_ENGLISH_STOPLIST) {
// articles
stop("the"); stop("a"); stop("an");
// conjunctions
stop("and"); stop("or");
// prepositions
stop("of"); stop("for"); stop("in");
stop("on"); stop("to"); stop("with");
stop("by");
// definite pronouns
stop("this"); stop("that"); stop("these");
stop("those"); stop("some"); stop("other");
// personal pronouns
stop("it"); stop("its"); stop("we");
stop("our");
// conjuctions
stop("as"); stop("but"); stop("not");
// verbs
stop("do"); stop("does"); stop("is");
stop("be"); stop("are"); stop("can");
stop("was"); stop("were");
}
}
public SimpleTokenizer(File stopfile) {
stoplist = new HashSet<String>();
try {
BufferedReader in =
new BufferedReader(new InputStreamReader(new FileInputStream(stopfile), "UTF-8"));
String word = null;
while ((word = in.readLine()) != null) {
stop(word);
}
in.close();
} catch (Exception e) {
System.err.println("problem loading stoplist: " + e);
}
}
public SimpleTokenizer(HashSet<String> stoplist) {
this.stoplist = stoplist;
}
public SimpleTokenizer deepClone() {
return new SimpleTokenizer((HashSet<String>) stoplist.clone());
}
public void stop(String word) {
stoplist.add(word);
}
public Instance pipe(Instance instance) {
int underscoreCodePoint = Character.codePointAt("_", 0);
if (instance.getData() instanceof CharSequence) {
CharSequence characters = (CharSequence) instance.getData();
ArrayList<String> tokens = new ArrayList<String>();
int[] tokenBuffer = new int[1000];
int length = -1;
// Using code points instead of chars allows us
// to support extended Unicode, and has no significant
// efficiency costs.
int totalCodePoints = Character.codePointCount(characters, 0, characters.length());
for (int i=0; i < totalCodePoints; i++) {
int codePoint = Character.codePointAt(characters, i);
int codePointType = Character.getType(codePoint);
if (codePointType == Character.LOWERCASE_LETTER ||
codePointType == Character.UPPERCASE_LETTER ||
codePoint == underscoreCodePoint) {
length++;
tokenBuffer[length] = codePoint;
}
else if (codePointType == Character.SPACE_SEPARATOR ||
codePointType == Character.LINE_SEPARATOR ||
codePointType == Character.PARAGRAPH_SEPARATOR ||
codePointType == Character.END_PUNCTUATION ||
codePointType == Character.DASH_PUNCTUATION ||
codePointType == Character.CONNECTOR_PUNCTUATION ||
codePointType == Character.START_PUNCTUATION ||
codePointType == Character.INITIAL_QUOTE_PUNCTUATION ||
codePointType == Character.FINAL_QUOTE_PUNCTUATION ||
codePointType == Character.OTHER_PUNCTUATION) {
// Things that delimit words
if (length != -1) {
String token = new String(tokenBuffer, 0, length + 1);
if (! stoplist.contains(token)) {
tokens.add(token);
}
length = -1;
}
}
else if (codePointType == Character.COMBINING_SPACING_MARK ||
codePointType == Character.ENCLOSING_MARK ||
codePointType == Character.NON_SPACING_MARK ||
codePointType == Character.TITLECASE_LETTER ||
codePointType == Character.MODIFIER_LETTER ||
codePointType == Character.OTHER_LETTER) {
// Obscure things that are technically part of words.
// Marks are especially useful for Indic scripts.
length++;
tokenBuffer[length] = codePoint;
}
else {
// Character.DECIMAL_DIGIT_NUMBER
// Character.CONTROL
// Character.MATH_SYMBOL
//System.out.println("type " + codePointType);
}
}
if (length != -1) {
String token = new String(tokenBuffer, 0, length + 1);
if (! stoplist.contains(token)) {
tokens.add(token);
}
}
instance.setData(tokens);
}
else {
throw new IllegalArgumentException("Looking for a CharSequence, found a " +
instance.getData().getClass());
}
return instance;
}
static final long serialVersionUID = 1;
}
| [
"[email protected]"
] | |
05283b7d5e4403660633c7d59e5476e8afd8d2e4 | 3c26b79d2bf8840889f09cc4c150f2fb9ba6f7c9 | /app/src/main/java/com/wolandsoft/sss/util/LogEx.java | 1e8702d78a57cdf1114f55a34caffef1976bdbbf | [
"Apache-2.0"
] | permissive | alexs20/SimpleSecretStorage | 3d1d855c79f99f1ff78d08bb1f184fe1d3dcaeb9 | 9c3a80bdec320bfddabc15903fde2023782d07eb | refs/heads/master | 2020-06-17T02:15:51.242077 | 2017-07-14T12:42:21 | 2017-07-14T12:42:21 | 75,049,636 | 1 | 1 | null | 2017-01-09T20:40:24 | 2016-11-29T06:14:27 | Java | UTF-8 | Java | false | false | 4,824 | java | /*
Copyright 2016, 2017 Alexander Shulgin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.wolandsoft.sss.util;
import android.util.Log;
import com.wolandsoft.sss.BuildConfig;
/**
* Simplified Logger's adapter that allow reduce impact of multiple string concatenations for logging
* and provides some extra information such source source's code line number.
*
* @author Alexander Shulgin
*/
@SuppressWarnings("unused")
public class LogEx {
public static final boolean IS_DEBUG = BuildConfig.DEBUG;
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
public static final boolean SHOW_SOURCE = BuildConfig.SHOW_SRC_IN_LOG;
//MessageFormat
/**
* Print debug information.
*
* @param args Sequence of elements to concatenate and print. The last element could be an exception.
*/
public static void d(Object... args) {
if (IS_DEBUG) {
SrcInfo si = getSrcInfoBuilder();
for (Object arg : args) {
if (arg instanceof Throwable) {
Log.d(si.tag, si.sb.toString(), (Throwable) arg);
return;
}
si.sb.append(arg);
}
Log.d(si.tag, si.sb.toString());
}
}
/**
* Print warning information.
*
* @param args Sequence of elements to concatenate and print. The last element could be an exception.
*/
public static void w(Object... args) {
SrcInfo si = getSrcInfoBuilder();
for (Object arg : args) {
if (arg instanceof Throwable) {
Log.w(si.tag, si.sb.toString(), (Throwable) arg);
return;
}
si.sb.append(arg);
}
Log.w(si.tag, si.sb.toString());
}
/**
* Print error information.
*
* @param args Sequence of elements to concatenate and print. The last element could be an exception.
*/
public static void e(Object... args) {
SrcInfo si = getSrcInfoBuilder();
for (Object arg : args) {
if (arg instanceof Throwable) {
Log.e(si.tag, si.sb.toString(), (Throwable) arg);
return;
}
si.sb.append(arg);
}
Log.e(si.tag, si.sb.toString());
}
/**
* Print info information.
*
* @param args Sequence of elements to concatenate and print. The last element could be an exception.
*/
public static void i(Object... args) {
SrcInfo si = getSrcInfoBuilder();
for (Object arg : args) {
if (arg instanceof Throwable) {
Log.i(si.tag, si.sb.toString(), (Throwable) arg);
return;
}
si.sb.append(arg);
}
Log.i(si.tag, si.sb.toString());
}
/**
* Print verbose information.
*
* @param args Sequence of elements to concatenate and print. The last element could be an exception.
*/
public static void v(Object... args) {
if (IS_DEBUG) {
SrcInfo si = getSrcInfoBuilder();
for (Object arg : args) {
if (arg instanceof Throwable) {
Log.v(si.tag, si.sb.toString(), (Throwable) arg);
return;
}
si.sb.append(arg);
}
Log.v(si.tag, si.sb.toString());
}
}
/*
* Build log header
*/
private static SrcInfo getSrcInfoBuilder() {
SrcInfo ret = new SrcInfo();
ret.sb = new StringBuilder();
Throwable th = new Throwable();
StackTraceElement ste = th.getStackTrace()[2];
String clsName = ste.getClassName();
if (SHOW_SOURCE) {
if (clsName.startsWith(PACKAGE_NAME)) {
ret.sb.append(clsName.substring(PACKAGE_NAME.length() + 1));
} else {
ret.sb.append(clsName);
}
ret.sb.append(".").append(ste.getMethodName()).append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")").append("\n");
}
ret.tag = clsName.substring(clsName.lastIndexOf(".") + 1);
return ret;
}
private static class SrcInfo {
StringBuilder sb;
String tag;
}
}
| [
"[email protected]"
] | |
8ecf6e46f4a3558a51004407a76d7ae1d85a9448 | b7e00de5c603a53f1d3d330bd77bdcacc3db1ab1 | /todolist-android/app/src/main/java/br/edu/unidavi/todolist/Task.java | ae524a512ff5be4e2b526ff3d412b608abfaf06b | [] | no_license | jhonatan2276/exemplosAndroid2 | 9a332b57aeb3c6d72e0bf999e7976fa84368979f | 0197fd68a17f1d94625276ee2c9cb67106744a60 | refs/heads/master | 2020-04-13T17:33:19.060500 | 2018-12-28T02:24:15 | 2018-12-28T02:24:15 | 163,350,809 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package br.edu.unidavi.todolist;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import java.util.Date;
@Entity(tableName = "tasks")
public class Task {
@PrimaryKey(autoGenerate = true)
private final Integer id;
private final String title;
private final boolean done;
private final Date creationDate;
@Ignore
public Task(String title) {
this.id = null;
this.title = title;
this.done = false;
this.creationDate = new Date();
}
public Task(Integer id, String title, boolean done, Date creationDate) {
this.id = id;
this.title = title;
this.done = done;
this.creationDate = creationDate;
}
public Integer getId() {
return id;
}
public String getTitle() {
return title;
}
public boolean isDone() {
return done;
}
public Date getCreationDate() {
return creationDate;
}
}
| [
"[email protected]"
] | |
70495013b91764b770938e1968c2d9dc98875769 | a0b2b206342f100b357a0e1d75ab484b6200d3f0 | /Base/ACB16/src/week1/day1/FirstProgram.java | c2b4ec171f2b1a63e8a4452eab9b157c87268ef9 | [] | no_license | gorobec/ArtCode | e39f0f497c2d2a699c41f9034c1ba7bc3c1aef6c | b4cb68761e563d18129168cb170e14c197e3b409 | refs/heads/master | 2020-04-12T02:25:10.439015 | 2018-03-11T18:19:55 | 2018-03-11T18:19:55 | 59,116,256 | 0 | 5 | null | 2017-05-27T12:28:28 | 2016-05-18T13:05:42 | Java | UTF-8 | Java | false | false | 188 | java | package week1.day1;
/**
* Created by gorobec on 21.05.16.
*/
public class FirstProgram {
public static void main(String[] args){
System.out.println("Hello world!");
}
}
| [
"[email protected]"
] | |
913ef94ca65405deb18f640b8ffe8a2055e773ee | ca2d11048c2c67269bad7cbc7de795827700e3e1 | /src/main/java/com/hotel/demo/Room/controller/RoomController.java | b2973900ac9442ca0e3554615562c8bb1128c0df | [] | no_license | anfalHasan96/Final_Project | 84e6b62d9c47f8813fbb792cd82844701a872983 | 2037bdc3ab7b25b418597ead6989dcc928bf5adb | refs/heads/master | 2022-07-02T07:18:10.989759 | 2019-08-24T17:46:45 | 2019-08-24T17:46:45 | 200,128,392 | 0 | 0 | null | 2022-06-21T01:44:01 | 2019-08-01T22:50:08 | Java | UTF-8 | Java | false | false | 1,288 | java | package com.hotel.demo.Room.controller;
import com.hotel.demo.Room.RoomDao;
import com.hotel.demo.Room.RoomInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@Controller
@RequestMapping("/room")
public class RoomController {
@Autowired
RoomDao roomDao;
@RequestMapping("/viewRoom")
public String viewReservation(Model model)
{
ArrayList<RoomInfo> roomInfoList= roomDao.getAllRoom();
Map<String,String> roomList=new LinkedHashMap<>();
for(RoomInfo room : roomInfoList){
roomList.put(room.getId(),room.getId()+" "+room.getPrice()+" $");
}
model.addAttribute("roomList",roomList);
model.addAttribute("roomInfo",new RoomInfo());
return "room";
}
@GetMapping(value = "/details/{room_id}",produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
public RoomInfo viewReservationDetails(@PathVariable String room_id){
return roomDao.getRoom(room_id);
}
}
| [
"[email protected]"
] | |
d02dd3e3e753cfeddbf0646c90b67dbac50457d8 | f3bfc15013a872d103b9f80dca9aa576fb02c653 | /app/src/main/java/com/skubit/comics/activities/SeriesActivity.java | 41557ee52ba1685395176916d2265e3d326848a4 | [
"Apache-2.0"
] | permissive | skubit/skubit-comics | 1ec0f9e94dfa19b4aab0da17f77e0948e32fafeb | 7b798b741a3f17df303704911f563070f666eec2 | refs/heads/master | 2016-09-07T19:01:48.669148 | 2015-09-21T01:43:54 | 2015-09-21T01:43:54 | 31,020,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,770 | java | package com.skubit.comics.activities;
import com.skubit.comics.BuildConfig;
import com.skubit.comics.R;
import com.skubit.comics.SeriesFilter;
import com.skubit.comics.UiState;
import com.skubit.comics.fragments.SeriesFragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Toast;
public class SeriesActivity extends ActionBarActivity {
private Toolbar toolbar;
private SeriesFilter mSeriesFilter;
public static Intent newInstance(SeriesFilter filter) {
Intent i = new Intent();
i.putExtra("com.skubit.comics.SERIES_FILTER", filter);
i.setClassName(BuildConfig.APPLICATION_ID, SeriesActivity.class.getName());
return i;
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.none, R.anim.push_out_right);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_series);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);
if (getIntent().getExtras() != null) {
mSeriesFilter = getIntent().getParcelableExtra("com.skubit.comics.SERIES_FILTER");
if (mSeriesFilter.hasCreator()) {
setTitle(mSeriesFilter.creator);
} else if (mSeriesFilter.hasGenre()) {
setTitle(mSeriesFilter.genre);
} else if (mSeriesFilter.hasPublisher()) {
setTitle(mSeriesFilter.publisher);
} else if (mSeriesFilter.hasSeries()) {
setTitle(mSeriesFilter.series);
} else {
setTitle("Unknown");
}
getFragmentManager().beginTransaction()
.replace(R.id.container, SeriesFragment.newInstance(mSeriesFilter),
UiState.SERIES)
.commit();
} else {
Toast.makeText(this, "SeriesActivity Intent is null", Toast.LENGTH_SHORT).show();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
overridePendingTransition(R.anim.none, R.anim.push_out_right);
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
] | |
6cb88d9dca9aa7427b4c93f5693b11dd00239f8a | 57edb737df8e9de3822d4f08d0de81f028403209 | /spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/JsonViewRequestBodyAdvice.java | 4e2495e26a2b2fd7aebed315376d63d2fd5c78d1 | [
"Apache-2.0"
] | permissive | haoxianrui/spring-framework | 20d904fffe7ddddcd7d78445537f66e0b4cf65f5 | e5163351c47feb69483e79fa782eec3e4d8613e8 | refs/heads/master | 2023-05-25T14:27:18.935575 | 2020-10-23T01:04:05 | 2020-10-23T01:04:05 | 260,652,424 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,082 | java | /*
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://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.springframework.web.servlet.mvc.method.annotation;
import java.io.IOException;
import java.lang.reflect.Type;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.http.converter.json.MappingJacksonInputMessage;
import org.springframework.util.Assert;
/**
* A {@link RequestBodyAdvice} implementation that adds support for Jackson's
* {@code @JsonView} annotation declared on a Spring MVC {@code @HttpEntity}
* or {@code @RequestBody} method parameter.
*
* <p>The deserialization view specified in the annotation will be passed in to the
* {@link org.springframework.http.converter.json.MappingJackson2HttpMessageConverter}
* which will then use it to deserialize the request body with.
*
* <p>Note that despite {@code @JsonView} allowing for more than one class to
* be specified, the use for a request body advice is only supported with
* exactly one class argument. Consider the use of a composite interface.
*
* @author Sebastien Deleuze
* @see com.fasterxml.jackson.annotation.JsonView
* @see com.fasterxml.jackson.databind.ObjectMapper#readerWithView(Class)
* @since 4.2
*/
public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter {
@Override
public boolean supports(MethodParameter methodParameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType) {
return (AbstractJackson2HttpMessageConverter.class.isAssignableFrom(converterType) &&
methodParameter.getParameterAnnotation(JsonView.class) != null);
}
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter,
Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException {
JsonView ann = methodParameter.getParameterAnnotation(JsonView.class);
Assert.state(ann != null, "No JsonView annotation");
Class<?>[] classes = ann.value();
if (classes.length != 1) {
throw new IllegalArgumentException(
"@JsonView only supported for request body advice with exactly 1 class argument: " + methodParameter);
}
return new MappingJacksonInputMessage(inputMessage.getBody(), inputMessage.getHeaders(), classes[0]);
}
}
| [
"[email protected]"
] | |
688ff247fc31b7e3e000b596b860e042188e2b20 | 9b8c40265be9fb6a82faffce327bee10b17423e1 | /Amazon/src/test/java/home/TestHome.java | 7b074d5102876c5b00a05bf57445d5124be104ca | [] | no_license | massisako/massiFramwork | 197f45cd1ab40ef63098c311b602b03a00f08cb9 | 9fd0d3b1e618c32e855a304723f5e87b28b50407 | refs/heads/master | 2023-05-11T06:55:14.444735 | 2019-09-22T13:36:02 | 2019-09-22T13:36:02 | 210,073,925 | 0 | 0 | null | 2023-05-09T18:16:56 | 2019-09-22T01:22:12 | Java | UTF-8 | Java | false | false | 454 | java | package home;
import common.CommonAPI;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class TestHome extends CommonAPI {
@Test
public void test1() {
//System.out.println(driver.getTitle());
driver.findElement(By.id("twotabsearchtextbox")).sendKeys("java books", Keys.ENTER);
driver.get("https://www.amazon.com/s?k=mac+book+pro&ref=nb_sb_noss_2");
}
}
| [
"[email protected]"
] | |
436ad29e2e453cb4cf46ea1d135e21a945de0e56 | a5139c1b14c73c00cdadb6d6706062e1a6731c83 | /art-train-web/src/main/java/com/suning/arttrain/web/casSecurity/ArtTrainUserDetailsService.java | 9ac191e62e058a901792a82cb38971ee7538f0fd | [] | no_license | zhangliangbo233/art-train | f7ea99244ef78cd8ad8c050e510f3eb721d2ef57 | 5d4d4fbb5803f83ab1f6cbef0f60bde7c76f6626 | refs/heads/master | 2021-04-09T16:09:14.604668 | 2016-07-03T10:40:53 | 2016-07-03T10:40:53 | 61,986,696 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,461 | java | package com.suning.arttrain.web.casSecurity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import com.suning.arttrain.common.util.JsonRpcClientUtil;
import com.suning.arttrain.common.util.ServiceTypeEnum;
import com.suning.arttrain.dto.UserDto;
import com.suning.arttrain.dto.UserRoleDto;
import com.suning.arttrain.param.UserDetailParam;
import com.suning.arttrain.service.UserService;
@SuppressWarnings("all")
public class ArtTrainUserDetailsService implements UserDetailsService,
Serializable {
/**
*
*/
private static final long serialVersionUID = -6434670800259687392L;
private final static Logger logger = LoggerFactory
.getLogger(ArtTrainUserDetailsService.class);
@Autowired
private JsonRpcClientUtil jsonRpcClientUtil;
public ArtTrainUserDetailsService() {
}
@Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
UserDto user = null;
List<UserRoleDto> roles;
List<GrantedAuthority> authorities = null;
try {
UserDetailParam param = new UserDetailParam();
param.setUserName(username);
user = (UserDto) jsonRpcClientUtil.doService(UserService.class,
"loginByUsername", param);
if (null == user) {
throw new Exception("็จๆทไธๅญๅจ");
}
if (user.getEnabled() != 1) {
throw new DisabledException("ๆจ็่ดฆๅทๅทฒ็ป่ขซๅป็ป");
}
roles = (List<UserRoleDto>) jsonRpcClientUtil.doService(
UserService.class, "listRolesByUsername", param);
authorities = new ArrayList<GrantedAuthority>();
for (UserRoleDto ur : roles) {
//authorities.add(new GrantedAuthorityImpl(ur.getRoleName()));
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
return new ArtTrainUserDetail(user.getUserId(), user.getUserName(),
user.getEnabled() == 1, authorities);
}
}
| [
"[email protected]"
] | |
9823e295d3e498da428b4e8810fea63fc0a6f276 | ac49244469fb2c8a4db498a3bf3d0077f5724da4 | /yass-ijk/src/main/java/com/ijk/application/Settings.java | 0cdd641e5bdc35398cf367f1a8fcde7b06d4659e | [] | no_license | wxyass/YassIjkPlayer | 151735f2669bf18864cf873bb706d9454432ab4c | 0707c403cda627f8c95f39265872635916f0dcce | refs/heads/master | 2020-03-28T10:40:39.230557 | 2018-09-10T09:43:53 | 2018-09-10T09:43:53 | 148,133,280 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,202 | java | /*
* Copyright (C) 2015 Bilibili
* Copyright (C) 2015 Zhang Rui <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ijk.application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.ijk.R;
public class Settings {
private Context mAppContext;
private SharedPreferences mSharedPreferences;
public static final int PV_PLAYER__Auto = 0;
public static final int PV_PLAYER__AndroidMediaPlayer = 1;
public static final int PV_PLAYER__IjkMediaPlayer = 2;
public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
public Settings(Context context) {
mAppContext = context.getApplicationContext();
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
}
public boolean getEnableBackgroundPlay() {
String key = mAppContext.getString(R.string.pref_key_enable_background_play);
return mSharedPreferences.getBoolean(key, false);
}
public int getPlayer() {
String key = mAppContext.getString(R.string.pref_key_player);
String value = mSharedPreferences.getString(key, "");
try {
return Integer.valueOf(value).intValue();
} catch (NumberFormatException e) {
return 0;
}
}
public boolean getUsingMediaCodec() {
String key = mAppContext.getString(R.string.pref_key_using_media_codec);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getUsingMediaCodecAutoRotate() {
String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getMediaCodecHandleResolutionChange() {
String key = mAppContext.getString(R.string.pref_key_media_codec_handle_resolution_change);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getUsingOpenSLES() {
String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
return mSharedPreferences.getBoolean(key, false);
}
public String getPixelFormat() {
String key = mAppContext.getString(R.string.pref_key_pixel_format);
return mSharedPreferences.getString(key, "");
}
public boolean getEnableNoView() {
String key = mAppContext.getString(R.string.pref_key_enable_no_view);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getEnableSurfaceView() {
String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getEnableTextureView() {
String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getEnableDetachedSurfaceTextureView() {
String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
return mSharedPreferences.getBoolean(key, false);
}
public boolean getUsingMediaDataSource() {
String key = mAppContext.getString(R.string.pref_key_using_mediadatasource);
return mSharedPreferences.getBoolean(key, false);
}
public String getLastDirectory() {
String key = mAppContext.getString(R.string.pref_key_last_directory);
return mSharedPreferences.getString(key, "/");
}
public void setLastDirectory(String path) {
String key = mAppContext.getString(R.string.pref_key_last_directory);
mSharedPreferences.edit().putString(key, path).apply();
}
}
| [
"[email protected]"
] | |
5dd032a38ded551063b6ff6aaa74720948220224 | 38c72654bcfe4e7c3b1a42fa852cfa73766dbdd9 | /src/Program5.java | 39b09abb40047f61579c25402749e1fb5b854178 | [] | no_license | vasupokalap/NaveenJavaAsignments | 6f6ab537ee08e5a4c2004acf3b04f9c38481d627 | e92c7ae4956f08d12ecb5a2a4d395081560bb4b2 | refs/heads/master | 2023-03-27T09:32:28.768546 | 2021-03-26T13:34:32 | 2021-03-26T13:34:32 | 351,533,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 190 | java |
public class Program5 {
public static void main(String args[]) {
int i =10;
while(i>0) {
if(i%7 ==0) {
break;
}else {
System.out.println(i);
i--;
}
}
}
}
| [
"[email protected]"
] | |
5df632cd3a7b05669298615b5518711c5f5098ca | f43d5de70d14179639192e091c923ccd27112faa | /src/com/codeHeap/generics/reflectionFactory/factoryConstraint/StringFactory.java | bd1a3c88422b4c92fb5c173d26462aa0ac605eaf | [] | no_license | basumatarau/trainingJavaCore | 2c80d02d539fc6e2e599f6e9240e8f6543ef1bdf | 1efc944b77b1ac7aea44bee89b84daa843670630 | refs/heads/master | 2020-04-04T23:13:47.929352 | 2019-01-09T09:51:35 | 2019-01-09T09:51:35 | 156,351,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 365 | java | package com.codeHeap.generics.reflectionFactory.factoryConstraint;
public class StringFactory implements IFacotory<String>{
@Override
public String create(Object... args) {
StringBuilder result = new StringBuilder();
for (Object arg : args) {
result.append(arg).append(", ");
}
return result.toString();
}
}
| [
"[email protected]"
] | |
a1b3695633446668b712197de72b8dcbb9d05006 | 0c1b924ff160b769b53facdb084aa0f19e23cd69 | /rt-gateway-impl-ctp/src/main/java/xyz/redtorch/gateway/ctp/x64v6v3v11v/api/CThostFtdcSyncDepositField.java | 657e145d7e401fa8693ecaeafeebb293a558f6f0 | [
"MIT"
] | permissive | whitespur/redtorch | c602eac6b945e26b7d2657b43059dd8480b9453a | 50798769e8f57120a6ab6e7cd462ba21555f425b | refs/heads/master | 2020-08-14T14:12:54.502219 | 2019-11-19T10:12:32 | 2019-11-19T10:12:32 | 215,182,016 | 0 | 0 | MIT | 2019-10-15T01:51:55 | 2019-10-15T01:51:54 | null | UTF-8 | Java | false | false | 2,810 | java | /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.0
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
package xyz.redtorch.gateway.ctp.x64v6v3v11v.api;
public class CThostFtdcSyncDepositField {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;
protected CThostFtdcSyncDepositField(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
protected static long getCPtr(CThostFtdcSyncDepositField obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
@SuppressWarnings("deprecation")
protected void finalize() {
delete();
}
public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
jctpv6v3v11x64apiJNI.delete_CThostFtdcSyncDepositField(swigCPtr);
}
swigCPtr = 0;
}
}
public void setDepositSeqNo(String value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_DepositSeqNo_set(swigCPtr, this, value);
}
public String getDepositSeqNo() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_DepositSeqNo_get(swigCPtr, this);
}
public void setBrokerID(String value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_BrokerID_set(swigCPtr, this, value);
}
public String getBrokerID() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_BrokerID_get(swigCPtr, this);
}
public void setInvestorID(String value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_InvestorID_set(swigCPtr, this, value);
}
public String getInvestorID() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_InvestorID_get(swigCPtr, this);
}
public void setDeposit(double value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_Deposit_set(swigCPtr, this, value);
}
public double getDeposit() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_Deposit_get(swigCPtr, this);
}
public void setIsForce(int value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_IsForce_set(swigCPtr, this, value);
}
public int getIsForce() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_IsForce_get(swigCPtr, this);
}
public void setCurrencyID(String value) {
jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_CurrencyID_set(swigCPtr, this, value);
}
public String getCurrencyID() {
return jctpv6v3v11x64apiJNI.CThostFtdcSyncDepositField_CurrencyID_get(swigCPtr, this);
}
public CThostFtdcSyncDepositField() {
this(jctpv6v3v11x64apiJNI.new_CThostFtdcSyncDepositField(), true);
}
}
| [
"[email protected]"
] | |
88b061ab744218e8b0fa2ac1eb997853e5d010d6 | 7abbbef9590f9c4b9469adcbae5ea8907478bf03 | /chromium_git/chromium/src/out/Debug/java_mojo/net_interfaces/src/org/chromium/mojom/net/interfaces/HostResolverRequestClient.java | 835d0ed89d1ee4ac87e2921503ac9b21730e2356 | [
"BSD-3-Clause"
] | permissive | GiorgiGagnidze/CEF | 845bdc2f54833254b3454ba8f6c61449431c7884 | fbfc30b5d60f1ea7157da449e34dd9ba9c50f360 | refs/heads/master | 2021-01-10T17:32:27.640882 | 2016-03-23T07:43:04 | 2016-03-23T07:43:04 | 54,463,340 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 822 | java |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by:
// mojo/public/tools/bindings/mojom_bindings_generator.py
// For:
// net/interfaces/host_resolver_service.mojom
//
package org.chromium.mojom.net.interfaces;
import org.chromium.base.annotations.SuppressFBWarnings;
public interface HostResolverRequestClient extends org.chromium.mojo.bindings.Interface {
public interface Proxy extends HostResolverRequestClient, org.chromium.mojo.bindings.Interface.Proxy {
}
Manager<HostResolverRequestClient, HostResolverRequestClient.Proxy> MANAGER = HostResolverRequestClient_Internal.MANAGER;
void reportResult(
int error, AddressList result);
}
| [
"[email protected]"
] | |
1b5267f629e42db51e4c11f6662fc0f6a5e8f0a0 | 088acc114720d0bcfc96bd0f12f56bf6c26a8a04 | /src/org/apache/el/parser/AstDiv.java | 780dc971beb7e2584859a935433449a508336c27 | [] | no_license | yuexiaoguang/tomcat8.5 | acbc70727b57c814bae88f8505d5992a19500dec | d0cc064df71f7760851ff9b4c9accae26323e52a | refs/heads/master | 2020-05-27T19:40:47.172022 | 2019-05-27T03:20:51 | 2019-05-27T03:20:51 | 188,763,583 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package org.apache.el.parser;
import javax.el.ELException;
import org.apache.el.lang.ELArithmetic;
import org.apache.el.lang.EvaluationContext;
public final class AstDiv extends ArithmeticNode {
public AstDiv(int id) {
super(id);
}
@Override
public Object getValue(EvaluationContext ctx)
throws ELException {
Object obj0 = this.children[0].getValue(ctx);
Object obj1 = this.children[1].getValue(ctx);
return ELArithmetic.divide(obj0, obj1);
}
}
| [
"[email protected]"
] | |
e4b7c3e880dde17473e6f042b77a67351ae7c784 | 39d4841fd6f47f3719e689ce8e2b2fe4fd593d87 | /src/test/java/com/townz/repository/timezone/DateTimeWrapper.java | c2381cfbe87f1dc44e2376e9e330866b5e4e70bb | [] | no_license | MayankDembla/AlgoDataStructure | 985dc7199b08114e65f23550d10f7431aa430d81 | 51453bfd534a5e3467ad975b92f9b07a6e2c05d1 | refs/heads/master | 2023-03-30T19:50:29.768476 | 2021-04-09T23:29:39 | 2021-04-09T23:29:39 | 291,277,278 | 0 | 0 | null | 2021-04-09T23:29:39 | 2020-08-29T13:33:19 | Java | UTF-8 | Java | false | false | 3,090 | java | package com.townz.repository.timezone;
import java.io.Serializable;
import java.time.*;
import java.util.Objects;
import javax.persistence.*;
@Entity
@Table(name = "jhi_date_time_wrapper")
public class DateTimeWrapper implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "instant")
private Instant instant;
@Column(name = "local_date_time")
private LocalDateTime localDateTime;
@Column(name = "offset_date_time")
private OffsetDateTime offsetDateTime;
@Column(name = "zoned_date_time")
private ZonedDateTime zonedDateTime;
@Column(name = "local_time")
private LocalTime localTime;
@Column(name = "offset_time")
private OffsetTime offsetTime;
@Column(name = "local_date")
private LocalDate localDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Instant getInstant() {
return instant;
}
public void setInstant(Instant instant) {
this.instant = instant;
}
public LocalDateTime getLocalDateTime() {
return localDateTime;
}
public void setLocalDateTime(LocalDateTime localDateTime) {
this.localDateTime = localDateTime;
}
public OffsetDateTime getOffsetDateTime() {
return offsetDateTime;
}
public void setOffsetDateTime(OffsetDateTime offsetDateTime) {
this.offsetDateTime = offsetDateTime;
}
public ZonedDateTime getZonedDateTime() {
return zonedDateTime;
}
public void setZonedDateTime(ZonedDateTime zonedDateTime) {
this.zonedDateTime = zonedDateTime;
}
public LocalTime getLocalTime() {
return localTime;
}
public void setLocalTime(LocalTime localTime) {
this.localTime = localTime;
}
public OffsetTime getOffsetTime() {
return offsetTime;
}
public void setOffsetTime(OffsetTime offsetTime) {
this.offsetTime = offsetTime;
}
public LocalDate getLocalDate() {
return localDate;
}
public void setLocalDate(LocalDate localDate) {
this.localDate = localDate;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DateTimeWrapper dateTimeWrapper = (DateTimeWrapper) o;
return !(dateTimeWrapper.getId() == null || getId() == null) && Objects.equals(getId(), dateTimeWrapper.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
// prettier-ignore
@Override
public String toString() {
return "TimeZoneTest{" +
"id=" + id +
", instant=" + instant +
", localDateTime=" + localDateTime +
", offsetDateTime=" + offsetDateTime +
", zonedDateTime=" + zonedDateTime +
'}';
}
}
| [
"[email protected]"
] | |
18c755c7ec27c9f5c07681a2f775263e7150a19b | 5a571eea26795909296828136cdfbf591976e5b2 | /src/main/java/com/loserbird/bookstore/service/impl/OrderServiceImpl.java | 8a2d0dc63a63d0101bbfb72492e87883179ab84d | [] | no_license | loserbird/online_bookstore | b26f4a157a1af21ee3a1b1a740019e4128ef34c7 | 6d4b45b74d360b733f2d962c055053a6e549c1a0 | refs/heads/master | 2021-09-09T01:03:11.270121 | 2018-03-13T05:11:35 | 2018-03-13T05:11:35 | 115,416,461 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,895 | java | package com.loserbird.bookstore.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.loserbird.bookstore.common.Const;
import com.loserbird.bookstore.common.ServerResponse;
import com.loserbird.bookstore.dao.*;
import com.loserbird.bookstore.pojo.*;
import com.loserbird.bookstore.service.IOrderService;
import com.loserbird.bookstore.util.BigDecimalUtil;
import com.loserbird.bookstore.util.DateTimeUtil;
import com.loserbird.bookstore.vo.OrderBookVo;
import com.loserbird.bookstore.vo.OrderItemVo;
import com.loserbird.bookstore.vo.OrderVo;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service("iOrderService")
public class OrderServiceImpl implements IOrderService {
private static final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderItemMapper orderItemMapper;
@Autowired
private CartMapper cartMapper;
@Autowired
private BookMapper bookMapper;
@Autowired
private ShippingMapper shippingMapper;
public ServerResponse createOrder(Integer userId, Integer shippingId){
//ไป่ดญ็ฉ่ฝฆไธญ่ทๅๆฐๆฎ
List<Cart> cartList = cartMapper.selectCheckedCartByUserId(userId);
//่ฎก็ฎ่ฟไธช่ฎขๅ็ๆปไปท
ServerResponse serverResponse = this.getCartOrderItem(userId,cartList);
if(!serverResponse.isSuccess()){
return serverResponse;
}
List<OrderItem> orderItemList = (List<OrderItem>)serverResponse.getData();
BigDecimal payment = this.getOrderTotalPrice(orderItemList);
//็ๆ่ฎขๅ
Order order = this.assembleOrder(userId,shippingId,payment);
if(order == null){
return ServerResponse.createByErrorMessage("็ๆ่ฎขๅ้่ฏฏ");
}
if(CollectionUtils.isEmpty(orderItemList)){
return ServerResponse.createByErrorMessage("่ดญ็ฉ่ฝฆไธบ็ฉบ");
}
for(OrderItem orderItem : orderItemList){
orderItem.setOrderNo(order.getOrderNo());
}
//mybatis ๆน้ๆๅ
ฅ
orderItemMapper.batchInsert(orderItemList);
//็ๆๆๅ,ๆไปฌ่ฆๅๅฐๆไปฌไนฆ็ฑ็ๅบๅญ
this.reduceBookStock(orderItemList);
//ๆธ
็ฉบไธไธ่ดญ็ฉ่ฝฆ
this.cleanCart(cartList);
//่ฟๅ็ปๅ็ซฏๆฐๆฎ
OrderVo orderVo = assembleOrderVo(order,orderItemList);
return ServerResponse.createBySuccess(orderVo);
}
private OrderVo assembleOrderVo(Order order,List<OrderItem> orderItemList){
OrderVo orderVo = new OrderVo();
orderVo.setOrderNo(order.getOrderNo());
orderVo.setPayment(order.getPayment());
orderVo.setPaymentType(order.getPaymentType());
orderVo.setPaymentTypeDesc(Const.PaymentTypeEnum.codeOf(order.getPaymentType()).getValue());
orderVo.setPostage(order.getPostage());
orderVo.setStatus(order.getStatus());
orderVo.setStatusDesc(Const.OrderStatusEnum.codeOf(order.getStatus()).getValue());
orderVo.setShippingId(order.getShippingId());
Shipping shipping = shippingMapper.selectByPrimaryKey(order.getShippingId());
if(shipping != null){
orderVo.setReceiverName(shipping.getReceiverName());
orderVo.setShipping(shipping);
}
orderVo.setPaymentTime(DateTimeUtil.dateToStr(order.getPaymentTime()));
orderVo.setSendTime(DateTimeUtil.dateToStr(order.getSendTime()));
orderVo.setEndTime(DateTimeUtil.dateToStr(order.getEndTime()));
orderVo.setCreateTime(DateTimeUtil.dateToStr(order.getCreateTime()));
orderVo.setCloseTime(DateTimeUtil.dateToStr(order.getCloseTime()));
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
for(OrderItem orderItem : orderItemList){
OrderItemVo orderItemVo = assembleOrderItemVo(orderItem);
orderItemVoList.add(orderItemVo);
}
orderVo.setOrderItemVoList(orderItemVoList);
return orderVo;
}
private OrderItemVo assembleOrderItemVo(OrderItem orderItem){
OrderItemVo orderItemVo = new OrderItemVo();
orderItemVo.setOrderNo(orderItem.getOrderNo());
orderItemVo.setBookId(orderItem.getBookId());
orderItemVo.setBookName(orderItem.getBookName());
orderItemVo.setBookImage(orderItem.getBookImage());
orderItemVo.setCurrentUnitPrice(orderItem.getCurrentUnitPrice());
orderItemVo.setQuantity(orderItem.getQuantity());
orderItemVo.setTotalPrice(orderItem.getTotalPrice());
orderItemVo.setCreateTime(DateTimeUtil.dateToStr(orderItem.getCreateTime()));
return orderItemVo;
}
private void cleanCart(List<Cart> cartList){
for(Cart cart : cartList){
cartMapper.deleteByPrimaryKey(cart.getId());
}
}
//ๅๅบๅญ
private void reduceBookStock(List<OrderItem> orderItemList){
for(OrderItem orderItem : orderItemList){
Book Book = bookMapper.selectByPrimaryKey(orderItem.getBookId());
Book.setStock(Book.getStock()-orderItem.getQuantity());
bookMapper.updateByPrimaryKeySelective(Book);
}
}
private Order assembleOrder(Integer userId,Integer shippingId,BigDecimal payment){
Order order = new Order();
long orderNo = this.generateOrderNo();
order.setOrderNo(orderNo);
order.setStatus(Const.OrderStatusEnum.NO_PAY.getCode());
order.setPostage(0);
order.setPaymentType(Const.PaymentTypeEnum.ONLINE_PAY.getCode());
order.setPayment(payment);
order.setUserId(userId);
order.setShippingId(shippingId);
//ๅ่ดงๆถ้ด็ญ็ญ
//ไปๆฌพๆถ้ด็ญ็ญ
int rowCount = orderMapper.insert(order);
if(rowCount > 0){
return order;
}
return null;
}
private long generateOrderNo(){
long currentTime =System.currentTimeMillis();
return currentTime+new Random().nextInt(100);
}
private BigDecimal getOrderTotalPrice(List<OrderItem> orderItemList){
BigDecimal payment = new BigDecimal("0");
for(OrderItem orderItem : orderItemList){
payment = BigDecimalUtil.add(payment.doubleValue(),orderItem.getTotalPrice().doubleValue());
}
return payment;
}
private ServerResponse getCartOrderItem(Integer userId,List<Cart> cartList){
List<OrderItem> orderItemList = Lists.newArrayList();
if(CollectionUtils.isEmpty(cartList)){
return ServerResponse.createByErrorMessage("่ดญ็ฉ่ฝฆไธบ็ฉบ");
}
//ๆ ก้ช่ดญ็ฉ่ฝฆ็ๆฐๆฎ,ๅ
ๆฌไนฆ็ฑ็็ถๆๅๆฐ้
for(Cart cartItem : cartList){
OrderItem orderItem = new OrderItem();
Book Book = bookMapper.selectByPrimaryKey(cartItem.getBookId());
if(Const.BookStatusEnum.ON_SALE.getCode() != Book.getStatus()){
return ServerResponse.createByErrorMessage("ไนฆ็ฑ"+Book.getName()+"ไธๆฏๅจ็บฟๅฎๅ็ถๆ");
}
//ๆ ก้ชๅบๅญ
if(cartItem.getQuantity() > Book.getStock()){
return ServerResponse.createByErrorMessage("ไนฆ็ฑ"+Book.getName()+"ๅบๅญไธ่ถณ");
}
orderItem.setUserId(userId);
orderItem.setBookId(Book.getId());
orderItem.setBookName(Book.getName());
orderItem.setBookImage(Book.getImage());
orderItem.setCurrentUnitPrice(Book.getPrice());
orderItem.setQuantity(cartItem.getQuantity());
orderItem.setTotalPrice(BigDecimalUtil.mul(Book.getPrice().doubleValue(),cartItem.getQuantity()));
orderItemList.add(orderItem);
}
return ServerResponse.createBySuccess(orderItemList);
}
public ServerResponse<String> cancel(Integer userId,Long orderNo){
Order order = orderMapper.selectByUserIdAndOrderNo(userId,orderNo);
if(order == null){
return ServerResponse.createByErrorMessage("่ฏฅ็จๆทๆญค่ฎขๅไธๅญๅจ");
}
if(order.getStatus() != Const.OrderStatusEnum.NO_PAY.getCode()){
return ServerResponse.createByErrorMessage("ๅทฒไปๆฌพ,ๆ ๆณๅๆถ่ฎขๅ");
}
Order updateOrder = new Order();
updateOrder.setId(order.getId());
updateOrder.setStatus(Const.OrderStatusEnum.CANCELED.getCode());
int row = orderMapper.updateByPrimaryKeySelective(updateOrder);
if(row > 0){
return ServerResponse.createBySuccess();
}
return ServerResponse.createByError();
}
public ServerResponse getOrderCartBook(Integer userId){
OrderBookVo orderBookVo = new OrderBookVo();
//ไป่ดญ็ฉ่ฝฆไธญ่ทๅๆฐๆฎ
List<Cart> cartList = cartMapper.selectCheckedCartByUserId(userId);
ServerResponse serverResponse = this.getCartOrderItem(userId,cartList);
if(!serverResponse.isSuccess()){
return serverResponse;
}
List<OrderItem> orderItemList =( List<OrderItem> ) serverResponse.getData();
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
BigDecimal payment = new BigDecimal("0");
for(OrderItem orderItem : orderItemList){
payment = BigDecimalUtil.add(payment.doubleValue(),orderItem.getTotalPrice().doubleValue());
orderItemVoList.add(assembleOrderItemVo(orderItem));
}
orderBookVo.setBookTotalPrice(payment);
orderBookVo.setOrderItemVoList(orderItemVoList);
return ServerResponse.createBySuccess(orderBookVo);
}
public ServerResponse<OrderVo> getOrderDetail(Integer userId,Long orderNo){
Order order = orderMapper.selectByUserIdAndOrderNo(userId,orderNo);
if(order != null){
List<OrderItem> orderItemList = orderItemMapper.getByOrderNoUserId(orderNo,userId);
OrderVo orderVo = assembleOrderVo(order,orderItemList);
return ServerResponse.createBySuccess(orderVo);
}
return ServerResponse.createByErrorMessage("ๆฒกๆๆพๅฐ่ฏฅ่ฎขๅ");
}
public ServerResponse<PageInfo> getOrderList(Integer userId,int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Order> orderList = orderMapper.selectByUserId(userId);
List<OrderVo> orderVoList = assembleOrderVoList(orderList,userId);
PageInfo pageResult = new PageInfo(orderList);
pageResult.setList(orderVoList);
return ServerResponse.createBySuccess(pageResult);
}
public ServerResponse<PageInfo> getOrderList(Integer userId,Integer status,int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Order> orderList = orderMapper.selectByUserIdStatus(userId,status);
List<OrderVo> orderVoList = assembleOrderVoList(orderList,userId);
PageInfo pageResult = new PageInfo(orderList);
pageResult.setList(orderVoList);
return ServerResponse.createBySuccess(pageResult);
}
private List<OrderVo> assembleOrderVoList(List<Order> orderList,Integer userId){
List<OrderVo> orderVoList = Lists.newArrayList();
for(Order order : orderList){
List<OrderItem> orderItemList = Lists.newArrayList();
if(userId == null){
//todo ็ฎก็ๅๆฅ่ฏข็ๆถๅ ไธ้่ฆไผ userId
orderItemList = orderItemMapper.getByOrderNo(order.getOrderNo());
}else{
orderItemList = orderItemMapper.getByOrderNoUserId(order.getOrderNo(),userId);
}
OrderVo orderVo = assembleOrderVo(order,orderItemList);
orderVoList.add(orderVo);
}
return orderVoList;
}
public ServerResponse pay(Long orderNo,Integer userId){
Order order = orderMapper.selectByUserIdAndOrderNo(userId,orderNo);
if(order == null){
return ServerResponse.createByErrorMessage("็จๆทๆฒกๆ่ฏฅ่ฎขๅ");
}
order.setPaymentTime(new Date());
order.setStatus(Const.OrderStatusEnum.PAID.getCode());
int count = orderMapper.updateByPrimaryKeySelective(order);
if(count >= 0){
return ServerResponse.createBySuccess("ๆฏไปๆๅ");
}
return ServerResponse.createByError();
}
public ServerResponse queryOrderPayStatus(Integer userId,Long orderNo){
Order order = orderMapper.selectByUserIdAndOrderNo(userId,orderNo);
if(order == null){
return ServerResponse.createByErrorMessage("็จๆทๆฒกๆ่ฏฅ่ฎขๅ");
}
if(order.getStatus() >= Const.OrderStatusEnum.PAID.getCode()){
return ServerResponse.createBySuccess();
}
return ServerResponse.createByError();
}
//backend
public ServerResponse<PageInfo> manageList(Integer status,int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Order> orderList = orderMapper.selectByUserIdStatus(null,status);
List<OrderVo> orderVoList = this.assembleOrderVoList(orderList,null);
PageInfo pageResult = new PageInfo(orderList);
pageResult.setList(orderVoList);
return ServerResponse.createBySuccess(pageResult);
}
public ServerResponse<OrderVo> manageDetail(Long orderNo){
Order order = orderMapper.selectByOrderNo(orderNo);
if(order != null){
List<OrderItem> orderItemList = orderItemMapper.getByOrderNo(orderNo);
OrderVo orderVo = assembleOrderVo(order,orderItemList);
return ServerResponse.createBySuccess(orderVo);
}
return ServerResponse.createByErrorMessage("่ฎขๅไธๅญๅจ");
}
public ServerResponse<PageInfo> manageSearch(Long orderNo,int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
Order order = orderMapper.selectByOrderNo(orderNo);
if(order != null){
List<OrderItem> orderItemList = orderItemMapper.getByOrderNo(orderNo);
OrderVo orderVo = assembleOrderVo(order,orderItemList);
PageInfo pageResult = new PageInfo(Lists.newArrayList(order));
pageResult.setList(Lists.newArrayList(orderVo));
return ServerResponse.createBySuccess(pageResult);
}
return ServerResponse.createByErrorMessage("่ฎขๅไธๅญๅจ");
}
public ServerResponse<String> manageSendGoods(Long orderNo){
Order order= orderMapper.selectByOrderNo(orderNo);
if(order != null){
if(order.getStatus() == Const.OrderStatusEnum.PAID.getCode()){
order.setStatus(Const.OrderStatusEnum.SHIPPED.getCode());
order.setSendTime(new Date());
orderMapper.updateByPrimaryKeySelective(order);
return ServerResponse.createBySuccess("ๅ่ดงๆๅ");
}
}
return ServerResponse.createByErrorMessage("่ฎขๅไธๅญๅจ");
}
public ServerResponse<String> FinishOrder(Long orderNo){
Order order= orderMapper.selectByOrderNo(orderNo);
if(order != null){
if(order.getStatus() == Const.OrderStatusEnum.SHIPPED.getCode()){
order.setStatus(Const.OrderStatusEnum.ORDER_SUCCESS.getCode());
order.setEndTime(new Date());
orderMapper.updateByPrimaryKeySelective(order);
return ServerResponse.createBySuccess("่ฎขๅๅฎ็ปๆๅ");
}
}
return ServerResponse.createByErrorMessage("่ฎขๅไธๅญๅจ");
}
}
| [
"[email protected]"
] | |
2a87e96fa43e4464a3b203f263fbfbb266f50cc6 | f9042b41e4d8358354210da4540fbd85a1ae880f | /MoodSpotterOnline/src/main/java/mus2/moodSpotter/util/SizedQueue.java | c8ff00bacea830ceee0184e6d5b975e1eb459abf | [] | no_license | tom-hacker/MoodSpotter | c609053b05d9246067cbd250f688c1f6410d432c | 12065be53d36099bc9010d8004e6f06a3e0957bb | refs/heads/master | 2023-01-12T07:33:22.636610 | 2019-06-29T21:38:42 | 2019-06-29T21:38:42 | 193,217,083 | 2 | 0 | null | 2023-01-07T07:15:44 | 2019-06-22T09:41:27 | Python | UTF-8 | Java | false | false | 371 | java | package mus2.moodSpotter.util;
import java.util.LinkedList;
public class SizedQueue<T> extends LinkedList<T> {
int maxSize;
public SizedQueue(int maxSize){
super();
this.maxSize = maxSize;
}
@Override
public boolean add(T item){
if(super.size() > maxSize)
super.pop();
return super.add(item);
}
}
| [
"[email protected]"
] | |
452ddb6f8bbbeddfccbd67d4baaaf6125ccc6efd | cff8fa98eb52e6057c3d67574d045165437b94ae | /Generador/org.xtext.dsl.generador.parent/org.xtext.dsl.generador.ui/xtend-gen/org/xtext/dsl/generador/ui/GeneradorUiModule.java | a2d76f3b5576c97d8e005216ac7d169b2bfbc32e | [] | no_license | pablobravo/TFM | c84201a177bfe55e572ddbb4e3346b921322b6b1 | 3bba07e864cc2eba3916f2d978033322741b2a39 | refs/heads/master | 2021-04-29T22:50:05.998376 | 2018-04-24T13:44:02 | 2018-04-24T13:44:02 | 121,643,889 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 533 | java | /**
* generated by Xtext 2.12.0
*/
package org.xtext.dsl.generador.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
import org.xtext.dsl.generador.ui.AbstractGeneradorUiModule;
/**
* Use this class to register components to be used within the Eclipse IDE.
*/
@FinalFieldsConstructor
@SuppressWarnings("all")
public class GeneradorUiModule extends AbstractGeneradorUiModule {
public GeneradorUiModule(final AbstractUIPlugin plugin) {
super(plugin);
}
}
| [
"[email protected]"
] | |
b545d1afe19ba8e3628d0f2c7f60b7eac0beca36 | e6d83ef264106d6424d910ced9771b61ae5745dd | /TeamVierAugen/Damage.java | 94fb9027ddfb5650047536acc63719133b91ecf4 | [] | no_license | Squirrel-Lord/BattlePets | c3ff4cdfe6280287ff5b95f9dfa298ef2a494ffa | 818f787d564b1d4dd6ae74a7a7f4cfa315716f13 | refs/heads/master | 2022-03-13T17:21:38.833095 | 2020-01-01T17:55:07 | 2020-01-01T17:55:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,944 | java | /**
* Authors: Alex Ahlrichs, Ross Baldwin, Jared Hollenberger, Zexin Liu, Lincoln Schroeder
*
* Purpose: This class defines the damage done by a pet during one round. It stores the random damage
* and conditional damage. It calculates the conditional damage, but doesn't access the
* RandomNumberGenerator.
*/
package TeamVierAugen;
import TeamVierAugen.Playables.Playable;
import TeamVierAugen.Skills.Skills;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Damage
{
private static final int POWER_CONDITIONAL_MULTIPLIER = 5;
private static final int SPEED_CONDITIONAL_DAMAGE = 10;
private static final float SPEED_CONDITIONAL_HP_PERCENT_UPPER = 0.75f;
private static final float SPEED_CONDITIONAL_HP_PERCENT_LOWER = 0.25f;
private static final int INTELLIGENCE_CONDITIONAL_DAMAGE_HIGH = 3;
private static final int INTELLIGENCE_CONDITIONAL_DAMAGE_LOW = 2;
private static final int SHOOT_THE_MOON_BONUS_DAMAGE = 20;
private double randomDamage;
private double conditionalDamage;
/**
* Constructor for explicitly setting random and conditional damage.
* @param randomDamage the random damage for this instance.
* @param conditionalDamage the conditional damage for this instance.
*/
public Damage(double randomDamage, double conditionalDamage)
{
this.randomDamage = randomDamage;
this.conditionalDamage = conditionalDamage;
}
/**
* Getter for randomDamage.
* @return randomDamage.
*/
public double getRandomDamage()
{
return randomDamage;
}
/**
* Setter for randomDamage.
* @param randomDamage the desired randomDamage.
*/
public void setRandomDamage(double randomDamage)
{
this.randomDamage = round(randomDamage, 2);
}
/**
* Getter for conditionalDamage.
* @return conditionalDamage.
*/
public double getConditionalDamage()
{
return conditionalDamage;
}
/**
* Setter for conditionalDamage.
* @param conditionalDamage the desired conditionalDamage.
*/
public void setConditionalDamage(double conditionalDamage)
{
this.conditionalDamage = round(conditionalDamage, 2);
}
/**
* Calculates the total damage for this turn.
* @return total damage.
*/
public double calculateTotalDamage()
{
return randomDamage + conditionalDamage;
}
/**
* Calculates conditional damage for POWER type Pets.
* @param usedSkill the skill that this pet is using.
* @param enemyUsedSkill the skill that the enemy is using.
* @return conditional damage for this turn.
* @throws Exception for invalid skill types.
*/
public double calculatePowerConditional(Skills usedSkill, Skills enemyUsedSkill) throws Exception
{
double damage = 0;
switch(usedSkill)
{
case ROCK_THROW:
if(enemyUsedSkill == Skills.SCISSORS_POKE)
damage = randomDamage * POWER_CONDITIONAL_MULTIPLIER;
break;
case PAPER_CUT:
if(enemyUsedSkill == Skills.ROCK_THROW)
damage = randomDamage * POWER_CONDITIONAL_MULTIPLIER;
break;
case SCISSORS_POKE:
if(enemyUsedSkill == Skills.PAPER_CUT)
damage = randomDamage * POWER_CONDITIONAL_MULTIPLIER;
break;
default:
throw new Exception("Invalid skill type!");
}
damage = round(damage, 2);
this.conditionalDamage = damage;
return damage;
}
/**
* Calculates conditional damage for SPEED type Pets.
* @param usedSkill the skill that this pet is using.
* @param enemyUsedSkill the skill that the enemy is using.
* @param enemyHpPercent the enemy's current hp percent.
* @return conditional damage for this turn.
* @throws Exception for invalid skill types.
*/
public double calculateSpeedConditional(Skills usedSkill, Skills enemyUsedSkill, double enemyHpPercent)
throws Exception
{
double damage = 0;
switch(usedSkill)
{
case ROCK_THROW:
if(enemyHpPercent >= SPEED_CONDITIONAL_HP_PERCENT_UPPER)
{
if(enemyUsedSkill == Skills.SCISSORS_POKE || enemyUsedSkill == Skills.PAPER_CUT)
damage = SPEED_CONDITIONAL_DAMAGE;
}
break;
case PAPER_CUT:
if(enemyHpPercent >= SPEED_CONDITIONAL_HP_PERCENT_LOWER && enemyHpPercent <
SPEED_CONDITIONAL_HP_PERCENT_UPPER)
{
if(enemyUsedSkill == Skills.ROCK_THROW || enemyUsedSkill == Skills.PAPER_CUT)
damage = SPEED_CONDITIONAL_DAMAGE;
}
break;
case SCISSORS_POKE:
if(enemyHpPercent < SPEED_CONDITIONAL_HP_PERCENT_LOWER)
{
if(enemyUsedSkill == Skills.SCISSORS_POKE || enemyUsedSkill == Skills.ROCK_THROW)
damage = SPEED_CONDITIONAL_DAMAGE;
}
break;
default:
throw new Exception("Invalid skill type!");
}
damage = round(damage, 2);
this.conditionalDamage = damage;
return damage;
}
/**
* Calculates conditional damage for INTELLIGENCE type Pets.
* @param usedSkill the skill that this pet is using.
* @param enemyPlayer the skill that the enemy pet is using.
* @return conditional damage for this turn.
* @throws Exception for invalid skill types.
*/
public double calculateIntelligenceConditional(Skills usedSkill, Playable enemyPlayer)
throws Exception
{
double damage = 0;
switch(usedSkill)
{
case ROCK_THROW:
if(enemyPlayer.getSkillRechargeTime(Skills.SCISSORS_POKE) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_HIGH;
if(enemyPlayer.getSkillRechargeTime(Skills.ROCK_THROW) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
if(enemyPlayer.getSkillRechargeTime(Skills.SHOOT_THE_MOON) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
break;
case PAPER_CUT:
if(enemyPlayer.getSkillRechargeTime(Skills.ROCK_THROW) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_HIGH;
if(enemyPlayer.getSkillRechargeTime(Skills.PAPER_CUT) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
if(enemyPlayer.getSkillRechargeTime(Skills.SHOOT_THE_MOON) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
break;
case SCISSORS_POKE:
if(enemyPlayer.getSkillRechargeTime(Skills.PAPER_CUT) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_HIGH;
if(enemyPlayer.getSkillRechargeTime(Skills.SCISSORS_POKE) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
if(enemyPlayer.getSkillRechargeTime(Skills.SHOOT_THE_MOON) > 0)
damage += INTELLIGENCE_CONDITIONAL_DAMAGE_LOW;
break;
default:
throw new Exception("Invalid skill type!");
}
damage = round(damage, 2);
this.conditionalDamage = damage;
return damage;
}
/**
* Calculates conditional damage for the skill Shoot the moon.
* @param predictedSkill skill that player thought the opponent used
* @param usedSkill skill used by opponent
* @return double value that is damage
*/
public double calculateShootTheMoonConditional(Skills predictedSkill, Skills usedSkill)
{
double damage = 0;
if(predictedSkill == usedSkill)
{
damage = SHOOT_THE_MOON_BONUS_DAMAGE;
}
this.conditionalDamage = damage;
return damage;
}
/**
* This method is used to round double values that hold the amount of damage
* done by a pet.
* @param value double value to round
* @param places amount of decimal places to round to
* @return double value that is rounded
*/
public static double round(double value, int places) {
if (places < 0) throw new IllegalArgumentException();
BigDecimal bd = BigDecimal.valueOf(value);
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
}
}
| [
"[email protected]"
] | |
05bbe07c7dc5740016a8ef135fd3249e497f9f45 | d1271349b7213ec090c3d7d10eda506fb14e48fd | /src/main/java/org/yx/db/conn/SumkDataSource.java | 575edfc720f117baedaae86bde3131991e8b2bd7 | [
"Apache-2.0"
] | permissive | luxiang1986/sumk | 51c372f4f946ac7ba33355698ef7dd7e7188d0d7 | 08ca8d60b1c76a74eb41a449e9cae8c77d500962 | refs/heads/master | 2022-11-19T14:09:55.694945 | 2020-07-11T02:45:46 | 2020-07-11T02:45:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,135 | java | /**
* Copyright (C) 2016 - 2030 youtongluan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.yx.db.conn;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Objects;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.yx.db.DBType;
import org.yx.exception.SumkException;
public class SumkDataSource implements DataSource {
private final String name;
private final DBType type;
private final DataSource proxy;
private boolean enable = true;
public SumkDataSource(String name, DBType type, DataSource ds) {
this.name = Objects.requireNonNull(name);
this.type = Objects.requireNonNull(type);
this.proxy = Objects.requireNonNull(ds);
}
public String getName() {
return name;
}
public DBType getType() {
return type;
}
@Override
public SumkConnection getConnection() throws SQLException {
return new SumkConnection(proxy.getConnection(), this);
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return proxy.getLogWriter();
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
proxy.setLogWriter(out);
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
proxy.setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout() throws SQLException {
return proxy.getLoginTimeout();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return proxy.getParentLogger();
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == this.getClass()) {
return iface.cast(this);
}
if (iface.isInstance(proxy)) {
return iface.cast(proxy);
}
throw new SumkException(-234345, this.getClass().getSimpleName() + " does not wrap " + iface.getName());
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface == this.getClass() || iface.isInstance(proxy);
}
@Override
public String toString() {
return new StringBuilder("ds[").append(name).append("-")
.append(type.name().startsWith("READ") ? "READ" : type.name()).append("]").toString();
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return new SumkConnection(proxy.getConnection(username, password), this);
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
}
| [
"[email protected]"
] | |
8974bf46363d418cebc477b15a040c6e8dc17374 | f6899a2cf1c10a724632bbb2ccffb7283c77a5ff | /glassfish-3.0/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/ServiceRefPortInfoRuntimeNode.java | cc5fe4567af073a3ba2bb20ac104b26836140787 | [] | no_license | Appdynamics/OSS | a8903058e29f4783e34119a4d87639f508a63692 | 1e112f8854a25b3ecf337cad6eccf7c85e732525 | refs/heads/master | 2023-07-22T03:34:54.770481 | 2021-10-28T07:01:57 | 2021-10-28T07:01:57 | 19,390,624 | 2 | 13 | null | 2023-07-08T02:26:33 | 2014-05-02T22:42:20 | null | UTF-8 | Java | false | false | 7,274 | java | /*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.enterprise.deployment.node.runtime;
import com.sun.enterprise.deployment.NameValuePairDescriptor;
import com.sun.enterprise.deployment.ServiceRefPortInfo;
import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
import com.sun.enterprise.deployment.node.NameValuePairNode;
import com.sun.enterprise.deployment.node.XMLElement;
import com.sun.enterprise.deployment.node.runtime.common.MessageSecurityBindingNode;
import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor;
import com.sun.enterprise.deployment.xml.WebServicesTagNames;
import org.w3c.dom.Node;
import javax.xml.namespace.QName;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* This node is responsible for handling runtime info for
* a service reference wsdl port.
*
* @author Kenneth Saks
* @version
*/
public class ServiceRefPortInfoRuntimeNode extends DeploymentDescriptorNode {
private String namespaceUri;
public ServiceRefPortInfoRuntimeNode() {
super();
registerElementHandler
(new XMLElement(WebServicesTagNames.STUB_PROPERTY),
NameValuePairNode.class, "addStubProperty");
registerElementHandler
(new XMLElement(WebServicesTagNames.CALL_PROPERTY),
NameValuePairNode.class, "addCallProperty");
registerElementHandler(new XMLElement(WebServicesTagNames.MESSAGE_SECURITY_BINDING), MessageSecurityBindingNode.class, "setMessageSecurityBinding");
}
/**
* all sub-implementation of this class can use a dispatch table to map xml element to
* method name on the descriptor class for setting the element value.
*
* @return the map with the element name as a key, the setter method as a value
*/
protected Map getDispatchTable() {
Map table = super.getDispatchTable();
table.put(WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE,
"setServiceEndpointInterface");
return table;
}
/**
* receives notiification of the value for a particular tag
*
* @param element the xml element
* @param value it's associated value
*/
public void setElementValue(XMLElement element, String value) {
String name = element.getQName();
if (WebServicesTagNames.NAMESPACE_URI.equals(name)) {
namespaceUri = value;
} else if (WebServicesTagNames.LOCAL_PART.equals(name)) {
ServiceRefPortInfo desc = (ServiceRefPortInfo)
getDescriptor();
QName wsdlPort = new QName(namespaceUri, value);
desc.setWsdlPort(wsdlPort);
namespaceUri = null;
} else super.setElementValue(element, value);
}
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param node name for the descriptor
* @param the descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node parent, String nodeName,
ServiceRefPortInfo desc) {
Node serviceRefPortInfoRuntimeNode =
super.writeDescriptor(parent, nodeName, desc);
appendTextChild(serviceRefPortInfoRuntimeNode,
WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE,
desc.getServiceEndpointInterface());
QName port = desc.getWsdlPort();
if( port != null ) {
Node wsdlPortNode = appendChild(serviceRefPortInfoRuntimeNode,
WebServicesTagNames.WSDL_PORT);
appendTextChild(wsdlPortNode,
WebServicesTagNames.NAMESPACE_URI,
port.getNamespaceURI());
appendTextChild(wsdlPortNode,
WebServicesTagNames.LOCAL_PART,
port.getLocalPart());
}
// stub-property*
NameValuePairNode nameValueNode = new NameValuePairNode();
Set stubProperties = desc.getStubProperties();
for(Iterator iter = stubProperties.iterator(); iter.hasNext();) {
NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next();
nameValueNode.writeDescriptor
(serviceRefPortInfoRuntimeNode,
WebServicesTagNames.STUB_PROPERTY, next);
}
// call-property*
for(Iterator iter = desc.getCallProperties().iterator();
iter.hasNext();) {
NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next();
nameValueNode.writeDescriptor
(serviceRefPortInfoRuntimeNode,
WebServicesTagNames.CALL_PROPERTY, next);
}
// message-security-binding
MessageSecurityBindingDescriptor messageSecBindingDesc =
desc.getMessageSecurityBinding();
if (messageSecBindingDesc != null) {
MessageSecurityBindingNode messageSecBindingNode =
new MessageSecurityBindingNode();
messageSecBindingNode.writeDescriptor(serviceRefPortInfoRuntimeNode, WebServicesTagNames.MESSAGE_SECURITY_BINDING, messageSecBindingDesc);
}
return serviceRefPortInfoRuntimeNode;
}
}
| [
"[email protected]"
] | |
cb12cd8b385d43cd20f07e4646b604f3affdcaa8 | 0fe326a7b72231a492092624ce3aa71c017a743d | /src/main/java/com/classmanagement/client/utils/DbHelper.java | 48b1a6069dc57e8d3371eac91ff1cfbb4f17e549 | [] | no_license | Richard0han/ClassManagement | a6158a9d7021d9f675da9b4412c4897f80382316 | 5897ab716e6750fd2bc5feb741d84767ae25e0ce | refs/heads/master | 2020-05-03T13:55:55.544578 | 2019-05-09T15:40:53 | 2019-05-09T15:40:53 | 178,664,515 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,573 | java | package com.classmanagement.client.utils;
import java.sql.*;
/**
* ClassManager
*
* @author Richard-J
* @description ๆฐๆฎๅบ่ฟๆฅ็ฑป
* @date 2019.03
*/
public class DbHelper {
/*
* "120.77.150.166"
*/
private static final String ip = "localhost";
private static final String driver = "com.mysql.cj.jdbc.Driver";
private static final String url = "jdbc:mysql://" + ip + ":3306/class_management" +
"?useUnicode=true&&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&user=root&password=[a1331110]&serverTimezone=UTC&characterEncoding=UTF-8&useSSL=true";
private static final String username = "root";
private static final String password = "root";
private static Connection con = null;
static {
try {
Class.forName(driver);
} catch (Exception var1) {
var1.printStackTrace();
}
}
public static Connection getConnection() throws Exception {
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
public static void close(PreparedStatement preparedStatement, Connection connection, ResultSet resultSet) {
try {
if (preparedStatement != null) {
preparedStatement.close();
}
if (connection != null) {
connection.close();
}
if (resultSet != null) {
resultSet.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
ca00520e3982f1af6d93689c3b9f20913b3e03a3 | 946d37f6148788d2e9a64698288977441a35bc0d | /ioandcollectionandthread/iotofile/Student.java | 947e74b23f71126bd4bdab2110256d38dfadd589 | [] | no_license | daqiaobian/codepractice | 66ee20517fde3435027679e0a6b182a4969b5d95 | 7608dbcb5cee9e4cf4190a25dc74f6fc4337581b | refs/heads/master | 2023-08-22T21:34:12.964312 | 2021-10-13T03:34:02 | 2021-10-13T03:34:02 | 415,317,636 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 986 | java | package iotofile;
public class Student {
private String name;
private int chinese;
private int math;
private int english;
public Student() {
}
public Student(String name, int chinese, int math, int english) {
this.name = name;
this.chinese = chinese;
this.math = math;
this.english = english;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getChinese() {
return chinese;
}
public void setChinese(int chinese) {
this.chinese = chinese;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
public int getEnglish() {
return english;
}
public void setEnglish(int english) {
this.english = english;
}
public int getSum(){
return this.chinese+this.math+this.english;
}
}
| [
"[email protected]"
] | |
52676b491e5fa228594ada1c0324c8f4e472a18d | 73f95a86afc5d5bd136d6c65f54f4f86197d6523 | /app/src/main/java/cc/sayaki/music/data/model/Lyrics.java | b383bcd85f9bd29ffaf438f82eddd5bbb03e1b31 | [] | no_license | lybeat/MikuMusicPlayer | b9bc777b3d55c1faec42c5e5e1a9583b0c7d25d3 | ed721b01cf3f9d7a9a86c088af3a20e9e9df64cb | refs/heads/master | 2021-01-25T09:26:23.969943 | 2017-06-21T09:29:25 | 2017-06-21T09:29:25 | 93,834,187 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 578 | java | package cc.sayaki.music.data.model;
/**
* Author: lybeat
* Date: 2016/8/16
*/
public class Lyrics {
private long timestamp;
private String lrc;
public Lyrics() {}
public Lyrics(long timestamp, String lrc) {
this.timestamp = timestamp;
this.lrc = lrc;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getLrc() {
return lrc;
}
public void setLrc(String lrc) {
this.lrc = lrc;
}
}
| [
"[email protected]"
] | |
fd67c58f25b66431b34906251d2871fd5dd5c869 | b60b9a8dc518bead0cee130aaef06420f0f3976f | /Chapter02/Ch2_30.java | a327415690b8fcf915bffed19aa271d5e508f7da | [
"MIT"
] | permissive | AzureCloudMonk/Learning-RxJava-Second-Edition | cf977ea47beab84387c1d9a517a8fde99c3e3937 | 2c44d4581207e6a965e3d892497adcba83a35042 | refs/heads/master | 2021-01-01T13:36:08.472450 | 2020-02-09T01:27:00 | 2020-02-09T01:27:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 751 | java | import io.reactivex.Maybe;
public class Ch2_30 {
public static void main(String[] args) {
// has emission
Maybe<Integer> source = Maybe.just(100);
//Observable<Integer> source = Observable.just(100);
source.subscribe(s -> System.out.println("Process 1:" + s),
e -> System.out.println("Error captured: " + e),
() -> System.out.println("Process 1 done!"));
//no emission
Maybe<Integer> empty = Maybe.empty();
//Observable<Integer> empty = Observable.empty();
empty.subscribe(s -> System.out.println("Process 2:" + s),
e -> System.out.println("Error captured: " + e),
() -> System.out.println("Process 2 done!"));
}
} | [
"[email protected]"
] | |
5066423a96d479b1d1b430570ff525585efcef5c | 2545fbc27156911234066bbf3642b5859e678fe6 | /app/src/main/java/com/huahuico/mynatiaveapplication/rxpermissions/RxPermissions.java | c80085f1f125abd4804caac61ce26071775e8b93 | [] | no_license | chenyilyang/MyOpenCV | 80d7693bf8366a394497d4db99b2e1a2b226e257 | ccd6e9383455edbfc54d4d8871a20a0a5336de68 | refs/heads/master | 2023-02-17T01:48:24.949870 | 2021-01-15T01:20:13 | 2021-01-15T01:20:13 | 319,495,272 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,385 | java | package com.huahuico.mynatiaveapplication.rxpermissions;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.core.ObservableTransformer;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.subjects.PublishSubject;
public class RxPermissions {
/**
* ๅปถๆถๅฎไพๅ็ๆฅๅฃๅฃฐๆ
* @param <T>
*/
@FunctionalInterface
public interface Lazy<T> {
T get();
}
private final static String TAG = RxPermissions.class.getSimpleName();
private final static Object TRIGGER = new Object();
@VisibleForTesting
Lazy<RxPermissionsFragment> mRxPermissionFragment;
public RxPermissions(@NonNull final FragmentActivity activity) {
mRxPermissionFragment = getLazySingleton(activity.getSupportFragmentManager());
}
public RxPermissions(@NonNull final Fragment fragment) {
mRxPermissionFragment = getLazySingleton(fragment.getChildFragmentManager());
}
private Lazy<RxPermissionsFragment> getLazySingleton(@NonNull final FragmentManager fragmentManager) {
return new Lazy<RxPermissionsFragment>() {
private RxPermissionsFragment rxPermissionsFragment;
@Override
public RxPermissionsFragment get() {
if (rxPermissionsFragment == null) {
rxPermissionsFragment = getRxPermissionsFragment(fragmentManager);
}
return rxPermissionsFragment;
}
};
}
private RxPermissionsFragment getRxPermissionsFragment(@NonNull final FragmentManager fragmentManager) {
RxPermissionsFragment rxPermissionsFragment = findRxPermissionsFragment(fragmentManager);
boolean isNewInstance = rxPermissionsFragment == null;
if (isNewInstance) {
rxPermissionsFragment = new RxPermissionsFragment();
fragmentManager.beginTransaction().add(rxPermissionsFragment, TAG).commitNow();
}
return rxPermissionsFragment;
}
private RxPermissionsFragment findRxPermissionsFragment(@NonNull final FragmentManager fragmentManager) {
return (RxPermissionsFragment) fragmentManager.findFragmentByTag(TAG);
}
public Observable<Boolean> request(final String ... permissions) {
return Observable.just(TRIGGER).compose(ensure(permissions));
}
public Observable<Permission> requestEach(final String ... permissions) {
return Observable.just(TRIGGER).compose(ensureEach(permissions));
}
public Observable<Permission> requestEachCombined(final String ... permissions) {
return Observable.just(TRIGGER).compose(ensureEachCombined(permissions));
}
/**
* ๅฏนๅคไธชๆ้็ณ่ฏทๅช่ฟ่กไธๆฌก็กฎ่ฎค๏ผๆไธไธชไธ้่ฟ้ฝไผ่ฟๅfalse
* @param permissions
* @param <T>
* @return boolean็ฑปๅ็่ขซ่งๅฏ่
*/
public <T> ObservableTransformer<T, Boolean> ensure(final String ... permissions) {
return new ObservableTransformer<T, Boolean>() {
@Override
public ObservableSource<Boolean> apply(Observable<T> upstream) {
return request(upstream, permissions)
.buffer(permissions.length)
.flatMap(new Function<List<Permission>, ObservableSource<Boolean>>() {
@Override
public ObservableSource<Boolean> apply(List<Permission> permissions) throws Throwable {
if (permissions.isEmpty()) {
return Observable.empty();
}
for (Permission permission : permissions) {
if (!permission.granted) {
return Observable.just(false);
}
}
return Observable.just(true);
}
});
}
};
}
/**
* ๅฏนๆฏไธไธชๆ้็ณ่ฏท็็ปๆ่ฟ่ก็กฎ่ฎค
* @param permissions
* @param <T>
* @return
*/
public <T> ObservableTransformer<T, Permission> ensureEach(final String ... permissions) {
return new ObservableTransformer<T, Permission>() {
@Override
public ObservableSource<Permission> apply(Observable<T> upstream) {
return request(upstream, permissions);
}
};
}
public <T> ObservableTransformer<T, Permission> ensureEachCombined(final String ... permissions) {
return new ObservableTransformer<T, Permission>() {
@Override
public ObservableSource<Permission> apply(Observable<T> upstream) {
return request(upstream, permissions).buffer(permissions.length)
.flatMap(new Function<List<Permission>, ObservableSource<Permission>>() {
@Override
public ObservableSource<Permission> apply(List<Permission> permissions) throws Throwable {
if (permissions.isEmpty()) {
return Observable.empty();
}
return Observable.just(new Permission(permissions));
}
});
}
};
}
/**
* ๅฏนไธๅฐๅคไธชๆ้่ฟ่ก็ณ่ฏท
* @param trigger
* @param permissions
* @return
*/
public Observable<Permission> request(final Observable<?> trigger, final String ... permissions) {
if (permissions == null || permissions.length == 0) {
throw new IllegalStateException("RxPermissions.request/requestEach requires at least one input permission");
}
return oneOf(trigger, pending(permissions))
.flatMap(new Function<Object, Observable<Permission>>() {
@Override
public Observable<Permission> apply(Object o) throws Throwable {
return requestImplementation(permissions);
}
});
}
private Observable<?> oneOf(Observable<?> trigger, Observable<?> pending) {
if (trigger == null) {
return Observable.just(TRIGGER);
}
return Observable.merge(trigger, pending);
}
private Observable<?> pending(final String ... permissions) {
for (String permission : permissions) {
if (!mRxPermissionFragment.get().containsByPermission(permission)) {
return Observable.empty();
}
}
return Observable.just(TRIGGER);
}
/**
* ๅฎ้
ๅ็ณป็ป็ณ่ฏทๆ้็ๅฎ็ฐ
* @param permissions
* @return
*/
private Observable<Permission> requestImplementation(final String ... permissions) {
List<Observable<Permission>> permissionList = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
for (String permission : permissions) {
Log.d(TAG, "Requesting permission " + permission);
if (isGranted(permission)) {
permissionList.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(permission)) {
permissionList.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = mRxPermissionFragment.get().getSubjectByPermission(permission);
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionFragment.get().setSubjectForPermission(permission, subject);
}
permissionList.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String [] unrequestPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromFragment(unrequestPermissionsArray);
}
return Observable.concat(Observable.fromIterable(permissionList));
}
public Observable<Boolean> shouldShowRequestPermissionRationale(final Activity activity, final String ... permissions) {
if (!isMarshmallow()) {
return Observable.just(false);
}
return Observable.just(shouldShowRequestPermissionRationaleImplementation(activity, permissions));
}
@TargetApi(Build.VERSION_CODES.M)
private boolean shouldShowRequestPermissionRationaleImplementation(final Activity activity, final String ... permissions) {
for (String permission : permissions) {
if (!isGranted(permission) && !activity.shouldShowRequestPermissionRationale(permission)) {
return false;
}
}
return true;
}
void requestPermissionsFromFragment(String [] permissions) {
Log.d(TAG, "reqeustPermissionsFromFragment" + TextUtils.join(", ", permissions));
mRxPermissionFragment.get().requestPermissions(permissions);
}
@TargetApi(Build.VERSION_CODES.M)
public boolean isGranted(String permission) {
return isMarshmallow() && mRxPermissionFragment.get().isGranted(permission);
}
boolean isMarshmallow() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}
public boolean isRevoked(String permission) {
return isMarshmallow() && mRxPermissionFragment.get().isRevoked(permission);
}
void onRequestPermissionsResult(String [] permissions, int [] grantResults) {
mRxPermissionFragment.get().onRequestPermissionsResult(permissions, grantResults, new boolean[permissions.length]);
}
}
| [
"[email protected]"
] | |
790b747c78fb8e5a711075f8efd8e2b586e27ad7 | 44a6735b00f1802a49b0533d9fbc8962d84a2036 | /src/java/ru/mirari/infra/security/UserDetailsService.java | 031d6c650c6ebe3e8753e1eb806c62f10763c245 | [] | no_license | alari/mirari-infra-security | 0def41fc8bf8be404dfbc029387141be87d591ec | bd64cb09ff443307f9c1362c251d0a379bb9a692 | refs/heads/master | 2021-01-01T18:11:08.703297 | 2011-12-04T21:29:19 | 2011-12-04T21:29:19 | 2,868,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,854 | java | package ru.mirari.infra.security;
import org.apache.log4j.Logger;
import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser;
import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService;
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import java.util.*;
/**
* @author alari
* @since 11/28/11 7:25 PM
*/
public class UserDetailsService implements GrailsUserDetailsService {
static private final Logger log = Logger.getLogger(UserDetailsService.class);
@Autowired AccountRepository accountRepository;
/**
* Some Spring Security classes (e.g. RoleHierarchyVoter) expect at least one role, so
* we give a user with no granted roles this one which gets past that restriction but
* doesn't grant anything.
*/
static final List<GrantedAuthority> NO_ROLES = Arrays.asList((GrantedAuthority)new GrantedAuthorityImpl(SpringSecurityUtils
.NO_ROLE));
public UserDetails loadUserByUsername(String email, boolean loadRoles) {
if(log.isDebugEnabled()) {
log.debug("Attempted user logon: ".concat(email));
}
Account account = accountRepository.getByEmail(email);
if(account == null) {
log.warn("User not found: ".concat(email));
throw new UsernameNotFoundException("User not found", email);
}
if (log.isDebugEnabled()) {
log.debug("User found: ".concat(email));
}
List<GrantedAuthority> roles = NO_ROLES;
if (loadRoles) {
if(account.getAuthorities().size() > 0) {
roles = new ArrayList<GrantedAuthority>(account.getAuthorities().size());
for(GrantedAuthority authority : account.getAuthorities()) {
roles.add(authority);
}
}
}
if (log.isDebugEnabled()) {
log.debug("User roles: ".concat(roles.toString()));
}
return createUserDetails(account, roles);
}
public UserDetails loadUserByUsername(String username) {
return loadUserByUsername(username, true);
}
protected UserDetails createUserDetails(Account account, Collection<GrantedAuthority> authorities) {
return new GrailsUser(account.getEmail(), account.getPassword(), account.isEnabled(),
!account.isAccountExpired(), !account.isPasswordExpired(),
!account.isAccountLocked(), authorities, account.getId().toString());
}
} | [
"[email protected]"
] | |
c02dd7ef918391411a3d26300bfe0a5d3917c934 | adcef06ed5012b036922f84e8fc10081ced4894b | /src/main/java/knu/univ/lingvo/coref/MentionExtractor.java | 9edb24e9685bedd39aec0a8670caa86aeefd37a3 | [] | no_license | taarraas/matrixfactorization | 412f5dac471e9c924636dd660c5f12e627056183 | bd62a865f8e7b3263edda412ec7cd12d4d92c433 | refs/heads/master | 2021-01-02T09:20:46.718919 | 2015-09-03T12:49:34 | 2015-09-03T12:49:34 | 41,859,510 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,823 | java | //
// StanfordCoreNLP -- a suite of NLP tools
// Copyright (c) 2009-2011 The Board of Trustees of
// The Leland Stanford Junior University. All Rights Reserved.
//
// 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 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// For more information, bug reports, fixes, contact:
// Christopher Manning
// Dept of Computer Science, Gates 1A
// Stanford CA 94305-9010
// USA
//
package knu.univ.lingvo.coref;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import edu.stanford.nlp.classify.LogisticClassifier;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.trees.HeadFinder;
import edu.stanford.nlp.trees.SemanticHeadFinder;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.tregex.TregexMatcher;
import edu.stanford.nlp.trees.tregex.TregexPattern;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.Generics;
import edu.stanford.nlp.util.Pair;
/**
* Generic mention extractor from a corpus.
*
* @author Jenny Finkel
* @author Mihai Surdeanu
* @author Karthik Raghunathan
* @author Heeyoung Lee
* @author Sudarshan Rangarajan
*/
public class MentionExtractor {
private final HeadFinder headFinder;
protected String currentDocumentID;
protected final Dictionaries dictionaries;
protected final Semantics semantics;
public CorefMentionFinder mentionFinder;
protected StanfordCoreNLP stanfordProcessor;
protected LogisticClassifier<String, String> singletonPredictor;
/** The maximum mention ID: for preventing duplicated mention ID assignment */
protected int maxID = -1;
public static final boolean VERBOSE = false;
public MentionExtractor(Dictionaries dict, Semantics semantics) {
this.headFinder = new SemanticHeadFinder();
this.dictionaries = dict;
this.semantics = semantics;
this.mentionFinder = new RuleBasedCorefMentionFinder(); // Default
}
public void setMentionFinder(CorefMentionFinder mentionFinder)
{
this.mentionFinder = mentionFinder;
}
/**
* Extracts the info relevant for coref from the next document in the corpus
* @return List of mentions found in each sentence ordered according to the tree traversal.
* @throws Exception
*/
public Document nextDoc() throws Exception { return null; }
/**
* Reset so that we start at the beginning of the document collection
*/
public void resetDocs() {
maxID = -1;
currentDocumentID = null;
}
public Document arrange(
Annotation anno,
List<List<CoreLabel>> words,
List<Tree> trees,
List<List<Mention>> unorderedMentions) throws Exception {
return arrange(anno, words, trees, unorderedMentions, null, false);
}
protected int getHeadIndex(Tree t) {
// The trees passed in do not have the CoordinationTransformer
// applied, but that just means the SemanticHeadFinder results are
// slightly worse.
Tree ht = t.headTerminal(headFinder);
if(ht==null) return -1; // temporary: a key which is matched to nothing
CoreLabel l = (CoreLabel) ht.label();
return l.get(CoreAnnotations.IndexAnnotation.class);
}
private String treeToKey(Tree t) {
int idx = getHeadIndex(t);
String key = Integer.toString(idx) + ':' + t.toString();
return key;
}
public Document arrange(
Annotation anno,
List<List<CoreLabel>> words,
List<Tree> trees,
List<List<Mention>> unorderedMentions,
List<List<Mention>> unorderedGoldMentions,
boolean doMergeLabels) throws Exception {
List<List<Mention>> predictedOrderedMentionsBySentence = arrange(anno, words, trees, unorderedMentions, doMergeLabels);
List<List<Mention>> goldOrderedMentionsBySentence = null;
// SieveCoreferenceSystem.debugPrintMentions(System.err, "UNORDERED GOLD MENTIONS:", unorderedGoldMentions);
if(unorderedGoldMentions != null) {
goldOrderedMentionsBySentence = arrange(anno, words, trees, unorderedGoldMentions, doMergeLabels);
}
// SieveCoreferenceSystem.debugPrintMentions(System.err, "ORDERED GOLD MENTIONS:", goldOrderedMentionsBySentence);
return new Document(anno, predictedOrderedMentionsBySentence, goldOrderedMentionsBySentence, dictionaries);
}
/**
* Post-processes the extracted mentions. Here we set the Mention fields required for coref and order mentions by tree-traversal order.
* @param words List of words in each sentence, in textual order
* @param trees List of trees, one per sentence
* @param unorderedMentions List of unordered, unprocessed mentions
* Each mention MUST have startIndex and endIndex set!
* Optionally, if scoring is desired, mentions must have mentionID and originalRef set.
* All the other Mention fields are set here.
* @return List of mentions ordered according to the tree traversal
* @throws Exception
*/
public List<List<Mention>> arrange(
Annotation anno,
List<List<CoreLabel>> words,
List<Tree> trees,
List<List<Mention>> unorderedMentions,
boolean doMergeLabels) throws Exception {
List<List<Mention>> orderedMentionsBySentence = new ArrayList<List<Mention>>();
//
// traverse all sentences and process each individual one
//
int mentionNumber =0;
for (int sent = 0, sz = words.size(); sent < sz; sent ++) {
List<CoreLabel> sentence = words.get(sent);
Tree tree = trees.get(sent);
List<Mention> mentions = unorderedMentions.get(sent);
Map<String, List<Mention>> mentionsToTrees = Generics.newHashMap();
// merge the parse tree of the entire sentence with the sentence words
if(doMergeLabels) mergeLabels(tree, sentence);
//
// set the surface information and the syntactic info in each mention
// startIndex and endIndex MUST be set before!
//
for (Mention mention: mentions) {
mention.sentenceNumber = sent;
mention.mentionNumber = mentionNumber++;
mention.contextParseTree = tree;
mention.sentenceWords = sentence;
mention.originalSpan = new ArrayList<CoreLabel>(mention.sentenceWords.subList(mention.startIndex, mention.endIndex));
if(!((CoreLabel)tree.label()).has(CoreAnnotations.BeginIndexAnnotation.class)) tree.indexSpans(0);
if(mention.headWord==null) {
Tree headTree = ((RuleBasedCorefMentionFinder) mentionFinder).findSyntacticHead(mention, tree, sentence);
mention.headWord = (CoreLabel)headTree.label();
mention.headIndex = mention.headWord.get(CoreAnnotations.IndexAnnotation.class) - 1;
}
if(mention.mentionSubTree==null) {
// mentionSubTree = highest NP that has the same head
Tree headTree = tree.getLeaves().get(mention.headIndex);
if (headTree == null) { throw new RuntimeException("Missing head tree for a mention!"); }
Tree t = headTree;
while ((t = t.parent(tree)) != null) {
if (t.headTerminal(headFinder) == headTree && t.value().equals("NP")) {
mention.mentionSubTree = t;
} else if(mention.mentionSubTree != null){
break;
}
}
if (mention.mentionSubTree == null) {
mention.mentionSubTree = headTree;
}
}
List<Mention> mentionsForTree = mentionsToTrees.get(treeToKey(mention.mentionSubTree));
if(mentionsForTree == null){
mentionsForTree = new ArrayList<Mention>();
mentionsToTrees.put(treeToKey(mention.mentionSubTree), mentionsForTree);
}
mentionsForTree.add(mention);
// generates all fields required for coref, such as gender, number, etc.
mention.process(dictionaries, semantics, this, singletonPredictor);
}
//
// Order all mentions in tree-traversal order
//
List<Mention> orderedMentions = new ArrayList<Mention>();
orderedMentionsBySentence.add(orderedMentions);
// extract all mentions in tree traversal order (alternative: tree.postOrderNodeList())
for (Tree t : tree.preOrderNodeList()) {
List<Mention> lm = mentionsToTrees.get(treeToKey(t));
if(lm != null){
for(Mention m: lm){
orderedMentions.add(m);
}
}
}
//
// find appositions, predicate nominatives, relative pronouns in this sentence
//
findSyntacticRelations(tree, orderedMentions);
assert(mentions.size() == orderedMentions.size());
}
return orderedMentionsBySentence;
}
/**
* Sets the label of the leaf nodes to be the CoreLabels in the given sentence
* The original value() of the Tree nodes is preserved
*/
public static void mergeLabels(Tree tree, List<CoreLabel> sentence) {
int idx = 0;
for (Tree t : tree.getLeaves()) {
CoreLabel cl = sentence.get(idx ++);
String value = t.value();
cl.set(CoreAnnotations.ValueAnnotation.class, value);
t.setLabel(cl);
}
tree.indexLeaves();
}
private static boolean inside(int i, Mention m) {
return i >= m.startIndex && i < m.endIndex;
}
/** Find syntactic relations (e.g., appositives) in a sentence */
private void findSyntacticRelations(Tree tree, List<Mention> orderedMentions) {
markListMemberRelation(orderedMentions);
Set<Pair<Integer, Integer>> appos = Generics.newHashSet();
// TODO: This apposition finding doesn't seem to be very good - what about using "appos" from dependencies?
findAppositions(tree, appos);
markMentionRelation(orderedMentions, appos, "APPOSITION");
Set<Pair<Integer, Integer>> preNomi = Generics.newHashSet();
findPredicateNominatives(tree, preNomi);
markMentionRelation(orderedMentions, preNomi, "PREDICATE_NOMINATIVE");
Set<Pair<Integer, Integer>> relativePronounPairs = Generics.newHashSet();
findRelativePronouns(tree, relativePronounPairs);
markMentionRelation(orderedMentions, relativePronounPairs, "RELATIVE_PRONOUN");
}
/** Find syntactic pattern in a sentence by tregex */
private void findTreePattern(Tree tree, String tregex, Set<Pair<Integer, Integer>> foundPairs) {
try {
TregexPattern tgrepPattern = TregexPattern.compile(tregex);
findTreePattern(tree, tgrepPattern, foundPairs);
} catch (Exception e) {
// shouldn't happen....
throw new RuntimeException(e);
}
}
private void findTreePattern(Tree tree, TregexPattern tgrepPattern, Set<Pair<Integer, Integer>> foundPairs) {
try {
TregexMatcher m = tgrepPattern.matcher(tree);
while (m.find()) {
Tree t = m.getMatch();
Tree np1 = m.getNode("m1");
Tree np2 = m.getNode("m2");
Tree np3 = null;
if(tgrepPattern.pattern().contains("m3")) np3 = m.getNode("m3");
addFoundPair(np1, np2, t, foundPairs);
if(np3!=null) addFoundPair(np2, np3, t, foundPairs);
}
} catch (Exception e) {
// shouldn't happen....
throw new RuntimeException(e);
}
}
private void addFoundPair(Tree np1, Tree np2, Tree t,
Set<Pair<Integer, Integer>> foundPairs) {
Tree head1 = np1.headTerminal(headFinder);
Tree head2 = np2.headTerminal(headFinder);
int h1 = ((CoreMap) head1.label()).get(CoreAnnotations.IndexAnnotation.class) - 1;
int h2 = ((CoreMap) head2.label()).get(CoreAnnotations.IndexAnnotation.class) - 1;
Pair<Integer, Integer> p = new Pair<Integer, Integer>(h1, h2);
foundPairs.add(p);
}
private static final TregexPattern appositionPattern = TregexPattern.compile("NP=m1 < (NP=m2 $.. (/,/ $.. NP=m3))");
private static final TregexPattern appositionPattern2 = TregexPattern.compile("NP=m1 < (NP=m2 $.. (/,/ $.. (SBAR < (WHNP < WP|WDT=m3))))");
private static final TregexPattern appositionPattern3 = TregexPattern.compile("/^NP(?:-TMP|-ADV)?$/=m1 < (NP=m2 $- /^,$/ $-- NP=m3 !$ CC|CONJP)");
private static final TregexPattern appositionPattern4 = TregexPattern.compile("/^NP(?:-TMP|-ADV)?$/=m1 < (PRN=m2 < (NP < /^NNS?|CD$/ $-- /^-LRB-$/ $+ /^-RRB-$/))");
private void findAppositions(Tree tree, Set<Pair<Integer, Integer>> appos) {
findTreePattern(tree, appositionPattern, appos);
findTreePattern(tree, appositionPattern2, appos);
findTreePattern(tree, appositionPattern3, appos);
findTreePattern(tree, appositionPattern4, appos);
}
private static final TregexPattern predicateNominativePattern = TregexPattern.compile("S < (NP=m1 $.. (VP < ((/VB/ < /^(am|are|is|was|were|'m|'re|'s|be)$/) $.. NP=m2)))");
private static final TregexPattern predicateNominativePattern2 = TregexPattern.compile("S < (NP=m1 $.. (VP < (VP < ((/VB/ < /^(be|been|being)$/) $.. NP=m2))))");
private void findPredicateNominatives(Tree tree, Set<Pair<Integer, Integer>> preNomi) {
// String predicateNominativePattern2 = "NP=m1 $.. (VP < ((/VB/ < /^(am|are|is|was|were|'m|'re|'s|be)$/) $.. NP=m2))";
findTreePattern(tree, predicateNominativePattern, preNomi);
findTreePattern(tree, predicateNominativePattern2, preNomi);
}
private static final TregexPattern relativePronounPattern = TregexPattern.compile("NP < (NP=m1 $.. (SBAR < (WHNP < WP|WDT=m2)))");
private void findRelativePronouns(Tree tree, Set<Pair<Integer, Integer>> relativePronounPairs) {
findTreePattern(tree, relativePronounPattern, relativePronounPairs);
}
private static void markListMemberRelation(List<Mention> orderedMentions) {
for(Mention m1 : orderedMentions){
for(Mention m2 : orderedMentions){
// Mark if m2 and m1 are in list relationship
if (m1.isListMemberOf(m2)) {
m2.addListMember(m1);
m1.addBelongsToList(m2);
} else if (m2.isListMemberOf(m1)) {
m1.addListMember(m2);
m2.addBelongsToList(m1);
}
}
}
}
private static void markMentionRelation(List<Mention> orderedMentions, Set<Pair<Integer, Integer>> foundPairs, String flag) {
for(Mention m1 : orderedMentions){
for(Mention m2 : orderedMentions){
// Ignore if m2 and m1 are in list relationship
if (m1.isListMemberOf(m2) || m2.isListMemberOf(m1) || m1.isMemberOfSameList(m2)) {
SieveCoreferenceSystem.logger.finest("Not checking '" + m1 + "' and '" + m2 + "' for " + flag + ": in list relationship");
continue;
}
for(Pair<Integer, Integer> foundPair: foundPairs){
if((foundPair.first == m1.headIndex && foundPair.second == m2.headIndex)){
if(flag.equals("APPOSITION")) m2.addApposition(m1);
else if(flag.equals("PREDICATE_NOMINATIVE")) m2.addPredicateNominatives(m1);
else if(flag.equals("RELATIVE_PRONOUN")) m2.addRelativePronoun(m1);
else throw new RuntimeException("check flag in markMentionRelation (dcoref/MentionExtractor.java)");
}
}
}
}
}
/**
* Finds the tree the matches this span exactly
* @param tree Leaves must be indexed!
* @param first First element in the span (first position has offset 1)
* @param last Last element included in the span (first position has offset 1)
*/
public static Tree findExactMatch(Tree tree, int first, int last) {
List<Tree> leaves = tree.getLeaves();
int thisFirst = ((CoreMap) leaves.get(0).label()).get(CoreAnnotations.IndexAnnotation.class);
int thisLast = ((CoreMap) leaves.get(leaves.size() - 1).label()).get(CoreAnnotations.IndexAnnotation.class);
if(thisFirst == first && thisLast == last) {
return tree;
} else {
Tree [] kids = tree.children();
for(Tree k: kids){
Tree t = findExactMatch(k, first, last);
if(t != null) return t;
}
}
return null;
}
/** Load Stanford Processor: skip unnecessary annotator */
protected static StanfordCoreNLP loadStanfordProcessor(Properties props) {
boolean replicateCoNLL = Boolean.parseBoolean(props.getProperty(Constants.REPLICATECONLL_PROP, "false"));
Properties pipelineProps = new Properties(props);
StringBuilder annoSb = new StringBuilder("");
if (!Constants.USE_GOLD_POS && !replicateCoNLL) {
annoSb.append("pos, lemma");
} else {
annoSb.append("lemma");
}
if(Constants.USE_TRUECASE) {
annoSb.append(", truecase");
}
if (!Constants.USE_GOLD_NE && !replicateCoNLL) {
annoSb.append(", ner");
}
if (!Constants.USE_GOLD_PARSES && !replicateCoNLL) {
annoSb.append(", parse");
}
String annoStr = annoSb.toString();
SieveCoreferenceSystem.logger.info("MentionExtractor ignores specified annotators, using annotators=" + annoStr);
pipelineProps.put("annotators", annoStr);
return new StanfordCoreNLP(pipelineProps, false);
}
public static void initializeUtterance(List<CoreLabel> tokens) {
for(CoreLabel l : tokens){
if (l.get(CoreAnnotations.UtteranceAnnotation.class) == null) {
l.set(CoreAnnotations.UtteranceAnnotation.class, 0);
}
}
}
}
| [
"[email protected]"
] | |
8a385bd1e0ab0dc0f6f580ac64099995fec0e264 | f0d25d83176909b18b9989e6fe34c414590c3599 | /app/src/main/java/com/google/android/gms/location/places/zzh.java | 56cbe90f3515efeae2815adbeac2fc6dfd6b0166 | [] | no_license | lycfr/lq | e8dd702263e6565486bea92f05cd93e45ef8defc | 123914e7c0d45956184dc908e87f63870e46aa2e | refs/heads/master | 2022-04-07T18:16:31.660038 | 2020-02-23T03:09:18 | 2020-02-23T03:09:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,502 | java | package com.google.android.gms.location.places;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.gms.common.internal.safeparcel.zzb;
import java.util.ArrayList;
import java.util.List;
public final class zzh implements Parcelable.Creator<PlaceFilter> {
public final /* synthetic */ Object createFromParcel(Parcel parcel) {
int zzd = zzb.zzd(parcel);
boolean z = false;
ArrayList<zzo> arrayList = null;
ArrayList<String> arrayList2 = null;
ArrayList<Integer> arrayList3 = null;
while (parcel.dataPosition() < zzd) {
int readInt = parcel.readInt();
switch (65535 & readInt) {
case 1:
arrayList3 = zzb.zzB(parcel, readInt);
break;
case 3:
z = zzb.zzc(parcel, readInt);
break;
case 4:
arrayList = zzb.zzc(parcel, readInt, zzo.CREATOR);
break;
case 6:
arrayList2 = zzb.zzC(parcel, readInt);
break;
default:
zzb.zzb(parcel, readInt);
break;
}
}
zzb.zzF(parcel, zzd);
return new PlaceFilter((List<Integer>) arrayList3, z, (List<String>) arrayList2, (List<zzo>) arrayList);
}
public final /* synthetic */ Object[] newArray(int i) {
return new PlaceFilter[i];
}
}
| [
"[email protected]"
] | |
27c5dff81576a36df4328292963f895d8fd6bd30 | 4c10b7aaf7d867f47a0626d91a76f54df9193bfb | /performance-counter/src/main/java/com/cxy/performancecounter/v1/metricsStorage/RedisMetricsStorage.java | 72715714b3a2dcf935c168da74f439a0b1d6f325 | [] | no_license | currynice/demo | 390d8ec7d9094a9f5cc57fae3a8f7a5b41b7f9ae | b13617c15dc1bf61589aca83d462aada70fd4855 | refs/heads/master | 2023-08-08T18:51:37.488014 | 2022-04-19T07:36:44 | 2022-04-19T07:36:44 | 198,806,075 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,398 | java | package com.cxy.performancecounter.v1.metricsStorage;
import com.cxy.performancecounter.utils.SpringCtxUtil;
import com.cxy.performancecounter.v1.api.RequestInfo;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import java.io.IOException;
import java.util.*;
/**
* Description: todo </br>
* Date: 2021/4/10 12:30
*
* @author :cxy </br>
* @version : 1.0 </br>
*/
public class RedisMetricsStorage implements MetricsStorage {
//ไธๅกๅ็ผ
private static final String Business_Prefix = "api@";
@Override
public void saveRequestInfo(RequestInfo requestInfo) {
//zadd
String apiName = requestInfo.getApiName();
ZSetOperations<String,Object> zSetOperations = SpringCtxUtil.getBean(ZSetOperations.class);
ObjectMapper objectMapper = new ObjectMapper();
try {
String value = objectMapper.writeValueAsString(requestInfo);
zSetOperations.add(Business_Prefix+apiName,value,requestInfo.getTimestamp());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
//todo
@Override
public List<RequestInfo> getRequestInfos(String apiName, long startTimestamp, long endTimestamp) {
//...
ObjectMapper objectMapper = new ObjectMapper();
List<RequestInfo> requestInfos = new ArrayList<>();
ZSetOperations<String,Object> zSetOperations = SpringCtxUtil.getBean(ZSetOperations.class);
Set<Object> datas = zSetOperations.range(Business_Prefix+apiName, startTimestamp, endTimestamp);
if(datas==null){
return requestInfos;
}
for (Object obj : datas) {
RequestInfo requestInfo = null;
try {
requestInfo = objectMapper.readValue((String) obj, RequestInfo.class);
} catch (IOException e) {
e.printStackTrace();
}
requestInfos.add(requestInfo);
}
return requestInfos;
}
@Override
public Map<String, List<RequestInfo>> getRequestInfos(long startTimestamp, long endTimestamp) {
Map<String, List<RequestInfo>> map = new LinkedHashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
RedisTemplate<String,Object> redisTemplate = SpringCtxUtil.getBean(RedisTemplate.class);
//todo : change to scan
Set<String> keyset = redisTemplate.keys(Business_Prefix+"*");
if(null==keyset){
return map;
}
ZSetOperations<String,Object> zSetOperations = SpringCtxUtil.getBean(ZSetOperations.class);
for (String key : keyset) {
Set<Object> datas = zSetOperations.rangeByScore(key, startTimestamp, endTimestamp);
List<RequestInfo> requestInfos = new ArrayList<>();
for (Object obj : datas) {
RequestInfo requestInfo = null;
try {
requestInfo = objectMapper.readValue((String) obj, RequestInfo.class);
} catch (IOException e) {
e.printStackTrace();
}
requestInfos.add(requestInfo);
}
map.put(key, requestInfos);
}
return map;
}
}
| [
"[email protected]"
] | |
291e459cd30bfa7226e2a1acca1040b1bb7d66fe | 95e0f5df2b570d7be562fadcecabe22c162610df | /common-service/src/main/java/com/cloud/common/model/BaseModel.java | 079ea6261046cb0db9f0fd9759b7e221f570d0a0 | [] | no_license | yijin0120/spring-cloud-demo | d4395d276066b07680d4183b821aac48d35bde4a | 3657fa1dee59be061c40ae748de617a94f99c167 | refs/heads/master | 2023-08-14T03:24:37.313003 | 2019-09-30T03:34:34 | 2019-09-30T03:34:34 | 210,277,442 | 0 | 0 | null | 2019-09-23T06:11:44 | 2019-09-23T06:11:43 | null | UTF-8 | Java | false | false | 1,344 | java | package com.cloud.common.model;
import java.io.Serializable;
import java.util.Date;
/**
* ็ฑปๆๆนๆณ็ๅ่ฝๆ่ฟฐ :ๅฎไฝๅบ็ฑป
*
* @author: wesley.wang
* @date: 2018-03-14 10:28
*/
public class BaseModel implements Serializable{
/**
* ๆฐๆฎๅบไธป้ฎ
*/
private Integer id;
/**
* ๅๅปบๆถ้ดๆฅๆ็ฑปๅ
*/
private Date createDate;
/**
* ๅๅปบไบบ
*/
private Integer createBy;
/**
* ไฟฎๆนๆถ้ดๆฅๆ็ฑปๅ
*/
private Date updateDate;
/**
* ๆดๆฐไบบ
*/
private Integer updateBy;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Integer getCreateBy() {
return createBy;
}
public void setCreateBy(Integer createBy) {
this.createBy = createBy;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Integer getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Integer updateBy) {
this.updateBy = updateBy;
}
}
| [
"[email protected]"
] | |
e0b1a7e8622f50a97cdc112ee106434e5856f41c | a7b21ca7f172a891d753126688d6a83464220cdf | /src/com/JavaCollectionFramework/LinkedHashSet/LinedHashSet1.java | 9dd78c17f178f76d11fde8617efecaf97c2ee68b | [] | no_license | gaurav-kj/JavaLearningP1 | b810b77557448f9291775d0996f6e7490055d8a7 | a04f2db427b090ff42931a29b1c1cda595ed6cde | refs/heads/master | 2023-07-26T22:18:01.729721 | 2021-09-07T11:00:09 | 2021-09-07T11:00:09 | 395,533,197 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 504 | java | package com.JavaCollectionFramework.LinkedHashSet;
import java.util.*;
class LinkedHashSet1{
public static void main(String args[]){
//Creating HashSet and adding elements
LinkedHashSet<String> set=new LinkedHashSet();
set.add("One");
set.add("Two");
set.add("Three");
set.add("Four");
set.add("Five");
Iterator<String> i=set.iterator();
while(i.hasNext())
{
System.out.println(i.next());
}
}
}
| [
"[email protected]"
] | |
80d75045bfca5e74377356dc7c5bfe7b440e99a0 | 9698143c08450693ba5c60663357cff8ac05f5c0 | /src/main/java/com/tuitaking/tree/CBTTree_919.java | 97697eb09beed362468e350c28dc97e3bd281bd6 | [] | no_license | TuitaKing/leetcode | fac76a1d8d0094488d786aa93b5ce1bd59d936ae | 474f94a6fca6b453c83461cbc402a68f31a14a7e | refs/heads/master | 2023-02-18T09:27:05.277848 | 2021-01-21T08:19:40 | 2021-01-21T08:19:40 | 263,050,229 | 0 | 0 | null | 2020-10-15T08:09:11 | 2020-05-11T13:27:11 | Java | UTF-8 | Java | false | false | 3,485 | java | package com.tuitaking.tree;
import java.util.ArrayList;
import java.util.List;
/**
* ๅฎๅ
จไบๅๆ ๆฏๆฏไธๅฑ๏ผ้คๆๅไธๅฑๅค๏ผ้ฝๆฏๅฎๅ
จๅกซๅ
๏ผๅณ๏ผ่็นๆฐ่พพๅฐๆๅคง๏ผ็๏ผๅนถไธๆๆ็่็น้ฝๅฐฝๅฏ่ฝๅฐ้ไธญๅจๅทฆไพงใ
*
* ่ฎพ่ฎกไธไธช็จๅฎๅ
จไบๅๆ ๅๅงๅ็ๆฐๆฎ็ปๆ CBTInserter๏ผๅฎๆฏๆไปฅไธๅ ็งๆไฝ๏ผ
*
* CBTInserter(TreeNode root)ไฝฟ็จๅคด่็นไธบroot็็ปๅฎๆ ๅๅงๅ่ฏฅๆฐๆฎ็ปๆ๏ผ
* CBTInserter.insert(int v) ๅๆ ไธญๆๅ
ฅไธไธชๆฐ่็น๏ผ่็น็ฑปๅไธบ TreeNode๏ผๅผไธบ v ใไฝฟๆ ไฟๆๅฎๅ
จไบๅๆ ็็ถๆ๏ผๅนถ่ฟๅๆๅ
ฅ็ๆฐ่็น็็ถ่็น็ๅผ๏ผ
* CBTInserter.get_root() ๅฐ่ฟๅๆ ็ๅคด่็นใ
*
*
* ็คบไพ 1๏ผ
*
* ่พๅ
ฅ๏ผinputs = ["CBTInserter","insert","get_root"], inputs = [[[1]],[2],[]]
* ่พๅบ๏ผ[null,1,[1,2]]
* ็คบไพ 2๏ผ
*
* ่พๅ
ฅ๏ผinputs = ["CBTInserter","insert","insert","get_root"], inputs = [[[1,2,3,4,5,6]],[7],[8],[]]
* ่พๅบ๏ผ[null,3,4,[1,2,3,4,5,6,7,8]]
*
* ๆ็คบ๏ผ
*
* ๆๅ็ปๅฎ็ๆ ๆฏๅฎๅ
จไบๅๆ ๏ผไธๅ
ๅซ1ๅฐ1000ไธช่็นใ
* ๆฏไธชๆต่ฏ็จไพๆๅค่ฐ็จCBTInserter.insertๆไฝ10000ๆฌกใ
* ็ปๅฎ่็นๆๆๅ
ฅ่็น็ๆฏไธชๅผ้ฝๅจ0ๅฐ5000ไน้ดใ
*
* ๆฅๆบ๏ผๅๆฃ๏ผLeetCode๏ผ
* ้พๆฅ๏ผhttps://leetcode-cn.com/problems/complete-binary-tree-inserter
* ่ไฝๆๅฝ้ขๆฃ็ฝ็ปๆๆใๅไธ่ฝฌ่ฝฝ่ฏท่็ณปๅฎๆนๆๆ๏ผ้ๅไธ่ฝฌ่ฝฝ่ฏทๆณจๆๅบๅคใ
*/
public class CBTTree_919 {
private TreeNode rootNode;
public CBTTree_919(TreeNode root) {
this.rootNode=root;
}
public int insert(int v) {
if(rootNode==null){
rootNode=new TreeNode(v);
}
List<List<TreeNode>> level=new ArrayList<>();
helper(rootNode,level,0);
if(level.size()>0){
int depth=level.size();
List<TreeNode> leafList=level.get(level.size()-1);
List<TreeNode> parentList=null;
if(level.size()<=1){
parentList=level.get(0);
}else {
parentList=level.get(level.size()-2);
}
int leafSize=leafList.size();
int nodes=(int)Math.pow(2,depth-1);
TreeNode parent=rootNode;
if(leafSize<nodes){
parent=parentList.get(((leafSize)/2));
}else if(leafSize==nodes){
parent=leafList.get(0);
}
if(parent.left==null){
parent.left=new TreeNode(v);
}else if(parent.right==null){
parent.right=new TreeNode(v);
}
return parent.val;
}
return 0;
}
private void helper(TreeNode node,List<List<TreeNode>> level,int depth){
if(node==null){
return;
}
if(level.size()==depth){
level.add(new ArrayList<TreeNode>());
}
level.get(depth).add(node);
helper(node.left,level,depth+1);
helper(node.right,level,depth+1);
}
public TreeNode get_root() {
return rootNode;
}
//todo ไฝฟ็จๆปกไบๅๆ ็ๆง่ดจ๏ผไปๆฐ็ปไธญๆณๅๆณ๏ผ
public static void main(String[] args) {
TreeNode node=TreeUtils.generateArrayToTree(new Integer[]{1,2,3,4,5,6});
CBTTree_919 cbtTree_919=new CBTTree_919(node);
System.out.println(cbtTree_919.insert(7));
System.out.println(cbtTree_919.insert(8));
System.out.println(cbtTree_919.get_root().val);
}
}
| [
"[email protected]"
] | |
ebef96f3052212a5001b1c9e785c7bddc47f34e5 | 7b75c5eb9b587780c05a617544720760f639ca4f | /challenge-eventstore-master/src/main/java/net/intelie/challenges/Event.java | 2f9c7c6495bbfed23d745ddf3fd8708c7b3ae5c3 | [] | no_license | krazybones/challenge-two | 48191f1775100b2475ea24af3324c2ec33a7b3b8 | 4f515a676fb8af51405a4c1901f88d023fbb63ea | refs/heads/master | 2023-07-31T11:14:28.541047 | 2021-09-19T20:21:28 | 2021-09-19T20:21:28 | 408,226,466 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 436 | java | package net.intelie.challenges;
import java.time.LocalDateTime;
/**
* This is just an event stub, feel free to expand it if needed.
*/
public class Event {
private String type;
private LocalDateTime timestamp;
public Event(String type, LocalDateTime timestamp) {
this.type = type;
this.timestamp = timestamp;
}
public String getType() {
return type;
}
public LocalDateTime getTimestamp() {
return timestamp;
}
}
| [
"[email protected]"
] | |
3293bd307211b77840473a2d0507d42c0a2dc8f5 | 387e3a568820b9307dc1d0aa65a7b2e535d2959a | /OrdenamientoSeleccion/PruebaOrdenamientoSeleccion.java | abdc33dd449841eb3497f924c4be2b4a992bb705 | [] | no_license | Alexgallo91/OrdenamientoBusquedaArreglos | 9b9173b574e312e87104dae30e7cfe3a6aecca3b | 085d8ceaf2f2434780e11c9aea8969b8eef41f51 | refs/heads/master | 2021-01-19T22:34:37.627475 | 2017-04-20T06:27:56 | 2017-04-20T06:27:56 | 88,828,940 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 480 | java |
package OrdenamientoSeleccion;
public class PruebaOrdenamientoSeleccion {
public static void main(String []args)
{
OrdenamientoSeleccion arregloOrden = new OrdenamientoSeleccion(10);
System.out.println("Arreglo desordenado");
System.out.println(arregloOrden);
arregloOrden.ordenar();
System.out.println("Arreglo ordenado");
System.out.println(arregloOrden);
}
}
| [
"[email protected]"
] | |
1206335080ff91ce69511bdcb1bd00baf7dec62f | c94dd358fa90697d8102d55a1fa9e793979fb3ad | /src/main/java/com/nomizo/controller/ProductController.java | 095659ec7f064fe5e7c60ca152b4757e23b3c452 | [] | no_license | nomizo-iox/Java-SpringBootCRUDv2 | a5a1f4e1452f368cb9f7720a0c7a09a99cab3798 | c92e0c0b588e6b57b67a1c0d07cd428cb6492196 | refs/heads/master | 2021-02-07T01:03:12.516647 | 2020-03-01T03:18:09 | 2020-03-01T03:18:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,492 | java | package com.nomizo.controller;
import com.nomizo.logs.Logging;
import com.nomizo.model.Product;
import com.nomizo.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class ProductController {
@Autowired
ProductService productService;
@Autowired
Logging logging;
/* POST METHOD */
@PostMapping("/addProduct")
public Product addProduct (@RequestBody Product product) { return productService.saveProduct(product); }
@PostMapping("/addProducts")
public List<Product> addProducts(@RequestBody List<Product> productList) { return productService.saveProducts(productList); }
/* GET METHOD */
@GetMapping("/getProducts")
public List<Product> findAllProducts() {return productService.getProducts(); }
@GetMapping("/product/{id}")
public Product findProductById (@PathVariable int id) { return productService.getProductById(id); }
@GetMapping("/product/{name}")
public Product findProductByName (@PathVariable String name) { return productService.getProductByName(name); }
/* PUT METHOD */
@PutMapping("/update")
public Product updateProduct(@RequestBody Product product) {return productService.updateProduct(product); }
/* DELETE METHOD */
@DeleteMapping("/delete/{id}")
public String deleteProduct(@PathVariable int id) { return productService.deleteProductId(id); }
}
| [
"[email protected]"
] | |
6c622f9f621d5c954fc277e2b7a930cbe089fcf9 | 3a40eca6c8793ac2d543213c0214a4fd1fd5063c | /z_JB0634/src/com/Eclipse_Tips/Eclipse_Tips.java | 3fa0230855ed2b2ecd472106c3eb2c8d4dd36489 | [] | no_license | TejkumarKempaiah/JB0634 | 8d0dc006b6e230aca995bb07a5379eaf30b5d637 | 369fe3713a5fd9d820425190d594b80d8f1f8730 | refs/heads/master | 2020-04-15T20:34:35.998744 | 2019-02-15T05:16:36 | 2019-02-15T05:16:36 | 164,999,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package com.Eclipse_Tips;
public class Eclipse_Tips {
public static void main(String[] args) {
Phones p1 = new Phones();
}
}
| [
"[email protected]"
] | |
f735903bae07b34dfc761dad7777f5e7b4abc473 | d9b10fe6b9f052866956354842af9dc31ac4d8fa | /app/src/p_projectone/java/com/project/one/ProjectOneActivity.java | d37f00a719f0d8685ea765ab5eb115192998b504 | [] | no_license | NicolasLv/plugindemo | b6e375555fc29c97ee36b2befdbe778381e49f9b | bff54c7d583cb11276c634723574c22602527370 | refs/heads/master | 2023-03-19T00:33:23.229147 | 2018-05-03T10:09:09 | 2018-05-03T10:09:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 354 | java | package com.project.one;
import android.app.Activity;
import android.os.Bundle;
import com.example.zengbo1.plugintest.R;
public class ProjectOneActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_project_one);
}
}
| [
"[email protected]"
] | |
dc327be64ff2b8f10b243c283b1999c8fb8f440e | 51aef8e206201568d04fb919bf54a3009c039dcf | /trunk/src/com/jmex/audio/openal/OpenALPropertyTool.java | fc582fa6939f87b3646965af546788d5a41439c6 | [] | no_license | lihak/fairytale-soulfire-svn-to-git | 0b8bdbfcaf774f13fc3d32cc3d3a6fae64f29c81 | a85eb3fc6f4edf30fef9201902fcdc108da248e4 | refs/heads/master | 2021-02-11T15:25:47.199953 | 2015-12-28T14:48:14 | 2015-12-28T14:48:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,069 | java | /*
* Copyright (c) 2003-2008 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jmex.audio.openal;
import org.lwjgl.openal.AL10;
import com.jmex.audio.player.AudioPlayer;
/**
* OpenAL utility class - used for keeping code access to openal properties in a
* single location.
*
* @author Joshua Slack
* @version $Id: OpenALPropertyTool.java,v 1.4 2007/08/18 02:58:34 renanse Exp $
*/
public class OpenALPropertyTool {
public static void applyProperties(AudioPlayer player, OpenALSource source) {
applyChannelVolume(source, player.getVolume());
applyChannelPitch(source, player.getPitch());
applyChannelMaxVolume(source, player.getMaxVolume());
applyChannelMinVolume(source, player.getMinVolume());
applyChannelRolloff(source, player.getRolloff());
applyChannelMaxAudibleDistance(source, player.getMaxDistance());
applyChannelReferenceDistance(source, player.getRefDistance());
}
public static void applyChannelVolume(OpenALSource source, float volume) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_GAIN, volume);
}
public static void applyChannelMaxVolume(OpenALSource source, float maxVolume) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_MAX_GAIN, maxVolume);
}
public static void applyChannelMinVolume(OpenALSource source, float minVolume) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_MIN_GAIN, minVolume);
}
public static void applyChannelRolloff(OpenALSource source, float rolloff) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_ROLLOFF_FACTOR, rolloff);
}
public static void applyChannelMaxAudibleDistance(OpenALSource source, float maxDistance) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_MAX_DISTANCE, maxDistance);
}
public static void applyChannelReferenceDistance(OpenALSource source, float refDistance) {
if (refDistance == 0) refDistance = 0.0000000001f; // 0 causes issues on some cards and the open al spec shows this value used in division
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_REFERENCE_DISTANCE, refDistance);
}
public static void applyChannelPitch(OpenALSource source, float pitch) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_PITCH, pitch);
}
}
| [
"[email protected]"
] | |
5cc4fc061707dd48ea79bcf8a2778f5cddf75055 | 86158d8fa9c3b44e561f61c87136125f72cc3e28 | /auburn/50 _ mobile0/mobile0/androidx/lifecycle/MethodCallsLogger.java | e80c33cc66e6e5471f4f9ef2394ae7eec99e9583 | [] | no_license | congtrung2k1/CTF-Write-up | 3e0cecb4888759d6da2a29c5213f249637fc1713 | fadbdceed4713d273d5c9268ff5edd10438bad9d | refs/heads/master | 2021-11-11T16:39:10.912008 | 2021-10-21T18:26:51 | 2021-10-21T18:26:51 | 230,739,687 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 770 | java | //
// Decompiled by Procyon v0.5.36
//
package androidx.lifecycle;
import java.util.HashMap;
import java.util.Map;
public class MethodCallsLogger
{
private Map<String, Integer> mCalledMethods;
public MethodCallsLogger() {
this.mCalledMethods = new HashMap<String, Integer>();
}
public boolean approveCall(final String s, final int n) {
final Integer n2 = this.mCalledMethods.get(s);
boolean b = false;
int intValue;
if (n2 != null) {
intValue = n2;
}
else {
intValue = 0;
}
final boolean b2 = (intValue & n) != 0x0;
this.mCalledMethods.put(s, intValue | n);
if (!b2) {
b = true;
}
return b;
}
}
| [
"[email protected]"
] | |
18e880bc7059d603a9a89719ce748860400434e5 | 8571ffca35f45456d1db8f0b70d89915060f401e | /app/src/main/java/com/bpbatam/enterprise/bbs/BBS_add_berita.java | a92fcba4fa0d73ad36b7bb5a62e1873c21639b06 | [] | no_license | bernadsatriani/EnterpriseBatam | 59e1bb5ec01cfa59dfadaef40b22618f62068bc9 | 1dac4f4ed8afb959ff3b316b33e305508e05c3b2 | refs/heads/master | 2020-04-07T05:42:19.089307 | 2017-04-16T05:03:46 | 2017-04-16T05:03:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,918 | java | package com.bpbatam.enterprise.bbs;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.bpbatam.AppConstant;
import com.bpbatam.AppController;
import com.bpbatam.enterprise.R;
import com.bpbatam.enterprise.model.BBS_CATEGORY;
import com.bpbatam.enterprise.model.BBS_Insert;
import com.bpbatam.enterprise.model.net.NetworkManager;
import org.json.JSONObject;
import java.io.File;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by setia.n on 11/3/2016.
*/
public class BBS_add_berita extends AppCompatActivity {
int CODE_FILE = 225;
ImageView imgAvatar, imgDelete, imgBack, imgPrioriti;
TextView txtName, txtJudul, txtAttach, txtSize, txtPublikasi, txtKategori, txtPrioriti;
EditText txtHeader;
String sName, sJudul, sIsi, sSize,
sFile_Path, sFile_Size, sFile_Type, sBbs_Date, sBbs_read;
SimpleAdapter adpGridView;
BBS_CATEGORY bbs_category;
BBS_Insert bbsInsert;
String[] lstCategory;
Uri uri;
String sCategory_Id, sPriority_id;
RelativeLayout layoutLampiran, layoutAttachment, layoutKategori, layout_btn_status;
boolean bDelete, bUpload;
String sBBsId = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_berita);
bDelete = false;
bUpload = false;
sCategory_Id = "";
sPriority_id = "0";
InitControl();
sName = AppConstant.USER_NAME;
try{
sJudul = getIntent().getExtras().getString("BBS_JUDUL").trim();
}catch (Exception e){
sJudul = "";
}
try{
sIsi = getIntent().getExtras().getString("BBS_ISI").trim();
}catch (Exception e){
sIsi = "";
}
try{
sSize = getIntent().getExtras().getString("BBS_SIZE").trim();
}catch (Exception e){
sSize = "";
}
try{
sBbs_Date = getIntent().getExtras().getString("BBS_DATE").trim();
}catch (Exception e){
sBbs_Date = "";
}
sBbs_Date = AppController.getInstance().getDate();
try{
sBbs_read = getIntent().getExtras().getString("BBS_READ").trim();
}catch (Exception e){
sBbs_read = "";
}
String sFileName = AppController.getInstance().getFileName(AppConstant.BBS_LINK);
txtName.setText(sName);
txtJudul.setText(sJudul);
txtAttach.setText(sFileName);
txtSize.setText(sSize);
if (sSize.equals("")) layoutAttachment.setVisibility(View.GONE);
//FillSpinnerCategory();
}
void InitControl(){
imgPrioriti = (ImageView)findViewById(R.id.img_prioriti);
txtPrioriti = (TextView)findViewById(R.id.text_prioriti);
layout_btn_status = (RelativeLayout)findViewById(R.id.layout_btn_status);
layout_btn_status.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent mIntent = new Intent(getBaseContext(), BBS_Prioritas.class);
startActivityForResult(mIntent, 20);
}
});
txtKategori = (TextView)findViewById(R.id.text_kategori);
layoutKategori = (RelativeLayout)findViewById(R.id.layout_kategori);
layoutKategori.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent mIntent = new Intent(getBaseContext(), BBS_category_list.class);
startActivityForResult(mIntent, 10);
}
});
txtPublikasi = (TextView)findViewById(R.id.textLabel2);
imgBack = (ImageView)findViewById(R.id.img_back);
imgAvatar = (ImageView)findViewById(R.id.img_avatar);
imgDelete = (ImageView)findViewById(R.id.img_delete);
txtName = (TextView)findViewById(R.id.text_Name);
txtJudul = (TextView)findViewById(R.id.text_judul);
txtAttach = (TextView)findViewById(R.id.lbl_attach);
txtSize = (TextView)findViewById(R.id.lbl_size);
//spnStatus = (Spinner)findViewById(R.id.spinner_status);
//spnBuletin = (Spinner)findViewById(R.id.spinner_caetogory);
txtHeader = (EditText)findViewById(R.id.text_header);
layoutLampiran = (RelativeLayout)findViewById(R.id.layout_lampiran);
layoutAttachment = (RelativeLayout)findViewById(R.id.layout_attachment1);
imgBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
txtHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layoutLampiran.setVisibility(View.VISIBLE);
}
});
txtPublikasi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sCategory_Id.equals("")){
CustomeDialog();
}else{
UpdateBSB();
}
}
});
layoutLampiran.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, CODE_FILE);
}
});
layoutLampiran.setVisibility(View.VISIBLE);
imgDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DeleteBBSAttachment();
}
});
}
void CustomeDialog(){
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_dialog);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
//dialog.setTitle("Title...");
TextView txtDismis = (TextView)dialog.findViewById(R.id.text_dismiss);
TextView txtDialog = (TextView)dialog.findViewById(R.id.text_dialog);
txtDialog.setText("Kategori belum dipilih!");
txtDismis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
void FillSpinner(){
String[] stsStatus = {"tinggi", "sedang", "rendah"};
ArrayList<HashMap<String, Object>> lstGrid;
HashMap<String, Object> mapGrid;
lstGrid = new ArrayList<HashMap<String,Object>>();
mapGrid = new HashMap<String, Object>();
mapGrid.put("img", R.drawable.ball_red);
mapGrid.put("description", "tinggi");
lstGrid.add(mapGrid);
mapGrid = new HashMap<String, Object>();
mapGrid.put("img", R.drawable.ball_yellow);
mapGrid.put("description", "sedang");
lstGrid.add(mapGrid);
mapGrid = new HashMap<String, Object>();
mapGrid.put("img", R.drawable.ball_green);
mapGrid.put("description", "rendah");
lstGrid.add(mapGrid);
adpGridView = new SimpleAdapter(this, lstGrid, R.layout.spinner_row,
new String[] {"img","description"},
new int[] {R.id.img_status, R.id.text_isi});
//spnStatus.setAdapter(adpGridView);
}
public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data) {
if (requestCode == CODE_FILE){
if (resultCode == Activity.RESULT_OK) {
uri = data.getData();
File f = new File(uri.getPath());
sFile_Path = f.getPath();
sFile_Size = Long.toString(f.length());
sFile_Type = f.getPath().substring(f.getPath().lastIndexOf(".") + 1); // Without dot jpg, png
if (sFile_Type.length() > 5){
//Image
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(uri,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
f = new File(picturePath);
sFile_Path = f.getPath();
sFile_Size = Long.toString(f.length());
sFile_Type = f.getPath().substring(f.getPath().lastIndexOf(".") + 1); // Without dot jpg, png
}else{
//File
}
bUpload = true;
layoutAttachment.setVisibility(View.VISIBLE);
DecimalFormat precision = new DecimalFormat("0.00");
double dFileSize = (double) f.length() / 1024;
txtAttach.setText(AppController.getInstance().getFileName(sFile_Path));
txtSize.setText("(" + precision.format(dFileSize) + " kb)" );
}
}else if (requestCode == 10){
if (resultCode == Activity.RESULT_OK) {
sCategory_Id = "";
Bundle res = data.getExtras();
sCategory_Id = res.getString("KODE");
txtKategori.setText(res.getString("DES"));
}
}else if (requestCode == 20){
if (resultCode == Activity.RESULT_OK) {
sPriority_id= "0";
Bundle res = data.getExtras();
sPriority_id = res.getString("KODE");
FillPrioriti();
}
}
}
void FillPrioriti(){
switch (sPriority_id){
case "1":
imgPrioriti.setColorFilter(getResources().getColor(R.color.colorRedCircle));
txtPrioriti.setText("Tinggi");
break;
case "0":
imgPrioriti.setColorFilter(getResources().getColor(R.color.colorGreen));
txtPrioriti.setText("Sedang");
break;
case "2":
imgPrioriti.setColorFilter(getResources().getColor(R.color.colorRendah));
txtPrioriti.setText("Rendah");
break;
}
}
void DeleteBBS(){
try {
AppConstant.HASHID = AppController.getInstance().getHashId(AppConstant.USER);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try{
BBS_Insert param = new BBS_Insert(AppConstant.HASHID, AppConstant.USER, AppConstant.REQID,
Integer.toString(AppConstant.EMAIL_ID));
Call<BBS_Insert> call = NetworkManager.getNetworkService(this).postBBSDelete(param);
call.enqueue(new Callback<BBS_Insert>() {
@Override
public void onResponse(Call<BBS_Insert> call, Response<BBS_Insert> response) {
int code = response.code();
if (code == 200){
layoutAttachment.setVisibility(View.GONE);
DeleteBBSAttachment();
}
}
@Override
public void onFailure(Call<BBS_Insert> call, Throwable t) {
}
});
}catch (Exception e){
}
}
void DeleteBBSAttachment(){
try {
AppConstant.HASHID = AppController.getInstance().getHashId(AppConstant.USER);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try{
BBS_Insert param = new BBS_Insert(AppConstant.HASHID, AppConstant.USER, AppConstant.REQID,
Integer.toString(AppConstant.EMAIL_ID), AppConstant.BBS_LINK);
Call<BBS_Insert> call = NetworkManager.getNetworkService(this).postBBSDeleteAttachment(param);
call.enqueue(new Callback<BBS_Insert>() {
@Override
public void onResponse(Call<BBS_Insert> call, Response<BBS_Insert> response) {
int code = response.code();
if (code == 200){
bDelete = true;
layoutAttachment.setVisibility(View.GONE);
}
}
@Override
public void onFailure(Call<BBS_Insert> call, Throwable t) {
}
});
}catch (Exception e){
}
}
void UpdateBSB(){
/*switch (spnBuletin.getSelectedItemPosition()){
case 0:
sCategory_Id = "QNQ";
break;
case 1:
sCategory_Id = "PDK";
break;
case 2:
sCategory_Id = "FRU";
break;
case 3:
sCategory_Id = "RUL";
break;
case 4:
sCategory_Id = "KDS";
break;
case 5:
sCategory_Id = "KSU";
break;
case 6:
sCategory_Id = "INB";
break;
case 7:
sCategory_Id = "PGU";
break;
case 8:
sCategory_Id = "PDB";
break;
default:
sCategory_Id = "QNQ";
break;
}*/
try {
AppConstant.HASHID = AppController.getInstance().getHashId(AppConstant.USER);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try{
BBS_Insert updateParam = new BBS_Insert(
AppConstant.HASHID,
AppConstant.USER,
AppConstant.REQID,
txtJudul.getText().toString().trim(),
AppConstant.USER_NAME,
sBbs_Date,
sBbs_Date,
txtHeader.getText().toString().trim(),
sBbs_Date,
sPriority_id,
"0",
sCategory_Id,
AppConstant.USER,
"0"
);
sJudul = txtJudul.getText().toString().trim();
JSONObject jsonObject = new JSONObject();
jsonObject.put("hashid", AppConstant.HASHID);
jsonObject.put("reqid", AppConstant.REQID);
jsonObject.put("userid", AppConstant.USER);
jsonObject.put("title", sJudul);
jsonObject.put("name", sName);
jsonObject.put("start_period", sBbs_read);
jsonObject.put("end_period", sBbs_Date);
jsonObject.put("content", txtHeader.getText().toString().trim());
jsonObject.put("bbs_date", sBbs_Date);
jsonObject.put("priority_id", sPriority_id);
jsonObject.put("read", "0");
jsonObject.put("category_id", sCategory_Id);
jsonObject.put("create_by", AppConstant.USER);
jsonObject.put("reply_id", "0");
Call<BBS_Insert> call = NetworkManager.getNetworkService(this).postBBSInsert(updateParam);
call.enqueue(new Callback<BBS_Insert>() {
@Override
public void onResponse(Call<BBS_Insert> call, Response<BBS_Insert> response) {
int code = response.code();
if (code == 200){
sBBsId = "";
bbsInsert = response.body();
if (bbsInsert.code.equals("00")){
sBBsId = bbsInsert.bbs_id;
sendBBSAttachment();
}
finish();
}
}
@Override
public void onFailure(Call<BBS_Insert> call, Throwable t) {
}
});
}catch (Exception e){
}
}
void sendBBSAttachment(){
try {
AppConstant.HASHID = AppController.getInstance().getHashId(AppConstant.USER);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try{
File file = new File(sFile_Path);
RequestBody requestFile =
RequestBody.create(MediaType.parse("multipart/form-data"), file);
// MultipartBody.Part is used to send also the actual file name
MultipartBody.Part body =
MultipartBody.Part.createFormData("files", file.getName(), requestFile);
RequestBody user_id =
RequestBody.create(
MediaType.parse("multipart/form-data"), AppConstant.USER);
RequestBody id =
RequestBody.create(
MediaType.parse("multipart/form-data"), "bbs");
RequestBody fileKey =
RequestBody.create(
MediaType.parse("multipart/form-data"), sBBsId);
Call<BBS_Insert> call = NetworkManager.getNetworkServiceUpload(this).postBBSInsertAttachmentOnly(
user_id,
id,
fileKey, body);
call.enqueue(new Callback<BBS_Insert>() {
@Override
public void onResponse(Call<BBS_Insert> call, Response<BBS_Insert> response) {
int code = response.code();
if(code == 200){
}
}
@Override
public void onFailure(Call<BBS_Insert> call, Throwable t) {
}
});
}catch (Exception e){
//Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
| [
"[email protected]"
] | |
6aeebc8fc54a49f4045a849389c1cfc823f026eb | 20325bc297ecc5b06c283e3f5bd285997652b6a8 | /src/main/java/com/bpodgursky/nlpviz/ParseHelper2.java | 77ee99dfbf3caa530dd37c8becd4fb49d00edf6b | [] | no_license | sebgod/nlpviz | 14020fcbfe0b6642e0043662f18bbae16ef5fa41 | 8840c09d5a634351382e784494cce95d85cf85b2 | refs/heads/master | 2020-12-28T19:57:24.860386 | 2014-04-06T20:37:40 | 2014-04-06T20:37:40 | 14,936,563 | 1 | 0 | null | 2019-10-05T00:35:09 | 2013-12-04T21:38:12 | JavaScript | UTF-8 | Java | false | false | 2,224 | java | package com.bpodgursky.nlpviz;
import com.google.common.collect.Lists;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.TreeCoreAnnotations;
import edu.stanford.nlp.util.CoreMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
public class ParseHelper2 {
private final StanfordCoreNLP pipeline;
public ParseHelper2() {
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
pipeline = new StanfordCoreNLP(props);
}
public JSONArray parse(String text) throws JSONException {
Annotation document = new Annotation(text);
pipeline.annotate(document);
JSONArray array = new JSONArray();
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
List<CoreLabel> coreLabels = sentence.get(CoreAnnotations.TokensAnnotation.class);
array.put(toJSON(tree, coreLabels.iterator()));
}
return array;
}
public static JSONObject toJSON(Tree tree, Iterator<CoreLabel> labels) throws JSONException {
List<JSONObject> children = Lists.newArrayList();
for (Tree child : tree.getChildrenAsList()) {
children.add(toJSON(child, labels));
}
JSONObject obj = new JSONObject();
if(tree.isLeaf()){
CoreLabel next = labels.next();
String word = next.get(CoreAnnotations.TextAnnotation.class);
String pos = next.get(CoreAnnotations.PartOfSpeechAnnotation.class);
String ne = next.get(CoreAnnotations.NamedEntityTagAnnotation.class);
obj.put("word", word);
obj.put("pos", pos);
obj.put("ne", ne);
obj.put("type", "TK");
}else{
obj.put("type", tree.label());
}
return new JSONObject()
.put("data", obj)
.put("children", new JSONArray(children));
}
}
| [
"[email protected]"
] | |
086b354b2bcdc1929fbf9a8e1aa52ebbc4ce33d8 | 1062912d6a6d1b40e2aac1ac570b2b00962dcb59 | /bt-manager-teams-ct/src/main/java/org/ernest/applications/bt/db/manager/teams/ct/UpdateAddCommentInput.java | 844d879e9b0aaecc3706523f0bc0edc80918fe51 | [] | no_license | ErnestOrt/bt-manager-teams-src | b5bec071d3fa2f2ead8aa327564c9780c13c0753 | d839bfd91229c05b1722f2f39072c412b1bfa1a6 | refs/heads/master | 2016-08-12T23:40:26.671078 | 2016-04-03T16:20:37 | 2016-04-03T16:20:37 | 53,073,868 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | package org.ernest.applications.bt.db.manager.teams.ct;
public class UpdateAddCommentInput {
private String teamId;
private String commentId;
public String getTeamId() {
return teamId;
}
public void setTeamId(String teamId) {
this.teamId = teamId;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
} | [
"[email protected]"
] | |
5696e674a6d89d802956863a6283e1ee5ee702be | 48f8a9a25074eb157a4b2b47f6b1605322fb589e | /ssm_system_domain/src/main/java/com/ssm_system/domain/Permission.java | 2ef7e0d0b855bcd74ab9ba55162cde9fd8b02589 | [] | no_license | DaKonKon/ssm_system | e829b9407a03b756eaeac22e364d22f92b7b63d1 | f3a006107cb543e6a36a54846e037da4a5f27ea0 | refs/heads/master | 2022-12-31T02:57:19.501017 | 2020-10-18T12:12:31 | 2020-10-18T12:12:31 | 302,541,519 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 763 | java | package com.ssm_system.domain;
import java.util.List;
public class Permission {
private int id;
private String permissionName;
private String url;
private List<Role> roles;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPermissionName() {
return permissionName;
}
public void setPermissionName(String permissionName) {
this.permissionName = permissionName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
}
| [
"[email protected]"
] | |
d120755598b9f744edf25e85f1420ccbf756012b | 6de2301bbc9048d1a363d44231273f3db9da4ec6 | /bitcamp-java-basic/src/step05/Exam02_1.java | 33cb8e291d0bb871770dbcf6a04da749c4ff5e1f | [] | no_license | sunghyeondong/bitcamp | 5265d207306adec04223dd0e0d958661334731fa | c4a7d0ba01b0d6b684c67004e6c487b61c6656d6 | refs/heads/master | 2021-01-24T10:28:52.267015 | 2018-10-24T01:32:45 | 2018-10-24T01:32:45 | 123,054,630 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,059 | java | // ํ๋ฆ ์ ์ด๋ฌธ - switch ์ฌ์ฉ ์
package step05;
import java.util.Scanner;
public class Exam02_1 {
public static void main(String[] args) {
Scanner keyScan = new Scanner(System.in);
System.out.println("[์ง์๋ถ์]");
System.out.println("1. S/W๊ฐ๋ฐ");
System.out.println("2. ์ผ๋ฐ๊ด๋ฆฌ");
System.out.println("3. ์์ค๊ฒฝ๋น");
System.out.print("์ง์ ๋ถ์ผ์ ๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์? ");
int no = keyScan.nextInt();
System.out.println("์ ์ถํ์ค ์๋ฅ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.");
if (no == 1) {
System.out.println("์ ๋ณด์ฒ๋ฆฌ์๊ฒฉ์ฆ");
System.out.println("์กธ์
์ฆ๋ช
์");
System.out.println("์ด๋ ฅ์");
} else if (no == 2) {
System.out.println("์กธ์
์ฆ๋ช
์");
System.out.println("์ด๋ ฅ์");
} else if (no == 3) {
System.out.println("์ด๋ ฅ์");
} else {
System.out.println("์ฌ๋ฐ๋ฅธ ๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์!");
}
}
} | [
"[email protected]"
] | |
1c57d528565b8aee8b1f69f7717f4f34dd339ea4 | 21273936d48726fa43dfbf7bab7bc3b17976a711 | /todo/todo-api/src/main/java/com/liferay/todo/service/TodoServiceWrapper.java | fa91702bedc21f1ea4d9ac8c3f7ad540783a6117 | [] | no_license | mir333/dxp-react-workshop | 24213350c4d92738ba0ee7105980a3800d735467 | ce1b6feda9e9e279965a9daf7a4d2157da716669 | refs/heads/master | 2020-12-02T21:24:47.852809 | 2016-09-15T19:01:30 | 2016-09-15T19:01:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,048 | java | /**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*/
package com.liferay.todo.service;
import aQute.bnd.annotation.ProviderType;
import com.liferay.portal.kernel.service.ServiceWrapper;
/**
* Provides a wrapper for {@link TodoService}.
*
* @author Brian Wing Shun Chan
* @see TodoService
* @generated
*/
@ProviderType
public class TodoServiceWrapper implements TodoService,
ServiceWrapper<TodoService> {
public TodoServiceWrapper(TodoService todoService) {
_todoService = todoService;
}
@Override
public com.liferay.todo.model.Todo addTodo(java.lang.String description) {
return _todoService.addTodo(description);
}
@Override
public com.liferay.todo.model.Todo setDone(long id, boolean done)
throws com.liferay.portal.kernel.exception.PortalException {
return _todoService.setDone(id, done);
}
/**
* Returns the OSGi service identifier.
*
* @return the OSGi service identifier
*/
@Override
public java.lang.String getOSGiServiceIdentifier() {
return _todoService.getOSGiServiceIdentifier();
}
@Override
public java.util.List<com.liferay.todo.model.Todo> getTodos() {
return _todoService.getTodos();
}
@Override
public void deleteTodo(long id)
throws com.liferay.portal.kernel.exception.PortalException {
_todoService.deleteTodo(id);
}
@Override
public TodoService getWrappedService() {
return _todoService;
}
@Override
public void setWrappedService(TodoService todoService) {
_todoService = todoService;
}
private TodoService _todoService;
} | [
"[email protected]"
] | |
aabc35c8d2487460ea6e458e0a6a5c55c568fddf | 00342d235aa7159b74fd71ea94d7ba3184ef0a8e | /src/animals/Parrot.java | 16904aff06e69e4d80a76d7324817cf1ec5f9266 | [] | no_license | Burton86/Zoo-master | 84088716f895b9432df14f9f457bbc634732d051 | 09f6180302b15695602dbe08e5b2934b35a16e74 | refs/heads/master | 2020-05-23T16:32:44.044281 | 2019-05-15T15:14:51 | 2019-05-15T15:14:51 | 186,851,872 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 629 | java | package animals;
import types.Bird;
/**
* Write a description of class Animals.Parrot here.
*
* @author (Kyle Burton)
* @version (5/10/19)
*/
public class Parrot extends Bird {
// instance variables - replace the example below with your own
private int age;
public Parrot() {
super("Parrot", "green and fleeting");
age = 2;
}
public Parrot(String name, String desc) {
super(name, desc);
age = 2;
}
public String eat() {
return "special low-fat bird seed";
}
public String makeNoise() {
return "repeats random phrases you say";
}
} | [
"[email protected]"
] | |
4590895a5c1211411871129a9c9b0e3cd805260f | bce6730ec0ef56ccbf01bd999c1b9249518186da | /src/test/java/com/project/MavenProject/javascriptexcecutors/ScriptExceutor.java | 50c266a8db129c73a413c0734421a02748ede551 | [] | no_license | ravilella1234/githubsourcebuild | 8e34fb126df7c83008068cee7a55456d2360a2ce | 19a361f49f421f5fb6375e8f2e908300de1d8ab0 | refs/heads/master | 2022-07-10T03:07:11.687781 | 2019-08-13T03:02:36 | 2019-08-13T03:02:36 | 202,052,001 | 0 | 1 | null | 2020-10-13T15:17:37 | 2019-08-13T02:59:55 | HTML | UTF-8 | Java | false | false | 1,984 | java | package com.project.MavenProject.javascriptexcecutors;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ScriptExceutor
{
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\DELL\\Desktop\\Drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
//driver.get("http://automationpractice.com/index.php?controller=authentication&back=my-account");
driver.get("https://www.facebook.com");
JavascriptExecutor js = (JavascriptExecutor)driver;
//js.executeScript("document.getElementById('email').value='ravilella'");
/*String v = js.executeScript("return document.title").toString();
System.out.println(v);*/
//js.executeScript("document.getElementById('email').value='ravilella'");
//String value = js.executeScript("return document.title").toString();
//System.out.println(value);
//js.executeScript("document.getElementById('email').value='ravilella'");
// String val = js.executeScript("return document.title").toString();
//String val = js.executeScript("return document.title").toString();
//System.out.println(val);
//js.executeScript("document.getElementById('email').value='keerthan'");
//js.executeScript("document.getElementById('loginbutton').click()");
//String str = js.executeScript("return document.title").toString();
//System.out.println(str);
//js.executeScript("window.scrollBy(0,100)");
//js.executeScript("window.scrollBy(0,document.body.scrollHeight)");
//js.executeScript("document.getElementById('u_0_p').scrollIntoView()");
js.executeScript("window.history.back()");
Thread.sleep(4000);
js.executeScript("window.history.forward()");
Thread.sleep(4000);
js.executeScript("window.history.go(0)");
}
}
| [
"ravilella1234"
] | ravilella1234 |
49b177acd4cd2291822261de431744ce599f84d9 | 8dedeb809d782042a8222f413883cf158ce7d16b | /src/main/java/com/netcracker/smarthome/business/auth/UserExistsException.java | 095f00bcfcab0c590d295e36b396426d9d455362 | [] | no_license | iradmt/smarthome-webapp | c5fdb4fb283bac20f6683279b8bbdda1d0245aa2 | 8b6a1a905954eeab071699a52b3e9471a7cfcacd | refs/heads/master | 2021-01-11T09:31:46.139038 | 2017-05-23T13:01:18 | 2017-05-23T13:01:18 | 77,473,318 | 0 | 8 | null | 2017-02-10T10:38:33 | 2016-12-27T17:55:13 | Java | UTF-8 | Java | false | false | 183 | java | package com.netcracker.smarthome.business.auth;
public class UserExistsException extends Exception {
public UserExistsException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
c2f24322652aaa14a7e2a3460ea58c7c395b9735 | 4e6fdc2c6b4325993fb7635677189e095cc5d947 | /src/com/rmc/Audio.java | 31a02375ba8c9b7d59c1b8d981b4d4cf6640e5ad | [] | no_license | alex022/RMC | 0b88ac8661ddf46d2a6141e9113f84fe9b2102cc | 5fe6d914ab75625bee2650464a1da5b8dfbf242f | refs/heads/master | 2021-01-25T03:26:14.448523 | 2014-06-05T01:11:08 | 2014-06-05T01:11:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,920 | java | package com.rmc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.R.integer;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class Audio extends MainActivity {
private static final int RECORDER_BPP = 16;
private static final String AUDIO_RECORDER_FILE_EXT_WAV = ".wav";
private static final String AUDIO_RECORDER_FOLDER = "AudioRecorder";
private static final String AUDIO_RECORDER_TEMP_FILE = "record_temp.raw";
private static final int RECORDER_SAMPLERATE = 8000;
private static final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_STEREO;
private static final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
private AudioRecord recorder = null;
private int bufferSize = 0;
private Thread recordingThread = null;
private boolean isRecording = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.audio);
setButtonHandlers();
bufferSize = AudioRecord.getMinBufferSize(RECORDER_SAMPLERATE,
RECORDER_CHANNELS,
RECORDER_AUDIO_ENCODING);
}
private void setButtonHandlers() {
((Button)findViewById(R.id.start)).setOnClickListener(btnClick);
((Button)findViewById(R.id.stop)).setOnClickListener(btnClick);
((Button)findViewById(R.id.play)).setOnClickListener(btnClick);
}
private String getFilename(){
String filepath = Environment.getExternalStorageDirectory().getPath();
File file = new File(filepath,AUDIO_RECORDER_FOLDER);
if(!file.exists()){
file.mkdirs();
}
return (file.getAbsolutePath() + "/" + "audio" + AUDIO_RECORDER_FILE_EXT_WAV);
}
private String getTempFilename(){
String filepath = Environment.getExternalStorageDirectory().getPath();
File file = new File(filepath,AUDIO_RECORDER_FOLDER);
if(!file.exists()){
file.mkdirs();
}
File tempFile = new File(filepath,AUDIO_RECORDER_TEMP_FILE);
if(tempFile.exists())
tempFile.delete();
return (file.getAbsolutePath() + "/" + AUDIO_RECORDER_TEMP_FILE);
}
private void startRecording(){
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
RECORDER_SAMPLERATE, RECORDER_CHANNELS,RECORDER_AUDIO_ENCODING, bufferSize);
int i = recorder.getState();
if(i==1)
recorder.startRecording();
isRecording = true;
recordingThread = new Thread(new Runnable() {
@Override
public void run() {
writeAudioDataToFile();
}
},"AudioRecorder Thread");
recordingThread.start();
}
private void writeAudioDataToFile(){
byte data[] = new byte[bufferSize];
String filename = getTempFilename();
FileOutputStream os = null;
try {
os = new FileOutputStream(filename);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int read = 0;
if(null != os){
while(isRecording){
read = recorder.read(data, 0, bufferSize);
if(AudioRecord.ERROR_INVALID_OPERATION != read){
try {
os.write(data);
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void stopRecording(){
if(null != recorder){
isRecording = false;
int i = recorder.getState();
if(i==1)
recorder.stop();
recorder.release();
recorder = null;
recordingThread = null;
}
copyWaveFile(getTempFilename(),getFilename());
deleteTempFile();
}
private void deleteTempFile() {
File file = new File(getTempFilename());
file.delete();
}
private void copyWaveFile(String inFilename,String outFilename){
FileInputStream in = null;
FileOutputStream out = null;
long totalAudioLen = 0;
long totalDataLen = totalAudioLen + 36;
long longSampleRate = RECORDER_SAMPLERATE;
int channels = 2;
long byteRate = RECORDER_BPP * RECORDER_SAMPLERATE * channels/8;
byte[] data = new byte[bufferSize];
try {
in = new FileInputStream(inFilename);
out = new FileOutputStream(outFilename);
totalAudioLen = in.getChannel().size();
totalDataLen = totalAudioLen + 36;
WriteWaveFileHeader(out, totalAudioLen, totalDataLen,
longSampleRate, channels, byteRate);
while(in.read(data) != -1){
out.write(data);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void WriteWaveFileHeader(FileOutputStream out, long totalAudioLen, long totalDataLen, long longSampleRate, int channels,
long byteRate) throws IOException {
byte[] header = new byte[44];
header[0] = 'R'; // RIFF/WAVE header
header[1] = 'I';
header[2] = 'F';
header[3] = 'F';
header[4] = (byte) (totalDataLen & 0xff);
header[5] = (byte) ((totalDataLen >> 8) & 0xff);
header[6] = (byte) ((totalDataLen >> 16) & 0xff);
header[7] = (byte) ((totalDataLen >> 24) & 0xff);
header[8] = 'W';
header[9] = 'A';
header[10] = 'V';
header[11] = 'E';
header[12] = 'f'; // 'fmt ' chunk
header[13] = 'm';
header[14] = 't';
header[15] = ' ';
header[16] = 16; // 4 bytes: size of 'fmt ' chunk
header[17] = 0;
header[18] = 0;
header[19] = 0;
header[20] = 1; // format = 1
header[21] = 0;
header[22] = (byte) channels;
header[23] = 0;
header[24] = (byte) (longSampleRate & 0xff);
header[25] = (byte) ((longSampleRate >> 8) & 0xff);
header[26] = (byte) ((longSampleRate >> 16) & 0xff);
header[27] = (byte) ((longSampleRate >> 24) & 0xff);
header[28] = (byte) (byteRate & 0xff);
header[29] = (byte) ((byteRate >> 8) & 0xff);
header[30] = (byte) ((byteRate >> 16) & 0xff);
header[31] = (byte) ((byteRate >> 24) & 0xff);
header[32] = (byte) (2 * 16 / 8); // block align
header[33] = 0;
header[34] = RECORDER_BPP; // bits per sample
header[35] = 0;
header[36] = 'd';
header[37] = 'a';
header[38] = 't';
header[39] = 'a';
header[40] = (byte) (totalAudioLen & 0xff);
header[41] = (byte) ((totalAudioLen >> 8) & 0xff);
header[42] = (byte) ((totalAudioLen >> 16) & 0xff);
header[43] = (byte) ((totalAudioLen >> 24) & 0xff);
out.write(header, 0, 44);
}
private View.OnClickListener btnClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
Thread audioThread;
switch(v.getId()){
case R.id.start:{
Toast.makeText(currentActivity, "Playing audio \"Eat!\"", Toast.LENGTH_SHORT).show();
audioThread = new Thread(new writeThread("*AUDIO1*", null, 0, null, null));
audioThread.start();
break;
}
case R.id.stop:{
Toast.makeText(currentActivity, "Playing audio \"Come!\"", Toast.LENGTH_SHORT).show();
audioThread = new Thread(new writeThread("*AUDIO2*", null, 0, null, null));
audioThread.start();
break;
}
case R.id.play:{
Toast.makeText(currentActivity, "Playing audio \"Guard!\"", Toast.LENGTH_SHORT).show();
audioThread = new Thread(new writeThread("*AUDIO3*", null, 0, null, null));
audioThread.start();
break;
}
}
}
};
}
| [
"[email protected]"
] | |
edb48160a9d549935302df85043764ade2a0943f | e86fb2b00aece2fd47bcfdce0ececa418540dd00 | /src/main/java/user/UserDao.java | 1006e67f9b2df5212b8555bda9b46843c5143541 | [
"Apache-2.0"
] | permissive | HPeti/jdbi-examples | 8901a3df9519bb39df2ed8b6a08090036662e90d | 5c80feca9e4bee2a9c323ef3dbb352e6cd902d79 | refs/heads/master | 2023-04-09T09:50:13.227869 | 2021-04-24T16:23:48 | 2021-04-24T16:23:48 | 361,107,664 | 0 | 0 | Apache-2.0 | 2021-04-24T08:16:10 | 2021-04-24T08:16:10 | null | UTF-8 | Java | false | false | 1,563 | java | package user;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.customizer.BindBean;
import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import java.util.List;
import java.util.Optional;
@RegisterBeanMapper(User.class)
public interface UserDao {
@SqlUpdate("""
CREATE TABLE users (
id IDENTITY PRIMARY KEY,
username VARCHAR NOT NULL,
password VARCHAR NOT NULL,
name VARCHAR NOT NULL,
email VARCHAR NOT NULL,
gender ENUM('MALE', 'FEMALE') NOT NULL,
birthDate DATE NOT NULL,
enabled BOOLEAN NOT NULL
)
"""
)
void createTable();
@SqlUpdate("""
INSERT INTO users (username, password, name, email, gender, birthDate, enabled)
VALUES (:username, :password, :name, :email, :gender, :birthDate, :enabled)
""")
@GetGeneratedKeys("id")
long insertUser(@BindBean User user);
@SqlQuery("SELECT * FROM users WHERE id = :id")
Optional<User> getUserById(@Bind("id") Long id);
@SqlQuery("SELECT * FROM users WHERE username = :username")
Optional<User> getUserByUsername(@Bind("username") String username);
@SqlUpdate("DELETE FROM users WHERE id = :id")
void deleteUser(@BindBean User user);
@SqlQuery("SELECT * FROM users ORDER BY id")
List<User> listUsers();
}
| [
"[email protected]"
] | |
a7ac161e353e883b669bfe2fa1d1b911fbf9e820 | 6999384c3b547917a7ce1544deaf6a25187bf365 | /client.java | becaec7381fbb39d8248f258a164e80846e28498 | [] | no_license | vyshnavilahari/Chat-Box | 1aa4bdaf31ea66e69976511702503cc83909fdbd | 33bb37e4b51c1869c9da1010d904bebc1b2aabb2 | refs/heads/master | 2022-11-18T04:16:55.509970 | 2020-07-21T07:54:48 | 2020-07-21T07:54:48 | 281,330,356 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,660 | java | package chatting;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import java.util.HashMap;
import java.util.PriorityQueue;
import javax.swing.JTextField;
import chatting.node;
import chatting.sortbyfreq;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.Color;
public class client {
private JFrame frame;
private static JTextField textField;
private static JTextField textField_1;
private static JTextArea textArea_1;
private static JTextArea textArea;
static Socket S;
static DataInputStream dis;
static DataOutputStream dos;
static String msgin="";
private static HashMap<String,String> enm = new HashMap<String,String>();//for storing ch-1010110
static String comsg="";
private static void printcodes(node root, String str)throws Exception {
if(root.left == null && root.right == null )
{
String da=""+root.data;
enm.put(da,str);
//ednm.put(str, da);
comsg=comsg+str+":"+da+"$";
return ;
}
printcodes(root.left,str+"0");
printcodes(root.right,str+"1");
}
public static void main(String[] args) throws Exception
{
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
client window = new client();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
//int port = Integer.parseInt(textField_1.getText());
try {
S = new Socket("localhost",2261);//(textField.getText(),port);
dos = new DataOutputStream(S.getOutputStream());
dis = new DataInputStream(S.getInputStream());
String hemmsg="";
String demmsg="";
int i,j;
String dnm="";
String decodemessage="";
while(msgin!="$$$$")
{
HashMap<String,String> ednm = new HashMap<String,String>();//for storing 1010110-ch
msgin = dis.readUTF();
for(i=0;i<msgin.length();i++)
{
if(msgin.charAt(i)=='@')
{
i++;
break;
}
hemmsg=hemmsg+msgin.charAt(i);
}
textArea.setText(textArea.getText()+"\n"+"rev : "+hemmsg);
for(j=i;j<msgin.length();j++)
{
if(msgin.charAt(j)==':')
{
j++;
ednm.put(demmsg,""+msgin.charAt(j));
demmsg="";
j=j+2;
if(j==msgin.length())
{
break;
}
}
demmsg=demmsg+msgin.charAt(j);
}
for(i=0;i<hemmsg.length();i++)
{
dnm=dnm+hemmsg.charAt(i);
if(ednm.containsKey(dnm))
{
decodemessage=decodemessage+ednm.get(dnm);
dnm="";
}
}
textArea_1.setText(decodemessage);
hemmsg="";
decodemessage="";
dnm="";
}
} catch (Exception e1) {
//not handle
}
}
public client() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(Color.ORANGE);
frame.setBounds(100, 100, 600, 550);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblIpAddress = new JLabel("IP Address");
lblIpAddress.setFont(new Font("Tahoma", Font.BOLD, 18));
lblIpAddress.setBounds(23, 29, 109, 22);
frame.getContentPane().add(lblIpAddress);
JLabel lblPortNumber = new JLabel("Port Number");
lblPortNumber.setFont(new Font("Tahoma", Font.BOLD, 18));
lblPortNumber.setBounds(229, 34, 131, 17);
frame.getContentPane().add(lblPortNumber);
textField = new JTextField();
textField.setBounds(12, 64, 173, 22);
frame.getContentPane().add(textField);
textField.setText("Hemanth");
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(229, 64, 142, 22);
frame.getContentPane().add(textField_1);
textField_1.setText(" - $ - * - $ -");
textField_1.setColumns(10);
JButton btnDisconnect = new JButton("Disconnect");
btnDisconnect.setBounds(446, 75, 97, 25);
frame.getContentPane().add(btnDisconnect);
btnDisconnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
dos = new DataOutputStream(S.getOutputStream());
dos.writeUTF("$$$$");
dos.flush();
S.close();
} catch (Exception e1) {
}
}
});
JLabel lblBeforeMessages = new JLabel("Before Messages");
lblBeforeMessages.setFont(new Font("Tahoma", Font.BOLD, 18));
lblBeforeMessages.setBounds(22, 111, 163, 22);
frame.getContentPane().add(lblBeforeMessages);
textArea = new JTextArea();
textArea.setBounds(23, 146, 530, 145);
frame.getContentPane().add(textArea);
JLabel lblRecivedMessage = new JLabel("Recived Message");
lblRecivedMessage.setFont(new Font("Tahoma", Font.BOLD, 18));
lblRecivedMessage.setBounds(23, 316, 190, 22);
frame.getContentPane().add(lblRecivedMessage);
textArea_1 = new JTextArea();
textArea_1.setBounds(23, 351, 530, 46);
frame.getContentPane().add(textArea_1);
JLabel lblTypeMessage = new JLabel("Type Message");
lblTypeMessage.setFont(new Font("Tahoma", Font.BOLD, 18));
lblTypeMessage.setBounds(23, 410, 162, 22);
frame.getContentPane().add(lblTypeMessage);
JTextArea textArea_2 = new JTextArea();
textArea_2.setBounds(23, 445, 442, 45);
frame.getContentPane().add(textArea_2);
JButton btnSend = new JButton("Send");
btnSend.setBounds(477, 444, 97, 25);
frame.getContentPane().add(btnSend);
btnSend.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String message =textArea_2.getText();
String encodemessage="";
int[] fre = new int[message.length()];
int i,j,n=0;
char str[] = message.toCharArray();
for(i=0;i<message.length();i++)
{
fre[i]=1;
for(j=i+1;j<message.length();j++)
{
if(str[i]==str[j])
{
fre[i]++;
str[j]='0';
}
}
}
for(i=0;i<fre.length;i++)
{
if( str[i]!='0')
{
n=n+1;
}
}
PriorityQueue<node> msg = new PriorityQueue<node>(n,new sortbyfreq());
for(i=0;i<fre.length;i++)
{
if( str[i]!='0')
{
node h=new node(fre[i],str[i]);
msg.add(h);
}
}
node root=null;//encoding
while(msg.size()>1)
{
node p = msg.peek();
msg.poll();//remove last
node q = msg.peek();
msg.poll();//remove second last
node temp = new node(p.frequency+q.frequency);
temp.left=p;
temp.right=q;
root=temp;
msg.add(temp);//add sum 2
}
comsg="";
printcodes(root,"");
for(i=0;i<message.length();i++)
{
String da=""+message.charAt(i);
//System.out.println(enm.get(da));
encodemessage=encodemessage+enm.get(da);
}
textArea.setText(textArea.getText()+"\n"+"sen : "+encodemessage);
encodemessage=encodemessage+"@"+comsg;
dos.writeUTF(encodemessage);
dos.flush();
textArea_2.setText(null);
} catch (Exception e1) {
// TODO Auto-generated catch block
}
}
});
}
}
| [
"[email protected]"
] | |
8fdd4cfa61529d081a7eddd4d7e3c9cfc572e04e | c1b261be52486f72e5d0db980169b9269c852107 | /src/org/drmx/CinemaViewer.java | f8e794c2f6c51adb13f0e416c437d6fdf2a5188c | [] | no_license | maxim-zolotov/DRMXbot | 0a96f0a5527d4b9579f96b5a90b5ebe8d5e4fe9f | 7cc194332c1666411dad580b770af81d4ec66fd5 | refs/heads/master | 2021-06-26T17:31:03.055705 | 2017-09-11T22:53:01 | 2017-09-11T22:53:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,056 | java | package org.drmx;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.*;
public class CinemaViewer {
public static final String SEANCES_URL = "http://cinemadelux.ru/seances/";
public static Map<String, List<SeanceDTO>> parseSeances() {
Map<String, List<SeanceDTO>> seances = new HashMap<>();
try {
Document document = Jsoup.connect(SEANCES_URL).get();
Elements contentDivs = document.select("div.area_seanse");
Iterator iterator = contentDivs.iterator();
while(iterator.hasNext()) {
SeanceDTO seanceDTO = new SeanceDTO();
Element seance = (Element) iterator.next();
seanceDTO.setTime(seance.select("div.time").text());
seanceDTO.setName(seance.select("div.name").select("a").text());
seanceDTO.setPrice(seance.select("div.price").text());
if(seances.containsKey(seanceDTO.getName())) {
seances.get(seanceDTO.getName()).add(seanceDTO);
} else {
List<SeanceDTO> seanceList = new ArrayList<>();
seanceList.add(seanceDTO);
seances.put(seanceDTO.getName(), seanceList);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
return null;
}
return seances;
}
public static String getSeances() {
StringBuilder seancesStr = new StringBuilder("ะกะตะฐะฝัั ะฝะฐ ัะตะณะพะดะฝั:\n");
for(List<SeanceDTO> seanceDTOs: parseSeances().values()) {
seancesStr.append(seanceDTOs.get(0).getName() + "\n");
for(SeanceDTO seanceDTO : seanceDTOs) {
seancesStr.append(" " + seanceDTO.getTime() + " - " + seanceDTO.getPrice() + " ั.\n");
}
}
return seancesStr.toString();
}
}
| [
"[email protected]"
] | |
1f495e8d581a77c3137e13644385c51d9bbf78ed | 3e740a40ecb3d6b4131946176eade2c6f194d3f8 | /src/main/java/com/zhoujian/dao/IProductDao.java | 8e58ecdf6e0fc31f67712cd76b69caead4636800 | [] | no_license | zhoujain/authoritySystem | 8a009b7a977c6050b9328d0d6b125d11fa5a3167 | c42de6502cf09a39b8d1d8e65575d7a042775ada | refs/heads/master | 2020-07-03T22:30:17.973473 | 2019-08-29T05:00:39 | 2019-08-29T05:00:39 | 202,072,920 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 861 | java | package com.zhoujian.dao;
import com.zhoujian.domain.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import java.util.List;
@Mapper
public interface IProductDao {
//ๆ นๆฎidๆฅ่ฏขไบงๅไฟกๆฏ
@Select("select * from product where id = #{id}")
Product findById(String id)throws Exception;
//ๆฅ่ฏขๆๆไบงๅไฟกๆฏ
@Select("select * from product")
List<Product> findAll() throws Exception;
@Insert("insert into product(id,productNum,productName,cityName,DepartureTime,productPrice,productDesc,productStatus)" +
"values(#{id},#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
void save(Product product);
//
}
| [
"[email protected]"
] | |
bf78348762e45a4a395122681b008f1c37b1c792 | 695cfdd237fe6ee11bb7be5648dfb4d50743ce26 | /app/src/main/java/com/kissasianapp/kissasian/ka_adapter/CountryAdapter.java | 61a387d8e7069746d3728185ee2e551446670d56 | [] | no_license | fandofastest/KISSAPP | e7a93a3c6e7fba6a14b93d6091bbedc29ed8f84b | a950b47b5aca8f867ef1b152472c16e01a7c8ba8 | refs/heads/master | 2020-12-28T18:50:34.291254 | 2020-04-24T16:35:35 | 2020-04-24T16:35:35 | 238,448,169 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,724 | java | package com.kissasianapp.kissasian.ka_adapter;
import android.content.Context;
import android.content.Intent;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.kissasianapp.kissasian.ItemMovieActivity;
import com.kissasianapp.kissasian.R;
import com.kissasianapp.kissasian.ka_model.CommonModels;
import java.util.ArrayList;
import java.util.List;
public class CountryAdapter extends RecyclerView.Adapter<CountryAdapter.OriginalViewHolder> {
private List<CommonModels> items = new ArrayList<>();
private Context ctx;
private String type;
private int c=0;
public CountryAdapter(Context context, List<CommonModels> items,String type) {
this.items = items;
ctx = context;
this.type=type;
}
@Override
public CountryAdapter.OriginalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
CountryAdapter.OriginalViewHolder vh;
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_country, parent, false);
vh = new CountryAdapter.OriginalViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(CountryAdapter.OriginalViewHolder holder, final int position) {
final CommonModels obj = items.get(position);
holder.name.setText(obj.getTitle());
holder.lyt_parent.setCardBackgroundColor(ctx.getResources().getColor(getColor()));
holder.lyt_parent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(ctx, ItemMovieActivity.class);
intent.putExtra("id",obj.getId());
intent.putExtra("title",obj.getTitle());
intent.putExtra("type",type);
ctx.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return items.size();
}
public class OriginalViewHolder extends RecyclerView.ViewHolder {
public TextView name;
private CardView lyt_parent;
public OriginalViewHolder(View v) {
super(v);
name = v.findViewById(R.id.name);
lyt_parent=v.findViewById(R.id.lyt_parent);
}
}
private int getColor(){
int colorList[] = {R.color.red_400,R.color.blue_400,R.color.indigo_400,R.color.orange_400,R.color.light_green_400,R.color.blue_grey_400};
if (c>=6){
c=0;
}
int color = colorList[c];
c++;
return color;
}
} | [
"[email protected]"
] | |
ef39b81247d8020122cd34ba416e64405a8e3007 | 5c7355b35f8a743d833c7fe8bfda87af9fde5d36 | /practice2.finish/toastapp/src/androidTest/java/ru/mirea/strokach/toastapp/ExampleInstrumentedTest.java | 55918c8586d76de270b98c8ecafc4cb61efa13cd | [] | no_license | baaanan01/mobbile | b44704fb3db94c740f91bc0e26b871cc38151027 | 17dd1507854f03215b948be6535c7befa5055bc1 | refs/heads/master | 2023-05-07T19:12:19.406634 | 2021-06-05T09:37:19 | 2021-06-05T09:37:19 | 374,074,149 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package ru.mirea.strokach.toastapp;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("ru.mirea.strokach.toastapp", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
c11c2b4588396d848ffe280dffe1ec944ef518e0 | 9c7a2264b36af2ad869a7d8ccae55e586ba6430d | /WorldClassWallSung/src/main/java/uni/stu/service/GradeMService.java | 8470ede462abe33089107d63b78c65978f251a1a | [] | no_license | shalom3698/WorldClassWallSung | 98e06c10f583cf6a23d4bfdb1027ec4efcb67682 | f8b710845065790598c81f192c35e582fae638ff | refs/heads/master | 2022-12-20T01:19:44.185324 | 2020-10-16T07:12:40 | 2020-10-16T07:12:40 | 286,380,301 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 718 | java | package uni.stu.service;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uni.stu.model.GradeMDto;
@Service
public class GradeMService{
@Autowired
GradeMDao mdao;
public GradeMService() {}
public List<GradeMDto> yearsList() {
return mdao.yearsList();
}
public List<GradeMDto> semList() {
return mdao.semList();
}
public List<GradeMDto> gradeMSel(int stu_no, int years, int sem) {
Map<String, Integer> m = new HashMap<String, Integer>();
m.put("stu_no", stu_no);
m.put("years", years);
m.put("sem", sem);
return mdao.gradeMSel(m);
}
public void setMdao(GradeMDao mdao) {
this.mdao = mdao;
}
}
| [
"[email protected]"
] | |
10ab873deddc56240aa6b6fc89d821dbe98788ae | 9b367e61ecedadab5eb9227265da70049bb7c863 | /src/com/bridgerputnam/dayTwo/ProblemTwo.java | 78b852e76ea5a8f0e40ab887d6ad84c8ae27e8c4 | [] | no_license | Putnam14/Advent-of-Code-2019 | 13e8b37f2d6170363f8e842876ef995a54811df0 | fe0280d11a377405f956458ca40ef3a3f5dcd14f | refs/heads/master | 2020-10-02T09:55:21.759602 | 2019-12-16T01:37:31 | 2019-12-16T01:37:31 | 227,752,005 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 853 | java | package com.bridgerputnam.dayTwo;
import com.bridgerputnam.InputReader;
import com.bridgerputnam.IntcodeProcessor;
import java.util.ArrayList;
import java.util.List;
public class ProblemTwo {
public static int solution() {
List<Integer> input = InputReader.inputToIntList("dayTwo/dayTwoInput.txt");
for(int noun = 0; noun <= 99; noun++) {
for(int verb = 0; verb <= 99; verb++) {
List<Integer> modifiedInput = new ArrayList<>(input.size());
modifiedInput.addAll(input);
modifiedInput.set(1,noun);
modifiedInput.set(2,verb);
IntcodeProcessor.processIntcode(modifiedInput);
int output = modifiedInput.get(0);
if(output == 19690720) return 100 * noun + verb;
}
}
return -1;
}
}
| [
"[email protected]"
] | |
c45cc958ea631efa8108f2079ac279010e27d133 | dce9814e5a555a50af294fa29f48010d76732369 | /nasa-service/nasa-service-impl/src/main/java/datsch/andre/service/impl/MarsServiceImpl.java | 466e5fa195100cb6d2cf46beda32759cbd6bc42d | [] | no_license | binottoeduardo/NasaTest | ffa8f5eae2be2676b3a0e971a89b5f49e46c62e4 | 1a53dee8ef272ecc33a2009f1095520a0a75df76 | refs/heads/master | 2020-12-25T09:48:11.887351 | 2016-03-19T00:43:25 | 2016-03-19T00:43:25 | 60,551,323 | 1 | 0 | null | 2016-06-06T18:31:44 | 2016-06-06T18:31:44 | null | ISO-8859-1 | Java | false | false | 2,996 | java | package datsch.andre.service.impl;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ejb.Stateless;
import datsch.andre.service.api.MarsService;
import datsch.andre.service.bean.Direcao;
import datsch.andre.service.bean.Robo;
/**
* Implementaรงรฃo do serviรงo de controle do Robo
*
* @author Andre
*/
@Stateless
public class MarsServiceImpl implements MarsService {
/**
* Tamanho do campo a ser explorado
*/
public static Integer tamanho = 5;
@Override
public String processaComando( String commando ) throws Exception {
validaEntrada(commando);
Robo robo = new Robo();
for ( int i = 0; i < commando.length(); i++ ) {
char comando = commando.charAt(i);
if ( comando == 'M' ) {
move(robo);
} else {
virar(robo, comando);
}
}
return robo.getPosicaoAtual();
}
/**
* Identifica e gira o robo para o lado correto
*
* @param robo Robo
*
* @param direcao Direรงรฃo para que o robo deve girar
*/
private void virar( Robo robo, char direcao ) {
if ( direcao == 'L' ) {
virarEsquerda(robo);
} else {
virarDireita(robo);
}
}
/**
* Gira o robo para a esquerda
*
* @param robo Robo
*/
private void virarEsquerda( Robo robo ) {
robo.setDirecao(Direcao.valueOf(robo.getDirecao().getEsquerda()));
}
/**
* Gira o robo pra direita
*
* @param robo robo
*/
private void virarDireita( Robo robo ) {
robo.setDirecao(Direcao.valueOf(robo.getDirecao().getDireita()));
}
/**
* Move o robo para a direรงรฃo que ele estรก apontado
*
* @param robo Robo
*
* @throws Exception
*/
private void move( Robo robo ) throws Exception {
switch ( robo.getDirecao() ) {
case NORTH:
move(robo, 0, 1);
break;
case SOUTH:
move(robo, 0, -1);
break;
case EAST:
move(robo, 1, 0);
break;
case WEST:
move(robo, -1, 0);
break;
default:
break;
}
validaPosicao(robo);
}
/**
* Move o robo a distancia especificada
*
* @param robo Robo
* @param x Distancia no eixo X
* @param y Distancia no eixo Y
*/
private void move( Robo robo, int x, int y ) {
robo.setPosicaoX(robo.getPosicaoX() + x);
robo.setPosicaoY(robo.getPosicaoY() + y);
}
/**
* Valida se o robo esta numa posiรงรฃo valida
*
* @param robo robo
* @throws Exception
*/
private void validaPosicao( Robo robo ) throws Exception {
if ( (robo.getPosicaoX() >= tamanho || robo.getPosicaoX() < 0)
|| (robo.getPosicaoY() >= tamanho || robo.getPosicaoY() < 0) ) {
throw new Exception("Posiรงรฃo Invรกlida");
}
}
/**
* Identifica se os comandos passados para o robo sรฃo vรกlidos
*
* @param command Comandos
* @throws Exception
*/
private void validaEntrada( String command ) throws Exception {
Pattern p = Pattern.compile("(?:[^MRL])+");
Matcher m = p.matcher(command);
if ( m.find() ) {
throw new Exception("Comando Invรกlido");
}
}
}
| [
"[email protected]"
] | |
3ad6e01e448af225addf2256bd254d6d91157c52 | 32fa24f0dcbd39aa954811915659c977ee0caa2e | /src/gribbit/route/RouteHandler.java | 8715775de2eb29ada48fc5f761983d93fe8f5e9c | [
"Apache-2.0"
] | permissive | lukehutch/gribbit | 7e94371795b4b46c21400c3821c7d11d76e20cb8 | ceb56aacfa4115f8f4fdb2de63b01c0be2481fce | refs/heads/master | 2021-01-10T18:31:38.627925 | 2016-03-08T10:46:39 | 2016-03-08T10:46:39 | 27,955,179 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,451 | java | /**
* This file is part of the Gribbit Web Framework.
*
* https://github.com/lukehutch/gribbit
*
* @author Luke Hutchison
*
* --
*
* @license Apache 2.0
*
* Copyright 2015 Luke Hutchison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gribbit.route;
import gribbit.auth.User;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
/**
* A route handler. Override the public default get() method with optional params to accept URL params, and/or the
* public default post() method with one optional param of type DataModel to populate the DataModel values from POST
* param values. Note: you should normally subclass RouteHandlerAuthNotRequired, RouteHandlerAuthRequired or
* RouteHandlerAuthAndValidatedEmailRequired, and not RouteHandler itself.
*/
public abstract class RouteHandler {
public RoutingContext routingContext;
public Session session;
public User user;
}
| [
"[email protected]"
] | |
6f1b9d7aef336a8ff7b2eb3b84239e6e9d61484b | 4518e966f471c819ca444cb64c9b51447b6a587a | /app/src/main/java/com/cali/mascotas/db/BaseDatos.java | 35a6e60cc4d463e5a117c3f0fd6b3eab868f263c | [] | no_license | Cali99-droid/Mascotas | 0c3cab6c89ecb104fd269beef6d0556f97aaa3e3 | 57674759c445fc65e35c2609a02ba9f50b89839f | refs/heads/master | 2022-12-13T08:12:42.417752 | 2020-09-10T00:34:26 | 2020-09-10T00:34:26 | 291,741,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,475 | java | package com.cali.mascotas.db;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
import com.cali.mascotas.pojo.Mascota;
import java.util.ArrayList;
public class BaseDatos extends SQLiteOpenHelper {
private Context context;
public BaseDatos(@Nullable Context context) {
super(context, ConstantesBaseDatos.DATABASE_NAMR, null, ConstantesBaseDatos.DATABASE_VERSION);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
String queryCrearTablaMascota = "CREATE TABLE " + ConstantesBaseDatos.TABLE_MASCOTA +
"("+ ConstantesBaseDatos.TABLE_MASCOTA_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ConstantesBaseDatos.TABLE_MASCOTA_NOMBRE+" TEXT,"
+ConstantesBaseDatos.TABLE_MASCOTA_FOTO+" INTEGER,"
+ConstantesBaseDatos.TABLE_MASCOTA_EDAD+" INTEGER"
+")";
String queryCrearTablaLikesMascotas= "CREATE TABLE "+ ConstantesBaseDatos.TABLES_LIKES_MASCOTAS+"(" +
ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+
ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_ID_MASCOTA + " INTEGER , "+
ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_NUMERO + " INTEGER, "+
"FOREIGN KEY ("+ConstantesBaseDatos.TABLE_MASCOTA_ID+") "+
"REFERENCES "+ ConstantesBaseDatos.TABLE_MASCOTA+"("+ConstantesBaseDatos.TABLE_MASCOTA_ID+")"+
")";
db.execSQL(queryCrearTablaMascota);
db.execSQL(queryCrearTablaLikesMascotas);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+ConstantesBaseDatos.TABLE_MASCOTA);
db.execSQL("DROP TABLE IF EXISTS "+ConstantesBaseDatos.TABLES_LIKES_MASCOTAS);
onCreate(db);
}
public ArrayList<Mascota> obtenerMascotas(){
ArrayList<Mascota> mascotas = new ArrayList<>();
String query = "SELECT * FROM " + ConstantesBaseDatos.TABLE_MASCOTA;
SQLiteDatabase db = this.getWritableDatabase();
Cursor registros = db.rawQuery(query, null);
while (registros.moveToNext()){
Mascota mascotaActuap = new Mascota();
mascotaActuap.setId(registros.getInt(0));
mascotaActuap.setNombre(registros.getString(1));
mascotaActuap.setFoto(registros.getInt(2));
mascotaActuap.setEdad(registros.getInt(3));
String queryLikes = "SELECT COUNT("+ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_NUMERO+")as likes"+
" FROM "+ ConstantesBaseDatos.TABLES_LIKES_MASCOTAS +
" WHERE "+ ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_ID_MASCOTA+ "=" + mascotaActuap.getId();
Cursor registrosLikes = db.rawQuery(queryLikes, null);
if (registrosLikes.moveToNext()){
mascotaActuap.setRank(registrosLikes.getInt(0));
}else{
mascotaActuap.setRank(0);
}
mascotas.add(mascotaActuap);
}
db.close();
return mascotas;
}
public void insertarMascota(ContentValues contentValues){
SQLiteDatabase db = this.getWritableDatabase();
db.insert(ConstantesBaseDatos.TABLE_MASCOTA, null, contentValues);
db.close();
}
public void insertarLikeMascota(ContentValues contentValues){
SQLiteDatabase db = this.getWritableDatabase();
db.insert(ConstantesBaseDatos.TABLES_LIKES_MASCOTAS, null , contentValues);
db.close();
}
public int obtenerLikesMascota(Mascota mascota){
int likes = 0;
String query = "SELECT COUNT("+ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_NUMERO+")"+
" FROM "+ ConstantesBaseDatos.TABLES_LIKES_MASCOTAS +
" WHERE " + ConstantesBaseDatos.TABLES_LIKES_MASCOTAS_ID_MASCOTA + " = "+mascota.getId();
SQLiteDatabase db = this.getWritableDatabase();
Cursor registros = db.rawQuery(query, null);
if (registros.moveToNext()){
likes = registros.getInt(0);
}
db.close();
return likes;
}
}
| [
"[email protected]"
] | |
74919bf29098c6fb78158a9e65e356e52651ff3c | 70047d3a1bd84fbe2c2771f6ad3e17566b25e6c6 | /ButtonEventTest1/app/src/main/java/cse/mobile/buttoneventtest1/MainActivity.java | 87947a991cf18b629e212bbeaef94f070753c055 | [] | no_license | jeon9825/grade3_MobileProgramming | 2eee3255eb374b064b1fe596e5ccdc879b4f597c | 184a3a8f7ed7b86ba9c803befe2179bb820e6bec | refs/heads/master | 2020-07-17T05:55:36.400604 | 2020-02-19T05:42:57 | 2020-02-19T05:42:57 | 205,961,417 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,672 | java | package cse.mobile.buttoneventtest1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button);
/*
* ์ฒซ๋ฒ์งธ ๋ฐฉ๋ฒ
ButtonClickListener buttonClickListener = new ButtonClickListener();
button.setOnClickListener(buttonClickListener);
*/
/*
* ๋๋ฒ์งธ ๋ฐฉ๋ฒ
button.setOnClickListener(mButtonClickListener);
*/
/*
* ์ธ๋ฒ์งธ ๋ฐฉ๋ฒ
button.setOnClickListener(new ButtonClickListener());
*/
// ๋ค๋ฒ์งธ ๋ฐฉ๋ฒ
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"๋ฒํผ๋๋ฆผ",Toast.LENGTH_SHORT).show();
}
});
}
class ButtonClickListener implements View.OnClickListener{
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(),"๋ฒํผ๋๋ฆผ",Toast.LENGTH_SHORT).show();
}
}
View.OnClickListener mButtonClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"๋ฒํผ๋๋ฆผ",Toast.LENGTH_SHORT).show();
}
};
}
| [
"[email protected]"
] | |
07164a1c2d4b430ee986356a3ce05e737ce6a3d9 | 15593c41a14b149a05ca0b5325fff90568d25c8b | /02/2.8/ScrollViewTest/src/org/crazyit/ui/ScrollViewTest.java | 6d6c43f0dd5ea3f6838a1339fc01823ee6083a85 | [] | no_license | code4j-chen/CrazyAndroid-source | 0f2ef444991667b691cb956498ac96f2b7e79365 | 738f866a3bcd675b195f677b3406e0671fde4328 | refs/heads/master | 2020-04-13T04:31:31.411578 | 2015-03-06T09:53:07 | 2015-03-06T09:53:07 | 31,763,124 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 548 | java | package org.crazyit.ui;
import android.app.Activity;
import android.os.Bundle;
/**
* Description:
* <br/>site: <a href="http://www.crazyit.org">crazyit.org</a>
* <br/>Copyright (C), 2001-2014, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee [email protected]
* @version 1.0
*/
public class ScrollViewTest extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
| [
"[email protected]"
] | |
a4dc0ec103b8c28de5ab6496f0be75eeb0819d2b | f599281b56f97d56ef647f172a9b63772a8c231d | /spring/src/main/java/cn/vincent/taste/spicy/spring/BeanPropertiesCopier.java | c3184fc73453914e12bd1078f0feee1fdbfad87b | [
"Apache-2.0"
] | permissive | vincent1857/taste-spicy | f035d63d8a7366067a7d461a8860895d9d802351 | 3e62fab434285b18735212a0331a58024fe59a72 | refs/heads/master | 2021-05-17T09:08:59.894017 | 2020-07-07T02:33:25 | 2020-07-07T02:33:25 | 250,720,470 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,152 | java | /*
* Copyright (c) 2015 by vincent.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.vincent.taste.spicy.spring;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.util.Assert;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
/**
* ๆฉๅฑspring็BeanUtils๏ผๅขๅ ๆท่ดๅฑๆงๆ้คnullๅผ็ๅ่ฝ(ๆณจ๏ผStringไธบnullไธ่่)
*
* @author vincent
* @version 1.0 2017/8/20 01:15
*/
public class BeanPropertiesCopier extends BeanUtils {
public static void copyNotNullProperties(Object source, Object target, String[] ignoreProperties) throws BeansException {
copyNotNullProperties(source, target, null, ignoreProperties);
}
public static void copyNotNullProperties(Object source, Object target, Class<?> editable) throws BeansException {
copyNotNullProperties(source, target, editable, null);
}
public static void copyNotNullProperties(Object source, Object target) throws BeansException {
copyNotNullProperties(source, target, null, null);
}
private static void copyNotNullProperties(Object source, Object target, Class<?> editable, String[] ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");
Class<?> actualEditable = target.getClass();
if (editable != null) {
if (!editable.isInstance(target)) {
throw new IllegalArgumentException("Target class [" + target.getClass().getName() + "] not assignable to Editable class [" + editable.getName() + "]");
}
actualEditable = editable;
}
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null) ? Arrays.asList(ignoreProperties) : null;
for (PropertyDescriptor targetPd : targetPds) {
boolean flag = (ignoreProperties == null || (!ignoreList.contains(targetPd.getName())));
if (targetPd.getWriteMethod() != null && flag) {
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
if (sourcePd != null && sourcePd.getReadMethod() != null) {
try {
Method readMethod = sourcePd.getReadMethod();
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(source);
boolean stringValueTypeFlag = "java.lang.String".equals(readMethod.getReturnType().getName());
// ่ฟ้ๅคๆญไปฅไธvalueๆฏๅฆไธบ็ฉบ๏ผๅฝ็ถ่ฟ้ไน่ฝ่ฟ่กไธไบ็นๆฎ่ฆๆฑ็ๅค็ ไพๅฆ็ปๅฎๆถๆ ผๅผ่ฝฌๆข็ญ็ญ๏ผๅฆๆๆฏString็ฑปๅ๏ผๅไธ้่ฆ้ช่ฏๆฏๅฆไธบ็ฉบ
if (value != null || stringValueTypeFlag) {
boolean isEmpty = false;
if (stringValueTypeFlag) {
if (value == null) {
isEmpty = true;
} else {
String stringValue = (String) value;
if ("".equals(stringValue.trim())) {
isEmpty = true;
}
}
}
if (value instanceof Set) {
Set<?> s = (Set<?>) value;
if (s.isEmpty()) {
isEmpty = true;
}
} else if (value instanceof Map) {
Map<?, ?> m = (Map<?, ?>) value;
if (m.isEmpty()) {
isEmpty = true;
}
} else if (value instanceof List) {
List<?> l = (List<?>) value;
if (l.size() < 1) {
isEmpty = true;
}
} else if (value instanceof Collection) {
Collection<?> c = (Collection<?>) value;
if (c.size() < 1) {
isEmpty = true;
}
}
if (!isEmpty) {
Method writeMethod = targetPd.getWriteMethod();
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
}
writeMethod.invoke(target, value);
}
}
} catch (Throwable ex) {
throw new FatalBeanException("Could not copy properties from source to target", ex);
}
}
}
}
}
public static void copyNotNullPropertiesSimple(Object source, Object target, String[] ignoreProperties) throws BeansException {
copyNotNullPropertiesSimple(source, target, null, ignoreProperties);
}
public static void copyNotNullPropertiesSimple(Object source, Object target, Class<?> editable) throws BeansException {
copyNotNullPropertiesSimple(source, target, editable, null);
}
public static void copyNotNullPropertiesSimple(Object source, Object target) throws BeansException {
copyNotNullPropertiesSimple(source, target, null, null);
}
/**
* ่ฟไธชๅฎ็ฐๅชๆฏ็ฎๅ็ๅคๆญๅผๆฏๅฆ็ญไบnull๏ผไธๅๅ
ถไป้ป่ฎคๅผ็ๅคๆญ
*
* @param source ๆบๅฏน่ฑก
* @param target ็ฎๆ ๅฏน่ฑก
* @param editable ๆฏๅฆๅฏ็ผ่พ
* @param ignoreProperties ๅฟฝ็ฅๅฑๆง
* @throws BeansException ๅผๅธธ
*/
private static void copyNotNullPropertiesSimple(Object source, Object target, Class<?> editable, String[] ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");
Class<?> actualEditable = target.getClass();
if (editable != null) {
if (!editable.isInstance(target)) {
throw new IllegalArgumentException("Target class [" + target.getClass().getName() + "] not assignable to Editable class [" + editable.getName() + "]");
}
actualEditable = editable;
}
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null) ? Arrays.asList(ignoreProperties) : null;
for (PropertyDescriptor targetPd : targetPds) {
boolean flag = (ignoreProperties == null || (!ignoreList.contains(targetPd.getName())));
if (targetPd.getWriteMethod() != null && flag) {
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
if (sourcePd != null && sourcePd.getReadMethod() != null) {
try {
Method readMethod = sourcePd.getReadMethod();
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(source);
if (value != null) {
Method writeMethod = targetPd.getWriteMethod();
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
}
writeMethod.invoke(target, value);
}
} catch (Throwable ex) {
throw new FatalBeanException("Could not copy properties from source to target", ex);
}
}
}
}
}
}
| [
"[email protected]"
] | |
4a8445d4ec0b162a9c5d8f55be1860b43cfc9800 | d4e56ef19d4aa3634e56435e4bb82651112029a7 | /src/main/java/com/dts/discover/jsearch/exception/KeyNotFoundException.java | 204b7bdaec1562cf511d3e20b10c7a76a3f9b0ec | [] | no_license | duminda-kt/command-line-search-app | 2dfad3d6ae9a60093f5d9a049b3b8fb9811294cf | 00f447e0f33e109ce9e0b692d7aa235a53d19eda | refs/heads/main | 2023-05-28T19:34:45.266720 | 2021-06-22T08:55:37 | 2021-06-22T08:55:37 | 379,155,945 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 191 | java | package com.dts.discover.jsearch.exception;
public class KeyNotFoundException extends Exception {
public KeyNotFoundException(String errorMessage) {
super(errorMessage);
}
}
| [
"="
] | = |
b284a5c4ede63ecd5a1ad3200daa0a96a0c151ff | fc9f781dcf4907114f884e33b634eb8d0f6ddd5a | /ActiSoftWeb/src/java/Agenda/AgendaList.java | cdb0cbf242bce426268a77574e8ab9114b7f5e7d | [] | no_license | Dgiulian/ActiSoft | c3517fa09c0179764cde2e23405273f4c4d71554 | 7f9b50772b2bde1ed905cb0c899356d8b0a04e83 | refs/heads/master | 2021-05-01T15:22:57.506495 | 2020-10-10T00:35:35 | 2020-10-10T00:35:35 | 50,962,477 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,768 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Agenda;
import bd.Agenda;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import transaccion.TAgenda;
import utils.BaseException;
import utils.JsonRespuesta;
import utils.Parser;
/**
*
* @author Diego
*/
public class AgendaList extends HttpServlet {
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("application/json;charset=UTF-8");
PrintWriter out = response.getWriter();
String pagNro = request.getParameter("pagNro");
Integer id_usuario = Parser.parseInt(request.getParameter("id_usuario"));
HashMap<String,String> mapFiltro = new HashMap<String,String>();
Integer page = (pagNro!=null)?Integer.parseInt(pagNro):0;
JsonRespuesta jr = new JsonRespuesta();
try {
List<Agenda> lista;
TAgenda tr = new TAgenda();
if(id_usuario!=0)
mapFiltro.put("id_usuario",id_usuario.toString());
lista = tr.getListFiltro(mapFiltro);
if (lista != null) {
jr.setTotalRecordCount(lista.size());
} else {
jr.setTotalRecordCount(0);
}
jr.setResult("OK");
jr.setRecords(lista);
if(id_usuario!=0) throw new BaseException("ERROR","No se encontró el usuario");
} catch(BaseException ex){
jr.setResult(ex.getResult());
jr.setMessage(ex.getMessage());
}
finally {
String jsonResult = new Gson().toJson(jr);
out.print(jsonResult);
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"[email protected]"
] | |
a4efdad1f3ca09b183548ba74699407291e9096f | b9fb1b6d553e524395d3beb76d246b11b5063ff6 | /JavaConsole/src/Controller.java | 7bb92c5b6675653634f8a2f2a951f0bcab855966 | [] | no_license | khadegaosman/kangae- | a8f520d3246e078b95cbcb6c393231f34379449d | 2d752a9ff2284d306622ab90a36d77347bff2aa6 | refs/heads/master | 2020-03-22T21:37:33.381213 | 2018-06-04T23:10:34 | 2018-06-04T23:10:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,475 | java | import javax.xml.crypto.Data;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
public class Controller implements Serializable{
private static ArrayList<User> users = new ArrayList<>();
private static ArrayList<Game> games = new ArrayList<>();
private static User loggedInUser = null;
private static int validSignUp(User newUser) {
for (User u : users) {
if (u.getEmail().equals(newUser.getEmail()))
return 0;
if ( u.getUserName().equals(newUser.getUserName()))
return 1;
}
return 2;
}
static int signUp(String firstName, String lastName, String userName, String password, String email, String gender,
String biography, String birthDate, boolean isTeacher) {
User newUser;
if (isTeacher) {
newUser = new Teacher(firstName, lastName, userName, password, email, gender, biography, birthDate);
} else {
newUser = new Student(firstName, lastName, userName, password, email, gender, biography, birthDate);
}
int validationAnswer = validSignUp(newUser);
if (validSignUp(newUser) != 2) {
return validationAnswer;
}
users.add(newUser);
loggedInUser = newUser;
return 2;
}
static boolean signIn(String userNameOrEmail, String password) {
for (User u : users) {
if ((u.getEmail().equals(userNameOrEmail) || u.getUserName().equals(userNameOrEmail)) && u.getPassword().equals(password)) {
loggedInUser = u;
return true;
}
}
return false;
}
public static User getLoggedInUser() {
return loggedInUser;
}
public static void setLoggedInUser (){
loggedInUser = null;
}
public static ArrayList<Game> getGames() {
return games;
}
public static ArrayList<User> getUsers() {
return users;
}
public static void start () throws IOException, ClassNotFoundException {
Database database = new Database();
games = database.readSerializerGames("games.ser");
users = database.readSerializerUsers("users.ser");
}
public static void finish () throws IOException {
Database database = new Database();
database.writeSerializeGames(games, "games.ser");
database.writeSerializeUsers(users, "users.ser");
}
}
| [
"[email protected]"
] | |
67df61d2b77f6b56a20b58f4bceb72c3dcec8ea5 | 3b8690b659fffe81298f91d39c4d5e38e8ffea15 | /wc18-back/wc18-domain/src/main/java/com/github/mjeanroy/wc18/domain/models/Rank.java | 468ace2bd99982477c8c28801b09b21af3c959d2 | [] | no_license | mjeanroy/wc18 | ce0a6924d5a193e0d2c1ed5ef98d7e7d08d00fdf | aea9e8a0ddf3ef4ad67dbbde6fac84a421707068 | refs/heads/master | 2020-03-21T03:53:49.338315 | 2018-09-19T14:28:26 | 2018-09-19T15:08:28 | 138,079,874 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,408 | java | /**
* The MIT License (MIT)
*
* Copyright (c) 2018 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.mjeanroy.wc18.domain.models;
public class Rank {
/**
* The identifier.
*/
private final String id;
/**
* The user.
*/
private final User user;
/**
* Number of points won by user.
*/
private final int score;
/**
* The percentage of good pronostics.
*/
private final int percentGood;
/**
* The percentage of perfect pronostics.
*/
private final int percentPerfect;
// Default constructor.
public Rank(User user, int score, int percentGood, int percentPerfect) {
this.id = user.getId();
this.user = user;
this.score = score;
this.percentGood = percentGood;
this.percentPerfect = percentPerfect;
}
/**
* Get {@link #id}
*
* @return {@link #id}
*/
public String getId() {
return id;
}
/**
* Get {@link #user}
*
* @return {@link #user}
*/
public User getUser() {
return user;
}
/**
* Get {@link #score}
*
* @return {@link #score}
*/
public int getScore() {
return score;
}
/**
* Get {@link #percentGood}
*
* @return {@link #percentGood}
*/
public int getPercentGood() {
return percentGood;
}
/**
* Get {@link #percentPerfect}
*
* @return {@link #percentPerfect}
*/
public int getPercentPerfect() {
return percentPerfect;
}
}
| [
"[email protected]"
] | |
955256cc6f38af1ee48b8c080da711c5ce90cea2 | 6c6e3ec274a930c94aa1dcb79085765a0ef70763 | /Code/Code/src/test/Test.java | 88b8e848adcc9c1e50b1220fbe23658e3a7dce5b | [] | no_license | Kinice/Blog | 5316fd48d5f8fb91d1740c329073d2144e87b522 | 0fa09c07a55e6a234ac80cdeb9c3932b8db426e8 | refs/heads/master | 2021-01-19T01:41:24.630428 | 2017-03-09T17:45:09 | 2017-03-09T17:45:09 | 84,393,743 | 0 | 0 | null | 2017-03-09T03:26:57 | 2017-03-09T03:26:57 | null | UTF-8 | Java | false | false | 247 | java | package test;
public class Test extends FatherClass implements TestInterface{
/*public void test(){
System.out.println("this");
}
*/
public static void main(String args[]) {
System.out.println("้ๅทๅคงๅญฆ".substring(0, 3));
}
}
| [
"[email protected]"
] | |
db2f1f81b139d41570260bf8621a8e3e52c49b4c | 95ffdbacafb9255d9dfe8c5caa84c5d324025848 | /zpoi/src/org/zkoss/poi/hssf/record/chart/SheetPropertiesRecord.java | cb3088a4275f1346cb760c12b2d3917e83893874 | [
"MIT"
] | permissive | dataspread/dataspread-web | 2143f3451c141a4857070a67813208c8f2da50dc | 2d07f694c7419473635e355202be11396023f915 | refs/heads/master | 2023-01-12T16:12:47.862760 | 2021-05-09T02:30:42 | 2021-05-09T02:30:42 | 88,792,776 | 139 | 34 | null | 2023-01-06T01:36:17 | 2017-04-19T21:32:30 | Java | UTF-8 | Java | false | false | 7,133 | java | /* ====================================================================
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.zkoss.poi.hssf.record.chart;
import org.zkoss.poi.hssf.record.RecordInputStream;
import org.zkoss.poi.hssf.record.StandardRecord;
import org.zkoss.poi.util.BitField;
import org.zkoss.poi.util.BitFieldFactory;
import org.zkoss.poi.util.HexDump;
import org.zkoss.poi.util.LittleEndianOutput;
/**
* Describes a chart sheet properties record. SHTPROPS (0x1044) <p/>
*
* (As with all chart related records, documentation is lacking.
* See {@link ChartRecord} for more details)
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public final class SheetPropertiesRecord extends StandardRecord {
public final static short sid = 0x1044;
private static final BitField chartTypeManuallyFormatted = BitFieldFactory.getInstance(0x01);
private static final BitField plotVisibleOnly = BitFieldFactory.getInstance(0x02);
private static final BitField doNotSizeWithWindow = BitFieldFactory.getInstance(0x04);
private static final BitField defaultPlotDimensions = BitFieldFactory.getInstance(0x08);
private static final BitField autoPlotArea = BitFieldFactory.getInstance(0x10);
private int field_1_flags;
private int field_2_empty;
public final static byte EMPTY_NOT_PLOTTED = 0;
public final static byte EMPTY_ZERO = 1;
public final static byte EMPTY_INTERPOLATED = 2;
public SheetPropertiesRecord() {
// fields uninitialised
}
public SheetPropertiesRecord(RecordInputStream in) {
field_1_flags = in.readUShort();
field_2_empty = in.readUShort();
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[SHTPROPS]\n");
buffer.append(" .flags = ").append(HexDump.shortToHex(field_1_flags)).append('\n');
buffer.append(" .chartTypeManuallyFormatted= ").append(isChartTypeManuallyFormatted()).append('\n');
buffer.append(" .plotVisibleOnly = ").append(isPlotVisibleOnly()).append('\n');
buffer.append(" .doNotSizeWithWindow = ").append(isDoNotSizeWithWindow()).append('\n');
buffer.append(" .defaultPlotDimensions = ").append(isDefaultPlotDimensions()).append('\n');
buffer.append(" .autoPlotArea = ").append(isAutoPlotArea()).append('\n');
buffer.append(" .empty = ").append(HexDump.shortToHex(field_2_empty)).append('\n');
buffer.append("[/SHTPROPS]\n");
return buffer.toString();
}
public void serialize(LittleEndianOutput out) {
out.writeShort(field_1_flags);
out.writeShort(field_2_empty);
}
protected int getDataSize() {
return 2 + 2;
}
public short getSid() {
return sid;
}
public Object clone() {
SheetPropertiesRecord rec = new SheetPropertiesRecord();
rec.field_1_flags = field_1_flags;
rec.field_2_empty = field_2_empty;
return rec;
}
/**
* Get the flags field for the SheetProperties record.
*/
public int getFlags() {
return field_1_flags;
}
/**
* Get the empty field for the SheetProperties record.
*
* @return One of
* EMPTY_NOT_PLOTTED
* EMPTY_ZERO
* EMPTY_INTERPOLATED
*/
public int getEmpty() {
return field_2_empty;
}
/**
* Set the empty field for the SheetProperties record.
*
* @param empty
* One of
* EMPTY_NOT_PLOTTED
* EMPTY_ZERO
* EMPTY_INTERPOLATED
*/
public void setEmpty(byte empty) {
this.field_2_empty = empty;
}
/**
* Sets the chart type manually formatted field value.
* Has the chart type been manually formatted?
*/
public void setChartTypeManuallyFormatted(boolean value) {
field_1_flags = chartTypeManuallyFormatted.setBoolean(field_1_flags, value);
}
/**
* Has the chart type been manually formatted?
* @return the chart type manually formatted field value.
*/
public boolean isChartTypeManuallyFormatted() {
return chartTypeManuallyFormatted.isSet(field_1_flags);
}
/**
* Sets the plot visible only field value.
* Only show visible cells on the chart.
*/
public void setPlotVisibleOnly(boolean value) {
field_1_flags = plotVisibleOnly.setBoolean(field_1_flags, value);
}
/**
* Only show visible cells on the chart.
* @return the plot visible only field value.
*/
public boolean isPlotVisibleOnly() {
return plotVisibleOnly.isSet(field_1_flags);
}
/**
* Sets the do not size with window field value.
* Do not size the chart when the window changes size
*/
public void setDoNotSizeWithWindow(boolean value) {
field_1_flags = doNotSizeWithWindow.setBoolean(field_1_flags, value);
}
/**
* Do not size the chart when the window changes size
* @return the do not size with window field value.
*/
public boolean isDoNotSizeWithWindow() {
return doNotSizeWithWindow.isSet(field_1_flags);
}
/**
* Sets the default plot dimensions field value.
* Indicates that the default area dimensions should be used.
*/
public void setDefaultPlotDimensions(boolean value) {
field_1_flags = defaultPlotDimensions.setBoolean(field_1_flags, value);
}
/**
* Indicates that the default area dimensions should be used.
* @return the default plot dimensions field value.
*/
public boolean isDefaultPlotDimensions() {
return defaultPlotDimensions.isSet(field_1_flags);
}
/**
* Sets the auto plot area field value.
* ??
*/
public void setAutoPlotArea(boolean value) {
field_1_flags = autoPlotArea.setBoolean(field_1_flags, value);
}
/**
* ??
* @return the auto plot area field value.
*/
public boolean isAutoPlotArea() {
return autoPlotArea.isSet(field_1_flags);
}
}
| [
"[email protected]"
] | |
79ff616def5c79d1476937e14ba8629d4b1317e8 | 02e67d447887f024b4f397262931da67c7dea526 | /src/java/com/dtos/ErrorDTO.java | a9454b200a2311c44f4a304d1f0e5c81865314f7 | [] | no_license | nguyen-tri-nhan/mooncakeshop | 0a7a41ea7fe1b6d90ae112dc084c99a0ed0e7c4e | 054026d6b9b1ac040c023106d290cc53d7cbae83 | refs/heads/main | 2023-01-12T07:54:47.236567 | 2020-11-16T12:51:35 | 2020-11-16T12:51:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 765 | java | /*
* 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.dtos;
/**
*
* @author Lenovo
*/
public class ErrorDTO {
String username, password;
public ErrorDTO() {
}
public ErrorDTO(String username, String password) {
this.username = username;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"[email protected]"
] | |
a13271faabbdc1d5614096a09240b52aa8230821 | 60786d83ce800ece6405bd0fb81f2bcb7f97db70 | /src/test/java/com/TestCases/BazaarVoiceReviewTestValidationForEnglish.java | 295b903969fdff238bfa44ac8f7315d951cc6d19 | [] | no_license | sskumar35/PR-Automation | 30453e27cd15c4de191a678638cfa6813de05d51 | 4f19e9638e376ca5bbcd404b5f277b6e9f627895 | refs/heads/master | 2020-03-30T00:53:57.489976 | 2019-01-21T10:24:29 | 2019-01-21T10:30:10 | 150,549,326 | 0 | 0 | null | 2018-09-27T09:21:24 | 2018-09-27T07:48:18 | null | UTF-8 | Java | false | false | 5,372 | java | package com.TestCases;
import java.text.DecimalFormat;
import org.openqa.selenium.JavascriptExecutor;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.BusinessComponents.CountrySelectorActions;
import com.BusinessComponents.HomePageActions;
import com.BusinessComponents.LoginPageAction;
import com.BusinessComponents.ProductDetailPageActions;
import com.Utilities.CommonUtils;
import com.Utilities.TestLogger;
//import junit.framework.Assert;
public class BazaarVoiceReviewTestValidationForEnglish extends CommonUtils{
@BeforeTest
public void setUp() throws Exception {
init();
HomePageActions.HandlingModalSuggestedBox();
HomePageActions.LoginAction();
String emailAddress = "[email protected]";
String password = "12345678";
LoginPageAction.TypeUserEmailAddress(emailAddress);
LoginPageAction.TypeUserPassword(password);
LoginPageAction.clickSignInButton();
}
@Test (priority=0)
public void NonGoogleShoppingUser_BazaarVoiceReviewTestValidationForEnglish_INDIA() throws Exception{
try {
TestLogger.testLoggerTCStart("Bazaar Voice Review Test Validation For English_INDIA - TC Start");
CountrySelectorActions.ClickCountrySelectorInHomePage();
CountrySelectorActions.SearchCountryDropDownInModalWindow("India");
Thread.sleep(500);
takeSnapShot();
HomePageActions.HandlingModalSuggestedBox();
Thread.sleep(1000);
String prodId1 = "912";
HomePageActions.SearchForAProduct(prodId1);
HomePageActions.ClickSearchButton();
ProductDetailPageActions.ClickViewReviewsTab();
takeSnapShot();
Thread.sleep(1000);
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0,500)");
Thread.sleep(1000);
takeSnapShot();
js.executeScript("window.scrollBy(0,800)");
Thread.sleep(1000);
takeSnapShot();
double valForAvgStarRating = ProductDetailPageActions.ValidateAvgOverallRatingFromStar();
DecimalFormat d = new DecimalFormat("##.0");
String rABR = ProductDetailPageActions.GetAvgOverallBVRatings();
System.out.println("Average Overall BV Ratings: " + rABR);
String rOQS = ProductDetailPageActions.GetAvgOverallQualityRatings();
System.out.println("Average Overall Quality Ratings: " + rOQS);
String rOVS = ProductDetailPageActions.GetAvgOverallValueRatings();
System.out.println("Average Overall Value Ratings: " + rOVS);
String r5 = ProductDetailPageActions.GetRatingSnapShot5Star();
System.out.println("Average 5 Star Total Ratings: " + r5);
String r4 = ProductDetailPageActions.GetRatingSnapShot4Star();
System.out.println("Average 4 Star Total Ratings: " + r4);
String r3 = ProductDetailPageActions.GetRatingSnapShot3Star();
System.out.println("Average 3 Star Total Ratings: " + r3);
String r2 = ProductDetailPageActions.GetRatingSnapShot2Star();
System.out.println("Average 2 Star Total Ratings: " + r2);
String r1 = ProductDetailPageActions.GetRatingSnapShot1Star();
System.out.println("Average 1 Star Total Ratings: " + r1);
//takeSnapShot();
String rOR = ProductDetailPageActions.GetRatingOnlyReviews();
System.out.println("Ratings Only Reviews: "+ rOR);
String rOL = ProductDetailPageActions.GetReviewsInOtherLanguages();
System.out.println("Reviews In Other Languages: " + rOL);
String titleChk1 = ProductDetailPageActions.GetAvgCustRatingsTitleInPanel();
System.out.println("Avg Cust Ratings Title In Panel " + titleChk1);
String titleChk2 = ProductDetailPageActions.GetAvgCustOverallRatingsTitle();
System.out.println("Avg Cust Overall Ratings " + titleChk2);
String titleChk3 = ProductDetailPageActions.GetAvgCustOverallQualityRatingsTitle();
System.out.println("Avg Cust Overall Quality Ratings Title " + titleChk3);
String titleChk4 = ProductDetailPageActions.GetAvgCustOverallValueRatingsTitle();
System.out.println("Avg Cust Overall Value Ratings Title " + titleChk4);
String titleChk5 = ProductDetailPageActions.GetRatingSnapshotFilterTitle();
System.out.println("Rating Snapshot Filter Title " + titleChk5);
String titleChk6 = ProductDetailPageActions.GetReviewPanelHeaderTitle();
System.out.println("Review Panel Header Title " + titleChk6);
String titleChk7 = ProductDetailPageActions.GetRatingSnapshotTitle();
System.out.println("Rating Snapshot Title " + titleChk7);
String pageSrc = driver.getPageSource();
Assert.assertTrue(pageSrc.contains("//apps.bazaarvoice.com/deployments/pipingrock/main_site/staging/en_US/bv.js"));
Assert.assertEquals(d.format(valForAvgStarRating), rABR);
Assert.assertEquals(titleChk1, "Average Customer Ratings");
Assert.assertEquals(titleChk2, "Overall");
Assert.assertEquals(titleChk3, "Quality");
Assert.assertEquals(titleChk4, "Value");
Assert.assertEquals(titleChk5, "Select a row below to filter reviews.");
Assert.assertEquals(titleChk6, "Reviews");
Assert.assertEquals(titleChk7, "Rating Snapshot");
TestLogger.testLoggerTCEnd("Bazaar Voice Review Test Validation For English_INDIA - TC End");
} catch (Exception e) {
TestLogger.testLoggerInfo("Bazaar Voice Review Test Validation For English_INDIA - Failed" + e);
}
}
@AfterTest
public void driverClose() throws Exception {
LoginPageAction.UserLogout();
closeDriver();
}
}
| [
"[email protected]"
] | |
ae8087bd1e456aea844e605cd0be97b25bfd4751 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /sgw-20180511/src/main/java/com/aliyun/sgw20180511/models/OpenSgwServiceResponse.java | 6570dd024ea09e229eca5fafad4620c753814e65 | [
"Apache-2.0"
] | permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 1,052 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sgw20180511.models;
import com.aliyun.tea.*;
public class OpenSgwServiceResponse extends TeaModel {
@NameInMap("headers")
@Validation(required = true)
public java.util.Map<String, String> headers;
@NameInMap("body")
@Validation(required = true)
public OpenSgwServiceResponseBody body;
public static OpenSgwServiceResponse build(java.util.Map<String, ?> map) throws Exception {
OpenSgwServiceResponse self = new OpenSgwServiceResponse();
return TeaModel.build(map, self);
}
public OpenSgwServiceResponse setHeaders(java.util.Map<String, String> headers) {
this.headers = headers;
return this;
}
public java.util.Map<String, String> getHeaders() {
return this.headers;
}
public OpenSgwServiceResponse setBody(OpenSgwServiceResponseBody body) {
this.body = body;
return this;
}
public OpenSgwServiceResponseBody getBody() {
return this.body;
}
}
| [
"[email protected]"
] | |
48d6872e612351b01c20fa1d7c0b4831cf114c66 | f2f0893bbc7d8d39bd8dfdddd7200067d4558748 | /ThinkingInJava/app01/Group3.java | ff3096520080fb4ae58c7e2fc5d1ede3e3c61be7 | [] | no_license | DmytroPushkarchuk/JavaCore | a1fc60974efed6a6a5fe073e1acdcbed04be75e0 | 9ec6c20da69d2dfcc64eea3f96470a921a8c76e5 | refs/heads/master | 2020-04-11T19:35:35.188944 | 2019-05-05T16:54:57 | 2019-05-05T16:54:57 | 162,039,355 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 179 | java | package app01;
public class Group3 extends Group{
private String nameGroup = "Abstract Group";
@Override
public void getGroup() {
System.out.println(nameGroup);
}
}
| [
"[email protected]"
] | |
115bb75e0c587691f64132848450f02df7fd6529 | 262aec1027d0b293dae77945bb260d862aeb3d84 | /kbop_web/src/main/java/com/kbop/config/Swagger2Config.java | 06298e7268db1c1a380735163d330bd79055a324 | [
"MIT"
] | permissive | casxter/kbop | afc9e07f160b5b6c6c9a42ab7309ec064ccde819 | cb67b7339e664fcf00be5aa3b056b75a40927174 | refs/heads/master | 2021-01-15T23:02:27.689229 | 2017-10-20T07:21:57 | 2017-10-20T07:21:57 | 59,013,919 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 813 | java | package com.kbop.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author WallaceTang
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.kbop.controller"))
.paths(PathSelectors.any())
.build();
}
}
| [
"[email protected]"
] | |
b1636b3abf14bee2f2d589a2f99f80a258088551 | cd83caf150649be2101ca409b209833f1cbf7ba4 | /Exemplos/ExemploString01.java | 1caff018cc2d8a836bce2dbd4dcd0279edd8ca35 | [] | no_license | asoliveira-philips/Entra21Java-2018 | cb922ed9bbfedc02c4fadacdc0b8bbf59f111529 | 548317a9c10a500d538a376fa8afd49070d201fc | refs/heads/master | 2020-04-22T06:40:47.524980 | 2019-02-12T01:44:17 | 2019-02-12T01:44:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,402 | java | import javax.swing.JOptionPane;
public class ExemploString01{
public static void main(String[] arg){
String nome = "Curso de Java";
// retorna a quantidade de caracteres da String
System.out.println(nome);
System.out.println("Tamanho da String: "
+ nome.length());
String nick = JOptionPane.showInputDialog( "Informe o nick do seu pager");
if(nick.equals("")){
JOptionPane.showMessageDialog(null,
"Digite seu nick");
}
String jogoDoAno = " League of Legend ";
// reove espaรงos do comeรงo e do fim
jogoDoAno= jogoDoAno.trim();
String sistemaOperacional = "Linux";
// colocar o texto todo em caixa alta
sistemaOperacional = sistemaOperacional.toUpperCase();
// colocar o texto todo em caixa baixa
sistemaOperacional = sistemaOperacional.toLowerCase();
// pegar um caracter em determinado indice
char letra = sistemaOperacional.charAt(2);
String nomeCompleto = "Juan Roberto da Rocha";
System.out.println(nomeCompleto.substring(5,12));
// 01234
String nome2 = "casas".trim();
//nome = nome.trim();
char letra = nome.charAt(nome.lenght() - 1);
if(letra == 's'){
//plural
}else{
//singular
}
}
} | [
"[email protected]"
] | |
384610d124c51cfac2ede86999bbaf0073dcd8ab | e8d037631444f01b74c8fa11e5fc2c6a7d0bdd81 | /frank/src/com/maptest/MapKeySetTest.java | 4a9a65a89bc430193bea57a65f5a7bcd714c6e1b | [] | no_license | franklifeng/IDEAProjects | d42b556978f1183779c9372b3a36949f257774e3 | 99c95619111b9cd18e2296c0f5448e8ae11fd7a2 | refs/heads/master | 2023-06-07T03:21:49.152770 | 2021-07-05T06:17:36 | 2021-07-05T06:17:36 | 262,698,508 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 652 | java | package com.maptest;
import javafx.scene.effect.SepiaTone;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @author frank
* @create 2019-10-17 9:30
*/
public class MapKeySetTest {
public static void main(String[] args) {
Map map = new HashMap();
map.put("A","124");
map.put("A","124");
map.put("A","124");
map.put("A","124");
map.put("A","124");
map.put("A","127");
Set<String> set = map.keySet();
for(String k :set){
System.out.println(k);
}
ArrayList a = new ArrayList();
}
}
| [
"[email protected]"
] | |
fc05ee8f4045adf6c2b09a78ec6f0ea5e9683de8 | 8fb549b1a4a93bfbb32af594b7d09ea738ad11cc | /app/src/main/java/com/hacredition/xph/hacredition/utils/RecyclerAnimator.java | a2c64c536847f003020ce330133a206a0b036fae | [] | no_license | xbeginner/hacredition | e58659ea36fa9a412e0c12ca703c1b0d97c98727 | 24f59fcd9ec352036f00ee084f5937c76b1c766e | refs/heads/master | 2021-01-11T23:50:04.131564 | 2017-06-15T09:44:20 | 2017-06-15T09:44:20 | 78,633,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,437 | java | package com.hacredition.xph.hacredition.utils;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
/**
* Created by pc on 2017/1/20.
*/
public class RecyclerAnimator extends RecyclerView.ItemAnimator {
@Override
public boolean animateDisappearance(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull ItemHolderInfo preLayoutInfo, @Nullable ItemHolderInfo postLayoutInfo) {
return false;
}
@Override
public boolean animateAppearance(@NonNull RecyclerView.ViewHolder viewHolder, @Nullable ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
return false;
}
@Override
public boolean animatePersistence(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
return false;
}
@Override
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder, @NonNull RecyclerView.ViewHolder newHolder, @NonNull ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
return false;
}
@Override
public void runPendingAnimations() {
}
@Override
public void endAnimation(RecyclerView.ViewHolder item) {
}
@Override
public void endAnimations() {
}
@Override
public boolean isRunning() {
return false;
}
}
| [
"[email protected]"
] | |
03ec6017f66aa179532cb2c68c86a1afd1b181a5 | 0dad344de42e0d2e8b939d46ceb457206f6d9ca1 | /app/src/main/java/com/jx372/gugudanfighter/HelpActivity.java | b555108aa54c8fe388fffca26d0382cceef7b797 | [] | no_license | shruddnr12/GuGuDanFighter | 8ae1a414a6059dbadf9aba01d1dcfe62b91be174 | 96f50a2b54cf221a004c7e5177ef73816b92dd93 | refs/heads/master | 2021-01-01T18:32:47.323526 | 2017-07-25T08:34:40 | 2017-07-25T08:34:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 337 | java | package com.jx372.gugudanfighter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class HelpActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
}
}
| [
"[email protected]"
] | |
adaf5fb6a87c69ad6bf710ca81e61aa8c21b93f4 | 1415e38988783076c88d29d6b212a0a5c528a3c2 | /Project/src/view/TicketView.java | 0031eccb52b0c2c93ca40e3b06a41035340c8b63 | [] | no_license | ghldbssla/Project | e9eab28ff6cee6d22bc275f6c064bf3b891ae8ee | 477d69162b3d1e2ec1cd130ca137e8a585dd2753 | refs/heads/master | 2023-03-05T17:11:22.707367 | 2021-02-16T03:57:43 | 2021-02-16T03:57:43 | 331,629,634 | 1 | 0 | null | null | null | null | UHC | Java | false | false | 516 | java | package view;
import java.util.Scanner;
import dao.MovieDAO;
public class TicketView {
Scanner sc = new Scanner(System.in);
public TicketView() {
while(true) {
System.out.println("1. ์์๊ด ์ ํ\n2. ์ํ ์ ํ\n3. ๋ฌด๋น๋ทฐ๋ก ๊ฐ๊ธฐ");
int choice = sc.nextInt();
if(choice==3) {
new MovieView();
}
switch (choice) {
case 1:
// ์์๊ด ์ ํ
new TheaterView();
break;
case 2:
// ์ํ ์ ํ
new MovieChoiceView();
break;
}
}
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.