blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 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 684M ⌀ | 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 132
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 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4f6c36b02489957f49edd40cf3ea087097c60f7d | d0ad14bab3b742f6899cd0f420a74cd640760456 | /SchedulerAppku/src/com/nana/bankapp/services/MarketingServiceImpl.java | 0114964bed5076913a4ec8cea409930abf14e244 | [] | no_license | nfebrian13/invoicescheduler | 514687fb1726e357bb7444ee8531e02314d5b362 | d1c989923aa358b902a0bf0e8d0f8c86ccf7233e | refs/heads/master | 2020-04-11T13:27:28.897310 | 2019-02-07T06:40:46 | 2019-02-07T06:40:46 | 161,816,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,407 | java | package com.nana.bankapp.services;
import java.util.List;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nana.bankapp.dao.MarketingDAO;
import com.nana.bankapp.model.Marketing;
@Service
public class MarketingServiceImpl implements MarketingService {
@Autowired
MarketingDAO marketingDAO;
@Override
@Transactional
public boolean saveMarketing(Marketing marketing) {
return marketingDAO.saveMarketing(marketing);
}
@Override
@Transactional
public boolean editMarketing(Marketing marketing) {
return marketingDAO.editMarketing(marketing);
}
@Override
@Transactional
public List<Marketing> getMarketings() {
return marketingDAO.getMarketings();
}
@Override
@Transactional
public List<Marketing> pageMarketingList(Integer offset, Integer maxResults, boolean condition) {
return marketingDAO.pageMarketingList(offset, maxResults, condition);
}
@Override
@Transactional
public Marketing getMarketing(String marketingId) {
return marketingDAO.getMarketing(marketingId);
}
@Override
@Transactional
public boolean deleteMarketing(String marketingId) {
return marketingDAO.deleteMarketing(marketingId);
}
@Override
@Transactional
public Long count() {
return marketingDAO.count();
}
}
| [
"DEVELOPER@DESKTOP-4NJBGC4.localdomain"
] | DEVELOPER@DESKTOP-4NJBGC4.localdomain |
413a491c3d583b0164705a8255f9979ec6b6ab4a | 0cb066e1974b7e5a5bc9130868d1143ba3fb0735 | /src/com/cdrock/exceptionhandling/CustomException.java | 4a8fbd94ba288046ca5b60d922d9ee42cc4dfe81 | [] | no_license | sharmaischandan/JavaBasic | 80e0ae97b6c5db70b797a473b5b9b25a6b7b5919 | 80d118bd03bb03167b1aaed9ddb23d7182d1ce0b | refs/heads/master | 2023-05-02T01:23:00.545050 | 2021-05-26T11:12:10 | 2021-05-26T11:12:10 | 370,091,147 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package com.cdrock.exceptionhandling;
/**
* @author Chandan Sharma
*/
public class CustomException extends Exception{
void employeeNotFound(){
System.out.println("Employee not found");
}
}
| [
"sharmaischandan@users.noreply.github.com"
] | sharmaischandan@users.noreply.github.com |
d171afef54d47f7142ead1b3c01072457422ec0a | dabcac7013d79ad2541160a0a5c94984997a15b3 | /src/main/scala/com/jfbank/data/dataToHive/sqoop/SqoopMethod.java | d388ee330b49a2583c599d042dd96469cec5a0d1 | [] | no_license | superqiangsuper/mp_report | 68339f9042bf1890869a4d419240bb4917c92809 | 48d4d991d1348869ac04d5b444e80e21f0b5c205 | refs/heads/master | 2021-01-01T18:36:36.822597 | 2017-07-26T08:26:02 | 2017-07-26T08:26:02 | 98,383,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,334 | java | package com.jfbank.data.dataToHive.sqoop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by zhangzhiqiang on 2017/7/3.
*/
public abstract class SqoopMethod {
private final Logger logger = LoggerFactory.getLogger(SqoopMethod.class);
public String sqoopCode;
BufferedReader bufferedReader;
//设置sqoop代码
public abstract String setSqoopCode(String sqoopCode);
//执行脚本
public Boolean execSqoopCode() {
Process proc = null;
try {
proc = Runtime.getRuntime().exec(sqoopCode);
String ls_1;
bufferedReader = new BufferedReader( new InputStreamReader(proc.getInputStream()));
while ( (ls_1=bufferedReader.readLine()) != null)
{
logger.info(ls_1);
}
proc.waitFor();
if(proc.exitValue()==0){
return true;
}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
bufferedReader.close();
proc.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
return false;
}
}
| [
"zhangzhiqiang@9fbank.cc"
] | zhangzhiqiang@9fbank.cc |
d793743e91e482414d582654d77392541578493b | b9d6099793e11029e3cfa38a1734a3646a00ceea | /src/entity/Boat.java | cbbfa7bef31d8170ce2682cca6071f9eca438aa4 | [] | no_license | IshankaDK/SeaFood-Delivery-Management-System | ee0d8648fb6f61e8fa6ec6cf92a64578b25689ec | 5a6ba49868a639df903259eb6807fb0dabd48188 | refs/heads/master | 2023-02-23T11:34:13.333983 | 2021-01-24T15:24:49 | 2021-01-24T15:24:49 | 296,741,563 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,048 | java | package entity;
public class Boat implements SuperEntity {
private String boatId;
private String name;
private String ownerName;
private String ownerContact;
public Boat(String boatId, String name, String ownerName, String ownerContact) {
this.setBoatId(boatId);
this.setName(name);
this.setOwnerName(ownerName);
this.setOwnerContact(ownerContact);
}
public Boat() {
}
public String getBoatId() {
return boatId;
}
public void setBoatId(String boatId) {
this.boatId = boatId;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public String getOwnerContact() {
return ownerContact;
}
public void setOwnerContact(String ownerContact) {
this.ownerContact = ownerContact;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| [
"idkodippili@gmail.com"
] | idkodippili@gmail.com |
ff3e07c22e710f5521e4ba7d5ae1de892f705de1 | 1f1f39aef94e8855155128c8dec0dea9db3705da | /src/refactoring/observer/Refactor.java | ac5814f374fa98c427706666c87e11755f903579 | [] | no_license | hainndev/Java8CasesStudy | cc3042971b6d81d875d84c62e4ce2ba800e09f53 | 598a9c0546b0424ae847402a846e0bfc0cbb81f2 | refs/heads/master | 2020-03-23T22:34:18.327866 | 2018-07-24T17:34:28 | 2018-07-24T17:34:28 | 142,183,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 669 | 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 refactoring.observer;
/**
*
* @author hnguyen
*/
public class Refactor {
public static void main(String[] args) {
Feed feed = new Feed();
feed.registerObserver(new CafeF());
feed.registerObserver(new VnExpress());
//Using lamda
feed.registerObserver(tweet -> System.out.println("Dan Tri " + tweet));
feed.registerObserver(tweet -> System.out.println("24h " + tweet));
feed.notifyObservers("Java 8");
}
}
| [
"hainn.dev@gmail.com"
] | hainn.dev@gmail.com |
7015bf2078538f7f8ef87a99f306b59d366c6889 | 42010a3ef8277262c2b9248103af0e4742c96741 | /src/main/java/part1/_3_bags_queues_and_stacks/InfixToPostfix.java | 22ff62d6d0ec6e99e406bc302a1edc9f00f6f273 | [] | no_license | Duelist256/Algorithms4 | 012cb9700bdacb885a463e5c160f957221269a0c | ce1863f48b0a558659d9379283057492a7279468 | refs/heads/master | 2021-01-22T01:06:12.111703 | 2019-10-10T20:57:57 | 2019-10-10T20:57:57 | 102,199,683 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,769 | java | package part1._3_bags_queues_and_stacks;
import edu.princeton.cs.algs4.Stack;
/**
* 1.3.10 Write a filter InfixToPostfix that converts an arithmetic expression from infix
* to postfix.
**/
public class InfixToPostfix {
public static void main(String[] args) {
System.out.println(convert("1*(2+3*4)+5"));
System.out.println(convert("1*2^3+4"));
System.out.println(convert("1-2+3"));
System.out.println(convert("1*(2+3)"));
System.out.println(convert("1+2*3"));
}
public static String convert(String s) {
String newString = "";
Stack<Character> stack = new Stack<>();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isDigit(ch)) {
newString += ch;
}
if (ch == '(') {
stack.push(ch);
}
if (ch == ')') {
while (stack.peek() != '(') {
newString += stack.pop();
}
stack.pop();
}
if (ch == '*' || ch == '/' || ch == '+' || ch == '-' || ch == '^') {
while (!stack.isEmpty() && getPrecendence(ch) <= getPrecendence(stack.peek())) {
newString += stack.pop();
}
stack.push(ch);
}
}
while (!stack.isEmpty()) {
newString += stack.pop();
}
return newString;
}
private static int getPrecendence(char ch) {
if (ch == '^') {
return 2;
}
if (ch == '*' || ch == '/') {
return 1;
}
if (ch == '+' || ch == '-') {
return 0;
}
return -1;
}
}
| [
"selykov.iw@yandex.ru"
] | selykov.iw@yandex.ru |
dbbaea88b976dc8ff4e5f8a662973f757e42c9c7 | ee666a45a763caaeb01a323ca03a99db9c861e6c | /Bus-Station/src/busstation/view/Welcome.java | dd959486deb64d2c732e18083f04e8e82f18fb28 | [] | no_license | rahat002/cse470-project | d634c23dcf0bc9716c66081e4c0e62d91e5109f0 | a74822befe0a955ea6d6ed5e1abe3aaa156e77a4 | refs/heads/main | 2023-02-10T13:42:08.448983 | 2021-01-02T23:07:34 | 2021-01-02T23:07:34 | 321,231,962 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,928 | java |
package busstation.view;
import busstation.model.BusStation;
import java.io.File;
import javax.swing.JOptionPane;
public class Welcome extends javax.swing.JFrame {
boolean admin = false;
boolean user = false;
File record = new File ("click.wav");
public Welcome() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
button = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setLocation(new java.awt.Point(400, 200));
setUndecorated(true);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
button.setOpaque(false); button.setContentAreaFilled(false); button.setBorderPainted(true);
button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/busstation/view/images/cancel.png"))); // NOI18N
button.setBorderPainted(false);
button.setOpaque(false); button.setContentAreaFilled(false); button.setBorderPainted(false);
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonActionPerformed(evt);
}
});
getContentPane().add(button, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 20, 30, 30));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/busstation/view/images/bg.jpg"))); // NOI18N
jLabel1.setText("jLabel1");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 770, 510));
jButton2.setBackground(new java.awt.Color(204, 255, 102));
jButton2.setFont(new java.awt.Font("Copperplate Gothic Light", 1, 18)); // NOI18N
jButton2.setForeground(new java.awt.Color(255, 102, 0));
jButton2.setText("<< Welcome >>");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 510, 280, 50));
jButton1.setBackground(new java.awt.Color(153, 153, 153));
jButton1.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 18)); // NOI18N
jButton1.setText("User");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 510, 240, 50));
jButton3.setBackground(new java.awt.Color(153, 153, 153));
jButton3.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 18)); // NOI18N
jButton3.setText("Administrator");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 510, 240, 50));
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonActionPerformed
BusStation.playrecord(record);
Exit e = new Exit();
e.setVisible(true);
}//GEN-LAST:event_buttonActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
BusStation.playrecord(record);
Login x = new Login();
x.setVisible(true);
this.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
BusStation.playrecord(record);
Login1 y = new Login1();
y.setVisible(true);
this.setVisible(false);
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
BusStation.playrecord(record);
JOptionPane.showMessageDialog(null,"Please Choose One","Welcome",JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Welcome().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton button;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| [
"abrarul.hassan.rahat@g.bracu.ac.bd"
] | abrarul.hassan.rahat@g.bracu.ac.bd |
fc4efa087008fd04ac0132ad233ccf9c8ec62464 | 7e1511cdceeec0c0aad2b9b916431fc39bc71d9b | /flakiness-predicter/input_data/original_tests/doanduyhai-Achilles/nonFlakyMethods/info.archinnov.achilles.persistence.PersistenceManagerFactoryTest-should_deserialize_from_json.java | 43b4e759a9e2d2bf5db7d2b4361a62e2dd32aa5d | [
"BSD-3-Clause"
] | permissive | Taher-Ghaleb/FlakeFlagger | 6fd7c95d2710632fd093346ce787fd70923a1435 | 45f3d4bc5b790a80daeb4d28ec84f5e46433e060 | refs/heads/main | 2023-07-14T16:57:24.507743 | 2021-08-26T14:50:16 | 2021-08-26T14:50:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 622 | java | @Test public void should_deserialize_from_json() throws Exception {
pmf.configContext=configContext;
ObjectMapper mapper=new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
when(configContext.getMapperFor(CompleteBean.class)).thenReturn(mapper);
final CompleteBean actual=pmf.deserializeJson(CompleteBean.class,"{\"id\":10,\"name\":\"name\"}");
assertThat(actual.getId()).isEqualTo(10L);
assertThat(actual.getName()).isEqualTo("name");
assertThat(actual.getFriends()).isNull();
assertThat(actual.getFollowers()).isNull();
assertThat(actual.getPreferences()).isNull();
}
| [
"aalsha2@masonlive.gmu.edu"
] | aalsha2@masonlive.gmu.edu |
17d99a34e9f7f757b7449d17f9a4123c3aadb0a1 | 587af5f9934cf032f3b78360c4e6af407767cfa9 | /src/main/java/org/wltea/analyzer/core/CN_QuantifierSegmenter.java | b987a3a454de3567639384c5a6afb3dadd30e96a | [
"Apache-2.0"
] | permissive | TFdream/lucene-analyzer-ik | 95a53b55987a3a5fd5171b53931b86c11aa34397 | 7385f7a38c3842a21b335064debd79f690ae66b4 | refs/heads/master | 2021-08-04T13:06:53.167003 | 2021-07-05T10:40:48 | 2021-07-05T10:40:48 | 50,817,658 | 1 | 0 | Apache-2.0 | 2021-07-05T10:41:11 | 2016-02-01T05:55:14 | Java | UTF-8 | Java | false | false | 6,950 | java | /**
* IK 中文分词 版本 5.0
* IK Analyzer release 5.0
*
* 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.
*
* 源代码由林良益(linliangyi2005@gmail.com)提供
* 版权声明 2012,乌龙茶工作室
* provided by Linliangyi and copyright 2012 by Oolong studio
*
*/
package org.wltea.analyzer.core;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.wltea.analyzer.dic.Dictionary;
import org.wltea.analyzer.dic.Hit;
/**
*
* 中文数量词子分词器
*/
class CN_QuantifierSegmenter implements ISegmenter{
//子分词器标签
static final String SEGMENTER_NAME = "QUAN_SEGMENTER";
//中文数词
private static String Chn_Num = "一二两三四五六七八九十零壹贰叁肆伍陆柒捌玖拾百千万亿拾佰仟萬億兆卅廿";//Cnum
private static Set<Character> ChnNumberChars = new HashSet<Character>();
static{
char[] ca = Chn_Num.toCharArray();
for(char nChar : ca){
ChnNumberChars.add(nChar);
}
}
/*
* 词元的开始位置,
* 同时作为子分词器状态标识
* 当start > -1 时,标识当前的分词器正在处理字符
*/
private int nStart;
/*
* 记录词元结束位置
* end记录的是在词元中最后一个出现的合理的数词结束
*/
private int nEnd;
//待处理的量词hit队列
private List<Hit> countHits;
CN_QuantifierSegmenter(){
nStart = -1;
nEnd = -1;
this.countHits = new LinkedList<Hit>();
}
/**
* 分词
*/
public void analyze(AnalyzeContext context) {
//处理中文数词
this.processCNumber(context);
//处理中文量词
this.processCount(context);
//判断是否锁定缓冲区
if(this.nStart == -1 && this.nEnd == -1 && countHits.isEmpty()){
//对缓冲区解锁
context.unlockBuffer(SEGMENTER_NAME);
}else{
context.lockBuffer(SEGMENTER_NAME);
}
}
/**
* 重置子分词器状态
*/
public void reset() {
nStart = -1;
nEnd = -1;
countHits.clear();
}
/**
* 处理数词
*/
private void processCNumber(AnalyzeContext context){
if(nStart == -1 && nEnd == -1){//初始状态
if(CharacterUtil.CHAR_CHINESE == context.getCurrentCharType()
&& ChnNumberChars.contains(context.getCurrentChar())){
//记录数词的起始、结束位置
nStart = context.getCursor();
nEnd = context.getCursor();
}
}else{//正在处理状态
if(CharacterUtil.CHAR_CHINESE == context.getCurrentCharType()
&& ChnNumberChars.contains(context.getCurrentChar())){
//记录数词的结束位置
nEnd = context.getCursor();
}else{
//输出数词
this.outputNumLexeme(context);
//重置头尾指针
nStart = -1;
nEnd = -1;
}
}
//缓冲区已经用完,还有尚未输出的数词
if(context.isBufferConsumed()){
if(nStart != -1 && nEnd != -1){
//输出数词
outputNumLexeme(context);
//重置头尾指针
nStart = -1;
nEnd = -1;
}
}
}
/**
* 处理中文量词
* @param context
*/
private void processCount(AnalyzeContext context){
// 判断是否需要启动量词扫描
if(!this.needCountScan(context)){
return;
}
if(CharacterUtil.CHAR_CHINESE == context.getCurrentCharType()){
//优先处理countHits中的hit
if(!this.countHits.isEmpty()){
//处理词段队列
Hit[] tmpArray = this.countHits.toArray(new Hit[this.countHits.size()]);
for(Hit hit : tmpArray){
hit = Dictionary.getSingleton().matchWithHit(context.getSegmentBuff(), context.getCursor() , hit);
if(hit.isMatch()){
//输出当前的词
Lexeme newLexeme = new Lexeme(context.getBufferOffset() , hit.getBegin() , context.getCursor() - hit.getBegin() + 1 , Lexeme.TYPE_COUNT);
context.addLexeme(newLexeme);
if(!hit.isPrefix()){//不是词前缀,hit不需要继续匹配,移除
this.countHits.remove(hit);
}
}else if(hit.isUnmatch()){
//hit不是词,移除
this.countHits.remove(hit);
}
}
}
//*********************************
//对当前指针位置的字符进行单字匹配
Hit singleCharHit = Dictionary.getSingleton().matchInQuantifierDict(context.getSegmentBuff(), context.getCursor(), 1);
if(singleCharHit.isMatch()){//首字成量词词
//输出当前的词
Lexeme newLexeme = new Lexeme(context.getBufferOffset() , context.getCursor() , 1 , Lexeme.TYPE_COUNT);
context.addLexeme(newLexeme);
//同时也是词前缀
if(singleCharHit.isPrefix()){
//前缀匹配则放入hit列表
this.countHits.add(singleCharHit);
}
}else if(singleCharHit.isPrefix()){//首字为量词前缀
//前缀匹配则放入hit列表
this.countHits.add(singleCharHit);
}
}else{
//输入的不是中文字符
//清空未成形的量词
this.countHits.clear();
}
//缓冲区数据已经读完,还有尚未输出的量词
if(context.isBufferConsumed()){
//清空未成形的量词
this.countHits.clear();
}
}
/**
* 判断是否需要扫描量词
* @return
*/
private boolean needCountScan(AnalyzeContext context){
if((nStart != -1 && nEnd != -1 ) || !countHits.isEmpty()){
//正在处理中文数词,或者正在处理量词
return true;
}else{
//找到一个相邻的数词
if(!context.getOrgLexemes().isEmpty()){
Lexeme l = context.getOrgLexemes().peekLast();
if(Lexeme.TYPE_CNUM == l.getLexemeType() || Lexeme.TYPE_ARABIC == l.getLexemeType()){
if(l.getBegin() + l.getLength() == context.getCursor()){
return true;
}
}
}
}
return false;
}
/**
* 添加数词词元到结果集
* @param context
*/
private void outputNumLexeme(AnalyzeContext context){
if(nStart > -1 && nEnd > -1){
//输出数词
Lexeme newLexeme = new Lexeme(context.getBufferOffset() , nStart , nEnd - nStart + 1 , Lexeme.TYPE_CNUM);
context.addLexeme(newLexeme);
}
}
}
| [
"vricky.feng@gmail.com"
] | vricky.feng@gmail.com |
54448ed357f36acfa000951b0c0654f9034ea9f6 | 3a77a32b6c05340632b844cf5c9429a207afb6b9 | /springboot/springboot-shiro/src/main/java/com/iteedu/ssoboot/modules/common/utils/DateConverUtil.java | b6967e19eb36284e0be6a316268459eca51182ae | [] | no_license | douzh/techdemo | 85401fbf66f581861f01890aa7212deb66749de1 | f12da7b5ce2ec6e4198aab9b8f018edeef96d035 | refs/heads/master | 2022-07-08T02:59:40.545652 | 2019-05-29T10:05:37 | 2019-05-29T10:05:37 | 149,618,619 | 0 | 0 | null | 2022-06-30T14:44:13 | 2018-09-20T14:02:28 | Java | UTF-8 | Java | false | false | 5,940 | java | package com.iteedu.ssoboot.modules.common.utils;
import org.springframework.util.StringUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 日期转换工具类
* 时间转换工具类
* @author shuang
*
*/
public final class DateConverUtil {
/**
* 当前该系统提供的一些日期时间格式——————使用的是枚举
*/
public enum TimeType {
/**"yyyy-MM-dd HH:mm:ss"*/type1("yyyy-MM-dd HH:mm:ss")
,/**"yyyy/MM/dd HH:mm:ss"*/type2("yyyy/MM/dd HH:mm:ss")
,/**"yyyy.MM.dd HH:mm:ss"*/type3("yyyy.MM.dd HH:mm:ss")
,/**"yyMMdd HH:mm:ss"*/type4("yyyyMMdd HH:mm:ss")
,/**"yyyy年MM月dd日 HH:mm:ss"*/type5("yyyy年MM月dd日 HH:mm:ss")
,/**"yyyy-MM-dd HH:mm"*/type11("yyyy-MM-dd HH:mm")
,/**"yyyy/MM/dd HH:mm"*/type21("yyyy/MM/dd HH:mm")
,/**"yyyy.MM.dd HH:mm"*/type31("yyyy.MM.dd HH:mm")
,/**"yyMMdd HH:mm"*/type41("yyyyMMdd HH:mm")
,/**"yyyy年MM月dd日 HH:mm"*/type51("yyyy年MM月dd日 HH:mm")
,/**"yyyy-MM-dd"*/type111("yyyy-MM-dd")
,/**"yyyy/MM/dd"*/type211("yyyy/MM/dd")
,/**"yyyy.MM.dd"*/type311("yyyy.MM.dd")
,/**"yyMMdd"*/type411("yyyyMMdd")
,/**"yyyy年MM月dd日"*/type511("yyyy年MM月dd日")
,/**"yyyy-MM-dd"*/type1111("yyyy-MM")
,/**"yyyy/MM/dd"*/type2111("yyyy/MM")
,/**"yyyy.MM.dd"*/type3111("yyyy.MM")
,/**"yyMMdd"*/type4111("yyyyMM")
,/**"yyyy年MM月dd日"*/type5111("yyyy年MM月")
,/**"yyyy-MM-dd"*/type11111("yyyy")
,/**"HH:mm:ss"*/type6("HH:mm:ss");
private final String value;
public String getValue() {
return value;
}
TimeType(String value) {
this.value = value;
}
}
/**
* 参数设定或系统特定格式的字符串 转换成 日期时间格式
* @param sdate 传入的字符串。例如:2013-11-05
* @param toTypes 传入的字符串时间类型格式,例如:yyyy-MM-dd HH:mm:ss
* @return Date日期对象
*
* 示例:String time="2013-11-01 11:22";
* DateConverUtil.dd1(time);或者DateConverUtil.dd1(time,"yyyy-MM-dd HH:mm");
*/
public static Date getDbyST(String sdate, String... toTypes){
Date date=null;
if(StringUtils.hasText(sdate)){
boolean a=true;
if(a)
for(String toType:toTypes){
try {
date=getDateFormat(toType).parse(sdate);
a=false;
break;
} catch (Exception e) {
continue;
}
}
if(a)
for(TimeType toType: TimeType.values()){
try {
date=getDateFormat(toType.getValue()).parse(sdate);
a=false;
break;
} catch (Exception e) {
continue;
}
}
}
return date;
}
/**
* 日期时间格式 转换成 参数设定或系统特定格式的字符串
* @param type 传入的转换成的日期格式 , DateConverUtil.TimeType中有一部分日期时间格式
* @return 字符串类型
*
* 示例:DateConverUtil.dd2(new Date(),DateConverUtil.TimeType.type2.getValue()) 或者 DateConverUtil.dd2(new Date(),"yyyy-MM-dd H:m:s") ;
*/
public static String getSbyDT(Date date, String type){
try {
return getDateFormat(type).format(date);
} catch (Exception e) {
return null;
}
}
/**
* 参数设定或系统特定格式的日期时间字符串 转换成 参数设定字符串格式的日期时间
* @param sdate 传入的日期字符串
* @param targetType 传入的转换后的参数设定日期时间 格式
* @param sourceType 传入的转换前的日期时间 格式
* @return 字符串类型
*
* 示例:DateConverUtil.dd3("2015-2-11","yyyy年MM月dd日","yyyy-M-dd") ;
*/
public static String getSbySST(String sdate, String targetType, String... sourceType){
try {
return getSbyDT(getDbyST(sdate, sourceType),targetType);
} catch (Exception e) {
return null;
}
}
/**
* 获取当前系统时间
* @return
*/
public static Date getNowTime(){
Calendar calendar= Calendar.getInstance();
return calendar.getTime();
}
/**
* 用指定的年、月、日构造日期对象
* @param year 年
* @param month 月
* @param day 日
* @return 日期对象
*/
public static Date getTimeByYMD(int year, int month, int day) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day);
return calendar.getTime();
}
/**
* 设为严格格式
* @param type 传入的格式
* @return SimpleDateFormat的对象
*/
public static DateFormat getDateFormat(String type){
DateFormat dateFormat=new SimpleDateFormat(type);
dateFormat.setLenient(false);
return dateFormat;
}
/**
* 计算时间
* @param date 日期
* @param field 类型 如按秒计算为: Calendar.SECOND
* @param amount 计算量
* @return
* @throws Exception
* 例子:计算当前时间的前10秒的时间?
* TimeCalculate(new Date(), Calendar.SECOND, -10)
* 例子:计算当前时间的后10秒的时间?
* TimeCalculate(new Date(), Calendar.SECOND, 10)
*/
public static Date TimeCalculate(Date date, int field, int amount) {
try {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(field, amount);
return cal.getTime();
} catch (Exception e) {
return null;
}
}
/**
* 取得当月天数
* */
public static int getCurrentMonthLastDay(){
Calendar a = Calendar.getInstance();
a.set(Calendar.DATE, 1);//把日期设置为当月第一天
a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
/**
* 得到指定月的天数
* */
public static int getMonthLastDay(int year, int month){
Calendar a = Calendar.getInstance();
a.set(Calendar.YEAR, year);
a.set(Calendar.MONTH, month - 1);
a.set(Calendar.DATE, 1);//把日期设置为当月第一天
a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
}
| [
"douzihui@9fbank.com.cn"
] | douzihui@9fbank.com.cn |
9f23a3407303f200e0c889ad0640b807e1fbb53d | 44ce357ee9ca8df2f399f7e0fcdf385b7b34c245 | /src/main/java/org/apache/commons/math3/analysis/function/Expm1.java | 44f0a852877198880b0c7fba6f58cf5b28903eab | [] | no_license | silas1037/SkEye | a8712f273e1cadd69e0be7d993963016df227cb5 | ed0ede814ee665317dab3209b8a33e38df24a340 | refs/heads/master | 2023-01-20T20:25:00.940114 | 2020-11-29T04:01:05 | 2020-11-29T04:01:05 | 315,267,911 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,166 | java | package org.apache.commons.math3.analysis.function;
import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math3.analysis.FunctionUtils;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math3.util.FastMath;
public class Expm1 implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
@Override // org.apache.commons.math3.analysis.UnivariateFunction
public double value(double x) {
return FastMath.expm1(x);
}
@Override // org.apache.commons.math3.analysis.DifferentiableUnivariateFunction
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
@Override // org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction
public DerivativeStructure value(DerivativeStructure t) {
return t.expm1();
}
}
| [
"silas1037@163.com"
] | silas1037@163.com |
186bb06c07556a7e5a58f4c88d67816446f1bc33 | ade60a0cd4d5ce7ce7d3ecc0ca9e1c599219705c | /studyappfuse/core/src/main/java/org/yy/dao/hibernate/RoleDaoHibernate.java | 457bddbf7df5e603474741548d694547023d954d | [
"Apache-2.0"
] | permissive | yyitsz/myjavastudio | bc7d21ed8ece3eccc07cb0fbc6bbad0be04a7f60 | f5563d45c36d1a0b0a7ce1f5a360ff6017f068e8 | refs/heads/master | 2021-06-11T23:04:43.228001 | 2017-03-24T10:05:27 | 2017-03-24T10:05:27 | 17,080,356 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,083 | java | package org.yy.dao.hibernate;
import org.yy.dao.RoleDao;
import org.yy.model.Role;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* This class interacts with Spring's HibernateTemplate to save/delete and
* retrieve Role objects.
*
* @author <a href="mailto:bwnoll@gmail.com">Bryan Noll</a>
*/
@Repository
public class RoleDaoHibernate extends GenericDaoHibernate<Role, Long> implements RoleDao {
/**
* Constructor to create a Generics-based version using Role as the entity
*/
public RoleDaoHibernate() {
super(Role.class);
}
/**
* {@inheritDoc}
*/
public Role getRoleByName(String rolename) {
List roles = getHibernateTemplate().find("from Role where name=?", rolename);
if (roles.isEmpty()) {
return null;
} else {
return (Role) roles.get(0);
}
}
/**
* {@inheritDoc}
*/
public void removeRole(String rolename) {
Object role = getRoleByName(rolename);
getHibernateTemplate().delete(role);
}
}
| [
"yyitsz@163.com"
] | yyitsz@163.com |
5ce22ba38fb6b5387da37c80da6779bbc2fe862f | dda667a3f51e0bdd9e966229bb2aa9bfa124cb21 | /src/main/java/me/anpan/usermanage/member/MemberController.java | 1c4554835c3106fd7723e021cd87224f72b58b94 | [] | no_license | changjun89/user-manage | 1cf536a2f2947f7618572c730f8df1fe1753f787 | dde388dc5b2dce6afd4ce8fc05b4722b2414d8f4 | refs/heads/master | 2020-05-03T09:58:42.052696 | 2019-04-24T04:28:55 | 2019-04-24T04:28:55 | 178,568,033 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,158 | java | package me.anpan.usermanage.member;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@Controller
@RequestMapping("/member")
public class MemberController {
private static final Logger log = LoggerFactory.getLogger(MemberController.class);
@Autowired
MemberRepository userRepository;
@GetMapping("/loginform")
public String loginPage(HttpServletRequest req) {
return "/member/login.html";
}
@GetMapping("/failLogin")
public String failLoginPage() {
return "/member/login_failed.html";
}
@PostMapping("/login")
public String login(Member member, BindingResult result,
HttpServletRequest request) {
if (result.hasErrors()) {
return "/member/login_failed.html";
}
System.out.println("login controller");
request.getSession().setAttribute("member", member);
return "redirect:/member/list";
}
@GetMapping("/form")
public String userForm(Model model) {
return "/member/form.html";
}
@PostMapping("/create")
public String createUser(@Valid Member member, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "/member/login_failed.html";
}
MemberRole role = new MemberRole();
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
member.setPassword(passwordEncoder.encode(member.getPassword()));
role.setRoleName("BASIC");
member.setRoles(Arrays.asList(role));
Member newMember = userRepository.save(member);
log.info("새롭게 등록된 사용자 : {}", newMember);
return "redirect:/member/list";
}
@GetMapping("/list")
public String userList(Model model) {
List<Member> userList = userRepository.findAll();
model.addAttribute("members", userList);
return "/member/list";
}
@GetMapping("/modifyForm")
public String modifyMember(Model model, HttpServletRequest request) {
Long userId = Long.parseLong(request.getParameter("userId"));
Member member = userRepository.findById(userId).get();
model.addAttribute("member",member);
return "/member/modify.html";
}
@PostMapping("/modify")
public String modifyMember(@Valid Member member, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "/member/login_failed.html";
}
userRepository.save(member);
return "redirect:/member/list";
}
}
| [
"leechang0423@naver.com"
] | leechang0423@naver.com |
ff600866ad54143d3e86355da0a8e78aa2eaae50 | e0ce8cb64702eccce7f6940d283bc93e8f632745 | /tags/1.1/src/org/jajim/modelo/conversaciones/ParticipantesListener.java | 304e3d2b5cb02b5ff00ae7ce53b899dd491f7dd6 | [] | no_license | BackupTheBerlios/jajim-svn | 5842b35027d995358e605fbd2c5b61dc2b6f7e80 | 7fa2082094decb25e7765aaaebd611c418676f07 | refs/heads/master | 2021-01-01T17:56:36.627562 | 2013-12-06T20:16:30 | 2013-12-06T20:16:30 | 40,748,648 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,222 | java | /*
Jabber client.
Copyright (C) 2010 Florencio Cañizal Calles
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jajim.modelo.conversaciones;
import java.util.Observable;
import java.util.Observer;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;
/**
* @author Florencio Cañizal Calles
* @version 1.1
* Clase oyente que escucha los eventos de adición a un chat multiusurario proce
* dentes del servidor.
*/
public class ParticipantesListener extends Observable implements PacketListener{
private String nickPropio;
private String nick;
private String usuario;
/**
* Constructor de la clase. Iniciliza las variables necesarias.
* @param observador El observador que será notificado de los eventos produci
* dos.
*/
public ParticipantesListener(Observer observador){
this.addObserver(observador);
}
/**
* Método que se ejecuta cuando se recibe un paquete que informa de que un
* usuario se ha conectado a nuestro chat multiusuario.
* @param packet El paquete que confirma el evento.
*/
@Override
public void processPacket(Packet packet){
// Recuperar el nick del usuario
usuario = packet.getFrom();
nick = StringUtils.parseResource(usuario);
// Si es nuestro nick abortar la operación.
if(nick.compareTo(nickPropio) == 0) {
return;
}
// Si el paquete no es de desconexión.
if(packet.toString().compareTo("unavailable") != 0){
// Notificar a los oyentes que un usuario se ha añadido a la sala.
this.setChanged();
this.notifyObservers(EventosConversacionEnumeracion.participanteAñadido);
}else{
// Notificar a los oyentes que un usuario se ha desconectado de la sala.
this.setChanged();
this.notifyObservers(EventosConversacionEnumeracion.participanteDesconectado);
}
}
/**
* Método que actualiza el valor del atributo nickPropio.
* @param nickPropio El nuevo valor para el atributo.
*/
public void setNickPropio(String nickPropio){
this.nickPropio = nickPropio;
}
/**
* Retorna el valor del atributo nick.
* @return El valor del atributo nick.
*/
public String getNick(){
return nick;
}
/**
* Retorna el valor del atributo usuario.
* @return El valor del atributo usuario.
*/
public String getUsuario(){
return usuario;
}
}
| [
"npi83@66271abf-8d89-0410-bfa2-80b8d0f357ea"
] | npi83@66271abf-8d89-0410-bfa2-80b8d0f357ea |
b421eee684eae6c6954cb9230c434393e4f6d9ef | 9fcff89d2e35912d6faeb7e6d71b650d18fb1916 | /sdu.parent/sdu.server/main/java/kz.sdu.server/beans/Utf8AndTraceResetFilter.java | d320b69253ae89ffd231a12f21324f3603e7a79b | [] | no_license | zigzak1996/aliexpresKazakhstanVesion | b5a6f5348d1d6be52f50810aba2389c3cfed800a | f5e60f27aa69e0c01dcdeabbd0e0ab2f46795541 | refs/heads/master | 2021-08-24T10:01:57.820221 | 2017-12-09T04:13:57 | 2017-12-09T04:13:57 | 113,604,731 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 917 | java | package kz.sdu.server.beans;
import kz.greetgo.depinject.core.Bean;
import kz.sdu.controller.logging.LogIdentity;
import javax.servlet.*;
import java.io.IOException;
import java.util.EnumSet;
@Bean
public class Utf8AndTraceResetFilter implements Filter {
public void register(ServletContext ctx) {
FilterRegistration.Dynamic dynamic = ctx.addFilter(getClass().getName(), this);
dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
LogIdentity.resetThread();
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void destroy() {}
}
| [
"zig.zak.1996@gmail.com"
] | zig.zak.1996@gmail.com |
8f64315782bea0a5a3b5cefb3b689f09dc58b985 | 2940938bb4830ad1d0eacd903703cf52dea16642 | /hydrogen-library/src/main/java/androlua/widget/webview/WebViewActivity.java | fcfed671dd39d7be261b5bb114185540f0a58f40 | [
"Apache-2.0"
] | permissive | jvedi/hydrogenApp | 5a0f689faf92d4b3a1a8be2aa41148d9600beeaa | b496b4df5aefb6a666ea3f3d01d5c5583deccc7f | refs/heads/master | 2020-04-07T06:53:22.570218 | 2018-11-17T04:18:43 | 2018-11-17T04:18:43 | 158,154,436 | 1 | 0 | Apache-2.0 | 2018-11-19T03:06:39 | 2018-11-19T03:06:39 | null | UTF-8 | Java | false | false | 10,084 | java | package androlua.widget.webview;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
import android.support.v4.view.GravityCompat;
import android.support.v7.widget.PopupMenu;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.TextView;
import androlua.LuaUtil;
import androlua.base.BaseActivity;
import androlua.widget.statusbar.StatusBarView;
import pub.hanks.luajandroid.R;
/**
* Created by hanks on 2017/6/2. Copyright (C) 2017 Hanks
*/
public class WebViewActivity extends BaseActivity {
private EditText etUrl;
private String url, webTitle;
private int color;
private WebView mWebView;
private View loading;
private View layout_toolbar;
private View ivRefresh, iv_more;
private Bitmap colorBitmap;
private Canvas canvas;
private StatusBarView view_statusbar;
public static void start(Context context, String url) {
start(context, url, Color.TRANSPARENT);
}
public static void start(Context context, String url, int color) {
Intent starter = new Intent(context, WebViewActivity.class);
starter.putExtra("url", url);
starter.putExtra("color", color);
context.startActivity(starter);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
etUrl = (EditText) findViewById(R.id.et_url);
loading = findViewById(R.id.loading);
layout_toolbar = findViewById(R.id.layout_toolbar);
mWebView = (WebView) findViewById(R.id.webview);
ivRefresh = findViewById(R.id.iv_refresh);
iv_more = findViewById(R.id.iv_more);
view_statusbar = (StatusBarView) findViewById(R.id.view_statusbar);
colorBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
canvas = new Canvas(colorBitmap);
WebSettings settings = mWebView.getSettings();
settings.setUseWideViewPort(true);
settings.setAppCacheEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setDisplayZoomControls(false);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAllowContentAccess(true);
settings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT >= 19) {
mWebView.setWebContentsDebuggingEnabled(true);
}
url = getIntent().getStringExtra("url");
color = getIntent().getIntExtra("color", 0);
if (color == Color.TRANSPARENT) {
setLightStatusBar();
} else {
setStatusBarColor(color);
layout_toolbar.setBackgroundColor(color);
}
etUrl.setText(url);
etUrl.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (TextUtils.isEmpty(url) || TextUtils.isEmpty(webTitle)) {
return;
}
if (hasFocus) {
etUrl.setText(url);
} else {
etUrl.setText(webTitle);
}
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
webTitle = title;
etUrl.setText(title);
}
});
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
loading.setVisibility(View.VISIBLE);
ivRefresh.setVisibility(View.GONE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
loading.setVisibility(View.GONE);
ivRefresh.setVisibility(View.VISIBLE);
fetchColor();
}
@Deprecated
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("hydrogen://");
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
String url = "";
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
url = webResourceRequest.getUrl().toString();
}
return !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("hydrogen://");
}
});
ivRefresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mWebView.loadUrl(url);
}
});
mWebView.loadUrl(url);
iv_more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(iv_more.getContext(), v, GravityCompat.START);
popupMenu.getMenu().add(Menu.NONE, 1, Menu.NONE, "复制链接");
popupMenu.getMenu().add(Menu.NONE, 2, Menu.NONE, "在浏览器打开");
popupMenu.getMenu().add(Menu.NONE, 3, Menu.NONE, "分享");
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (TextUtils.isEmpty(url)) {
return false;
}
switch (item.getItemId()) {
case 1:
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) WebViewActivity.this.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("lua", url);
clipboard.setPrimaryClip(clip);
break;
case 2:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
WebViewActivity.this.startActivity(intent);
break;
case 3:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
sendIntent.setType("text/plain");
WebViewActivity.this.startActivity(sendIntent);
break;
}
return false;
}
});
popupMenu.show();
}
});
etUrl.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String url = etUrl.getText().toString();
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
mWebView.loadUrl(url);
}
return false;
}
});
}
private boolean canAsBgColor(int i) {
return Color.red(i) < 220 || Color.green(i) < 220 || Color.blue(i) < 220;
}
private void fetchColor() {
if (mWebView != null && mWebView.getVisibility() == View.VISIBLE && mWebView.getScrollX() < LuaUtil.dp2px(20)) {
mWebView.draw(canvas);
if (colorBitmap != null) {
int pixel = colorBitmap.getPixel(0, 0);
if (canAsBgColor(pixel)) {
layout_toolbar.setBackgroundColor(pixel);
if (pixel == Color.WHITE) {
setLightStatusBar();
} else {
setStatusBarColor(pixel);
}
}
}
}
}
@Override
public void onBackPressed() {
if (mWebView.canGoBack()) {
mWebView.goBack();
return;
}
super.onBackPressed();
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (mWebView != null) {
if (mWebView.getParent() instanceof ViewGroup) {
((ViewGroup) mWebView.getParent()).removeAllViews();
}
mWebView.stopLoading();
mWebView.setWebChromeClient(null);
mWebView.setWebViewClient(null);
mWebView.removeAllViews();
mWebView.destroy();
mWebView = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"zhangyuhan2014@gmail.com"
] | zhangyuhan2014@gmail.com |
3b808e7e1c644f2ffaa1a60120f459f289271bfc | d11080f6d8f7cd69d6630af2a31be7f0b37941ec | /app/src/main/java/com/v/imagecache/Cache/MemoryCacheUtil.java | 96e3e34914dc5ed7c60b5cc5ebd6ec0887f59cae | [] | no_license | zhangqifan1/ImageCache | 5411db753ff3618619fabb5a7a24a5cdd821b016 | 9e5123fc570c8c6a2efb98046251e9cfa1ef90d0 | refs/heads/master | 2021-05-06T21:03:37.331860 | 2017-11-29T06:12:36 | 2017-11-29T06:12:36 | 112,434,655 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,400 | java | package com.v.imagecache.Cache;
import android.graphics.Bitmap;
import android.util.LruCache;
import java.util.LinkedHashMap;
/**
* Created by Administrator on 2017/11/28.
*/
public class MemoryCacheUtil {
private LruCache<String,Bitmap> mLruCache;
public MemoryCacheUtil() {
//获取最大的可用内存
long maxMemory = Runtime.getRuntime().maxMemory()/8;
mLruCache=new LruCache<String, Bitmap>((int) maxMemory){
@Override
protected int sizeOf(String key, Bitmap value) {
//重写此方法来衡量每张图片的大小 默认返回图片数量
int byteCount = value.getByteCount();
return byteCount;
}
};
}
/**
* 通过url从内存中获取图片
* @param url
*/
public Bitmap getBitmapFromMemory(String url){
Bitmap bitmap = mLruCache.get(url);
return bitmap;
}
/**
* 设置Bitmap到内存
* @param url
* @param bitmap
*/
public void setBitmapToMemory(String url,Bitmap bitmap){
//集合中没有 那就放进去
if(getBitmapFromMemory(url)==null){
mLruCache.put(url,bitmap);
}
}
/**
* 从缓存中删除指定的Key
* @param key
*/
public void removeBitmapFromMemory(String key){
mLruCache.remove(key);
}
}
| [
"852780161@qq.com"
] | 852780161@qq.com |
3a7d9cdf6da80ed2df9897f1b1388bcb87979554 | 9e9e614d7f017059b327d8d8c65289eed3a4b175 | /bluetooth_vpn/src/main/java/edu/unt/nslab/butshuti/bluetoothvpn/ui/fragments/SettingsFragment.java | f2f64cc191a13a03fc318623917de230f7014de9 | [] | no_license | butshuti/bluetoothvpn | 426e645c9f146587318d8868e809a21ed0bd16fe | 17bfc990584710c6e0c5ddcb1ed1448fcf6a9660 | refs/heads/master | 2020-04-16T02:04:27.703830 | 2019-01-11T07:44:27 | 2019-01-11T07:44:27 | 165,196,753 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,808 | java | package edu.unt.nslab.butshuti.bluetoothvpn.ui.fragments;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceManager;
import edu.unt.nslab.butshuti.bluetoothvpn.R;
public final class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
private SharedPreferences settings;
public SettingsFragment(){
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.settings);
settings = PreferenceManager.getDefaultSharedPreferences(getContext());
}
@Override
public void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onPause() {
super.onPause();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
SharedPreferences.Editor editor = settings.edit();
if(key.equals(getString(R.string.pref_key_enable_passive_mode))){
editor = editBoolean(editor, sharedPreferences, key);
}else if(key.equals(getString(R.string.pref_key_enable_client_mode))){
editor = editBoolean(editor, sharedPreferences, key);
}else if(key.equals(getString(R.string.pref_key_num_active_connections))){
editor = editString(editor, sharedPreferences, key, "-1");
}else if(key.equals(getString(R.string.pref_key_install_default_routes))){
editor = editBoolean(editor, sharedPreferences, key);
}else if(key.equals(getString(R.string.pref_key_routing_mode))){
editor = editString(editor, sharedPreferences, key, "UNKNOWN");
}
editor.apply();
}
private SharedPreferences.Editor editBoolean(SharedPreferences.Editor editor, SharedPreferences pref, String key){
Boolean prefValue = pref.getBoolean(key, false);
return editor.putBoolean(key, prefValue);
}
private SharedPreferences.Editor editInt(SharedPreferences.Editor editor, SharedPreferences pref, String key, int defaultValue){
int prefValue = pref.getInt(key, defaultValue);
return editor.putInt(key, prefValue);
}
private SharedPreferences.Editor editString(SharedPreferences.Editor editor, SharedPreferences pref, String key, String defaultValue){
String prefValue = pref.getString(key, defaultValue);
return editor.putString(key, prefValue);
}
}
| [
"bucutith@gmail.com"
] | bucutith@gmail.com |
b77748f1adad54bfd95fbffda3217191c948dded | cbc61ffb33570a1bc55bb1e754510192b0366de2 | /ole-app/olefs/src/main/java/org/kuali/ole/pdp/util/PdpPaymentDetailQuestionCallback.java | f9423c14e004c6df2a2b719b42681c84ed80e9f1 | [
"ECL-2.0"
] | permissive | VU-libtech/OLE-INST | 42b3656d145a50deeb22f496f6f430f1d55283cb | 9f5efae4dfaf810fa671c6ac6670a6051303b43d | refs/heads/master | 2021-07-08T11:01:19.692655 | 2015-05-15T14:40:50 | 2015-05-15T14:40:50 | 24,459,494 | 1 | 0 | ECL-2.0 | 2021-04-26T17:01:11 | 2014-09-25T13:40:33 | Java | UTF-8 | Java | false | false | 1,319 | java | /*
* Copyright 2008 The Kuali Foundation
*
* Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
*
* 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.kuali.ole.pdp.util;
import org.kuali.rice.kim.api.identity.Person;
/**
* PDP PaymentDetail Question Callback defines a callback method for post processing handling in the question interface.
*/
public interface PdpPaymentDetailQuestionCallback {
/**
* Hooks for performing different actions on payment detail after a question has been performed.
*
* @param paymentDetailId the id of the payment
* @param note a note from the user
* @param user the user that perfoms the action
* @return true if succesful, false otherwise
*/
public boolean doPostQuestion(int paymentDetailId, String note, Person user);
}
| [
"david.lacy@villanova.edu"
] | david.lacy@villanova.edu |
94a9f56c987f11b981a69d8847d40e243996e3d2 | 5a25d3d10193a31fb6d419c906a90689f04fcb1e | /src/main/java/de/escidoc/admintool/view/resource/RawXmlWindow.java | b748ba7d27aef56053b45d0b7dc5df4f9e124acc | [] | no_license | MPDL/eSciDocCoreAdminTool | 90db23683c9c3d1f230741541110cc9b03fba110 | 32394c0c188aaac57750ed6fe5c942e710ac276b | refs/heads/master | 2021-01-14T10:23:40.320080 | 2011-12-12T11:56:57 | 2011-12-12T11:56:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,649 | java | /**
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at license/ESCIDOC.LICENSE
* or https://www.escidoc.org/license/ESCIDOC.LICENSE .
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at license/ESCIDOC.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
*
* Copyright 2011 Fachinformationszentrum Karlsruhe Gesellschaft
* fuer wissenschaftlich-technische Information mbH and Max-Planck-
* Gesellschaft zur Foerderung der Wissenschaft e.V.
* All rights reserved. Use is subject to license terms.
*/
package de.escidoc.admintool.view.resource;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
import de.escidoc.admintool.view.ViewConstants;
public class RawXmlWindow extends Window {
private final class CancelButtonListener implements ClickListener {
private static final long serialVersionUID = -1211409730229979129L;
@Override
public void buttonClick(final ClickEvent event) {
closeWindow();
}
}
private static final long serialVersionUID = -4691275024835350852L;
private static final String MODAL_DIALOG_WIDTH = "460px";
private static final String MODAL_DIALOG_HEIGHT = "450px";
private final Button okButton = new Button(ViewConstants.OK_LABEL);
private final Button cancelBtn = new Button(ViewConstants.CANCEL_LABEL);
String selectedParent;
Window mainWindow;
FormLayout fl = new FormLayout();
public RawXmlWindow(final Window mainWindow) {
this.mainWindow = mainWindow;
init();
}
private void init() {
setContent(fl);
fl.setMargin(true);
configureWindow();
configureTextArea();
addButtons();
}
private final TextField textArea = new TextField(ViewConstants.RAW_METADATA);
private void configureTextArea() {
textArea.setRows(20);
textArea.setWidth(300, Sizeable.UNITS_PIXELS);
fl.addComponent(textArea);
}
private final HorizontalLayout buttons = new HorizontalLayout();
private void addButtons() {
fl.addComponent(buttons);
fl.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);
addOkButton();
addCancelButton();
}
private void addCancelButton() {
cancelBtn.addListener(new CancelButtonListener());
buttons.addComponent(cancelBtn);
}
void closeWindow() {
mainWindow.removeWindow(this);
}
private void addOkButton() {
buttons.addComponent(okButton);
}
private void configureWindow() {
setModal(true);
setCaption("Enter Metadata as Raw XML");
setHeight(MODAL_DIALOG_HEIGHT);
setWidth(MODAL_DIALOG_WIDTH);
}
public void setSelected(final String selectedParent) {
this.selectedParent = selectedParent;
}
}
| [
"christian.herlambang@fiz-karlsruhe.de"
] | christian.herlambang@fiz-karlsruhe.de |
91c2e8dcd3667a51ad77373fa7412b9ec067fc3f | e0e5384692f338777b63d181fc22069dd80b410b | /src/cursoJava/TestaContas.java | 7ad31811feeda548a5f9f7d92836e6d7ef3323c3 | [] | no_license | joaopedross/cursoJava | e57e6e6c84802229f916038012b2c29c2084fcd2 | 58badc8b0fa85e5ab7ca87da5419b150f0c9d986 | refs/heads/master | 2021-01-17T19:56:09.375971 | 2014-12-13T18:30:30 | 2014-12-13T18:30:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 571 | java | package cursoJava;
public class TestaContas{
public static void main(String[] args) {
AtualizadorDeContas adc = new AtualizadorDeContas(0.02);
ContaPoupanca cp = new ContaPoupanca();
cp.deposita(1000);
System.out.println(cp.saca(500));
System.out.println(adc.roda(cp));
System.out.println("Saldo: "+cp.getSaldo());
ContaCorrente cc = new ContaCorrente();
cc.deposita(700);
System.out.println(cc.saca(500));
System.out.println(adc.roda(cc));
System.out.println("Saldo: "+cc.getSaldo());
System.out.println("Saldo Total: "+adc.getTotal());
}
}
| [
"murilo.oliveira7@gmail.com"
] | murilo.oliveira7@gmail.com |
5c86261a6fbeabef8cbf50d286be21338722de3b | 6077507b605987dbb733f7244b95a17d6755e22e | /src/main/java/com/japanwork/payload/request/CompanyTranslationRequest.java | 9755b35f18957d193b070c307d03a24cd3be3e62 | [] | no_license | PhuNguyen240196/back-end | c9fee090504d5a83e39afa71a78d847193366f94 | 3914a498fad158480b34de5adff21dc397d71bf3 | refs/heads/master | 2020-06-21T02:29:39.053955 | 2019-07-24T09:11:27 | 2019-07-24T09:11:27 | 197,323,611 | 0 | 0 | null | 2019-07-17T05:50:53 | 2019-07-17T05:50:53 | null | UTF-8 | Java | false | false | 1,035 | java | package com.japanwork.payload.request;
import java.util.UUID;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
public class CompanyTranslationRequest {
@NotNull(message = "company_required")
@JsonProperty("company_id")
private UUID companyId;
@NotBlank(message = "name_company_required")
private String name;
@NotBlank(message = "address_required")
private String address;
private String introduction;
public UUID getCompanyId() {
return companyId;
}
public void setCompanyId(UUID companyId) {
this.companyId = companyId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
}
| [
"38210727+PhuNguyen240196@users.noreply.github.com"
] | 38210727+PhuNguyen240196@users.noreply.github.com |
a322312f99b6b09cbc4069fba18827ccd02ee08d | 685e25a770dc922368c1508bcbae1108bf87715e | /src/third_party/protobuf/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistry.java | d4f6ba9e79d61b993aef4c4ec8d687ad4ca4f8f9 | [
"FSFUL",
"BSD-3-Clause",
"LicenseRef-scancode-protobuf"
] | permissive | Mendeley/breakpad | f5ff7e60c4efa1b4046697abb351fe9eef17dd62 | 7184baa8d2c97cdd55b065916b94d901d8a930a4 | refs/heads/master | 2020-04-15T20:10:01.340793 | 2018-12-11T12:33:24 | 2018-12-11T12:33:24 | 20,398,094 | 35 | 22 | BSD-3-Clause | 2018-03-27T16:04:11 | 2014-06-02T08:59:38 | C++ | UTF-8 | Java | false | false | 10,419 | java | // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* A table of known extensions, searchable by name or field number. When
* parsing a protocol message that might have extensions, you must provide
* an {@code ExtensionRegistry} in which you have registered any extensions
* that you want to be able to parse. Otherwise, those extensions will just
* be treated like unknown fields.
*
* <p>For example, if you had the {@code .proto} file:
*
* <pre>
* option java_class = "MyProto";
*
* message Foo {
* extensions 1000 to max;
* }
*
* extend Foo {
* optional int32 bar;
* }
* </pre>
*
* Then you might write code like:
*
* <pre>
* ExtensionRegistry registry = ExtensionRegistry.newInstance();
* registry.add(MyProto.bar);
* MyProto.Foo message = MyProto.Foo.parseFrom(input, registry);
* </pre>
*
* <p>Background:
*
* <p>You might wonder why this is necessary. Two alternatives might come to
* mind. First, you might imagine a system where generated extensions are
* automatically registered when their containing classes are loaded. This
* is a popular technique, but is bad design; among other things, it creates a
* situation where behavior can change depending on what classes happen to be
* loaded. It also introduces a security vulnerability, because an
* unprivileged class could cause its code to be called unexpectedly from a
* privileged class by registering itself as an extension of the right type.
*
* <p>Another option you might consider is lazy parsing: do not parse an
* extension until it is first requested, at which point the caller must
* provide a type to use. This introduces a different set of problems. First,
* it would require a mutex lock any time an extension was accessed, which
* would be slow. Second, corrupt data would not be detected until first
* access, at which point it would be much harder to deal with it. Third, it
* could violate the expectation that message objects are immutable, since the
* type provided could be any arbitrary message class. An unprivileged user
* could take advantage of this to inject a mutable object into a message
* belonging to privileged code and create mischief.
*
* @author kenton@google.com Kenton Varda
*/
public final class ExtensionRegistry extends ExtensionRegistryLite {
/** Construct a new, empty instance. */
public static ExtensionRegistry newInstance() {
return new ExtensionRegistry();
}
/** Get the unmodifiable singleton empty instance. */
public static ExtensionRegistry getEmptyRegistry() {
return EMPTY;
}
/** Returns an unmodifiable view of the registry. */
@Override
public ExtensionRegistry getUnmodifiable() {
return new ExtensionRegistry(this);
}
/** A (Descriptor, Message) pair, returned by lookup methods. */
public static final class ExtensionInfo {
/** The extension's descriptor. */
public final FieldDescriptor descriptor;
/**
* A default instance of the extension's type, if it has a message type.
* Otherwise, {@code null}.
*/
public final Message defaultInstance;
private ExtensionInfo(final FieldDescriptor descriptor) {
this.descriptor = descriptor;
defaultInstance = null;
}
private ExtensionInfo(final FieldDescriptor descriptor,
final Message defaultInstance) {
this.descriptor = descriptor;
this.defaultInstance = defaultInstance;
}
}
/**
* Find an extension by fully-qualified field name, in the proto namespace.
* I.e. {@code result.descriptor.fullName()} will match {@code fullName} if
* a match is found.
*
* @return Information about the extension if found, or {@code null}
* otherwise.
*/
public ExtensionInfo findExtensionByName(final String fullName) {
return extensionsByName.get(fullName);
}
/**
* Find an extension by containing type and field number.
*
* @return Information about the extension if found, or {@code null}
* otherwise.
*/
public ExtensionInfo findExtensionByNumber(final Descriptor containingType,
final int fieldNumber) {
return extensionsByNumber.get(
new DescriptorIntPair(containingType, fieldNumber));
}
/** Add an extension from a generated file to the registry. */
public void add(final GeneratedMessage.GeneratedExtension<?, ?> extension) {
if (extension.getDescriptor().getJavaType() ==
FieldDescriptor.JavaType.MESSAGE) {
if (extension.getMessageDefaultInstance() == null) {
throw new IllegalStateException(
"Registered message-type extension had null default instance: " +
extension.getDescriptor().getFullName());
}
add(new ExtensionInfo(extension.getDescriptor(),
extension.getMessageDefaultInstance()));
} else {
add(new ExtensionInfo(extension.getDescriptor(), null));
}
}
/** Add a non-message-type extension to the registry by descriptor. */
public void add(final FieldDescriptor type) {
if (type.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
throw new IllegalArgumentException(
"ExtensionRegistry.add() must be provided a default instance when " +
"adding an embedded message extension.");
}
add(new ExtensionInfo(type, null));
}
/** Add a message-type extension to the registry by descriptor. */
public void add(final FieldDescriptor type, final Message defaultInstance) {
if (type.getJavaType() != FieldDescriptor.JavaType.MESSAGE) {
throw new IllegalArgumentException(
"ExtensionRegistry.add() provided a default instance for a " +
"non-message extension.");
}
add(new ExtensionInfo(type, defaultInstance));
}
// =================================================================
// Private stuff.
private ExtensionRegistry() {
this.extensionsByName = new HashMap<String, ExtensionInfo>();
this.extensionsByNumber = new HashMap<DescriptorIntPair, ExtensionInfo>();
}
private ExtensionRegistry(ExtensionRegistry other) {
super(other);
this.extensionsByName = Collections.unmodifiableMap(other.extensionsByName);
this.extensionsByNumber =
Collections.unmodifiableMap(other.extensionsByNumber);
}
private final Map<String, ExtensionInfo> extensionsByName;
private final Map<DescriptorIntPair, ExtensionInfo> extensionsByNumber;
private ExtensionRegistry(boolean empty) {
super(ExtensionRegistryLite.getEmptyRegistry());
this.extensionsByName = Collections.<String, ExtensionInfo>emptyMap();
this.extensionsByNumber =
Collections.<DescriptorIntPair, ExtensionInfo>emptyMap();
}
private static final ExtensionRegistry EMPTY = new ExtensionRegistry(true);
private void add(final ExtensionInfo extension) {
if (!extension.descriptor.isExtension()) {
throw new IllegalArgumentException(
"ExtensionRegistry.add() was given a FieldDescriptor for a regular " +
"(non-extension) field.");
}
extensionsByName.put(extension.descriptor.getFullName(), extension);
extensionsByNumber.put(
new DescriptorIntPair(extension.descriptor.getContainingType(),
extension.descriptor.getNumber()),
extension);
final FieldDescriptor field = extension.descriptor;
if (field.getContainingType().getOptions().getMessageSetWireFormat() &&
field.getType() == FieldDescriptor.Type.MESSAGE &&
field.isOptional() &&
field.getExtensionScope() == field.getMessageType()) {
// This is an extension of a MessageSet type defined within the extension
// type's own scope. For backwards-compatibility, allow it to be looked
// up by type name.
extensionsByName.put(field.getMessageType().getFullName(), extension);
}
}
/** A (GenericDescriptor, int) pair, used as a map key. */
private static final class DescriptorIntPair {
private final Descriptor descriptor;
private final int number;
DescriptorIntPair(final Descriptor descriptor, final int number) {
this.descriptor = descriptor;
this.number = number;
}
@Override
public int hashCode() {
return descriptor.hashCode() * ((1 << 16) - 1) + number;
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof DescriptorIntPair)) {
return false;
}
final DescriptorIntPair other = (DescriptorIntPair)obj;
return descriptor == other.descriptor && number == other.number;
}
}
}
| [
"robert.knight@mendeley.com"
] | robert.knight@mendeley.com |
0d3b9fbd821d21f1173b52ee7b7f49b8e8f8ad29 | e3241b8f3744d0488aaafd9a5dfbc211de1a0b27 | /src/main/java/cdot/ccsp/utils/SecurityModeAnnc.java | eecd0627965b03ca1fbb3843e45d5a37fcf8c6ad | [] | no_license | jaswantIISC/Example1 | 2fb6b8bebddded529f45cc464018f4daa342542c | f99d4cd5c8619bfe4b9430aa6a8a2728ac1ff0c5 | refs/heads/master | 2022-11-10T19:03:08.931915 | 2020-07-08T09:49:06 | 2020-07-08T09:49:06 | 278,051,509 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,674 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2019.12.17 at 02:51:19 PM IST
//
package cdot.ccsp.utils;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlType;
import cdot.onem2m.resource.xsd.AnnouncedFlexContainerResource;
import cdot.onem2m.resource.xsd.ChildResourceRef;
import cdot.onem2m.resource.xsd.Subscription;
/**
* <p>Java class for securityModeAnnc complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="securityModeAnnc">
* <complexContent>
* <extension base="{http://www.onem2m.org/xml/protocols}announcedFlexContainerResource">
* <sequence>
* <element name="currentSecurityMode" type="{http://www.onem2m.org/xml/protocols/homedomain}enumSecurityMode" minOccurs="0"/>
* <element name="securityModes" minOccurs="0">
* <simpleType>
* <list itemType="{http://www.onem2m.org/xml/protocols/homedomain}enumSecurityMode" />
* </simpleType>
* </element>
* <choice minOccurs="0">
* <element name="childResource" type="{http://www.onem2m.org/xml/protocols}childResourceRef" maxOccurs="unbounded"/>
* <choice maxOccurs="unbounded">
* <element ref="{http://www.onem2m.org/xml/protocols}subscription"/>
* </choice>
* </choice>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "securityModeAnnc", propOrder = {
"currentSecurityMode",
"securityModes",
"childResource",
"subscription"
})
public class SecurityModeAnnc
extends AnnouncedFlexContainerResource
{
protected BigInteger currentSecurityMode;
@XmlList
protected List<BigInteger> securityModes;
protected List<ChildResourceRef> childResource;
@XmlElement(namespace = "http://www.onem2m.org/xml/protocols")
protected List<Subscription> subscription;
/**
* Gets the value of the currentSecurityMode property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getCurrentSecurityMode() {
return currentSecurityMode;
}
/**
* Sets the value of the currentSecurityMode property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setCurrentSecurityMode(BigInteger value) {
this.currentSecurityMode = value;
}
/**
* Gets the value of the securityModes property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the securityModes property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSecurityModes().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link BigInteger }
*
*
*/
public List<BigInteger> getSecurityModes() {
if (securityModes == null) {
securityModes = new ArrayList<BigInteger>();
}
return this.securityModes;
}
/**
* Gets the value of the childResource property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the childResource property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getChildResource().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ChildResourceRef }
*
*
*/
public List<ChildResourceRef> getChildResource() {
if (childResource == null) {
childResource = new ArrayList<ChildResourceRef>();
}
return this.childResource;
}
/**
* Gets the value of the subscription property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the subscription property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSubscription().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Subscription }
*
*
*/
public List<Subscription> getSubscription() {
if (subscription == null) {
subscription = new ArrayList<Subscription>();
}
return this.subscription;
}
}
| [
"jaswant.meena10@gmail.com"
] | jaswant.meena10@gmail.com |
17374993a7d50b5c141fb7488242233cc46511ef | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_481bf3231f9c299204021b84e8c8f229d13c1a4d/Trigger/2_481bf3231f9c299204021b84e8c8f229d13c1a4d_Trigger_t.java | 79e8af3cca37edb6b16dcb79f7534bfccb342b84 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 15,277 | java | /*
* Copyright 2006 Amazon Technologies, Inc. or its affiliates.
* Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
* of Amazon Technologies, Inc. or its affiliates. All rights reserved.
*
* 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.amazon.carbonado;
/**
* Callback mechanism to allow custom code to run when a storable is
* persisted. By default, the methods defined in this class do
* nothing. Subclass and override trigger conditions of interest, and then
* {@link Storage#addTrigger register} it. Each overridden trigger method is
* called in the same transaction scope as the persist operation. Trigger
* implementations are encouraged to override the equals method, to prevent
* accidental double registration.
*
* <p>To ensure proper nesting, all "before" events are run in the
* <em>opposite</em> order that the trigger was registered. All "after" and
* "failed" events are run in the same order that the trigger was registered.
* In other words, the last added trigger is at the outermost nesting level.
*
* <p>Triggers always run within the same transaction as the triggering
* operation. The exact isolation level and update mode is outside the
* trigger's control. If an explicit isolation level or update mode is
* required, create a nested transaction within a trigger method. A trigger's
* nested transaction can also be defined to span the entire triggering operation.
* To do this, enter the transaction in the "before" method, but return the
* transaction object without exiting it. The "after" method is responsible for
* exiting the transaction. It extracts (or simply casts) the transaction from
* the state object passed into it. When creating spanning transactions like
* this, it is critical that the "failed" method be defined to properly exit
* the transaction upon failure.
*
* @author Brian S O'Neill
*/
public abstract class Trigger<S> {
/**
* Called before a storable is to be inserted. The default implementation
* does nothing.
*
* <p>Any exception thrown by this method will cause the insert operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the insert method.
*
* @param storable storable before being inserted
* @return arbitrary state object, passed to afterInsert or failedInsert method
*/
public Object beforeInsert(S storable) throws PersistException {
return null;
}
/**
* Called before a storable is to be inserted via tryInsert. The default
* implementation simply calls {@link #beforeInsert}. Only override if
* trigger needs to distinguish between different insert variants.
*
* <p>Any exception thrown by this method will cause the tryInsert operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the tryInsert method.
*
* @param storable storable before being inserted
* @return arbitrary state object, passed to afterTryInsert or failedInsert method
* @see #abortTry
*/
public Object beforeTryInsert(S storable) throws PersistException {
return beforeInsert(storable);
}
/**
* Called right after a storable has been successfully inserted. The
* default implementation does nothing.
*
* <p>Any exception thrown by this method will cause the insert operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the insert method.
*
* @param storable storable after being inserted
* @param state object returned by beforeInsert method
*/
public void afterInsert(S storable, Object state) throws PersistException {
}
/**
* Called right after a storable has been successfully inserted via
* tryInsert. The default implementation simply calls {@link #afterInsert}.
* Only override if trigger needs to distinguish between different insert
* variants.
*
* <p>Any exception thrown by this method will cause the tryInsert
* operation to rollback and all remaining triggers to not run. The
* exception is ultimately passed to the caller of the tryInsert method.
*
* @param storable storable after being inserted
* @param state object returned by beforeTryInsert method
* @see #abortTry
*/
public void afterTryInsert(S storable, Object state) throws PersistException {
afterInsert(storable, state);
}
/**
* Called when an insert operation failed due to a unique constraint
* violation or an exception was thrown. The main purpose of this method is
* to allow any necessary clean-up to occur on the optional state object.
*
* <p>Any exception thrown by this method will be passed to the current
* thread's uncaught exception handler.
*
* @param storable storable which failed to be inserted
* @param state object returned by beforeInsert method, but it may be null
*/
public void failedInsert(S storable, Object state) {
}
/**
* Called before a storable is to be updated. The default implementation
* does nothing.
*
* <p>Any exception thrown by this method will cause the update operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the update method.
*
* @param storable storable before being updated
* @return arbitrary state object, passed to afterUpdate or failedUpdate method
*/
public Object beforeUpdate(S storable) throws PersistException {
return null;
}
/**
* Called before a storable is to be updated via tryUpdate. The default
* implementation simply calls {@link #beforeUpdate}. Only override if
* trigger needs to distinguish between different update variants.
*
* <p>Any exception thrown by this method will cause the tryUpdate operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the tryUpdate method.
*
* @param storable storable before being updated
* @return arbitrary state object, passed to afterTryUpdate or failedUpdate method
* @see #abortTry
*/
public Object beforeTryUpdate(S storable) throws PersistException {
return beforeUpdate(storable);
}
/**
* Called right after a storable has been successfully updated. The default
* implementation does nothing.
*
* <p>Any exception thrown by this method will cause the update operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the update method.
*
* @param storable storable after being updated
* @param state optional object returned by beforeUpdate method
*/
public void afterUpdate(S storable, Object state) throws PersistException {
}
/**
* Called right after a storable has been successfully updated via
* tryUpdate. The default implementation simply calls {@link #afterUpdate}.
* Only override if trigger needs to distinguish between different update
* variants.
*
* <p>Any exception thrown by this method will cause the tryUpdate
* operation to rollback and all remaining triggers to not run. The
* exception is ultimately passed to the caller of the tryUpdate method.
*
* @param storable storable after being updated
* @param state object returned by beforeTryUpdate method
* @see #abortTry
*/
public void afterTryUpdate(S storable, Object state) throws PersistException {
afterUpdate(storable, state);
}
/**
* Called when an update operation failed because the record was missing or
* an exception was thrown. The main purpose of this method is to allow any
* necessary clean-up to occur on the optional state object.
*
* <p>Any exception thrown by this method will be passed to the current
* thread's uncaught exception handler.
*
* @param storable storable which failed to be updated
* @param state optional object returned by beforeUpdate
* method, but it may be null
*/
public void failedUpdate(S storable, Object state) {
}
/**
* Called before a storable is to be deleted. The default implementation
* does nothing.
*
* <p>Any exception thrown by this method will cause the delete operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the delete method.
*
* @param storable storable before being deleted
* @return arbitrary state object, passed to afterDelete or failedDelete method
*/
public Object beforeDelete(S storable) throws PersistException {
return null;
}
/**
* Called before a storable is to be deleted via tryDelete. The default
* implementation simply calls {@link #beforeDelete}. Only override if
* trigger needs to distinguish between different delete variants.
*
* <p>Any exception thrown by this method will cause the tryDelete operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the tryDelete method.
*
* @param storable storable before being deleted
* @return arbitrary state object, passed to afterTryDelete or failedDelete method
* @see #abortTry
*/
public Object beforeTryDelete(S storable) throws PersistException {
return beforeDelete(storable);
}
/**
* Called right after a storable has been successfully deleted. The default
* implementation does nothing.
*
* <p>Any exception thrown by this method will cause the delete operation
* to rollback and all remaining triggers to not run. The exception is
* ultimately passed to the caller of the delete method.
*
* @param storable storable after being deleted
* @param state optional object returned by beforeDelete method
*/
public void afterDelete(S storable, Object state) throws PersistException {
}
/**
* Called right after a storable has been successfully deleted via
* tryDelete. The default implementation simply calls {@link #afterDelete}.
* Only override if trigger needs to distinguish between different delete
* variants.
*
* <p>Any exception thrown by this method will cause the tryDelete
* operation to rollback and all remaining triggers to not run. The
* exception is ultimately passed to the caller of the tryDelete method.
*
* @param storable storable after being deleted
* @param state object returned by beforeTryDelete method
* @see #abortTry
*/
public void afterTryDelete(S storable, Object state) throws PersistException {
afterDelete(storable, state);
}
/**
* Called when an delete operation failed because the record was missing or
* an exception was thrown. The main purpose of this method is to allow any
* necessary clean-up to occur on the optional state object.
*
* <p>Any exception thrown by this method will be passed to the current
* thread's uncaught exception handler.
*
* @param storable storable which failed to be deleted
* @param state optional object returned by beforeDelete
* method, but it may be null
*/
public void failedDelete(S storable, Object state) {
}
/**
* Called right after a storable has been successfully loaded or
* fetched. The default implementation does nothing.
*
* @param storable storable after being loaded or fetched
* @since 1.2
*/
public void afterLoad(S storable) throws FetchException {
}
/**
* Call to quickly abort a "try" operation, returning false to the
* caller. This method should not be called by a non-try trigger method,
* since the caller gets thrown an exception with an incomplete stack trace.
*
* <p>This method never returns normally, but as a convenience, a return
* type is defined. The abort exception can be thrown by {@code throw abortTry()},
* but the {@code throw} keyword is not needed.
*/
protected Abort abortTry() throws Abort {
// Throwing and catching an exception is not terribly expensive, but
// creating a new exception is more than an order of magnitude slower.
// Therefore, re-use the same instance. It has no stack trace since it
// would be meaningless.
throw Abort.INSTANCE;
}
public static final class Abort extends PersistException {
private static final long serialVersionUID = -8498639796139966911L;
static final Abort INSTANCE = new Abort();
private Abort() {
super("Trigger aborted operation", null);
}
private Abort(String message) {
super(message);
super.fillInStackTrace();
}
/**
* Override to remove the stack trace.
*/
@Override
public Throwable fillInStackTrace() {
return null;
}
/**
* Returns this exception but with a fresh stack trace. The trace does
* not include the original thrower of this exception.
*/
public Abort withStackTrace() {
Abort a = new Abort(getMessage());
StackTraceElement[] trace = a.getStackTrace();
if (trace != null && trace.length > 1) {
// Trim off this method from the trace, which is element 0.
StackTraceElement[] trimmed = new StackTraceElement[trace.length - 1];
System.arraycopy(trace, 1, trimmed, 0, trimmed.length);
a.setStackTrace(trimmed);
}
return a;
}
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
99ec91fc3f5885881ffc21a2e5ebd89009307590 | a3d3c1ecd909da6c45751bd70661eed7569389a8 | /app/src/main/java/cn/meituan/jp/fragment/BusinessInfoFragment.java | 0b21493bb751e0a40f7afd387333c38be5e7b617 | [] | no_license | jp5201314/fly-leopard-client-android | 0669c32c0581b113706e9bbd30c82aa2d8f0d97a | abdfad795bca5a630859980d5f1aea43b8a1dab4 | refs/heads/master | 2021-01-19T11:53:50.516390 | 2017-05-15T04:04:09 | 2017-05-15T04:04:09 | 88,003,000 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 784 | java | package cn.meituan.jp.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import cn.meituan.jp.R;
/**
* Created by 11608 on 2017/4/19.
*/
public class BusinessInfoFragment extends BaseFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_business_info, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onDestroyView() {
super.onDestroyView();
ButterKnife.unbind(this);
}
}
| [
"1160873948@qq.com"
] | 1160873948@qq.com |
48f553a1383af9dd698364fa4d1d0175a802e446 | 9dfe33f936674e09eb7011a3a700bc673625ae2a | /shopee-web/shopee-admin/src/main/java/cn/shopee/web/modules/email/service/IEmailTemplateService.java | d60f19bd4206a37a9fa589a0f8e1ae5953cdfb68 | [
"Apache-2.0"
] | permissive | yourant/ShopEE | 73180806f46c45b76c76bf749949332378027f27 | 371b803781568b3c22776abefad2674fc90d787b | refs/heads/master | 2022-01-30T22:33:25.801026 | 2019-03-24T06:25:41 | 2019-03-24T06:26:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 549 | java | package cn.shopee.web.modules.email.service;
import cn.shopee.web.modules.email.entity.EmailTemplate;
import cn.shopee.common.mybatis.mvc.service.ICommonService;
/**
* All rights Reserved, Designed By www.shopee.cn
*
* @version V1.0
* @package cn.shopee.web.modules.email.service
* @title: 邮件模板服务接口
* @description: 邮件模板服务接口
* @author: HuLiang
* @date: 2018-09-12 10:59:18
* @copyright: 2018 www.shopee.cn Inc. All rights reserved.
*/
public interface IEmailTemplateService extends ICommonService<EmailTemplate> {
} | [
"418206020@qq.com"
] | 418206020@qq.com |
71445863131d2d04287463f9f22829ae71f6ae5a | d466cb9dd96df9a343399ce17ce8503751667f1e | /app/src/androidTest/java/com/example/dhorovyi/myfirstapplication/ExampleInstrumentedTest.java | c559a1d5391fbb36a5dc062f8f1f9f3d6468365e | [] | no_license | dgorovoy456/Android_Sensors_app | 658773b1033e495d4d6abb9e2f0a48edee9989db | c1283e86a9dd08f397593db2d74d5691e6a4c3c6 | refs/heads/master | 2020-05-29T16:43:21.573654 | 2019-06-20T08:35:18 | 2019-06-20T08:35:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 762 | java | package com.example.dhorovyi.myfirstapplication;
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.*;
/**
* 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.getTargetContext();
assertEquals("com.example.dhorovyi.myfirstapplication", appContext.getPackageName());
}
}
| [
"dgorovoy456@gmail.com"
] | dgorovoy456@gmail.com |
5ece934840768af12288ea4ed43170898db25f65 | 2e651027c9d927ee56ef1e84e5138d57de508d41 | /src/Lessons7andAbove/Task10.java | 8627560a41eac7c138e2416448340242672119f8 | [] | no_license | FatOFF32/JJD | 27a58dd9d5be56eb7a95678a6ad3efe09c898286 | d4984a5b7c5cc5c6c559af59510073b805776844 | refs/heads/master | 2021-05-04T19:49:40.413643 | 2018-11-22T20:33:43 | 2018-11-22T20:33:43 | 106,460,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 609 | java | package Lessons7andAbove;
public class Task10 {
public static void main(String[] args) {
// // Задрание 1
// System.out.println("Earth weight: " + Planets.Earth.getWeight());
// System.out.println("Earth radius: " + Planets.Earth.radius);
// Задание 2
List<String> list = new LinkedList();
list.add("Адын");
list.add("Дыва");
list.add("Тари");
list.add("Шатыры");
list.add("Пьять");
for (String s :
list) {
System.out.println(s);
}
}
}
| [
"fat-ne@yandex.ru"
] | fat-ne@yandex.ru |
05557b003e00bf9e40302ed7ca4237938150a94b | 0deffdd02bc1a330a7f06d5366ba693b2fd10e61 | /BOOT_CAMP_PROJECTS/Deevanshu/StructsDemo1/src/com/info/model1/Item.java | 31212a616530096f91d105b3f0f93df25e9c0b25 | [] | no_license | deevanshu07/Projects | 77adb903575de9563a324a294c04c88e50dfffeb | 6c49672b3b1eda8b16327b56114560140b087e38 | refs/heads/master | 2021-04-27T21:52:13.560590 | 2018-04-26T15:35:21 | 2018-04-26T15:35:21 | 122,406,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 675 | java | package com.info.model1;
public class Item
{
private int itemId;
private String itemName;
private String itemDesc;
public Item(int itemId, String itemName, String itemDesc)
{
super();
this.itemId = itemId;
this.itemName = itemName;
this.itemDesc = itemDesc;
}
public String getItemDesc()
{
return itemDesc;
}
public int getItemId()
{
return itemId;
}
public String getItemName()
{
return itemName;
}
public void setItemDesc(String itemDesc)
{
this.itemDesc = itemDesc;
}
public void setItemId(int itemId)
{
this.itemId = itemId;
}
public void setItemName(String itemName)
{
this.itemName = itemName;
}
}
| [
"deevanshumahajan07@gmail.com"
] | deevanshumahajan07@gmail.com |
f1f60a49000806d9f7be3df5cb79730075d2df19 | 7a5f54f5397a22628783f8f0a452d050a64a8df2 | /analysis/src/dox/DOX.java | 6e75cafacdb299af81b91000315179d51bde552c | [] | no_license | Satsu13/stock_analysis | 5bd08f04dab52b3b0923e9c0fa92c29894046474 | 490004ffad47155f85bb50baadf0b489fa8044ac | refs/heads/master | 2021-05-16T03:38:57.435044 | 2017-10-02T23:42:32 | 2017-10-02T23:42:32 | 105,594,657 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,617 | java | package dox;
import investment_simulator.report.SimulationReport;
import repository.stock_repository.StockRepository;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.time.LocalDate;
import java.util.*;
public abstract class DOX {
public final StockRepository repository;
private LinkedList<DesignAxis> designAxis;
private LocalDate startDate;
private LocalDate endDate;
public DOX(StockRepository repository) {
this.repository = repository;
designAxis = new LinkedList<>();
startDate = LocalDate.MIN;
endDate = LocalDate.MAX;
}
public DOX(StockRepository repository, LocalDate startDate, LocalDate endDate) {
this.repository = repository;
designAxis = new LinkedList<>();
this.startDate = startDate;
this.endDate = endDate;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
public LocalDate getEndDate() {
return endDate;
}
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
protected abstract DOXReport getDoxReport(File doxReportDirectory);
public void simulate(File reportDirectory) throws Exception {
DOXReport doxReport = getDoxReport(reportDirectory);
for (List<Double> axisValues : calculatePossibleAxisValues()) {
tryProcessingSimulation(doxReport, axisValues);
}
}
private Iterable<? extends List<Double>> calculatePossibleAxisValues() {
LinkedList<List<Double>> inputValues = new LinkedList<>();
for (DesignAxis designAxi : designAxis) {
inputValues.add(designAxi.calculateValues());
}
List<DefaultMutableTreeNode> values = buildTreeNodes(inputValues);
return calculatePossibleAxisValues(values);
}
private List<DefaultMutableTreeNode> buildTreeNodes(LinkedList<List<Double>> inputValueStack) {
if (inputValueStack.size() == 0) {
return Collections.emptyList();
}
List<DefaultMutableTreeNode> treeNodes = new LinkedList<>();
for (Double inputValue : inputValueStack.pop()) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(inputValue);
buildTreeNodes((LinkedList<List<Double>>) inputValueStack.clone()).forEach(node::add);
treeNodes.add(node);
}
return treeNodes;
}
private Iterable<? extends List<Double>> calculatePossibleAxisValues(List<DefaultMutableTreeNode> values) {
LinkedList<List<Double>> possibleValues = new LinkedList<>();
for (DefaultMutableTreeNode treeNode : values) {
possibleValues.addAll(calculatePossibleAxisValues(treeNode));
}
return possibleValues;
}
private Collection<? extends List<Double>> calculatePossibleAxisValues(DefaultMutableTreeNode treeNode) {
Enumeration<DefaultMutableTreeNode> leafs = treeNode.depthFirstEnumeration();
LinkedList<List<Double>> possibleValues = new LinkedList<>();
while (leafs.hasMoreElements()) {
DefaultMutableTreeNode node = leafs.nextElement();
if (node.isLeaf()) {
possibleValues.add(buildValueList(node.getUserObjectPath()));
}
}
return possibleValues;
}
private List<Double> buildValueList(Object[] userObjectPath) {
List<Double> values = new ArrayList<>(userObjectPath.length);
for (Object valueObject : userObjectPath) {
values.add((Double) valueObject);
}
return values;
}
private void tryProcessingSimulation(DOXReport doxReport, List<Double> axisValues) throws Exception {
try {
processSimulation(doxReport, axisValues);
} catch (Exception e) {
doxReport.processSimulationException(e);
}
}
private void processSimulation(DOXReport doxReport, List<Double> axisValues) throws Exception {
SimulationReport simulationReport = simulateExperiment(axisValues);
doxReport.processReport(simulationReport, axisValues);
}
private SimulationReport simulateExperiment(List<Double> axisValues) {
Experiment experiment = getExperiment();
experiment.setStartDate(startDate);
experiment.setEndDate(endDate);
return experiment.simulate(axisValues);
}
protected abstract Experiment getExperiment();
protected LinkedList<DesignAxis> getDesignAxis() {
return designAxis;
}
}
| [
"nsrestifo@hotmail.com"
] | nsrestifo@hotmail.com |
3cb6cbb26d3a3d0d95efaea4764a1db04f301b8b | e882ad85c077b1d61ff17b67cc6d6e31efc7d619 | /src/main/java/com/danilorocha/logistica/api/model/output/DestinatarioOutput.java | 40634827763e4337240e02847d1d612c13cf40ab | [] | no_license | danilorocha22/sistema-logistica-de-entrega-api-server | 44e7688222a4b2f14383845919ae8b80e37b8f61 | 138616f730c45a5e394a86b199195451392c16c3 | refs/heads/main | 2023-08-25T14:54:30.282273 | 2021-10-24T21:57:34 | 2021-10-24T21:57:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | java | package com.danilorocha.logistica.api.model.output;
import com.danilorocha.logistica.domain.entity.Destinatario;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DestinatarioOutput {
private String nome;
private String logradouro;
private String numero;
private String complemento;
private String bairro;
}
| [
"danilo.rochaa@gmail.com"
] | danilo.rochaa@gmail.com |
2aac25bdeff96b05250d48c1bf483c0bd70bb2e6 | e57b39d36c3f3bc69cb0cd4b46f8db626c4ca7ee | /src/main/java/fr/data2Thymeleaf/PageToProcess.java | 057bb8aacad8db196168ee329cb737121744b279 | [] | no_license | CharlesCarbonne/data2thymeleaf | d1485d27197f52594c3db854ca596871796cb12d | d9f376c861432f9ee21d0e03f87543cd412ece2a | refs/heads/master | 2020-03-19T11:42:32.573236 | 2018-06-14T09:35:59 | 2018-06-14T09:35:59 | 136,471,444 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 680 | java | package fr.data2Thymeleaf;
public class PageToProcess {
private Data data;
private PageConfig config;
public PageToProcess(Data data, PageConfig config, PageTemplate template) {
super();
this.data = data;
this.config = config;
}
public PageToProcess() {
super();
// TODO Auto-generated constructor stub
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public PageConfig getConfig() {
return config;
}
public void setConfig(PageConfig config) {
this.config = config;
}
@Override
public String toString() {
return "PageToProcess [data=" + data + ", config=" + config + "]";
}
}
| [
"charlescarbonne@hotmail.fr"
] | charlescarbonne@hotmail.fr |
c0bce4d887a94de7853a630344c70bcd0634344a | d286a796a030ff396721d29e75fcf17c3e5aefa2 | /app/src/main/java/com/tintin/mat/winecellar/adapter/ClayetteAdapter.java | e646ed5e752cc559db36dcb22f18a763c17397d6 | [] | no_license | TintinMat/WineCellar | 9d93128b1ae3983175c22c0371ec6511cb867b58 | 80d3c8a80cc76cf0a32dc91e8c95e30be80deb4a | refs/heads/master | 2023-03-30T10:39:59.900921 | 2021-02-05T21:50:16 | 2021-02-05T21:50:16 | 116,180,115 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,979 | java | package com.tintin.mat.winecellar.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.tintin.mat.winecellar.R;
import com.tintin.mat.winecellar.bo.Bouteille;
import com.tintin.mat.winecellar.bo.Clayette;
import com.tintin.mat.winecellar.dao.BouteilleDao;
import com.tintin.mat.winecellar.interfce.BouteilleInterface;
import com.tintin.mat.winecellar.utils.Utils;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* Created by Mat & Audrey on 22/10/2017.
*/
public class ClayetteAdapter extends ArrayAdapter<Clayette> {
Context context;
//private BouteilleInterface listener;
public ClayetteAdapter(Context context, List<Clayette> clayettes/*, BouteilleInterface listener*/) {
super(context, 0, clayettes);
this.context = context;
//this.listener=listener;
}
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_clayette,parent, false);
}
ClayetteViewHolder viewHolder = (ClayetteViewHolder) convertView.getTag();
if(viewHolder == null){
viewHolder = new ClayetteViewHolder();
viewHolder.nom = (TextView) convertView.findViewById(R.id.nomClayetteRowTextView);
viewHolder.nombreBouteilles = (TextView) convertView.findViewById(R.id.nombreBouteillesRowTextView);
convertView.setTag(viewHolder);
}
final Clayette clayette = getItem(position);
//il ne reste plus qu'à remplir notre vue
if (clayette.getNom() != null && clayette.getNom().length()>0) {
viewHolder.nom.setText(clayette.getNom());
}else{
viewHolder.nom.setText(clayette.toString());
}
String messageNbBouteillesMillesime = "";
if (clayette.listeBouteilles() != null && clayette.listeBouteilles().size()>0) {
messageNbBouteillesMillesime = getContext().getString(R.string.text_view_row_nb_bouteilles, clayette.listeBouteilles().size());
}else {
messageNbBouteillesMillesime = getContext().getString(R.string.text_view_row_nb_bouteilles, 0);
}
viewHolder.nombreBouteilles.setText(messageNbBouteillesMillesime);
/*
// afficher le bouton pour déguster
Button btn = convertView.findViewById(R.id.deguster_btn);
btn.setVisibility(View.VISIBLE);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});*/
return convertView;
}
private class ClayetteViewHolder{
public TextView nom;
public TextView nombreBouteilles;
}
}
| [
"35079356+TintinMat@users.noreply.github.com"
] | 35079356+TintinMat@users.noreply.github.com |
ab4bf77ec9989c7511ea44f88cb2ce20a8f715cf | 129f58086770fc74c171e9c1edfd63b4257210f3 | /src/testcases/CWE760_Predictable_Salt_One_Way_Hash/CWE760_Predictable_Salt_One_Way_Hash__getQueryString_Servlet_13.java | 1820c81a95dfd58b73c36bcbc4938f34789c44fe | [] | no_license | glopezGitHub/Android23 | 1bd0b6a6c7ce3c7439a74f1e4dcef2c4c0fac4ba | 6215d0684c4fbdc7217ccfbedfccfca69824cc5e | refs/heads/master | 2023-03-07T15:14:59.447795 | 2023-02-06T13:59:49 | 2023-02-06T13:59:49 | 6,856,387 | 0 | 3 | null | 2023-02-06T18:38:17 | 2012-11-25T22:04:23 | Java | UTF-8 | Java | false | false | 11,912 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE760_Predictable_Salt_One_Way_Hash__getQueryString_Servlet_13.java
Label Definition File: CWE760_Predictable_Salt_One_Way_Hash.label.xml
Template File: sources-sinks-13.tmpl.java
*/
/*
* @description
* CWE: 760 Use of one-way hash with a predictable salt
* BadSource: getQueryString_Servlet Parse id param out of the URL query string (without using getParameter())
* GoodSource: A hardcoded string
* Sinks:
* GoodSink: use a sufficiently random salt
* BadSink : SHA512 with a predictable salt
* Flow Variant: 13 Control flow: if(IO.static_final_five==5) and if(IO.static_final_five!=5)
*
* */
package testcases.CWE760_Predictable_Salt_One_Way_Hash;
import testcasesupport.*;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.SecureRandom;
import javax.servlet.http.*;
import javax.servlet.http.*;
import java.util.StringTokenizer;
public class CWE760_Predictable_Salt_One_Way_Hash__getQueryString_Servlet_13 extends AbstractTestCaseServlet
{
public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
if(IO.static_final_five==5)
{
data = ""; /* initialize data in case id is not in query string */
/* POTENTIAL FLAW: Parse id param out of the URL querystring (without using getParameter()) */
{
StringTokenizer st = new StringTokenizer(request.getQueryString(), "&");
while (st.hasMoreTokens())
{
String token = st.nextToken(); /* a token will be like "id=foo" */
if(token.startsWith("id=")) /* check if we have the "id" parameter" */
{
data = token.substring(3); /* set data to "foo" */
break; /* exit while loop */
}
}
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Use a hardcoded string */
data = "foo";
}
if(IO.static_final_five==5)
{
if (data != null)
{
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(data.getBytes("UTF-8")); /* POTENTIAL FLAW: SHA512 with a predictable salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
SecureRandom r = new SecureRandom();
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(r.getSeed(32)); /* FIX: Use a sufficiently random salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
/* goodG2B1() - use goodsource and badsink by changing first IO.static_final_five==5 to IO.static_final_five!=5 */
private void goodG2B1(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
if(IO.static_final_five!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
data = ""; /* initialize data in case id is not in query string */
/* POTENTIAL FLAW: Parse id param out of the URL querystring (without using getParameter()) */
{
StringTokenizer st = new StringTokenizer(request.getQueryString(), "&");
while (st.hasMoreTokens())
{
String token = st.nextToken(); /* a token will be like "id=foo" */
if(token.startsWith("id=")) /* check if we have the "id" parameter" */
{
data = token.substring(3); /* set data to "foo" */
break; /* exit while loop */
}
}
}
}
else {
/* FIX: Use a hardcoded string */
data = "foo";
}
if(IO.static_final_five==5)
{
if (data != null)
{
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(data.getBytes("UTF-8")); /* POTENTIAL FLAW: SHA512 with a predictable salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
SecureRandom r = new SecureRandom();
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(r.getSeed(32)); /* FIX: Use a sufficiently random salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
/* goodG2B2() - use goodsource and badsink by reversing statements in first if */
private void goodG2B2(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
if(IO.static_final_five==5)
{
/* FIX: Use a hardcoded string */
data = "foo";
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
data = ""; /* initialize data in case id is not in query string */
/* POTENTIAL FLAW: Parse id param out of the URL querystring (without using getParameter()) */
{
StringTokenizer st = new StringTokenizer(request.getQueryString(), "&");
while (st.hasMoreTokens())
{
String token = st.nextToken(); /* a token will be like "id=foo" */
if(token.startsWith("id=")) /* check if we have the "id" parameter" */
{
data = token.substring(3); /* set data to "foo" */
break; /* exit while loop */
}
}
}
}
if(IO.static_final_five==5)
{
if (data != null)
{
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(data.getBytes("UTF-8")); /* POTENTIAL FLAW: SHA512 with a predictable salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
SecureRandom r = new SecureRandom();
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(r.getSeed(32)); /* FIX: Use a sufficiently random salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
/* goodB2G1() - use badsource and goodsink by changing second IO.static_final_five==5 to IO.static_final_five!=5 */
private void goodB2G1(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
if(IO.static_final_five==5)
{
data = ""; /* initialize data in case id is not in query string */
/* POTENTIAL FLAW: Parse id param out of the URL querystring (without using getParameter()) */
{
StringTokenizer st = new StringTokenizer(request.getQueryString(), "&");
while (st.hasMoreTokens())
{
String token = st.nextToken(); /* a token will be like "id=foo" */
if(token.startsWith("id=")) /* check if we have the "id" parameter" */
{
data = token.substring(3); /* set data to "foo" */
break; /* exit while loop */
}
}
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Use a hardcoded string */
data = "foo";
}
if(IO.static_final_five!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
if (data != null)
{
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(data.getBytes("UTF-8")); /* POTENTIAL FLAW: SHA512 with a predictable salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
else {
SecureRandom r = new SecureRandom();
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(r.getSeed(32)); /* FIX: Use a sufficiently random salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
/* goodB2G2() - use badsource and goodsink by reversing statements in second if */
private void goodB2G2(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
if(IO.static_final_five==5)
{
data = ""; /* initialize data in case id is not in query string */
/* POTENTIAL FLAW: Parse id param out of the URL querystring (without using getParameter()) */
{
StringTokenizer st = new StringTokenizer(request.getQueryString(), "&");
while (st.hasMoreTokens())
{
String token = st.nextToken(); /* a token will be like "id=foo" */
if(token.startsWith("id=")) /* check if we have the "id" parameter" */
{
data = token.substring(3); /* set data to "foo" */
break; /* exit while loop */
}
}
}
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Use a hardcoded string */
data = "foo";
}
if(IO.static_final_five==5)
{
SecureRandom r = new SecureRandom();
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(r.getSeed(32)); /* FIX: Use a sufficiently random salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
else {
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
if (data != null)
{
MessageDigest hash = MessageDigest.getInstance("SHA-512");
hash.update(data.getBytes("UTF-8")); /* POTENTIAL FLAW: SHA512 with a predictable salt */
byte[] hashv = hash.digest("hash me".getBytes("UTF-8"));
IO.writeLine(IO.toHex(hashv));
}
}
}
public void good(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
goodG2B1(request, response);
goodG2B2(request, response);
goodB2G1(request, response);
goodB2G2(request, response);
}
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"guillermo.pando@gmail.com"
] | guillermo.pando@gmail.com |
7f0e11ad29bd69421afefd3b8098cb389a338d3a | 70677921f10f6f1605e3b76dea1115e9286d395d | /spt-jenkins-demo/src/main/java/com/gavin/spt/jenkins/controller/IndexCtroller.java | 36307621e4b0534bf39ec1d49c7e9fb47a35d0df | [] | no_license | xujun339/spt | 951491b5b83597d8f5cc2aad4f4eae95cfe5006a | 6bb2f4130bbc3fd58f41a7d94b6bd272ceb1ec2e | refs/heads/master | 2023-06-24T21:49:37.022011 | 2021-07-10T23:25:13 | 2021-07-10T23:25:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 432 | java | package com.gavin.spt.jenkins.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class IndexCtroller {
@RequestMapping(value = "/hello")
public Object hello() {
Map<String, String> m = new HashMap<>();
m.put("ret", "0");
return m;
}
}
| [
"gavinjunftd@163.com"
] | gavinjunftd@163.com |
171d2d198343c5511dd13ee41ceda934d9a56f22 | 15a71c35e285b5af8ec5d79f04a103891c4a2476 | /src/MinMaxPQ.java | 925e1ff38a80e9b41479d0a48bb22a00c56814af | [] | no_license | alexanderson2209/Double-Ended-PQ | 3da097e0443f7c8f50abc17cf6fa4315b2b7b114 | 7880ce61e2ae7d2142365fdcdd689b3b0b37f753 | refs/heads/master | 2021-01-10T14:23:12.411471 | 2015-11-25T23:23:19 | 2015-11-25T23:23:19 | 46,893,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,728 | java | /*
* Author: Alex Anderson
* Summer 2014
*/
package a07;
import java.util.Arrays;
import java.util.NoSuchElementException;
/*
* Double-ended priority queue implemented using 2 arrays of private class Element.
* One to hold a Max PQ, and the other to hold the Min PQ.
*/
public class MinMaxPQ<T extends Comparable<T>> {
private Element<T>[] maxPriorityQueue;
private Element<T>[] minPriorityQueue;
private int size;
@SuppressWarnings("unchecked")
public MinMaxPQ() {
maxPriorityQueue = new Element[2];
minPriorityQueue = new Element[2];
size = 0;
}
/*
* Element provides clean/concise way of storing useful information, much like a Node.
*/
private class Element<E> {
E data;
int maxIndex;
int minIndex;
Element(E data) {
this.data = data;
}
@Override
public String toString() {
return data.toString();
}
}
/*
* Adds element to DEPQ. If element is null, method throws NullPointerException.
*
* Time Complexity:
* maxSwim and minSwim use worst case log(n) comparisons.
* At first glance, the resize operation would take O(n) time.
* I researched this a little bit and if we use an amortized analysis
* of the resize method (since resizing doesn't happen every time), it
* turns out to be O(1) time for resizing.
*
* This method would use O(2log(n)). This reduces to O(log(n)).
*/
public void add(T e) {
if (e == null) throw new NullPointerException();
if (size >= maxPriorityQueue.length - 1)
resize(maxPriorityQueue.length * 2);
Element<T> temp = new Element<>(e);
temp.maxIndex = ++size;
temp.minIndex = size;
maxPriorityQueue[size] = temp;
minPriorityQueue[size] = temp;
maxSwim(size);
minSwim(size);
}
/*
* Removes the max element from the DEPQ.
*
* Time Complexity:
* removeMax and removeMin time complexity is analogous to the
* add method time complexity (see explanation for add method).
*/
public T removeMax() {
if (isEmpty()) throw new NoSuchElementException();
//return element
T max = maxPriorityQueue[1].data;
//index in corresponding min PQ.
int minIndex = maxPriorityQueue[1].minIndex;
//Switches maximum element with last element in both PQs.
minSwap(minIndex, size);
maxSwap(1, size);
//Deletes end elements for both PQs and decrements size.
maxPriorityQueue[size] = null;
minPriorityQueue[size] = null;
size--;
if (size > 0) {
//Shrinks arrays if size becomes 1/4 of the arrays capacity.
if (size <= (minPriorityQueue.length - 1) / 4)
resize((minPriorityQueue.length) / 2);
//Sinks the switched element in both PQs.
maxSink(1);
minSink(minIndex);
}
return max;
}
/*
* Removes the min element from the DEPQ.
*
* Time Complexity:
* removeMax and removeMin time complexity is analogous to the
* add method time complexity (see explanation for add method).
*/
public T removeMin() {
if (isEmpty()) throw new NoSuchElementException();
//return element
T min = minPriorityQueue[1].data;
//index in corresponding max PQ.
int maxIndex = minPriorityQueue[1].maxIndex;
//Switches minimum element with last element in both PQs.
maxSwap(maxIndex, size);
minSwap(1, size);
//Deletes end elements for both PQs and decrements size.
minPriorityQueue[size] = null;
maxPriorityQueue[size] = null;
size--;
if (size > 0) {
//Shrinks arrays if size becomes 1/4 of the arrays capacity.
if (size <= (minPriorityQueue.length - 1) / 4)
resize((minPriorityQueue.length) / 2);
//Sinks the switched element in both PQs.
minSink(1);
maxSink(maxIndex);
}
return min;
}
/*
* Returns maximum element. Throws NoSuchElementException if no max element is found.
*
* Time Complexity:
* max() uses O(1) time.
*/
public T max() {
if (size == 0) throw new NoSuchElementException("There is no Max element");
return maxPriorityQueue[1].data;
}
/*
* Returns minimum element. Throws NoSuchElementException if no min element is found.
*
* Time Complexity:
* min() uses O(1) time.
*/
public T min() {
if (size == 0) throw new NoSuchElementException("There is no Min element");
return minPriorityQueue[1].data;
}
/*
* Returns true if empty, false otherwise.
*
* Time Complexity:
* isEmpty() uses O(1) time.
*/
public boolean isEmpty() {
return size == 0;
}
/*
* Sends element @ index upwards towards the top of the max PQ until it reaches the correct position.
*/
private void maxSwim(int index) {
while (index > 1 && maxPriorityQueue[index / 2].data.compareTo(maxPriorityQueue[index].data) < 0) {
maxSwap(index / 2, index);
index /= 2;
}
}
/*
* Sends element @ index downwards towards the correct position in the max PQ.
*/
private void maxSink(int index) {
while (index <= size / 2) {
int comparedIndex = index * 2;
if (comparedIndex < size && maxPriorityQueue[comparedIndex].data.compareTo(maxPriorityQueue[comparedIndex + 1].data) < 0)
comparedIndex++;
if (maxPriorityQueue[index].data.compareTo(maxPriorityQueue[comparedIndex].data) > 0)
break;
maxSwap(index, comparedIndex);
index = comparedIndex;
}
}
/*
* Swaps a & b in the max PQ.
*/
private void maxSwap(int a, int b) {
Element<T> temp = maxPriorityQueue[a];
maxPriorityQueue[a] = maxPriorityQueue[b];
maxPriorityQueue[b] = temp;
maxPriorityQueue[a].maxIndex = a;
maxPriorityQueue[b].maxIndex = b;
}
/*
* Sends element @ index upwards towards the top of the min PQ until it reaches the correct position.
*/
private void minSwim(int index) {
while (index > 1 && minPriorityQueue[index / 2].data.compareTo(minPriorityQueue[index].data) > 0) {
minSwap(index / 2, index);
minSwim(index / 2);
}
}
/*
* Sends element @ index downwards towards the correct position in the min PQ.
*/
private void minSink(int index) {
while (index <= size / 2) {
int comparedIndex = index * 2;
if (comparedIndex < size && minPriorityQueue[comparedIndex].data.compareTo(minPriorityQueue[comparedIndex + 1].data) > 0)
comparedIndex++;
if (minPriorityQueue[index].data.compareTo(minPriorityQueue[comparedIndex].data) < 0)
break;
minSwap(index, comparedIndex);
index = comparedIndex;
}
}
/*
* Swaps a & b in the min PQ.
*/
private void minSwap(int a, int b) {
Element<T> temp = minPriorityQueue[a];
minPriorityQueue[a] = minPriorityQueue[b];
minPriorityQueue[b] = temp;
minPriorityQueue[a].minIndex = a;
minPriorityQueue[b].minIndex = b;
}
/*
* Resizes the DEPQ to size newArraySize
*/
private void resize(int newArraySize) {
maxPriorityQueue = Arrays.copyOf(maxPriorityQueue, newArraySize);
minPriorityQueue = Arrays.copyOf(minPriorityQueue, newArraySize);
}
} | [
"alex.anderson2209@gmail.com"
] | alex.anderson2209@gmail.com |
007ba72c57c2d8120cbec100ac23a96bf5c669e1 | aa7892d58784de382e5fa7b873e8361715bd14a3 | /app/src/main/java/com/appniche/android/sunshine/app/gcm/MyInstanceIDListenerService.java | 1d5091329faf7f214b9f3106d7cbd6a3447f183f | [
"Apache-2.0"
] | permissive | jay-thakur/Go-Ubiquitous | 11d7829f8232e40053f10a36f26a36bd6fd5bfa1 | 595335375b0ce637c78a388fd11df8bc1e5462e0 | refs/heads/master | 2020-12-06T11:27:17.255779 | 2017-02-17T09:52:41 | 2017-02-17T09:52:41 | 67,813,388 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,304 | java | /*
* Copyright (C) 2015 The Android Open Source Project
*
* 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.appniche.android.sunshine.app.gcm;
import android.content.Intent;
import com.google.android.gms.iid.InstanceIDListenerService;
public class MyInstanceIDListenerService extends InstanceIDListenerService {
private static final String TAG = "MyInstanceIDLS";
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. This call is initiated by the
* InstanceID provider.
*/
@Override
public void onTokenRefresh() {
// Fetch updated Instance ID token.
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
}
}
| [
"jayprakashthakursnr@gmail.com"
] | jayprakashthakursnr@gmail.com |
fe34bb220e32a9da00a41171e2bf8f48198f27ff | dfc4e17f1251540d13b51e189192415136ed8b24 | /opscloud-domain/src/main/java/com/baiyi/opscloud/domain/generator/opscloud/AliyunLog.java | 16e82bca8b3e26637f3194e3d98b6a61de6ff6e0 | [
"Apache-2.0"
] | permissive | ixrjog/opscloud4 | c397df0777d235f177519466cc7626178c46710e | 941c6fde279bf57a24889737828e44d552cdaa14 | refs/heads/master | 2023-09-06T02:24:47.441021 | 2023-08-29T10:30:01 | 2023-08-29T10:30:01 | 136,586,249 | 351 | 119 | Apache-2.0 | 2023-07-25T08:18:48 | 2018-06-08T07:54:42 | Java | UTF-8 | Java | false | false | 727 | java | package com.baiyi.opscloud.domain.generator.opscloud;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Data
@Table(name = "aliyun_log")
public class AliyunLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 数据源实例id
*/
@Column(name = "datasource_instance_id")
private Integer datasourceInstanceId;
private String project;
private String logstore;
private String config;
private String comment;
@Column(name = "create_time", insertable = false, updatable = false)
private Date createTime;
@Column(name = "update_time", insertable = false, updatable = false)
private Date updateTime;
} | [
"ixrjog@qq.com"
] | ixrjog@qq.com |
cecb0106c8c80b6f69239fce447e9ca42a8844a7 | 38cda5249d49719045a2e5b079d204b6d8557a9f | /Sum of two digit number/Main.java | 2813351608003f4f574569d13a96df48b9cf0a6a | [] | no_license | riyajoy780783/Playground | 91941852b6b95890f67b3dddb9de3cc08b37aba4 | 400aa6e25b9be7f35b522af6abd9541922cebd19 | refs/heads/master | 2020-06-05T18:43:39.717242 | 2019-08-31T12:49:38 | 2019-08-31T12:49:38 | 192,515,284 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 138 | java | #include<stdio.h>
int main()
{
int a,b,sum,num;
scanf("%d",&num);
a=num%10;
b=num/10;
sum=a+b;
printf("%d",sum);
return 0;
} | [
"51952440+riyajoy780783@users.noreply.github.com"
] | 51952440+riyajoy780783@users.noreply.github.com |
32b2b2a8512c728f8b1ef3c9985135b486e40cfe | 1e575d637795c388b8c0dffdff095ed99dd242eb | /jeecms/src/com/tnt/core/entity/base/BaseUnifiedUser.java | f43627ed5aac7cc56e82c379384f99256e60340e | [] | no_license | apachemsl/tntbbs | b5ba7e9fe1d0559ff44d12f93813a1c107b70889 | 54bf3710061edf5d689b850f51cb6f8dcafbc185 | refs/heads/master | 2020-07-09T13:47:08.520219 | 2016-09-01T04:03:51 | 2016-09-01T04:03:51 | 67,028,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,622 | java | package com.tnt.core.entity.base;
import java.io.Serializable;
/**
* This is an object that contains data related to the jo_user table.
* Do not modify this class because it will be overwritten if the configuration file
* related to this class is modified.
*
* @hibernate.class
* table="jo_user"
*/
public abstract class BaseUnifiedUser implements Serializable {
public static String REF = "UnifiedUser";
public static String PROP_LOGIN_COUNT = "loginCount";
public static String PROP_REGISTER_TIME = "registerTime";
public static String PROP_PASSWORD = "password";
public static String PROP_LAST_LOGIN_IP = "lastLoginIp";
public static String PROP_EMAIL = "email";
public static String PROP_RESET_KEY = "resetKey";
public static String PROP_LAST_LOGIN_TIME = "lastLoginTime";
public static String PROP_RESET_PWD = "resetPwd";
public static String PROP_ID = "id";
public static String PROP_REGISTER_IP = "registerIp";
public static String PROP_USERNAME = "username";
// constructors
public BaseUnifiedUser () {
initialize();
}
/**
* Constructor for primary key
*/
public BaseUnifiedUser (java.lang.Integer id) {
this.setId(id);
initialize();
}
/**
* Constructor for required fields
*/
public BaseUnifiedUser (
java.lang.Integer id,
java.lang.String username,
java.lang.String password,
java.util.Date registerTime,
java.lang.String registerIp,
java.lang.Integer loginCount) {
this.setId(id);
this.setUsername(username);
this.setPassword(password);
this.setRegisterTime(registerTime);
this.setRegisterIp(registerIp);
this.setLoginCount(loginCount);
initialize();
}
protected void initialize () {}
private int hashCode = Integer.MIN_VALUE;
// primary key
private java.lang.Integer id;
// fields
private java.lang.String username;
private java.lang.String email;
private java.lang.String password;
private java.util.Date registerTime;
private java.lang.String registerIp;
private java.util.Date lastLoginTime;
private java.lang.String lastLoginIp;
private java.lang.Integer loginCount;
private java.lang.String resetKey;
private java.lang.String resetPwd;
private java.util.Date errorTime;
private java.lang.Integer errorCount;
private java.lang.String errorIp;
private java.lang.Boolean activation;
private java.lang.String activationCode;
/**
* Return the unique identifier of this class
* @hibernate.id
* generator-class="identity"
* column="user_id"
*/
public java.lang.Integer getId () {
return id;
}
/**
* Set the unique identifier of this class
* @param id the new ID
*/
public void setId (java.lang.Integer id) {
this.id = id;
this.hashCode = Integer.MIN_VALUE;
}
/**
* Return the value associated with the column: username
*/
public java.lang.String getUsername () {
return username;
}
/**
* Set the value related to the column: username
* @param username the username value
*/
public void setUsername (java.lang.String username) {
this.username = username;
}
/**
* Return the value associated with the column: email
*/
public java.lang.String getEmail () {
return email;
}
/**
* Set the value related to the column: email
* @param email the email value
*/
public void setEmail (java.lang.String email) {
this.email = email;
}
/**
* Return the value associated with the column: password
*/
public java.lang.String getPassword () {
return password;
}
/**
* Set the value related to the column: password
* @param password the password value
*/
public void setPassword (java.lang.String password) {
this.password = password;
}
/**
* Return the value associated with the column: register_time
*/
public java.util.Date getRegisterTime () {
return registerTime;
}
/**
* Set the value related to the column: register_time
* @param registerTime the register_time value
*/
public void setRegisterTime (java.util.Date registerTime) {
this.registerTime = registerTime;
}
/**
* Return the value associated with the column: register_ip
*/
public java.lang.String getRegisterIp () {
return registerIp;
}
/**
* Set the value related to the column: register_ip
* @param registerIp the register_ip value
*/
public void setRegisterIp (java.lang.String registerIp) {
this.registerIp = registerIp;
}
/**
* Return the value associated with the column: last_login_time
*/
public java.util.Date getLastLoginTime () {
return lastLoginTime;
}
/**
* Set the value related to the column: last_login_time
* @param lastLoginTime the last_login_time value
*/
public void setLastLoginTime (java.util.Date lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
/**
* Return the value associated with the column: last_login_ip
*/
public java.lang.String getLastLoginIp () {
return lastLoginIp;
}
/**
* Set the value related to the column: last_login_ip
* @param lastLoginIp the last_login_ip value
*/
public void setLastLoginIp (java.lang.String lastLoginIp) {
this.lastLoginIp = lastLoginIp;
}
/**
* Return the value associated with the column: login_count
*/
public java.lang.Integer getLoginCount () {
return loginCount;
}
/**
* Set the value related to the column: login_count
* @param loginCount the login_count value
*/
public void setLoginCount (java.lang.Integer loginCount) {
this.loginCount = loginCount;
}
/**
* Return the value associated with the column: reset_key
*/
public java.lang.String getResetKey () {
return resetKey;
}
/**
* Set the value related to the column: reset_key
* @param resetKey the reset_key value
*/
public void setResetKey (java.lang.String resetKey) {
this.resetKey = resetKey;
}
/**
* Return the value associated with the column: reset_pwd
*/
public java.lang.String getResetPwd () {
return resetPwd;
}
/**
* Set the value related to the column: reset_pwd
* @param resetPwd the reset_pwd value
*/
public void setResetPwd (java.lang.String resetPwd) {
this.resetPwd = resetPwd;
}
public java.util.Date getErrorTime() {
return errorTime;
}
public void setErrorTime(java.util.Date errorTime) {
this.errorTime = errorTime;
}
public java.lang.Integer getErrorCount() {
return errorCount;
}
public void setErrorCount(java.lang.Integer errorCount) {
this.errorCount = errorCount;
}
public java.lang.String getErrorIp() {
return errorIp;
}
public void setErrorIp(java.lang.String errorIp) {
this.errorIp = errorIp;
}
public java.lang.Boolean getActivation() {
return activation;
}
public void setActivation(java.lang.Boolean activation) {
this.activation = activation;
}
public java.lang.String getActivationCode() {
return activationCode;
}
public void setActivationCode(java.lang.String activationCode) {
this.activationCode = activationCode;
}
public boolean equals (Object obj) {
if (null == obj) return false;
if (!(obj instanceof com.tnt.core.entity.UnifiedUser)) return false;
else {
com.tnt.core.entity.UnifiedUser unifiedUser = (com.tnt.core.entity.UnifiedUser) obj;
if (null == this.getId() || null == unifiedUser.getId()) return false;
else return (this.getId().equals(unifiedUser.getId()));
}
}
public int hashCode () {
if (Integer.MIN_VALUE == this.hashCode) {
if (null == this.getId()) return super.hashCode();
else {
String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
this.hashCode = hashStr.hashCode();
}
}
return this.hashCode;
}
public String toString () {
return super.toString();
}
} | [
"msl1221@126.com"
] | msl1221@126.com |
cb7df608056b44b60d93d46fb04208332460faaa | d48c65ff6fe79831f2d2f0485fae65ca2ee828af | /app/src/main/java/space/dotcat/assistant/screen/general/BaseDiffUtilCallback.java | 307304c5910490c51c9f50abc7e7b043081d9a9d | [
"MIT"
] | permissive | dot-cat/creative_assistant_android | 12fd908a2244b8e36dda470d49990baec988bd16 | be283b237bad7d2775e8f8490f91dc38606ce505 | refs/heads/devel | 2021-09-24T09:24:58.922384 | 2018-08-08T08:54:34 | 2018-08-08T08:54:34 | 68,194,675 | 0 | 2 | MIT | 2018-08-08T08:54:35 | 2016-09-14T09:52:34 | Java | UTF-8 | Java | false | false | 562 | java | package space.dotcat.assistant.screen.general;
import android.support.v7.util.DiffUtil;
import java.util.List;
public abstract class BaseDiffUtilCallback<T> extends DiffUtil.Callback {
protected List<T> mOldList;
protected List<T> mNewList;
public BaseDiffUtilCallback(List<T> oldList, List<T> newList) {
mOldList = oldList;
mNewList = newList;
}
@Override
public int getOldListSize() {
return mOldList.size();
}
@Override
public int getNewListSize() {
return mNewList.size();
}
}
| [
"DavudD83@gmail.com"
] | DavudD83@gmail.com |
d366764ae7aa479e20a1375297d85bff06913f5c | 00cc2ec59810679f4f517def18c42a15932d506c | /src/comparable/Animal.java | a10c7daae839f67be48a3df2ffaae58cd3957635 | [] | no_license | hugotb88/OCP_SE8 | 3b199eee6e1d39c612a8fd631843afba74e1dee3 | 3d9d9592fa6c521907ecc24276987a3eb147ae80 | refs/heads/master | 2021-10-27T14:33:20.872859 | 2021-10-11T19:40:29 | 2021-10-11T19:40:29 | 129,809,641 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,307 | java | package comparable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author victor olvera
* This class uses a custom compareTo, the another one Duck, uses of the String
* For example, if we want to sort our animals in the zoo by their id
*/
public class Animal implements Comparable<Animal>{
//Fields
private int id;
//Constructor
public Animal(int id) {
this.id = id;
}
//Methods
public String toString() {
return Integer.toString(id);
}
@Override
public int compareTo(Animal a) {
return id - a.id;
}
//Main
public static void main(String[] args) {
Animal a1 = new Animal(5);
Animal a2 = new Animal(7
);
List<Animal> animals = new ArrayList<>();
animals.add(a1);
animals.add(a2);
//Before we sort, we can check which value returns compareTo
System.out.println(a1.compareTo(a2)); //-2 - First rule, compares a smaller id to a large one and get negative value
System.out.println(a1.compareTo(a1)); // 0 - Second rule, id's are the same
System.out.println(a2.compareTo(a1)); // 2 - Third rule, compares a higher id to a smaller one and gets positive
Collections.sort(animals); //uses compareTo
System.out.println(animals); //2,5
}
}
| [
"victor olvera@TDG-MBL-GDL498.tiempodev.local"
] | victor olvera@TDG-MBL-GDL498.tiempodev.local |
bec1cde9943fb2f735544030b6993daca6620cea | 8b3cd315befd8ec11ef5e51d1777ee1bdbcb7f31 | /nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java | c32bbd5a709938e932ce714c61b85bdf8cd60a97 | [] | no_license | marekgr/hc2vpp | 25fdd8c4c93022e015844ac09efb74641417c5e7 | c6e27c7f0e1f1bc791878f3d0ca277500aad5fe6 | refs/heads/master | 2020-03-20T20:20:20.603702 | 2018-06-15T11:38:44 | 2018-06-15T11:43:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,922 | java | /*
* Copyright (c) 2017 Cisco and/or its affiliates.
*
* 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 io.fd.hc2vpp.nat.read;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Maps;
import com.google.common.primitives.UnsignedBytes;
import com.google.common.primitives.UnsignedInts;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.StaticCacheKeyFactory;
import io.fd.vpp.jvpp.nat.dto.Nat64PrefixDetails;
import io.fd.vpp.jvpp.nat.dto.Nat64PrefixDetailsReplyDump;
import io.fd.vpp.jvpp.nat.dto.Nat64PrefixDump;
import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.Instance;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.InstanceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.PolicyBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.policy.Nat64Prefixes;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.policy.Nat64PrefixesBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.policy.Nat64PrefixesKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class Nat64PrefixesCustomizer
implements ListReaderCustomizer<Nat64Prefixes, Nat64PrefixesKey, Nat64PrefixesBuilder>,
JvppReplyConsumer, Ipv6Translator {
private static final Logger LOG = LoggerFactory.getLogger(Nat64PrefixesCustomizer.class);
private final DumpCacheManager<Map<Long, Nat64PrefixDetails>, Void> dumpManager;
Nat64PrefixesCustomizer(@Nonnull final FutureJVppNatFacade jvppNat) {
this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Map<Long, Nat64PrefixDetails>, Void>()
.withExecutor(new Nat64PrefixesExecutor(jvppNat))
.withCacheKeyFactory(
new StaticCacheKeyFactory(Nat64PrefixesCustomizer.class.getName() + "_dump", Map.class))
.build();
}
@Nonnull
@Override
public List<Nat64PrefixesKey> getAllIds(@Nonnull final InstanceIdentifier<Nat64Prefixes> id,
@Nonnull final ReadContext context)
throws ReadFailedException {
final InstanceKey natKey = id.firstKeyOf(Instance.class);
LOG.trace("Listing IDs for all nat64 prefixes within nat-instance(vrf): {}", natKey);
// VPP supports only single nat64-prefix per VRF/nat-instance (we map nat-instances to VRFs)
final Map<Long, Nat64PrefixDetails> prefixesByVrfId =
dumpManager.getDump(id, context.getModificationCache()).get();
final Nat64PrefixDetails details = prefixesByVrfId.get(natKey.getId());
if (details != null) {
return Collections.singletonList(new Nat64PrefixesKey(readPrefix(details)));
} else {
return Collections.emptyList();
}
}
@Override
public void merge(@Nonnull final Builder<? extends DataObject> builder,
@Nonnull final List<Nat64Prefixes> readData) {
((PolicyBuilder) builder).setNat64Prefixes(readData);
}
@Nonnull
@Override
public Nat64PrefixesBuilder getBuilder(@Nonnull final InstanceIdentifier<Nat64Prefixes> id) {
return new Nat64PrefixesBuilder();
}
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Nat64Prefixes> id,
@Nonnull final Nat64PrefixesBuilder builder, @Nonnull final ReadContext context)
throws ReadFailedException {
LOG.trace("Reading nat64-prefixes: {}", id);
final Map<Long, Nat64PrefixDetails> prefixesByVrfId =
dumpManager.getDump(id, context.getModificationCache()).get();
final Nat64PrefixDetails details = prefixesByVrfId.get(id.firstKeyOf(Instance.class).getId());
if (details != null) {
builder.setNat64Prefix(readPrefix(details));
}
}
private Ipv6Prefix readPrefix(final Nat64PrefixDetails details) {
return toIpv6Prefix(details.prefix, UnsignedBytes.toInt(details.prefixLen));
}
private final class Nat64PrefixesExecutor implements EntityDumpExecutor<Map<Long, Nat64PrefixDetails>, Void> {
private final FutureJVppNatFacade jvppNat;
private Nat64PrefixesExecutor(@Nonnull final FutureJVppNatFacade jvppNat) {
this.jvppNat = checkNotNull(jvppNat, "jvppNat should not be null");
}
@Nonnull
@Override
public Map<Long, Nat64PrefixDetails> executeDump(final InstanceIdentifier<?> id, final Void params)
throws ReadFailedException {
final Nat64PrefixDetailsReplyDump dump =
getReplyForRead(jvppNat.nat64PrefixDump(new Nat64PrefixDump()).toCompletableFuture(), id);
// To improve read performance (if multiple nat instances are defined),
// we store map instead of list of prefixes.
// Current nat64-prefixes mapping relies on the fact, that VPP supports single prefix for VRF.
// To validate that we rely on Guava's Maps.uniqueIndex which trows IllegalStateException
// if duplicate key is found.
return Maps.uniqueIndex(dump.nat64PrefixDetails, prefixDetails -> UnsignedInts.toLong(prefixDetails.vrfId));
}
}
}
| [
"mgradzki@cisco.com"
] | mgradzki@cisco.com |
8e0e416684e870baf7bb10c7edf67ae7ebc89476 | 83069583daa890bd7a34cf546001af4ace2fc1af | /src/com/km/bean/CostPlan.java | e3835d6646d59e3d00add602dbd78bbaa25bb113 | [] | no_license | np7sky/internship | 247484c90ff383a5cf0073738f316db01fbdb2f7 | b94a75b94b7591f11f2624dc83aa9f3767e98489 | refs/heads/master | 2021-06-01T02:03:08.038627 | 2016-06-07T13:47:34 | 2016-06-07T13:47:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,848 | java | package com.km.bean;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.km.common.bean.AbstractBaseEntity;
import com.km.util.CommonUtil;
/**
* @author tcn 空幕 email:1623092203@qq.com time:2016年5月23日下午8:17:27
*/
@Entity
@Table
public class CostPlan extends AbstractBaseEntity<Long>
{
//实习总费用
private Double totalCost = 0d;
//专业实习人数
private Long professionalNumber = 0L;
//毕业实习人数
private Long graduateNumner = 0L;
//专业实习平均费用
private Double professionalAvgCost = 0d;
//毕业实习平均费用
private Double graduateAvgCost = 0d;
//本专科生实习费用
private Double collegeStuFee = 0d;
//实习联系费
private Double connectionFee = 0d;
//实习机动经费
private Double activeFee = 0d;
//剩余实习经费
private Double residualFee = 0d;
//实习经费计划名称
private String costPlanName;
//实习经费计划说明
private String planRemark;
//实习计划所属年份
private Long planYear;
@OneToMany(mappedBy="costPlan")
private List<MajorPlan> majorPlans;
public Double getTotalCost()
{
return CommonUtil.formatDouble(totalCost);
}
public void setTotalCost(Double totalCost)
{
this.totalCost = CommonUtil.formatDouble(totalCost);
}
public Long getProfessionalNumber()
{
return professionalNumber;
}
public void setProfessionalNumber(Long professionalNumber)
{
this.professionalNumber = professionalNumber;
}
public Long getGraduateNumner()
{
return graduateNumner;
}
public void setGraduateNumner(Long graduateNumner)
{
this.graduateNumner = graduateNumner;
}
public Double getProfessionalAvgCost()
{
return CommonUtil.formatDouble(professionalAvgCost);
}
public void setProfessionalAvgCost(Double professionalAvgCost)
{
this.professionalAvgCost = CommonUtil.formatDouble(professionalAvgCost);
}
public Double getGraduateAvgCost()
{
return CommonUtil.formatDouble(graduateAvgCost);
}
public void setGraduateAvgCost(Double graduateAvgCost)
{
this.graduateAvgCost = CommonUtil.formatDouble(graduateAvgCost);
}
public Double getCollegeStuFee()
{
return CommonUtil.formatDouble(collegeStuFee);
}
public void setCollegeStuFee(Double collegeStuFee)
{
this.collegeStuFee = CommonUtil.formatDouble(collegeStuFee);
}
public Double getConnectionFee()
{
return CommonUtil.formatDouble(connectionFee);
}
public void setConnectionFee(Double connectionFee)
{
this.connectionFee = CommonUtil.formatDouble(connectionFee);
}
public Double getActiveFee()
{
return CommonUtil.formatDouble(activeFee);
}
public void setActiveFee(Double activeFee)
{
this.activeFee = CommonUtil.formatDouble(activeFee);
}
public Double getResidualFee()
{
return CommonUtil.formatDouble(residualFee);
}
public void setResidualFee(Double residualFee)
{
this.residualFee = CommonUtil.formatDouble(residualFee);
}
public String getCostPlanName()
{
return costPlanName;
}
public void setCostPlanName(String costPlanName)
{
this.costPlanName = costPlanName;
}
public String getPlanRemark()
{
return planRemark;
}
public void setPlanRemark(String planRemark)
{
this.planRemark = planRemark;
}
public Long getPlanYear()
{
return planYear;
}
public void setPlanYear(Long planYear)
{
this.planYear = planYear;
}
public List<MajorPlan> getMajorPlans()
{
return majorPlans;
}
public void setMajorPlans(List<MajorPlan> majorPlans)
{
this.majorPlans = majorPlans;
}
}
| [
"3201008489@qq.com"
] | 3201008489@qq.com |
cbe2c7f463031d394af28bd4abfd38aa7228a65d | 564a7e774404dcf8f9a9d92e22a71c95bcb46715 | /src/example/citypulse/sensors/temperature/TemperatureSensor.java | 9021266eb6085e8ca28f4c770dbb7aaf83bb7ced | [] | no_license | huangjunli864/prime-middleware-examples | cc8dd49cabfc91ed92faf14caa7d48ed2d4e7943 | 24c9c666c8dad977dd5b2a544847a619542ac975 | refs/heads/master | 2021-05-28T06:53:37.528694 | 2014-12-15T13:55:04 | 2014-12-15T13:55:04 | 43,998,198 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,878 | java | /**
* This file is part of the PRIME middleware.
* See http://www.erc-smscom.org
*
* Copyright (C) 2008-2013 ERC-SMSCOM Project
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA, or send email
*
* @author Mauro Caporuscio
*/
package example.citypulse.sensors.temperature;
import org.prime.core.comm.addressing.AURI;
import org.prime.core.comm.addressing.CURI;
import org.prime.description.Description;
import org.prime.comm.pastry_impl.PastryGateway;
import org.prime.core.PrimeApplication;
import org.prime.core.PrimeResource;
import example.citypulse.data.SensorInfo;
import example.citypulse.sensors.temperature.resources.TemperatureSensorResource;
import example.citypulse.sensors.utility.GPS;
import example.citypulse.sensors.utility.Thermometer;
import example.citypulse.sensors.temperature.TemperatureSensor;
public class TemperatureSensor extends PrimeApplication{
private GPS gps;
private Thermometer t;
private SensorInfo myinfo;
private CURI tempCURI;
private AURI tempAURI;
public TemperatureSensor(String id, int httpPort) throws Exception{
super(id, httpPort);
gps = new GPS();
t = new Thermometer();
myinfo = new SensorInfo(gps.getGeoInfo(), String.valueOf(t.getValue()), "temperature");
}
// public void calculateMyGeoInfo(){
//
// CURI dest = new CURI("api.ipinfodb.com/v3/ip-city/?key=f1add0d3e2e8b2b2ca3b880ba97bf40f35776a877e7c9532c4c37b5ea6871d6e&format=xml");
//
// try {
//
//
// PrimeHTTPConnection conn = this.getConnection(dest);
//
// GeoInfo newval = JAXB.unmarshal(conn.get().getStream(), GeoInfo.class);
// if ((this.mygeo == null) || !newval.equals(this.mygeo)){
// this.mygeo = newval;
//
// GeoInfoResponse info = new GeoInfoResponse(this.mygeo);
// info.setName(this.applicationId.toString());
//
//
// this.notify(this.applicationId, new AURI("GeoLocatedAgentGroup"), info);
// }
//
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
public void loadResource(Class<? extends PrimeResource> resource){
try {
tempCURI = this.registerResource(resource);
Description d = this.registry.getDescription(tempCURI);
d.getContext().set("latitude", this.myinfo.getLatitude());
d.getContext().set("longitude", this.myinfo.getLongitude());
tempAURI = d.getAURI();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getName(){
return this.applicationId.toString();
}
public SensorInfo getSensorInfo(){
return this.myinfo;
}
public void checkSensorValue(long sleep){
while(true){
try {
Thread.sleep(sleep);
if (this.myinfo.getValue().compareTo(String.valueOf(t.getValue())) != 0 ){
notify(tempCURI, tempAURI, myinfo);
this.myinfo.setValue(String.valueOf(t.getValue()));
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) throws Exception {
//Parse input parameters
String name = args[0];
int localDNSPort = Integer.parseInt(args[1]);
int httpPort = Integer.parseInt(args[2]);
long intervall = Long.parseLong(args[3]);
//Initialize PrimeApplication
TemperatureSensor sensor = new TemperatureSensor(name, httpPort);
//Instantiate the Prime Communication layer
PastryGateway gateway = new PastryGateway(localDNSPort);
sensor.setGateway(gateway);
//Initialize Semantic-aware DNS
String[] onts = {"data/ontologies/ApplicationOntology-SMSComDevices.owl"};
sensor.initResourceRegistry(onts, "http://www.erc-smscom.org/ex/early#");
//Load the resource to expose
sensor.loadResource(TemperatureSensorResource.class);
//Start the PrimeApplication
sensor.startPrimeApplication();
//Keep checking the temperature every "interval" millis
sensor.checkSensorValue(intervall);
}
}
| [
"mauro.caporuscio@lnu.se"
] | mauro.caporuscio@lnu.se |
2e24dd36028af9d0a32b924a977f65d6cdb1a22e | 3814b41a7f890d00f6ddfd451138a5cab4f4d8a8 | /src/lesson_9/ITC_1/Main.java | 036b34c85bb1e47f32270e1655ec3cbaa521a0cf | [] | no_license | m0levich/first_repository | dd70774ae79a48474795d0b6a75e16772880803f | 12afdd9e3f7b3df4e7afd580a7e2632c12c2bcde | refs/heads/master | 2021-01-03T09:43:00.189619 | 2020-03-19T15:35:39 | 2020-03-19T15:35:39 | 240,025,918 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,052 | java | package lesson_9.ITC_1;
import java.sql.*;
public class Main {
public static void main(String[] args) {
Connection connection = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/carsshop?serverTimezone=UTC",
"root",
"notfound"
);
Statement stmt = connection.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM cars");
while (result.next()){
System.out.println("Номер строки в выборке " + result.getRow() + "\n Марка " + result.getString(2) +
" модель " + result.getString("model") +
"\n цена " + result.getInt("price"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| [
"molkov@i-teco.ru"
] | molkov@i-teco.ru |
fa501ef93236ab6dfc8406d41c847f2e7bdc44e6 | a94e9cfc8af1361da9c23e85fa582ceb0c5c3626 | /src/test/java/br/ce/wcaquino/servicos/OrdemTest.java | ac0dbd3519754e4048129c212ab38194aceae343 | [] | no_license | IHPNULL/EstudoTestesUnitarios | 85bc98bf2b2660697349591bcdb43450d8a89c61 | d609d643204a14f99876acd5fef575066a6b6564 | refs/heads/master | 2021-03-30T09:13:24.956864 | 2020-03-30T17:53:26 | 2020-03-30T17:53:26 | 248,036,613 | 0 | 0 | null | 2020-10-13T20:26:18 | 2020-03-17T17:50:26 | Java | UTF-8 | Java | false | false | 375 | java | package br.ce.wcaquino.servicos;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OrdemTest {
public static int cont = 0;
@Test
public void inicia() {
cont = 1;
}
@Test
public void verifica() {
Assert.assertEquals(1, cont);
}
}
| [
"54510120+IHP-null@users.noreply.github.com"
] | 54510120+IHP-null@users.noreply.github.com |
8a0530c269798e3e1be6bdd94a93b1033e606c25 | 657f392fa1e466ea141f4f67995d32f196ff2565 | /src/bounded_contexts/shared/domain/main/java/bounded_contexts/shared/domain/validations/fieds/FieldMatchWithRegExp.java | b1bd91a37db3cb05a8267fc4044e05c62014610d | [] | no_license | hdespaigne87/spring-gradle-ddd-skeleton | 73806daadddf5b15d501f522d8cb7e24fc325cfe | 5858184b6d77eb6507709cd346099c81948e6870 | refs/heads/master | 2022-12-05T17:25:15.428803 | 2020-08-13T17:52:04 | 2020-08-13T17:52:04 | 286,538,174 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 681 | java | package bounded_contexts.shared.domain.validations.fieds;
import java.util.regex.Pattern;
public abstract class FieldMatchWithRegExp extends FieldValidation {
public FieldMatchWithRegExp(Object rootObject, String fieldName, Object fieldValueToValidate) {
super(rootObject, fieldName, fieldValueToValidate);
}
protected abstract String getRegExpPattern();
@Override
protected boolean isValid(Object fieldValueToValidate) {
if (!(fieldValueToValidate instanceof String))
return true;
Pattern pattern = Pattern.compile(getRegExpPattern());
return pattern.matcher(fieldValueToValidate.toString()).matches();
}
}
| [
"husseyn.despaignereyes@gmail.com"
] | husseyn.despaignereyes@gmail.com |
d359e206ad4cc3c2495636c3d55f6d7820048d2c | 506fd7964c7d3a32bcf2ae2e4f34714e8e448fcd | /3.JavaMultithreading/src/com/javarush/task/task32/task3209/actions/RedoAction.java | d44e003103ad51a7bca6763c471da630dac8bc1e | [] | no_license | TatianaSnisarenko/JavaRushTasks | e012845c8d361108a5badd382f6b9e383802295b | 07426ca7e08320798a5668486e89cdc031dd87b7 | refs/heads/master | 2023-03-03T00:34:42.192953 | 2021-02-13T19:04:25 | 2021-02-13T19:04:25 | 338,644,868 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | package com.javarush.task.task32.task3209.actions;
import com.javarush.task.task32.task3209.View;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class RedoAction extends AbstractAction {
private View view;
public RedoAction(View view){
this.view = view;
}
@Override
public void actionPerformed(ActionEvent actionEvent) {
view.redo();
}
}
| [
"tatiana.snisarenko.p@gmail.com"
] | tatiana.snisarenko.p@gmail.com |
6132e9921284c7b4f0c35e570faf0fe7339dfd76 | d87768be3e44b4e2b5808e9c1d2b5f32e296eb0b | /Java Básico - Eclipse/Mobile/src/br/senai/sp/informatica/mobileb/aulas/ex04/Ex0403.java | ec71d5f738e6293d429bd4182915dce3399adf56 | [] | no_license | rodolfoand/CodeEX | 71caa034dfb25005c716f9db885392944636c183 | 8f6a06b041aa5b497e17c2d8483cb139ef8f01f4 | refs/heads/master | 2021-09-06T18:57:33.676658 | 2018-02-09T23:52:40 | 2018-02-09T23:52:40 | 109,196,421 | 0 | 0 | null | 2017-12-10T17:46:13 | 2017-11-01T23:52:16 | Java | UTF-8 | Java | false | false | 522 | java | package br.senai.sp.informatica.mobileb.aulas.ex04;
import br.senai.sp.informatica.mobileb.lib.Util;
public class Ex0403 {
public static void main(String[] args) {
double a = Util.leReal("Informe o valor de a: ");
double b = Util.leReal("Informe o valor de b: ");
double c = Util.leReal("Informe o valor de c: ");
double x1 = (-b + Math.sqrt( Math.pow(b, 2) - 4 * a *c)) / 2 * a;
double x2 = (-b - Math.sqrt( Math.pow(b, 2) - 4 * a *c)) / 2 * a;
Util.escreva("x' = ", x1, "\n", "x'' = ", x2);
}
}
| [
"rdvieira@gmail.com"
] | rdvieira@gmail.com |
4fbc7e8c8b0952c9c34e1c3b31800329626af1b9 | e56e35069c07155b8ab049290b0ac6b5ae0e6fb5 | /app/src/main/java/com/softdesign/devintensive/data/network/res/UserListRes.java | 92fe96174ce6dc8b9048fdc3c12d0678645eb50a | [] | no_license | bugtsa/DevIntensive | 589e959517cc05f5dc77d883260a181dbc18969f | 1afa163761b20745830e4cee5f0d3a1ad298cfb0 | refs/heads/master | 2021-01-20T15:57:50.425793 | 2017-08-18T18:28:43 | 2017-08-18T18:28:43 | 61,551,189 | 0 | 0 | null | 2016-07-27T09:49:59 | 2016-06-20T13:49:41 | Java | UTF-8 | Java | false | false | 1,818 | java | package com.softdesign.devintensive.data.network.res;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
public class UserListRes {
@SerializedName("success")
@Expose
private boolean success;
@SerializedName("data")
@Expose
private List<UserData> data = new ArrayList<UserData>();
public List<UserData> getData() {
return data;
}
public class UserData {
@SerializedName("_id")
@Expose
private String id;
@SerializedName("first_name")
@Expose
private String firstName;
@SerializedName("second_name")
@Expose
private String secondName;
@SerializedName("__v")
@Expose
private int v;
@SerializedName("repositories")
@Expose
private UserModelRes.Repositories repositories;
@SerializedName("profileValues")
@Expose
private UserModelRes.ProfileValues profileValues;
@SerializedName("publicInfo")
@Expose
private UserModelRes.PublicInfo publicInfo;
@SerializedName("specialization")
@Expose
private String specialization;
@SerializedName("updated")
@Expose
private String updated;
public UserModelRes.Repositories getRepositories() {
return repositories;
}
public UserModelRes.ProfileValues getProfileValues() {
return profileValues;
}
public UserModelRes.PublicInfo getPublicInfo() {
return publicInfo;
}
public String getFullName() {
return firstName + " " + secondName;
}
public String getId() {
return id;
}
}
}
| [
"bugtsa@gmail.com"
] | bugtsa@gmail.com |
b4c2134a9410b36d222b740127dc7f886e77df87 | 11eb2eda22a3a450eb6a31e01c0ca8a4bfc031ff | /src/main/java/com/wang/springboot/mySpringBoot/api/account/domain/Account.java | caca49914e77bd6b16ec52f092e14f38d83c97d3 | [] | no_license | tcwangxiaoxi/mySpringBoot | b4bde870eaed5fb7d0e4ac047f380d424ec7fa06 | f2df59eddf3a0945ffe5d664287f332d4637966c | refs/heads/master | 2021-01-10T02:53:17.404954 | 2016-04-12T08:29:20 | 2016-04-12T08:29:20 | 51,162,540 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,549 | java | /**
* @Title: Account.java
* @Package com.wang.springboot.mySpringBoot.api.account.domain
* @Description: TODO(用一句话描述该文件做什么)
* @author River.W
* @date 2016年2月6日 上午12:44:29
* @version V1.0
*/
package com.wang.springboot.mySpringBoot.api.account.domain;
import java.io.Serializable;
import com.wang.springboot.mySpringBoot.base.domain.AbstractAuditingEntity;
/**
* @ClassName: Account
* @Description: 用户对象
* @Company:
* @author River.W
* @date 2016年2月6日 上午12:44:29
*
*/
public class Account extends AbstractAuditingEntity implements Serializable {
/**
* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
*/
private static final long serialVersionUID = -2717785170437637556L;
private String id;
private String name;
private String email;
private String password;
private boolean activated;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isActivated() {
return activated;
}
public void setActivated(boolean activated) {
this.activated = activated;
}
/**
* <p>
* Title:
* </p>
* <p>
* Description:
* </p>
*/
public Account() {
super();
}
/**
* <p>
* Title:
* </p>
* <p>
* Description:
* </p>
*
* @param id
* @param name
* @param email
* @param password
* @param activated
*/
public Account(String id, String name, String email, String password, boolean activated) {
super();
this.id = id;
this.name = name;
this.email = email;
this.password = password;
this.activated = activated;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName()).append(" [").append("Hash = ").append(hashCode()).append(", id=")
.append(id).append(", name=").append(name).append(", password=").append(password).append(", email=")
.append(email).append(", activated=").append(activated).append(", serialVersionUID=")
.append(serialVersionUID).append("]");
return sb.toString();
}
}
| [
"tcwangxiaoxi@gmail.com"
] | tcwangxiaoxi@gmail.com |
666e07f2173ffe533021c2730eca787fac0a7f28 | 0ff0314505b7ba26fa731f345cef75cb3ae3fb9f | /simple/commons/src/main/java/cn/com/yunyoutianxia/commons/exception/BusinessException.java | 5adce80e3e9d3a42f2dd58d89f954f8cba11afa2 | [] | no_license | tanyp/simple | e9dea813127cdf78ac34fd5f00f36909e453c7ab | 3dc035e0e825b69017e941ebd961f09ce946dd8d | refs/heads/master | 2020-04-28T00:07:30.678792 | 2019-04-05T13:09:05 | 2019-04-05T13:09:05 | 174,804,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 149 | java | package cn.com.yunyoutianxia.commons.exception;
/**
* Created by tanyp on 2019/3/13
*/
public class BusinessException extends RuntimeException{
}
| [
"dev.tanyp@qq.com"
] | dev.tanyp@qq.com |
6d3d77f2c7161d8be75c6023fed7a70c7a080930 | 1fa175a35c393619edc2dc47cc09e5fcbb8c8636 | /Aula-10/src/main/java/inimigo/Inimigo.java | 2d3161d45cc8be96d384d8e5bd161dce817a5279 | [] | no_license | HadassaKimura/POO | 2e87b5a96fbc551b1d5b84623c0a1510ac6d0834 | 04f808d4336f2175fa7d898c297eb29b7c2e0e5f | refs/heads/main | 2023-08-11T20:11:59.871697 | 2021-09-27T17:20:28 | 2021-09-27T17:20:28 | 410,977,872 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 499 | java | package inimigo;
public abstract class Inimigo {
protected double vida;
protected String nome;
//Construtor
public Inimigo(double vida, String nome) {
this.vida = vida;
this.nome =nome;
}
public abstract void atacando();
public void tomarDano(){
System.out.println("Inimigo: " +this.nome + " tomando dano");
}
//Getter
public double getVida() {
return vida;
}
public String getNome() {
return nome;
}
}
| [
"69400710+HadassaKimura@users.noreply.github.com"
] | 69400710+HadassaKimura@users.noreply.github.com |
89682871caa432fc8c4d74cb26508d1b040a8d83 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/ui/widget/MMEditText$d.java | 9ff92f2b43f8e815ffe4213d9ee94318e06c3513 | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 316 | java | package com.tencent.mm.ui.widget;
public abstract interface MMEditText$d
{
public abstract boolean awK(int paramInt);
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes4.jar
* Qualified Name: com.tencent.mm.ui.widget.MMEditText.d
* JD-Core Version: 0.7.0.1
*/ | [
"98632993+tsuzcx@users.noreply.github.com"
] | 98632993+tsuzcx@users.noreply.github.com |
e8a55d3fae9f035274324418f4e5925eb5d92acd | 8a4f1aa397b7e689ddc0ca130d1c0f5777f538d0 | /src/main/java/com/kuangshan/riskcontrol/tool/JiguangPush.java | 1e2044eaa8dec7a93070e6adb61cec8cccdbe586 | [] | no_license | venom1999/ksaq_web | 46f67ffeb6651500ef1dd52ca8b148c0bf15fdcf | 0ec0915f4e3c951bc6304fe2689e111f806bb098 | refs/heads/master | 2022-12-25T11:14:46.406387 | 2020-04-09T05:51:19 | 2020-04-09T05:51:19 | 254,073,487 | 0 | 1 | null | 2022-12-16T07:52:30 | 2020-04-08T11:51:33 | JavaScript | UTF-8 | Java | false | false | 7,770 | java | package com.kuangshan.riskcontrol.tool;
import cn.jpush.api.push.model.SMS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;
import java.util.Collection;
/**
* java后台极光推送方式二:使用Java SDK
*/
@SuppressWarnings({ "deprecation", "restriction" })
public class JiguangPush {
private static final Logger log = LoggerFactory.getLogger(JiguangPush.class);
private static String masterSecret = "7c88abf1d2e2820314c8a41b";
private static String appKey = "9a9849f3da48e4cf392c1577";
// private static final String ALERT = "推送信息";
/**
* 极光推送
*/
JiguangPush(){
}
/**
* 极光推送方法(采用java SDK)
* @param alias 别名集合
* @param tags 用户集合
* @param alert 传递信息
* @return PushResult
*/
public static PushResult push(Collection<String> alias, Collection<String> tags, String alert){
ClientConfig clientConfig = ClientConfig.getInstance();
JPushClient jpushClient = new JPushClient(masterSecret, appKey, null, clientConfig);
PushPayload payload = null;
if(alias!=null&&!alias.isEmpty()){
payload = buildPushObject_android_ios_alias_alert(alias,alert);
}else {
payload = buildPushObject_android_tag_alertWithTitle(tags,alert);
}
try {
return jpushClient.sendPush(payload);
} catch (APIConnectionException e) {
log.error("Connection error. Should retry later. ", e);
return null;
} catch (APIRequestException e) {
log.error("Error response from JPush server. Should review and fix it. ", e);
log.info("HTTP Status: " + e.getStatus());
log.info("Error Code: " + e.getErrorCode());
log.info("Error Message: " + e.getErrorMessage());
log.info("Msg ID: " + e.getMsgId());
return null;
}
}
/**
* 生成极光推送对象PushPayload(采用java SDK) 针对alias推送
* @param alias
* @param alert
* @return PushPayload
*/
public static PushPayload buildPushObject_android_ios_alias_alert( Collection<String> alias
,String alert){
if(alias!=null&&alert!=null){
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setSMS(SMS.content(1,10))
.setAudience(Audience.alias(alias))
.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(alert)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(alert)
.build())
.build())
.setOptions(Options.newBuilder()
.setApnsProduction(false)//true-推送生产环境 false-推送开发环境(测试使用参数)
.setTimeToLive(90)//消息在JPush服务器的失效时间(测试使用参数)
.build())
.build();
} else if(alias==null&&alert!=null){
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setSMS(SMS.content(1,10))
.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(alert)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(alert)
.build())
.build())
.setOptions(Options.newBuilder()
.setApnsProduction(false)//true-推送生产环境 false-推送开发环境(测试使用参数)
.setTimeToLive(90)//消息在JPush服务器的失效时间(测试使用参数)
.build())
.build();
} else if(alias!=null&&alert==null){
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setSMS(SMS.content(1,10))
.setAudience(Audience.alias(alias))
.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("type", "infomation")
.build())
.addPlatformNotification(IosNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(alert)
.build())
.build())
.setOptions(Options.newBuilder()
.setApnsProduction(false)//true-推送生产环境 false-推送开发环境(测试使用参数)
.setTimeToLive(90)//消息在JPush服务器的失效时间(测试使用参数)
.build())
.build();
}else {
return null;
}
}
/**
* 生成极光推送对象PushPayload(采用java SDK) 针对alias推送
* @param tags 推送目标标志
* @param ALERT
* @return PushPayload
*/
public static PushPayload buildPushObject_android_tag_alertWithTitle( Collection<String> tags,String ALERT){
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setSMS(SMS.content(1,10))
.setAudience(Audience.tag(tags))
.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(ALERT)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.addExtra("type", "infomation")
.setAlert(ALERT)
.build())
.build())
.setOptions(Options.newBuilder()
.setApnsProduction(false)//true-推送生产环境 false-推送开发环境(测试使用参数)
.setTimeToLive(90)//消息在JPush服务器的失效时间(测试使用参数)
.build())
.build();
}
} | [
"49115023+venom1999@users.noreply.github.com"
] | 49115023+venom1999@users.noreply.github.com |
d982bd5555c64f63809d4a670d7729f644e977ad | d8a3409ddfef26fdcf2a7f8676ffa05639a0a09e | /src/main/java/org/fife/util/FlatUtil.java | a9bf3aee7bd3fa6f7a557f9dceead6d19383f49f | [] | no_license | Abneco/FifeCommon | 125c0a27776314d2a5eb6c364627e2414a6ac53b | e0712e2bbffa49d8d5df6ccc1f04024d862f5d06 | refs/heads/master | 2023-08-27T06:12:25.552302 | 2021-10-27T02:57:06 | 2021-10-27T02:57:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,756 | java | /*
* http://fifesoft.com/rtext
* Licensed under a modified BSD license.
* See the included license file for details.
*/
package org.fife.util;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
/**
* Utility methods to make FifeCommon mesh better with FlatLaf.
*
* @author Robert Futrell
* @version 1.0
*/
public final class FlatUtil {
/**
* Private constructor to prevent instantiation.
*/
private FlatUtil() {
// Do nothing
}
/**
* Returns whether the currently installed LookAndFeel is a FlatLaf variant.
*
* @return Whether the currently installed LookAndFeel is a FlatLaf variant.
* @see #isFlatLookAndFeel(String)
*/
public static boolean isFlatLafInstalled() {
return isFlatLookAndFeel(UIManager.getLookAndFeel());
}
/**
* Returns whether a LookAndFeel is Flat.
*
* @param laf The LookAndFeel. If this is {@code null}, {@code false} is
* returned.
* @return Whether the LaF is a FlatLaf variant.
* @see #isFlatLafInstalled()
*/
public static boolean isFlatLookAndFeel(LookAndFeel laf) {
return laf != null && isFlatLookAndFeel(laf.getClass().getSimpleName());
}
/**
* Returns whether a LookAndFeel is Flat.
*
* @param laf The class name of the LookAndFeel. If this is {@code null},
* {@code null} is returned.
* @return Whether the LaF is a FlatLaf variant.
* @see #isFlatLafInstalled()
*/
public static boolean isFlatLookAndFeel(String laf) {
return laf != null && laf.contains("Flat");
}
/**
* Returns whether the specified UI is a FlatLaf UI.
*
* @param ui The UI to check.
* @return Whether it's a FlatLaf UI.
*/
public static boolean isFlatUI(ComponentUI ui) {
return ui.getClass().getSimpleName().contains("Flat");
}
}
| [
"robert.e.futrell@gmail.com"
] | robert.e.futrell@gmail.com |
47821c8a2dee5040daef7ee8020a77c490739bfa | 071a9fa7cfee0d1bf784f6591cd8d07c6b2a2495 | /corpus/norm-class/eclipse.jdt.core/2658.java | c9162a591d30ba77ac7eb6c722faf7554822a5b6 | [
"MIT"
] | permissive | masud-technope/ACER-Replication-Package-ASE2017 | 41a7603117f01382e7e16f2f6ae899e6ff3ad6bb | cb7318a729eb1403004d451a164c851af2d81f7a | refs/heads/master | 2021-06-21T02:19:43.602864 | 2021-02-13T20:44:09 | 2021-02-13T20:44:09 | 187,748,164 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,657 | java | copyright bea systems rights reserved program accompanying materials terms eclipse license accompanies distribution http eclipse org legal epl html contributors mkaufman bea initial api implementation ibm corporation remove deprecated warning org eclipse jdt apt tests junit framework test junit framework test suite testsuite org eclipse core resources i file ifile org eclipse core resources resources plugin resourcesplugin org eclipse core runtime preferences instance scope instancescope org eclipse jdt apt core internal apt plugin aptplugin org eclipse jdt apt core internal generated file generatedfile generated file manager generatedfilemanager org eclipse jdt apt core util apt config aptconfig org eclipse jdt core i compilation unit icompilationunit org eclipse jdt core i java project ijavaproject org eclipse jdt core java model exception javamodelexception org eclipse jdt core working copy owner workingcopyowner org eclipse jdt core tests model modifying resource tests modifyingresourcetests apt reconcile tests aptreconciletests modifying resource tests modifyingresourcetests i java project ijavaproject jproject apt reconcile tests aptreconciletests string test suite test suite testsuite apt reconcile tests aptreconciletests test generated file testgeneratedfile throwable string fname test folder testfolder java errors annotation commented string code with errors codewitherrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld create file createfile fname code with errors codewitherrors problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code with errors codewitherrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems errors annotations string code with out errors codewithouterrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld set working copy contents setworkingcopycontents code with out errors codewithouterrors working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems throwable print stack trace printstacktrace delete file deletefile fname tests annotation generates file annotation generates file error parent file todo enable test sporadically flaky find throwable test nested generated file testnestedgeneratedfile throwable string fname test folder testfolder java errors annotation commented string code with errors codewitherrors test org eclipse jdt apt tests annotations nested helloworld nestedhelloworld nested hello world annotation nestedhelloworldannotation nested hello world annotation nestedhelloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld create file createfile fname code with errors codewitherrors problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code with errors codewitherrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems errors annotations string code with out errors codewithouterrors test org eclipse jdt apt tests annotations nested helloworld nestedhelloworld nested hello world annotation nestedhelloworldannotation nested hello world annotation nestedhelloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld set working copy contents setworkingcopycontents code with out errors codewithouterrors working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems throwable print stack trace printstacktrace delete file deletefile fname test stop gen erating file in reconciler teststopgeneratingfileinreconciler exception string fname test folder testfolder java errors annotation commented string code with errors codewitherrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld create file createfile fname code with errors codewitherrors problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code with errors codewitherrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems errors annotations string code with out errors codewithouterrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld set working copy contents setworkingcopycontents code with out errors codewithouterrors working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems errors annotations set working copy contents setworkingcopycontents code with errors codewitherrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems exception print stack trace printstacktrace tests working copy discarded clean cached data generated file manager generatedfilemanager test discard parent working copy testdiscardparentworkingcopy throwable string fname test folder testfolder java string code with out errors codewithouterrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld create file createfile fname code with out errors codewithouterrors problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code with out errors codewithouterrors problem requestor remove errors occurred set up working copy setupworkingcopy problem requestor problemrequestor problem requestor problemrequestor working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems i java project ijavaproject working copy workingcopy get java project getjavaproject generated file manager generatedfilemanager gfm apt plugin aptplugin get apt project getaptproject get generated file manager getgeneratedfilemanager gfm contains working copy map entries for parent containsworkingcopymapentriesforparent i file ifile working copy workingcopy get resource getresource fail expected find map entries generated file manager generatedfilemanager working copy workingcopy discard working copy discardworkingcopy gfm contains working copy map entries for parent containsworkingcopymapentriesforparent i file ifile working copy workingcopy get resource getresource fail unexpected map entries generated file manager generatedfilemanager delete file deletefile fname test basic reconcile testbasicreconcile exception string fname test folder testfolder java string code test org eclipse jdt apt tests annotations api test apitest common main string argv create file createfile fname code problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems delete file deletefile fname test no reconcile testnoreconcile throwable start disabling reconcile time processing apt config aptconfig set process during reconcile setprocessduringreconcile jproject string fname test folder testfolder java errors annotation commented string code with errors codewitherrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld create file createfile fname code with errors codewitherrors problem requestor problemrequestor problem requestor problemrequestor set up working copy setupworkingcopy fname code with errors codewitherrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems errors annotations reconcile string code with out errors codewithouterrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld set working copy contents setworkingcopycontents code with out errors codewithouterrors working copy workingcopy reconcile i compilation unit icompilationunit ast string expected problems expectedproblems error test project testproject src test java generatedfilepackage generated file test generatedfiletest hello world helloworld generatedfilepackage resolved assert problems assertproblems unexpected problems expected problems expectedproblems enable reconcile time processing errors apt config aptconfig set process during reconcile setprocessduringreconcile jproject string code with out errors codewithouterrors test org eclipse jdt apt tests annotations helloworld hello world annotation helloworldannotation hello world annotation helloworldannotation main string argv generatedfilepackage generated file test generatedfiletest hello world helloworld set working copy contents setworkingcopycontents code with out errors codewithouterrors working copy workingcopy reconcile i compilation unit icompilationunit ast assert problems assertproblems unexpected problems unexpectedproblems throwable print stack trace printstacktrace delete file deletefile fname set up setup exception increments project test helps sporadic thr eading threading problems w harley wharley test project num testprojectnum test project testproject test project test project num testprojectnum test folder testfolder test project testproject src test apt plugin aptplugin trace setting test project testproject set up setup disable auto build don build time type generation int erfering interfering reconcile tests string key resources plugin resourcesplugin pref auto building instance scope instancescope instance get node getnode resources plugin resourcesplugin resources put boolean putboolean key problem requestor problemrequestor problem requestor problemrequestor i java project ijavaproject project create java project createjavaproject test project testproject string src string jcl lib bin test util testutil create and add annotation jar createandaddannotationjar project apt config aptconfig set enabled setenabled project create folder createfolder test folder testfolder jproject project tear down teardown exception jproject apt plugin aptplugin trace tearing test project testproject delete project deleteproject test project testproject tear down teardown copied reconciler tests reconcilertests set working copy contents setworkingcopycontents string contents java model exception javamodelexception working copy workingcopy get buffer getbuffer set contents setcontents contents problem requestor problemrequestor initialize contents to char array tochararray suppress warnings suppresswarnings deprecation set up working copy setupworkingcopy string path string contents java model exception javamodelexception working copy workingcopy working copy workingcopy discard working copy discardworkingcopy working copy workingcopy get compilation unit getcompilationunit path get working copy getworkingcopy working copy owner workingcopyowner problem requestor problemrequestor set working copy contents setworkingcopycontents contents working copy workingcopy make consistent makeconsistent assert problems assertproblems string message string expected assert problems assertproblems message expected problem requestor problemrequestor i compilation unit icompilationunit working copy workingcopy problem requestor problemrequestor problem requestor problemrequestor string test project testproject string test folder testfolder test project num testprojectnum nls string test project apt reconcile tests aptreconciletests get name getname project | [
"masudcseku@gmail.com"
] | masudcseku@gmail.com |
ee5ef8238186b09e1cb0be6f0473c484c091da10 | 263e18dbb9358d1b92fd84a9f8d142918689d853 | /hw5/task8/ArrayGarland.java | dd57de3572ebdae8b541a0d35816f092ed0c644e | [] | no_license | MaksGrishaev/HomeWork | 754fb84af6508468da48d6cd37245b17c54d4724 | 3bfcb96e9391bad3ffe67caf553e5051bfe16221 | refs/heads/master | 2021-09-06T23:46:55.188756 | 2018-02-13T13:24:25 | 2018-02-13T13:24:25 | 115,286,546 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 247 | java | package hw5.task8;
public class ArrayGarland {
public static void main(String[] args) {
int[] garland = new int[50];
ArrayGarlandMethods.generateBinGarland(garland);
ArrayGarlandMethods.garlandChoice(garland);
}
}
| [
"gm.grishaev@gmail.com"
] | gm.grishaev@gmail.com |
98cea9a87aaed82e43ba16d0b6471fc967da035f | 7370ab46ee64e3d3f6b9b495799374035bef4afa | /project1/src/main/java/com/revature/daos/PersonDaoImp.java | 082e2c76c6d5c3d0f2adac3d7f5f08d733655923 | [] | no_license | TRMS-v4/back-end | 23a89ce664c5e8053829e205654c0621ba3624d3 | 71a3344f2a6fb7ba43146be303b7247614cda53a | refs/heads/main | 2023-06-20T13:53:02.440016 | 2021-07-23T19:28:34 | 2021-07-23T19:28:34 | 388,858,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,916 | java | package com.revature.daos;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.revature.beans.Person;
import com.revature.logs.EmployeeLog;
import com.revature.util.JDBC;
public class PersonDaoImp implements PersonDao {
private Connection conn = JDBC.getConnection();
@Override
public boolean createPerson(Person p) {
String sql = "insert into trms.person values" + "(default, ?,?,?,?,?,?);";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, p.getFirstname());
ps.setString(2, p.getLastname());
ps.setString(3, p.getUsername());
ps.setString(4, p.getPass());
ps.setInt(5, p.getPos_id());
ps.setDouble(6, p.getReimb_limit());
ps.execute();
EmployeeLog.empCreateLog();
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public Person getById(Integer p_id) {
String sql = "select * from trms.person where p_id =?;";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, p_id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
Person p = new Person();
p.setP_id(rs.getInt("p_id"));
p.setFirstname(rs.getString("firstname"));
p.setLastname(rs.getString("lastname"));
p.setUsername(rs.getString("username"));
p.setPass(rs.getString("pass"));
p.setPos_id(rs.getInt("pos_id"));
p.setReimb_limit(rs.getDouble("reimb_limit"));
EmployeeLog.empGetByIdLog(p);
return p;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public Person getByUsername(String username) {
String sql = "select * from trms.person where username = ?;";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, username);
ResultSet rs = ps.executeQuery();
if(rs.next()) {
Person p = new Person();
p.setP_id(rs.getInt("p_id"));
p.setFirstname(rs.getString("firstname"));
p.setLastname(rs.getString("lastname"));
p.setUsername(rs.getString("username"));
p.setPass(rs.getString("pass"));
p.setPos_id(rs.getInt("pos_id"));
p.setReimb_limit(rs.getDouble("reimb_limit"));
return p;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public List<Person> getAll() {
String sql = "select * from trms.person;";
List<Person> people = new ArrayList<Person>();
try {
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()) {
Person p = new Person();
p.setP_id(rs.getInt("p_id"));
p.setFirstname(rs.getString("firstname"));
p.setLastname(rs.getString("lastname"));
p.setUsername(rs.getString("username"));
p.setPass(rs.getString("pass"));
p.setPos_id(rs.getInt("pos_id"));
p.setReimb_limit(rs.getDouble("reimb_limit"));
people.add(p);
}
EmployeeLog.empGetAllLog(people);
return people;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public Person getLast() {
String sql = "select * from trms.person where p_id = (select max(p_id) from trms.person);";
Person p = null;
try {
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if(rs.next()) {
p = new Person();
p.setP_id(rs.getInt("p_id"));
p.setFirstname(rs.getString("firstname"));
p.setLastname(rs.getString("lastname"));
p.setUsername(rs.getString("username"));
p.setPass(rs.getString("pass"));
p.setPos_id(rs.getInt("pos_id"));
p.setReimb_limit(rs.getDouble("reimb_limit"));
}
}catch(SQLException e) {
e.printStackTrace();
}
return p;
}
@Override
public boolean update(Person p) {
String sql = "update trms.person set "
+ "firstname =?, "
+ "lastname = ?, "
+ "username = ?, "
+ "pass = ?, "
+ "pos_id = ?, "
+ "reimb_limit = ?"
+ "where p_id = ?;";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, p.getFirstname());
ps.setString(2, p.getLastname());
ps.setString(3, p.getUsername());
ps.setString(4, p.getPass());
ps.setInt(5, p.getPos_id());
ps.setDouble(6, p.getReimb_limit());
ps.setInt(7, p.getP_id());
ps.execute();
EmployeeLog.empUpdateLog(p);
return true;
}catch(SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean deleteById(Integer p_id) {
String sql = "delete from trms.person where p_id = ?;";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, p_id);
EmployeeLog.empDeleteLog(p_id);
ps.execute();
return true;
}catch(SQLException e) {
e.printStackTrace();
}
return false;
}
public static void main(String[] args) {
// test create
// Person p = new Person();
// p.setFirstname("f");
// p.setLastname("l");
// p.setUsername("test");
// p.setPass("pass");
// p.setPos_id(1);
// p.setReimb_limit(1000d);
// PersonDaoImp pDao = new PersonDaoImp();
// pDao.createPerson(p);
// test getById
// PersonDaoImp pDao = new PersonDaoImp();
// System.out.println(pDao.getById(4));
//test getByname
// PersonDaoImp pDao = new PersonDaoImp();
// System.out.println(pDao.getByUsername("pokemon"));
//test getAll
// PersonDaoImp pDao = new PersonDaoImp();
// System.out.println(pDao.getAll());
//
//test getLast()
// PersonDaoImp pDao = new PersonDaoImp();
// System.out.println(pDao.getLast());
//test update
// Person p = new Person();
// p.setP_id(4);
// p.setFirstname("poke");
// p.setLastname("mon");
// p.setUsername("pokemon");
// p.setPass("pass");
// p.setPos_id(1);
// PersonDaoImp pDao = new PersonDaoImp();
// pDao.update(p);
//test delete
// PersonDaoImp pDao = new PersonDaoImp();
// pDao.deleteById(3);
}
}
| [
"mshen0505@gmail.com"
] | mshen0505@gmail.com |
c10efe698d934650369e5f1e3716eca1a969b1d3 | 9849f5c797d446e1d87d5ddd35f92a153142dea2 | /waimai-android/proj.android/app/src/main/java/org/egret/java/waimai-android/GameLoadingView.java | 0d76d620da64501e783c73117450142b8325989e | [] | no_license | wangtututu/WMsender | 6e916ca0332c39f44b2ec5b3c72ed907288eb2c8 | 8556351332ef1b62c49d34dc481e6744bb421698 | refs/heads/master | 2021-05-15T07:11:29.880122 | 2017-11-15T10:35:43 | 2017-11-15T10:35:43 | 110,819,275 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,127 | java | package org.egret.java.waimai-android;
import android.content.Context;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
public class GameLoadingView extends FrameLayout {
private ProgressBar bar;
private TextView tv;
/**
* 游戏下载进度条 上线前请替换渠道自定制进度条
*
* @param context
*/
public GameLoadingView(Context context) {
super(context);
tv = new TextView(context);
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
tv.setText("Game Loading...");
this.addView(tv);
bar = new ProgressBar(context, null,
android.R.attr.progressBarStyleHorizontal);
this.addView(bar);
}
public void onProgress(float progress) {
bar.setProgress((int) progress);
}
public void onGameZipUpdateProgress(float percent) {
bar.setProgress((int) percent);
}
public void onGameZipUpdateError() {
}
public void onGameZipUpdateSuccess() {
}
}
| [
"wangyao_email@163.com"
] | wangyao_email@163.com |
9f2b05a5c5c3c7a99a0534322281eb7914a7c348 | 914e4faa8f66d9c3012c11b557d8e6e92e19beb5 | /vaadin-context-menu-flow-parent/vaadin-context-menu-flow-integration-tests/src/test/java/com/vaadin/flow/component/contextmenu/it/PreserveOnRefreshIT.java | d74ddd810734c3b5ea3b301c304797815abf7ab1 | [
"Apache-2.0"
] | permissive | nohecastellanos/flow-components | 0bbe97f966f1f8af62f97a2ac9d9a7f35e4669c4 | 92cd7f21536efb34ae8ffe0a1636c0f11ab3dee1 | refs/heads/master | 2023-08-11T14:09:11.871892 | 2021-10-08T17:59:17 | 2021-10-08T17:59:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,338 | java | /*
* Copyright 2000-2019 Vaadin Ltd.
*
* 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.vaadin.flow.component.contextmenu.it;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.flow.testutil.TestPath;
/**
* @author Vaadin Ltd
*/
@TestPath("vaadin-context-menu/preserve-on-refresh")
public class PreserveOnRefreshIT extends AbstractContextMenuIT {
@Test
public void autoAttachedContextMenuWithPreserveOnRefresh_refresh_noClientErrors_menuRendered() {
open();
waitForElementPresent(By.id("target"));
getDriver().navigate().refresh();
waitForElementPresent(By.id("target"));
checkLogsForErrors();
rightClickOn("target");
Assert.assertArrayEquals(new String[] { "foo" }, getMenuItemCaptions());
}
}
| [
"manolo@vaadin.com"
] | manolo@vaadin.com |
f23bc5f5f33dae4c25135c3d887c3e3f955e2435 | 6ee19ac1b28430665e9fce2b837ae947db0a03b9 | /lab_1/test/simpledb/HeapPageIdTest.java | 224d3eff4d3690b6917c16c7f8b1c0ef2e999e10 | [] | no_license | vieozhu/SimpleDB | c516ea4577c206a457c305abc59e4e7ae475652c | 0f5f1000074199106fe63da7c91cf94707e322cf | refs/heads/master | 2020-04-01T09:27:18.994982 | 2018-12-15T14:27:04 | 2018-12-15T14:27:04 | 153,075,647 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,244 | java | package simpledb;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import junit.framework.JUnit4TestAdapter;
import org.junit.Before;
import org.junit.Test;
import simpledb.systemtest.SimpleDbTestBase;
public class HeapPageIdTest extends SimpleDbTestBase {
private HeapPageId pid;
@Before
public void createPid() {
pid = new HeapPageId(1, 1);
}
/**
* Unit test for HeapPageId.getTableId()
*/
@Test
public void getTableId() {
assertEquals(1, pid.getTableId());
}
/**
* Unit test for HeapPageId.pageno()
*/
@Test
public void pageno() {
assertEquals(1, pid.pageno());
}
/**
* Unit test for HeapPageId.hashCode()
*/
@Test
public void testHashCode() {
int code1, code2;
// NOTE(ghuo): the hashCode could be anything. test determinism,
// at least.
pid = new HeapPageId(1, 1);
code1 = pid.hashCode();
assertEquals(code1, pid.hashCode());
assertEquals(code1, pid.hashCode());
pid = new HeapPageId(2, 2);
code2 = pid.hashCode();
assertEquals(code2, pid.hashCode());
assertEquals(code2, pid.hashCode());
}
/**
* Unit test for HeapPageId.equals()
*/
@Test
public void equals() {
HeapPageId pid1 = new HeapPageId(1, 1);
HeapPageId pid1Copy = new HeapPageId(1, 1);
HeapPageId pid2 = new HeapPageId(2, 2);
// .equals() with null should return false
assertFalse(pid1.equals(null));
// .equals() with the wrong type should return false
assertFalse(pid1.equals(new Object()));
assertTrue(pid1.equals(pid1));
assertTrue(pid1.equals(pid1Copy));
assertTrue(pid1Copy.equals(pid1));
assertTrue(pid2.equals(pid2));
assertFalse(pid1.equals(pid2));
assertFalse(pid1Copy.equals(pid2));
assertFalse(pid2.equals(pid1));
assertFalse(pid2.equals(pid1Copy));
}
/**
* JUnit suite target
*/
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(HeapPageIdTest.class);
}
}
| [
"397184114@qq.com"
] | 397184114@qq.com |
a2e95be6f347c37e2f8f3c058bc63d78bc2a3bcc | 37b18a07ef958dd4bddad39571994e0f3225cf11 | /BaseGame/src/exceptions/AddingShipAdjacentToAnotherException.java | 5ea7cc1426d31fbf2795d12c70bbf708803c191c | [] | no_license | OferSpivak/BattleShipGame | d6ef8a25e400df36e81dfd8b5f4d641e4a3b5ce8 | f5098fb00f2869ff4973081351698193399d29e1 | refs/heads/master | 2021-01-19T12:48:45.025178 | 2017-07-08T09:07:23 | 2017-07-08T09:07:23 | 88,046,000 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 444 | java | package exceptions;
import engine.battleShip.BattleShip;
/**
* Created by OFer.Spivak on 19/04/2017.
*/
public class AddingShipAdjacentToAnotherException extends InitializationFailException {
public AddingShipAdjacentToAnotherException(BattleShip ship, int x, int y) {
super("Adding the ship {" + ship.toString() + "} is impossible due to it been adjacent to another ship at " + (x + 1) + ", " + (y + 1) + " position");
}
}
| [
"ofer.spivak@timetoknow.com"
] | ofer.spivak@timetoknow.com |
873017768fa232dc60e27def75c9e2ecc12f1385 | 41d887a6d127e0d541f59b743b0ce9848d7ea447 | /src/main/resource/com/fb/qa/test/loginpagetesting.java | efdb68d04d67a367a6b278f3e835b60ea9074bc7 | [] | no_license | nishanth664/nishu | 6d313a2535842a119b162e72122be7205a918827 | aa0ce78f9a7ee5190df6140fc52f7c84eac230ca | refs/heads/master | 2021-07-07T13:03:32.979303 | 2020-02-23T10:57:51 | 2020-02-23T10:57:51 | 241,935,283 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,943 | java | package com.fb.qa.test;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import org.seleniumhq.jetty9.util.security.Credential;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.fb.qa.baseclass.credentials;
import com.fb.qa.pageobject.Loginpageobjects;
import com.fb.qa.utils.commonactions;
public class loginpagetesting extends credentials {
credentials cred = new credentials();
Loginpageobjects loginpageobjects = new Loginpageobjects();
commonactions actions = new commonactions();
Properties prop = new Properties();
public void setup() throws Exception {
cred.nishanth();
}
@Test(priority = 1)
public boolean Gettitle() {
System.out.println("driver=" + driver);
String actualtitle = driver.getTitle();
String expectedTitle = "facebook_ login";
if(actualtitle.contains(expectedTitle)){
System.out.println("title currect ");
return true;
}
else {
System.out.println("title wrong ");
return false;
}
}
@Test(priority =2 )
public void Login_username() {
WebElement object = loginpageobjects.Login_username();
object.isDisplayed();
System.out.println("username is displayed");
object.isSelected();
object.click();
object.sendKeys(prop.getProperty("username"));
}
@Test(priority =3)
public void Login_passwod() {
WebElement object = loginpageobjects.Login_password();
object.click();
object.sendKeys(prop.getProperty("username"));
}
@Test(priority =4 )
public void Login_button() {
WebElement object = loginpageobjects.Login_button();
object.isDisplayed();
object.click();
}
@Test(priority = 5)
public void Check_logo() {
WebElement object = loginpageobjects.Check_logo();
object.click();
}
}
| [
"61287104+nishanth664@users.noreply.github.com"
] | 61287104+nishanth664@users.noreply.github.com |
ab142b1dea583660da0edb83bd8f442f628f88ac | 434693ce33221f85578b5b7c711b8f5e67cdc855 | /app/src/main/java/com/won/taskmodule/AcceptedTaskActivity.java | e75811e4976286567733367a2e44e7e69865935b | [] | no_license | wonwick/group27MobileApp | 08230edd495b24f21f951db35bccadd557c6b2b9 | 8a9b56c6df0f347515caea96d1aff60d4e5b3403 | refs/heads/master | 2021-09-03T04:32:12.407877 | 2017-12-11T05:45:15 | 2017-12-11T05:45:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,291 | java | package com.won.taskmodule;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.text.DateFormat;
import java.util.Date;
public class AcceptedTaskActivity extends AppCompatActivity {
String taskId;
String taskName;
String taskArea;
String contactName;
String contactNumber;
String deadline;
String description;
String acceptedDate;
SharedPreferences sharedPreferences ;
String userName;
DatabaseReference unavailableTask;
DatabaseReference unavailableTaskOverview;
ScrollView scrolview;
TextView textViewContactName ;
TextView textViewContactNumber ;
TextView textViewDeadline ;
TextView textViewDescription ;
TextView textViewTaskName ;
TextView textViewTaskID ;
TextView textViewTaskArea ;
TextView textViewAcceptedDate;
EditText editTextMessage;
private static FirebaseDatabase fbdb;
TableLayout tableLayoutChat;
DatabaseReference acceptedTask;
static boolean calledAlready = false;
// acceptedTask;
// DatabaseReference chat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_acceptd_task);
Intent intent = getIntent();
taskId = intent.getStringExtra("TASK_ID");
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
userName = sharedPreferences.getString("appUser", "");
unavailableTask = FirebaseDatabase.getInstance().getReference("availableTasks").child(taskId);
unavailableTaskOverview = FirebaseDatabase.getInstance().getReference("OverviewAvailableTask").child(taskId);
if (fbdb==null)
{
fbdb=FirebaseDatabase.getInstance();
}
scrolview=(ScrollView) findViewById(R.id.ScrollViewChat);
textViewTaskName = (TextView) findViewById(R.id.textViewTaskName);
textViewTaskID = (TextView) findViewById(R.id.textViewTaskID);
textViewTaskArea = (TextView) findViewById(R.id.textViewTaskArea);
textViewContactName = (TextView) findViewById(R.id.textViewContactName);
textViewContactNumber = (TextView) findViewById(R.id.textViewContactNumber);
textViewDeadline = (TextView) findViewById(R.id.textViewDeadline);
textViewDescription = (TextView) findViewById(R.id.textViewDescription);
textViewAcceptedDate= (TextView) findViewById(R.id.textViewAcceptedDate);
tableLayoutChat=(TableLayout) findViewById(R.id.tableLayoutChat);
editTextMessage=(EditText) findViewById(R.id.editTextMessage);
}
@Override
protected void onStart() {
super.onStart();
//attaching value event listener
acceptedTask = fbdb.getReference("acceptedTasks").child(userName).child(taskId);
acceptedTask.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
AcceptedTask task = dataSnapshot.getValue(AcceptedTask.class);
try {
taskId = task.getId();
taskName = task.getName();
taskArea = task.getArea();
contactName = task.getContactName();
contactNumber = task.getContactNumber();
deadline = task.getDeadline();
description = task.getDescription();
acceptedDate = task.getAcceptedDate();
textViewTaskID.setText(taskId);
textViewTaskName.setText(taskName);
textViewTaskArea.setText(taskArea);
textViewContactName.setText(contactName);
textViewContactNumber.setText(contactNumber);
textViewDeadline.setText(deadline);
textViewDescription.setText(description);
textViewAcceptedDate.setText(acceptedDate);
}
catch (Exception e){
Log.d("AcceptedTaskError","onStart,accptedTaskVAlueListner");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
DatabaseReference chat=fbdb.getReference("chat").child(taskId);
chat.addValueEventListener(new ValueEventListener() {
//chat is handled here
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
tableLayoutChat.removeAllViews();
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
//getting artist;
ChatMessage chatMessage = postSnapshot.getValue(ChatMessage.class);
String theMessege=chatMessage.getMessage();
String theSender=chatMessage.getSender();
String theTime=chatMessage.getTime();
TableRow header=new TableRow(AcceptedTaskActivity.this);
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
header.setLayoutParams(params);
TextView sender = new TextView(AcceptedTaskActivity.this);
sender.setGravity(Gravity.LEFT);
if (theSender.equals(userName)){
sender.setTextColor(Color.BLUE);
}
else{
sender.setTextColor(Color.GREEN);
}
sender.setText(theSender);
TextView time = new TextView(AcceptedTaskActivity.this);
time.setGravity(Gravity.LEFT);
time.setTextColor(Color.GRAY);
time.setText(theTime);
//Log.d("theTime",theTime);
TableRow body=new TableRow(AcceptedTaskActivity.this);
body.setLayoutParams(params);
TextView message = new TextView(AcceptedTaskActivity.this);
message.setGravity(Gravity.LEFT);
message.setText(theMessege);
TableRow spacing=new TableRow(AcceptedTaskActivity.this);
spacing.setLayoutParams(params);
TextView space = new TextView(AcceptedTaskActivity.this);
header.addView(sender);
header.addView(time);
body.addView(message);
spacing.addView(space);
tableLayoutChat.addView(header, params);
tableLayoutChat.addView(body, params);
tableLayoutChat.addView(spacing,params);
scrolview.fullScroll(ScrollView.FOCUS_DOWN);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
@Override
public void onBackPressed() {
startActivity(new Intent(AcceptedTaskActivity.this, AcceptedTasksListActivity.class));
finish();
}
void CompleteTask(View view) {
DatabaseReference chat=FirebaseDatabase.getInstance().getReference("chat").child(taskId).push();
chat.child("sender").setValue(userName);
chat.child("message").setValue("----- C O M P L E T E D -----");
chat.child("time").setValue(DateFormat.getDateTimeInstance().format(new Date()));
startActivity(new Intent(AcceptedTaskActivity.this, EmployeeActivity.class));
addToCompletedTasks();
removeFromAcceptedTasks();
}
void sendMessage(View view) {
String textMessage=editTextMessage.getText().toString();
DatabaseReference chat=FirebaseDatabase.getInstance().getReference("chat").child(taskId).push();
chat.child("sender").setValue(userName);
chat.child("message").setValue(textMessage);
chat.child("time").setValue(DateFormat.getDateTimeInstance().format(new Date()));
editTextMessage.setText("");
scrolview.fullScroll(ScrollView.FOCUS_DOWN);
}
void addToCompletedTasks(){
DatabaseReference newAcceptedTask = FirebaseDatabase.getInstance().getReference("completedTasks").child(userName).child(taskId);
newAcceptedTask.child("id").setValue(taskId);
newAcceptedTask.child("name").setValue(taskName);
newAcceptedTask.child("area").setValue(taskArea);
newAcceptedTask.child("contactName").setValue(contactName);
newAcceptedTask.child("contactNumber").setValue(contactNumber);
newAcceptedTask.child("deadline").setValue(deadline);
newAcceptedTask.child("description").setValue(description);
newAcceptedTask.child("acceptedDate").setValue(acceptedDate);
newAcceptedTask.child("CompletedDate").setValue(DateFormat.getDateTimeInstance().format(new Date()));
}
void removeFromAcceptedTasks() {
acceptedTask.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot detailsSnapshot : dataSnapshot.getChildren()) {
detailsSnapshot.getRef().removeValue();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
| [
"wonwick@gmail.com"
] | wonwick@gmail.com |
934dabecbdff38e43a81c9f5d6dd9c53f56b46b5 | b04848fce55b4808ad55d8f8b65ad7ad4b18d5e5 | /springboot-consumer/src/main/java/com/sxw/springbootconsumer/consumer/OrderReceiver.java | 88af5ccb16c95f17f4609d58d20be2e045315089 | [] | no_license | podrickzhang/springboot-rabbitmq | 39f2e8b0944de88a87999c48b95ab56828ce7d1f | 76d0ff849fe5593c910d521b01837ec4c45eb050 | refs/heads/master | 2020-03-30T07:38:40.418106 | 2018-09-30T10:15:22 | 2018-09-30T10:15:22 | 150,955,347 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,157 | java | package com.sxw.springbootconsumer.consumer;
import com.rabbitmq.client.Channel;
import com.sxw.entity.Order;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
@Component
public class OrderReceiver {
//配置监听的哪一个队列,同时在没有queue和exchange的情况下会去创建并建立绑定关系
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "order-queue",durable = "true"),
exchange = @Exchange(name="order-exchange",durable = "true",type = "topic"),
key = "order.*"
)
)
@RabbitHandler//如果有消息过来,在消费的时候调用这个方法
//@Payload 可以理解为一系列信息中最为关键的信息。
public void onOrderMessage(@Payload Order order, @Headers Map<String,Object> headers, Channel channel) throws IOException {
//消费者操作
System.out.println("---------收到消息,开始消费---------");
System.out.println("订单ID:"+order.getId());
/**
* Delivery Tag 用来标识信道中投递的消息。RabbitMQ 推送消息给 Consumer 时,会附带一个 Delivery Tag,
* 以便 Consumer 可以在消息确认时告诉 RabbitMQ 到底是哪条消息被确认了。
* RabbitMQ 保证在每个信道中,每条消息的 Delivery Tag 从 1 开始递增。
*/
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
/**
* multiple 取值为 false 时,表示通知 RabbitMQ 当前消息被确认
* 如果为 true,则额外将比第一个参数指定的 delivery tag 小的消息一并确认
*/
boolean multiple = false;
//ACK,确认一条消息已经被消费。不然的话,在rabbitmq首页会有Unacked显示为未处理数1.
channel.basicAck(deliveryTag,multiple);
}
}
| [
"958786497@qq.com"
] | 958786497@qq.com |
01fc468a53583374fba440e92bc7b316ac457295 | 624e9434febb6c9534af3625aae4f1e997bd278b | /src/main/java/nl/hgrsd/when/OccurrencesResource.java | 66b591d2797d85f6f96ea7f4af981fa50d1bbbf8 | [] | no_license | hgrsd/when | 18a8f08740476934f18830217f0b9a0d0856302a | cdc4d30066bd9dcf899bb28f6c942c6cf038b8a2 | refs/heads/main | 2023-08-12T06:26:39.698475 | 2021-09-19T18:37:53 | 2021-09-19T20:14:18 | 408,206,077 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 769 | java | package nl.hgrsd.when;
import org.dmfs.rfc5545.recur.InvalidRecurrenceRuleException;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/occurrences")
public class OccurrencesResource {
@Inject
@Cached
OccurrencesRepo repo;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<String> getOccurrences(@QueryParam("rrule") String rrule,
@QueryParam("from") String from,
@QueryParam("to") String to)
throws InvalidRecurrenceRuleException {
return repo.getOccurrences(rrule, from, to);
}
} | [
"daniel@hgrsd.nl"
] | daniel@hgrsd.nl |
94d4eece01e08bf080ee1271ae22534c5ec1f151 | bea43d2f165e7b6929e193fb33fa1dffa6b1b7dd | /app/src/main/java/com/leo/moviehunter/task/GetWatchedListTask.java | 9359480d9e5e3fdc6fa98f8b2adac688f9d3713a | [] | no_license | aaa72/MovieHunter | 79ce4e2e4fede6cf62e4d1244bb17f30f10ee8c8 | 68ec560af80e6773e4d99a948c73e9106a0a93d3 | refs/heads/master | 2020-05-27T09:01:48.518715 | 2017-09-08T03:59:33 | 2017-09-08T03:59:33 | 82,537,739 | 0 | 1 | null | 2017-03-30T08:50:43 | 2017-02-20T09:06:44 | Java | UTF-8 | Java | false | false | 814 | java | package com.leo.moviehunter.task;
import android.content.Context;
import android.os.AsyncTask;
import com.leo.moviehunter.data.user.WatchItem;
import com.leo.moviehunter.datahelper.UserDataHelperFactory;
import java.util.List;
public abstract class GetWatchedListTask extends AsyncTask<Void, Void, List<WatchItem>> {
private Context mContext;
public GetWatchedListTask(Context context) {
mContext = context.getApplicationContext();
}
@Override
protected List<WatchItem> doInBackground(Void... params) {
return UserDataHelperFactory.get(mContext).getWatchedList();
}
@Override
protected void onPostExecute(List<WatchItem> watchedList) {
onGetWatchedList(watchedList);
}
abstract protected void onGetWatchedList(List<WatchItem> watchedList);
}
| [
"leo_huang@htc.com"
] | leo_huang@htc.com |
6be533d711266593744b8fce0c683060b71e51b1 | d1ad602ef9e5dd95f082eec8118d2cd065fae6b1 | /Q1/src/main_package/Main.java | fb95d2abcf7b604b58e7882f8ca1425523091f34 | [] | no_license | guanyuhou/CISC181_q1 | 20fb8d34a8866ab89e638db9148352b122794902 | ddc14dba4e5a31d7b1cb5d90ed982aea9e0ff391 | refs/heads/master | 2021-01-10T11:03:14.168686 | 2016-02-22T07:33:39 | 2016-02-22T07:33:39 | 52,255,086 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,356 | java | package main_package;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
//ask user for status input
System.out.println("Enter number of touchdown passes (TD): ");
double td = in.nextDouble();
System.out.println("Enter number of passing yards (YDS): ");
double yds = in.nextDouble();
System.out.println("Enter number of interceptions (INT): ");
double intercept = in.nextDouble();
System.out.println("Enter number of completions (COMP): ");
double comp = in.nextDouble();
System.out.println("Enter number of passes attempted (ATT): ");
double att = in.nextDouble();
in.close();
//calculate each components
double a = (((comp / att) - 0.3) * 5);
double b = (((yds / att) - 3) * 0.25);
double c = ((td / att) * 20);
double d = 2.375 - (intercept * 25 / att);
//check if the components exceed max or min value
final double max_value = 2.375;
a = (a > max_value) ?2.375 :a;
b = (b > max_value) ?2.375 :b;
c = (c > max_value) ?2.375 :c;
d = (d > max_value) ?2.375 :d;
a = (a < 0) ?0 :a;
b = (b < 0) ?0 :b;
c = (c < 0) ?0 :c;
d = (d < 0) ?0 :d;
//calculate the final rating
double rating = (a + b + c + d) * 100 / 6.0 ;
//print out the qb rating
System.out.println("The QB rating is " + rating);
}
}
| [
"guanyushandong@gmail.com"
] | guanyushandong@gmail.com |
8b70970b91590ea721d3238d4cf7bc285d38a714 | 3f7a5d7c700199625ed2ab3250b939342abee9f1 | /src/gcom/gui/cadastro/localidade/FiltrarQuadraAction.java | 157e56bd77b1ee86cc655590617ba5a01c849356 | [] | no_license | prodigasistemas/gsan-caema | 490cecbd2a784693de422d3a2033967d8063204d | 87a472e07e608c557e471d555563d71c76a56ec5 | refs/heads/master | 2021-01-01T06:05:09.920120 | 2014-10-08T20:10:40 | 2014-10-08T20:10:40 | 24,958,220 | 1 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 12,137 | java | /*
* Copyright (C) 2007-2007 the GSAN - Sistema Integrado de Gestão de Serviços de Saneamento
*
* This file is part of GSAN, an integrated service management system for Sanitation
*
* GSAN 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.
*
* GSAN 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
*/
/*
* GSAN - Sistema Integrado de Gestão de Serviços de Saneamento
* Copyright (C) <2007>
* Adriano Britto Siqueira
* Alexandre Santos Cabral
* Ana Carolina Alves Breda
* Ana Maria Andrade Cavalcante
* Aryed Lins de Araújo
* Bruno Leonardo Rodrigues Barros
* Carlos Elmano Rodrigues Ferreira
* Cláudio de Andrade Lira
* Denys Guimarães Guenes Tavares
* Eduardo Breckenfeld da Rosa Borges
* Fabíola Gomes de Araújo
* Flávio Leonardo Cavalcanti Cordeiro
* Francisco do Nascimento Júnior
* Homero Sampaio Cavalcanti
* Ivan Sérgio da Silva Júnior
* José Edmar de Siqueira
* José Thiago Tenório Lopes
* Kássia Regina Silvestre de Albuquerque
* Leonardo Luiz Vieira da Silva
* Márcio Roberto Batista da Silva
* Maria de Fátima Sampaio Leite
* Micaela Maria Coelho de Araújo
* Nelson Mendonça de Carvalho
* Newton Morais e Silva
* Pedro Alexandre Santos da Silva Filho
* Rafael Corrêa Lima e Silva
* Rafael Francisco Pinto
* Rafael Koury Monteiro
* Rafael Palermo de Araújo
* Raphael Veras Rossiter
* Roberto Sobreira Barbalho
* Rodrigo Avellar Silveira
* Rosana Carvalho Barbosa
* Sávio Luiz de Andrade Cavalcante
* Tai Mu Shih
* Thiago Augusto Souza do Nascimento
* Tiago Moreno Rodrigues
* Vivianne Barbosa Sousa
*
* Este programa é software livre; você pode redistribuí-lo e/ou
* modificá-lo sob os termos de Licença Pública Geral GNU, conforme
* publicada pela Free Software Foundation; versão 2 da
* Licença.
* Este programa é distribuído na expectativa de ser útil, mas SEM
* QUALQUER GARANTIA; sem mesmo a garantia implícita de
* COMERCIALIZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM
* PARTICULAR. Consulte a Licença Pública Geral GNU para obter mais
* detalhes.
* Você deve ter recebido uma cópia da Licença Pública Geral GNU
* junto com este programa; se não, escreva para Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA.
*/
package gcom.gui.cadastro.localidade;
import gcom.cadastro.localidade.FiltroLocalidade;
import gcom.cadastro.localidade.FiltroQuadra;
import gcom.cadastro.localidade.FiltroSetorComercial;
import gcom.cadastro.localidade.Localidade;
import gcom.cadastro.localidade.SetorComercial;
import gcom.fachada.Fachada;
import gcom.gui.ActionServletException;
import gcom.gui.GcomAction;
import gcom.util.ConstantesSistema;
import gcom.util.Util;
import gcom.util.filtro.ParametroSimples;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* Descrição da classe
*
* @author Administrador
* @date 08/07/2006
*/
public class FiltrarQuadraAction extends GcomAction {
/**
* <Breve descrição sobre o caso de uso>
*
* <Identificador e nome do caso de uso>
*
* <Breve descrição sobre o subfluxo>
*
* <Identificador e nome do subfluxo>
*
* <Breve descrição sobre o fluxo secundário>
*
* <Identificador e nome do fluxo secundário>
*
* @author Administrador
* @date 08/07/2006
*
* @param actionMapping
* @param actionForm
* @param httpServletRequest
* @param httpServletResponse
* @return
*/
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionForward retorno = actionMapping
.findForward("retornarFiltroQuadra");
Fachada fachada = Fachada.getInstancia();
HttpSession sessao = httpServletRequest.getSession(false);
FiltrarQuadraActionForm filtrarQuadraActionForm = (FiltrarQuadraActionForm) actionForm;
FiltroQuadra filtroQuadra = new FiltroQuadra(FiltroQuadra.ID_LOCALIDADE);
// Objetos que serão retornados pelo hibernate.
filtroQuadra
.adicionarCaminhoParaCarregamentoEntidade("setorComercial.localidade");
String localidadeID = filtrarQuadraActionForm.getLocalidadeID();
String setorComercialCD = filtrarQuadraActionForm.getSetorComercialCD();
String quadraNM = filtrarQuadraActionForm.getQuadraNM();
//String bairroNome = filtrarQuadraActionForm.getBairroNome();
String idRota = filtrarQuadraActionForm.getIdRota();
String indicadorUso = filtrarQuadraActionForm.getIndicadorUso();
//String tipoPesquisa = filtrarQuadraActionForm.getTipoPesquisa();
// 1 check --- null uncheck
String indicadorAtualizar = httpServletRequest
.getParameter("indicadorAtualizar");
boolean peloMenosUmParametroInformado = false;
if (localidadeID != null && !localidadeID.equalsIgnoreCase("")) {
pesquisarLocalidade(filtrarQuadraActionForm,fachada,localidadeID);
peloMenosUmParametroInformado = true;
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.ID_LOCALIDADE, new Integer(localidadeID)));
}
if (setorComercialCD != null && !setorComercialCD.equalsIgnoreCase("")) {
pesquisarSetorComercial(filtrarQuadraActionForm,fachada,setorComercialCD,localidadeID);
peloMenosUmParametroInformado = true;
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.CODIGO_SETORCOMERCIAL, new Integer(setorComercialCD)));
}
if (quadraNM != null && !quadraNM.equalsIgnoreCase("")) {
peloMenosUmParametroInformado = true;
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.NUMERO_QUADRA, new Integer(quadraNM)));
}
if (idRota != null && !idRota.equalsIgnoreCase("")) {
peloMenosUmParametroInformado = true;
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.ROTA_ID, new Integer(idRota)));
}
/*
if (bairroNome != null && !bairroNome.equalsIgnoreCase("")) {
peloMenosUmParametroInformado = true;
if (tipoPesquisa != null
&& tipoPesquisa
.equals(ConstantesSistema.TIPO_PESQUISA_COMPLETA
.toString())) {
filtroQuadra.adicionarParametro(new ComparacaoTextoCompleto(
FiltroQuadra.NOME_BAIRRO, bairroNome));
} else {
filtroQuadra.adicionarParametro(new ComparacaoTexto(
FiltroQuadra.NOME_BAIRRO, bairroNome));
}
}
*/
if (indicadorUso != null && !indicadorUso.equalsIgnoreCase("")
&& !indicadorUso.equalsIgnoreCase("3")) {
peloMenosUmParametroInformado = true;
if (indicadorUso.equalsIgnoreCase(String
.valueOf(ConstantesSistema.INDICADOR_USO_ATIVO))) {
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.INDICADORUSO,
ConstantesSistema.INDICADOR_USO_ATIVO));
} else {
filtroQuadra.adicionarParametro(new ParametroSimples(
FiltroQuadra.INDICADORUSO,
ConstantesSistema.INDICADOR_USO_DESATIVO));
}
}
// Erro caso o usuário mandou filtrar sem nenhum parâmetro
if (!peloMenosUmParametroInformado) {
throw new ActionServletException(
"atencao.filtro.nenhum_parametro_informado");
}
filtroQuadra.setCampoOrderBy(FiltroQuadra.NUMERO_QUADRA,
FiltroQuadra.DESCRICAO_LOCALIDADE);
sessao.setAttribute("filtroQuadra", filtroQuadra);
sessao.setAttribute("indicadorAtualizar", indicadorAtualizar);
// devolve o mapeamento de retorno
return retorno;
}
private void pesquisarLocalidade(
FiltrarQuadraActionForm filtrarQuadraActionForm,
Fachada fachada, String localidadeID) {
Collection colecaoPesquisa;
FiltroLocalidade filtroLocalidade = new FiltroLocalidade();
filtroLocalidade.adicionarParametro(new ParametroSimples(
FiltroLocalidade.ID, localidadeID));
//Retorna localidade
colecaoPesquisa = fachada.pesquisar(filtroLocalidade,
Localidade.class.getName());
if (colecaoPesquisa == null || colecaoPesquisa.isEmpty()) {
//Localidade nao encontrada
//Limpa o campo localidadeID do formulário
filtrarQuadraActionForm.setLocalidadeID("");
filtrarQuadraActionForm
.setLocalidadeNome("Localidade inexistente.");
throw new ActionServletException("atencao.pesquisa_inexistente",
null,"Localidade");
}else {
Localidade objetoLocalidade = (Localidade) Util
.retonarObjetoDeColecao(colecaoPesquisa);
filtrarQuadraActionForm.setLocalidadeID(String
.valueOf(objetoLocalidade.getId()));
filtrarQuadraActionForm
.setLocalidadeNome(objetoLocalidade.getDescricao());
}
}
private void pesquisarSetorComercial(
FiltrarQuadraActionForm filtrarQuadraActionForm,
Fachada fachada,String setorComercialCD,String localidadeID) {
Collection colecaoPesquisa;
if (localidadeID == null || localidadeID.trim().equalsIgnoreCase("")) {
//Limpa os campos setorComercialCD e setorComercialID do formulario
filtrarQuadraActionForm.setSetorComercialCD("");
filtrarQuadraActionForm.setSetorComercialID("");
filtrarQuadraActionForm
.setSetorComercialNome("Informe Localidade.");
throw new ActionServletException("atencao.campo_selecionado.obrigatorio",
null,"Localidade");
} else {
FiltroSetorComercial filtroSetorComercial = new FiltroSetorComercial();
filtroSetorComercial.adicionarParametro(new ParametroSimples(
FiltroSetorComercial.ID_LOCALIDADE, localidadeID));
filtroSetorComercial.adicionarParametro(new ParametroSimples(
FiltroSetorComercial.CODIGO_SETOR_COMERCIAL,
setorComercialCD));
//Retorna setorComercial
colecaoPesquisa = fachada.pesquisar(filtroSetorComercial,
SetorComercial.class.getName());
if (colecaoPesquisa == null || colecaoPesquisa.isEmpty()) {
//setorComercial nao encontrado
//Limpa os campos setorComercialCD e setorComercialID do
// formulario
filtrarQuadraActionForm.setSetorComercialCD("");
filtrarQuadraActionForm.setSetorComercialID("");
filtrarQuadraActionForm
.setSetorComercialNome("Setor comercial inexistente.");
throw new ActionServletException("atencao.setor_comercial_nao_existe");
} else {
SetorComercial objetoSetorComercial = (SetorComercial) Util
.retonarObjetoDeColecao(colecaoPesquisa);
filtrarQuadraActionForm.setSetorComercialCD(String
.valueOf(objetoSetorComercial.getCodigo()));
filtrarQuadraActionForm.setSetorComercialID(String
.valueOf(objetoSetorComercial.getId()));
filtrarQuadraActionForm
.setSetorComercialNome(objetoSetorComercial
.getDescricao());
}
}
}
}
| [
"felipesantos2089@gmail.com"
] | felipesantos2089@gmail.com |
86d606b2f287b53d0d49a4674a881eecab36855b | d5361b4459774029ad5b4d5db2173a9517bad281 | /src/main/com/faveset/mahttpd/RequestHeaderHandler.java | 2447ed70c7fc459436a54b5f2800ee8e71c3894f | [] | no_license | kevinko/mahttp | 149d4ebefe9ba5847ab2467ee64cb7492735bb95 | ca53520d0947481eaf45ff65a90c9697c9a5522d | refs/heads/master | 2016-09-06T19:56:37.722834 | 2015-01-18T05:26:31 | 2015-01-18T05:26:31 | 29,323,538 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,232 | java | // Copyright 2014, Kevin Ko <kevin@faveset.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package com.faveset.mahttpd;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
class RequestHeaderHandler implements StateHandler {
/**
* Handles a continuation line.
*
* @param lineBuf the current line buffer.
* @param lastHeaderName the name of the last processed header.
* @param builder the HeadersBuilder to update.
*
* @throws InvalidRequestException will be thrown if an invalid
* continuation is detected.
*/
private static void handleContinuation(ByteBuffer lineBuf,
String lastHeaderName, HeadersBuilder builder) throws InvalidRequestException {
if (lastHeaderName.isEmpty()) {
throw new InvalidRequestException("Invalid request header continuation", HttpStatus.BAD_REQUEST);
}
String addedValue = parseHeaderValue(lineBuf);
// Append to the last added header value.
builder.appendValue(lastHeaderName, addedValue);
}
/**
* Parses a set of request headers from buf and populates req.
* state's LastHeaderName will be updated as each header is parsed.
*
* @param conn is not used
*
* @return false if more data is needed for reading into buf. True if
* ALL header parsing is complete; a state transition should occur in
* this case.
*
* @throws InvalidRequestException on bad request.
*/
@Override
public boolean handleState(AsyncConnection conn, ByteBuffer buf, HandlerState state) throws InvalidRequestException {
HttpRequestBuilder req = state.getRequestBuilder();
do {
if (Strings.hasLeadingCrlf(buf)) {
// We found the lone CRLF. We're done with this state.
return true;
}
ByteBuffer lineBuf;
try {
lineBuf = Strings.parseLine(buf);
} catch (BufferOverflowException e) {
throw new InvalidRequestException("Request-Line exceeded buffer", HttpStatus.REQUEST_URI_TOO_LONG);
}
if (lineBuf == null) {
// We need more data. buf was compacted by parseLine.
return false;
}
if (Strings.hasLeadingSpace(lineBuf)) {
handleContinuation(lineBuf, state.getLastHeaderName(), req.getHeadersBuilder());
continue;
}
try {
// This updates mLastHeaderName.
parseHeaderLine(lineBuf, state);
} catch (ParseException e) {
throw new InvalidRequestException("could not parse header line", HttpStatus.BAD_REQUEST);
}
} while (true);
}
/**
* Parses a request header from buf and places the contents in req.
*
* This updates state's LastHeaderName on success.
*
* @param lineBuf will be interpreted as a complete line and is typically
* provided via parseLine.
* @throws ParseException if the header is malformed.
*/
private static void parseHeaderLine(ByteBuffer lineBuf, HandlerState state) throws ParseException {
HttpRequestBuilder req = state.getRequestBuilder();
String fieldName = Strings.parseToken(lineBuf);
if (fieldName.length() == 0 || !lineBuf.hasRemaining()) {
throw new ParseException("Could not parse header name");
}
char ch = (char) lineBuf.get();
if (ch != ':') {
throw new ParseException("Could not parse header separator");
}
String v = parseHeaderValue(lineBuf);
req.getHeadersBuilder().add(fieldName, v);
state.setLastHeaderName(fieldName);
}
/**
* @param valueBuf must be positioned at the start of the header value.
* Any preceding whitespace will be skipped.
*
* @return a String containing the trimmed value.
*/
private static String parseHeaderValue(ByteBuffer valueBuf) {
Strings.skipWhitespace(valueBuf);
return Strings.parseText(valueBuf);
}
}
| [
"kevin.s.ko@gmail.com"
] | kevin.s.ko@gmail.com |
33a285a8eaf6ab6ead6ec86eaa4e5a9dedbeed25 | afb4cf30e328c78efc7adad573a4e4a1870754b6 | /High School/Classes/Computer Science 1/src/Triforce.java | 28543469efa52404b4813bf7c6e449fb4a993541 | [
"Apache-2.0"
] | permissive | mmcclain117/School-Code | 5c404aaa9b95df136ba382dff79cb7d44e56b4bc | aa9c501d42fc51fa9a66f53c65b875408a40ea0c | refs/heads/main | 2023-01-21T00:27:18.669866 | 2020-11-29T21:32:52 | 2020-11-29T21:32:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,067 | java |
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import static java.lang.Math.random;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author Master
*/
class Tri extends JPanel {
@Override
public void paintComponent(Graphics g) {
int x = 100;
int y = 50;
for (int i = 0; i <= 10; i++) {
for (int ii = 0; ii <= 10; ii++) {
g.setColor(Color.blue);
fillTriforce(g, x, y);
x += 125;
y += 0;
}
x = 0;
y += 100;
}
}
private Color randomColor() {
int r = (int) (random() * 256);
int G = (int) (random() * 256);
int b = (int) (random() * 256);
return new Color(r, G, b);
}
private void fillTriforce(Graphics g, int x, int y) {
int xPoints[] = {x + 0, x + 25, x + 0, x + 25, x - 50, x + 0, x - 100};
int yPoints[] = {y + 0, y + 100, y + 100, y + 50, y + 50, y + 100, y + 100};
g.fillPolygon(xPoints, yPoints, xPoints.length);
}
}
/**
* ************************************************************
* The code below is needed to create the Graphics window. You should not modify
* or delete any of the code.
* ***********************************************************
*/
public class Triforce {
public static void main(String[] args) {
//This is a necessary in order to create the frame window
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
start();
}
});
}
public static void start() {
//Sets up the frame
JFrame frame = new JFrame("Graphics");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Adds the graphics panel and sets the size
frame.setSize(new Dimension(800, 600));
frame.getContentPane().add(new Tri(), BorderLayout.CENTER);
frame.setVisible(true);
}
}
| [
"codingmace@gmail.com"
] | codingmace@gmail.com |
7834daf9f49e7bfe64b29165cbaa62e094367b47 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_6fe3c45cedb1184396981920a84924dbc6e46c88/RoutingHelper/8_6fe3c45cedb1184396981920a84924dbc6e46c88_RoutingHelper_s.java | 9203745af1ab757f5363b24f14d9f0295a9e9dc3 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 23,193 | java | package net.osmand.plus.routing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.LogUtil;
import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.plus.routing.RouteProvider.RouteCalculationResult;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.voice.CommandPlayer;
import android.content.Context;
import android.location.Location;
import android.os.Handler;
import android.util.FloatMath;
import android.widget.Toast;
public class RoutingHelper {
private static final org.apache.commons.logging.Log log = LogUtil.getLog(RoutingHelper.class);
public static interface IRouteInformationListener {
public void newRouteIsCalculated(boolean updateRoute);
public void routeWasCancelled();
}
private final double DISTANCE_TO_USE_OSMAND_ROUTER = 20000;
private List<IRouteInformationListener> listeners = new ArrayList<IRouteInformationListener>();
private Context context;
private boolean isFollowingMode = false;
private GPXRouteParams currentGPXRoute = null;
// instead of this properties RouteCalculationResult could be used
private List<Location> routeNodes = new ArrayList<Location>();
private List<RouteDirectionInfo> directionInfo = null;
private int[] listDistance = null;
// Note always currentRoute > get(currentDirectionInfo).routeOffset,
// but currentRoute <= get(currentDirectionInfo+1).routeOffset
protected int currentDirectionInfo = 0;
protected int currentRoute = 0;
private LatLon finalLocation;
private Location lastFixedLocation;
private Thread currentRunningJob;
private long lastTimeEvaluatedRoute = 0;
private int evalWaitInterval = 3000;
private ApplicationMode mode;
private OsmandSettings settings;
private RouteProvider provider = new RouteProvider();
private VoiceRouter voiceRouter;
private Handler uiHandler;
public RoutingHelper(OsmandSettings settings, Context context, CommandPlayer player){
this.settings = settings;
this.context = context;
voiceRouter = new VoiceRouter(this, player);
uiHandler = new Handler();
}
public boolean isFollowingMode() {
return isFollowingMode;
}
public void setFollowingMode(boolean isFollowingMode) {
this.isFollowingMode = isFollowingMode;
}
public void setFinalAndCurrentLocation(LatLon finalLocation, Location currentLocation){
setFinalAndCurrentLocation(finalLocation, currentLocation, null);
}
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, Location currentLocation, GPXRouteParams gpxRoute){
clearCurrentRoute(finalLocation);
currentGPXRoute = gpxRoute;
// to update route
setCurrentLocation(currentLocation);
}
public void clearCurrentRoute(LatLon newFinalLocation) {
this.routeNodes.clear();
listDistance = null;
directionInfo = null;
evalWaitInterval = 3000;
uiHandler.post(new Runnable() {
@Override
public void run() {
for (IRouteInformationListener l : listeners) {
l.routeWasCancelled();
}
}
});
this.finalLocation = newFinalLocation;
if (newFinalLocation == null) {
settings.FOLLOW_THE_ROUTE.set(false);
settings.FOLLOW_THE_GPX_ROUTE.set(null);
// clear last fixed location
this.lastFixedLocation = null;
this.isFollowingMode = false;
}
}
public GPXRouteParams getCurrentGPXRoute() {
return currentGPXRoute;
}
public List<Location> getCurrentRoute() {
return currentGPXRoute == null || currentGPXRoute.points.isEmpty() ? Collections
.unmodifiableList(routeNodes) : Collections
.unmodifiableList(currentGPXRoute.points);
}
public void setAppMode(ApplicationMode mode){
this.mode = mode;
voiceRouter.updateAppMode();
}
public ApplicationMode getAppMode() {
return mode;
}
public LatLon getFinalLocation() {
return finalLocation;
}
public boolean isRouterEnabled(){
return finalLocation != null && lastFixedLocation != null;
}
public boolean isRouteCalculated(){
return !routeNodes.isEmpty();
}
public VoiceRouter getVoiceRouter() {
return voiceRouter;
}
public boolean finishAtLocation(Location currentLocation) {
Location lastPoint = routeNodes.get(routeNodes.size() - 1);
if(currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < 60){
if(lastFixedLocation != null && lastFixedLocation.distanceTo(lastPoint) < 60){
showMessage(context.getString(R.string.arrived_at_destination));
voiceRouter.arrivedDestinationPoint();
clearCurrentRoute(null);
}
lastFixedLocation = currentLocation;
return true;
}
return false;
}
public Location getCurrentLocation() {
return lastFixedLocation;
}
private void updateCurrentRoute(int currentRoute){
this.currentRoute = currentRoute;
if(directionInfo != null){
while(currentDirectionInfo < directionInfo.size() - 1 &&
directionInfo.get(currentDirectionInfo + 1).routePointOffset < currentRoute){
currentDirectionInfo ++;
}
}
}
public void addListener(IRouteInformationListener l){
listeners.add(l);
}
public boolean removeListener(IRouteInformationListener l){
return listeners.remove(l);
}
public void setCurrentLocation(Location currentLocation) {
if(finalLocation == null || currentLocation == null){
return;
}
boolean calculateRoute = false;
synchronized (this) {
if(routeNodes.isEmpty() || routeNodes.size() <= currentRoute){
calculateRoute = true;
} else {
// Check whether user follow by route in correct direction
// 1. try to mark passed route (move forward)
float dist = currentLocation.distanceTo(routeNodes.get(currentRoute));
while(currentRoute + 1 < routeNodes.size()){
float newDist = currentLocation.distanceTo(routeNodes.get(currentRoute + 1));
boolean proccesed = false;
if (newDist < dist){
if(newDist > 150){
// may be that check is really not needed ? only for start position
if(currentRoute > 0 ){
// check that we are not far from the route (if we are on the route distance doesn't matter)
float bearing = routeNodes.get(currentRoute - 1).bearingTo(routeNodes.get(currentRoute));
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute));
float d = Math.abs(currentLocation.distanceTo(routeNodes.get(currentRoute)) * FloatMath.sin((bearingMovement - bearing)*3.14f/180f));
if(d > 50){
proccesed = true;
}
} else {
proccesed = true;
}
if(proccesed && log.isDebugEnabled()){
log.debug("Processed distance : " + newDist + " " + dist); //$NON-NLS-1$//$NON-NLS-2$
}
} else {
// case if you are getting close to the next point after turn
// but you haven't turned before (could be checked bearing)
if(currentLocation.hasBearing() || lastFixedLocation != null){
float bearingToPoint = currentLocation.bearingTo(routeNodes.get(currentRoute));
float bearingBetweenPoints = routeNodes.get(currentRoute).bearingTo(routeNodes.get(currentRoute+1));
float bearing = currentLocation.hasBearing() ? currentLocation.getBearing() : lastFixedLocation.bearingTo(currentLocation);
if(Math.abs(bearing - bearingToPoint) >
Math.abs(bearing - bearingBetweenPoints)){
if(log.isDebugEnabled()){
log.debug("Processed point bearing : " + Math.abs(currentLocation.getBearing() - bearingToPoint) + " " //$NON-NLS-1$ //$NON-NLS-2$
+ Math.abs(currentLocation.getBearing() - bearingBetweenPoints));
}
proccesed = true;
}
}
}
}
if(proccesed){
// that node already passed
updateCurrentRoute(currentRoute + 1);
dist = newDist;
} else {
break;
}
}
// 2. check if destination found
if(finishAtLocation(currentLocation)){
return;
}
// 3. check if closest location already passed
if(currentRoute + 1 < routeNodes.size()){
float bearing = routeNodes.get(currentRoute).bearingTo(routeNodes.get(currentRoute + 1));
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute));
// only 35 degrees for that case because it wrong catches sharp turns
if(Math.abs(bearing - bearingMovement) > 140 && Math.abs(bearing - bearingMovement) < 220){
if(log.isDebugEnabled()){
log.debug("Processed point movement bearing : "+bearingMovement +" bearing " + bearing); //$NON-NLS-1$ //$NON-NLS-2$
}
updateCurrentRoute(currentRoute + 1);
}
}
// 3.5 check that we already pass very sharp turn by missing one point (so our turn is sharper than expected)
// instead of that rule possible could be introduced another if the dist < 5m mark the location as already passed
if(currentRoute + 2 < routeNodes.size()){
float bearing = routeNodes.get(currentRoute + 1).bearingTo(routeNodes.get(currentRoute + 2));
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute + 1));
// only 15 degrees for that case because it wrong catches sharp turns
if(Math.abs(bearing - bearingMovement) > 165 && Math.abs(bearing - bearingMovement) < 195){
if(log.isDebugEnabled()){
log.debug("Processed point movement bearing 2 : "+bearingMovement +" bearing " + bearing); //$NON-NLS-1$ //$NON-NLS-2$
}
updateCurrentRoute(currentRoute + 2);
}
}
// 4. evaluate distance to the route and reevaluate if needed
if(currentRoute > 0){
float bearing = routeNodes.get(currentRoute - 1).bearingTo(routeNodes.get(currentRoute));
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute));
float d = Math.abs(currentLocation.distanceTo(routeNodes.get(currentRoute)) * FloatMath.sin((bearingMovement - bearing)*3.14f/180f));
if(d > 50) {
log.info("Recalculate route, because correlation : " + d); //$NON-NLS-1$
calculateRoute = true;
}
}
// 5. also check bearing by summing distance
if(!calculateRoute){
float d = currentLocation.distanceTo(routeNodes.get(currentRoute));
if (d > 80) {
if (currentRoute > 0) {
// possibly that case is not needed (often it is covered by 4.)
float f1 = currentLocation.distanceTo(routeNodes.get(currentRoute - 1)) + d;
float c = routeNodes.get(currentRoute - 1).distanceTo(routeNodes.get(currentRoute));
if (c * 2 < d + f1) {
log.info("Recalculate route, because too far from points : " + d + " " + f1 + " >> " + c); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
calculateRoute = true;
}
} else {
// that case is needed
log.info("Recalculate route, because too far from start : " + d); //$NON-NLS-1$
calculateRoute = true;
}
}
}
// 5. Also bearing could be checked (is it same direction)
// float bearing;
// if(currentLocation.hasBearing()){
// bearing = currentLocation.getBearing();
// } else if(lastFixedLocation != null){
// bearing = lastFixedLocation.bearingTo(currentLocation);
// }
// bearingRoute = currentLocation.bearingTo(routeNodes.get(currentRoute));
// if (Math.abs(bearing - bearingRoute) > 60f && 360 - Math.abs(bearing - bearingRoute) > 60f) {
// something wrong however it could be starting movement
// }
}
}
voiceRouter.updateStatus(currentLocation);
lastFixedLocation = currentLocation;
if(calculateRoute){
recalculateRouteInBackground(lastFixedLocation, finalLocation, currentGPXRoute);
}
}
private synchronized void setNewRoute(RouteCalculationResult res){
final boolean updateRoute = !routeNodes.isEmpty();
routeNodes = res.getLocations();
directionInfo = res.getDirections();
listDistance = res.getListDistance();
currentDirectionInfo = 0;
currentRoute = 0;
if(isFollowingMode){
voiceRouter.newRouteIsCalculated(updateRoute);
}
uiHandler.post(new Runnable() {
@Override
public void run() {
for (IRouteInformationListener l : listeners) {
l.newRouteIsCalculated(updateRoute);
}
}
});
}
public synchronized int getLeftDistance(){
if(listDistance != null && currentRoute < listDistance.length){
int dist = listDistance[currentRoute];
Location l = routeNodes.get(currentRoute);
if(lastFixedLocation != null){
dist += lastFixedLocation.distanceTo(l);
}
return dist;
}
return 0;
}
public String getGeneralRouteInformation(){
int dist = getLeftDistance();
int hours = getLeftTime() / (60 * 60);
int minutes = (getLeftTime() / 60) % 60;
return context.getString(R.string.route_general_information, OsmAndFormatter.getFormattedDistance(dist, context),
hours, minutes);
}
public Location getLocationFromRouteDirection(RouteDirectionInfo i){
if(i.routePointOffset < routeNodes.size()){
return routeNodes.get(i.routePointOffset);
}
return null;
}
public RouteDirectionInfo getNextRouteDirectionInfo(){
if(directionInfo != null && currentDirectionInfo < directionInfo.size() - 1){
return directionInfo.get(currentDirectionInfo + 1);
}
return null;
}
public RouteDirectionInfo getNextNextRouteDirectionInfo(){
if(directionInfo != null && currentDirectionInfo < directionInfo.size() - 2){
return directionInfo.get(currentDirectionInfo + 2);
}
return null;
}
public List<RouteDirectionInfo> getRouteDirections(){
if(directionInfo != null && currentDirectionInfo < directionInfo.size()){
if(currentDirectionInfo == 0){
return directionInfo;
}
if(currentDirectionInfo < directionInfo.size() - 1){
return directionInfo.subList(currentDirectionInfo + 1, directionInfo.size());
}
}
return Collections.emptyList();
}
public int getDistanceToNextRouteDirection() {
if (directionInfo != null && currentDirectionInfo < directionInfo.size()) {
int dist = listDistance[currentRoute];
if (currentDirectionInfo < directionInfo.size() - 1) {
dist -= listDistance[directionInfo.get(currentDirectionInfo + 1).routePointOffset];
}
if(lastFixedLocation != null){
dist += lastFixedLocation.distanceTo(routeNodes.get(currentRoute));
}
return dist;
}
return 0;
}
public synchronized int getLeftTime(){
if(directionInfo != null && currentDirectionInfo < directionInfo.size()){
int t = directionInfo.get(currentDirectionInfo).afterLeftTime;
int e = directionInfo.get(currentDirectionInfo).expectedTime;
if (e > 0) {
int passedDist = listDistance[directionInfo.get(currentDirectionInfo).routePointOffset] - listDistance[currentRoute];
int wholeDist = listDistance[directionInfo.get(currentDirectionInfo).routePointOffset];
if (currentDirectionInfo < directionInfo.size() - 1) {
wholeDist -= listDistance[directionInfo.get(currentDirectionInfo + 1).routePointOffset];
}
if (wholeDist > 0) {
t = (int) (t + ((float)e) * (1 - (float) passedDist / (float) wholeDist));
}
}
return t;
}
return 0;
}
private void recalculateRouteInBackground(final Location start, final LatLon end, final GPXRouteParams gpxRoute){
if (start == null || end == null) {
return;
}
// temporary check while osmand offline router is not stable
RouteService serviceToUse = settings.ROUTER_SERVICE.get();
if (serviceToUse == RouteService.OSMAND && !settings.USE_OSMAND_ROUTING_SERVICE_ALWAYS.get()) {
double distance = MapUtils.getDistance(end, start.getLatitude(), start.getLongitude());
if (distance > DISTANCE_TO_USE_OSMAND_ROUTER) {
showMessage(context.getString(R.string.osmand_routing_experimental), Toast.LENGTH_LONG);
serviceToUse = RouteService.CLOUDMADE;
}
}
final RouteService service = serviceToUse;
if(currentRunningJob == null){
// do not evaluate very often
if (System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
final boolean fastRouteMode = settings.FAST_ROUTE_MODE.get();
synchronized (this) {
currentRunningJob = new Thread(new Runnable() {
@Override
public void run() {
if(service != RouteService.OSMAND && !settings.isInternetConnectionAvailable()){
showMessage(context.getString(R.string.internet_connection_required_for_online_route), Toast.LENGTH_LONG);
}
RouteCalculationResult res = provider.calculateRouteImpl(start, end, mode, service, context, gpxRoute, fastRouteMode);
synchronized (RoutingHelper.this) {
if (res.isCalculated()) {
setNewRoute(res);
// reset error wait interval
evalWaitInterval = 3000;
} else {
evalWaitInterval = evalWaitInterval * 4 / 3;
if (evalWaitInterval > 120000) {
evalWaitInterval = 120000;
}
}
currentRunningJob = null;
}
if (res.isCalculated()) {
int[] dist = res.getListDistance();
int l = dist != null && dist.length > 0 ? dist[0] : 0;
showMessage(context.getString(R.string.new_route_calculated_dist)
+ " : " + OsmAndFormatter.getFormattedDistance(l, context)); //$NON-NLS-1$
} else {
if (res.getErrorMessage() != null) {
showMessage(context.getString(R.string.error_calculating_route) + " : " + res.getErrorMessage()); //$NON-NLS-1$
} else if (res.getLocations() == null) {
showMessage(context.getString(R.string.error_calculating_route_occured));
} else {
showMessage(context.getString(R.string.empty_route_calculated));
}
}
lastTimeEvaluatedRoute = System.currentTimeMillis();
}
}, "Calculating route"); //$NON-NLS-1$
currentRunningJob.start();
}
}
}
}
public boolean isRouteBeingCalculated(){
return currentRunningJob != null;
}
private void showMessage(final String msg, final int length) {
uiHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(context, msg, length).show();
}
});
}
private void showMessage(final String msg){
showMessage(msg, Toast.LENGTH_SHORT);
}
public boolean hasPointsToShow(){
return finalLocation != null && !routeNodes.isEmpty();
}
protected Context getContext() {
return context;
}
public synchronized void fillLocationsToShow(double topLatitude, double leftLongitude, double bottomLatitude,double rightLongitude, List<Location> l){
l.clear();
boolean previousVisible = false;
if(lastFixedLocation != null){
if(leftLongitude <= lastFixedLocation.getLongitude() && lastFixedLocation.getLongitude() <= rightLongitude &&
bottomLatitude <= lastFixedLocation.getLatitude() && lastFixedLocation.getLatitude() <= topLatitude){
l.add(lastFixedLocation);
previousVisible = true;
}
}
for (int i = currentRoute; i < routeNodes.size(); i++) {
Location ls = routeNodes.get(i);
if(leftLongitude <= ls.getLongitude() && ls.getLongitude() <= rightLongitude &&
bottomLatitude <= ls.getLatitude() && ls.getLatitude() <= topLatitude){
l.add(ls);
if (!previousVisible) {
if (i > currentRoute) {
l.add(0, routeNodes.get(i - 1));
} else if (lastFixedLocation != null) {
l.add(0, lastFixedLocation);
}
}
previousVisible = true;
} else if(previousVisible){
l.add(ls);
previousVisible = false;
// do not continue make method more efficient (because it calls in UI thread)
// this break also has logical sense !
break;
}
}
}
public GPXFile generateGPXFileWithRoute(){
return provider.createOsmandRouterGPX(currentRoute, routeNodes, currentDirectionInfo, directionInfo);
}
public static class TurnType {
public static final String C = "C"; // continue (go straight) //$NON-NLS-1$
public static final String TL = "TL"; // turn left //$NON-NLS-1$
public static final String TSLL = "TSLL"; // turn slight left //$NON-NLS-1$
public static final String TSHL = "TSHL"; // turn sharp left //$NON-NLS-1$
public static final String TR = "TR"; // turn right //$NON-NLS-1$
public static final String TSLR = "TSLR"; // turn slight right //$NON-NLS-1$
public static final String TSHR = "TSHR"; // turn sharp right //$NON-NLS-1$
public static final String TU = "TU"; // U-turn //$NON-NLS-1$
public static final String TRU = "TRU"; // Right U-turn //$NON-NLS-1$
public static String[] predefinedTypes = new String[] {C, TL, TSLL, TSHL, TR, TSLR, TSHR, TU, TRU};
public static TurnType valueOf(String s){
for(String v : predefinedTypes){
if(v.equals(s)){
return new TurnType(v);
}
}
if (s != null && s.startsWith("EXIT")) { //$NON-NLS-1$
return getExitTurn(Integer.parseInt(s.substring(4)), 0);
}
return null;
}
private final String value;
private int exitOut;
// calculated CW head rotation if previous direction to NORTH
private float turnAngle;
public static TurnType getExitTurn(int out, float angle){
TurnType r = new TurnType("EXIT", out); //$NON-NLS-1$
r.setTurnAngle(angle);
return r;
}
private TurnType(String value, int exitOut){
this.value = value;
this.exitOut = exitOut;
}
// calculated CW head rotation if previous direction to NORTH
public float getTurnAngle() {
return turnAngle;
}
public void setTurnAngle(float turnAngle) {
this.turnAngle = turnAngle;
}
private TurnType(String value){
this.value = value;
}
public String getValue() {
return value;
}
public int getExitOut() {
return exitOut;
}
public boolean isRoundAbout(){
return value.equals("EXIT"); //$NON-NLS-1$
}
}
public static class RouteDirectionInfo {
public String descriptionRoute = ""; //$NON-NLS-1$
// expected time after route point
public int expectedTime;
public TurnType turnType;
// location when you should action (turn or go ahead)
public int routePointOffset;
// TODO add from parser
public String ref;
public String streetName;
// speed limit in m/s (should be array of speed limits?)
public float speedLimit;
// calculated vars
// after action (excluding expectedTime)
public int afterLeftTime;
// distance after action (for i.e. after turn to next turn)
public int distance;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
0eec606e81f484b8d6953cb8e1a79fb6a06e9b57 | 7b336bab67fecee7d0450a05c6baa547594a13dc | /src/main/java/com/nogroup/municipality/manager/data/embedded/GCUType.java | 8593dffb2232fc6d3005741242ac9892febc42e6 | [] | no_license | mzarbi/munMan | 55e7911116192ef7ec791eae4f48830cd9d91ca0 | c562c2997df191c7caf145dad36c1a3a2c521ef1 | refs/heads/main | 2023-01-06T22:42:51.024901 | 2020-11-02T12:08:35 | 2020-11-02T12:08:35 | 309,355,078 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 102 | java | package com.nogroup.municipality.manager.data.embedded;
public enum GCUType {
ON_FOOT,
MOTORIZED
}
| [
"medzied.arbi@gmail.com"
] | medzied.arbi@gmail.com |
151c0a3c1bc4c877cd4d1b40f1e528f320f67573 | 85c5ff24d4452505843392ce6e14e919b19192b3 | /src/com/leqi/bean/RouteSharePicEntity.java | 6418819d5b035b41f538479fa00471872891f3fc | [] | no_license | hu-yulin/leqiWEB | b633d2036b6acfc9c7ea14d274566bb7717268bb | 8c12abe56b4a9783d2b65cdea35a6ab9ad171de4 | refs/heads/master | 2020-12-24T16:23:32.873607 | 2018-08-23T04:18:45 | 2018-08-23T04:18:45 | 76,779,080 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,218 | java | package com.leqi.bean;
/**
* Created by mbshqqb on 16-12-26.
*/
public class RouteSharePicEntity {
private int shareId;
private String path;
private int picId;
public int getShareId() {
return shareId;
}
public void setShareId(int shareId) {
this.shareId = shareId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public int getPicId() {
return picId;
}
public void setPicId(int picId) {
this.picId = picId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RouteSharePicEntity that = (RouteSharePicEntity) o;
if (shareId != that.shareId) return false;
if (picId != that.picId) return false;
if (path != null ? !path.equals(that.path) : that.path != null) return false;
return true;
}
@Override
public int hashCode() {
int result = shareId;
result = 31 * result + (path != null ? path.hashCode() : 0);
result = 31 * result + picId;
return result;
}
}
| [
"zhangjing1994"
] | zhangjing1994 |
567a5b9b2694dfc203e6372d18ba82555e3a6ce0 | e1adeab1077d0a7269184596ba870741ea16cab3 | /app/src/main/java/com/example/myapplication/fragments/PostsFragment.java | 7bdfd68639aaf7b3d4c9648d59555e485b300c88 | [
"Apache-2.0"
] | permissive | alejandroQu/MyApplication | 0e541b36fcd6cee8d8ee227347e77201a9ecc660 | b67bc9be893a4eae979952b9012a7cc17d236d68 | refs/heads/master | 2023-03-21T17:52:05.252226 | 2021-03-06T03:13:06 | 2021-03-06T03:13:06 | 342,067,769 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,537 | java | package com.example.myapplication.fragments;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.myapplication.Post;
import com.example.myapplication.PostsAdapter;
import com.example.myapplication.R;
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseQuery;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class PostsFragment extends Fragment {
public static final String TAG = "PostsFragment";
private RecyclerView rvPosts;
protected PostsAdapter adapter;
protected List<Post> allPosts;
public PostsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_posts, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
rvPosts = view.findViewById(R.id.rvPosts);
allPosts = new ArrayList<>();
adapter = new PostsAdapter(getContext(),allPosts);
rvPosts.setAdapter(adapter);
rvPosts.setLayoutManager(new LinearLayoutManager(getContext()));
queryPosts();
}
protected void queryPosts() {
ParseQuery<Post> query = ParseQuery.getQuery(Post.class);
query.include(Post.KEY_USER);
query.setLimit(20);
query.addDescendingOrder(Post.KEY_CREATED_KEY);
query.findInBackground(new FindCallback<Post>() {
@Override
public void done(List<Post> posts, ParseException e) {
if(e!= null){
Log.e(TAG,"Issue getting posts",e);
return;
}
for (Post post: posts){
Log.i(TAG, "Posts: "+ post.getDescription()+ ", username: "+ post.getUser().getUsername());
}
allPosts.addAll(posts);
adapter.notifyDataSetChanged();
}
});
}
} | [
"alejandro.quibrera@gmail.com"
] | alejandro.quibrera@gmail.com |
651be2878b284cfc30cca9096f3d67464e04c32d | 2071ffa2417d00976b0100e8c9cb852afe54bebe | /BYoj/src/t87/Main.java | cec6ff0f516c9221e282b54ff476d10fb1260a47 | [] | no_license | fanshui/ccodeOJ | 9133e08fb648e2b90de037db0b9e2023391e570f | 3cc660aa39be68945035c3c56989ddcf5f84e907 | refs/heads/master | 2021-01-19T09:35:17.593211 | 2018-04-28T08:30:48 | 2018-04-28T08:30:48 | 87,767,328 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,074 | java | package t87;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] output = new int[100];
int k =0;
String str = "";
Scanner in = new Scanner(System.in);
int cases = in.nextInt();
str = in.nextLine();
while(cases != 0){
str = in.nextLine();
//处理
String[] s = str.split(":");
// System.out.println(s[0]+" "+s[1] + " " + s[2]);
//变成int 来处理
int year = Integer.parseInt(s[0]);
int mon = Integer.parseInt(s[1]);
int day = Integer.parseInt(s[2]);
// System.out.println(year+" "+mon + " " + day);
boolean rn = isRN(year);
// output[k]=Dayth(mon,day,rn);
System.out.println(Dayth(mon,day,rn));
cases --;
k++;
}
in.close();
// for(int i = 0;i<k;i++){
// System.out.println(output[i]);
// }
}
private static boolean isRN(int year) {
if(year % 4 ==0 &&year % 100 != 0 || year % 400 ==0)
return true;
return false;
}
private static int Dayth(int month,int days,boolean isRN) {
int res=0;
if (month >2) {
if (isRN) {
switch (month) {
case 3:
res = 60 + days;
break;
case 4:
res = 91 + days;break;
case 5:
res = 121 + days;break;
case 6:
res = 152 + days;break;
case 7:
res = 182 + days;break;
case 8:
res = 213 + days;break;
case 9:
res = 244 + days;break;
case 10:
res = 274 + days;break;
case 11:
res = 305 + days;break;
case 12:
res = 335 + days;break;
default:
break;
}
} else {
switch (month) {
case 3:
res = 59 + days;break;
case 4:
res = 90 + days;break;
case 5:
res = 120 + days;break;
case 6:
res = 151 + days;break;
case 7:
res = 181 + days;break;
case 8:
res = 212 + days;break;
case 9:
res = 243 + days;break;
case 10:
res = 273 + days;break;
case 11:
res = 304 + days;break;
case 12:
res = 334 + days;break;
default:
break;
}
}
return res;
}
else if(month == 1){
return days;
}else {
return 31+days;
}
}
}
| [
"fh006007@163.com"
] | fh006007@163.com |
1173d2ac4d7db0a1d23bf1eb0f9298581c529511 | 438259d056b68daca72eb764990c76b2fe203528 | /app/src/main/java/com/example/adapterpractice/MainActivity.java | b3291d10a2fda1f7deaaf5036bb2df00b5b575b5 | [] | no_license | jinoochinoo/Clone_Android_ListView | 60ab1e092b0f89754938a65bcedbd057b7c17afe | 27a693dd30503b46d07f9c5384daa998651ff52f | refs/heads/master | 2023-03-20T20:10:07.448394 | 2021-03-03T13:39:29 | 2021-03-03T13:39:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,766 | java | package com.example.adapterpractice;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ArrayList<String> midList = new ArrayList<String>();
ListView list = findViewById(R.id.listView1);
// Context 위치, 디자인, Data jinwoo
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, midList);
list.setAdapter(adapter);
// 버튼, EditText 연결
final EditText edtItem = findViewById(R.id.edtItem);
Button btnAdd = findViewById(R.id.btnAdd);
btnAdd.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// 입력값 리스트 추가 --> 변화됐다고 notify
midList.add(edtItem.getText().toString());
adapter.notifyDataSetChanged();
}
});
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
midList.remove(position);
adapter.notifyDataSetChanged();
return false;
}
});
}
} | [
"73393147+jinoochinoo@users.noreply.github.com"
] | 73393147+jinoochinoo@users.noreply.github.com |
b55c3891707cc2e98582a4978761c49f8eb7ac2d | ddb5ab44b21bbade2877afbdd9f26b53ab37a64b | /test/src/main/java/org/sample/JMHBenchmark_06_SumCalcInvoke.java | 383bf58dd5fd2111a1f3b2dc38d7cf0956fd494d | [] | no_license | Java8Test/liberica-jdk-inliner-jmh-measurement | 446d7a04ce0a77718982b850aa641c597e1f0c85 | efea5efe261f783910c5b77f5c29eeb5a9bf2034 | refs/heads/main | 2022-12-25T14:09:31.843239 | 2020-10-08T07:07:52 | 2020-10-08T07:07:52 | 300,942,689 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,869 | java | /*
* Copyright (c) 2014, Oracle America, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Oracle 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 HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.sample;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Timeout;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.TimeUnit;
@Timeout(time = 1, timeUnit = TimeUnit.SECONDS)
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class JMHBenchmark_06_SumCalcInvoke {
static final long ITERATIONS = 100;
@Benchmark
public void baseline() {
// do nothing, this is a baseline
}
@Benchmark
public long noInvocationSumCalc() {
long sumValue = 0;
for (long i = 0; i < ITERATIONS; ++i)
sumValue += (i/3) + (i/2);;
return sumValue;
}
@Benchmark
public long SumCalcInvoke() {
long sumValue = 0;
for (long i = 0; i < ITERATIONS; ++i)
sumValue += _sumMethod(i);
return sumValue;
}
private long _sumMethod(long value) {
return (value/3) + (value/2);
}
} | [
"venia_k@mail.ru"
] | venia_k@mail.ru |
72894c55d52453464f0ea4fa7ed549f530aea08b | 74b47b895b2f739612371f871c7f940502e7165b | /aws-java-sdk-macie2/src/main/java/com/amazonaws/services/macie2/model/UserIdentity.java | a0511a10fce52e3fd39249cc637343fe59726aaf | [
"Apache-2.0"
] | permissive | baganda07/aws-sdk-java | fe1958ed679cd95b4c48f971393bf03eb5512799 | f19bdb30177106b5d6394223a40a382b87adf742 | refs/heads/master | 2022-11-09T21:55:43.857201 | 2022-10-24T21:08:19 | 2022-10-24T21:08:19 | 221,028,223 | 0 | 0 | Apache-2.0 | 2019-11-11T16:57:12 | 2019-11-11T16:57:11 | null | UTF-8 | Java | false | false | 18,912 | java | /*
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.macie2.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
* <p>
* Provides information about the type and other characteristics of an entity that performed an action on an affected
* resource.
* </p>
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/macie2-2020-01-01/UserIdentity" target="_top">AWS API
* Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class UserIdentity implements Serializable, Cloneable, StructuredPojo {
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the AssumeRole operation
* of the Security Token Service (STS) API, the identifiers, session context, and other details about the identity.
* </p>
*/
private AssumedRole assumedRole;
/**
* <p>
* If the action was performed using the credentials for another Amazon Web Services account, the details of that
* account.
* </p>
*/
private AwsAccount awsAccount;
/**
* <p>
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the name of
* the service.
* </p>
*/
private AwsService awsService;
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the GetFederationToken
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details about the
* identity.
* </p>
*/
private FederatedUser federatedUser;
/**
* <p>
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the name and
* other details about the user.
* </p>
*/
private IamUser iamUser;
/**
* <p>
* If the action was performed using the credentials for your Amazon Web Services account, the details of your
* account.
* </p>
*/
private UserIdentityRoot root;
/**
* <p>
* The type of entity that performed the action.
* </p>
*/
private String type;
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the AssumeRole operation
* of the Security Token Service (STS) API, the identifiers, session context, and other details about the identity.
* </p>
*
* @param assumedRole
* If the action was performed with temporary security credentials that were obtained using the AssumeRole
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details
* about the identity.
*/
public void setAssumedRole(AssumedRole assumedRole) {
this.assumedRole = assumedRole;
}
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the AssumeRole operation
* of the Security Token Service (STS) API, the identifiers, session context, and other details about the identity.
* </p>
*
* @return If the action was performed with temporary security credentials that were obtained using the AssumeRole
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details
* about the identity.
*/
public AssumedRole getAssumedRole() {
return this.assumedRole;
}
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the AssumeRole operation
* of the Security Token Service (STS) API, the identifiers, session context, and other details about the identity.
* </p>
*
* @param assumedRole
* If the action was performed with temporary security credentials that were obtained using the AssumeRole
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details
* about the identity.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withAssumedRole(AssumedRole assumedRole) {
setAssumedRole(assumedRole);
return this;
}
/**
* <p>
* If the action was performed using the credentials for another Amazon Web Services account, the details of that
* account.
* </p>
*
* @param awsAccount
* If the action was performed using the credentials for another Amazon Web Services account, the details of
* that account.
*/
public void setAwsAccount(AwsAccount awsAccount) {
this.awsAccount = awsAccount;
}
/**
* <p>
* If the action was performed using the credentials for another Amazon Web Services account, the details of that
* account.
* </p>
*
* @return If the action was performed using the credentials for another Amazon Web Services account, the details of
* that account.
*/
public AwsAccount getAwsAccount() {
return this.awsAccount;
}
/**
* <p>
* If the action was performed using the credentials for another Amazon Web Services account, the details of that
* account.
* </p>
*
* @param awsAccount
* If the action was performed using the credentials for another Amazon Web Services account, the details of
* that account.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withAwsAccount(AwsAccount awsAccount) {
setAwsAccount(awsAccount);
return this;
}
/**
* <p>
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the name of
* the service.
* </p>
*
* @param awsService
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the
* name of the service.
*/
public void setAwsService(AwsService awsService) {
this.awsService = awsService;
}
/**
* <p>
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the name of
* the service.
* </p>
*
* @return If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the
* name of the service.
*/
public AwsService getAwsService() {
return this.awsService;
}
/**
* <p>
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the name of
* the service.
* </p>
*
* @param awsService
* If the action was performed by an Amazon Web Services account that belongs to an Amazon Web Service, the
* name of the service.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withAwsService(AwsService awsService) {
setAwsService(awsService);
return this;
}
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the GetFederationToken
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details about the
* identity.
* </p>
*
* @param federatedUser
* If the action was performed with temporary security credentials that were obtained using the
* GetFederationToken operation of the Security Token Service (STS) API, the identifiers, session context,
* and other details about the identity.
*/
public void setFederatedUser(FederatedUser federatedUser) {
this.federatedUser = federatedUser;
}
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the GetFederationToken
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details about the
* identity.
* </p>
*
* @return If the action was performed with temporary security credentials that were obtained using the
* GetFederationToken operation of the Security Token Service (STS) API, the identifiers, session context,
* and other details about the identity.
*/
public FederatedUser getFederatedUser() {
return this.federatedUser;
}
/**
* <p>
* If the action was performed with temporary security credentials that were obtained using the GetFederationToken
* operation of the Security Token Service (STS) API, the identifiers, session context, and other details about the
* identity.
* </p>
*
* @param federatedUser
* If the action was performed with temporary security credentials that were obtained using the
* GetFederationToken operation of the Security Token Service (STS) API, the identifiers, session context,
* and other details about the identity.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withFederatedUser(FederatedUser federatedUser) {
setFederatedUser(federatedUser);
return this;
}
/**
* <p>
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the name and
* other details about the user.
* </p>
*
* @param iamUser
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the
* name and other details about the user.
*/
public void setIamUser(IamUser iamUser) {
this.iamUser = iamUser;
}
/**
* <p>
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the name and
* other details about the user.
* </p>
*
* @return If the action was performed using the credentials for an Identity and Access Management (IAM) user, the
* name and other details about the user.
*/
public IamUser getIamUser() {
return this.iamUser;
}
/**
* <p>
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the name and
* other details about the user.
* </p>
*
* @param iamUser
* If the action was performed using the credentials for an Identity and Access Management (IAM) user, the
* name and other details about the user.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withIamUser(IamUser iamUser) {
setIamUser(iamUser);
return this;
}
/**
* <p>
* If the action was performed using the credentials for your Amazon Web Services account, the details of your
* account.
* </p>
*
* @param root
* If the action was performed using the credentials for your Amazon Web Services account, the details of
* your account.
*/
public void setRoot(UserIdentityRoot root) {
this.root = root;
}
/**
* <p>
* If the action was performed using the credentials for your Amazon Web Services account, the details of your
* account.
* </p>
*
* @return If the action was performed using the credentials for your Amazon Web Services account, the details of
* your account.
*/
public UserIdentityRoot getRoot() {
return this.root;
}
/**
* <p>
* If the action was performed using the credentials for your Amazon Web Services account, the details of your
* account.
* </p>
*
* @param root
* If the action was performed using the credentials for your Amazon Web Services account, the details of
* your account.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public UserIdentity withRoot(UserIdentityRoot root) {
setRoot(root);
return this;
}
/**
* <p>
* The type of entity that performed the action.
* </p>
*
* @param type
* The type of entity that performed the action.
* @see UserIdentityType
*/
public void setType(String type) {
this.type = type;
}
/**
* <p>
* The type of entity that performed the action.
* </p>
*
* @return The type of entity that performed the action.
* @see UserIdentityType
*/
public String getType() {
return this.type;
}
/**
* <p>
* The type of entity that performed the action.
* </p>
*
* @param type
* The type of entity that performed the action.
* @return Returns a reference to this object so that method calls can be chained together.
* @see UserIdentityType
*/
public UserIdentity withType(String type) {
setType(type);
return this;
}
/**
* <p>
* The type of entity that performed the action.
* </p>
*
* @param type
* The type of entity that performed the action.
* @return Returns a reference to this object so that method calls can be chained together.
* @see UserIdentityType
*/
public UserIdentity withType(UserIdentityType type) {
this.type = type.toString();
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getAssumedRole() != null)
sb.append("AssumedRole: ").append(getAssumedRole()).append(",");
if (getAwsAccount() != null)
sb.append("AwsAccount: ").append(getAwsAccount()).append(",");
if (getAwsService() != null)
sb.append("AwsService: ").append(getAwsService()).append(",");
if (getFederatedUser() != null)
sb.append("FederatedUser: ").append(getFederatedUser()).append(",");
if (getIamUser() != null)
sb.append("IamUser: ").append(getIamUser()).append(",");
if (getRoot() != null)
sb.append("Root: ").append(getRoot()).append(",");
if (getType() != null)
sb.append("Type: ").append(getType());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof UserIdentity == false)
return false;
UserIdentity other = (UserIdentity) obj;
if (other.getAssumedRole() == null ^ this.getAssumedRole() == null)
return false;
if (other.getAssumedRole() != null && other.getAssumedRole().equals(this.getAssumedRole()) == false)
return false;
if (other.getAwsAccount() == null ^ this.getAwsAccount() == null)
return false;
if (other.getAwsAccount() != null && other.getAwsAccount().equals(this.getAwsAccount()) == false)
return false;
if (other.getAwsService() == null ^ this.getAwsService() == null)
return false;
if (other.getAwsService() != null && other.getAwsService().equals(this.getAwsService()) == false)
return false;
if (other.getFederatedUser() == null ^ this.getFederatedUser() == null)
return false;
if (other.getFederatedUser() != null && other.getFederatedUser().equals(this.getFederatedUser()) == false)
return false;
if (other.getIamUser() == null ^ this.getIamUser() == null)
return false;
if (other.getIamUser() != null && other.getIamUser().equals(this.getIamUser()) == false)
return false;
if (other.getRoot() == null ^ this.getRoot() == null)
return false;
if (other.getRoot() != null && other.getRoot().equals(this.getRoot()) == false)
return false;
if (other.getType() == null ^ this.getType() == null)
return false;
if (other.getType() != null && other.getType().equals(this.getType()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getAssumedRole() == null) ? 0 : getAssumedRole().hashCode());
hashCode = prime * hashCode + ((getAwsAccount() == null) ? 0 : getAwsAccount().hashCode());
hashCode = prime * hashCode + ((getAwsService() == null) ? 0 : getAwsService().hashCode());
hashCode = prime * hashCode + ((getFederatedUser() == null) ? 0 : getFederatedUser().hashCode());
hashCode = prime * hashCode + ((getIamUser() == null) ? 0 : getIamUser().hashCode());
hashCode = prime * hashCode + ((getRoot() == null) ? 0 : getRoot().hashCode());
hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode());
return hashCode;
}
@Override
public UserIdentity clone() {
try {
return (UserIdentity) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.macie2.model.transform.UserIdentityMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}
| [
""
] | |
da042280ec5582e5a5951fdf955cd922b3a23e79 | 1ebc6e33255d2cc2e3ad5b6df30d93a10a23fd79 | /src/main/java/julian/cames/patchs/services/uniparam/dto/MergeData.java | b3d7155b2784eecec5562c633f55d57484c89d15 | [] | no_license | juliancames/JulianCamesServer | 07b8051afc2997d1da9c46821c42413aa2674c23 | 777ae3634ef66c9c1099fc9192b91fae47a2352a | refs/heads/master | 2021-08-16T14:48:44.185227 | 2017-11-20T02:20:58 | 2017-11-20T02:20:58 | 104,829,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 565 | java | package julian.cames.patchs.services.uniparam.dto;
public class MergeData {
String srcData;
String toMergeData;
//mandatory constructor
public MergeData() {}
public MergeData(String srcData, String toMergeData) {
super();
this.srcData = srcData;
this.toMergeData = toMergeData;
}
public String getSrcData() {
return srcData;
}
public void setSrcData(String srcData) {
this.srcData = srcData;
}
public String getToMergeData() {
return toMergeData;
}
public void setToMergeData(String toMergeData) {
this.toMergeData = toMergeData;
}
}
| [
"juliancamespatchs@yahoo.com.co"
] | juliancamespatchs@yahoo.com.co |
1e23eebc80be97f0e4b81d22d5872c0bc3e8c8ac | 2bf3a8937dabadfd08071e45ee35c50e0c7aa864 | /study-codes/spring-aspect-study/src/main/java/beinet/cn/springaspectstudy/controller/DemoController.java | c9ab1b8b06b3832fa9bc4371ab19718f0a27d332 | [] | no_license | lzy-eng/study | 85ea3e09f7c0e8065947081d89ec3c40b86cf6d2 | 425c15091beaafb9736bb753e82e36bd49949126 | refs/heads/master | 2023-08-18T09:17:32.271168 | 2021-10-18T15:45:39 | 2021-10-18T15:45:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,349 | java | package beinet.cn.springaspectstudy.controller;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@RestController
public class DemoController {
@RequestMapping("")
public String index() {
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
return String.format("我是RequestMapping的GET:%s %s", now, this.getClass().getName());
}
@GetMapping("isGet")
public String isGet() {
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
return String.format("我是GetMapping:%s %s", now, this.getClass().getName());
}
@RequestMapping(value = "isPost", method = RequestMethod.POST)
public String isPost() {
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
return String.format("我是RequestMapping的POST:%s %s", now, this.getClass().getName());
}
@PostMapping(value = "isPost2")
public String isPost2() {
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
return String.format("我是PostMapping:%s %s", now, this.getClass().getName());
}
}
| [
"youbl@126.com"
] | youbl@126.com |
7ecf4bc101f3e1eb1c3cf127b0453605470b8f30 | f1a9b228188f685ece5aaf0b872a7174fda5d90a | /src/com/maycontainsoftware/partition/BackButton.java | 5c563831454596fdf54bba3883bdc29ec0197883 | [] | no_license | cfmdobbie/Partition | 08caf700450853f2fd827b09dabc94e9d413e024 | c0d3a4e187ea3904bc1c61b92a62fb19f07ba0bf | refs/heads/master | 2021-01-17T14:31:33.944778 | 2015-05-18T18:43:56 | 2015-05-18T18:44:24 | 27,093,637 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,250 | java | package com.maycontainsoftware.partition;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.maycontainsoftware.partition.CardStack.IStackChangeListener;
/**
* A button for navigating backwards in the card stack. This button listens to stackChanged events from the CardStack
* and automatically hides itself if there's only one card in the stack.
*
* @author Charlie
*/
class BackButton extends Button implements IStackChangeListener {
/** Tag for logging purposes. */
private static final String TAG = BackButton.class.getName();
/**
* Construct a new BackButton.
*
* @param game
* @param atlas
*/
public BackButton(final PartitionGame game, final TextureAtlas atlas) {
super(new TextureRegionDrawable(atlas.findRegion("back")));
}
@Override
public void stackChanged(int newSize) {
Gdx.app.debug(TAG, "stackChanged::newSize=" + newSize);
// If there's only one card in the stack, want to hide the back button.
// If there's more than one - want to show it.
if (newSize <= 1) {
this.setVisible(false);
} else {
this.setVisible(true);
}
}
}
| [
"cfmdobbie@gmail.com"
] | cfmdobbie@gmail.com |
1b3e7bca19e8fefcbf6448c8f09bb6ae8d5d77f0 | a14f30c17f986dd044819197ec55530e4f75e999 | /game-core/game-core-common/src/main/java/cn/fulugame/common/ResultStatus.java | 0e63d5081ec299f5c1ff33d8935e8a30d37c0e3e | [] | no_license | ancyshi/cmb-games | eddec15b9fe924541437374b1ae8856fc1b8bf8b | 29b2faeba511b8ce52122d032be3a280ee400c8a | refs/heads/master | 2020-04-14T20:19:35.694570 | 2019-01-07T03:04:12 | 2019-01-07T03:04:12 | 164,089,853 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 673 | java | package cn.fulugame.common;
/**
* Author: koabs
* 8/22/16.
* 返回结果状态
*/
public class ResultStatus {
//接口正常返回
public static Integer SUCCESS = 200;
//系统内部错误,需要前端捕获的
public static Integer ERROR = 500;
//用户未登陆
public static Integer NOLOGIN = 501;
public static Integer USER_BANNED = 504;
//没有formToken,不能提交表单
public static Integer DATAEXCPTION = 503;
//新用户待绑定
public static Integer NEWUSER = 201;
//无接口调用权限
public static Integer ACCESS_DENY = 403;
//版本太低
public static Integer VERSIONS_LOW = 600;
}
| [
"ancyshi@163.com"
] | ancyshi@163.com |
5bcb588ce07078491788aa21b0ccfa2fc968951a | 10ca82fb63db632c4000a75ef9abaef3cae65b41 | /study-zuul/src/main/java/com/my/study/filter/PreLogFilter.java | cfd0f04e0a777da0312e7c305df32d20e9aa7080 | [] | no_license | 15974219211/lyjStudy | 8185485ac9435857e60f51f4104aa17165e82c4e | 8ebe836adf0c75ea0317c89af26f80bddbc86aac | refs/heads/master | 2022-07-01T20:37:54.804977 | 2020-03-26T15:19:08 | 2020-03-26T15:19:08 | 247,299,884 | 0 | 0 | null | 2022-06-21T02:59:15 | 2020-03-14T15:15:47 | Java | UTF-8 | Java | false | false | 1,647 | java | package com.my.study.filter;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import javax.servlet.http.HttpServletRequest;
@Slf4j
//@Component
public class PreLogFilter extends ZuulFilter {
/*
* pre: 这种过滤器在请求被路由之前调用。可利用这种过滤器实现身份验证、在集群中选择请求的微服务,记录调试信息等。
routing: 这种过滤器将请求路由到微服务。这种过滤器用于构建发送给微服务的请求,并使用apache httpclient或netflix ribbon请求微服务。
post: 这种过滤器在路由到微服务以后执行。这种过滤器可用来为响应添加标准的http header、收集统计信息和指标、将响应从微服务发送给客户端等。
error: 在其他阶段发送错误时执行该过滤器。
*
* */
@Override
public String filterType() {
return FilterConstants.PRE_TYPE;
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
return RequestContext.getCurrentContext().sendZuulResponse();
}
@Override
public Object run() throws ZuulException {
RequestContext currentContext = RequestContext.getCurrentContext();
HttpServletRequest request = currentContext.getRequest();
log.info("zuul pre filter-->" + request.getRequestURL() + "-->" + request.getMethod());
return null;
}
}
| [
"lin.yinjian@trs.com.cn"
] | lin.yinjian@trs.com.cn |
d9cb8d1d51be35ee14584f7259068310e15f6dfe | fbe90bf959b5b48017285b083a2bbd878229d00c | /Area of a rectangle/Main.java | 8ad2fcf625a0066e1e91efc342051c9566899521 | [] | no_license | priyansh-0402/Playground | c52d3d7bb011b88541055bd614fefe56afae7aae | 8f1a8bb2a0b85a6eeb56036d69ecc67ebb2a4976 | refs/heads/master | 2020-06-05T02:06:41.932868 | 2019-06-18T09:37:07 | 2019-06-18T09:37:07 | 192,276,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 137 | java | #include<stdio.h>
int main()
{int a,b,c;
//Type your code here
scanf("%d",&a);
scanf("%d",&b);
c=a*b;
printf("%d",c);
return 0;
} | [
"51899070+priyansh-0402@users.noreply.github.com"
] | 51899070+priyansh-0402@users.noreply.github.com |
029fc60d25c3e71a0338f5c56d7898fe0837e3aa | 350af3e9678c7de0f692906e2ebf7fb8d2a3f67f | /src/main/Test.java | 0f0495444b3ffbd810d07bafefc355c23a82a7f5 | [] | no_license | zeroLJ/WxDemo | 7eec58c3cfff25d84c366266ace05728e164b972 | 18d3643e69a49f5bc52ff2271d151c217da13460 | refs/heads/master | 2020-03-28T10:30:02.364128 | 2018-09-10T07:16:40 | 2018-09-10T07:16:40 | 148,114,850 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 3,812 | java | package main;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import wxUtils.WxMessage;
import wxUtils.WxSolve;
/**
* 微信公众号后台处理
*/
@WebServlet("/Test")
public class Test extends HttpServlet {
private static final long serialVersionUID = 1L;
static String connectionUrl = "jdbc:sqlserver://localhost:1433;"
// "jdbc:sqlserver://192.168.0.188:1433;"
+ "databaseName=Demo;" + "user=940034240;" + "password=pp123456;";
/**
* @see HttpServlet#HttpServlet()
*/
public Test() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
Map<String, String> params = new HashMap<>();
Map<String, String[]> map = request.getParameterMap();
for (String key : map.keySet()) {
params.put(key, map.get(key)[0]);
}
String signature = params.get("signature");
String timestamp = params.get("timestamp");
String nonce = params.get("nonce");
String echostr = params.get("echostr");
String token = "token";
List<String> list = new ArrayList<>();
list.add(token);
list.add(timestamp);
list.add(nonce);
System.out.println("1111");
System.out.println("signature:"+signature);
System.out.println("timestamp:"+timestamp);
System.out.println("nonce:"+nonce);
System.out.println("echostr:"+echostr);
// String access_token=HttpRequest.sendGet("https://api.weixin.qq.com/cgi-bin/token", "grant_type=client_credential&appid=wx6f0a4417cb3850f4&secret=fab18c81b82699eb1fe288f8d68dc095");
// System.out.println("access_token" + access_token);
String result = "";
if (echostr!=null && echostr.length()>0) { //只有端口验证的时候有用
result = echostr;
System.out.println("xml2:" + "\n");
}else {
/** 读取接收到的xml消息 */
StringBuffer sb = new StringBuffer();
InputStream is = request.getInputStream();
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String s = "";
while ((s = br.readLine()) != null) {
sb.append(s);
}
String xml = sb.toString(); //次即为接收到微信端发送过来的xml数据
System.out.println("xml:"+xml + "\n");
WxMessage message = new WxMessage(xml);
message.print();
result = WxSolve.getResult(message);
// Document dom=DocumentHelper.parseText(xml);
// Element root=dom.getRootElement();
// String weighTime=root.element("weighTime").getText();
// String cardNum=root.element("cardNum").getText();
// String cfid=root.element("cfid").getText();
// System.out.println(weighTime);
// System.out.println(cardNum);
// System.out.println(cfid);
}
try {
OutputStream os = response.getOutputStream();
os.write(result.getBytes("UTF-8"));
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"940034240@qq.com"
] | 940034240@qq.com |
ded228911ba04dc6c1e7b188ef40ae0769a0d7fd | d85028f6a7c72c6e6daa1dd9c855d4720fc8b655 | /gnu/trove/impl/hash/TShortByteHash.java | eea8c988133c42521c37ac2a273c26cf3a48f0bb | [] | no_license | RavenLeaks/Aegis-src-cfr | 85fb34c2b9437adf1631b103f555baca6353e5d5 | 9815c07b0468cbba8d1efbfe7643351b36665115 | refs/heads/master | 2022-10-13T02:09:08.049217 | 2020-06-09T15:31:27 | 2020-06-09T15:31:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,227 | java | /*
* Decompiled with CFR <Could not determine version>.
*/
package gnu.trove.impl.hash;
import gnu.trove.impl.HashFunctions;
import gnu.trove.impl.hash.TPrimitiveHash;
import gnu.trove.procedure.TShortProcedure;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
public abstract class TShortByteHash
extends TPrimitiveHash {
static final long serialVersionUID = 1L;
public transient short[] _set;
protected short no_entry_key;
protected byte no_entry_value;
protected boolean consumeFreeSlot;
public TShortByteHash() {
this.no_entry_key = 0;
this.no_entry_value = 0;
}
public TShortByteHash(int initialCapacity) {
super((int)initialCapacity);
this.no_entry_key = 0;
this.no_entry_value = 0;
}
public TShortByteHash(int initialCapacity, float loadFactor) {
super((int)initialCapacity, (float)loadFactor);
this.no_entry_key = 0;
this.no_entry_value = 0;
}
public TShortByteHash(int initialCapacity, float loadFactor, short no_entry_key, byte no_entry_value) {
super((int)initialCapacity, (float)loadFactor);
this.no_entry_key = no_entry_key;
this.no_entry_value = no_entry_value;
}
public short getNoEntryKey() {
return this.no_entry_key;
}
public byte getNoEntryValue() {
return this.no_entry_value;
}
@Override
protected int setUp(int initialCapacity) {
int capacity = super.setUp((int)initialCapacity);
this._set = new short[capacity];
return capacity;
}
public boolean contains(short val) {
if (this.index((short)val) < 0) return false;
return true;
}
public boolean forEach(TShortProcedure procedure) {
byte[] states = this._states;
short[] set = this._set;
int i = set.length;
do {
if (i-- <= 0) return true;
} while (states[i] != 1 || procedure.execute((short)set[i]));
return false;
}
@Override
protected void removeAt(int index) {
this._set[index] = this.no_entry_key;
super.removeAt((int)index);
}
protected int index(short key) {
byte[] states = this._states;
short[] set = this._set;
int length = states.length;
int hash = HashFunctions.hash((int)key) & Integer.MAX_VALUE;
int index = hash % length;
byte state = states[index];
if (state == 0) {
return -1;
}
if (state != 1) return this.indexRehashed((short)key, (int)index, (int)hash, (byte)state);
if (set[index] != key) return this.indexRehashed((short)key, (int)index, (int)hash, (byte)state);
return index;
}
int indexRehashed(short key, int index, int hash, byte state) {
int length = this._set.length;
int probe = 1 + hash % (length - 2);
int loopIndex = index;
do {
if ((index -= probe) < 0) {
index += length;
}
if ((state = this._states[index]) == 0) {
return -1;
}
if (key != this._set[index] || state == 2) continue;
return index;
} while (index != loopIndex);
return -1;
}
protected int insertKey(short val) {
int hash = HashFunctions.hash((int)val) & Integer.MAX_VALUE;
int index = hash % this._states.length;
byte state = this._states[index];
this.consumeFreeSlot = false;
if (state == 0) {
this.consumeFreeSlot = true;
this.insertKeyAt((int)index, (short)val);
return index;
}
if (state != 1) return this.insertKeyRehash((short)val, (int)index, (int)hash, (byte)state);
if (this._set[index] != val) return this.insertKeyRehash((short)val, (int)index, (int)hash, (byte)state);
return -index - 1;
}
int insertKeyRehash(short val, int index, int hash, byte state) {
int length = this._set.length;
int probe = 1 + hash % (length - 2);
int loopIndex = index;
int firstRemoved = -1;
do {
if (state == 2 && firstRemoved == -1) {
firstRemoved = index;
}
if ((index -= probe) < 0) {
index += length;
}
if ((state = this._states[index]) == 0) {
if (firstRemoved != -1) {
this.insertKeyAt((int)firstRemoved, (short)val);
return firstRemoved;
}
this.consumeFreeSlot = true;
this.insertKeyAt((int)index, (short)val);
return index;
}
if (state != 1 || this._set[index] != val) continue;
return -index - 1;
} while (index != loopIndex);
if (firstRemoved == -1) throw new IllegalStateException((String)"No free or removed slots available. Key set full?!!");
this.insertKeyAt((int)firstRemoved, (short)val);
return firstRemoved;
}
void insertKeyAt(int index, short val) {
this._set[index] = val;
this._states[index] = 1;
}
protected int XinsertKey(short key) {
byte[] states = this._states;
short[] set = this._set;
int length = states.length;
int hash = HashFunctions.hash((int)key) & Integer.MAX_VALUE;
int index = hash % length;
byte state = states[index];
this.consumeFreeSlot = false;
if (state == 0) {
this.consumeFreeSlot = true;
set[index] = key;
states[index] = 1;
return index;
}
if (state == 1 && set[index] == key) {
return -index - 1;
}
int probe = 1 + hash % (length - 2);
if (state != 2) {
do {
if ((index -= probe) >= 0) continue;
index += length;
} while ((state = states[index]) == 1 && set[index] != key);
}
if (state == 2) {
int firstRemoved = index;
while (state != 0 && (state == 2 || set[index] != key)) {
if ((index -= probe) < 0) {
index += length;
}
state = states[index];
}
if (state == 1) {
return -index - 1;
}
set[index] = key;
states[index] = 1;
return firstRemoved;
}
if (state == 1) {
return -index - 1;
}
this.consumeFreeSlot = true;
set[index] = key;
states[index] = 1;
return index;
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeByte((int)0);
super.writeExternal((ObjectOutput)out);
out.writeShort((int)this.no_entry_key);
out.writeByte((int)this.no_entry_value);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
in.readByte();
super.readExternal((ObjectInput)in);
this.no_entry_key = in.readShort();
this.no_entry_value = in.readByte();
}
}
| [
"emlin2021@gmail.com"
] | emlin2021@gmail.com |
680b82643aa8b7ced26971e9318c63c6d790e03a | 1a5ced3a2bdb9629b0f9709da51674775daae039 | /CoffeeMaker_JUnit/src/edu/najah/csp/coffeemaker/testcases/RecipeBookTest_AddRecipe.java | 2e10406985996ea7dbf0057f1bf77806266639c6 | [] | no_license | SamiOmran/JUnit-Testing-Homework-2 | 6da663c56c39d62ad0ada203659745d4ea4ce9ec | bd1e37eadcf860222e0e3037f9181cdb7c402149 | refs/heads/main | 2023-04-03T06:54:05.390564 | 2021-04-04T17:10:10 | 2021-04-04T17:10:10 | 352,409,995 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,359 | java | package edu.najah.csp.coffeemaker.testcases;
import static org.junit.Assert.*;
import org.junit.Test;
import edu.najah.csp.coffeemaker.Recipe;
import edu.najah.csp.coffeemaker.RecipeBook;
import edu.najah.csp.coffeemaker.exceptions.RecipeException;
public class RecipeBookTest_AddRecipe {
@Test // case 1. adding one recipe to the book
public void testAddRecipe1() {
boolean expected = true, actual;
RecipeBook book = new RecipeBook();
Recipe recipe = new Recipe();
actual = book.addRecipe(recipe);
assertTrue(actual == expected);
}
@Test // case 2. adding similar Recipes
public void testAddRecipe2() {
boolean expected = true, actual;
RecipeBook book = new RecipeBook();
Recipe recipe1 = new Recipe();
Recipe recipe2 = new Recipe();
book.addRecipe(recipe1);
actual = book.addRecipe(recipe2);
assertFalse(actual == expected);
}
@Test // case 3. adding recipe to full book, but first we need to full the book
public void testAddRecipe3() throws RecipeException {
boolean expected = true, actual;
RecipeBook book = new RecipeBook();
for(int i=0;i<4;i++) {
Recipe recipe = new Recipe();
recipe.setName(" "+i);
book.addRecipe(recipe);
}
Recipe overload_recipe = new Recipe();
overload_recipe.setName("5");
actual = book.addRecipe(overload_recipe);
assertFalse(actual == expected);
}
}
| [
"samiimran2016@gmail.com"
] | samiimran2016@gmail.com |
8139ae8a0c2b5fe9a85d9e1f433e2029a9f809a8 | a30e947d4fdf4ac834456a3c796f02ad2634fb8a | /src/main/java/com/devkuma/spring01demo/SampleBeanInterface.java | 02b9d4cf855be5208f83f923470f5e9b1be64bb1 | [] | no_license | newtein80/spring01App | 4b4cb8a9f920b07adb7d779ac1f523ff5fd3f693 | 72372b93d69a79bcd1223b670d88dda41d2e98ce | refs/heads/master | 2020-04-25T14:07:52.417111 | 2019-03-05T06:50:09 | 2019-03-05T06:50:09 | 172,830,859 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 337 | java | package com.devkuma.spring01demo;
/**
* SampleBeanInterface : bean 의 내용을 정의
* 단, Bean의 일반적인 사용법이 이미지될 수 있도록, 이번에는 인터페이스부터 만들어 두었다.
*/
public interface SampleBeanInterface {
public String getMessage();
public void setMessage(String message);
} | [
"newtein80@gmail.com"
] | newtein80@gmail.com |
0855b689ad4b72d2e9ae4e9a42b888b44eba5545 | 79e55c5f1376eb42259b50179fd99ae741e37164 | /src/main/java/org/example/service/impl/FileService.java | ef755d35c7da33fe56f815dcf9e36d3420a02f02 | [] | no_license | 1186659466/File_Upload_Download | f8110af0f606515d360a2e1bb9bc5989a8a7f24b | 56a2b484db132b0ec385f5cd2fc5dc104f31ec22 | refs/heads/master | 2023-04-04T18:42:51.504824 | 2021-04-19T03:36:01 | 2021-04-19T03:36:01 | 359,179,659 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 664 | java | package org.example.service.impl;
import java.util.List;
import org.example.entity.Files;
import org.example.mapper.FileMapper;
import org.example.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class FileService
implements IFileService
{
@Autowired
private FileMapper fileMapper;
public void insertFile(Files files)
{
this.fileMapper.insertFile(files);
}
public List<Files> selectFile()
{
return this.fileMapper.selectFile();
}
public Files selectOneFile(String FId)
{
return this.fileMapper.selectOneFile(FId);
}
}
| [
"1186659466@qq.com"
] | 1186659466@qq.com |
2c8c53f56c6f87b3c0e887493e0b894c78212a25 | bbdb9da0fbab8a54a4121df2ddeab0b5013a1bcc | /antology/src/main/java/de/unkrig/antology/task/PropertyXml2Task.java | 1898c84897fa30ca3e00a2d1d97ceebfc57cec94 | [
"BSD-3-Clause"
] | permissive | aunkrig/antology | 4051e2b3204fffd0f14c4fa7a94d48ff2eb711d0 | 82f6a69622292cbb68a55eb2e4b1b8887ab78c8a | refs/heads/master | 2022-12-10T01:02:44.602808 | 2022-01-20T11:10:38 | 2022-01-20T11:10:38 | 70,775,364 | 3 | 0 | NOASSERTION | 2022-12-05T23:23:53 | 2016-10-13T06:21:11 | Java | UTF-8 | Java | false | false | 13,306 | java |
/*
* antology - Some contributions to APACHE ANT
*
* Copyright (c) 2015, Arno Unkrig
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* 2. 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.
* 3. Neither the name of the copyright holder 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 HOLDER 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 de.unkrig.antology.task;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import de.unkrig.commons.lang.AssertionUtil;
import de.unkrig.commons.lang.ExceptionUtil;
import de.unkrig.commons.nullanalysis.NotNullByDefault;
import de.unkrig.commons.nullanalysis.Nullable;
// SUPPRESS CHECKSTYLE LineLength:26
/**
* Creates an XML document from ANT properties; the counterpart of the {@link XmlProperty2Task <xmlProperty2>} task.
* <p>
* Uses the following properties to create the root element of the XML document:
* </p>
* <pre>
* prefix.0.<var>root-element-name</var>._<var>att1-name</var> = <var>att1-value</var>
* prefix.0.<var>root-element-name</var>._<var>att2-name</var> = <var>att2-value</var>
* prefix.0.<var>root-element-name</var>.<var>index</var>.$ = <var>text</var>
* prefix.0.<var>root-element-name</var>.<var>index</var>.# = <var>comment</var>
* prefix.0.<var>root-element-name</var>.<var>index</var>.! = <var>cdata-text</var>
* prefix.0.<var>root-element-name</var>.<var>index</var>.? = <var>processing-instruction-target-and-data</var>
* </pre>
* <p>
* The <var>index</var>es must be integral values (typically, but not necessarily starting at zero and increasing
* with step size 1), and determine the order of the subnodes.
* In addition to text, comment, cdata, processing instruction and entity nodes, subelements, sub-subelements and so
* forth can be defined in the same manner:
* </p>
* <pre>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>._<var>att1-name</var> = <var>att1-value</var>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>._<var>att2-name</var> = <var>att2-value</var>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>.<var>index</var>.$ = <var>text</var>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>.<var>index</var>.# = <var>comment</var>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>.<var>index</var>.! = <var>cdata-text</var>
* ...<var>parent-element-name</var>.<var>index</var>.<var>subelement-name</var>.<var>index</var>.? = <var>processing-instruction-target-and-data</var>
* </pre>
* <h3>Example:</h3>
* <p>
* The build script
* </p>
* <pre>{@literal
* <property name="prefix.0.project._name" value="prj1" />
* <property name="prefix.0.project.0.$" value=" 	" />
* <property name="prefix.0.project.1.target._name" value="trg1" />
* <property name="prefix.0.project.1.target.0.$" value=" 		" />
* <property name="prefix.0.project.1.target.1.echo._message" value="msg" />
* <property name="prefix.0.project.1.target.2.$" value=" 	" />
* <property name="prefix.0.project.2.$" value=" " />
* <propertyXml2 prefix="prefix." />}</pre>
* <p>
* generates this XML document:
* </p>
* <pre>{@literal
* <?xml version='1.0' encoding='UTF-8'?>
* <project name="prj1">
* <target name="trg1">
* <echo message="msg" />
* </target>
* </project>}</pre>
* <p>
* Notice that "{@code }" denotes a line break and "{@code 	}" a TAB character.
* If you don't care about proper indentation, you can leave out the "{@code ...$}" properties.
* </p>
* <p>
* This task is the inversion of the {@link XmlProperty2Task} task. Notice that the "{@code ...$$}" properties
* which {@link XmlProperty2Task} sets (which are entirely redundant) are <em>not</em> used by this task.
* </p>
*/
public
class PropertyXml2Task extends Task {
static { AssertionUtil.enableAssertionsForThisClass(); }
@Nullable private File file;
private String prefix = "";
private static final Pattern PATTERN = Pattern.compile("(\\d+)\\..*");
// ==================== BEGIN CONFIGURATION SETTERS ====================
/**
* The file to store the XML document in. If this attribute is not set, then the document is printed to the
* console.
*/
public void
setFile(File file) { this.file = file; }
/**
* Determines which properties are used; see task description.
*/
public void
setPrefix(String prefix) { this.prefix = prefix; }
// ==================== END CONFIGURATION SETTERS ====================
@Override public void
execute() {
try {
this.execute2();
} catch (Exception e) {
throw new BuildException(e);
}
}
private void
execute2() throws ParserConfigurationException, TransformerException {
Map<String, Object> allProperties = this.getProject().getProperties();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
documentBuilder.setEntityResolver(new EntityResolver() {
@NotNullByDefault(false) @Override public InputSource
resolveEntity(String publicId, String systemId) {
return new InputSource("((" + publicId + "||" + systemId + "))");
}
});
PropertyXml2Task.createSubelements(allProperties, this.prefix, document, document);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult result = this.file != null ? new StreamResult(this.file) : new StreamResult(System.out);
transformer.transform(source, result);
}
private static Element
createElement(Map<String, Object> allProperties, String prefix, Document document) {
document.createElement("company");
String elementName = null;
Map<String, String> attributes = new HashMap<String, String>();
for (Entry<String, Object> e : allProperties.entrySet()) {
String propertyName = e.getKey();
Object propertyValue = e.getValue();
if (!propertyName.startsWith(prefix)) continue;
int pos;
{
pos = propertyName.indexOf('.', prefix.length());
String en = (
pos == -1
? propertyName.substring(prefix.length())
: propertyName.substring(prefix.length(), pos)
);
if (elementName == null) {
elementName = en;
} else
if (!en.equals(elementName)) {
throw new BuildException(
"Property \""
+ propertyName
+ "\": Inconsistent element name: \""
+ elementName
+ "\" vs. \""
+ en
+ "\""
);
}
pos++;
}
String s = propertyName.substring(pos);
if (s.startsWith("_")) {
attributes.put(s.substring(1), (String) propertyValue);
}
}
if (elementName == null) {
throw new BuildException("No valid subelement for property name prefix \"" + prefix + "\"");
}
Element element;
try {
element = document.createElement(elementName);
} catch (DOMException de) {
throw ExceptionUtil.wrap("Element \"" + elementName + "\"", de, RuntimeException.class);
}
for (Entry<String, String> att : attributes.entrySet()) {
String attributeName = att.getKey();
String attributeValue = att.getValue();
int idx = attributeName.indexOf('.');
if (idx == -1) {
element.setAttribute(attributeName, attributeValue);
} else {
element.setAttributeNS(attributeName.substring(0, idx), attributeName.substring(idx + 1), attributeValue);
}
}
PropertyXml2Task.createSubelements(allProperties, prefix + elementName + '.', element, document);
return element;
}
private static void
createSubelements(Map<String, Object> allProperties, String prefix, Node parent, Document document) {
Set<Integer> indexes = new HashSet<Integer>();
for (String propertyName : allProperties.keySet()) {
if (!propertyName.startsWith(prefix)) continue;
String s = propertyName.substring(prefix.length());
Matcher m;
if ((m = PropertyXml2Task.PATTERN.matcher(s)).matches()) {
int idx = Integer.parseInt(m.group(1));
indexes.add(idx);
}
}
int[] indexes2 = new int[indexes.size()];
{
int i = 0;
for (int index : indexes) indexes2[i++] = index;
}
Arrays.sort(indexes2);
for (int index : indexes2) {
String prefix2 = prefix + index + '.';
String text = (String) allProperties.get(prefix2 + '$');
if (text != null) {
parent.appendChild(document.createTextNode(text));
continue;
}
String comment = (String) allProperties.get(prefix2 + '#');
if (comment != null) {
parent.appendChild(document.createComment(comment));
continue;
}
String cdata = (String) allProperties.get(prefix2 + '!');
if (cdata != null) {
parent.appendChild(document.createCDATASection(cdata));
continue;
}
String pi = (String) allProperties.get(prefix2 + '?');
if (pi != null) {
int spc = pi.indexOf(' ');
if (spc == -1) throw new BuildException("Value of property \"" + prefix2 + "?\" lacks a space");
String target = pi.substring(0, spc);
String data = pi.substring(spc + 1);
parent.appendChild(document.createProcessingInstruction(target, data));
continue;
}
parent.appendChild(PropertyXml2Task.createElement(allProperties, prefix2, document));
}
}
}
| [
"aunkrig@users.noreply.github.com"
] | aunkrig@users.noreply.github.com |
50095914d2b3d3624ca916fe33e46b0ca6ea2716 | 724fccb583dc56b0f2ce38a17e9ccc9c1292e9b5 | /SarahProject/Unicorn.java | b7d27bad4916c95d7b2ed252a580b1ccd6792754 | [] | no_license | runninbear5/GooseHunt | d1664df2da22878dc289bf2c71f892e47f1cc6f4 | 2f3cbe334ac4059335028472cc1cded8ad697c9d | refs/heads/master | 2021-09-04T22:23:05.812025 | 2018-01-22T17:17:20 | 2018-01-22T17:17:20 | 115,132,079 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,454 | java | import greenfoot.*;// (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Unicorn here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Unicorn extends Actor
{
//instance variables
int currentImage = 1;
int counter = 0;
long timeStop = 0;
int stop = 0;
int x;
int y;
boolean right;
/**
* Act - do whatever the Deer wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
//declare vars
x = getX();
y = getY();
if (!right) { //comes in from left
if ((x - 10 <= stop)&&(x + 10 >= stop)) { //if is w/in the randomly selected stop window
setImage("Unicorn11.fw.png");
if(timeStop + 500 <= System.currentTimeMillis()){//stops for # or milliseconds
x = stop + 11; //gets out of the stop window
walk(); //keeps moving
}
} else {
walk(); //keeps moving if not in that window
}
} else {
if ((x - 10 <= stop)&&(x + 10 >= stop)) {//if creature is w/in zone
setImage("Unicorn11.fw.png");
getImage().mirrorHorizontally(); //reflect b/c opposite side entrance
if(timeStop + 500 <= System.currentTimeMillis()){ //stop for set time
x = stop - 11; //get out of stop zone
walk(); //keep moving
}
} else {
walk(); //keep moving
}
}
if(Greenfoot.mouseClicked(this)){//if shot
((PlayScreen)getWorld()).animalHit("Unicorn");//chnage to help screen when created
((PlayScreen)getWorld()).removeObject(this);
}
}
public Unicorn (boolean right) {//which side does it spawn on?
this.right = right;
stop = (int)(Math.random() * 1280);
//System.out.println(stop); debug
}
public void walk () { //move across the screen
if(!right){//start left
x+=5; //add level multiplier
counter++;//slow movement (so visible)
if (counter == 5) {
setImageLeft(); //specific to left side
counter = 0;
}
if (x >= 1265) {//if at boundary
makeDissapear();
}
if ((x - 10 <= stop)&&(x + 10 >= stop)) { //w/in this zone, stop and keep going
timeStop = System.currentTimeMillis();
setImage("Unicorn11.fw.png"); //stop image
}
setLocation(x, y); //set to above increment (x+=5)
} else {//start right
x-=5; //move left
counter++; //slow movement for visibility
if (counter == 5) {
setImageRight(); //call for right entrance
counter = 0; //restart counter
}
if (x <= 10) {//if reached boundary
makeDissapear();
}
if ((x - 10 <= stop)&&(x + 10 >= stop)) { //if w/in window, stop and continue
timeStop = System.currentTimeMillis();
setImageRightArg("Unicorn11.fw.png"); //stopping image
//getImage().mirrorHorizontally();
}
setLocation(x, y); //set location to the above increment
}
}
public void makeDissapear () {//if shot or reached boundary
((PlayScreen)getWorld()).removeObject(this);
}
public void setImageLeft() { //change image to create moving gif
currentImage++; //increment image
if (currentImage == 12) { //loop through graphics
currentImage = 1;
}
setImage("Unicorn" + currentImage + ".fw.png"); //call antler file
}
public void setImageRight () { //if spawned on right
currentImage++; //increment image
if (currentImage == 12) { //loop through graphics
currentImage = 1;
}
setImage("Unicorn" + currentImage + ".fw.png"); //call file
getImage().mirrorHorizontally();
}
public void setImageRightArg (String file){//face the right way when stopped
setImage(file);
getImage().mirrorHorizontally();
}
}
| [
"34775449+separkes1@users.noreply.github.com"
] | 34775449+separkes1@users.noreply.github.com |
252be26396a1bf2da4c577471fb9a4582f2061bb | f47491c1079663f12fdc713b7864df607c547dbb | /bigdata_framework_hbase/src/main/java/learn/hbase/inaction/Infos.java | 53ef9e47d369c5196692ebfcde08033a06ac4ade | [] | no_license | MouseSong/Big-Data | d400f0546760626d3e132d87ba6adf2cff1a568d | e64cc36632a196ed735e65c4aba3651441ae7225 | refs/heads/master | 2021-01-11T10:20:33.041499 | 2016-11-17T08:14:38 | 2016-11-17T08:14:38 | 72,337,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 362 | java | package learn.hbase.inaction;
public class Infos {
public static int TABLE_POOL_CAPACITY = 10;
public static String ZK_SERVICE_PORT = "2181";
public static String ZK_NODES = "hbase";
public static String HBASE_MASTER_ADDR = "hbase:60000";
public static String TABLE_TWITS = "twits";
public static String COLUMN_FAMILY_TWITS = "twits";
}
| [
"zhangdonginpeking@gmail.com"
] | zhangdonginpeking@gmail.com |
e99d8f9d501a56c7c95d0365cb317a9845318911 | 6df097c5c36bbfd49d2941800da4ba4c6f0220e5 | /easycache-client/src/main/java/com/easycache/sqlclient/log/IMDGLog.java | 04ed25707c074d96b476504892cf8368de49e62a | [] | no_license | JiangYongPlus/easycache | cd625afb27dc5dd20c1709727e89a6e5218b2d74 | 93e6bae20dcfa97ae9c57b9581c75e5a055cd831 | refs/heads/master | 2021-01-10T16:37:41.790505 | 2016-01-27T02:41:34 | 2016-01-27T02:41:34 | 50,475,643 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 906 | java | package com.easycache.sqlclient.log;
public class IMDGLog {
public static boolean flag = false;
public static void print(String str) {
if (flag) {
System.out.println("IMDG log: " + str);
}
}
public static void funcLog(String str) {
if (flag) {
System.out.println("function: " + str + " is executed!");
}
}
public static void rstFuncLog(String str) {
if (flag) {
System.out.println("---IMDGResultSet function: " + str + " is executed!---");
}
}
public static void stmtFuncLog(String str) {
if (flag) {
System.out.println("---Statement function: " + str + " is executed!---");
}
}
public static void showPstSql(String sql) {
if (flag) {
System.out.println("---preparedstatement sql is: " + sql + "----");
}
}
public static void showStmtSql(String sql) {
if (flag) {
System.out.println("--statement sql is: " + sql + "----");
}
}
}
| [
"jiangyongplus@gmail.com"
] | jiangyongplus@gmail.com |
eb34d85a50ba6bbada36ac589cd9152d1b31e919 | c03a5001d24621ff1a6b206f0807e7829801e8a0 | /src/Q_61_84/Q83/p1/p2/B.java | 50c577c91f8388c89156952295361a29c17ae0cc | [] | no_license | ozgenkacar/OCA_CalismaKitabi | 6896d7393e130d1d5fcdd7a43224460c75931365 | f2f6b5e5909baaf56d95aaf958461fe75171fdab | refs/heads/master | 2022-11-10T22:59:12.056045 | 2020-06-18T21:43:46 | 2020-06-18T21:43:46 | 273,314,724 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 234 | java | package Q_61_84.Q83.p1.p2;
//line n1
import Q_61_84.Q83.p1.A;
public class B {
public void doStuff(){
A b= new A();
}
}
// Answer C
/*
line n1 => import p1;
line n2 => import p1.A;
import p1.p2.B;
*/ | [
"ssabanci@gmail.com"
] | ssabanci@gmail.com |
1748d638ba41d56a74fa62d8b15cd90d6367d35f | e739e4dbf3abf660b28671a77047f2dbb4c14be8 | /src/java/com/dietManager/database/UserDetails/GeneralBAO/GeneralBAOInterfaceImpl.java | d00705034d780a6113ae5e3a0a55ad7e8bb377bf | [] | no_license | rabindra-dahal/Diet-Recommender | 46b0c5de453b503055e3d5733ab0fc630a077f98 | 9ceab5625bace66735d7ee84554a4e0740f88cf9 | refs/heads/master | 2020-12-04T10:49:51.947863 | 2020-01-04T09:05:45 | 2020-01-04T09:05:45 | 231,734,088 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,329 | java | package com.dietManager.database.UserDetails.GeneralBAO;
import com.dietManager.database.UserDetails.GeneralDAO.GeneralDAOInterface;
import com.dietManager.database.UserDetails.GeneralDAO.GeneralDAOInterfaceImpl;
import com.dietManager.model.UserDetails.General;
import java.util.List;
public class GeneralBAOInterfaceImpl implements GeneralBAOInterface {
private final GeneralDAOInterface impl=new GeneralDAOInterfaceImpl();
@Override
public int generalSave(General g) throws Exception {
return impl.save(g);
}
@Override
public boolean generalUpdate(General g, String u_name) throws Exception {
return impl.update(g,u_name);
}
@Override
public boolean generalDelete(General g) throws Exception {
return impl.delete(g);
}
@Override
public General generalFindByPK(double id) throws Exception {
return impl.findByPK(id);
}
@Override
public General generalFindByName(String name) throws Exception {
return impl.findByName(name);
}
@Override
public List<General> generalFindAll() throws Exception {
return impl.findAll();
}
@Override
public General generalFindByNameAndPassword(String u_name, String password) throws Exception {
return impl.findByNameAndPassword(u_name, password);
}
}
| [
"rabindradahal2076@gmail.com"
] | rabindradahal2076@gmail.com |
8c0ac0e10cda58cd3d853bd5f55398ca0f06ee6d | f8fe9d32a3672e75a93b0a082bd46a5d90cb11d0 | /src/main/java/com/madoka/sunb0002/springbootdemo/common/filters/JwtFilter.java | cbbe7a6e47597615d040e086ba68cea55e2c224d | [] | no_license | sunb0002/SpringBootPlay | 1e1bf35949099b5c365be84f4929c1016141b14a | 8f172b663f65bc4dcdd0e04a41940f83b475a8fb | refs/heads/master | 2023-07-24T19:52:45.063299 | 2021-08-31T04:46:23 | 2021-08-31T04:46:23 | 120,400,422 | 0 | 0 | null | 2023-07-16T14:52:31 | 2018-02-06T04:11:29 | Java | UTF-8 | Java | false | false | 2,777 | java | /**
*
*/
package com.madoka.sunb0002.springbootdemo.common.filters;
import java.io.IOException;
import java.util.Date;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.madoka.sunb0002.springbootdemo.common.utils.DateUtils;
import com.madoka.sunb0002.springbootdemo.common.utils.JwtHelper;
import com.madoka.sunb0002.springbootdemo.common.utils.Validators;
import lombok.extern.slf4j.Slf4j;
/**
* @author sunbo
*
*/
@Slf4j
public class JwtFilter implements Filter {
private static final String AUTH_HEADER_KEY = "Authorization";
private static final String AUTH_HEADER_VALUE_PREFIX = "Bearer "; // with trailing space to separate token
private String jwtKey;
@Override
public void destroy() {
// Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
// Handles pre-flight requests
if (HttpMethod.OPTIONS.name().equals(httpRequest.getMethod())) {
chain.doFilter(request, response);
return;
}
HttpServletResponse httpResponse = (HttpServletResponse) response;
String jwtToken = getBearerToken(httpRequest);
log.debug("Jwt filter will decode token=" + jwtToken + ", with key=" + jwtKey);
DecodedJWT jwt = null;
try {
jwt = JwtHelper.parseToken(jwtToken, jwtKey);
} catch (Exception e) {
httpResponse.sendError(HttpStatus.FORBIDDEN.value(), "Unbale to decode jwt: " + e.getMessage());
return;
}
String adminName = jwt.getClaim("name").asString(); // NOSONAR
Date expiry = jwt.getExpiresAt();
if (Validators.isEmpty(adminName) || DateUtils.compare(expiry) < 0) {
httpResponse.sendError(HttpStatus.FORBIDDEN.value(), "Invalid or expired JWT token.");
return;
}
request.setAttribute("adminName", adminName);
request.setAttribute("adminExpireAt", expiry);
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig config) throws ServletException {
this.jwtKey = config.getInitParameter("jwtKey");
}
private String getBearerToken(HttpServletRequest request) {
String authHeader = request.getHeader(AUTH_HEADER_KEY);
if (authHeader != null && authHeader.startsWith(AUTH_HEADER_VALUE_PREFIX)) {
return authHeader.substring(AUTH_HEADER_VALUE_PREFIX.length());
}
return null;
}
}
| [
"st_sunbo@hotmail.com"
] | st_sunbo@hotmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.