blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b260efb5d731f74ce7af38f750cf8975dc8432a9 | b7994e58e9b5989cb7f3bd973e71ee0d5f19b9f7 | /eclipse-workspace/BTL/src/Sentence/Title.java | 587304d487d8acfe7774dc15dfc0c9ef73eec380 | [] | no_license | duydo131/Bai_tap_lon_OOP | 5b45a7fe066510c4e9ce822301ab7b1d9073f534 | 21a071a92213a145fb090b1a9465800e8ee887c5 | refs/heads/main | 2021-05-23T11:31:54.532290 | 2020-05-02T17:35:16 | 2020-05-02T17:35:16 | 253,266,235 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | package Sentence;
public class Title extends CommentSentence {
}
| [
"[email protected]"
] | |
5b054535e277755f5f2cdc9f379788b5d4982be0 | 5abcef0ad95a404b14072fa1da2e014af1ade4e0 | /src/main/java/com/example/mikroblog/service/UserManager.java | 26e14bc8ba0b148865399b032e8f7cd1cddb3f46 | [] | no_license | michalpodlecki/mikroblog | 33fa343cda888a8560c513b5e7541cd2a8d1e771 | 6aa0b078dfc29802c2169caa96861a09b0965570 | refs/heads/master | 2021-01-01T16:19:00.191711 | 2011-07-27T09:24:36 | 2011-07-27T09:24:36 | 2,111,973 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,444 | java | package com.example.mikroblog.service;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.example.mikroblog.domain.Komentarz;
import com.example.mikroblog.domain.Post;
import com.example.mikroblog.domain.User;
@Stateless
public class UserManager {
@PersistenceContext
EntityManager em;
public void addUser(User u) {
User user = new User();
List<Post> posty = new ArrayList<Post>();
user.setLogin(u.getLogin());
user.setHaslo(u.getHaslo());
user.setImie(u.getImie());
user.setNazwisko(u.getNazwisko());
user.setRok_urodzenia(u.getRok_urodzenia());
user.setPosty(posty);
em.persist(user);
}
public User zaloguj(User u) {
User doZalogowania = new User();
try {
doZalogowania = (User) em.createNamedQuery("user.login").setParameter("login", u.getLogin()).setParameter("haslo", u.getHaslo()).getSingleResult(); //find(User.class, u.getId());
if(doZalogowania != null) {
return doZalogowania;
}
} catch (Exception e) {}
return null;
}
public void edytujUsera(User u) {
em.merge(u);
}
public void addPost(User u, Post p) {
User user = new User();
user.setId(u.getId());
Post post = new Post();
post = p;
post.setUser(user);
List<Komentarz> komentarze = new ArrayList<Komentarz>();
post.setKomentarze(komentarze);
em.persist(post);
}
public void editPost(Post p) {
em.merge(p);
}
public void removePost(Post p) {
Post doUsuniecia = new Post();
doUsuniecia = em.find(Post.class, p.getId());
em.remove(doUsuniecia);
}
public void addKomentarz(Post p, Komentarz k) {
Post post = new Post();
post.setId(p.getId());
Komentarz komentarz = new Komentarz();
komentarz = k;
komentarz.setPost(post);
em.persist(komentarz);
}
public void removeKomentarz(Komentarz k) {
Komentarz doUsuniecia = new Komentarz();
doUsuniecia = em.find(Komentarz.class, k.getId());
em.remove(doUsuniecia);
}
public List<User> pobierzWszystkichUserow() {
return em.createNamedQuery("user.all").getResultList();
}
public List<Post> pobierzWszystkiePosty(User u) {
return em.createNamedQuery("posty.all").setParameter("user", u).getResultList();
}
public List<Post> pobierzWszystkieKomentarze(Post p) {
return em.createQuery("from Komentarz k where k.post=:post").setParameter("post", p).getResultList();
}
}
| [
"[email protected]"
] | |
feba303b36fde0d44cac516c8895bc786983dc2f | 286a421197eb6c7423f19483a9c16bb628af8949 | /ReserveStringInFirstWord.java | 6a03a3d2128694e2374805f556bae5f36e76aaae | [] | no_license | vedhanayaki/wordrevesre | 1a3436c8917ff8b8247738b4f51f41d7a7888820 | d4e912d1820d32c977d08a21a1ad0b7c9c10d94a | refs/heads/master | 2021-01-01T16:14:10.336519 | 2017-07-20T04:06:01 | 2017-07-20T04:06:01 | 97,789,181 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 368 | java | package player;
import java.util.Scanner;
public class ReserveStringInFirstWord {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter the String:");
Scanner s=new Scanner(System.in);
String a=s.nextLine();
int c=a.length();
StringBuffer b=new StringBuffer(a).reverse();
System.out.println(b);
}
}
| [
"[email protected]"
] | |
84e7dae88f5264b78a61fd181265ce44347d4359 | 66903023e6c0469b886201ca6c59b606777f58ee | /oca/src/wbs/basic_data_types/C05.java | 1a700b6bbacbd3c6fa43dd5c8b27a838231bd653 | [] | no_license | MrChrisBee/UnterichtsmaterialOCA | 17f13c4a820c2b4af11b4c37b8fcef5451ae08f3 | ba66579de6f16a0f54ba0c0146889323c83c9c35 | refs/heads/master | 2020-12-22T16:48:43.781520 | 2016-07-29T13:49:44 | 2016-07-29T13:49:44 | 64,137,286 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 581 | java | package wbs.basic_data_types;
public class C05 {
public static void main(String[] args) {
Number n1 = 1;
Number n2 = 1L;
Number n3 = (byte) 1;
Number n4 = (short) 1;
Number n5 = 0b11;
Number n6 = 0b11L;
Number n7 = 1.0;
Number n8 = 1.0f;
System.out.println(n1.getClass());
System.out.println(n2.getClass());
System.out.println(n3.getClass());
System.out.println(n4.getClass());
System.out.println(n5.getClass());
System.out.println(n6.getClass());
System.out.println(n7.getClass());
System.out.println(n8.getClass());
}
}
| [
"[email protected]"
] | |
775ea20f78b951879bf70ed6d231f7301035cf3c | ca030864a3a1c24be6b9d1802c2353da4ca0d441 | /classes4.dex_source_from_JADX/com/facebook/common/hardware/BatteryStateManager$HealthState.java | 06ae4f7497d2b0c71cc72e6ef9e2d9ab5b9ef956 | [] | no_license | pxson001/facebook-app | 87aa51e29195eeaae69adeb30219547f83a5b7b1 | 640630f078980f9818049625ebc42569c67c69f7 | refs/heads/master | 2020-04-07T20:36:45.758523 | 2018-03-07T09:04:57 | 2018-03-07T09:04:57 | 124,208,458 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 222 | java | package com.facebook.common.hardware;
/* compiled from: max_group_size */
public enum BatteryStateManager$HealthState {
UNKNOWN,
GOOD,
OVERHEAT,
DEAD,
OVER_VOLTAGE,
UNSPECIFIED_FAILURE,
COLD
}
| [
"[email protected]"
] | |
5487ea3c99d607e236b089fc1de2223370a932ee | 632a7b3196aa156513a8884e1cd13939009c16c2 | /Circle.java | f085bc0b41184a6b6ed0c35778826400885fd308 | [] | no_license | yohhadgithub/JavaLexcon | cbf51396ae68cfd83f1e343010a155160ec2c968 | 36ade1d6f8ca568d2ec53ec6fd818327a96489d7 | refs/heads/master | 2021-07-20T22:56:34.523518 | 2017-10-26T10:12:22 | 2017-10-26T10:12:22 | 107,642,916 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 431 | java |
public class Circle {
public static void main(String[] args) {
try{
int val = Integer.parseInt(args[0]);
double area = 3.141593*val*val;
double omkrets =3.141593*(2*(val));
System.out.println("Cirkelns area: " + area);
System.out.println("Cirkelns omkrets: " + omkrets);
}
catch(NumberFormatException e){
System.out.println("Snälla anger rätt nummer!");
}
}
}
| [
"[email protected]"
] | |
fc7056b42acb9dcdfe7eb790314fd1a797cf80ef | c80d39388b05322df21ad81c9fca65b275a2cb0c | /src/main/java/de/vogel612/helper/data/util/ProjectSerializer.java | a64d7c4ff0e53c9c99286ceb2037a86bac7a92ab | [
"MIT"
] | permissive | Vogel612/TranslationHelper | 72d6d0e618c080229ed1541b7d70acf37f930a0f | da488aeb3fa53630ee38ec209807428c4d7e56e1 | refs/heads/master | 2021-01-17T03:59:30.887884 | 2018-12-31T18:24:25 | 2018-12-31T18:24:25 | 37,615,062 | 4 | 3 | MIT | 2018-12-31T18:21:48 | 2015-06-17T19:04:00 | Java | UTF-8 | Java | false | false | 4,081 | java | package de.vogel612.helper.data.util;
import de.vogel612.helper.data.Project;
import de.vogel612.helper.data.ResourceSet;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Static helper class to serialize and deserialize Projects into and from files
*/
public final class ProjectSerializer {
/**
* Serializes a given Project into the given file
*
* @param project
* The project to serialize. Must not be null
* @param file
* The file to serialize the project to. Must point to a file
*
* @throws IOException
* If the file could not be opened, created, written to or generally if IO went sideways
*/
public static void serialize(Project project, Path file) throws IOException {
Objects.requireNonNull(project, "project");
// TODO check path for being a file
Document resultDocument = new Document();
resultDocument.setRootElement(getRoot(project.getName()));
project.getAssociatedResources().stream()
.map(set -> ProjectSerializer.getResourceSetEl(set, file))
.forEach(resultDocument.getRootElement()::addContent);
Serialization.serializeDocument(resultDocument, file);
}
private static Element getResourceSetEl(ResourceSet resourceSet, Path projectFile) {
Element el = new Element("resource-set");
el.setAttribute("name", resourceSet.getName());
el.setAttribute("folder", projectFile.getParent().relativize(resourceSet.getFolder()).toString().replace('\\', '/'));
for (String locale : resourceSet.getLocales()) {
if (locale.equals(DataUtilities.FALLBACK_LOCALE)) {
continue;
}
Element localeEl = new Element("locale");
localeEl.setAttribute("name", locale);
el.addContent(localeEl);
}
return el;
}
private static Element getRoot(String name) {
Element el = new Element("project");
el.setAttribute("name", name);
return el;
}
/**
* Deserializes a project from a given file. No error-checking whatsoever is performed as of now
*
* @param file
* The file where the serialized project is saved at
*
* @return A Project-instance that's equivalent to the Project instance originally serialized into the file
*/
public static Project deserialize(Path file) throws IOException {
String projectName;
List<ResourceSet> declaredResources;
try {
Document projectDocument = Serialization.parseFile(file);
Element root = projectDocument.getRootElement();
projectName = root.getAttribute("name").getValue();
declaredResources = root.getChildren().stream()
.map(el -> ProjectSerializer.deserializeResourceSet(el, file))
.filter(Objects::nonNull)
.collect(Collectors.toList());
} catch (JDOMException e) {
// probably an empty file
// log a warning
projectName = file.getFileName().toString().replace(".thp", "");
declaredResources = new ArrayList<>();
}
return new Project(projectName, declaredResources);
}
private static ResourceSet deserializeResourceSet(Element element, Path projectFile) {
final String name = element.getAttributeValue("name");
final Path folder = Paths.get(".", element.getAttributeValue("folder").split("[\\\\/]")).normalize();
final Set<String> locales = element.getChildren().stream()
.map(el -> el.getAttributeValue("name"))
.collect(Collectors.toSet());
return new ResourceSet(name, projectFile.getParent().resolve(folder), locales);
}
}
| [
"[email protected]"
] | |
f8723195b14ea1c464040a50c8971dcaac0f3f86 | 1a382ee624bbdf711a14977827f78f233192144d | /casestudies/kamp4aps/metamodel/original/edu.kit.ipd.sdq.kamp4aps.aps/src/edu/kit/ipd/sdq/kamp4aps/model/aPS/ComponentRepository/VacuumSwitch.java | 14cc74cbc9a58cc44df441cb1e978e27ca3f96e9 | [] | no_license | kit-sdq/Metamodel-Reference-Architecture-Validation | ea44205379782132b872c15ed7ca069c8ae561a5 | ef3adaeb355de0dd46034eef1c0c6e7f639978ff | refs/heads/master | 2020-04-13T14:26:33.043861 | 2019-09-25T09:33:32 | 2019-09-25T09:33:32 | 163,263,325 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 481 | java | /**
*/
package edu.kit.ipd.sdq.kamp4aps.model.aPS.ComponentRepository;
import edu.kit.ipd.sdq.kamp4aps.model.aPS.ElectronicComponents.Switch;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Vacuum Switch</b></em>'.
* <!-- end-user-doc -->
*
*
* @see edu.kit.ipd.sdq.kamp4aps.model.aPS.ComponentRepository.ComponentRepositoryPackage#getVacuumSwitch()
* @model
* @generated
*/
public interface VacuumSwitch extends Switch {
} // VacuumSwitch
| [
"[email protected]"
] | |
1a302dd7f3272d2eedbff831ff7e8faceb5101fb | ab083f03b7b29d01e9dce49621de996867116fe5 | /Standard_algorithm_and_data_structure/Permutation&Combination/src/main/java/PermutationR.java | f74dcfdc836b4f2c17347436ae241f313fd12abe | [] | no_license | njushishuo/Algorithm | 510beb9d612fd4cc4b21bd46b10529f4b1746993 | ab61365322fe1e8f3a1c73470f2a3f00383de84b | refs/heads/master | 2022-12-25T11:07:32.097584 | 2019-12-04T15:06:21 | 2019-12-04T15:06:21 | 106,374,625 | 0 | 0 | null | 2020-10-13T12:07:38 | 2017-10-10T06:02:11 | Java | UTF-8 | Java | false | false | 1,903 | java | import java.util.*;
/**
* Created by ss14 on 2017/5/4.
* 递归实现打印排列数
* 输入: int [] a ; int m
* 输出: 打印每个排列情况
*
* 思想: n = a.length m = m;
* 一个排列情况,其实就是从n个数中,依次挑出m个数
* 采用递归的思想,使用m容量的额外空间temp
* 当已经填充了m个元素时,打印结果
*
* 每次遍历数组,挑选没有被选中过的元素加入到temp中去,然后递归地调用
* 注意:递归返回后,需要从temp中删除之前添加的元素 ,以达到擦除影响的目的
*
*/
public class PermutationR {
/**
* @param inputArray 数组
* @param m
* 从数组中选出m个数
*/
public void printPermutaion( int [] inputArray ,int m){
if(m<=0){
return;
}
int []a = reduceDuplication(inputArray);
LinkedList<Integer> temp = new LinkedList<Integer>();
printPermutationRecursively(a,temp, m);
}
private int [] reduceDuplication(int a[]){
Set set = new HashSet();
for(int i=0; i<a.length ; i++){
set.add(a[i]);
}
Integer [] tempArray = (Integer[]) set.toArray(new Integer[set.size()]);
int [] result = new int [tempArray.length];
for(int i=0;i<result.length;i++ ){
result[i]=tempArray[i];
}
return result;
}
private void printPermutationRecursively(int [] a , LinkedList<Integer> temp, int m){
if(temp.size()>=m){
printList(temp);
return;
}
for(int i=0;i<a.length;i++) {
if (!temp.contains(a[i])) {
temp.addLast(a[i]);
printPermutationRecursively(a, temp,m);
temp.removeLast();
}
}
}
private void printList(List temp){
System.out.println(temp);
}
}
| [
"[email protected]"
] | |
358c0bcf5ddd5309df4fc7726fa19b8fffed77b1 | 885b8119ee81ddb85c450ac339d342e41c6e821c | /src/EjemploLectura.java | bd1a66c8b394f1c07267311bc673e32cdb931fda | [] | no_license | Seplarui/Hilos | 7539eff46ab39d230e2f0ba1da5239f1e9ceebe9 | 1a0794828229d3a8f49ca082d96d5c53c67f8641 | refs/heads/master | 2020-04-01T01:03:59.236668 | 2018-10-14T16:57:05 | 2018-10-14T16:57:05 | 152,724,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 490 | java | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class EjemploLectura {
public static void main(String[] args) {
InputStreamReader in= new InputStreamReader(System.in);
BufferedReader br= new BufferedReader(in);
String texto;
try {
System.out.println("Introduce una cadena...");
texto=br.readLine();
System.out.println("Cadena escrita: "+ texto);
in.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
e909f257c442e6dc85bdaf186be41f21429a9caf | 25a5540fe9240e09d71f39f0d169663ee3101faa | /src/main/java/week3/day1/RBI.java | 65229184278e87d9c94a621e9d6426d3647a64ef | [] | no_license | KarukuuvelRaj/Selenium | 52411b054ad70e24cd6418354ad1e66d0c965a84 | 2c18202e74964cf13866939ec14a6b6cec0d5a1e | refs/heads/master | 2022-07-07T01:56:41.971082 | 2019-05-29T17:17:05 | 2019-05-29T17:17:05 | 189,270,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 128 | java | package week3.day1;
public interface RBI {
int num=5;
public void mandatoryAadhar();
public void noOfTransactions();
}
| [
"RAJ K@Batch2-KarkuvelRaj"
] | RAJ K@Batch2-KarkuvelRaj |
c02fbd0a98003067eeeb55365107e916ea667255 | c1e85f6413abdc4407ea9374f433df928fa56237 | /android/app/src/main/java/com/blixtwallet/MainApplication.java | d8feee61d3c14e031a4194e893e14b0930e67f7d | [
"MIT"
] | permissive | attigo-io/blixt | ea407fbb6eff5f653e1153df6df739408bb05848 | 859df641db0eb796a150011f5a51fdda21ac52ac | refs/heads/master | 2023-08-19T20:15:07.894685 | 2021-10-20T16:08:03 | 2021-10-20T16:08:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,817 | java | package com.blixtwallet;
import com.blixtwallet.tor.BlixtTorPackage;
import androidx.multidex.MultiDexApplication;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.react.bridge.JSIModulePackage;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.hypertrack.hyperlog.HyperLog;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new LndMobilePackage());
packages.add(new LndMobileToolsPackage());
packages.add(new LndMobileScheduledSyncPackage());
packages.add(new BlixtTorPackage());
packages.add(new RealTimeBlurPackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
HyperLog.initialize(this);
HyperLog.setLogLevel(
BuildConfig.DEBUG
? android.util.Log.VERBOSE
: android.util.Log.DEBUG
);
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.blixtwallet.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
0b17f9b35586f1d69639976f24683d1dda1e00ef | 3de80234fecb5b87423f62f9d0ca243f072bb2a4 | /src/java/com/sokil/dao/impl/SequenceDAOImpl.java | 69b4b4877f3fa7a7f3964a4ef0fefa456787b942 | [] | no_license | ViktorSokil/my_active_mq_subscriber | 66bc4747f70c04a2a26cee50c4eb6cb718e0600f | 15e72ceea90f219613503f4e58320bd302554c7f | refs/heads/master | 2021-05-03T04:25:01.534162 | 2018-02-07T12:53:35 | 2018-02-07T12:53:35 | 120,614,795 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,265 | java | package com.sokil.dao.impl;
import com.sokil.dao.ISequenceDao;
import com.sokil.dto.Sequence;
import com.sokil.exeptions.SequenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
@Repository
public class SequenceDAOImpl implements ISequenceDao {
@Autowired
private MongoOperations mongoOperations;
@Override
public Long getNextSequenceId(String key) {
Query query = new Query(Criteria.where("_id").is(key));
Update update = new Update();
update.inc("sequence", 1);
FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true);
Sequence sequence = mongoOperations.findAndModify(query, update, options, Sequence.class);
if(sequence == null) {
throw new SequenceException("Unable to get sequence for key: " + key);
}
return sequence.getSequence();
}
}
| [
"[email protected]"
] | |
75c7d3a22a5313e82b9c7aaf2219a09512f72e83 | 49fa8459ece58858b71416b42237da65a2977a75 | /src/main/java/com/sad/yardmanagementsystem/controller/dto/ViewOrdine.java | 9c7df99a4bd3da6dea0dd3091265058348fe337b | [] | no_license | FabioMartone/YardManagementSystem- | 9e5c6c068e8a96769d8e697714188ef8f9786325 | 166fd54931e259fb12b80c186456bcf1b7d1c57f | refs/heads/main | 2023-06-18T17:34:27.814138 | 2021-07-22T06:42:39 | 2021-07-22T06:42:39 | 379,953,639 | 0 | 0 | null | 2021-07-04T08:31:37 | 2021-06-24T14:30:44 | Java | UTF-8 | Java | false | false | 2,388 | java | package com.sad.yardmanagementsystem.controller.dto;
public class ViewOrdine {
private String tipologiaOrdine;
private String numeroOrdine;
private String dataPrevista;
private int numeroColli;
private int numeroColonne;
private int numeroPedane;
private float pesoTotale;
private String deposito;
private String targa;
private String autista;
public ViewOrdine() {
super();
}
public ViewOrdine(String tipologiaOrdine, String numeroOrdine, String dataPrevista, int numeroColli,
int numeroColonne, int numeroPedane, float pesoTotale, String deposito, String targa,
String autista) {
super();
this.tipologiaOrdine = tipologiaOrdine;
this.numeroOrdine = numeroOrdine;
this.dataPrevista = dataPrevista;
this.numeroColli = numeroColli;
this.numeroColonne = numeroColonne;
this.numeroPedane = numeroPedane;
this.pesoTotale = pesoTotale;
this.deposito = deposito;
this.targa = targa;
this.autista = autista;
}
public String getTipologiaOrdine() {
return tipologiaOrdine;
}
public void setTipologiaOrdine(String tipologiaOrdine) {
this.tipologiaOrdine = tipologiaOrdine;
}
public String getNumeroOrdine() {
return numeroOrdine;
}
public void setNumeroOrdine(String numeroOrdine) {
this.numeroOrdine = numeroOrdine;
}
public String getDataPrevista() {
return dataPrevista;
}
public void setDataPrevista(String dataPrevista) {
this.dataPrevista = dataPrevista;
}
public int getNumeroColli() {
return numeroColli;
}
public void setNumeroColli(int numeroColli) {
this.numeroColli = numeroColli;
}
public int getNumeroColonne() {
return numeroColonne;
}
public void setNumeroColonne(int numeroColonne) {
this.numeroColonne = numeroColonne;
}
public int getNumeroPedane() {
return numeroPedane;
}
public void setNumeroPedane(int numeroPedane) {
this.numeroPedane = numeroPedane;
}
public float getPesoTotale() {
return pesoTotale;
}
public void setPesoTotale(float pesoTotale) {
this.pesoTotale = pesoTotale;
}
public String getDeposito() {
return deposito;
}
public void setDeposito(String deposito) {
this.deposito = deposito;
}
public String getTarga() {
return targa;
}
public void setTarga(String targa) {
this.targa = targa;
}
public String getAutista() {
return autista;
}
public void setAutista(String autista) {
this.autista = autista;
}
}
| [
"[email protected]"
] | |
9e5aa70a62a5a02605f989cb4d2b475719bc02c7 | 27d438ea43813456743486a599edd0a3174e3e6a | /desapp-groupA-2019S1-backend/src/main/java/ar/edu/unq/desapp/grupoa/controller/rest/dto/eventDTO/BaquitaRepresentativesDTO.java | 8a733dcff3cdee2c4959e1dcdb15feb82a855f53 | [] | no_license | VictorDegano/desapp-groupA-2019S1 | e20db91d86cefab8a83269bc3c118d03f5a1bcb5 | eb1e3cd89932968eb9a7796c333f61f1a4d9142e | refs/heads/master | 2023-01-04T22:42:32.883829 | 2019-07-18T21:39:31 | 2019-07-18T21:39:31 | 177,886,292 | 0 | 1 | null | 2023-01-02T22:13:39 | 2019-03-26T23:54:05 | Java | UTF-8 | Java | false | false | 3,262 | java | package ar.edu.unq.desapp.grupoa.controller.rest.dto.eventDTO;
import ar.edu.unq.desapp.grupoa.controller.rest.dto.GoodDTO;
import ar.edu.unq.desapp.grupoa.controller.rest.dto.GuestDTO;
import ar.edu.unq.desapp.grupoa.controller.rest.dto.UserDTO;
import ar.edu.unq.desapp.grupoa.model.event.Event;
import ar.edu.unq.desapp.grupoa.model.event.EventStatus;
import ar.edu.unq.desapp.grupoa.model.event.baquita.BaquitaRepresentatives;
import ar.edu.unq.desapp.grupoa.model.event.canasta.Canasta;
import ar.edu.unq.desapp.grupoa.service.EventService;
import com.fasterxml.jackson.annotation.JsonInclude;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaquitaRepresentativesDTO extends EventDTO {
private List<GuestDTO> representatives;
private List<LoadedGoodDTO> loadedGoods;
public BaquitaRepresentativesDTO(Integer id, String name, UserDTO organizer,
String type, Integer quantityOfGuest, List<GoodDTO> goods,
List<GuestDTO> guests, EventStatus status, LocalDateTime creationDate, List<GuestDTO> representatives, List<LoadedGoodDTO> loadedGoods) {
this.id = id;
this.eventName = name;
this.organizer = organizer;
this.type = type;
this.quantityOfGuest = quantityOfGuest;
this.goods = goods;
this.guests = guests;
this.status = status;
this.creationDate = creationDate;
this.representatives = representatives;
this.loadedGoods = loadedGoods;
}
public BaquitaRepresentativesDTO() {
}
@Override
public EventDTO from(Event aBaquita) {
return new BaquitaRepresentativesDTO(
aBaquita.getId(),
aBaquita.getName(),
UserDTO.from(aBaquita.getOrganizer()),
aBaquita.getType().toString(),
aBaquita.getQuantityOfGuests(),
getGoodsFrom(aBaquita.getGoodsForGuest()),
getGuestsFrom(aBaquita.getGuest()),
aBaquita.getStatus(),
aBaquita.getCreationDate(),
getGuestsFrom(aBaquita.getRepresentatives()),
LoadedGoodDTO.fromList(aBaquita.getLoadedGoods())
);
}
@Override
public Integer handleCreation(EventService eventService) {
return eventService.createBaquitaRepresentatives(
this.eventName,
this.organizer.id,
this.guestMail(),
toGood(this.goods));
}
@Override
public void handleUpdate(EventService eventService) {
BaquitaRepresentatives baquitaRepresentatives = (BaquitaRepresentatives) eventService.getById(id);
Optional.ofNullable(eventName).ifPresent(baquitaRepresentatives::setName);
Optional.ofNullable(status).ifPresent(baquitaRepresentatives::setStatus);
eventService.update(baquitaRepresentatives);
}
public List<GuestDTO> getRepresentatives() {
return representatives;
}
public List<LoadedGoodDTO> getLoadedGoods() {
return loadedGoods;
}
}
| [
"[email protected]"
] | |
cb20e8878a72e3813cfefb94e8f40d7241948233 | 2bc21f86fe648f89a21222b376fa16f3270ffcf9 | /vGuide/app/src/main/java/com/example/hp/vguide/Logout.java | 38149760cbe43404ed6b99b46e16fa5187c9e461 | [] | no_license | PiranavanShanmugavadivelu/samp1 | 7b0baf35561f3352f9740b5c9b481f393e3d9262 | 16c43bb8aeedd0df63f8b592701b1d13344c187d | refs/heads/master | 2020-04-01T13:35:00.499235 | 2018-10-16T09:27:38 | 2018-10-16T09:27:38 | 153,258,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package com.example.hp.vguide;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Logout extends Login {
public Logout() {
super.signOut();
}
}
| [
"[email protected]"
] | |
481c4fec49ad59edc3f178841240316695d88d0d | 54626c3ad74c2c8d6cdd2b2428b9b0dc12f69769 | /leetcode/string/Solution.java | 8bdcf97539d1acd48733c3805138e4bf6701a418 | [] | no_license | medolia/algorithms | 984e5c0b1850596770196cca913580f6a526aff0 | 61f6c89c4af3d86d510d4c5f40ab8602625eae4f | refs/heads/master | 2023-02-14T01:02:55.580324 | 2021-01-07T09:37:55 | 2021-01-07T09:37:55 | 296,219,718 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,485 | java | package string;
import java.util.*;
public class Solution {
/**
* 剑指 Offer 05. 替换空格
*/
public String replaceSpace(String s) {
StringBuilder res = new StringBuilder();
for (int i = 0; i < s.length(); ++i) {
char curr = s.charAt(i);
if (curr != ' ')
res.append(curr);
else
res.append("%20");
}
return res.toString();
}
/**
* 剑指 Offer 20. 表示数值的字符串
* <p>
* 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字
* 符串"+100"、"5e2"、"-123"、"3.1416"、"-1E-16"、"0123"都表示
* 数值,但"12e"、"1a3.14"、"1.2.3"、"+-5"及"12e+5.4"都不是。
* <p>
* 思路:将字符串分为整数A,小数B,指数C三个部分,则数字的模式可以是 A[.[B]][E/eC] 或 .B[E/eC]
* 其中 A、C 为有符号整数,B 为无符号整数,一开始去掉两边空格并添加自定义终止字符防止越界
*/
int idx;
public boolean isNumber(String s) {
s = s.trim() + '|';
idx = 0;
if (s.length() == 0) return false;
boolean isNumeric = scanInteger(s);
if (s.charAt(idx) == '.') {
++idx;
// 需要将扫描行为置于左边,否则可能会跳过扫描
isNumeric = scanUnsignedInt(s) || isNumeric;
}
if (s.charAt(idx) == 'e' || s.charAt(idx) == 'E') {
++idx;
isNumeric = scanInteger(s) && isNumeric;
}
return isNumeric && s.charAt(idx) == '|';
}
boolean scanInteger(String s) {
if (s.charAt(idx) == '+' || s.charAt(idx) == '-')
++idx;
return scanUnsignedInt(s);
}
boolean scanUnsignedInt(String s) {
int start = idx;
while (s.charAt(idx) >= '0' && s.charAt(idx) <= '9')
++idx;
return idx > start;
}
/**
* 剑指 Offer 48. 最长不含重复字符的子字符串
* <p>
* 请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。
* <p>
* 思路:双指针,哈希映射
* 遍历字符串时,如果出现重复字符时更新左指针(只能增大)
* 然后记录每个字符出现的最新索引位置,更新结果
*/
public int lengthOfLongestSubstring(String s) {
Map<Character, Integer> idxMap = new HashMap<>();
int left = -1, res = 0;
for (int i = 0; i < s.length(); ++i) {
char curr = s.charAt(i);
if (idxMap.containsKey(curr))
left = Math.max(left, idxMap.get(curr));
idxMap.put(curr, i);
res = Math.max(res, i - left);
}
return res;
}
/**
* 剑指 Offer 50. 第一个只出现一次的字符
* <p>
* 在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。
* s 只包含小写字母。
* <p>
* 思路:计数器(类似哈希表),遍历两遍字符串,第一遍计数,第二遍找值;
* <p>
* 启发:检测字符在字符串中重复、出现次数等,可考虑用数组或者哈希表计数
*/
public char firstUniqChar(String s) {
int[] counter = new int[26]; // 也可以存 char - 'a' 的值缩小尺寸
for (int i = 0; i < s.length(); i++)
counter[s.charAt(i) - 'a']++;
for (int i = 0; i < s.length(); i++)
if (counter[s.charAt(i) - 'a'] == 1) return s.charAt(i);
return ' ';
}
/**
* 剑指 Offer 58 - I. 翻转单词顺序
* <p>
* 输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。为简单起见,标点符号和普通字母一
* 样处理。例如输入字符串"I am a student. ",则输出"student. a am I"。
* 此外,两端空格逆转后不输出,忽略掉两单词间多余的空格,不能使用 split()、reverse() 内建函数。
* <p>
* 思路:双指针,从右端开始扫描,左指针 l 指向最近的第一个空格,右指针 r 指向最近的第一个非空格
* 由此一次扫描后字符串 s 的 [l+1,r] 为扫描得到的那个单词。
*/
public String reverseWords(String s) {
s = s.trim();
StringBuilder res = new StringBuilder();
int r = s.length() - 1, l = r;
while (true) {
// 更新左指针
while (l >= 0 && s.charAt(l) != ' ')
--l;
res.append(s, l + 1, r + 1).append(" ");
if (l < 0) break;
r = l; // 添加后右指针需要从左指针处开始扫描
while (s.charAt(r) == ' ')
--r;
l = r;
}
return res.toString().trim();
}
/**
* 剑指 Offer 58 - II. 左旋转字符串
* <p>
* 字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。请定义一个函数实现字符串左旋转操作的
* 功能。比如,输入字符串"abcdefg"和数字2,该函数将返回左旋转两位得到的结果"cdefgab"。
* <p>
* 思路:拼接,后半部分 s[n:] 和前半部分 s[0:n]
* <p>
* 启发:若为数组,则原索引 i 与新索引 i' 的关系为 i' = (i + s.len) % n
*/
public String reverseLeftWords(String s, int n) {
return s.substring(n) + s.substring(0, n);
}
/**
* 剑指 Offer 67. 把字符串转换成整数
* <p>
* 写一个函数 StrToInt,实现把字符串转换成整数这个功能。不能使用 atoi 或者其他类似的库函数。
* 1. 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止;
* 2. 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;
* 3. 假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。
* 4. 该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影响。
* <p>
* 思路:
* 1. 开头的正负号需要跳过(默认跳过首位,检测头尾不为正负号则不跳过),使用一个变量保存符号
* 2. 注意边界溢出,当 currRes > max / 10 || ( == max / 10 && curr > '7') 时判定溢出
*/
public int strToInt(String str) {
str = str.trim();
if (str.length() == 0) return 0;
int res = 0, sign = 1, boundary = Integer.MAX_VALUE / 10;
int startI = 1;
if (str.charAt(0) == '-') sign = -1;
else if (str.charAt(0) != '+') startI = 0;
for (int i = startI; i < str.length(); i++) {
char curr = str.charAt(i);
if (curr < '0' || curr > '9') break;
if (res > boundary || (res == boundary && curr > '7'))
return sign == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
res = res * 10 + curr - '0';
}
return res * sign;
}
/**
* 5. 最长回文子串
* <p>
* 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。
* <p>
* 思路:回文中心、双指针扫描;
* 考虑到最长回文可能是奇数串也可能是偶数串,所以对于当前位置 i,回文中心可能是
* i 也可能是 i 和 i+1,两种可能都需要考虑;
* <p>
* 时间复杂度 N^2 空间复杂度 1
*/
public String longestPalindrome(String s) {
int maxLen = 0;
String res = "";
for (int i = 0; i < s.length(); i++) {
int l = i, r = i;
while (l >= 0 && r < s.length() && s.charAt(l) == s.charAt(r)) {
--l;
++r;
}
if (r - l + 1 > maxLen) {
res = s.substring(l + 1, r);
maxLen = r - l + 1;
}
;
l = i;
r = i + 1;
while (l >= 0 && r < s.length() && s.charAt(l) == s.charAt(r)) {
--l;
++r;
}
if (r - l + 1 > maxLen) {
res = s.substring(l + 1, r);
maxLen = r - l + 1;
}
;
}
return res;
}
/**
* 14. 最长公共前缀
* <p>
* 编写一个函数来查找字符串数组中的最长公共前缀。
* 如果不存在公共前缀,返回空字符串 ""。
* <p>
* 思路:纵向扫描,由于答案一定是第一个字符串的子串,可以逐个将首个字符串的
* 字符与之后的字符串对应位置进行比较;
*/
public String longestCommonPrefix(String[] strs) {
if (strs == null || strs.length == 0) return "";
for (int charI = 0; charI < strs[0].length(); charI++) {
char curr = strs[0].charAt(charI);
for (int strI = 1; strI < strs.length; strI++) {
if (charI == strs[strI].length() || strs[strI].charAt(charI) != curr)
return strs[0].substring(0, charI);
}
}
return strs[0];
}
/**
* 20. 有效的括号
* <p>
* 给定一个只包括 '(',')','{','}','[',']'的字符串,判断字符串是否有效。
* 有效字符串需满足:
* 1. 左括号必须用相同类型的右括号闭合。
* 2. 左括号必须以正确的顺序闭合。
* 3. 注意空字符串可被认为是有效字符串。
* <p>
* 思路:遇到左部分时入栈,遇到右部分时检查栈顶是否匹配;
*/
public boolean isValid(String s) {
Stack<Character> stack = new Stack<>();
Map<Character, Character> map = new HashMap<>() {{
put(')', '(');
put(']', '[');
put('}', '{');
}};
for (int i = 0; i < s.length(); i++) {
char curr = s.charAt(i);
if (curr == '(' || curr == '{' || curr == '[')
stack.push(curr);
else {
if (stack.isEmpty() || map.get(curr) != stack.peek())
return false;
stack.pop();
}
}
return stack.isEmpty();
}
/**
* 43. 字符串乘法
* 从个位开始相乘,num1 i 与 num2 j 对应结果数组中的 i+j 和 i+j+1 位
*/
public String multiply(String num1, String num2) {
int len1 = num1.length(), len2 = num2.length();
int[] res = new int[len1 + len2];
for (int i = len1 - 1; i >= 0; i--)
for (int j = len2 - 1; j >= 0; j--) {
int mul = (num1.charAt(i) - '0') * (num2.charAt(j) - '0');
int p1 = i + j, p2 = i + j + 1;
int sum = mul + res[p2];
res[p2] = sum % 10;
res[p1] += sum / 10;
}
int p = 0;
while (p < res.length && res[p] == 0) ++p;
StringBuilder ans = new StringBuilder();
for (int i = p; i < res.length; i++)
ans.append(res[i]);
return ans.length() == 0 ? "0" : ans.toString();
}
/**
* 71. 简化 Unix 文件路径
*/
public String simplifyPath(String path) {
Deque<String> stack = new LinkedList<>();
String[] split = path.split("/");
for (String curr : split) {
if (curr.equals("..")) {
if (!stack.isEmpty())
stack.pop();
} else if (curr.length() > 0 && !curr.equals("."))
stack.push(curr);
}
if (stack.isEmpty())
return "/";
StringBuffer ans = new StringBuffer();
while (!stack.isEmpty()) {
ans.append("/").append(stack.pollLast());
}
return ans.toString();
}
/**
* 205. 同构字符串
* <p>
* 给定两个字符串 s 和 t,判断它们是否是同构的。
* 如果 s 中的字符可以被替换得到 t ,那么这两个字符串是同构的。
* 所有出现的字符都必须用另一个字符替换,同时保留字符的顺序。两个字符不能映射到同一个字符上,但字符可以映射自己本身。
* <p>
* 思路:需求s的字符与t的字符一一对应,映射必须唯一,考虑使用两个映射;
*/
public boolean isIsomorphic(String s, String t) {
Map<Character, Character> s2t = new HashMap<>(), t2s = new HashMap<>();
for (int i = 0; i < s.length(); i++) {
char sc = s.charAt(i), tc = t.charAt(i);
if (t2s.containsKey(tc) && t2s.get(tc) != sc || s2t.containsKey(sc) && s2t.get(sc) != tc) return false;
t2s.put(tc, sc);
s2t.put(sc, tc);
}
return true;
}
/**
* 224. 基本计算器
* <p>
* 实现一个基本的计算器来计算一个简单的字符串表达式的值。
* 字符串表达式可以包含左括号 ( ,右括号 ),基本运算符("+"、"-"、"*"、"/")非负整数和空格。
* <p>
* 思路:使用栈分解表达式;
* 例:"1 + 2 / 3 - 5 * 3" 转化为 "+1 +2/3 +(-5*3);即左至右遍历,遇到一个运算符结算一次;
* num -> 10 * preNum + num;"+" -> push(num); "-" -> push(-num);
* "*" -> push(pop() * num); "/" -> push(pop / num);
* 括号处理:找到对应右括号的位置,递归子串;
*/
public int calculate(String s) {
Stack<Integer> stack = new Stack<>();
char sign = '+';
int num = 0;
for (int i = 0; i < s.length(); i++) {
char curr = s.charAt(i);
if (Character.isDigit(curr))
num = 10 * num + (curr - '0');
if ((!Character.isDigit(curr) && curr != ' ') || i == s.length() - 1) {
if (curr == '(') {
int pR = getPR(s, i);
num = calculate(s.substring(i + 1, pR));
i = pR - 1;
} else {
if (sign == '+')
stack.push(num);
else if (sign == '-')
stack.push(-num);
else if (sign == '*') {
int pre = stack.pop();
stack.push(pre * num);
} else if (sign == '/') {
int pre = stack.pop();
stack.push(pre / num);
}
sign = curr;
num = 0;
}
}
}
int res = 0;
while (!stack.isEmpty())
res += stack.pop();
return res;
}
private int getPR(String s, int pL) {
int count = 1, pR = -1;
for (int i = pL + 1; i < s.length(); i++) {
if (s.charAt(i) == '(') ++count;
else if (s.charAt(i) == ')') {
if (--count == 0) {
pR = i;
break;
}
}
}
return pR;
}
/**
* 391. 完美矩形
* <p>
* 我们有 N 个与坐标轴对齐的矩形, 其中 N > 0, 判断它们是否能精确地覆盖一个矩形区域。
* 每个矩形用左下角的点和右上角的点的坐标来表示。例如,一个单位正方形可以表示为 [1,1,2,2]。
* ( 左下角的点的坐标为 (1, 1) 以及右上角的点的坐标为 (2, 2) )。
* <p>
* 思路:假设遍历所有矩形后找到了 4 个最值定点,符合条件需要满足两个要求:
* 1. 所有小矩形的面积和等于最终形成的大矩形面积;
* 2. 小矩形的四个顶点两两抵消,最后剩下恰好剩下四个大矩形的顶点;
*/
public boolean isRectangleCover(int[][] rectangles) {
int areaSum = 0;
int X1, Y1, X2, Y2;
X1 = Y1 = Integer.MAX_VALUE;
X2 = Y2 = Integer.MIN_VALUE;
// 应以字符串为键,数组为键会出错;
Set<String> points = new HashSet<>();
for (int[] rec : rectangles) {
int x1 = rec[0], y1 = rec[1], x2 = rec[2], y2 = rec[3];
X1 = Math.min(x1, X1);
X2 = Math.max(x2, X2);
Y1 = Math.min(y1, Y1);
Y2 = Math.max(y2, Y2);
areaSum += (x2 - x1) * (y2 - y1);
String[] currPoints = new String[]{x1 + " " + y1, x1 + " " + y2, x2 + " " + y1, x2 + " " + y2};
for (String point : currPoints) { // 抵消顶点;
if (points.contains(point))
points.remove(point);
else points.add(point);
}
}
// 面积需要相等
int areaContained = (X2 - X1) * (Y2 - Y1);
if (areaSum != areaContained) return false;
// 点位需要对上
if (points.size() != 4 || !points.contains(X1 + " " + Y1) || !points.contains(X1 + " " + Y2)
|| !points.contains(X2 + " " + Y1) || !points.contains(X2 + " " + Y2))
return false;
return true;
}
/**
* 567. 字符串的排列
* <p>
* 给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列。
* 换句话说,第一个字符串的排列之一是第二个字符串的子串。
* 注:输入的字符串只包含小写字母。
* <p>
* 思路:使用一个整数数组作计数器;
*/
public boolean checkInclusion(String s1, String s2) {
int[] map = new int[26];
int count = 0;
for (int i = 0; i < s1.length(); i++)
if (map[s1.charAt(i) - 'a']++ == 0) count++;
int l = 0;
for (int i = 0; i < s2.length(); i++) {
int ch = s2.charAt(i) - 'a';
if (--map[ch] == 0) count--;
while (map[ch] < 0)
if (map[s2.charAt(l++) - 'a']++ == 0) count++;
if (count == 0) return true;
}
return false;
}
public static void main(String[] args) {
new Solution().isIsomorphic("foo", "bar");
}
}
| [
"[email protected]"
] | |
c2e878b5a63b819c7b2df504e6c4ee6924468836 | 92448fa8ff25563537eb5b3fda4ef8fec629f554 | /Javaweb_day22-2/src/com/wei/web/servlet/DownloadServlet.java | d376e5c526fbebf1d9dde70f4abb269947924cc3 | [] | no_license | Cyan-King/coding | ced716b973475d37b5aa2f7dbac37b9f9719b1e6 | 981ae99f536af90ed5fd793780307e0a043ad56c | refs/heads/master | 2020-03-12T10:24:52.757634 | 2018-10-10T14:51:30 | 2018-10-10T14:51:30 | 130,572,408 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,514 | java | package com.wei.web.servlet;
import org.apache.commons.io.IOUtils;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
public class DownloadServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String filePath = "D:/CloudMusic/岑宁儿 - 追光者.mp3";
String contentType = this.getServletContext().getMimeType(filePath);//通过文件获取文件类型
DownUtils downUtils = new DownUtils();
String framename = downUtils.filenameEncoding("追光者.mp3", request);
// String framename = new String ("追光者.mp3".getBytes("GBK"), "ISO-8859-1");
response.setHeader("Content-Type", contentType);
String contentDisposition = "atatachment;filename=" + framename;
response.setHeader("Content-Disposition",contentDisposition);
//一个流
FileInputStream inputStream = new FileInputStream(filePath);
ServletOutputStream outputStream = response.getOutputStream();
IOUtils.copy(inputStream, outputStream);
}
}
| [
"[email protected]"
] | |
c8e89d3d92c6e0995cecd63a3fef086f06bd9615 | 07f08499168f458d433a63bcb0843452905d3099 | /app/src/main/java/com/nucleus/events/clubhub/Student_login.java | 788e1e3c4297ae8264341fbd3cb6cd50d81b12d9 | [] | no_license | Shweta871/ClubHub | be92b1635240bcb0af9b8d4189db19b9eb7e29b8 | 739bb400a6e19931814857ddfa4edc6fd241b3f6 | refs/heads/master | 2023-03-02T14:29:35.167331 | 2021-02-15T18:14:37 | 2021-02-15T18:14:37 | 339,165,788 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,237 | java | package com.nucleus.events.clubhub;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class Student_login extends AppCompatActivity {
EditText login_email, login_password;
Button login_button;
TextView forget_passoword;
FirebaseAuth mauth;
String semail, spassoword;
ProgressDialog progressDialog;
Context logincontext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_login);
login_email = findViewById(R.id.login_email);
login_password = findViewById(R.id.login_password);
login_button = findViewById(R.id.btn_login);
forget_passoword = findViewById(R.id.forget_pasword);
mauth = FirebaseAuth.getInstance();
// String str = mauth.getCurrentUser().getUid();
progressDialog = new ProgressDialog(this);
TextView signup = findViewById(R.id.signup);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(Student_login.this, Student_register.class));
}
});
login_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
semail = login_email.getText().toString();
spassoword = login_password.getText().toString();
if (TextUtils.isEmpty(semail) || TextUtils.isEmpty(spassoword)) {
Toast.makeText(Student_login.this, "Email and password is required", Toast.LENGTH_SHORT).show();
} else {
Login();
}
}
});
forget_passoword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dialog dialog=new Dialog(logincontext);
{
dialog.setContentView(R.layout.forgot_password_dialog);
}//create Dialog
dialog.show();
}
});
}
private void Login() {
mauth.signInWithEmailAndPassword(semail, spassoword).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
progressDialog.setTitle("Logging In");
progressDialog.setMessage("Please wait ...");
progressDialog.show();
if (task.isSuccessful()) {
progressDialog.dismiss();
String string = mauth.getCurrentUser().getUid();
if(string.equals("hu7KFsplYYQyKgPLHcQYTjFFl5r1"))
{
Intent intent = new Intent(Student_login.this, Admin_Dashboard.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
else{
Intent intent = new Intent(Student_login.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
} else {
String str = task.getException().toString();
Toast.makeText(Student_login.this, str, Toast.LENGTH_SHORT).show();
}
}
});
}
}
| [
"[email protected]"
] | |
e6ac9f415fb610b5480bb3416331ee35c870ec10 | e3241b8f3744d0488aaafd9a5dfbc211de1a0b27 | /src/main/java/cdot/ccsp/utils/DeviceSecurityPanel.java | ae497a0106367987812470779fc956a2e5f608e0 | [] | 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 | 4,154 | 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.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.XmlElements;
import javax.xml.bind.annotation.XmlType;
import cdot.onem2m.resource.xsd.ChildResourceRef;
import cdot.onem2m.resource.xsd.FlexContainerResource;
import cdot.onem2m.resource.xsd.Subscription;
/**
* <p>Java class for deviceSecurityPanel complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="deviceSecurityPanel">
* <complexContent>
* <extension base="{http://www.onem2m.org/xml/protocols}flexContainerResource">
* <sequence>
* <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/homedomain}securityMode"/>
* <element ref="{http://www.onem2m.org/xml/protocols}subscription"/>
* </choice>
* </choice>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "deviceSecurityPanel", propOrder = {
"childResource",
"securityModeOrSubscription"
})
public class DeviceSecurityPanel
extends FlexContainerResource
{
protected List<ChildResourceRef> childResource;
@XmlElements({
@XmlElement(name = "securityMode", namespace = "http://www.onem2m.org/xml/protocols/homedomain", type = SecurityMode.class),
@XmlElement(name = "subscription", namespace = "http://www.onem2m.org/xml/protocols", type = Subscription.class)
})
protected List<Object> securityModeOrSubscription;
/**
* 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 securityModeOrSubscription 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 securityModeOrSubscription property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSecurityModeOrSubscription().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link SecurityMode }
* {@link Subscription }
*
*
*/
public List<Object> getSecurityModeOrSubscription() {
if (securityModeOrSubscription == null) {
securityModeOrSubscription = new ArrayList<Object>();
}
return this.securityModeOrSubscription;
}
}
| [
"[email protected]"
] | |
1a936667bb630f8ef28fb7c4d5110920a06afe58 | 7615225276ca84f1bda19a78beba577d25fe0157 | /src/main/java/com/proyecto/beans/PeriodoRegimenSalud.java | ec5a7a643cf13eba32a49e228da4a1a354008c8c | [] | no_license | Ultrakill/Planillas | 073d103533e4172a25df233ca5aec3cdecfbe2d8 | a45626832de62376ddbfc99f8fc41664b79f82d5 | refs/heads/master | 2021-03-12T22:32:14.193731 | 2014-11-26T22:51:27 | 2014-11-26T22:51:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,757 | java | package com.proyecto.beans;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name="p_regimen_salud")
public class PeriodoRegimenSalud implements Serializable {
@Column(name="nombre",nullable=false)
@Basic
private String nombre;
@Column(name="id",nullable=false)
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne(targetEntity=RegimenAseguramiento.class)
@JoinColumn(name="regimen_aseguramiento_id",referencedColumnName="codigo",insertable=true,nullable=true,unique=false,updatable=true)
private RegimenAseguramiento regimenAseguramiento;
@Column(name="fecha_fin",nullable=false)
@Temporal(TemporalType.DATE)
@Basic
private Date fechaFin;
@Column(name="fecha_inicio",nullable=false)
@Temporal(TemporalType.DATE)
@Basic
private Date fechaInicio;
@ManyToOne(targetEntity=Contrato.class)
@JoinColumn(name="contrato_id",referencedColumnName="id",insertable=true,nullable=true,unique=false,updatable=true)
private Contrato contrato;
@Column(name="vigente")
@Basic
private Boolean vigente;
public PeriodoRegimenSalud(){
}
public String getNombre() {
return this.nombre;
}
public void setNombre (String nombre) {
this.nombre = nombre;
}
public Long getId() {
return this.id;
}
public void setId (Long id) {
this.id = id;
}
public RegimenAseguramiento getRegimenAseguramiento() {
return this.regimenAseguramiento;
}
public void setRegimenAseguramiento (RegimenAseguramiento regimenAseguramiento) {
this.regimenAseguramiento = regimenAseguramiento;
}
public Date getFechaFin() {
return this.fechaFin;
}
public void setFechaFin (Date fechaFin) {
this.fechaFin = fechaFin;
}
public Date getFechaInicio() {
return this.fechaInicio;
}
public void setFechaInicio (Date fechaInicio) {
this.fechaInicio = fechaInicio;
}
public Contrato getContrato() {
return this.contrato;
}
public void setContrato (Contrato contrato) {
this.contrato = contrato;
}
public Boolean isVigente() {
return this.vigente;
}
public void setVigente (Boolean vigente) {
this.vigente = vigente;
}
}
| [
"Documentos@Doc-PC"
] | Documentos@Doc-PC |
a1fac6430ba9894c26fe7efa770938960239b32d | 8cf2ec05a6929552914e6ad73a023b9c3dc18e80 | /android/lesson 12 - elad/TicTacToe/app/src/androidTest/java/com/example/tictactoe/ExampleInstrumentedTest.java | 034b8e27f92f1510934e9a5006161d57961a2b9c | [] | no_license | maayanpolitzer/Android2016September | 317c9a73f8609316ab18fd275d13455287f8455a | b54f5e1a12465b7dd38b255eec0eae45a6aa409b | refs/heads/master | 2021-05-03T08:43:04.206303 | 2017-02-13T14:59:05 | 2017-02-13T14:59:05 | 69,218,479 | 0 | 6 | null | null | null | null | UTF-8 | Java | false | false | 746 | java | package com.example.tictactoe;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.tictactoe", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
2ea4274b5140644f2be6e19b24b909dc6fc36f6a | eeda269c1bcc122d36bcfde1a6c1e8c7ac45335f | /Javaprj/src/캡슐화로또/Lotto.java | d88137c7d1f4a1132a78a4dfd6dbae9a78c8059b | [] | no_license | hongssi9/JAVA-newlec | 3bcf2bc17dd4fb32bb31b237624506ceab25f2d3 | a6e8a1695bf28d15b327375b92f8a88890878552 | refs/heads/main | 2023-06-06T05:15:21.871940 | 2021-06-20T14:06:22 | 2021-06-20T14:06:22 | 360,113,667 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,576 | java | package 캡슐화로또;
import java.util.Random;
//재사용
public class Lotto {
private int[] nums; // 로또 번호를 정의함
private int size;
//---------------------------초기화------------------------------------------
public static void init(Lotto lotto) { // 반환 없는 함수 //구현부
lotto.size = 6;
lotto.nums = new int[lotto.size];
}
//-----------------------------랜덤으로 숫자 생성-----------------------------------------
static Lotto gen(Lotto lotto) {
// Lotto lotto = new Lotto(); // 4byte 이 객체를 프로그램 클래스에서 공유한다
// lotto.nums = new int[6]; // 24byte
Random rand = new Random();
for (int i = 0; i < lotto.size; i++) {
lotto.nums[i] = rand.nextInt(45) + 1;
}
return lotto;
}
//-------------------------------------------정렬--------------------------------------
public static void sort(Lotto lotto) {
for (int j = 0; j < 5; j++) {
for (int i = 0; i < 5 - j; i++) {
int compare;
if (lotto.nums[i] > lotto.nums[i + 1]) {
compare = lotto.nums[i];
lotto.nums[i] = lotto.nums[i + 1];
lotto.nums[i + 1] = compare;
}
}
}
}
//-------------------------------for문에 돌릴 사이즈-------------------------------
public static int getSize(Lotto lotto) {
return lotto.size;
}
//-------------------------------------------------------------------
// static 은 함수를 만들때
public static int getNum(Lotto lotto, int i) {
int num = lotto.nums[i];
return num;
}
}
| [
"[email protected]"
] | |
04f57d7bc858de51e08c68094e0e92810973d0fc | bccb412254b3e6f35a5c4dd227f440ecbbb60db9 | /hl7/pseudo/datastructure/VR.java | fa34a333d94438038730eb80d33d3d8dfa6cf45e | [] | no_license | nlp-lap/Version_Compatible_HL7_Parser | 8bdb307aa75a5317265f730c5b2ac92ae430962b | 9977e1fcd1400916efc4aa161588beae81900cfd | refs/heads/master | 2021-03-03T15:05:36.071491 | 2020-03-09T07:54:42 | 2020-03-09T07:54:42 | 245,967,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 304 | java | package hl7.pseudo.datastructure;
import hl7.bean.datastructure.DataStructure;
public class VR extends hl7.model.V2_7.datastructure.VR{
public VR(){
super();
}
public static VR CLASS;
static{
CLASS = new VR();
}
public DataStructure[] getComponents(){
return super.getComponents();
}
}
| [
"[email protected]"
] | |
2a773e9ae0c04b23495808c352bde955e0ed8de0 | 2978673ccf9a20d7df367da072de8a90bcf6d134 | /src/main/java/day_5/ReplacePlaceHolder.java | 9344b954fae6e3dd1109360cd7eaac2e516e36fd | [] | no_license | chengzstory/leetcode | 3352fb461225b1ef0c02b5282a2da205814744a7 | 5c202a908ae0a497557c71c48c93e2f744fa5329 | refs/heads/master | 2021-09-23T18:10:02.555514 | 2018-09-26T11:04:09 | 2018-09-26T11:04:09 | 114,202,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 851 | java | package day_5;
import java.util.Stack;
/**
* Created by chengzstory on 2018/9/21.
*/
public class ReplacePlaceHolder {
// {} {} {} {}
public static boolean match(String str) {
Stack<Character> stack = new Stack<Character>();
for (char c : str.toCharArray()) {
if (c == '(')
stack.push(')');
else if (c == '{')
stack.push('}');
else if (c == '[')
stack.push(']');
else if (stack.isEmpty() || stack.pop() != c)
return false;
}
return stack.isEmpty();
}
public static void main(String args[]) {
String str = "[{}]";
// Map params = new HashMap();
// params.put("code", 785132);
// params.put("name", "chengzhi");
System.out.println(match(str));
}
}
| [
"[email protected]"
] | |
17a08688b30cc46cf03dd810d776bfb2ee472144 | ddeb98608fad38b08f6893e1f5d337e93ac6b271 | /litemc-protocol/src/main/java/pub/qiuf/litemc/protocol/server/play/AttachEntityEvent.java | 598fb5b055721325b323c4142a8afdd4e0753998 | [] | no_license | qiufeng6407/litemc | 7049d99a54ab780e2b81032b7318b181d74ced93 | c72323fd2e649fcabcdd42598321993b31bcf8a8 | refs/heads/master | 2021-06-08T07:58:46.986413 | 2019-03-16T01:47:03 | 2019-03-16T01:47:03 | 97,201,389 | 2 | 0 | null | 2020-09-01T03:14:07 | 2017-07-14T06:35:12 | Java | UTF-8 | Java | false | false | 374 | java | package pub.qiuf.litemc.protocol.server.play;
import pub.qiuf.litemc.common.annotation.ServerPacket;
import pub.qiuf.litemc.common.protocol.ServerEvent;
import pub.qiuf.litemc.common.stream.LiteMcInputStream;
@ServerPacket(0x3a)
public class AttachEntityEvent extends ServerEvent {
@Override
public void decode(LiteMcInputStream lmis) throws Exception {
}
}
| [
"[email protected]"
] | |
2c707cea2eec94e674b4177543ed68ee29bd1d8c | 030e78558ca960d50410734c107ef371b48caddb | /lib/src/main/java/com/pora/lib/Person.java | df5fa9f6658c00bf1233f70197c2f88901f05893 | [] | no_license | aljazfarkas/Stempl | cae49ed4d048ec64f90fb78378b1f1363f1e61aa | f0a84d5445e848508fc70ddf3443cc8e7d344ba6 | refs/heads/main | 2023-07-10T19:13:36.971246 | 2021-08-19T16:18:27 | 2021-08-19T16:18:27 | 385,730,797 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,338 | java | package com.pora.lib;
import java.time.LocalDateTime;
import java.util.ArrayList;
public class Person {
private String name;
private String pin;
private ArrayList<CheckPair> checkedTimes;
public Person(String name, String pin) {
this.name = name;
this.pin = pin;
this.checkedTimes = new ArrayList<>();
}
public ArrayList<CheckPair> getCheckedTimes() {
return checkedTimes;
}
public void setCheckedTimes(ArrayList<CheckPair> checkedTimes) {
this.checkedTimes = checkedTimes;
}
public Person(String name, String pin, ArrayList<CheckPair[]> checkedTimes) {
this.name = name;
this.pin = pin;
this.checkedTimes = new ArrayList<CheckPair>();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void addCheckIn(LocalDateTime dateTime){
this.checkedTimes.add(new CheckPair());
this.checkedTimes.get(this.checkedTimes.size() - 1).setCheckIn(dateTime);
}
public void addCheckOut(LocalDateTime dateTime){
this.checkedTimes.get(this.checkedTimes.size() - 1).setCheckOut(dateTime);
}
public String getPin() {
return pin;
}
public void setPin(String pin) {
this.pin = pin;
}
}
| [
"[email protected]"
] | |
c20399e3af866824de1e07fee42b1ea7e49c82bc | c915c40bfe2bacd7a3516eccc8b02b999502700d | /src/main/java/com/yibo/springbootkafkademo/entity/User.java | 6febc9a532cb350f62e32ca2dc30daa5d839a872 | [] | no_license | jjhyb/spring-boot-kafka-demo | ed2fa4e671a7e12a5a392b36060cc85f58691693 | 6c592accf912f9c9bee1c0a9ac4d4e33bf131e23 | refs/heads/master | 2020-05-17T23:30:28.946230 | 2019-04-29T08:49:56 | 2019-04-29T08:49:56 | 184,034,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,131 | java | package com.yibo.springbootkafkademo.entity;
import java.io.Serializable;
/**
* @author: wb-hyb441488
* @Date: 2019/1/11 19:43
* @Description:
*/
public class User implements Serializable {
private Long id;
private String name;
private Integer age;
/**
* transient 关键字修饰的字段不会被序列化
*/
private transient String desc;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
", desc='" + desc + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
fcb4a7cf2f77241f2ad9b1323c9555b41e16ff83 | c44f890f85abcd60817fa289ad321e24a7668860 | /src/exceedvote/air/ui/EachTopicResultUI.java | e236a0dd89388ccd489b15e0bef7c09af99b42d3 | [] | no_license | Air-team/ExceedVote | 29ccfe5535f547bde335930176c5afddebe4775d | 3e97b54507f67e35d8aec0b2cc29e3648f87ee9a | refs/heads/master | 2016-09-05T16:39:29.154391 | 2012-12-25T17:38:10 | 2012-12-25T17:38:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,713 | java | package exceedvote.air.ui;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextPane;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JButton;
import exceedvote.air.controller.ControllerControl;
import exceedvote.air.controller.ControllerVote;
import exceedvote.air.model.VoteTopic;;
/**
* Detail user interface show
* @author AIr Team
* @version 2012.11.3
*/
public class EachTopicResultUI extends JFrame implements RunUI {
// private VoteTypeUI voteTypeUI;
private JPanel contentPane;
private JTextPane txtpnVotetype = new JTextPane();
private JLabel lblSelectTheType = new JLabel(
Messages.getString("Detail.label.clicktype")); //$NON-NLS-1$
// button submit
private JButton btnGoToVote;
private JLabel select = new JLabel(
Messages.getString("Detail.label.select")); //$NON-NLS-1$
// label shows which user select type
private JLabel selectType;
private String labelSelect = ""; //$NON-NLS-1$
private Map<String, JButton> dynamicButtons = new HashMap<String, JButton>();
// service for call other ui
SeviceUI serviceUI;
private Font font;
private int ballot = 0;
private Object[] names;
private JTextField fieldWatch = new JTextField();
private int lastPos = 0;
public EachTopicResultUI() {
ControllerControl control = ControllerControl.getInstance();
names = control.getTopicArray();
ControllerVote voteControllerVote = ControllerVote.getInstance();
ballot = voteControllerVote.checkAmountBallot();
}
/**
* set all component
*/
public void initComponent() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
font = new Font("Monaco", Font.BOLD, 20); //$NON-NLS-1$
setBounds(100, 100, 450, 478);
contentPane = new JPanel();
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setButton();
txtpnVotetype.setEditable(false);
txtpnVotetype.setFont(new Font("Tahoma", Font.PLAIN, 36)); //$NON-NLS-1$
txtpnVotetype.setText(Messages.getString("Detail.text.votetype")); //$NON-NLS-1$
txtpnVotetype.setBounds(10, 11, 176, 50);
contentPane.add(txtpnVotetype);
lblSelectTheType.setBounds(20, 72, 185, 14);
contentPane.add(lblSelectTheType);
selectType = new JLabel();
selectType.setText(Messages.getString("Detail.label.none")); //$NON-NLS-1$
selectType.setBounds(86, lastPos + 50, 199, 14);
contentPane.add(selectType);
btnGoToVote = new JButton(new ActionSubmit());
btnGoToVote.setText(Messages.getString("Detail.butt.resultpage")); //$NON-NLS-1$
btnGoToVote.setBounds(232, lastPos + 50, 169, 23);
contentPane.add(btnGoToVote);
select.setBounds(30, lastPos + 50, 46, 14);
contentPane.add(select);
setSize(430, lastPos + 100);
}
/** Remove the topic button when it out of from persistence */
public void removeButton(String name) {
JButton button = dynamicButtons.remove(name);
contentPane.remove(button);
contentPane.invalidate();
contentPane.repaint();
}
/** Set the button vcomponent */
private void setButton() {
int pos = 55;
for (int i = 0; i < names.length; i++) {
pos += 30;
JButton topicBtn = new JButton();
topicBtn.setText(((VoteTopic) names[i]).getTitle());
topicBtn.addActionListener(new ActionSelect());
dynamicButtons.put(((VoteTopic) names[i]).getTitle(), topicBtn);
topicBtn.setBounds(20, pos, 379, 30);
contentPane.add(topicBtn);
if (i == (names.length - 1)) {
lastPos = pos;
}
}
contentPane.invalidate();
contentPane.repaint();
}
/**
* action event when user select After user click any type, the type will
* show in button of interface
*/
public class ActionSelect extends AbstractAction {
public ActionSelect() {
super();
}
public void actionPerformed(ActionEvent e) {
JButton o = (JButton) e.getSource();
labelSelect = o.getText();
System.out.println(labelSelect);
selectType.setText(labelSelect);
}
}
/**
* Action event when user click submit button if type was select, run
* voterUi. Show message box when user click submit but don't select any
* type.
*/
private class ActionSubmit extends AbstractAction {
public ActionSubmit() {
super();
}
public void actionPerformed(ActionEvent e) {
if (labelSelect.equals("")) //$NON-NLS-1$
{
JOptionPane
.showConfirmDialog(
(Component) null,
Messages.getString("Detail.pop.clicktype"), Messages.getString("Detail.pop.selecttype"), JOptionPane.DEFAULT_OPTION); //$NON-NLS-1$ //$NON-NLS-2$
} else {
TopicScoreUI detail = new TopicScoreUI(labelSelect);
ControllerControl control = ControllerControl.getInstance();
detail.addData(control.getBallot(labelSelect));
detail.run(""); //$NON-NLS-1$
}
}
}
/**
* Invisible
*/
public void close() {
this.setVisible(false);
}
/**
* add serviceUI in this class
* @param SeviceUI
*/
public void addService(SeviceUI serviceUI) {
this.serviceUI = serviceUI;
}
/**
* run this frame
*/
public void run(String info) {
this.initComponent();
this.setVisible(true);
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
| [
"[email protected]"
] | |
42e74c3f9787340e72889bec0a08d10a698bf53c | 6a403153d01ebb6e794ac0197f79466da81b4616 | /passerelle-engine/trunk/com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/userlib/AddFolderToLibraryConfigurer.java | 2038f71065978ae0240633cf157992356ea41728 | [
"BSD-3-Clause",
"Minpack",
"Apache-2.0"
] | permissive | codehaus/passerelle | cea0a5b0b02b166d540a665260a59cf4a72344af | c063ee4b5ebd3d043a604be6c3f2a8aed8a88ea3 | refs/heads/master | 2023-07-20T00:35:11.261984 | 2011-05-17T08:18:32 | 2011-05-17T08:18:32 | 36,342,596 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,141 | java | /* Copyright 2010 - iSencia Belgium NV
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.isencia.passerelle.actor.gui.graph.userlib;
import javax.swing.BoxLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.isencia.passerelle.actor.gui.LibraryManager;
import ptolemy.actor.gui.Configuration;
import ptolemy.gui.Query;
import ptolemy.moml.EntityLibrary;
/**
* Panel that allows to pick a library name from a drop-down list,
* and save a composite actor into it.
*
* @author erwin dl
*/
public class AddFolderToLibraryConfigurer extends Query {
private static final String FOLDER_NAME = "Folder name";
private final static Logger logger = LoggerFactory.getLogger(AddFolderToLibraryConfigurer.class);
private EntityLibrary _parentLibrary;
private Configuration _configuration;
private LibraryManager libraryManager;
/**
*
* @param configuration
* @param actor
*/
public AddFolderToLibraryConfigurer(Configuration configuration, EntityLibrary parentLibrary) {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setTextWidth(25);
_parentLibrary = parentLibrary;
_configuration = configuration;
libraryManager = new LibraryManager(_configuration);
addLine(FOLDER_NAME, FOLDER_NAME, "new folder");
}
/**
* @param configuredEntities
*/
/**
* @throws Exception
*
*/
public void save() throws Exception {
String folderName = getStringValue(FOLDER_NAME);
libraryManager.addSubLibrary(_parentLibrary,folderName);
}
}
| [
"erwindl0@384cdc12-9176-0410-81a5-8911e62acf96"
] | erwindl0@384cdc12-9176-0410-81a5-8911e62acf96 |
b3472745d668ea86f98e9fae8b75f029a8bed23a | 9bf095554ab25aabc14d1b0fb1814ea6e5ddf661 | /blog/src/main/java/com/jgmt/blog/service/MarkdownService.java | 001f4c3ba9b37a7a58eb2810e3ce5dee835cc926 | [] | no_license | Dyinfalse/JavaLearn | 586da13ed6ddaa3b724902ffbd0d09612c9eb27d | eb2c4b6b0787f895ef7cbcc024970d6a3822b984 | refs/heads/master | 2022-12-31T23:32:50.600554 | 2021-04-21T03:45:37 | 2021-04-21T03:45:37 | 218,942,971 | 0 | 0 | null | 2022-12-15T23:57:53 | 2019-11-01T08:14:58 | CSS | UTF-8 | Java | false | false | 302 | java | package com.jgmt.blog.service;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@Service
public interface MarkdownService {
String generateHtml(InputStream is) throws IOException;
List<String> getCssFileList();
}
| [
"[email protected]"
] | |
dafd6840ffb3ff883eeb8c4a739354c65ed64284 | 2661cbe5d00fc5b0c10170125d1179b7fd10d401 | /src/main/java/com/byqj/vo/ExamPointPostPersonVo.java | eaa51aab37dda36908e4a34ac56bb1cd13f668d2 | [] | no_license | cc623213878/byqjFujianDeom | 3c683d5d32bf4ca94b46844185114255be54e925 | 85aa66ac573e56076c13785baf6c5c52896c1fdc | refs/heads/master | 2020-05-24T18:51:25.489947 | 2019-05-19T00:44:47 | 2019-05-19T00:44:47 | 187,418,272 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package com.byqj.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ExamPointPostPersonVo {
private String postId; // 岗位id
private String postName; // 岗位名称
private Integer postNum; // 岗位数
private Integer schedulePostNum; // 已经安排的数量
}
| [
"[email protected]"
] | |
9686a027f1a16f6b2a19d0800c83bb450b7cb034 | a6405d0b22f3e4fe4341b75492a509059a7a5057 | /jiujinhui/src/zz/itcast/jiujinhui/activity/ZongZiChanActivity.java | 6a20818ac28b63bc993e9e25d7e34060a2a5c29e | [] | no_license | chengongshun0809/ttzq | aeb0b23704615f6f41f2b31ec083b2815e1227fc | a963b0f7ada3562ebdf12932cb624eae2ffb24aa | refs/heads/master | 2021-01-20T11:56:19.415837 | 2017-06-06T02:55:37 | 2017-06-06T02:55:37 | 82,639,026 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,303 | java | package zz.itcast.jiujinhui.activity;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import zz.itcast.jiujinhui.R;
import zz.itcast.jiujinhui.res.NetUtils;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class ZongZiChanActivity extends BaseActivity {
@ViewInject(R.id.tv_back)
private ImageView tv_back;
@ViewInject(R.id.tv__title)
private TextView tv__title;
/*@ViewInject(R.id.Rl_jindu)
private RelativeLayout Rl_jindu;*/
@ViewInject(R.id.ll_content)
private LinearLayout ll_content;
boolean stopThread = false;
private SharedPreferences sp;
private String unionidString;
@Override
public void initData() {
// TODO Auto-generated method stub
new Thread(new Runnable() {
private InputStream iStream;
@Override
public void run() {
while (!stopThread) {
String url_serviceinfo = "https://www.4001149114.com/NLJJ/ddapp/mysub?unionid="
+ unionidString;
try {
HttpsURLConnection connection = NetUtils
.httpsconnNoparm(url_serviceinfo, "POST");
int code = connection.getResponseCode();
if (code == 200) {
iStream = connection.getInputStream();
String infojson = NetUtils.readString(iStream);
JSONObject jsonObject = new JSONObject(infojson);
// Log.e("我靠快快快快快快快", jsonObject.toString());
parseJson(jsonObject);
stopThread=true;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (iStream != null) {
try {
iStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}).start();
}
Handler handler=new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
/*Rl_jindu.setVisibility(View.GONE);*/
loading_dialog.dismiss();
UpdateUI();
break;
default:
break;
}
};
};
private LayoutInflater inflater;
private JSONArray jsonArray;
private int length;
private DecimalFormat df;
private void parseJson(JSONObject jsonObject) {
// TODO Auto-generated method stub
try {
jsonArray = jsonObject.getJSONArray("dealdatas");
length = jsonArray.length();
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
boolean firstclick=true;
protected void UpdateUI() {
// TODO Auto-generated method stub
for (int i = 0; i < length; i++) {
View view=inflater.inflate(R.layout.zongzichan_detail, null);
//酒金窖名字
TextView name=(TextView) view.findViewById(R.id.jiujiao_name);
//总收益
TextView zshouyi=(TextView) view.findViewById(R.id.zshouyi);
//总资产
TextView zong_assists=(TextView) view.findViewById(R.id.zongzichan);
TextView shengyu=(TextView) view.findViewById(R.id.shengyu);
TextView saling=(TextView) view.findViewById(R.id.naichuzhong);
TextView buying=(TextView) view.findViewById(R.id.buying);
TextView finished_chengjiao=(TextView) view.findViewById(R.id.finished_chengjiao);
TextView finished_tihuo=(TextView) view.findViewById(R.id.finished_tihuo);
TextView finished_trans=(TextView) view.findViewById(R.id.finished_trans);
RelativeLayout rl_lookMore=(RelativeLayout) view.findViewById(R.id.rl_lookMore);
final LinearLayout ll_lookvalue=(LinearLayout) view.findViewById(R.id.ll_lookvalue);
//获取数据
try {
JSONObject jsonObject=jsonArray.getJSONObject(i);
//总收益
df = new DecimalFormat("#0.00");
String zongshouyi=jsonObject.getString("buyintotal");
//名字
String jiujiaoname=jsonObject.getString("owner");
//总资产
String total=jsonObject.getString("subnum");
//剩余资产
int left_total=jsonObject.getInt("stock");
//卖出中
int saleingsString=jsonObject.getInt("putnum");
//买入中
String buyingString=jsonObject.getString("getnum");
//已成交
String chengjiaoString=jsonObject.getString("dealnum");
//已提货
String tihuo_num=jsonObject.getString("consumenum");
//已转让
String trans_num=jsonObject.getString("buybacknum");
double shou_d=Double.parseDouble(zongshouyi);
zshouyi.setText(df.format(shou_d/100));
name.setText(jiujiaoname);
zong_assists.setText((left_total+saleingsString)+"");
shengyu.setText(left_total+"");
saling.setText(saleingsString+"");
buying.setText(buyingString);
finished_chengjiao.setText(chengjiaoString);
finished_tihuo.setText(tihuo_num);
finished_trans.setText(trans_num);
rl_lookMore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (firstclick) {
ll_lookvalue.setVisibility(View.VISIBLE);
firstclick=false;
}else {
ll_lookvalue.setVisibility(View.GONE);
firstclick=true;
}
}
});
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ll_content.addView(view);
}
}
@Override
public void initListener() {
// TODO Auto-generated method stub
tv_back.setOnClickListener(this);
inflater=(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private Dialog loading_dialog = null;
@Override
public void initView() {
// TODO Auto-generated method stub
ViewUtils.inject(this);
tv__title.setText("个人资产");
sp = getSharedPreferences("user", 0);
unionidString = sp.getString("unionid", null);
/*Rl_jindu.setVisibility(View.VISIBLE);
*/
loading_dialog=zz.itcast.jiujinhui.res.DialogUtil.createLoadingDialog(ZongZiChanActivity.this, "加载中...");
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.tv_back:
loading_dialog.dismiss();
finish();
break;
default:
break;
}
}
@Override
public int getLayoutResID() {
// TODO Auto-generated method stub
return R.layout.zongzichan_activity;
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
stopThread = false;
handler.removeMessages(1);
}
}
| [
"[email protected]"
] | |
d4395de45f172ae3615e49105ef89b2021c0a2b8 | 96008d989056a35b6864c32dbcc22033d79f81b5 | /app/src/main/java/com/example/studycs/rnotes.java | 4b0d0a24ec27a147e5215401d098a61727252035 | [] | no_license | iraghavpareek/StudyCS | e1cd0363462eac68955c791c344f1eb34211a1b6 | e0408e3011be1ad27aca264de63a40ccd77f8f5a | refs/heads/master | 2023-02-26T10:55:50.542542 | 2022-11-28T18:01:37 | 2022-11-28T18:01:37 | 570,900,303 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,125 | java | package com.example.studycs;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.github.barteksc.pdfviewer.PDFView;
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.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class rnotes extends AppCompatActivity {
private TextView textView;
private PDFView pdfView;
ProgressBar progressBar;
FirebaseDatabase database=FirebaseDatabase.getInstance();
DatabaseReference mref=database.getReference("ruby");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rnotes);
pdfView=findViewById(R.id.jsn1);
textView=findViewById(R.id.text1);
progressBar=findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);
mref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String value =dataSnapshot.getValue(String.class);
textView.setText(value);
Toast.makeText(rnotes.this, "Updated", Toast.LENGTH_SHORT).show();
String url =textView.getText().toString();
progressBar.setVisibility(View.GONE);
new RetrivePdfStream().execute(url);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(rnotes.this, "Failed To Load", Toast.LENGTH_SHORT).show();
}
});}
class RetrivePdfStream extends AsyncTask<String,Void, InputStream> {
@Override
protected InputStream doInBackground(String... strings) {
InputStream inputStream=null;
try {
URL url=new URL (strings[0]);
HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection();
if (urlConnection.getResponseCode()==200){
inputStream=new BufferedInputStream(urlConnection.getInputStream());
}
}catch (IOException e){
return null;
}
return inputStream;
}
@Override
protected void onPostExecute(InputStream inputStream) {
pdfView.fromStream(inputStream).load();
}
}
}
| [
"[email protected]"
] | |
a5821ae010461e647cbb70f53b2c426a4df8405f | 232375291c915a086eebcd482971595a70fd12cc | /cloudfoundry-client/src/main/java/org/cloudfoundry/client/v2/featureflags/_SetFeatureFlagRequest.java | 21c2716c8038bf04afa9092dc62bf0215bd1ef3e | [
"Apache-2.0"
] | permissive | carlos-salinas/cf-java-client | 3ddc94d9f74946cc1a4e0c750d269966801158a1 | 583596bf7d790b1e96c427b46be6059ab2f05a62 | refs/heads/master | 2021-01-20T07:29:35.745607 | 2017-04-28T19:59:04 | 2017-04-28T20:00:10 | 90,006,934 | 1 | 0 | null | 2017-05-02T07:58:58 | 2017-05-02T07:58:58 | null | UTF-8 | Java | false | false | 1,350 | java | /*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cloudfoundry.client.v2.featureflags;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.cloudfoundry.Nullable;
import org.immutables.value.Value;
/**
* The request payload for the Set Feature Flag operation
*/
@Value.Immutable
abstract class _SetFeatureFlagRequest {
/**
* The state of the feature flag
*/
@JsonProperty("enabled")
abstract Boolean getEnabled();
/**
* The custom error message for the feature flag
*/
@JsonProperty("error_message")
@Nullable
abstract String getErrorMessage();
/**
* The name of the feature flag
*/
@JsonIgnore
abstract String getName();
}
| [
"[email protected]"
] | |
e33e1c677bec196cca0075425be0ae27652021d5 | 005897b76d3f61a4ce2ba7a601d828584f16e1b8 | /Java-EU5-1/src/assignment8/q12.java | 315ec67467456c42a6bae34194595807de5f1561 | [] | no_license | HCRPC/Java-EU5-1 | 5e8607ce81df378aa4d12390ee4320f4877bc625 | 560a29dd08545bb98c6bbeaf97b7fcb6a97e7d6c | refs/heads/master | 2023-05-07T01:33:42.499811 | 2021-05-31T11:48:36 | 2021-05-31T11:48:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 504 | java | package assignment8;
public class q12 {
public static void main(String[] args) {
System.out.println(hamletQuote(false,true));
}
public static boolean hamletQuote(boolean q1,boolean q2) {
// if((q1==true&&q2==true)||(q1!=true&&q2==true)||(q1==true&&q2!=true)){
if(q1==true||q2==true) {
return true;
}
else {
return false;
}
}
}
| [
"[email protected]"
] | |
ddd714c00b76af56b695575e6b5ab242918240a8 | ecb07e796b2babb50c2a059d26188b7d83429ed5 | /src/java/htsjdk/samtools/SamInputResource.java | f84676b3d67f70204cc50db4b0a71871667d8a8a | [] | no_license | HadoopGenomics/htsjdk | dc70a3e5f503a3159bbebc98ef97b55d571337c0 | eccce8947f37112fc71c4f63a0f3c3a2b6b24136 | refs/heads/master | 2021-01-17T23:59:10.689437 | 2014-08-13T18:28:19 | 2014-08-13T18:28:19 | 22,572,678 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,270 | java | package htsjdk.samtools;
import htsjdk.samtools.seekablestream.SeekableFileStream;
import htsjdk.samtools.seekablestream.SeekableHTTPStream;
import htsjdk.samtools.seekablestream.SeekableStream;
import htsjdk.samtools.util.Lazy;
import htsjdk.samtools.util.RuntimeIOException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
/**
* Describes a SAM-like resource, including its data (where the records are), and optionally an index.
* <p/>
* A data or index source may originate from a {@link java.io.File}, {@link java.io.InputStream}, {@link URL}, or
* {@link htsjdk.samtools.seekablestream.SeekableStream}; look for the appropriate overload for
* {@code htsjdk.samtools.SamInputResource#of()}.
*
* @author mccowan
*/
public class SamInputResource {
private final InputResource source;
private InputResource index;
SamInputResource(final InputResource data) {
this(data, null);
}
SamInputResource(final InputResource source, final InputResource index) {
if (source == null) throw new NullPointerException("source");
this.source = source;
this.index = index;
}
/** The resource that is the SAM data (e.g., records) */
InputResource data() {
return source;
}
/**
* The resource that is the SAM index
*
* @return null, if no index is defined for this resource
*/
InputResource indexMaybe() {
return index;
}
@Override
public String toString() {
return String.format("data=%s;index=%s", source, index);
}
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */
public static SamInputResource of(final File file) { return new SamInputResource(new FileInputResource(file)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */
public static SamInputResource of(final InputStream inputStream) { return new SamInputResource(new InputStreamInputResource(inputStream)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */
public static SamInputResource of(final URL url) { return new SamInputResource(new UrlInputResource(url)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */
public static SamInputResource of(final SeekableStream seekableStream) { return new SamInputResource(new SeekableStreamInputResource(seekableStream)); }
/** Updates the index to point at the provided resource, then returns itself. */
public SamInputResource index(final File file) {
this.index = new FileInputResource(file);
return this;
}
/** Updates the index to point at the provided resource, then returns itself. */
public SamInputResource index(final InputStream inputStream) {
this.index = new InputStreamInputResource(inputStream);
return this;
}
/** Updates the index to point at the provided resource, then returns itself. */
public SamInputResource index(final URL url) {
this.index = new UrlInputResource(url);
return this;
}
/** Updates the index to point at the provided resource, then returns itself. */
public SamInputResource index(final SeekableStream seekableStream) {
this.index = new SeekableStreamInputResource(seekableStream);
return this;
}
}
/**
* Describes an arbitrary input source, which is something that can be accessed as either a
* {@link htsjdk.samtools.seekablestream.SeekableStream} or {@link java.io.InputStream}. A concrete implementation of this class exists for
* each of {@link InputResource.Type}.
*/
abstract class InputResource {
protected InputResource(final Type type) {this.type = type;}
enum Type {
FILE, URL, SEEKABLE_STREAM, INPUT_STREAM
}
private final Type type;
final Type type() {
return type;
}
/** Returns null if this resource cannot be represented as a {@link File}. */
abstract File asFile();
/** Returns null if this resource cannot be represented as a {@link URL}. */
abstract URL asUrl();
/** Returns null if this resource cannot be represented as a {@link htsjdk.samtools.seekablestream.SeekableStream}. */
abstract SeekableStream asUnbufferedSeekableStream();
/** All resource types support {@link java.io.InputStream} generation. */
abstract InputStream asUnbufferedInputStream();
@Override
public String toString() {
final String childToString;
switch (type()) {
case FILE:
childToString = asFile().toString();
break;
case INPUT_STREAM:
childToString = asUnbufferedInputStream().toString();
break;
case SEEKABLE_STREAM:
childToString = asUnbufferedSeekableStream().toString();
break;
case URL:
childToString = asUrl().toString();
break;
default:
throw new IllegalStateException();
}
return String.format("%s:%s", type(), childToString);
}
}
class FileInputResource extends InputResource {
final File fileResource;
final Lazy<SeekableStream> lazySeekableStream = new Lazy<SeekableStream>(new Lazy.LazyInitializer<SeekableStream>() {
@Override
public SeekableStream make() {
try {
return new SeekableFileStream(fileResource);
} catch (final FileNotFoundException e) {
throw new RuntimeIOException(e);
}
}
});
FileInputResource(final File fileResource) {
super(Type.FILE);
this.fileResource = fileResource;
}
@Override
public File asFile() {
return fileResource;
}
@Override
public URL asUrl() {
return null;
}
@Override
public SeekableStream asUnbufferedSeekableStream() {
return lazySeekableStream.get();
}
@Override
public InputStream asUnbufferedInputStream() {
return asUnbufferedSeekableStream();
}
}
class UrlInputResource extends InputResource {
final URL urlResource;
final Lazy<SeekableStream> lazySeekableStream = new Lazy<SeekableStream>(new Lazy.LazyInitializer<SeekableStream>() {
@Override
public SeekableStream make() {
return new SeekableHTTPStream(urlResource);
}
});
UrlInputResource(final URL urlResource) {
super(Type.URL);
this.urlResource = urlResource;
}
@Override
public File asFile() {
return null;
}
@Override
public URL asUrl() {
return urlResource;
}
@Override
public SeekableStream asUnbufferedSeekableStream() {
return lazySeekableStream.get();
}
@Override
public InputStream asUnbufferedInputStream() {
return asUnbufferedSeekableStream();
}
}
class SeekableStreamInputResource extends InputResource {
final SeekableStream seekableStreamResource;
SeekableStreamInputResource(final SeekableStream seekableStreamResource) {
super(Type.SEEKABLE_STREAM);
this.seekableStreamResource = seekableStreamResource;
}
@Override
File asFile() {
return null;
}
@Override
URL asUrl() {
return null;
}
@Override
SeekableStream asUnbufferedSeekableStream() {
return seekableStreamResource;
}
@Override
InputStream asUnbufferedInputStream() {
return asUnbufferedSeekableStream();
}
}
class InputStreamInputResource extends InputResource {
final InputStream inputStreamResource;
InputStreamInputResource(final InputStream inputStreamResource) {
super(Type.INPUT_STREAM);
this.inputStreamResource = inputStreamResource;
}
@Override
File asFile() {
return null;
}
@Override
URL asUrl() {
return null;
}
@Override
SeekableStream asUnbufferedSeekableStream() {
return null;
}
@Override
InputStream asUnbufferedInputStream() {
return inputStreamResource;
}
}
| [
"[email protected]"
] | |
7e6a10dba8e353dd5de688d2abdde1da91444114 | 2c42d04cba77776514bc15407cd02f6e9110b554 | /src/org/processmining/mining/bpel4ws/BPEL4WSConnectVisitor.java | 112eedc1ba16454cb8afbcb8466caea1858f80fc | [] | no_license | pinkpaint/BPMNCheckingSoundness | 7a459b55283a0db39170c8449e1d262e7be21e11 | 48cc952d389ab17fc6407a956006bf2e05fac753 | refs/heads/master | 2021-01-10T06:17:58.632082 | 2015-06-22T14:58:16 | 2015-06-22T14:58:16 | 36,382,761 | 0 | 1 | null | 2015-06-14T10:15:32 | 2015-05-27T17:11:29 | null | UTF-8 | Java | false | false | 5,775 | java | /***********************************************************
* This software is part of the ProM package *
* http://www.processmining.org/ *
* *
* Copyright (c) 2003-2006 TU/e Eindhoven *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by Eindhoven University of Technology *
* Department of Information Systems *
* http://is.tm.tue.nl *
* *
**********************************************************/
package org.processmining.mining.bpel4ws;
import java.util.HashMap;
import org.processmining.framework.log.LogEvent;
import org.processmining.framework.log.LogReader;
import org.processmining.framework.models.bpel4ws.type.BPEL4WS;
import org.processmining.framework.models.bpel4ws.type.BPEL4WSProcess;
import org.processmining.framework.models.bpel4ws.type.BPEL4WSVisitor;
import org.processmining.framework.models.bpel4ws.type.activity.Activity;
import org.processmining.framework.models.bpel4ws.type.activity.Assign;
import org.processmining.framework.models.bpel4ws.type.activity.Empty;
import org.processmining.framework.models.bpel4ws.type.activity.Flow;
import org.processmining.framework.models.bpel4ws.type.activity.Invoke;
import org.processmining.framework.models.bpel4ws.type.activity.Pick;
import org.processmining.framework.models.bpel4ws.type.activity.Receive;
import org.processmining.framework.models.bpel4ws.type.activity.Reply;
import org.processmining.framework.models.bpel4ws.type.activity.Sequence;
import org.processmining.framework.models.bpel4ws.type.activity.Switch;
import org.processmining.framework.models.bpel4ws.type.activity.Wait;
import org.processmining.framework.models.bpel4ws.type.activity.While;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class BPEL4WSConnectVisitor extends BPEL4WSVisitor {
/**
* The instance of this BPEL4WSHierarchyVisitor
*/
private static final BPEL4WSConnectVisitor instance = new BPEL4WSConnectVisitor();
private static LogReader log;
private static HashMap map;
public BPEL4WSConnectVisitor() {
}
public static synchronized void Build(BPEL4WS model, LogReader log, HashMap map) {
instance.log = log;
instance.map = map;
model.process.acceptVisitor(instance);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitProcess(org.processmining.exporting.bpel4ws.type.Process)
*/
public void visitProcess(BPEL4WSProcess process) {
process.activity.acceptVisitor(this);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitSequence(org.processmining.exporting.bpel4ws.type.activity.Sequence)
*/
public void visitSequence(Sequence sequence) {
for (Activity activity : sequence.activities) {
activity.acceptVisitor(this);
}
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitReceive(org.processmining.exporting.bpel4ws.type.activity.Receive)
*/
public void visitReceive(Receive receive) {
Object[] objects = (Object[]) map.get(receive);
receive.setLogEvent((LogEvent) objects[0]);
receive.getVertex().setIdentifier((String) objects[1]);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitEmpty(org.processmining.exporting.bpel4ws.type.activity.Empty)
*/
public void visitEmpty(Empty empty) {
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitReply(org.processmining.exporting.bpel4ws.type.activity.Reply)
*/
public void visitReply(Reply reply) {
Object[] objects = (Object[]) map.get(reply);
reply.setLogEvent((LogEvent) objects[0]);
reply.getVertex().setIdentifier((String) objects[1]);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitWhile(org.processmining.exporting.bpel4ws.type.activity.While)
*/
public void visitWhile(While whileActivity) {
whileActivity.activity.acceptVisitor(this);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitSwitch(org.processmining.exporting.bpel4ws.type.activity.Switch)
*/
public void visitSwitch(Switch switch1) {
for (Activity activity : switch1.cases.keySet()) {
activity.acceptVisitor(this);
}
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitFlow(org.processmining.exporting.bpel4ws.type.activity.Flow)
*/
public void visitFlow(Flow flow) {
for (Activity activity : flow.activities) {
activity.acceptVisitor(this);
}
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitInvoke(org.processmining.exporting.bpel4ws.type.activity.Invoke)
*/
public void visitInvoke(Invoke invoke) {
Object[] objects = (Object[]) map.get(invoke);
invoke.setLogEvent((LogEvent) objects[0]);
invoke.getVertex().setIdentifier((String) objects[1]);
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitPick(org.processmining.exporting.bpel4ws.type.activity.Pick)
*/
public void visitPick(Pick pick) {
for (Activity activity : pick.messages.keySet()) {
activity.acceptVisitor(this);
}
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitAssign(org.processmining.exporting.bpel4ws.type.activity.Assign)
*/
public void visitAssign(Assign assign) {
}
/**
* @see org.processmining.exporting.bpel4ws.type.BPEL4WSVisitor#visitWait(org.processmining.exporting.bpel4ws.type.activity.Wait)
*/
public void visitWait(Wait wait) {
}
}
| [
"[email protected]"
] | |
b68714af62ec81ae7916e60e37b6d764003d6488 | a3e0cdfd506d0f3b780d1135359e4f55f9af92ad | /teavm-core/src/main/java/org/teavm/javascript/ast/RenamingVisitor.java | bb0e1afd40846753667b9b6ba379ce6021b0d806 | [
"Apache-2.0"
] | permissive | RuedigerMoeller/teavm | 739948602544c98443313e51c9c429a69a1824a6 | 70338531f58999f3080ff1578960112633ca0c01 | refs/heads/master | 2023-06-14T18:19:51.946286 | 2014-10-09T13:36:44 | 2014-10-09T13:36:44 | 24,997,400 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,141 | java | /*
* Copyright 2013 Alexey Andreev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teavm.javascript.ast;
/**
*
* @author Alexey Andreev
*/
public class RenamingVisitor implements StatementVisitor, ExprVisitor {
private int[] varNames;
public RenamingVisitor(int[] varNames) {
this.varNames = varNames;
}
@Override
public void visit(BinaryExpr expr) {
expr.getFirstOperand().acceptVisitor(this);
expr.getSecondOperand().acceptVisitor(this);
}
@Override
public void visit(UnaryExpr expr) {
expr.getOperand().acceptVisitor(this);
}
@Override
public void visit(ConditionalExpr expr) {
expr.getCondition().acceptVisitor(this);
expr.getConsequent().acceptVisitor(this);
expr.getAlternative().acceptVisitor(this);
}
@Override
public void visit(ConstantExpr expr) {
}
@Override
public void visit(VariableExpr expr) {
expr.setIndex(varNames[expr.getIndex()]);
}
@Override
public void visit(SubscriptExpr expr) {
expr.getArray().acceptVisitor(this);
expr.getIndex().acceptVisitor(this);
}
@Override
public void visit(UnwrapArrayExpr expr) {
expr.getArray().acceptVisitor(this);
}
@Override
public void visit(InvocationExpr expr) {
for (Expr arg : expr.getArguments()) {
arg.acceptVisitor(this);
}
}
@Override
public void visit(QualificationExpr expr) {
expr.getQualified().acceptVisitor(this);
}
@Override
public void visit(NewExpr expr) {
}
@Override
public void visit(NewArrayExpr expr) {
expr.getLength().acceptVisitor(this);
}
@Override
public void visit(NewMultiArrayExpr expr) {
for (Expr dim : expr.getDimensions()) {
dim.acceptVisitor(this);
}
}
@Override
public void visit(InstanceOfExpr expr) {
expr.getExpr().acceptVisitor(this);
}
@Override
public void visit(StaticClassExpr expr) {
}
@Override
public void visit(AssignmentStatement statement) {
if (statement.getLeftValue() != null) {
statement.getLeftValue().acceptVisitor(this);
}
statement.getRightValue().acceptVisitor(this);
}
@Override
public void visit(SequentialStatement statement) {
for (Statement part : statement.getSequence()) {
part.acceptVisitor(this);
}
}
@Override
public void visit(ConditionalStatement statement) {
statement.getCondition().acceptVisitor(this);
for (Statement part : statement.getConsequent()) {
part.acceptVisitor(this);
}
for (Statement part : statement.getAlternative()) {
part.acceptVisitor(this);
}
}
@Override
public void visit(SwitchStatement statement) {
statement.getValue().acceptVisitor(this);
for (SwitchClause clause : statement.getClauses()) {
for (Statement part : clause.getBody()) {
part.acceptVisitor(this);
}
}
for (Statement part : statement.getDefaultClause()) {
part.acceptVisitor(this);
}
}
@Override
public void visit(WhileStatement statement) {
if (statement.getCondition() != null) {
statement.getCondition().acceptVisitor(this);
}
for (Statement part : statement.getBody()) {
part.acceptVisitor(this);
}
}
@Override
public void visit(BlockStatement statement) {
for (Statement part : statement.getBody()) {
part.acceptVisitor(this);
}
}
@Override
public void visit(BreakStatement statement) {
}
@Override
public void visit(ContinueStatement statement) {
}
@Override
public void visit(ReturnStatement statement) {
if (statement.getResult() != null) {
statement.getResult().acceptVisitor(this);
}
}
@Override
public void visit(ThrowStatement statement) {
statement.getException().acceptVisitor(this);
}
@Override
public void visit(InitClassStatement statement) {
}
@Override
public void visit(TryCatchStatement statement) {
for (Statement part : statement.getProtectedBody()) {
part.acceptVisitor(this);
}
for (Statement part : statement.getHandler()) {
part.acceptVisitor(this);
}
statement.setExceptionVariable(varNames[statement.getExceptionVariable()]);
}
}
| [
"[email protected]"
] | |
0481f8b1e3223c309f5c3653cba1e32468e35281 | f47defb72a405d62a3eff55912157661b1de4623 | /src/main/java/com/mastercard/interview/configuration/SwaggerConfiguration.java | c64640999d5e146f96bdc9d06d2a49ceb638a816 | [] | no_license | rahulvarma051/city-roads | c41f5fe0a4752f0f6404c2c237d4d38c3d6669db | 1098451e5278a7e1bff722d322fd1dedb65c50d1 | refs/heads/master | 2020-04-04T20:24:05.475891 | 2018-11-05T17:21:43 | 2018-11-05T17:21:43 | 156,245,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 965 | java | package com.mastercard.interview.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* SwaggerConfiguration configures a {@link Docket} builder which is intended to be the primary interface into the swagger-springmvc framework.
*/
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.mastercard.interview"))
.paths(PathSelectors.any())
.build();
}
}
| [
"[email protected]"
] | |
6553c6cda146c0cd5252e810587aa0995228e6b8 | 899368ca2332d398fee8112dc5c5cc6a2ca85729 | /java/com/tanmoy/mapreduce/globalMapCounters/CounterMapper.java | 9064f09bd6198e5f2c4b8d40c7c8ce8fb26fd4cf | [] | no_license | Tanmoy248/mapreduce | 7e3c7c74b8dae0c107ee8a52e821b490937608d0 | 932955502921ae15bf7edc705e6240bef6899d32 | refs/heads/master | 2020-04-21T20:10:05.011657 | 2019-02-19T18:29:32 | 2019-02-19T18:29:32 | 169,833,788 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 971 | java | package com.tanmoy.mapreduce.globalMapCounters;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.*;
/**
* Example input line:
* 96.7.4.14 - - [24/Apr/2011:04:20:11 -0400] "GET /cat.jpg HTTP/1.1" 200 12433
*
*/
public class CounterMapper extends
Mapper<LongWritable, Text, Text, IntWritable> {
enum InfoCounter{EMAIL,MOBILE};
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String[] fields = value.toString().split(",");
if (fields.length > 1) {
int email = Integer.parseInt(fields[10]);
int mobile = Integer.parseInt(fields[11]);
if (email==1) {
context.getCounter(InfoCounter.EMAIL).increment(1);
}
if (mobile==1) {
context.getCounter(InfoCounter.MOBILE).increment(1);
}
}
}
} | [
"[email protected]"
] | |
18a3ae1d92196c1fe25c679aa70b88611701fc37 | 9e9db42569685b4fcb0a8d9bd39b47d35c2bc61f | /app/src/main/java/com/learning/rxoperators/MainActivity.java | 30bb3004e536a180cdfcc92f18a20e263036af9c | [] | no_license | saravinfotech/RXOperators | fa94fb13f784d990f8509c4773f126891fc42562 | 678f0b3c710e61969164f3b5f7ef67cdb3a079c3 | refs/heads/master | 2020-07-06T15:13:27.293260 | 2019-08-18T22:44:39 | 2019-08-18T22:44:39 | 203,063,723 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package com.learning.rxoperators;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
| [
"[email protected]"
] | |
90df66ba46fd4e27eeaeef6a1a42a936f6794c01 | 25b2a3f71a94de0da71a02dfd9f5e7c04d2c2643 | /src/StreamExampel.java | c7ecc2939fc9169f21b7ee7c42496ada86cb53c7 | [] | no_license | Andrey9426/Lesson17 | 1ae2c6ef01c6d733b6616825d51fa238632e3a9d | 23572ccfed9ae02ecfe38b698cd2af1822e0b6fe | refs/heads/master | 2020-04-13T12:38:24.724662 | 2018-12-26T18:48:25 | 2018-12-26T18:48:25 | 163,208,285 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,046 | java | import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class StreamExampel {
public static void justRead(){
FileInputStream fis = null;
try {
// fis = new FileInputStream("Test/test.txt");
fis = new FileInputStream("C:\\Users\\Java Core Student 1\\IdeaProjects\\Lesson17\\Test");
//
System.out.println("file size in bytes: " + fis.available());
int content;
while ((content = fis.read())!= -1){
System.out.print((char)content);
}
}catch (IOException e){
System.out.print(e.getMessage());
}finally {
if (fis!= null){
try{
fis.close();
}catch (IOException e){
System.out.print(e.getMessage());
}
}
}
}
public static void readWithReSources(){
try(FileInputStream fis = new FileInputStream("Test1/test.txt")){
System.out.println("file size " + fis.available());
int content;
while ((content = fis.read())!= -1){
System.out.print((char)content);
}
}catch (IOException e){
e.printStackTrace();
}
}
public static void readAndWrite(){
try(FileInputStream fis = new FileInputStream("Test/test.txt");
FileOutputStream fos = new FileOutputStream("Test1\\result.txt")) {
int content;
while ((content = fis.read()) != -1) {
System.out.println((char)content);
fos.write(content);
}
}catch (IOException e){
e.printStackTrace();
}
}
public static void readAndWriteWithoundClosing(){
FileInputStream fis= null;
FileOutputStream fos = null;
try{
fis = new FileInputStream("Test/test.txt");
fos = new FileOutputStream("Test1/test.txt");
int content;
while ((content= fis.read()) != -1){
System.out.println((char)content);
fos.write(content);
}
}catch (IOException e){
e.printStackTrace();
}
}
public static void bufferedInputStream(){
InputStream inStream = null;
BufferedInputStream bis = null;
BufferedOutputStream bas = null;
try{
inStream = new FileInputStream("Test/test.txt");
bis =new BufferedInputStream(inStream);
bas = new BufferedOutputStream(new FileOutputStream("Test/buff_res.txt"));
while(bis.available() > 0){
char c = (char)bis.read();
System.out.println("char : " + c);
bas.write(c);
}
} catch (Exception e){
e.printStackTrace();
}
finally {
if (inStream != null && bis!=null && bas != null){
try{
inStream.close();
bis.close();
bas.close();
}catch (IOException e ){
e.printStackTrace();
}
}
}
}
public static List<String> getLinesfromFile(){
File file =new File("Test/test.txt");
List<String>result = new ArrayList<>();
try(BufferedReader br = new BufferedReader(new FileReader(file))){
String line;
while((line =br.readLine())!= null){
System.out.println(line);
result.add(line);
}
}catch (IOException e){
e.printStackTrace();
}
return result;
}
public static void main(String[] args) {
// justRead();
// readWithReSources();
// readAndWrite();
// readAndWriteWithoundClosing();
// bufferedInputStream();
List<String> file = getLinesfromFile();
for(String s: file){
System.out.println(s);
}
}
}
| [
"[email protected]"
] | |
9f26a50c35772edeae083a66924e6b87dacb6c76 | eb79515694ff22a9b4a06055c2ae7471ec9a62fd | /src/NextWordList.java | 79ef373edb7ded09c67b4a40ef8a2b3f87da25d0 | [] | no_license | BrennerCampos/Markov-Gibberish | b1bdaa2596caac937ba06eecc6d26817a733a8ee | 16066a010819d77819024756aaaebc63fd4e9ac8 | refs/heads/main | 2023-07-16T23:50:57.892269 | 2021-08-20T18:45:28 | 2021-08-20T18:45:28 | 398,372,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,337 | java | public class NextWordList
{
private static class NextWordListElement
{
NextWordListElement next;
String word;
int count;
public NextWordListElement(String str) // constructor : will also include a count var
{
word = str;
next = null;
count = 0;
}
}
private NextWordListElement first; // initializing pointer vars
private NextWordListElement last;
private int size;
// private int count;
public NextWordList()
{
first = null;
last = null;
size = 0;
}
public void foundNextWord(String nextWord) // search for the list for nextWord
{
NextWordListElement current = find(nextWord); // take in word to add to the list, but first check it's not already there
if (current==null) // if the word does NOT exist in our list yet...
{
current = add(nextWord); // ...add it to our NextWordList...
// current.count = 1; // ...and set its count to 1 (first of its kind in our list)
}
// else {
current.count++; // if it does already exist, up it's counter
// }
/*
for (int i = 0; i < size; i++) // move through potentially all of the steps on the list
{
if (!current.word.equals(nextWord)) // if it does NOT find it, add it and set count to 1
{
current=add(nextWord);
count=1;
}
else // if it does find it, increase the count
{
// current = current.next;
current.count++;
}
}
*/
}
private NextWordListElement find(String nextWord) // checking to see if our word is already in the list
{
NextWordListElement current = first; // creating new NextWord element and setting it to the beginning of the list
for (int i = 0; i < size; i++) // move through potentially all of the steps on the list
{
if (current.word.equals(nextWord)) // if it DOES find it...
{
return current; // return in to follow through with "foundNextWord"
}
current=current.next; // otherwise, set the pointer to the next spot and continue dealing with it in "foundNextWord"
}
return null; // if the size is 0, return that it is null
}
public NextWordListElement add(String nextWord)
{
NextWordListElement current = new NextWordListElement(nextWord);
if (first==null) // if there's nothing in the list yet (aka null)
// if (size==0)
{
first=current; //set both list pointers to current capsule with "next word"
}
else
{
last.next = current; // sets new list pointer to after last element
}
last=current;
size++; // increase size of list
// current.count++;
return current; //return current list element with updated pointers
}
public String getRandomWord() // picks a random word within the NextWordList of current word
{
int totalCount= 0;
int runningCount = 0;
NextWordListElement current = first; // start at the beginning of the NextWordList
for (int i = 0; i < size; i++) // iterate as long as the size of the NextWordList for word is
{
totalCount = current.count + totalCount; // adds how many times word is used to totalCount
// if (totalCount<size)
// {
current = current.next; // then move to next element
// }
}
int randomNum = (int)(Math.random() * (totalCount)); // picks a random number from 0 to number of words in current NextWordList
current = first; // set starting position back to 0
for (int j = 0; j < size; j++)
{
runningCount = current.count + runningCount; // add to the running count
if (runningCount >= randomNum) // if we hit the random position or go over it...
{
break; // break out of the loop and return the current word
//return current.word;
}
runningCount = current.count + runningCount; // otherwise, add to the running count...
current = current.next; // and go on to the next element
}
return current.word;
}
public int length() // returns index of the first instance of "str"
{
return size;
}
public void print() // prints to console
{
NextWordListElement current = first;
for (int i = 0; i < size; i++) // move through all of the steps on the list
{
System.out.println("\t" +current.word +" " +current.count); // print out each element in NextWordList as well as it's count
current = current.next; // then move on to next element in list
}
System.out.println();
}
}
| [
"[email protected]"
] | |
92f00b2566a66eac220d964a9d9a0bde0d2b8319 | f752c8cae8db8c8e25d4284c737b95e7772e4e86 | /core/src/main/java/leansecurity/store/UserStore.java | b4f4c49423757650e70db9e25b64de3531a66758 | [
"Apache-2.0"
] | permissive | samgurtman-zz/LeanSecurity | eb72c4f03d82fb0e6415dca85fb8aacc97867728 | 4c32755b0758b0e45bcdbcbffb4630812901d40b | refs/heads/master | 2022-05-08T23:21:37.355066 | 2016-06-13T03:37:37 | 2016-06-13T03:37:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 182 | java | package leansecurity.store;
/**
* Manages users for security filter
*/
public interface UserStore{
User getUserByUsername(String username);
User getUserById(String id);
}
| [
"[email protected]"
] | |
fc78a3b3c9fe148934196d35392eadef99bae809 | bb3809ee6cc87c9af679ac90d2945e92d6f0bfb2 | /java-rdd/src/main/java/com/owp/rdddemo/RddMap.java | b04b3e8496854fc469d52f9bde6b7968ad8cf111 | [] | no_license | lk6678979/owp-spark | c1507c12dabaf66a4ccbff3793b12379445aeb0d | b854e5319a49b512180be0beae325bae300c6b8e | refs/heads/master | 2020-05-25T03:45:35.570107 | 2019-05-30T13:04:34 | 2019-05-30T13:04:34 | 187,611,556 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 843 | java | package com.owp.rdddemo;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.junit.Test;
import java.util.Arrays;
/**
* @描述:
* @公司:
* @作者:
* @版本: 1.0.0
* @日期: 2019-05-27 00:04:01
*/
public class RddMap {
@Test
public void map() {
SparkConf sparkConf = new SparkConf().setAppName("demo").setMaster("local").set("spark.executor.memory", "1g");
JavaSparkContext javaSparkContext = new JavaSparkContext(sparkConf);
JavaRDD<String> rdd = javaSparkContext.parallelize(Arrays.asList("klhk lsad has", "dfsdf sdf", "sdgg hgfh", "yu yds f", "cxvx cvasd"));
JavaRDD<String> mapedRdd = rdd.map(e -> e + "_我被map处理过");
mapedRdd.collect().forEach(e -> System.out.println(e));
}
}
| [
"[email protected]"
] | |
0022d01064129aeb686713038ea3d37d98b67413 | 7bf78067c0acafc179ea04aff6df33acdde11bbb | /src/yt30_lp28/chatapp/impl/MyString.java | 57a2caac9bc4de0a8810f68c9823de96bad09dfa | [] | no_license | aureole-420/sengoku-game | f43d92b3f90d373d941e184ec3f63c65065c3d38 | af0965d4edb36873042238e5e13f21799570d2ce | refs/heads/master | 2022-02-13T22:54:17.203391 | 2019-09-04T01:21:23 | 2019-09-04T01:21:23 | 114,840,693 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 642 | java | package yt30_lp28.chatapp.impl;
import common.ICRMessageType;
import common.IUserMessageType;
/**
* Message type for sending String to remote user, can be used in both user and chat room level.
*/
public class MyString implements IUserMessageType, ICRMessageType {
private static final long serialVersionUID = -7078630287513482645L;
private String data;
/**
* Constructor for MyString, takes a String object as parameter
* @param data the String object
*/
public MyString(String data) {
this.data = data;
}
/**
* Get the data (String object)
* @return the data
*/
public String getData() {
return this.data;
}
}
| [
"[email protected]"
] | |
46ec4ff1c8bca2710fdc86f05640fbbb6a0e8fa4 | 5f26ead101e8cbd1948ef41dda979ab9114abaae | /little program/collection4J/src/main/java/designPatterns/visitor/Visitor.java | c8224223705085f0bc210c966aa092edae449220 | [] | no_license | computerwan/awesome-note | a874740c966b6d046c55f6e96ddf125cbe1e5d5b | b4f3a2a3d575d81d95257d1ac9879af386797075 | refs/heads/master | 2021-01-12T05:07:41.539032 | 2017-03-09T05:58:20 | 2017-03-09T05:58:20 | 77,844,988 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 149 | java | package designPatterns.visitor;
/**
* Created by pengcheng.wan on 2016/8/17.
*/
public interface Visitor {
public void visit(Subject sub);
}
| [
"鹏程万"
] | 鹏程万 |
7b59f4c08b938f269f57ddf1f926fb09565d70b4 | 2b62613f7d285b6f314fa0b0949663c46cde5100 | /app/src/main/java/com/softmiracle/githubmvp/screen/repo/RepoContract.java | 584fd871cf46560d25495c33dfe43e4c1b653d42 | [] | no_license | dnsfrolov/SempraHub | e138b936f46bf771581664a9db3c1a8c98ef339e | 65e2428fa3c4407f34a4721fb6a9179228bda31c | refs/heads/master | 2021-11-11T07:17:11.171946 | 2017-05-16T19:58:18 | 2017-05-16T19:58:18 | 83,134,176 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 508 | java | package com.softmiracle.githubmvp.screen.repo;
import com.softmiracle.githubmvp.data.models.Repo;
import java.util.List;
/**
* Created by dnsfrolov on 24.04.2017.
*/
interface RepoContract {
interface RepoView {
void showProgressIndicator();
void hideProgressIndicator();
void showRepo(List<Repo> repoList);
void showError(Throwable error);
}
interface RepoPresenter {
void loadRepo(String user, int page);
void detachView();
}
}
| [
"[email protected]"
] | |
4936092f92f3b1f2fa37cfe82063e50bdd794464 | 37905f95a3effa04ebae76dd3407249a5fa8e004 | /reactNative/Movie/android/app/src/main/java/com/movie/MainApplication.java | bcd2b502625de743436051ca1fabee077c081572 | [] | no_license | jenny520/web | 5fed9c6278fec050ebad518552d3652eedf22157 | 74694d4c866dbbb53209e4a83625582f4eb91ca3 | refs/heads/master | 2021-05-02T14:47:16.734375 | 2017-06-17T02:27:30 | 2017-06-17T02:27:30 | 52,333,288 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 870 | java | package com.movie;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
| [
"[email protected]"
] | |
4c4694673505308f29d02d5c1ef38559d84006df | 7af846ccf54082cd1832c282ccd3c98eae7ad69a | /ftmap/src/main/java/taxi/nicecode/com/ftmap/generated/package_22/Foo56.java | 67e46bfc80c9fd1855fc9b1cf30dd8b6c447961e | [] | no_license | Kadanza/TestModules | 821f216be53897d7255b8997b426b359ef53971f | 342b7b8930e9491251de972e45b16f85dcf91bd4 | refs/heads/master | 2020-03-25T08:13:09.316581 | 2018-08-08T10:47:25 | 2018-08-08T10:47:25 | 143,602,647 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 268 | java | package taxi.nicecode.com.ftmap.generated.package_22;
public class Foo56 {
public void foo0(){
new Foo55().foo5();
}
public void foo1(){
foo0();
}
public void foo2(){
foo1();
}
public void foo3(){
foo2();
}
public void foo4(){
foo3();
}
public void foo5(){
foo4();
}
} | [
"1"
] | 1 |
ac7f79ed3d09198556d60ab398f548c74cab1da1 | f61e573fc1e80ca8467b26820b8c398543cf6158 | /src/main/java/com/example/constant/error/ErrorDetail.java | c2fae15f384650cc61d6b23e54a6c2502566d3b6 | [] | no_license | tanphat1896/leaveexample | a8d2ed7218007f361c3745eed3b18e362a6b82eb | 8e03febbee5be67716b9e25da70172eea4f06b6d | refs/heads/master | 2020-03-20T17:50:07.974816 | 2018-06-18T16:53:24 | 2018-06-18T16:53:24 | 137,566,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | java | package com.example.constant.error;
public class ErrorDetail {
public static final String DATABASE = "DATABASE OR CONNECTION ERROR";
public static final String INTERNAL = "AN INTERNAL ERROR HAS OCCUR";
public static final String NO_DATA = "NO DATA FOUND FROM DATABASE";
}
| [
"[email protected]"
] | |
9bcdbeb81523f8857c698e1fb09fe284ca07f37d | b2e8aba8ad86eea5e3ecc29921d8cf0c46168cef | /src/main/java/com/townmc/utils/jackson/databind/deser/DataFormatReaders.java | 1ffbad6883696bcc30a1d115ba2fc1813ec97c45 | [] | no_license | fatalwing/utils | 9a25b95b96595abcd16cac79faef072645e1f49a | 9548c86bd73f353c908187aa27d9b59c264a0cac | refs/heads/master | 2022-12-12T17:39:32.392441 | 2021-02-12T02:47:41 | 2021-02-12T02:47:41 | 97,003,764 | 0 | 0 | null | 2022-12-05T23:29:23 | 2017-07-12T12:14:34 | Java | UTF-8 | Java | false | false | 13,095 | java | package com.townmc.utils.jackson.databind.deser;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import com.townmc.utils.jackson.core.*;
import com.townmc.utils.jackson.core.format.*;
import com.townmc.utils.jackson.core.io.MergedStream;
import com.townmc.utils.jackson.databind.*;
/**
* Alternative to {@link DataFormatDetector} that needs to be used when
* using data-binding.
*
* @since 2.1
*/
public class DataFormatReaders
{
/**
* By default we will look ahead at most 64 bytes; in most cases,
* much less (4 bytes or so) is needed, but we will allow bit more
* leniency to support data formats that need more complex heuristics.
*/
public final static int DEFAULT_MAX_INPUT_LOOKAHEAD = 64;
/**
* Ordered list of readers which both represent data formats to
* detect (in precedence order, starting with highest) and contain
* factories used for actual detection.
*/
protected final ObjectReader[] _readers;
/**
* Strength of match we consider to be good enough to be used
* without checking any other formats.
* Default value is {@link MatchStrength#SOLID_MATCH},
*/
protected final MatchStrength _optimalMatch;
/**
* Strength of minimal match we accept as the answer, unless
* better matches are found.
* Default value is {@link MatchStrength#WEAK_MATCH},
*/
protected final MatchStrength _minimalMatch;
/**
* Maximum number of leading bytes of the input that we can read
* to determine data format.
*<p>
* Default value is {@link #DEFAULT_MAX_INPUT_LOOKAHEAD}.
*/
protected final int _maxInputLookahead;
/*
/**********************************************************
/* Construction
/**********************************************************
*/
public DataFormatReaders(ObjectReader... detectors) {
this(detectors, MatchStrength.SOLID_MATCH, MatchStrength.WEAK_MATCH,
DEFAULT_MAX_INPUT_LOOKAHEAD);
}
public DataFormatReaders(Collection<ObjectReader> detectors) {
this(detectors.toArray(new ObjectReader[detectors.size()]));
}
private DataFormatReaders(ObjectReader[] detectors,
MatchStrength optMatch, MatchStrength minMatch,
int maxInputLookahead)
{
_readers = detectors;
_optimalMatch = optMatch;
_minimalMatch = minMatch;
_maxInputLookahead = maxInputLookahead;
}
/*
/**********************************************************
/* Fluent factories for changing match settings
/**********************************************************
*/
public DataFormatReaders withOptimalMatch(MatchStrength optMatch) {
if (optMatch == _optimalMatch) {
return this;
}
return new DataFormatReaders(_readers, optMatch, _minimalMatch, _maxInputLookahead);
}
public DataFormatReaders withMinimalMatch(MatchStrength minMatch) {
if (minMatch == _minimalMatch) {
return this;
}
return new DataFormatReaders(_readers, _optimalMatch, minMatch, _maxInputLookahead);
}
public DataFormatReaders with(ObjectReader[] readers) {
return new DataFormatReaders(readers, _optimalMatch, _minimalMatch, _maxInputLookahead);
}
public DataFormatReaders withMaxInputLookahead(int lookaheadBytes)
{
if (lookaheadBytes == _maxInputLookahead) {
return this;
}
return new DataFormatReaders(_readers, _optimalMatch, _minimalMatch, lookaheadBytes);
}
/*
/**********************************************************
/* Fluent factories for changing underlying readers
/**********************************************************
*/
public DataFormatReaders with(DeserializationConfig config)
{
final int len = _readers.length;
ObjectReader[] r = new ObjectReader[len];
for (int i = 0; i < len; ++i) {
r[i] = _readers[i].with(config);
}
return new DataFormatReaders(r, _optimalMatch, _minimalMatch, _maxInputLookahead);
}
public DataFormatReaders withType(JavaType type)
{
final int len = _readers.length;
ObjectReader[] r = new ObjectReader[len];
for (int i = 0; i < len; ++i) {
r[i] = _readers[i].forType(type);
}
return new DataFormatReaders(r, _optimalMatch, _minimalMatch, _maxInputLookahead);
}
/*
/**********************************************************
/* Public API
/**********************************************************
*/
/**
* Method to call to find format that content (accessible via given
* {@link InputStream}) given has, as per configuration of this detector
* instance.
*
* @return Matcher object which contains result; never null, even in cases
* where no match (with specified minimal match strength) is found.
*/
public Match findFormat(InputStream in) throws IOException
{
return _findFormat(new AccessorForReader(in, new byte[_maxInputLookahead]));
}
/**
* Method to call to find format that given content (full document)
* has, as per configuration of this detector instance.
*
* @return Matcher object which contains result; never null, even in cases
* where no match (with specified minimal match strength) is found.
*/
public Match findFormat(byte[] fullInputData) throws IOException
{
return _findFormat(new AccessorForReader(fullInputData));
}
/**
* Method to call to find format that given content (full document)
* has, as per configuration of this detector instance.
*
* @return Matcher object which contains result; never null, even in cases
* where no match (with specified minimal match strength) is found.
*
* @since 2.1
*/
public Match findFormat(byte[] fullInputData, int offset, int len) throws IOException
{
return _findFormat(new AccessorForReader(fullInputData, offset, len));
}
/*
/**********************************************************
/* Overrides
/**********************************************************
*/
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append('[');
final int len = _readers.length;
if (len > 0) {
sb.append(_readers[0].getFactory().getFormatName());
for (int i = 1; i < len; ++i) {
sb.append(", ");
sb.append(_readers[i].getFactory().getFormatName());
}
}
sb.append(']');
return sb.toString();
}
/*
/**********************************************************
/* Internal methods
/**********************************************************
*/
private Match _findFormat(AccessorForReader acc) throws IOException
{
ObjectReader bestMatch = null;
MatchStrength bestMatchStrength = null;
for (ObjectReader f : _readers) {
acc.reset();
MatchStrength strength = f.getFactory().hasFormat(acc);
// if not better than what we have so far (including minimal level limit), skip
if (strength == null || strength.ordinal() < _minimalMatch.ordinal()) {
continue;
}
// also, needs to better match than before
if (bestMatch != null) {
if (bestMatchStrength.ordinal() >= strength.ordinal()) {
continue;
}
}
// finally: if it's good enough match, we are done
bestMatch = f;
bestMatchStrength = strength;
if (strength.ordinal() >= _optimalMatch.ordinal()) {
break;
}
}
return acc.createMatcher(bestMatch, bestMatchStrength);
}
/*
/**********************************************************
/* Helper classes
/**********************************************************
*/
/**
* We need sub-class here as well, to be able to access efficiently.
*/
protected class AccessorForReader extends InputAccessor.Std
{
public AccessorForReader(InputStream in, byte[] buffer) {
super(in, buffer);
}
public AccessorForReader(byte[] inputDocument) {
super(inputDocument);
}
public AccessorForReader(byte[] inputDocument, int start, int len) {
super(inputDocument, start, len);
}
public Match createMatcher(ObjectReader match, MatchStrength matchStrength)
{
return new Match(_in, _buffer, _bufferedStart, (_bufferedEnd - _bufferedStart),
match, matchStrength);
}
}
/**
* Result class, similar to {@link DataFormatMatcher}
*/
public static class Match
{
protected final InputStream _originalStream;
/**
* Content read during format matching process
*/
protected final byte[] _bufferedData;
/**
* Pointer to the first byte in buffer available for reading
*/
protected final int _bufferedStart;
/**
* Number of bytes available in buffer.
*/
protected final int _bufferedLength;
/**
* Factory that produced sufficient match (if any)
*/
protected final ObjectReader _match;
/**
* Strength of match with {@link #_match}
*/
protected final MatchStrength _matchStrength;
protected Match(InputStream in, byte[] buffered,
int bufferedStart, int bufferedLength,
ObjectReader match, MatchStrength strength)
{
_originalStream = in;
_bufferedData = buffered;
_bufferedStart = bufferedStart;
_bufferedLength = bufferedLength;
_match = match;
_matchStrength = strength;
}
/*
/**********************************************************
/* Public API, simple accessors
/**********************************************************
*/
/**
* Accessor to use to see if any formats matched well enough with
* the input data.
*/
public boolean hasMatch() { return _match != null; }
/**
* Method for accessing strength of the match, if any; if no match,
* will return {@link MatchStrength#INCONCLUSIVE}.
*/
public MatchStrength getMatchStrength() {
return (_matchStrength == null) ? MatchStrength.INCONCLUSIVE : _matchStrength;
}
/**
* Accessor for {@link JsonFactory} that represents format that data matched.
*/
public ObjectReader getReader() { return _match; }
/**
* Accessor for getting brief textual name of matched format if any (null
* if none). Equivalent to:
*<pre>
* return hasMatch() ? getMatch().getFormatName() : null;
*</pre>
*/
public String getMatchedFormatName() {
return _match.getFactory().getFormatName();
}
/*
/**********************************************************
/* Public API, factory methods
/**********************************************************
*/
/**
* Convenience method for trying to construct a {@link JsonParser} for
* parsing content which is assumed to be in detected data format.
* If no match was found, returns null.
*/
public JsonParser createParserWithMatch() throws IOException
{
if (_match == null) {
return null;
}
JsonFactory jf = _match.getFactory();
if (_originalStream == null) {
return jf.createParser(_bufferedData, _bufferedStart, _bufferedLength);
}
return jf.createParser(getDataStream());
}
/**
* Method to use for accessing input for which format detection has been done.
* This <b>must</b> be used instead of using stream passed to detector
* unless given stream itself can do buffering.
* Stream will return all content that was read during matching process, as well
* as remaining contents of the underlying stream.
*/
public InputStream getDataStream() {
if (_originalStream == null) {
return new ByteArrayInputStream(_bufferedData, _bufferedStart, _bufferedLength);
}
return new MergedStream(null, _originalStream, _bufferedData, _bufferedStart, _bufferedLength);
}
}
}
| [
"[email protected]"
] | |
0e4b0f7a3b15a3aec093a7a0381f946541327605 | 45ca2c940f7a330e3dc442daa0f321d2c2925bdf | /ProduceConsumerUsingConditionVariable/src/Application.java | bd8ba69a85a5a3d788a2ce78c8acdaf2ae90ced2 | [] | no_license | mihutlorenzo/P.D.A | 4ae3d983a7316b1be4900a54cda2fad30eb2f8af | ae61280774f85b3c035f62a5f52b1cae3180b283 | refs/heads/master | 2020-03-08T11:55:30.075963 | 2018-05-10T06:00:40 | 2018-05-10T06:00:40 | 127,189,471 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,024 | java |
public class Application {
static final int PRODUCERNUMBER = 3;
static final int CONSUMERNUMBER = 2;
static Buffer buffer = new Buffer();
static Thread[] producers = new Thread[PRODUCERNUMBER];
static Thread[] consumers = new Thread[CONSUMERNUMBER];
static void main(String[] args) {
for(int i = 0;i<PRODUCERNUMBER ;i++) {
producers[i] = new Thread(new Producer(buffer,i));
}
for(int i = 0;i<CONSUMERNUMBER;i++) {
consumers[i] = new Thread(new Consumer(buffer,i));
}
for(int i = 0;i<PRODUCERNUMBER ;i++) {
producers[i].start();
}
for(int i = 0;i<CONSUMERNUMBER;i++) {
consumers[i].start();
}
for(int i = 0;i<PRODUCERNUMBER ;i++) {
try {
producers[i].join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for(int i = 0;i<CONSUMERNUMBER;i++) {
try {
consumers[i].join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
48ff189d599a93892d7c2a8be264788215497caf | 74b47b895b2f739612371f871c7f940502e7165b | /aws-java-sdk-sesv2/src/main/java/com/amazonaws/services/simpleemailv2/model/Destination.java | 8d8cc08d6bd4d5b14595d850b7c7600b9a9185c2 | [
"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 | 12,305 | 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.simpleemailv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
* <p>
* An object that describes the recipients for an email.
* </p>
* <note>
* <p>
* Amazon SES does not support the SMTPUTF8 extension, as described in <a
* href="https://tools.ietf.org/html/rfc6531">RFC6531</a>. For this reason, the <i>local part</i> of a destination email
* address (the part of the email address that precedes the @ sign) may only contain <a
* href="https://en.wikipedia.org/wiki/Email_address#Local-part">7-bit ASCII characters</a>. If the <i>domain part</i>
* of an address (the part after the @ sign) contains non-ASCII characters, they must be encoded using Punycode, as
* described in <a href="https://tools.ietf.org/html/rfc3492.html">RFC3492</a>.
* </p>
* </note>
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sesv2-2019-09-27/Destination" target="_top">AWS API
* Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Destination implements Serializable, Cloneable, StructuredPojo {
/**
* <p>
* An array that contains the email addresses of the "To" recipients for the email.
* </p>
*/
private java.util.List<String> toAddresses;
/**
* <p>
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* </p>
*/
private java.util.List<String> ccAddresses;
/**
* <p>
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* </p>
*/
private java.util.List<String> bccAddresses;
/**
* <p>
* An array that contains the email addresses of the "To" recipients for the email.
* </p>
*
* @return An array that contains the email addresses of the "To" recipients for the email.
*/
public java.util.List<String> getToAddresses() {
return toAddresses;
}
/**
* <p>
* An array that contains the email addresses of the "To" recipients for the email.
* </p>
*
* @param toAddresses
* An array that contains the email addresses of the "To" recipients for the email.
*/
public void setToAddresses(java.util.Collection<String> toAddresses) {
if (toAddresses == null) {
this.toAddresses = null;
return;
}
this.toAddresses = new java.util.ArrayList<String>(toAddresses);
}
/**
* <p>
* An array that contains the email addresses of the "To" recipients for the email.
* </p>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setToAddresses(java.util.Collection)} or {@link #withToAddresses(java.util.Collection)} if you want to
* override the existing values.
* </p>
*
* @param toAddresses
* An array that contains the email addresses of the "To" recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withToAddresses(String... toAddresses) {
if (this.toAddresses == null) {
setToAddresses(new java.util.ArrayList<String>(toAddresses.length));
}
for (String ele : toAddresses) {
this.toAddresses.add(ele);
}
return this;
}
/**
* <p>
* An array that contains the email addresses of the "To" recipients for the email.
* </p>
*
* @param toAddresses
* An array that contains the email addresses of the "To" recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withToAddresses(java.util.Collection<String> toAddresses) {
setToAddresses(toAddresses);
return this;
}
/**
* <p>
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* </p>
*
* @return An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
*/
public java.util.List<String> getCcAddresses() {
return ccAddresses;
}
/**
* <p>
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* </p>
*
* @param ccAddresses
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
*/
public void setCcAddresses(java.util.Collection<String> ccAddresses) {
if (ccAddresses == null) {
this.ccAddresses = null;
return;
}
this.ccAddresses = new java.util.ArrayList<String>(ccAddresses);
}
/**
* <p>
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* </p>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setCcAddresses(java.util.Collection)} or {@link #withCcAddresses(java.util.Collection)} if you want to
* override the existing values.
* </p>
*
* @param ccAddresses
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withCcAddresses(String... ccAddresses) {
if (this.ccAddresses == null) {
setCcAddresses(new java.util.ArrayList<String>(ccAddresses.length));
}
for (String ele : ccAddresses) {
this.ccAddresses.add(ele);
}
return this;
}
/**
* <p>
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* </p>
*
* @param ccAddresses
* An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withCcAddresses(java.util.Collection<String> ccAddresses) {
setCcAddresses(ccAddresses);
return this;
}
/**
* <p>
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* </p>
*
* @return An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
*/
public java.util.List<String> getBccAddresses() {
return bccAddresses;
}
/**
* <p>
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* </p>
*
* @param bccAddresses
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
*/
public void setBccAddresses(java.util.Collection<String> bccAddresses) {
if (bccAddresses == null) {
this.bccAddresses = null;
return;
}
this.bccAddresses = new java.util.ArrayList<String>(bccAddresses);
}
/**
* <p>
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* </p>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setBccAddresses(java.util.Collection)} or {@link #withBccAddresses(java.util.Collection)} if you want to
* override the existing values.
* </p>
*
* @param bccAddresses
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withBccAddresses(String... bccAddresses) {
if (this.bccAddresses == null) {
setBccAddresses(new java.util.ArrayList<String>(bccAddresses.length));
}
for (String ele : bccAddresses) {
this.bccAddresses.add(ele);
}
return this;
}
/**
* <p>
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* </p>
*
* @param bccAddresses
* An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Destination withBccAddresses(java.util.Collection<String> bccAddresses) {
setBccAddresses(bccAddresses);
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 (getToAddresses() != null)
sb.append("ToAddresses: ").append(getToAddresses()).append(",");
if (getCcAddresses() != null)
sb.append("CcAddresses: ").append(getCcAddresses()).append(",");
if (getBccAddresses() != null)
sb.append("BccAddresses: ").append(getBccAddresses());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Destination == false)
return false;
Destination other = (Destination) obj;
if (other.getToAddresses() == null ^ this.getToAddresses() == null)
return false;
if (other.getToAddresses() != null && other.getToAddresses().equals(this.getToAddresses()) == false)
return false;
if (other.getCcAddresses() == null ^ this.getCcAddresses() == null)
return false;
if (other.getCcAddresses() != null && other.getCcAddresses().equals(this.getCcAddresses()) == false)
return false;
if (other.getBccAddresses() == null ^ this.getBccAddresses() == null)
return false;
if (other.getBccAddresses() != null && other.getBccAddresses().equals(this.getBccAddresses()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getToAddresses() == null) ? 0 : getToAddresses().hashCode());
hashCode = prime * hashCode + ((getCcAddresses() == null) ? 0 : getCcAddresses().hashCode());
hashCode = prime * hashCode + ((getBccAddresses() == null) ? 0 : getBccAddresses().hashCode());
return hashCode;
}
@Override
public Destination clone() {
try {
return (Destination) 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.simpleemailv2.model.transform.DestinationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}
| [
""
] | |
d8586d4ecb7bc1e9a6ee748b9e0a4a013217e48c | 0ac69eee3e890f9980fe9985dbd78b2402c3a08e | /20170513/src/Chapter9/TestScannerKeyBoard.java | 25a9782f5c707329d7e788032b78f2338cd69992 | [] | no_license | ltt19921124/learnjava | f14f6c61139ea5ae1e15f6f596ec99aee16ef20b | 4122013e8d75874fbd00009f684ac45e4c89c1ef | refs/heads/master | 2021-01-19T14:29:13.925023 | 2017-05-24T10:48:31 | 2017-05-24T10:48:31 | 88,137,154 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 430 | java | package Chapter9;
import java.util.Scanner;
public class TestScannerKeyBoard {
public static void main(String[] args) {
//System.in代表标准输入,就是键盘输入
Scanner sc = new Scanner(System.in);
//下面增加下面一行将只把回车键作为分隔符
sc.useDelimiter("\n");
while (sc.hasNext()) {
//输出输入项
System.out.println("键盘输入的内容为:" + sc.next());
}
}
}
| [
"[email protected]"
] | |
c50876b0015e6b754f72d9e25d8c09501f543512 | c94a74c0b697e1a5d20aae2a4d2bd8dc672edf83 | /src/main/java/frc/team2989/robot/commands/TeleopDriveCommand.java | 9f3ecf4be705fd0a563a6d8370c3e1dde6bab2a4 | [] | no_license | frcteam2989/2018Code | 07f6b1715dad85c77e3dc9598510e74efedf9c6a | 59bc990baf2092c6fe6dbfa7275bdbc4e7b95c6b | refs/heads/master | 2021-03-22T04:34:40.665136 | 2018-02-27T23:14:54 | 2018-02-27T23:14:54 | 116,494,405 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 775 | java | package frc.team2989.robot.commands;
import edu.wpi.first.wpilibj.command.Command;
import frc.team2989.robot.Robot;
import frc.team2989.robot.oi.GTADrive;
public class TeleopDriveCommand extends Command {
private GTADrive gtaDrive;
public TeleopDriveCommand() {
requires(Robot.driveTrain);
}
@Override
protected void initialize() {
this.gtaDrive = new GTADrive(Robot.oi.getDriveStick());
}
@Override
protected void execute() {
gtaDrive.driveRobot();
Robot.arm.move();
Robot.climbing.moveTapeMeasure();
}
@Override
protected boolean isFinished() {
return false;
}
@Override
protected void end() {
}
@Override
protected void interrupted() {
}
}
| [
"[email protected]"
] | |
f8c993fb143d7f5630a3ef93e2c085a417abba2e | 1bbc6bc4ef8e10a8f52cea11470fd08892848446 | /AndroidApp/7report_diary/app/src/main/java/com/example/a7report_diary/MainActivity.java | 4a8329596c99facc6a1482cc8c42ebff1da436af | [] | no_license | yeonseo/AndroidWebAppEdu | 8b826c49b2e3ef4e48d72860824d82c901037261 | f38ba2ee4a1135ee9ac3dca7fc0b55929b784e0d | refs/heads/master | 2022-04-18T00:10:19.959584 | 2020-03-12T06:21:40 | 2020-03-12T06:21:40 | 194,628,540 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,179 | java | package com.example.a7report_diary;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity implements DatePicker.OnDateChangedListener, View.OnClickListener, View.OnFocusChangeListener, TextWatcher, View.OnLongClickListener {
DatePicker datePicker;
EditText editText;
Button btnSave, btnExit;
String filename, diary;
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
datePicker = findViewById(R.id.datePicker);
editText = findViewById(R.id.editText);
btnSave = findViewById(R.id.btnSave);
btnExit = findViewById(R.id.btnExit);
datePickerSetCurrent();
datePicker.setOnDateChangedListener(this);
editText.addTextChangedListener(this);
btnSave.setOnClickListener(this);
btnSave.setOnLongClickListener(this);
}
private void datePickerSetCurrent() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
filename = String.valueOf(year) + String.valueOf(month) + String.valueOf(day) + ".txt";
readDiary();
datePicker.init(year, month, day, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
}
});
toastDisplay(filename);
}
//datePicker Action
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
int month = monthOfYear + 1;
filename = String.valueOf(year) + String.valueOf(month) + String.valueOf(dayOfMonth) + ".txt";
readDiary();
}
//edtText Action
@Override
public void onClick(View v) {
diary = editText.getText().toString().trim();
if (diary.length() > 0) {
switch (btnSave.getText().toString()) {
case "저장하기":
case "수정하기":
buttonTextSetting(2);
saveDiary();
break;
case "삭제하기":
deleteDiary();
editText.setText("");
break;
}
} else {
toastDisplay("Text empty!!");
}
}//end of onClick , btnSave Action
@Override
public boolean onLongClick(View v) {
diary = editText.getText().toString().trim();
if (diary.length() > 0&&btnSave.getText().toString().equals("수정하기")) {
buttonTextSetting(3);
} else {
toastDisplay("Text empty!!");
}
return false;
}//end of onLongClick , btnSave Action
private void saveDiary() {
try {
FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
diary = editText.getText().toString().trim();
fos.write(diary.getBytes());
fos.close();
toastDisplay("system write : " + filename);
} catch (Exception e) {
toastDisplay("Save diary fail");
e.printStackTrace();
}
}//end of saveDiary , btnSave Action
private void readDiary() {
FileInputStream fis = null;
try {
fis = openFileInput(filename);
byte[] diary = new byte[fis.available()];
fis.read(diary);
editText.setText(new String(diary));
buttonTextSetting(2);
} catch (Exception e) {
toastDisplay("No diary");
editText.setText("");
buttonTextSetting(1);
e.printStackTrace();
}
}//end of onDateChanged , datePicker Action
private void deleteDiary() {
File file = new File(getFilesDir().getAbsolutePath() + "/" + filename);
if (file.exists()) {
file.delete();
toastDisplay(filename + "삭제 완료");
}
buttonTextSetting(1);
}
private void buttonTextSetting(int num) {
String btntxt = btnSave.getText().toString();
switch (num) {
case 1:
btnSave.setText("저장하기");
btnSave.setClickable(false);
break;
case 2:
btnSave.setText("수정하기");
btnSave.setClickable(false);
break;
case 3:
btnSave.setText("삭제하기");
btnSave.setClickable(false);
break;
case 4:
btnSave.setClickable(true);
break;
}
}
private void toastDisplay(String message) {
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
}
//editText 변화 감지.
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (editText.getText().length() > 0) {
btnSave.setClickable(true);
}
buttonTextSetting(1);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
buttonTextSetting(4);
}
@Override
public void afterTextChanged(Editable s) {
buttonTextSetting(4);
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
buttonTextSetting(4);
}
}
| [
"[email protected]"
] | |
843a92595c9f613f0a47e7d27c08b1bca636f47e | 1ae584c076f7f3540a0012cf81e9c28d6bedc30a | /src/bi/two/tre/OrderWatcher.java | 752589f83af51c80ac2db763be9e83825e82a201 | [] | no_license | biTst/biTwo | 5d83e231bc0787dd7a4d100ad2781ef850814377 | 5e240f259ea80d662271fc5ee3eb10521e43ef2d | refs/heads/master | 2021-01-24T07:31:58.634184 | 2019-01-29T11:42:44 | 2019-01-29T11:42:44 | 93,350,704 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,983 | java | package bi.two.tre;
import bi.two.exch.Exchange;
import bi.two.exch.OrderBook;
import bi.two.exch.OrderData;
import bi.two.exch.OrderSide;
import bi.two.util.TimeStamp;
import bi.two.util.Utils;
import java.util.concurrent.TimeUnit;
class OrderWatcher extends BaseOrderWatcher {
public static final long MAX_LIVE_OUT_OF_SPREAD = TimeUnit.SECONDS.toMillis(2);
public static final long MAX_LIVE_ON_SPREAD_WITH_OTHERS = TimeUnit.SECONDS.toMillis(4);
public static final long MAX_LIVE_ON_SPREAD = TimeUnit.SECONDS.toMillis(6);
public static final double OUT_OF_SPREAD_PRICE_STEP_RATE = 0.10;
public static final double ON_SPREAD_WITH_OTHERS_PRICE_STEP_RATE = 0.15;
public static final double ON_SPREAD_PRICE_STEP_RATE = 0.20;
public TimeStamp m_outOfTopSpreadStamp = new TimeStamp(0); // time when order becomes out of spread
public TimeStamp m_onTopSpreadAloneStamp = new TimeStamp(0); // time when order appears on spread alone
public TimeStamp m_onTopSpreadWithOthersStamp = new TimeStamp(0); // time when order appears on spread with other
private OrderBook.Spread m_lastTopSpread;
public OrderWatcher(Exchange exchange, RoundNodePlan.RoundStep roundStep) {
super(exchange, roundStep);
}
@Override public String toString() {
return "OrderWatcher: " + m_orderData;
}
@Override public boolean onTimerInt() {
try {
double priceStepRate = 0;
boolean move = false;
long outOfSpreadOld = m_outOfTopSpreadStamp.getPassedMillis();
if (outOfSpreadOld > MAX_LIVE_OUT_OF_SPREAD) {
console("onTimer: order out of top spread already " + m_outOfTopSpreadStamp.getPassed() + ". moving...");
move = true;
priceStepRate = OUT_OF_SPREAD_PRICE_STEP_RATE;
} else {
long onTopSpreadWithOthersOld = m_onTopSpreadWithOthersStamp.getPassedMillis();
if (onTopSpreadWithOthersOld > MAX_LIVE_ON_SPREAD_WITH_OTHERS) {
console("onTimer: order on top spread with others already " + m_onTopSpreadWithOthersStamp.getPassed() + ". moving...");
move = true;
priceStepRate = ON_SPREAD_WITH_OTHERS_PRICE_STEP_RATE;
} else {
long onTopSpreadOld = m_onTopSpreadAloneStamp.getPassedMillis();
if (onTopSpreadOld > MAX_LIVE_ON_SPREAD) {
console("onTimer: order on top spread alone already " + m_onTopSpreadAloneStamp.getPassed() + ". moving...");
move = true;
priceStepRate = ON_SPREAD_PRICE_STEP_RATE;
}
}
}
if (move) {
double minOrderToCreate = m_exchPairData.m_minOrderToCreate.m_value;
double remained = m_orderData.remained();
if (remained >= minOrderToCreate) {
console(" remained=" + Utils.format8(remained) + "; minOrderToCreate=" + minOrderToCreate);
OrderBook orderBook = m_exchPairData.getOrderBook();
OrderBook.Spread topSpread = orderBook.getTopSpread();
double orderPrice = m_orderData.m_price;
double minPriceStep = m_exchPairData.m_minPriceStep;
console(" orderBook.topSpread=" + topSpread + "; orderPrice=" + orderPrice + "; minPriceStep=" + Utils.format8(minPriceStep));
OrderSide side = m_orderData.m_side;
boolean isBuy = side.isBuy();
double askPrice = topSpread.m_askEntry.m_price;
double bidPrice = topSpread.m_bidEntry.m_price;
double topSpreadDiff = askPrice - bidPrice;
double priceStep = topSpreadDiff * priceStepRate;
console(" topSpreadDiff=" + Utils.format8(topSpreadDiff) + ";priceStepRate=" + priceStepRate + "; priceStep=" + Utils.format8(priceStep));
if (priceStep < minPriceStep) {
priceStep = minPriceStep;
console(" priceStep fixed to minPriceStep=" + minPriceStep);
}
double price = isBuy ? bidPrice + priceStep : askPrice - priceStep;
console(" price=" + Utils.format8(price) + "; spread=" + topSpread);
String replaceOrderId = m_orderData.m_orderId;
OrderData orderData = m_orderData.copyForReplace();
orderData.m_price = price;
console(" submitOrderReplace: " + orderData);
if (Tre.SEND_REPLACE) {
orderData.addOrderListener(m_orderListener);
m_orderData = orderData;
boolean sent = m_exchange.submitOrderReplace(replaceOrderId, orderData);
if (sent) {
m_outOfTopSpreadStamp.reset(); // reset
m_onTopSpreadAloneStamp.reset(); // reset
m_onTopSpreadWithOthersStamp.reset(); // reset
}
}
} else {
console(" remained " + Utils.format8(remained) + " is too low for move order; minOrderToCreate=" + minOrderToCreate);
}
}
} catch (Exception e) {
String msg = "OrderWatcher.onTimer() error: " + e;
console(msg);
err(msg, e);
}
return (m_state == State.done);
}
@Override protected void onBookUpdatedInt(OrderBook orderBook) {
// console("OrderWatcher.onOrderBookUpdated() orderBook=" + orderBook);
OrderBook.Spread topSpread = orderBook.getTopSpread();
if ((m_lastTopSpread == null) || !topSpread.equals(m_lastTopSpread)) {
double orderPrice = m_orderData.m_price;
console("OrderWatcher.onOrderBookUpdated() changed topSpread=" + topSpread + "; orderPrice: " + Utils.format8(orderPrice));
m_lastTopSpread = topSpread;
OrderSide side = m_orderData.m_side;
boolean isBuy = side.isBuy();
OrderBook.OrderBookEntry entry = isBuy ? topSpread.m_bidEntry : topSpread.m_askEntry;
double sidePrice = entry.m_price;
double delta = sidePrice - orderPrice;
double minPriceStep = m_exchPairData.m_minPriceStep;
log(" side price " + (isBuy ? "buy" : "ask") + "Price=" + Utils.format8(sidePrice)
+ "; delta=" + Utils.format12(delta) + "; minPriceStep=" + Utils.format8(minPriceStep));
if (Math.abs(delta) < (minPriceStep / 2)) {
double entrySize = entry.m_size;
double orderRemained = m_orderData.remained();
console(" order is on spread side. entrySize=" + Utils.format8(entrySize) + "; orderRemained=" + Utils.format8(orderRemained));
if (entrySize > orderRemained) {
m_onTopSpreadWithOthersStamp.startIfNeeded();
m_onTopSpreadAloneStamp.reset();
console(" !!! some other order on the same price for " + m_onTopSpreadWithOthersStamp.getPassed());
} else {
m_onTopSpreadAloneStamp.startIfNeeded();
m_onTopSpreadWithOthersStamp.reset();
console(" all fine - order on spread side alone for " + m_onTopSpreadAloneStamp.getPassed());
}
m_outOfTopSpreadStamp.reset();
} else { // need order price update
m_outOfTopSpreadStamp.startIfNeeded();
m_onTopSpreadAloneStamp.reset();
m_onTopSpreadWithOthersStamp.reset();
console(" !!! need order price update for " + m_outOfTopSpreadStamp.getPassed());
}
}
}
}
| [
"[email protected]"
] | |
ae554c251870b848f1bd20c4d9c524b7dac1494c | bad75659a25d9b8c5fb9c86284a7986685af46c8 | /src/main/java/Columns.java | 93dcdf240cf467a1b093fcc5fc8dee943b6593c1 | [] | no_license | screamcol/TransactionAnalyser | 2eedd97fd84b2f1bebefe2b7e1689428fc7e99ef | 389a2b5c6a2dd2444c1107b5eaeeb5f94559ec21 | refs/heads/main | 2023-01-04T16:19:34.992259 | 2020-11-02T08:52:22 | 2020-11-02T08:52:22 | 307,335,376 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 234 | java | public enum Columns {
ID(0), Date(1), AMOUNT(2), MERCHANT(3), TYPE(4), RELATED_TRANSACTION(5);
private int index;
Columns(int index) {
this.index = index;
}
int getIndex() {
return index;
}
}
| [
"[email protected]"
] | |
e9ab6df8f6507e8e2d433743132cfd7e389abefb | 4fa1b9bd4d45acbd0231d345e9b68a26665acfc1 | /app/src/main/java/com/cmed/health/app/configs/CorsLocalConfig.java | 75844ad4cda82f69972d6b58151fce64f4c60977 | [] | no_license | tanvirgh/SpringBoot-Oauth2-Angular-JWT | 39b266f8ca0a7a0c575b3bf6f75a162c12321303 | 8db6298e3c074906897dadeb48fe8ea2efe30fd5 | refs/heads/master | 2022-12-02T18:29:32.691794 | 2020-08-25T13:37:54 | 2020-08-25T13:37:54 | 289,834,507 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,041 | java | package com.cmed.health.app.configs;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Creator : Tanvir Chowdhury
* Date : 2020-08-23
*/
@Configuration
public class CorsLocalConfig {
// check https://spring.io/blog/2015/06/08/cors-support-in-spring-framework
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH")
.allowCredentials(false).maxAge(3600);
}
};
}
}
| [
"[email protected]"
] | |
317656783c6a759e567876f8949bd602020846c6 | 8cd256ee1bb6cbab636ffb4a535de4f630259567 | /java/src/CompaniesInterviewExperience/Walmart/KthSmallest.java | 94dbfd1d07166183352d5dca4c91d31003b8d716 | [] | no_license | MehakDogra7/CrackingTheCodingInterview | 9dec10d5a2d5aac83d3a30ae76fdf6b259c0b6d2 | 1e0e2815aa8c451ac3b4a6ed2cf1bbe3983fa726 | refs/heads/master | 2023-02-23T21:32:26.147358 | 2021-01-29T16:04:27 | 2021-01-29T16:04:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,321 | java | package CompaniesInterviewExperience.Walmart;
import java.util.Arrays;
public class KthSmallest {
public static void main(String[] args) {
int[] arr = {12, 3, 5, 7, 4, 19, 26};
int n = arr.length, k = 3;
System.out.println(k + "'th smallest element is " + new KthSmallest().kthSmallest(arr, 0, n - 1, k));
}
public int kthSmallest(int[] arr, int l, int r, int k) {
if (k < 1 || k > r - l + 1) return Integer.MAX_VALUE; // If k is more than number of elements in array
int n = r - l + 1, i;
int[] median = new int[(n + 4) / 5]; // There will be floor((n+4)/5) groups;
for (i = 0; i < n / 5; i++) {
median[i] = findMedian(arr, l + i * 5, 5);
}
if (i * 5 < n) { // For last group with less than 5 elements
median[i] = findMedian(arr, l + i * 5, n % 5);
i++;
}
int medOfMed = (i == 1) ? median[i - 1] : kthSmallest(median, 0, i - 1, i / 2);
int pos = partition(arr, l, r, medOfMed);
if (pos - l == k - 1) return arr[pos]; // If position is same as k
else if (pos - l > k - 1) return kthSmallest(arr, l, pos - 1, k); // If position is more, recur for left
return kthSmallest(arr, pos + 1, r, k - pos + l - 1); // Else recur for right subarray
}
public int findMedian(int[] arr, int i, int n) {
if (i <= n)
Arrays.sort(arr, i, n); // Sort the array
else
Arrays.sort(arr, n, i);
return arr[n / 2]; // Return middle element
}
public void swap(int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public int partition(int[] arr, int l, int r, int x) {
// It searches for x in arr[l..r], and partitions the array around x.
// Search for x in arr[l..r] and move it to end
int i;
for (i = l; i < r; i++)
if (arr[i] == x)
break;
swap(arr, i, r);
// Standard partition algorithm
i = l;
for (int j = l; j <= r - 1; j++) {
if (arr[j] <= x) {
swap(arr, i, j);
i++;
}
}
swap(arr, i, r);
return i;
}
}
| [
"[email protected]"
] | |
ff0b2a85b9d0a3fda3a9194c13e0a92801184009 | 5bad0bc5a1928324619fc227fd0254bca1f64f55 | /Android/newOnPe/libmodule/src/main/java/com/dev/voltsoft/lib/utility/UtilityUI.java | a8662083d4ffdc7a6616dfcdc6ba3b9d0f28f6b6 | [] | no_license | marukang/newOnPe | e00754d4a0396559efe608c6a0589a4ad705c664 | 1451f0c028a7a459bf71ee2eb70f99ab0f015076 | refs/heads/master | 2023-06-27T12:17:26.500929 | 2021-07-29T09:27:15 | 2021-07-29T09:27:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 61,766 | java | package com.dev.voltsoft.lib.utility;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.text.Editable;
import android.text.InputFilter;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.OvershootInterpolator;
import android.view.animation.Transformation;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.MainThread;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.view.MarginLayoutParamsCompat;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.dev.voltsoft.lib.R;
import com.dev.voltsoft.lib.view.gls.Rotate3dAnimation;
import com.nineoldandroids.view.ViewHelper;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import jp.wasabeef.glide.transformations.BlurTransformation;
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
public class UtilityUI {
private static final int STANDARD_PIXEL_WIDTH = 720;
private static final int STANDARD_PIXEL_HEIGHT = 1230;
private static int mScreenWidth = 0;
private static int mScreenHeight = 0;
public static void installApkFile(Context context, String authority, File file)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri apkUri = null;
if (Build.VERSION.SDK_INT >= 24)
{
Uri uri = FileProvider.getUriForFile(context, authority, file);
intent.setDataAndType(uri, "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
intent.setData(uri);
context.startActivity(intent);
}
else
{
apkUri = Uri.fromFile(file);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.getApplicationContext().startActivity(intent);
}
}
/**
* 현대 단말기의 해상도 기준으로 일치하는 픽셀값을 반환
*
* @param c
* @param pixel
* @return
*/
public static int conversionWidthPixel(Context c, int pixel)
{
if (mScreenWidth == 0)
{
mScreenWidth = getScreenWidth(c);
}
float conversionRate = mScreenWidth / STANDARD_PIXEL_WIDTH;
return (int) (pixel * conversionRate);
}
/**
* 현대 단말기의 해상도 기준으로 일치하는 픽셀값을 반환
*
*
* @param c
* @param pixel
* @return
*/
public static int conversionHeightPixel(Context c, int pixel)
{
if (mScreenHeight == 0)
{
mScreenHeight= getScreenHeight(c);
}
float conversionRate = mScreenHeight / STANDARD_PIXEL_HEIGHT;
return (int) (pixel * conversionRate);
}
public static void addEmptyTextAsGone(final TextView... textViews)
{
for (TextView textView : textViews)
{
addEmptyTextAsGone(textView);
}
}
public static void addEmptyTextAsGone(final TextView editText)
{
try
{
if (editText != null)
{
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
{
if (TextUtils.isEmpty(charSequence.toString()))
{
editText.setVisibility(View.GONE);
}
else
{
editText.setVisibility(View.VISIBLE);
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static InputFilter getEnglishFilter()
{
return new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int i, int i1, Spanned spanned, int i2, int i3) {
Pattern ps = Pattern.compile("^[a-zA-Z0-9]+$");
if (!ps.matcher(source).matches())
{
return "";
}
return null;
}
};
}
public static InputFilter getKoreanFilter()
{
return new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int i, int i1, Spanned spanned, int i2, int i3) {
Pattern ps = Pattern.compile("^[ㄱ-가-힣]+$");
if (!ps.matcher(source).matches())
{
return "";
}
return null;
}
};
}
public static int getNavigationBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}
public static boolean hasSoftNavigationBar(Context context)
{
boolean hasSoftNavigationBar = false;
ViewConfiguration viewConfig = ViewConfiguration.get(context);
hasSoftNavigationBar = !viewConfig.hasPermanentMenuKey();
// 위 API 로 올바르지 않은 값이 리턴 되는 경우가 있다 (예를들면 G2 단말의 경우)
// 따라서 아래 로직으로 한번 더 확인한다.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
{
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
display.getRealMetrics(realDisplayMetrics);
int realHeight = realDisplayMetrics.heightPixels;
int realWidth = realDisplayMetrics.widthPixels;
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getMetrics(displayMetrics);
int displayHeight = displayMetrics.heightPixels;
int displayWidth = displayMetrics.widthPixels;
hasSoftNavigationBar = (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
}
return hasSoftNavigationBar;
}
public static int getMeasuredWidth(View v) {
return (v == null) ? 0 : v.getMeasuredWidth();
}
public static int getWidth(View v) {
return (v == null) ? 0 : v.getWidth();
}
public static int getWidthWithMargin(View v) {
return getWidth(v) + getMarginHorizontally(v);
}
public static int getStart(View v) {
return getStart(v, false);
}
public static int getStart(View v, boolean withoutPadding) {
if (v == null) {
return 0;
}
if (isLayoutRtl(v)) {
return (withoutPadding) ? v.getRight() - getPaddingStart(v) : v.getRight();
} else {
return (withoutPadding) ? v.getLeft() + getPaddingStart(v) : v.getLeft();
}
}
public static int getEnd(View v) {
return getEnd(v, false);
}
public static int getEnd(View v, boolean withoutPadding) {
if (v == null) {
return 0;
}
if (isLayoutRtl(v)) {
return (withoutPadding) ? v.getLeft() + getPaddingEnd(v) : v.getLeft();
} else {
return (withoutPadding) ? v.getRight() - getPaddingEnd(v) : v.getRight();
}
}
public static int getPaddingStart(View v) {
if (v == null) {
return 0;
}
return ViewCompat.getPaddingStart(v);
}
public static int getPaddingEnd(View v) {
if (v == null) {
return 0;
}
return ViewCompat.getPaddingEnd(v);
}
public static int getPaddingHorizontally(View v) {
if (v == null) {
return 0;
}
return v.getPaddingLeft() + v.getPaddingRight();
}
public static int getMarginStart(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp);
}
public static int getMarginEnd(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginEnd(lp);
}
public static int getMarginHorizontally(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
public static boolean isLayoutRtl(View v) {
return ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
public static int getRatioDimension(Context context, int dimensionId, int standardScreenWidth) {
if (context != null) {
try {
Resources resources = context.getResources();
int dimension = (int) resources.getDimension(dimensionId);
int standardWidth = (int) resources.getDimension(standardScreenWidth);
return ((dimension * getScreenWidth(context)) / standardWidth);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}
public static int getDimension(Context context, int resourcesId) {
if (context != null) {
try {
Resources resources = context.getResources();
return (int) resources.getDimension(resourcesId);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}
public static int getMeasuredHeight(Context context, View view) {
if (context instanceof Activity) {
WindowManager windowManager = ((Activity) context).getWindowManager();
return getMeasuredHeight(windowManager.getDefaultDisplay(), view);
} else {
return 0;
}
}
public static int getMeasuredWidth(Context context, View view) {
if (context instanceof Activity) {
WindowManager windowManager = ((Activity) context).getWindowManager();
return getMeasuredWidth(windowManager.getDefaultDisplay(), view);
} else {
return 0;
}
}
public static int getMeasuredHeight(Display display, View view) {
if (display != null && view != null) {
view.measure(display.getWidth(), display.getHeight());
return view.getMeasuredHeight();
} else {
return 0;
}
}
public static int getMeasuredWidth(Display display, View view) {
if (display != null && view != null) {
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
return view.getMeasuredWidth();
} else {
return 0;
}
}
public static SpannableString getColorSpannableString(String str, int color) {
SpannableString spannableString = new SpannableString(str);
spannableString.setSpan(
new ForegroundColorSpan(color), 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannableString;
}
public static int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= Build.VERSION_CODES.M)
{
return ContextCompat.getColor(context, id);
}
else
{
return context.getResources().getColor(id);
}
}
public static Drawable getDrawable(Context context, int id) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return context.getDrawable(id);
} else {
return context.getResources().getDrawable(id);
}
}
public static void setClickListner(View view, View.OnClickListener clickListener) {
if (view != null) {
view.setOnClickListener(clickListener);
}
}
public static View getActivityRoot(Activity activity) {
return ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
}
public static void setKeyboardEventListener
(final Activity activity, final KeyBoardVisibilityListener eventListener) {
if (activity == null) {
return;
}
int softInputMethod = activity.getWindow().getAttributes().softInputMode;
if (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE != softInputMethod &&
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED != softInputMethod){
return;
}
if (eventListener == null) {
return;
}
final View activityRoot = getActivityRoot(activity);
final ViewTreeObserver.OnGlobalLayoutListener layoutListener =
new ViewTreeObserver.OnGlobalLayoutListener() {
private boolean wasOpened = false;
@Override
public void onGlobalLayout() {
Rect r = new Rect();
activityRoot.getWindowVisibleDisplayFrame(r);
int screenHeight = activityRoot.getRootView().getHeight();
if (screenHeight > 0 && hasSoftNavigationBar(activity)) {
int navigationBarHeight = getNavigationBarHeight(activity);
screenHeight -= navigationBarHeight;
}
int keyboardHeight = screenHeight - (r.bottom);
boolean isOpen = (keyboardHeight >= 100);
if (wasOpened != isOpen) {
wasOpened = isOpen;
if (wasOpened) {
eventListener.onKeyBoardShow(keyboardHeight);
} else {
eventListener.onKeyBoardHide();
}
}
}
};
activityRoot.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener);
activity.getApplication()
.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity ac, Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(Activity ac) {
}
@Override
public void onActivityResumed(Activity ac) {
}
@Override
public void onActivityPaused(Activity ac) {
}
@Override
public void onActivityStopped(Activity ac) {
}
@Override
public void onActivitySaveInstanceState(Activity ac, Bundle outState) {
}
@Override
public void onActivityDestroyed(Activity ac) {
if (activity == ac) {
setGlobalLayoutListenerRemoved(activityRoot, layoutListener);
activity.getApplication().unregisterActivityLifecycleCallbacks(this);
}
}
});
}
public static float convertDpToPx(Context context, float dp) {
Resources res = context.getResources();
return dp * (res.getDisplayMetrics().densityDpi / 160f);
}
public static void setText(TextView view, String strText) {
if (view != null) {
view.setText(strText);
}
}
public static void setText(TextView view, SpannableStringBuilder strText) {
if (view != null) {
view.setText(strText);
}
}
public static int getScreenWidth(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return displayMetrics.widthPixels;
}
public static int getScreenHeight(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return displayMetrics.heightPixels;
}
/**
* 더블 클릭 여부 체크.
*/
private static long mlLastClickTime = 0;
/**
*
* @return {@link Boolean}
*/
public static boolean isNotDoubleClick() {
if (SystemClock.elapsedRealtime() - mlLastClickTime <= ViewConfiguration.getDoubleTapTimeout()) {
return true;
}
mlLastClickTime = SystemClock.elapsedRealtime();
return false;
}
/**
* @auhtor woozie
*
* @param view
* @param globalLayoutListener
*/
public static void setGlobalLayoutListenerRemoved(View view , ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener) {
if (view == null) {
return;
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(globalLayoutListener);
} else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(globalLayoutListener);
}
}
public static <LM extends LinearLayoutManager> int getScrollOffsetY(LM lm , int position) {
int scrollOffset = 0;
if (lm != null) {
View v = lm.findViewByPosition(position);
scrollOffset = (int) ViewHelper.getY(v);
}
return scrollOffset;
}
public static <LM extends LinearLayoutManager> int getScrollOffsetX(LM lm , int position) {
int scrollOffset = 0;
if (lm != null) {
View v = lm.findViewByPosition(position);
scrollOffset = (int) ViewHelper.getX(v);
}
return scrollOffset;
}
/**
* @auhtor woozie
*
* @param lm
* @param position
* @param <LM>
* @return
*/
public static <LM extends LinearLayoutManager> int getListItemVisiblePercent(LM lm , int position) {
int visiblePercent = 0;
if (lm != null && position >= 0) {
View v = lm.findViewByPosition(position);
visiblePercent = getViewVisiblePercent(v);
}
return visiblePercent;
}
public static int getGlobalRectTop(View view) {
if (view != null) {
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
Log.d("confirm" , ">> confirm getGlobalRectTop rect.top " + rect.top);
return rect.top;
}
Log.d("confirm" , ">> confirm getGlobalRectTop view is null ");
return 0;
}
/**
*
* @auhtor woozie
*
* @param view
* @return
*/
public static int getViewVisiblePercent(View view) {
int visiblePercent = 0;
try {
if (view != null) {
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
visiblePercent = (rect.height() * 100 / view.getHeight());
}
} catch (Exception e) {
}
return visiblePercent;
}
/**
*
* @auhtor woozie
*
* @param view
* @return
*/
public static int getViewVisibleHeight(View view) {
int visiblePercent = 0;
try {
if (view != null) {
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
return rect.height();
}
} catch (Exception e) {
}
return visiblePercent;
}
public static void setViewText(View view , String text) {
if (view != null) {
if (view instanceof TextView) {
((TextView) view).setText(text);
}
}
}
/**
*
* @param recyclerView
* RecyclerView
*/
public static void setListNotifyDataSetChanged(RecyclerView recyclerView) {
if (recyclerView == null) {
return;
}
if (recyclerView.getAdapter() != null) {
recyclerView.getAdapter().notifyDataSetChanged();
}
}
/**
*
* @param view
* @param y
*/
public static void setY(View view , float y) {
if (view != null) {
ViewHelper.setY(view , y);
}
}
/**
*
* @param view
* View
* @param transitionY
* float
*/
public static void setTranslationY(View view, float transitionY) {
if (view != null) {
ViewHelper.setTranslationY(view, transitionY);
}
}
/**
*
* @param view
* @param scaleX
*/
public static void setScaleX(View view , float scaleX) {
if (view != null) {
ViewHelper.setScaleX(view , scaleX);
}
}
/**
*
* @param view
* @param scaleY
*/
public static void setScaleY(View view , float scaleY) {
if (view != null) {
ViewHelper.setScaleY(view , scaleY);
}
}
/**
*
* @param view
* View
* @param transitionX
* float
*/
public static void setTranslationX(View view, float transitionX) {
if (view != null) {
ViewHelper.setTranslationX(view, transitionX);
}
}
public static Drawable getDrawable(Context paramContext, String paramString) throws IOException {
return Drawable.createFromStream(paramContext.getAssets().open("drawable/" + paramString), null);
}
/**
*
* @param view
* View
* @return float
*/
public static float getY(View view) {
float viewY = 0.0f;
if (view != null) {
viewY = ViewHelper.getY(view);
}
return viewY;
}
/**
*
* @param view
* View
* @return float
*/
public static float getTranslationY(View view) {
float transitionY = 0.0f;
if (view != null) {
transitionY = ViewHelper.getTranslationY(view);
}
return transitionY;
}
/**
*
* @param button
* Button
* @param bEnable
* boolean
*/
public static void setButtonTextEnable(Button button, boolean bEnable) {
if (button == null) {
return;
}
setEnabled(button, bEnable);
if (bEnable) {
button.setTextColor(Color.parseColor("#ffffff"));
} else {
button.setTextColor(Color.parseColor("#bbbbbb"));
}
}
/**
* View에 Enabled 값 세팅.
*
* @param vTarget
* : Target View
* @param bEnabled
* : Enabled 여부
*/
public static void setEnabled(View vTarget, boolean bEnabled) {
if (vTarget == null) {
return;
}
vTarget.setEnabled(bEnabled);
}
/**
*
* @param textView
* TextView
* @param bEffect
* boolean
*/
public static void setTextLineBoldEffect(TextView textView, boolean bEffect) {
if (bEffect) {
textView.setTextColor(Color.parseColor("#333333"));
} else {
textView.setTextColor(Color.parseColor("#bbbbbb"));
}
}
/**
*
* @param textView
* TextView
* @param bEffect
* boolean
*/
public static void setUnderlineEffect(TextView textView, boolean bEffect) {
String content = textView.getText().toString();
SpannableString spannableString = new SpannableString(content);
if (bEffect) {
spannableString.setSpan(new UnderlineSpan(), 0, content.length(), 0);
} else {
spannableString.removeSpan(new UnderlineSpan());
}
textView.setText(spannableString);
}
public static void setAlpha(View view , float alpha) {
if (view != null) {
ViewHelper.setAlpha(view , alpha);
}
}
public static void setViewTag(View view , Object o) {
if (view != null) {
view.setTag(o);
}
}
public static void setVisibility(View view , int visible) {
if (view != null) {
view.setVisibility(visible);
}
}
public static void setClickListener(View view, View.OnClickListener clickListener) {
if (view != null) {
view.setOnClickListener(clickListener);
}
}
public static void setClickListener(View view, Object tag, View.OnClickListener clickListener) {
if (view != null) {
view.setTag(tag);
view.setOnClickListener(clickListener);
}
}
public static void setBackgroundBitmapDrawable(ImageView imageView , Bitmap bitmap) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN){
imageView.setBackground(new BitmapDrawable(imageView.getResources() , bitmap));
} else {
imageView.setBackgroundDrawable(new BitmapDrawable(imageView.getResources() , bitmap));
}
}
public static void setBackGroundDrawable(View view , int resourceId) {
if (view != null) {
try {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN){
view.setBackground(ContextCompat.getDrawable(view.getContext(), resourceId));
} else {
view.setBackgroundDrawable(ContextCompat.getDrawable(view.getContext(), resourceId));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void setBackGroundDrawable(View view , Drawable drawable) {
if (view != null)
{
try
{
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN)
{
view.setBackground(drawable);
}
else
{
view.setBackgroundDrawable(drawable);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public static Bitmap getBlurImage(Context context , Bitmap sentBitmap , int radius)
{
Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
final RenderScript renderScript = RenderScript.create(context);
final Allocation inputallocation = Allocation.createFromBitmap(renderScript, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
final Allocation outputallocation = Allocation.createTyped(renderScript, inputallocation.getType());
final ScriptIntrinsicBlur scriptIntrinsicBlur = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
scriptIntrinsicBlur.setRadius(radius);
scriptIntrinsicBlur.setInput(inputallocation);
scriptIntrinsicBlur.forEach(outputallocation);
outputallocation.copyTo(bitmap);
return bitmap;
}
public static void setThumbNailImageView(Context context , ImageView imageView , String thumnailPath)
{
try
{
if (!TextUtils.isEmpty(thumnailPath))
{
RequestOptions options = new RequestOptions()
.centerCrop();
Glide.with(context).load(thumnailPath)
.apply(options)
.transition(withCrossFade())
.into(imageView);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void setThumbNailImageView(ImageView imageView , String thumnailPath, RequestListener requestListener)
{
try
{
if (!TextUtils.isEmpty(thumnailPath))
{
RequestOptions options = new RequestOptions()
.centerCrop();
Glide.with(imageView.getContext()).load(thumnailPath)
.apply(options)
.transition(withCrossFade())
.listener(requestListener)
.into(imageView);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void setThumbNailTopRoundedImageView(final Context context , final ImageView imageView , String thumnailPath) {
try {
if (!TextUtils.isEmpty(thumnailPath))
{
int radius = (int) context.getResources().getDimension(R.dimen.dp25);
RequestOptions options = new RequestOptions()
.centerCrop()
.transforms(new RoundedCorners(radius));
Glide.with(context).load(thumnailPath)
.apply(options)
.transition(withCrossFade())
.into(imageView);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setThumbNailRoundedImageView(final Context context , final ImageView imageView , String thumbNailPath , int radiusDimension) {
try {
if (!TextUtils.isEmpty(thumbNailPath))
{
int radius = (int) context.getResources().getDimension(radiusDimension);
RequestOptions options = new RequestOptions()
.centerCrop()
.transforms(new RoundedCorners(radius));
Glide.with(context).load(thumbNailPath)
.apply(options)
.transition(withCrossFade())
.into(imageView);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setThumbNailTopRoundedBlurImageView(final Context context , final ImageView imageView , String thumnailPath) {
try {
if (!TextUtils.isEmpty(thumnailPath))
{
int radius = (int) context.getResources().getDimension(R.dimen.dp25);
RequestOptions options = new RequestOptions()
.centerCrop()
.transforms(
new RoundedCorners(radius),
new BlurTransformation(context));
Glide.with(context).load(thumnailPath)
.apply(options)
.transition(withCrossFade())
.into(imageView);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static View getViewByPosition(int position, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (position < firstListItemPosition || position > lastListItemPosition) {
return listView.getAdapter().getView(position, null, listView);
} else {
final int childIndex = position - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
public static void setForceKeyboardDown(Context context, EditText editText) {
try
{
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null)
{
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
inputMethodManager.hideSoftInputFromInputMethod(editText.getWindowToken(), 0);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 소프트키 Show/Hide
*
* @param oContext
* @param oView
* : windowToken source
* @param bShow
*/
public static void setSoftKeyVisibility(Context oContext, View oView, boolean bShow) {
if (oContext == null) {
return;
}
if (oView == null) {
return;
}
InputMethodManager oInputMethodManager = (InputMethodManager) oContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (oInputMethodManager == null) {
return;
}
if (bShow) {
oView.requestFocus();
oInputMethodManager.showSoftInput(oView, InputMethodManager.SHOW_IMPLICIT);
} else {
oInputMethodManager.hideSoftInputFromWindow(oView.getApplicationWindowToken(), 0);
}
}
/**
* @author woozie
*
*/
public static int getWidthOfScreen(Context context)
{
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics.widthPixels;
}
/**
* @author woozie
*
*/
public static int getHeightOfScreen(Context context)
{
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics.heightPixels;
}
@MainThread
public static void set3dRotateAnim(final ViewGroup viewGroup) {
if (viewGroup == null) {
return;
}
final float centerX = viewGroup.getWidth() / 2.0f;
final float centerY = viewGroup.getHeight() / 10.0f;
if (viewGroup.getChildCount() < 2) {
return;
}
final View backView = viewGroup.getChildAt(0);
final View frontView = viewGroup.getChildAt(1);
Rotate3dAnimation rotate3dAnimation = new Rotate3dAnimation(0f , 90f, centerX, centerY, 600.0f , true);
rotate3dAnimation.setDuration(200);
rotate3dAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
backView.setVisibility(View.VISIBLE);
backView.bringToFront();
frontView.setVisibility(View.INVISIBLE);
Rotate3dAnimation rotate3dAnimationnext = new Rotate3dAnimation(90f, 180f, centerX, centerY , 600.0f , false);
rotate3dAnimationnext.setDuration(200);
viewGroup.startAnimation(rotate3dAnimationnext);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
viewGroup.startAnimation(rotate3dAnimation);
}
/**
* @author woozie
*
*/
public static void setAnimationYFrom(Context context, View view, float desty) {
Animator animator = ObjectAnimator.ofFloat(view, "Y", ViewHelper.getY(view) + desty, ViewHelper.getY(view));
animator.setDuration(400);
animator.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
animator.start();
}
/**
* @author woozie
*
*/
public static void setAnimationYStart(Context context, View view, float desty) {
Animator animator = ObjectAnimator.ofFloat(view, "Y", ViewHelper.getY(view), desty);
animator.setDuration(400);
animator.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
animator.start();
}
public static void setAnimationEffectBounceRemove(View view) {
if (view != null)
{
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 1.0f, 1.05f , 0.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 1.0f, 1.05f , 0.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.start();
}
}
public static void setAnimationEffectBounceRemoveAndGone(final View view) {
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 1.0f, 1.05f , 0.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 1.0f, 1.05f , 0.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
setVisibility(view , View.GONE);
}
});
animatorSet.start();
}
public static void setAnimationEffectBounceRemove(View view , final Runnable runnable) {
if (view != null) {
float scaleX = 0;
float scaleY = 0;
scaleX = ViewHelper.getScaleX(view);
scaleY = ViewHelper.getScaleX(view);
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", scaleX, 1.0f, 1.05f , 0.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", scaleY, 1.0f, 1.05f , 0.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (runnable != null) {
runnable.run();
}
}
});
animatorSet.start();
}
}
public static void setAnimationEffectBounceRemove(View view , int startDelay , final Runnable runnable) {
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 1.0f, 1.05f , 0.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 1.0f, 1.05f , 0.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.setStartDelay(startDelay);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (runnable != null) {
runnable.run();
}
}
});
animatorSet.start();
}
/**
* @author woozie
*
*/
public static void setAnimationEffectBounce(View view) {
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 1.0f, 1.6f , 0.6f , 1.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 1.0f, 1.6f , 0.6f , 1.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.setInterpolator(new OvershootInterpolator());
animatorSet.start();
}
/**
* @author woozie
*
*/
public static void setAnimationEffectAppearBounce(final View view) {
ViewHelper.setScaleX(view , 0.0f);
ViewHelper.setScaleY(view , 0.0f);
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 0.0f, 1.1f , 0.95f , 1.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 0.0f, 1.1f , 0.95f , 1.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
setVisibility(view , View.VISIBLE);
}
});
animatorSet.start();
}
public static void setAnimationEffectAppearBounce(final View view , int duration) {
ViewHelper.setScaleX(view , 0.0f);
ViewHelper.setScaleY(view , 0.0f);
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 0.0f, 1.1f , 0.95f , 1.0f);
animator0.setDuration(duration);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 0.0f, 1.1f , 0.95f , 1.0f);
animator1.setDuration(duration);
animatorSet.playTogether(animator0, animator1);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
setVisibility(view , View.VISIBLE);
}
});
animatorSet.start();
}
public static void setAnimationEffectFadeAwayWithMovingTop(final View view, int delay , final Runnable runnable) {
if (view != null) {
AnimatorSet animatorSet = new AnimatorSet();
int screenHeight = getHeightOfScreen(view.getContext());
int screenHeightPivot = (screenHeight / 2);
int transitionY0 = (screenHeightPivot * 3) / 6;
int transitionY1 = (screenHeightPivot * 4) / 6;
Animator animator0 = ObjectAnimator.ofFloat(view, "TranslationY", ViewHelper.getTranslationY(view), -transitionY0 , -transitionY1);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getScaleX(view), 1.0f , 1.0f , 0.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.setInterpolator(AnimationUtils.loadInterpolator(view.getContext() , android.R.anim.decelerate_interpolator));
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animatorSet.start();
}
}
public static void setAnimationEffectFadeAwayWithMovingTop(final View view, final Runnable runnable) {
if (view != null) {
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "TranslationY", 100 , 30 , 10 , 0);
animator0.setDuration(1500);
Animator animator1 = ObjectAnimator.ofFloat(view, "Alpha", 0.0f , 1.0f);
animator1.setDuration(300);
animatorSet.playTogether(animator0, animator1);
animatorSet.setInterpolator(AnimationUtils.loadInterpolator(view.getContext() , android.R.anim.decelerate_interpolator));
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
setVisibility(view , View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animatorSet.start();
}
}
/**
* @author woozie
*
*/
public static void setAnimationEffectAppearBounce(final View view, final Runnable runnable) {
if (view != null) {
ViewHelper.setScaleX(view , 0.0f);
ViewHelper.setScaleY(view , 0.0f);
Animator animator2 = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getScaleX(view), 0.0f, 1.0f);
animator2.setDuration(500);
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator0.setDuration(1000);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator1.setDuration(1000);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animator0, animator1 , animator2);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
view.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animatorSet.start();
}
}
public static void setAnimationEffectAppearBounce(final View view, int startDelay , final Runnable runnable) {
if (view != null) {
ViewHelper.setScaleX(view , 0.0f);
ViewHelper.setScaleY(view , 0.0f);
Animator animator2 = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getScaleX(view), 0.0f, 1.0f);
animator2.setDuration(500);
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator0.setDuration(1000);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator1.setDuration(1000);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animator0, animator1 , animator2);
animatorSet.setStartDelay(startDelay);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
view.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animatorSet.start();
}
}
public static void setAnimationEffectAppearBounceAlpha(final View view) {
if (view != null) {
view.setVisibility(View.VISIBLE);
ViewHelper.setScaleX(view , 0.0f);
ViewHelper.setScaleY(view , 0.0f);
AnimatorSet animatorSet = new AnimatorSet();
Animator animator2 = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getScaleX(view), 0.0f, 1.0f);
animator2.setDuration(500);
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator0.setDuration(1000);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 0.0f, 1.05f , 0.95f , 1.0f);
animator1.setDuration(1000);
animatorSet.playTogether(animator0, animator1 , animator2);
animatorSet.start();
}
}
public static void setAnimationEffectBounce(final View view, final Runnable runnable) {
if (view != null) {
AnimatorSet animatorSet = new AnimatorSet();
Animator animator0 = ObjectAnimator.ofFloat(view, "ScaleX", ViewHelper.getScaleX(view), 1.0f, 0.9f , 1.05f , 1.0f);
animator0.setDuration(600);
Animator animator1 = ObjectAnimator.ofFloat(view, "ScaleY", ViewHelper.getScaleY(view), 1.0f, 0.9f , 1.05f , 1.0f);
animator1.setDuration(600);
animatorSet.playTogether(animator0, animator1);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
view.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animatorSet.start();
}
}
public static void setAnimationEffectAlphaRemoved(View view) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), 0.0f);
animator.setDuration(500);
animator.start();
}
/**
* @author woozie
*
*/
public static void setAnimationEffectAlpha(View view) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), 0.2f, 1.0f);
animator.setDuration(500);
animator.start();
}
public static void setAnimationEffectAlpha(View view , float targetAlphaValue) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), targetAlphaValue);
animator.setDuration(500);
animator.start();
}
/**
* @author woozie
*
*/
public static void setAnimationEffectAlpha(View view, final Runnable runnable) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), 0.2f, 1.0f);
animator.setDuration(500);
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animator.start();
}
/**
* @author woozie
*
*/
public static void setAnimationEffectAlpha(final View view, int duration , final Runnable runnable) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", 0.0f, 1.0f);
animator.setDuration(duration);
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
setVisibility(view , View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
animator.start();
}
public static void setAnimationEffectAlpha(final View view , float targetAlphaValue , final Runnable runnable) {
Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), targetAlphaValue);
animator.setDuration(500);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (runnable != null) {
runnable.run();
}
}
});
animator.start();
}
public static void setAnimationEffectAlpha(final View view , int startDelay , float targetAlphaValue , final Runnable runnable) {
final Animator animator = ObjectAnimator.ofFloat(view, "Alpha", ViewHelper.getAlpha(view), targetAlphaValue);
animator.setDuration(500);
animator.setStartDelay(startDelay);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (runnable != null) {
runnable.run();
}
}
});
new Handler(view.getContext().getMainLooper()).post(new Runnable() {
@Override
public void run() {
animator.start();
}
});
}
/**
* @author woozie
*
*/
public static void setAnimationEffectResize(Context context, View view, int toWidth, int toHeight) {
int width = view.getLayoutParams().width;
int height = view.getLayoutParams().height;
AnimationResize animationResize = new AnimationResize(view, width, height, toWidth, toHeight);
animationResize.setDuration(600);
animationResize.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
view.startAnimation(animationResize);
}
/**
* @author woozie
*
*/
public static void setAnimationEffectResize(Context context, View view, int toWidth, int toHeight, final Runnable runnable) {
AnimationResize animationResize = new AnimationResize(view, view.getWidth(), view.getHeight(), toWidth, toHeight);
animationResize.setDuration(400);
animationResize.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
animationResize.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
new Handler().postDelayed(runnable, 200);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
});
view.startAnimation(animationResize);
}
/**
* @author woozie
*
*/
public static void setAnimationEffectResizeWidth(View view, int toWidth) {
AnimationResize animationResize = new AnimationResize(view, view.getWidth(), view.getHeight(), toWidth, view.getHeight());
animationResize.setDuration(200);
view.startAnimation(animationResize);
}
/**
* @author woozie
*
*/
public static void setAnimationEffectResizeHeight(Context context, View view, int toHeight) {
AnimationResize animationResize = new AnimationResize(view, view.getWidth(), view.getHeight(), view.getWidth(), toHeight);
animationResize.setDuration(600);
animationResize.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
view.startAnimation(animationResize);
}
/**
* @author woozie
*
*/
public static void setAnimationEffectResizeHeight(Context context, View view, int toHeight, final Runnable runnable) {
AnimationResize animationResize = new AnimationResize(view, view.getWidth(), view.getHeight(), view.getWidth(), toHeight);
animationResize.setDuration(600);
animationResize.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.decelerate_interpolator));
animationResize.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
new Handler().postDelayed(runnable, 100);
}
});
view.startAnimation(animationResize);
}
/**
* @author woozie
*
*/
public static class AnimationResize extends Animation {
private View moview;
private float motoheight;
private float mofromheight;
private float motowidth;
private float mofromwidth;
public AnimationResize(View view, float fromWidth, float fromHeight, float toWidth, float toHeight) {
motoheight = toHeight;
motowidth = toWidth;
mofromheight = fromHeight;
mofromwidth = fromWidth;
moview = view;
setDuration(300);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float height = (motoheight - mofromheight) * interpolatedTime + mofromheight;
float width = (motowidth - mofromwidth) * interpolatedTime + mofromwidth;
moview.getLayoutParams().height = (int) height;
moview.getLayoutParams().width = (int) width;
moview.requestLayout();
}
}
}
| [
"[email protected]"
] | |
8740e1b7658a7e5079bd38582d0c81ae6fad0fa0 | fc6bc99acab1e31c58a98ac5d4b4000f236f7a76 | /android/app/src/main/java/com/novalog/toque/MainApplication.java | c215ee8ff69359d73b9e4e08298dd2be0a575975 | [
"MIT"
] | permissive | xtealer/rn-toque | 1dc81b7ecf41fd8141807577ad6ed1f37dabe9ce | b7b57155f8bd8cf683bb51cf60b0453a15042b39 | refs/heads/master | 2022-10-23T03:59:51.642269 | 2020-04-24T03:35:32 | 2020-04-24T03:35:32 | 255,502,089 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,726 | java | package com.novalog.toque;
import android.app.Application;
import android.net.Uri;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.novalog.toque.generated.BasePackageList;
import org.unimodules.adapters.react.ReactAdapterPackage;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.Package;
import org.unimodules.core.interfaces.SingletonModule;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
public class MainApplication extends Application implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
new BasePackageList().getPackageList(), null);
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
| [
"[email protected]"
] | |
ce87ebd04ef1d21bd9563423dbe81fa0850cefd4 | 1d6db04bae12ddf27a11bd9c1584e58e235ebc0a | /src/main/java/com/zhangqiang/sqgl/websocket/snake/Snake.java | d552e8100f720449aff005f6dd955fd28788a15c | [] | no_license | duwanqiebi/Bookmarks_Manager | e027564664bfe13231a1325cf7deb91b40e79cd7 | 10af01f96148da7ea6757e0eb54af805a7ebac4b | refs/heads/master | 2021-01-16T23:06:15.855592 | 2017-04-11T08:32:15 | 2017-04-11T08:32:15 | 58,466,033 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,919 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zhangqiang.sqgl.websocket.snake;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
public class Snake {
private static final int DEFAULT_LENGTH = 5;
private final int id;
private final WebSocketSession session;
private Direction direction;
private int length = DEFAULT_LENGTH;
private Location head;
private final Deque<Location> tail = new ArrayDeque<Location>();
private final String hexColor;
public Snake(int id, WebSocketSession session) {
this.id = id;
this.session = session;
this.hexColor = SnakeUtils.getRandomHexColor();
resetState();
}
private void resetState() {
this.direction = Direction.NONE;
this.head = SnakeUtils.getRandomLocation();
this.tail.clear();
this.length = DEFAULT_LENGTH;
}
private synchronized void kill() throws Exception {
resetState();
sendMessage("{'type': 'dead'}");
}
private synchronized void reward() throws Exception {
this.length++;
sendMessage("{'type': 'kill'}");
}
protected void sendMessage(String msg) throws Exception {
this.session.sendMessage(new TextMessage(msg));
}
public synchronized void update(Collection<Snake> snakes) throws Exception {
Location nextLocation = this.head.getAdjacentLocation(this.direction);
if (nextLocation.x >= SnakeUtils.PLAYFIELD_WIDTH) {
nextLocation.x = 0;
}
if (nextLocation.y >= SnakeUtils.PLAYFIELD_HEIGHT) {
nextLocation.y = 0;
}
if (nextLocation.x < 0) {
nextLocation.x = SnakeUtils.PLAYFIELD_WIDTH;
}
if (nextLocation.y < 0) {
nextLocation.y = SnakeUtils.PLAYFIELD_HEIGHT;
}
if (this.direction != Direction.NONE) {
this.tail.addFirst(this.head);
if (this.tail.size() > this.length) {
this.tail.removeLast();
}
this.head = nextLocation;
}
handleCollisions(snakes);
}
private void handleCollisions(Collection<Snake> snakes) throws Exception {
for (Snake snake : snakes) {
boolean headCollision = this.id != snake.id
&& snake.getHead().equals(this.head);
boolean tailCollision = snake.getTail().contains(this.head);
if (headCollision || tailCollision) {
kill();
if (this.id != snake.id) {
snake.reward();
}
}
}
}
public synchronized Location getHead() {
return this.head;
}
public synchronized Collection<Location> getTail() {
return this.tail;
}
public synchronized void setDirection(Direction direction) {
this.direction = direction;
}
public synchronized String getLocationsJson() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(this.head.x),
Integer.valueOf(this.head.y)));
for (Location location : this.tail) {
sb.append(',');
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x),
Integer.valueOf(location.y)));
}
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id),
sb.toString());
}
public int getId() {
return this.id;
}
public String getHexColor() {
return this.hexColor;
}
}
| [
"[email protected]"
] | |
e4abf990c0122469cb545cd65c31846e951c704f | 3bae1297357f39b007d2437f7ea31ea22565de0a | /twelvemonkeys-servlet/src/main/java/com/twelvemonkeys/servlet/ServletResponseStreamDelegate.java | 1c29a951bd473bae26803f15978ae6b69c405373 | [] | no_license | lokling/TwelveMonkeys | 4be50db432f2397998b9c88ca89a210ea11c5495 | 261c6f803870108b6e49f7d501f648724d0a1804 | refs/heads/master | 2021-01-17T05:04:44.455734 | 2009-12-27T15:34:13 | 2009-12-27T15:34:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,858 | java | /*
* Copyright (c) 2008, Harald Kuhr
* 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 "TwelveMonkeys" 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.twelvemonkeys.servlet;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.OutputStream;
/**
* A delegate for handling stream support in wrapped servlet responses.
*
* @author <a href="mailto:[email protected]">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-servlet/src/main/java/com/twelvemonkeys/servlet/ServletResponseStreamDelegate.java#2 $
*/
public class ServletResponseStreamDelegate {
private Object mOut = null;
protected final ServletResponse mResponse;
public ServletResponseStreamDelegate(ServletResponse pResponse) {
if (pResponse == null) {
throw new IllegalArgumentException("response == null");
}
mResponse = pResponse;
}
// NOTE: Intentionally NOT threadsafe, as one request/response should be
// handled by one thread ONLY.
public final ServletOutputStream getOutputStream() throws IOException {
if (mOut == null) {
OutputStream out = createOutputStream();
mOut = out instanceof ServletOutputStream ? out : new OutputStreamAdapter(out);
}
else if (mOut instanceof PrintWriter) {
throw new IllegalStateException("getWriter() allready called.");
}
return (ServletOutputStream) mOut;
}
// NOTE: Intentionally NOT threadsafe, as one request/response should be
// handled by one thread ONLY.
public final PrintWriter getWriter() throws IOException {
if (mOut == null) {
// NOTE: getCharacterEncoding may should not return null
OutputStream out = createOutputStream();
String charEncoding = mResponse.getCharacterEncoding();
mOut = new PrintWriter(charEncoding != null ? new OutputStreamWriter(out, charEncoding) : new OutputStreamWriter(out));
}
else if (mOut instanceof ServletOutputStream) {
throw new IllegalStateException("getOutputStream() allready called.");
}
return (PrintWriter) mOut;
}
/**
* Returns the {@code OutputStream}.
* Override this method to provide a decoreated outputstream.
* This method is guaranteed to be invoked only once for a request/response.
* <P/>
* This implementation simply returns the output stream from the wrapped
* response.
*
* @return the {@code OutputStream} to use for the response
* @throws IOException if an I/O exception occurs
*/
protected OutputStream createOutputStream() throws IOException {
return mResponse.getOutputStream();
}
public void flushBuffer() throws IOException {
if (mOut instanceof ServletOutputStream) {
((ServletOutputStream) mOut).flush();
}
else if (mOut != null) {
((PrintWriter) mOut).flush();
}
}
public void resetBuffer() {
// TODO: Is this okay? Probably not... :-)
mOut = null;
}
}
| [
"[email protected]"
] | |
8c09fa8cb0f06c54cb5205b3cb1e95e81204c39b | 72aa9ae048ea035ea6b65b56d953e91d7c479940 | /src/main/java/cn/tpson/device/watch/cmd/InSosCmd.java | 56e7263f7b552aebf55f4e200c25648f91321500 | [] | no_license | kulucode/KuluCloudServer | 91d54d3b50749729a91774ed1fb4689aa5e93795 | 56ff501c21e292d94027323c4dc542f4357e9a2f | refs/heads/master | 2020-03-18T13:33:53.061508 | 2018-08-24T10:10:29 | 2018-08-24T10:10:29 | 134,792,396 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 903 | java | package cn.tpson.device.watch.cmd;
import java.util.ArrayList;
import org.apache.mina.core.session.IoSession;
import com.kulu.activemq.MQWatchMessage;
import cn.tpson.device.watch.data.LbsData;
import cn.tpson.device.watch.data.WifiData;
/**
* (cmd:42)SOS警报(WIFI+LBS)
*
* @author tangbin
*
*/
public class InSosCmd extends BaseCommand {
public int baseStationNum = 0;
public ArrayList<LbsData> lbsData = null;
public int wifiNum = 0;
public ArrayList<WifiData> wifiData = null;
public InSosCmd(int baseStationNum, ArrayList<LbsData> lbsData, int wifiNum, ArrayList<WifiData> wifiData) {
this.type = "42";
this.baseStationNum = baseStationNum;
this.lbsData = lbsData;
this.wifiNum = wifiNum;
this.wifiData = wifiData;
}
@Override
public String toCmd() {
return null;
}
@Override
public void handle(IoSession session) {
MQWatchMessage.sendData(this);
}
}
| [
"[email protected]"
] | |
08fd0f6ab34384010e1485158eda9ad0cb85c2ad | 169fd1518b2f7f002b3ffce050dcf2e57c0d2fb8 | /Space-Wars/src/modelo/Estrela.java | 189577e0ffec7e791f3046d9c729c245744c0873 | [] | no_license | PauloFilho-019/Space_Wars-Demo- | 17958f8f06ede69cefc9322d608433888299bd08 | 56cc898cde592b0cb39b58ae8a64ec3a533cd4db | refs/heads/master | 2023-06-11T13:56:31.161614 | 2021-07-02T19:58:07 | 2021-07-02T19:58:07 | 382,449,807 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,493 | java | package modelo;
import java.awt.Image;
import java.awt.Rectangle;
import java.util.List;
import java.util.Random;
import javax.swing.ImageIcon;
public class Estrela {
private Image imagem;
private int x, y;
private int largura, altura;
private boolean isVisivel;
private List<Estrela> tiros;
//Distancia percorrida pelo tiro
private static final int LARGURA = 990;
private static int VELOCIDADE = 4;
public Estrela(int x, int y) {
//Definindo a onde o tiro vai aparecer
this.x = x;
this.y = y;
isVisivel = true;
}
public void load() {
//Definindo a estetica do tiro
ImageIcon referencia = new ImageIcon("C:\\Users\\paulo\\eclipse-workspace\\Space-Wars\\src\\res\\stars.gif");
imagem = referencia.getImage();
this.largura = imagem.getWidth(null);
this.altura = imagem.getHeight(null);
}
public void update() {
if(this.x < 0) {
this.x = largura;
Random a = new Random();
int m = a.nextInt(900);
this.x = m + 1624;
Random r = new Random();
int n = r.nextInt(1268);
this.y = n;
}
this.x -= VELOCIDADE;
}
public boolean isVisivel() {
return isVisivel;
}
public void setVisivel(boolean isVisivel) {
this.isVisivel = isVisivel;
}
public static int getVELOCIDADE() {
return VELOCIDADE;
}
public static void setVELOCIDADE(int vELOCIDADE) {
VELOCIDADE = vELOCIDADE;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public Image getImagem() {
return imagem;
}
}
| [
"[email protected]"
] | |
e83f181e696ef6ce26ed428f79bc683a15531b47 | 9cb524bef0212086ffe2f6f60ccbc6ee832d666d | /crm - 副本/target/tomcat/work/Tomcat/localhost/_/org/apache/jsp/WEB_002dINF/views/setting/loglist_jsp.java | 6f3345fdc214ecce0a36568c8fc1a544988b7dd0 | [] | no_license | Trendisking/javaee21 | 57e1c86a5478993a81537735a9137183c32dca13 | 57123b1a955dc5668abc5809d36cbfba0d3ae3b2 | refs/heads/master | 2020-12-25T15:08:18.244190 | 2016-08-05T03:49:35 | 2016-08-05T03:49:35 | 60,613,635 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 28,477 | java | /*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/7.0.47
* Generated at: 2016-07-12 03:49:32 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp.WEB_002dINF.views.setting;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class loglist_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
static {
_jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(2);
_jspx_dependants.put("/WEB-INF/views/setting/../include/leftSidebar.jsp", Long.valueOf(1468255510000L));
_jspx_dependants.put("/WEB-INF/views/setting/../include/mainHeader.jsp", Long.valueOf(1468249348000L));
}
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname;
private javax.el.ExpressionFactory _el_expressionfactory;
private org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public void _jspInit() {
_005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
public void _jspDestroy() {
_005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody.release();
_005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname.release();
_005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname.release();
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<!--\r\n");
out.write("This is a starter template page. Use this page to start your new project from\r\n");
out.write("scratch. This page gets rid of all links and provides the needed markup only.\r\n");
out.write("-->\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write(" <meta charset=\"utf-8\">\r\n");
out.write(" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n");
out.write(" <title>英雄志-英雄登录日志</title>\r\n");
out.write(" <!-- Tell the browser to be responsive to screen width -->\r\n");
out.write(" <meta content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\" name=\"viewport\">\r\n");
out.write(" <!-- Bootstrap 3.3.6 -->\r\n");
out.write(" <link rel=\"stylesheet\" href=\"/static/bootstrap/css/bootstrap.min.css\">\r\n");
out.write(" <!-- Font Awesome -->\r\n");
out.write("\r\n");
out.write(" <link rel=\"stylesheet\" href=\"/static/dist/css/AdminLTE.min.css\">\r\n");
out.write("\r\n");
out.write(" <link rel=\"stylesheet\" href=\"/static/dist/css/skins/skin-blue.min.css\">\r\n");
out.write(" <link rel=\"stylesheet\" href=\"/static/plugins/datatables/css/dataTables.bootstrap.min.css\">\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("</head>\r\n");
out.write("<body class=\"hold-transition skin-blue sidebar-mini\">\r\n");
out.write("<div class=\"wrapper\">\r\n");
out.write("\r\n");
out.write(" ");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("<header class=\"main-header\">\r\n");
out.write("\r\n");
out.write(" <!-- Logo -->\r\n");
out.write(" <a href=\"index2.html\" class=\"logo\">\r\n");
out.write(" <!-- mini logo for sidebar mini 50x50 pixels -->\r\n");
out.write(" <span class=\"logo-mini\">CBB</span>\r\n");
out.write(" <!-- logo for regular state and mobile devices -->\r\n");
out.write(" <span class=\"logo-lg\"><b>CHEN</b>BIE</span>\r\n");
out.write(" </a>\r\n");
out.write("\r\n");
out.write(" <!-- Header Navbar -->\r\n");
out.write(" <nav class=\"navbar navbar-static-top\" role=\"navigation\">\r\n");
out.write(" <!-- Sidebar toggle button-->\r\n");
out.write(" <a href=\"#\" class=\"sidebar-toggle\" data-toggle=\"offcanvas\" role=\"button\">\r\n");
out.write(" <span class=\"sr-only\">Toggle navigation</span>\r\n");
out.write(" </a>\r\n");
out.write(" <!-- Navbar Right Menu -->\r\n");
out.write(" <div class=\"navbar-custom-menu\">\r\n");
out.write(" <ul class=\"nav navbar-nav\">\r\n");
out.write(" <!-- Messages: style can be found in dropdown.less-->\r\n");
out.write(" <li class=\"dropdown messages-menu\">\r\n");
out.write(" <!-- Menu toggle button -->\r\n");
out.write(" <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\r\n");
out.write(" <i class=\"fa fa-envelope-o\"></i>\r\n");
out.write(" <span class=\"label label-success\">4</span>\r\n");
out.write(" </a>\r\n");
out.write(" <ul class=\"dropdown-menu\">\r\n");
out.write(" <li class=\"header\">You have 4 messages</li>\r\n");
out.write(" <li>\r\n");
out.write(" <!-- inner menu: contains the messages -->\r\n");
out.write(" <ul class=\"menu\">\r\n");
out.write(" <li><!-- start message -->\r\n");
out.write(" <a href=\"#\">\r\n");
out.write(" <div class=\"pull-left\">\r\n");
out.write(" <!-- User Image -->\r\n");
out.write(" <img src=\"/static/dist/img/user2-160x160.jpg\" class=\"img-circle\" alt=\"User Image\">\r\n");
out.write(" </div>\r\n");
out.write(" <!-- Message title and timestamp -->\r\n");
out.write(" <h4>\r\n");
out.write(" Support Team\r\n");
out.write(" <small><i class=\"fa fa-clock-o\"></i> 5 mins</small>\r\n");
out.write(" </h4>\r\n");
out.write(" <!-- The message -->\r\n");
out.write(" <p>Why not buy a new awesome theme?</p>\r\n");
out.write(" </a>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- end message -->\r\n");
out.write(" </ul>\r\n");
out.write(" <!-- /.menu -->\r\n");
out.write(" </li>\r\n");
out.write(" <li class=\"footer\"><a href=\"#\">See All Messages</a></li>\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- /.messages-menu -->\r\n");
out.write("\r\n");
out.write(" <!-- Notifications Menu -->\r\n");
out.write(" <li class=\"dropdown notifications-menu\">\r\n");
out.write(" <!-- Menu toggle button -->\r\n");
out.write(" <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\r\n");
out.write(" <i class=\"fa fa-bell-o\"></i>\r\n");
out.write(" <span class=\"label label-warning\">10</span>\r\n");
out.write(" </a>\r\n");
out.write(" <ul class=\"dropdown-menu\">\r\n");
out.write(" <li class=\"header\">You have 10 notifications</li>\r\n");
out.write(" <li>\r\n");
out.write(" <!-- Inner Menu: contains the notifications -->\r\n");
out.write(" <ul class=\"menu\">\r\n");
out.write(" <li><!-- start notification -->\r\n");
out.write(" <a href=\"#\">\r\n");
out.write(" <i class=\"fa fa-users text-aqua\"></i> 5 new members joined today\r\n");
out.write(" </a>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- end notification -->\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" <li class=\"footer\"><a href=\"#\">View all</a></li>\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- Tasks Menu -->\r\n");
out.write(" <li class=\"dropdown tasks-menu\">\r\n");
out.write(" <!-- Menu Toggle Button -->\r\n");
out.write(" <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\r\n");
out.write(" <i class=\"fa fa-flag-o\"></i>\r\n");
out.write(" <span class=\"label label-danger\">9</span>\r\n");
out.write(" </a>\r\n");
out.write(" <ul class=\"dropdown-menu\">\r\n");
out.write(" <li class=\"header\">You have 9 tasks</li>\r\n");
out.write(" <li>\r\n");
out.write(" <!-- Inner menu: contains the tasks -->\r\n");
out.write(" <ul class=\"menu\">\r\n");
out.write(" <li><!-- Task item -->\r\n");
out.write(" <a href=\"#\">\r\n");
out.write(" <!-- Task title and progress text -->\r\n");
out.write(" <h3>\r\n");
out.write(" Design some buttons\r\n");
out.write(" <small class=\"pull-right\">20%</small>\r\n");
out.write(" </h3>\r\n");
out.write(" <!-- The progress bar -->\r\n");
out.write(" <div class=\"progress xs\">\r\n");
out.write(" <!-- Change the css width attribute to simulate progress -->\r\n");
out.write(" <div class=\"progress-bar progress-bar-aqua\" style=\"width: 20%\" role=\"progressbar\" aria-valuenow=\"20\" aria-valuemin=\"0\" aria-valuemax=\"100\">\r\n");
out.write(" <span class=\"sr-only\">20% Complete</span>\r\n");
out.write(" </div>\r\n");
out.write(" </div>\r\n");
out.write(" </a>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- end task item -->\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" <li class=\"footer\">\r\n");
out.write(" <a href=\"#\">View all tasks</a>\r\n");
out.write(" </li>\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" <!-- User Account Menu -->\r\n");
out.write(" <li class=\"dropdown \">\r\n");
out.write(" <!-- Menu Toggle Button -->\r\n");
out.write(" <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">\r\n");
out.write("\r\n");
out.write(" <!-- hidden-xs hides the username on small devices so only the image appears. -->\r\n");
out.write(" <span class=\"hidden-xs\">");
if (_jspx_meth_shiro_005fprincipal_005f0(_jspx_page_context))
return;
out.write("</span>\r\n");
out.write(" </a>\r\n");
out.write(" <ul class=\"dropdown-menu\">\r\n");
out.write(" <li><a href=\"/user/password\">修改密码</a></li>\r\n");
out.write(" <li><a href=\"/user/log\">登录日志</a></li>\r\n");
out.write(" <li class=\"divider\"></li>\r\n");
out.write(" <li><a href=\"/logout\">安全退出</a> </li>\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write("\r\n");
out.write(" </ul>\r\n");
out.write(" </div>\r\n");
out.write(" </nav>\r\n");
out.write("</header>\r\n");
out.write("\r\n");
out.write(" ");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("<aside class=\"main-sidebar\">\r\n");
out.write("\r\n");
out.write(" <!-- sidebar: style can be found in sidebar.less -->\r\n");
out.write(" <section class=\"sidebar\">\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write(" <ul class=\"sidebar-menu\">\r\n");
out.write(" ");
if (_jspx_meth_shiro_005fhasAnyRoles_005f0(_jspx_page_context))
return;
out.write("\r\n");
out.write(" ");
if (_jspx_meth_shiro_005fhasRole_005f0(_jspx_page_context))
return;
out.write("\r\n");
out.write(" </ul>\r\n");
out.write(" <!-- /.sidebar-menu -->\r\n");
out.write(" </section>\r\n");
out.write(" <!-- /.sidebar -->\r\n");
out.write("</aside>\r\n");
out.write("\r\n");
out.write("\r\n");
out.write(" <!-- Content Wrapper. Contains page content -->\r\n");
out.write(" <div class=\"content-wrapper\">\r\n");
out.write("\r\n");
out.write("\r\n");
out.write(" <!-- Main content -->\r\n");
out.write(" <section class=\"content\">\r\n");
out.write("\r\n");
out.write(" <div class=\"box box-primary\">\r\n");
out.write(" <div class=\"box-header with-border\">\r\n");
out.write(" <h3 class=\"box-title\">登录日志列表</h3>\r\n");
out.write(" </div>\r\n");
out.write(" <div class=\"box-body\">\r\n");
out.write(" <table class=\"table\" id=\"logTable\">\r\n");
out.write(" <thead>\r\n");
out.write(" <tr>\r\n");
out.write(" <th>登录时间</th>\r\n");
out.write(" <th>登录IP</th>\r\n");
out.write("\r\n");
out.write(" </tr>\r\n");
out.write(" </thead>\r\n");
out.write(" <tbody>\r\n");
out.write("\r\n");
out.write(" </tbody>\r\n");
out.write(" </table>\r\n");
out.write(" </div>\r\n");
out.write("\r\n");
out.write(" </div>\r\n");
out.write("\r\n");
out.write(" </section>\r\n");
out.write(" <!-- /.content -->\r\n");
out.write(" </div>\r\n");
out.write(" <!-- /.content-wrapper -->\r\n");
out.write("</div>\r\n");
out.write("<!-- ./wrapper -->\r\n");
out.write("\r\n");
out.write("<!-- REQUIRED JS SCRIPTS -->\r\n");
out.write("\r\n");
out.write("<!-- jQuery 2.2.0 -->\r\n");
out.write("<script src=\"/static/plugins/jQuery/jQuery-2.2.0.min.js\"></script>\r\n");
out.write("<!-- Bootstrap 3.3.6 -->\r\n");
out.write("<script src=\"/static/bootstrap/js/bootstrap.min.js\"></script>\r\n");
out.write("<!-- AdminLTE App -->\r\n");
out.write("<script src=\"/static/dist/js/app.min.js\"></script>\r\n");
out.write("<script src=\"/static/plugins/datatables/js/jquery.dataTables.min.js\"></script>\r\n");
out.write("<script src=\"/static/plugins/datatables/js/dataTables.bootstrap.min.js\"></script>\r\n");
out.write("<script>\r\n");
out.write(" $(function(){\r\n");
out.write(" var dateTable=$(\"#logTable\").DataTable({\r\n");
out.write(" searching:false,\r\n");
out.write(" serverSide:true,\r\n");
out.write(" ajax:\"/user/log/load\",\r\n");
out.write(" ordering:false,\r\n");
out.write(" \"autoWidth\":false,\r\n");
out.write(" columns:[\r\n");
out.write(" {\"data\":\"logintime\"},\r\n");
out.write(" {\"data\":\"loginip\"}\r\n");
out.write(" ],\r\n");
out.write(" \"language\": { //定义中文\r\n");
out.write(" \"search\": \"请输入书籍名称:\",\r\n");
out.write(" \"zeroRecords\": \"没有匹配的数据\",\r\n");
out.write(" \"lengthMenu\": \"显示 _MENU_ 条数据\",\r\n");
out.write(" \"info\": \"显示从 _START_ 到 _END_ 条数据 共 _TOTAL_ 条数据\",\r\n");
out.write(" \"infoFiltered\": \"(从 _MAX_ 条数据中过滤得来)\",\r\n");
out.write(" \"loadingRecords\": \"加载中...\",\r\n");
out.write(" \"processing\": \"处理中...\",\r\n");
out.write(" \"paginate\": {\r\n");
out.write(" \"first\": \"首页\",\r\n");
out.write(" \"last\": \"末页\",\r\n");
out.write(" \"next\": \"下一页\",\r\n");
out.write(" \"previous\": \"上一页\"\r\n");
out.write(" }\r\n");
out.write(" }\r\n");
out.write(" });\r\n");
out.write(" });\r\n");
out.write("</script>\r\n");
out.write("</body>\r\n");
out.write("</html>\r\n");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try { out.clearBuffer(); } catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
private boolean _jspx_meth_shiro_005fprincipal_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// shiro:principal
org.apache.shiro.web.tags.PrincipalTag _jspx_th_shiro_005fprincipal_005f0 = (org.apache.shiro.web.tags.PrincipalTag) _005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody.get(org.apache.shiro.web.tags.PrincipalTag.class);
_jspx_th_shiro_005fprincipal_005f0.setPageContext(_jspx_page_context);
_jspx_th_shiro_005fprincipal_005f0.setParent(null);
// /WEB-INF/views/setting/../include/mainHeader.jsp(130,48) name = property type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_shiro_005fprincipal_005f0.setProperty("realname");
int _jspx_eval_shiro_005fprincipal_005f0 = _jspx_th_shiro_005fprincipal_005f0.doStartTag();
if (_jspx_th_shiro_005fprincipal_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody.reuse(_jspx_th_shiro_005fprincipal_005f0);
return true;
}
_005fjspx_005ftagPool_005fshiro_005fprincipal_0026_005fproperty_005fnobody.reuse(_jspx_th_shiro_005fprincipal_005f0);
return false;
}
private boolean _jspx_meth_shiro_005fhasAnyRoles_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// shiro:hasAnyRoles
org.apache.shiro.web.tags.HasAnyRolesTag _jspx_th_shiro_005fhasAnyRoles_005f0 = (org.apache.shiro.web.tags.HasAnyRolesTag) _005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname.get(org.apache.shiro.web.tags.HasAnyRolesTag.class);
_jspx_th_shiro_005fhasAnyRoles_005f0.setPageContext(_jspx_page_context);
_jspx_th_shiro_005fhasAnyRoles_005f0.setParent(null);
// /WEB-INF/views/setting/../include/leftSidebar.jsp(12,12) name = name type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_shiro_005fhasAnyRoles_005f0.setName("经理,员工");
int _jspx_eval_shiro_005fhasAnyRoles_005f0 = _jspx_th_shiro_005fhasAnyRoles_005f0.doStartTag();
if (_jspx_eval_shiro_005fhasAnyRoles_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\r\n");
out.write(" <li class=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.menu=='home'?'active':''}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("\"><a href=\"/notice\"><a href=\"/home\"><i class=\"fa fa-home\"></i> <span>首页</span></a></li>\r\n");
out.write(" <li class=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.menu=='notice'?'active':''}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("\"><a href=\"/notice\"><i class=\"fa fa-bullhorn\"></i> <span>公告</span></a></li>\r\n");
out.write(" <li><a href=\"#\"><i class=\"fa fa-building-o\"></i> <span>项目管理</span></a></li>\r\n");
out.write(" <li><a href=\"#\"><i class=\"fa fa-child\"></i> <span>客户管理</span></a></li>\r\n");
out.write(" <li><a href=\"#\"><i class=\"fa fa-bar-chart\"></i> <span>统计业务</span></a></li>\r\n");
out.write(" <li><a href=\"#\"><i class=\"fa fa-calendar-check-o\"></i> <span>待办事项</span></a></li>\r\n");
out.write(" <li><a href=\"#\"><i class=\"fa fa-file-text\"></i> <span>文档管理</span></a></li>\r\n");
out.write(" ");
int evalDoAfterBody = _jspx_th_shiro_005fhasAnyRoles_005f0.doAfterBody();
if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
break;
} while (true);
}
if (_jspx_th_shiro_005fhasAnyRoles_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname.reuse(_jspx_th_shiro_005fhasAnyRoles_005f0);
return true;
}
_005fjspx_005ftagPool_005fshiro_005fhasAnyRoles_0026_005fname.reuse(_jspx_th_shiro_005fhasAnyRoles_005f0);
return false;
}
private boolean _jspx_meth_shiro_005fhasRole_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// shiro:hasRole
org.apache.shiro.web.tags.HasRoleTag _jspx_th_shiro_005fhasRole_005f0 = (org.apache.shiro.web.tags.HasRoleTag) _005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname.get(org.apache.shiro.web.tags.HasRoleTag.class);
_jspx_th_shiro_005fhasRole_005f0.setPageContext(_jspx_page_context);
_jspx_th_shiro_005fhasRole_005f0.setParent(null);
// /WEB-INF/views/setting/../include/leftSidebar.jsp(21,12) name = name type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_shiro_005fhasRole_005f0.setName("管理员");
int _jspx_eval_shiro_005fhasRole_005f0 = _jspx_th_shiro_005fhasRole_005f0.doStartTag();
if (_jspx_eval_shiro_005fhasRole_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\r\n");
out.write(" <li class=\"treeview\">\r\n");
out.write(" <a href=\"javascript:;\"><i class=\"fa fa-cogs\"></i> <span>系统管理</span> <i class=\"fa fa-angle-left pull-right\"></i></a>\r\n");
out.write(" <ul class=\"treeview-menu\">\r\n");
out.write(" <li><a href=\"/admin/users\">员工管理</a></li>\r\n");
out.write(" <li><a href=\"#\">系统设置</a></li>\r\n");
out.write(" </ul>\r\n");
out.write(" </li>\r\n");
out.write(" ");
int evalDoAfterBody = _jspx_th_shiro_005fhasRole_005f0.doAfterBody();
if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
break;
} while (true);
}
if (_jspx_th_shiro_005fhasRole_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname.reuse(_jspx_th_shiro_005fhasRole_005f0);
return true;
}
_005fjspx_005ftagPool_005fshiro_005fhasRole_0026_005fname.reuse(_jspx_th_shiro_005fhasRole_005f0);
return false;
}
}
| [
"[email protected]"
] | |
2f442e7c3e85a3cb3c5f23e56198998a00e1c5eb | 1cfee0710db41c9f23dc027be647cb89705c65ca | /src/main/java/org/qamation/jmeter/java/sampler/browser/PageProcessor.java | 0ef3e2350a66a618f2280c37e893fea337e3089c | [] | no_license | gpawel/qamation_jmeter | ec0c2ed111e5d2ff7d3b6c40bfef1eff2062d0ab | ad84da8f794091ef0c0d058142f0be13d194f330 | refs/heads/master | 2023-03-12T05:33:02.812664 | 2020-02-23T22:15:17 | 2020-02-23T22:15:17 | 242,596,632 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,946 | java | package org.qamation.jmeter.java.sampler.browser;
import com.google.common.base.Function;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.qamation.jmeter.java.sampler.exceptions.StringComparisonException;
import org.qamation.utils.StringUtils;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.samplers.SampleResult;
public class PageProcessor extends PageNavigatAndCheck {
private static final String EXTRACT_TO = "ENTER VARIABLE NAME TO STORE EXTACTED DATA";
private static final String COMMENT = "ENTER A COMMENT TO BE INCLUDED INTO A LABEL. Leave empty ";
private String comment;
private String extractTo;
private boolean shouldExtract;
public Arguments getDefaultParameters() {
Arguments defaultParameters = super.getDefaultParameters();
defaultParameters.addArgument(COMMENT, "${COMMENT}");
defaultParameters.addArgument(EXTRACT_TO, "${EXTRACT_TO}");
return defaultParameters;
}
@Override
protected void readSamplerParameters() {
comment = getSamplerParameterValue(COMMENT);
super.readSamplerParameters();
extractTo = getSamplerParameterValue(EXTRACT_TO);
initProcessorVariablels();
}
protected void initProcessorVariablels() {
shouldExtract = true;
if (elementLocator.isEmpty() || extractTo.isEmpty()) shouldExtract = false;
}
@Override
protected void toDo() {
initPageInstance();
navigatePage();
boolean failed = verifyText();
extractValue();
goBack();
if (failed) throw new StringComparisonException("Read text does not match to expected value");
}
@Override
protected boolean verifyText() {
boolean passed = false;
boolean failed = true;
if (shouldVerifyText) {
ExpectedCondition<String> condition = getCondition(elementLocator, expectedResult);
try {
readText = page.isReady(condition);
return passed;
}
catch (TimeoutException ex) {
readText = readText();
return failed;
}
}
return passed;
}
protected void extractValue() {
if (shouldExtract) {
String value = extractFromPage(elementLocator);
setStringIntoVariables(extractTo, value);
}
}
protected String extractFromPage(String extractFrom) {
String value = page.readTextFrom(extractFrom);
return value;
}
@Override
protected SampleResult assembleTestFailure(Exception ex) {
SampleResult result = new SampleResult();
result.setSuccessful(false);
if (ex != null) addExceptionInformation(result, ex);
if (comment != null) addCommentToLable(result);
result.setStopThread(shouldStop);
return result;
}
private void addExceptionInformation(SampleResult result, Exception ex) {
if (ex instanceof StringComparisonException) {
String label = getAssertionErrorLable();
String message = getAssertionErrorMessage();
result.setSampleLabel(label);
result.setResponseMessage(message);
return;
}
result.setResponseMessage("FAILED");
result.setResponseData(StringUtils.getStackTrace(ex).getBytes());
return;
}
private void addCommentToLable(SampleResult result) {
if (comment.isEmpty()) return;
String label = result.getSampleLabel();
if (label == null || label.isEmpty())
label = comment;
else
label = comment + " - " + label;
result.setSampleLabel(label);
return;
}
@Override
protected SampleResult assembleTestResult() {
SampleResult result = new SampleResult();
result.setSuccessful(true);
String label = getLabel();
result.setSampleLabel(label);
addCommentToLable(result);
result.setResponseMessageOK();
return result;
}
protected ExpectedCondition<String> getExpectedTextIsReadyCondition(final String location, final String expectedString) {
ExpectedCondition<String> condition = new ExpectedCondition<String>() {
@Override
public String apply(WebDriver webDriver) {
String read = page.readTextFrom(location,expectedString.length());
if (read.equals(expectedString)) return read;
else return null;
}
};
return condition;
}
//processor
private ExpectedCondition<String> getCondition(final String location, final String expectedString) {
return getExpectedTextIsReadyCondition(location, expectedString);
}
}
| [
"[email protected]"
] | |
1756071dc026f788da7fac4098b64850e897c48a | 0859e27559e4ac5219dee0518752097025290e93 | /isis2304-tutorial-arquitectura/src/rest/ReservaService.java | 17f2afd098fbe68979170bf53d69c2583113c6c6 | [
"MIT"
] | permissive | andresilva1997/alohaAndes | b71c2cdd4f016e0c16d1ea3bcd476e266635d3d0 | bdbc6bb37a3fad24d48feee6bb908329d3dd8c31 | refs/heads/master | 2021-09-09T22:47:12.225275 | 2018-03-20T04:09:26 | 2018-03-20T04:09:26 | 125,921,342 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,309 | java | package rest;
import java.util.List;
import javax.servlet.ServletContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import tm.AlohaTransactionManager;
import vos.Reserva;
import vos.Usuario;
@Path("reservas")
public class ReservaService {
///////////////////////////////
////////// ATRIBUTOS////////////
///////////////////////////////
/**
* Atributo que usa la anotacion @Context para tener el ServletContext de la
* conexion actual.
*/
@Context
private ServletContext context;
///////////////////////////////
/// METODOS DE INICIALIZACION///
///////////////////////////////
/**
* Metodo que retorna el path de la carpeta WEB-INF/ConnectionData en el
* deploy actual dentro del servidor.
*
* @return path de la carpeta WEB-INF/ConnectionData en el deploy actual.
*/
private String getPath() {
return context.getRealPath("WEB-INF/ConnectionData");
}
private String doErrorMessage(Exception e) {
return "{ \"ERROR\": \"" + e.getMessage() + "\"}";
}
///////////////////////////////
/////// METODOS DE REST////////
///////////////////////////////
/**
* Metodo GET que trae a todos los reservas en la Base de datos. <br/>
* <b>Precondicion: </b> el archivo <em>'conectionData'</em> ha sido
* inicializado con las credenciales del reserva <br/>
* <b>URL: </b> http://localhost:8080/Aloha/rest/reservas <br/>
*
* @return <b>Response Status 200</b> - JSON que contiene a todos los
* reservas que estan en la Base de Datos <br/>
* <b>Response Status 500</b> - Excepcion durante el transcurso de
* la transaccion
*/
@GET
@Produces({ MediaType.APPLICATION_JSON })
public Response getReservas() {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
List<Reserva> reservas;
reservas = tm.getAllReservas();
return Response.status(200).entity(reservas).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
/**
* Metodo GET que trae al usuario en la Base de Datos con el ID dado por
* parametro <br/>
* <b>Precondicion: </b> el archivo <em>'conectionData'</em> ha sido
* inicializado con las credenciales del usuario <br/>
* <b>URL: </b> http://localhost:8080/Aloha/rest/usuarios/{id} <br/>
*
* @return <b>Response Status 200</b> - JSON Reserva que contiene al usuario
* cuyo ID corresponda al parametro <br/>
* <b>Response Status 500</b> - Excepcion durante el transcurso de
* la transaccion
*/
@GET
@Path("{id: \\d+}")
@Produces({ MediaType.APPLICATION_JSON })
public Response getReservaById(@PathParam("id") Long id) {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
Reserva usuario = tm.getReservaById(id);
return Response.status(200).entity(usuario).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
/**
* Metodo GET que trae las reservas por usuario y operador en la Base de
* Datos con los ID dados por parametro <br/>
* <b>Precondicion: </b> el archivo <em>'conectionData'</em> ha sido
* inicializado con las credenciales del usuario <br/>
* <b>URL: </b> http://localhost:8080/Aloha/rest/usuarios/{id} <br/>
*
* @return <b>Response Status 200</b> - JSON Reserva que contiene a la
* reserva cuyo ID corresponda al parametro <br/>
* <b>Response Status 500</b> - Excepcion durante el transcurso de
* la transaccion
*/
@GET
@Path("{idUsuario: \\d+}/{idOperador: \\d+}")
@Produces({ MediaType.APPLICATION_JSON })
public Response getReservaByUsuarioOperador(@PathParam("idUsuario") Long idUsuario,
@PathParam("idOperador") Long idOperador) {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
List<Reserva> usuarios;
usuarios = tm.getReservaByUsuarioOperador(idUsuario, idOperador);
return Response.status(200).entity(usuarios).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
/**
* crea una nueva reserva e informa de los posibles casos de error.
*
* @param usuario
* @return
*/
@PUT
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
public Response addReserva(Reserva reserva) {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
tm.addReserva(reserva);
return Response.status(200).entity(reserva).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
/**
* Modifica la reserva que entra por parametro e informa sobre los casos de
* error.
*
* @param reserva
* @return
*/
@POST
@Path("{id: \\d+}")
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
public Response updateReserva(Reserva reserva, @PathParam("id") Long id) {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
if (tm.getReservaById(id) == null) {
return Response.status(404).build();
}
tm.updateReserva(reserva);
return Response.status(200).entity(reserva).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
/**
* Metodo que borra un usuario y comenta sobre los casos de error.
*
* @param reserva
* @param codigo
* @return
*/
@DELETE
@Path("{id: \\d+}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteReserva(Reserva reserva, @PathParam("id") Long id) {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
if (tm.getReservaById(id) == null) {
return Response.status(404).build();
}
tm.deleteReserva(reserva);
return Response.status(200).entity(reserva).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@Path("RFC2")
public Response RFC2() {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
List<String> res = tm.RFC2();
StringBuilder st1 = new StringBuilder();
for (int i = 0; i < res.size(); i++) {
st1.append(res.get(i));
}
return Response.ok(st1.toString(), MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@Path("RFC1")
public Response RFC1() {
try {
AlohaTransactionManager tm = new AlohaTransactionManager(getPath());
List<String> res = tm.RFC1();
StringBuilder st1 = new StringBuilder();
for (int i = 0; i < res.size(); i++) {
st1.append(res.get(i));
}
return Response.ok(st1.toString(), MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
return Response.status(500).entity(doErrorMessage(e)).build();
}
}
} | [
"[email protected]"
] | |
226d792323bb5b7ac1f6e266da2a727e7ace1627 | 12cca0e87b82f816e7765a8ec77c8d997e1e087a | /reuze/ga_i_PolygonTesselator.java | f9eecd3281b9a916abda3ffa4ffa393795eebe68 | [] | no_license | mageru/softwarereuse | b970e734783bfb6b6de846d226f1dac53f6e68b6 | b72af735321ec29e768c76b0cd0c1addb7a07c98 | refs/heads/master | 2020-06-08T21:26:41.704118 | 2012-10-25T02:24:28 | 2012-10-25T02:24:28 | 5,502,804 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 345 | java | package reuze;
import reuze.ga_Triangle2D;
import java.util.List;
public interface ga_i_PolygonTesselator {
/**
* Tesselates the given polygon into a set of triangles.
*
* @param poly
* polygon
* @return list of triangles
*/
public List<ga_Triangle2D> tesselatePolygon(ga_Polygon poly);
} | [
"[email protected]"
] | |
e18e606bc2acf4f2c1549f19f8bff4d96863599c | eb8978c7597cf425460500eeddbcad0eec03e7b0 | /app/src/androidTest/java/com/smart/android/cnblogs/ApplicationTest.java | 9ed2b0358600eeacde2b3dac9eea033876f6ea6d | [] | no_license | miaolingzi/cnblogs_android | b2f0540f655049958dde0aab09e9bff4324957c0 | a77ef90d3be53e53c1f2086087450b75c3744254 | refs/heads/master | 2020-12-24T13:43:58.984391 | 2020-05-04T05:19:37 | 2020-05-04T05:19:37 | 38,287,099 | 0 | 1 | null | 2015-07-05T13:35:21 | 2015-06-30T04:06:46 | Java | UTF-8 | Java | false | false | 356 | java | package com.smart.android.cnblogs;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"[email protected]"
] | |
347d156633e102bc12664e3432ee10de0be00720 | cb5f27eb6960c64542023d7382d6b917da38f0fc | /sources/com/google/firebase/analytics/connector/AnalyticsConnectorImpl.java | 61e61d517f8ba5fa9f5b73651a8ebe45157103c0 | [] | no_license | djtwisty/ccah | a9aee5608d48448f18156dd7efc6ece4f32623a5 | af89c8d3c216ec3371929436545227682e811be7 | refs/heads/master | 2020-04-13T05:33:08.267985 | 2018-12-24T13:52:39 | 2018-12-24T13:52:39 | 162,995,366 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,929 | java | package com.google.firebase.analytics.connector;
import android.content.Context;
import android.os.Bundle;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.VisibleForTesting;
import com.google.android.gms.measurement.AppMeasurement;
import com.google.android.gms.measurement.internal.zzan;
import com.google.android.gms.measurement.internal.zzbw;
import com.google.firebase.DataCollectionDefaultChange;
import com.google.firebase.FirebaseApp;
import com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorHandle;
import com.google.firebase.analytics.connector.AnalyticsConnector.AnalyticsConnectorListener;
import com.google.firebase.analytics.connector.AnalyticsConnector.ConditionalUserProperty;
import com.google.firebase.analytics.connector.internal.zza;
import com.google.firebase.analytics.connector.internal.zzc;
import com.google.firebase.analytics.connector.internal.zzd;
import com.google.firebase.analytics.connector.internal.zzf;
import com.google.firebase.events.Event;
import com.google.firebase.events.Subscriber;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class AnalyticsConnectorImpl implements AnalyticsConnector {
private static volatile AnalyticsConnector zzbsp;
@VisibleForTesting
private final AppMeasurement zzbsq;
@VisibleForTesting
final Map<String, zza> zzbsr = new ConcurrentHashMap();
private AnalyticsConnectorImpl(AppMeasurement appMeasurement) {
Preconditions.checkNotNull(appMeasurement);
this.zzbsq = appMeasurement;
}
@KeepForSdk
public static AnalyticsConnector getInstance(FirebaseApp firebaseApp, Context context, Subscriber subscriber) {
Preconditions.checkNotNull(firebaseApp);
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(subscriber);
Preconditions.checkNotNull(context.getApplicationContext());
if (zzbsp == null) {
synchronized (AnalyticsConnectorImpl.class) {
if (zzbsp == null) {
Bundle bundle = new Bundle(1);
if (firebaseApp.isDefaultApp()) {
subscriber.subscribe(DataCollectionDefaultChange.class, zza.zzbss, zzb.zzbst);
bundle.putBoolean("dataCollectionDefaultEnabled", firebaseApp.isDataCollectionDefaultEnabled());
}
zzbsp = new AnalyticsConnectorImpl(zzbw.zza(context, zzan.zzc(bundle)).zzkm());
}
}
}
return zzbsp;
}
@KeepForSdk
public static AnalyticsConnector getInstance() {
return getInstance(FirebaseApp.getInstance());
}
@KeepForSdk
public static AnalyticsConnector getInstance(FirebaseApp firebaseApp) {
return (AnalyticsConnector) firebaseApp.get(AnalyticsConnector.class);
}
@KeepForSdk
public void logEvent(String str, String str2, Bundle bundle) {
if (bundle == null) {
bundle = new Bundle();
}
if (zzc.zzft(str) && zzc.zza(str2, bundle) && zzc.zzb(str, str2, bundle)) {
this.zzbsq.logEventInternal(str, str2, bundle);
}
}
@KeepForSdk
public void setUserProperty(String str, String str2, Object obj) {
if (zzc.zzft(str) && zzc.zzz(str, str2)) {
this.zzbsq.setUserPropertyInternal(str, str2, obj);
}
}
@KeepForSdk
public Map<String, Object> getUserProperties(boolean z) {
return this.zzbsq.getUserProperties(z);
}
@KeepForSdk
public AnalyticsConnectorHandle registerAnalyticsConnectorListener(final String str, AnalyticsConnectorListener analyticsConnectorListener) {
Preconditions.checkNotNull(analyticsConnectorListener);
if (!zzc.zzft(str) || zzfs(str)) {
return null;
}
AppMeasurement appMeasurement = this.zzbsq;
Object zzd = AppMeasurement.FIAM_ORIGIN.equals(str) ? new zzd(appMeasurement, analyticsConnectorListener) : AppMeasurement.CRASH_ORIGIN.equals(str) ? new zzf(appMeasurement, analyticsConnectorListener) : null;
if (zzd == null) {
return null;
}
this.zzbsr.put(str, zzd);
return new AnalyticsConnectorHandle(this) {
private final /* synthetic */ AnalyticsConnectorImpl zzbsu;
public void unregister() {
if (this.zzbsu.zzfs(str)) {
AnalyticsConnectorListener zztv = ((zza) this.zzbsu.zzbsr.get(str)).zztv();
if (zztv != null) {
zztv.onMessageTriggered(0, null);
}
this.zzbsu.zzbsr.remove(str);
}
}
@KeepForSdk
public void registerEventNames(Set<String> set) {
if (this.zzbsu.zzfs(str) && str.equals(AppMeasurement.FIAM_ORIGIN) && set != null && !set.isEmpty()) {
((zza) this.zzbsu.zzbsr.get(str)).registerEventNames(set);
}
}
@KeepForSdk
public void unregisterEventNames() {
if (this.zzbsu.zzfs(str) && str.equals(AppMeasurement.FIAM_ORIGIN)) {
((zza) this.zzbsu.zzbsr.get(str)).unregisterEventNames();
}
}
};
}
@KeepForSdk
public void setConditionalUserProperty(ConditionalUserProperty conditionalUserProperty) {
if (zzc.zza(conditionalUserProperty)) {
this.zzbsq.setConditionalUserProperty(zzc.zzb(conditionalUserProperty));
}
}
@KeepForSdk
public void clearConditionalUserProperty(String str, String str2, Bundle bundle) {
if (str2 == null || zzc.zza(str2, bundle)) {
this.zzbsq.clearConditionalUserProperty(str, str2, bundle);
}
}
@KeepForSdk
public List<ConditionalUserProperty> getConditionalUserProperties(String str, String str2) {
List<ConditionalUserProperty> arrayList = new ArrayList();
for (AppMeasurement.ConditionalUserProperty zzd : this.zzbsq.getConditionalUserProperties(str, str2)) {
arrayList.add(zzc.zzd(zzd));
}
return arrayList;
}
@KeepForSdk
public int getMaxUserProperties(String str) {
return this.zzbsq.getMaxUserProperties(str);
}
private final boolean zzfs(String str) {
return (str.isEmpty() || !this.zzbsr.containsKey(str) || this.zzbsr.get(str) == null) ? false : true;
}
static final /* synthetic */ void zza(Event event) {
boolean z = ((DataCollectionDefaultChange) event.getPayload()).enabled;
synchronized (AnalyticsConnectorImpl.class) {
((AnalyticsConnectorImpl) zzbsp).zzbsq.zzd(z);
}
}
}
| [
"[email protected]"
] | |
4a8f6dd27bb9da73949c2a6ac7e0fb08c08247c5 | 12623bd1e076d66fb2077010c8b963ba4a5f8d2a | /common/src/main/java/com/example/common/repository/ListingRepository.java | f096da367584d0fbe39369fffac69d1574397f8c | [] | no_license | SevoMkrtchyan/modular_project | 15e334f9838554b54434439c6b9753994e283a23 | 5c20557543d6c4712cf631553bb07f0786c40f12 | refs/heads/main | 2023-08-27T17:12:59.849201 | 2021-09-30T21:54:00 | 2021-09-30T21:54:00 | 411,820,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,091 | java | package com.example.common.repository;
import com.example.common.entity.Category;
import com.example.common.entity.Listing;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import javax.transaction.Transactional;
import java.util.List;
@Transactional
public interface ListingRepository extends JpaRepository<Listing, Integer> {
List<Listing> findAllByUserEmail(String email);
List<Listing> findAllByCategory(Category category);
@Modifying
@Query(value = "UPDATE listing SET category_id=:nullValue WHERE category_id=:id", nativeQuery = true)
void changeListingCategoryNullWhenCategoryDeleted(@Param("id") Integer id, @Param("nullValue") Integer nullValue);
@Modifying
@Query(value = "UPDATE listing SET user_id=:nullValue WHERE user_id=:id", nativeQuery = true)
void changeListingUserNullWhenUserDeleted(@Param("id") Integer id, @Param("nullValue") Integer nullValue);
}
| [
"[email protected]"
] | |
e699593e74df4ffde1d287c3484b7b907e4cdebe | bb0b2a35c662fe44970542958df3bab520835a73 | /src/main/java/com/emse/spring/faircorp/restapi/LightController.java | cb069c1238dc9104a050d1cbd4c1190c98a78263 | [] | no_license | anas-r/springlab | 9367d1feedb26a36be7f82da33949e404d62892e | 0f6996903bbf8c1c1023d59a9b0b4468a8739260 | refs/heads/master | 2020-09-13T19:52:03.606401 | 2019-12-18T16:55:11 | 2019-12-18T16:55:11 | 222,887,360 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,054 | java | package com.emse.spring.faircorp.restapi;
import com.emse.spring.faircorp.model.Light;
import com.emse.spring.faircorp.model.LightDao;
import com.emse.spring.faircorp.model.RoomDao;
import com.emse.spring.faircorp.model.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@RestController // 1.
@RequestMapping("/api/lights") // 2.
@Transactional // 3.
public class LightController {
@Autowired
private LightDao lightDao; // 4.
@Autowired
private RoomDao roomDao;
@GetMapping // 5.
public List<LightDto> findAll() {
return lightDao.findAll()
.stream()
.map(LightDto::new)
.collect(Collectors.toList());
}
@GetMapping(path = "/{id}")
public LightDto findById(@PathVariable Integer id) {
return lightDao.findById(id).map(light -> new LightDto(light)).orElse(null);
}
@PutMapping(path = "/{id}/switch")
public LightDto switchStatus(@PathVariable Integer id) {
Light light = lightDao.findById(id).orElseThrow(IllegalArgumentException::new);
light.setStatus(light.getStatus() == Status.ON ? Status.OFF: Status.ON);
return new LightDto(light);
}
@PostMapping
public LightDto create(@RequestBody LightDto dto) {
Light light = null;
if (dto.getId() != null) {
light = lightDao.findById(dto.getId()).orElse(null);
}
if (light == null) {
light = lightDao.save(new Light(dto.getLevel(), dto.getStatus(), roomDao.getOne(dto.getRoom())));
} else {
light.setLevel(dto.getLevel());
light.setStatus(dto.getStatus());
lightDao.save(light);
}
return new LightDto(light);
}
@DeleteMapping(path = "/{id}")
public void delete(@PathVariable Integer id) {
lightDao.deleteById(id);
}
} | [
"[email protected]"
] | |
98e15ddf6a284b696a6c7366c3cf28049822db9c | 893d477125629ef820a98125b7133a864ab801ec | /SolutisCoffeClubMobile/app/src/main/java/solutis/jose/com/solutiscoffeeclub_mobile/Capsula.java | a20503cc7749b5df2ba6987a4958124258464332 | [] | no_license | JoseRoberto26/SolutisCoffeeClub | d0f9fd82cd153e88a8d83c481909e0361c6ecc88 | 6a98b2fd0fc314159c347786cac6736eb3449af7 | refs/heads/master | 2020-03-14T12:16:31.028913 | 2018-05-14T21:34:27 | 2018-05-14T21:34:27 | 130,413,301 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,047 | java | package solutis.jose.com.solutiscoffeeclub_mobile;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class Capsula implements Serializable{
@SerializedName("id")
@Expose
private Long id;
@SerializedName("marca")
@Expose
private String marca;
@SerializedName("sabor")
@Expose
private String sabor;
@SerializedName("doses")
@Expose
private Integer doses;
public Capsula() {
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public String getSabor() {
return sabor;
}
public void setSabor(String sabor) {
this.sabor = sabor;
}
public Integer getDoses() {
return doses;
}
public void setDoses(Integer doses) {
this.doses = doses;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
| [
"[email protected]"
] | |
ef7882bfa0a3a5b51eec66b27a3e9e77cabe4fdc | 240e126f8d1abcd316f957832539713acbb5ca6e | /common/src/main/java/com/springaft/common/annotation/Inner.java | b774f8acf27be043c3bfc4300e652eac26b3bb53 | [
"MIT"
] | permissive | cs58722320/SpringCloudAft | d802bb6e5aa697cf42b2c3e2d1a1b8b5b4cc47ea | 43607851d0a3a680c845a3d0f8b54cb514e52342 | refs/heads/master | 2022-06-23T22:30:52.128962 | 2019-11-03T03:41:42 | 2019-11-03T03:41:42 | 205,971,252 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 558 | java | package com.springaft.common.annotation;
import java.lang.annotation.*;
/**
* 名称:服务调用不鉴权注解<br>
* 描述:服务调用不鉴权注解<br>
*
* @author JeffDu
* @version 1.0
* @since 1.0.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Inner {
/**
* 是否AOP统一处理
*
* @return false, true
*/
boolean value() default true;
/**
* 需要特殊判空的字段(预留)
*
* @return {}
*/
String[] field() default {};
}
| [
"[email protected]"
] | |
bba397a37fde97f9c0e84b705eac00608cd419e3 | d47a7f7199bed7f88bcfb4e1b879dcfb9c0fb0a3 | /CBAApp/app/src/main/java/com/ceylonapz/cbaapp/SendActivity.java | edd76a68065da6880f09da60987ae964a012e287 | [] | no_license | amalskr/cba | 98e095c2576ba99ae21cf527e16e48b3cc207557 | 6559435c468e4106820053f8e5afb868085e3cbc | refs/heads/master | 2021-01-21T15:19:28.608448 | 2017-05-19T20:12:40 | 2017-05-19T20:12:40 | 91,840,983 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,813 | java | package com.ceylonapz.cbaapp;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import com.ceylonapz.cbaapp.model.User;
import com.ceylonapz.cbaapp.utils.Util;
import com.ceylonapz.cbaapp.utils.Validator;
import com.google.gson.Gson;
import java.io.File;
import java.io.Serializable;
public class SendActivity extends AppCompatActivity {
private User user;
private Uri imageUri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Gson gson = new Gson();
user = gson.fromJson(getIntent().getStringExtra("USER"), User.class);
}
public void sendNow(View view) {
EditText eml_et = (EditText) findViewById(R.id.emailEt);
String email = eml_et.getText().toString();
if (Validator.isValidEmail(email)) {
sendEmail(email);
} else {
Util.showToast(this, "Invalid email! Your name and domain name should have minimum 3 letters.([email protected]) ");
}
}
private void sendEmail(String email) {
imageUri = Uri.parse(user.getSignatureImagePath());
String body = "NAME : " + user.getName() + "\n" +
"AMOUNT : " + user.getAmount() + "\n" +
"CODE : " + user.getCode();
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain");
intent.setData(Uri.parse("mailto:" + email));
intent.putExtra(Intent.EXTRA_SUBJECT, "CBA payment - " + user.getName());
intent.putExtra(Intent.EXTRA_TEXT, body);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
File fdelete = new File(imageUri.getPath());
if (fdelete.exists()) {
if (fdelete.delete()) {
System.out.println("file Deleted :" + imageUri.getPath());
} else {
System.out.println("file not Deleted :" + imageUri.getPath());
}
}
}
}
| [
"[email protected]"
] | |
77e8bc33adbb2148840d5ece9e095750dffdb409 | a80dee436499f31403f0513e1efbc36416ee5e95 | /springcloud/parent/scloud-service/src/main/java/com/yhh/springcloud/scloudservice/config/FeignClientConfig.java | e9d8afa0f848737a3ece462ec8e37499dbef888f | [] | no_license | shuisheng13/practice | aa9077cb9d351fbe6367d754c1a10c6ab65e97a3 | e47564a323d7b526d1cb72c57ac5feda58a8f17f | refs/heads/master | 2022-12-23T03:29:32.080490 | 2019-08-03T10:24:37 | 2019-08-03T10:24:37 | 181,495,198 | 0 | 0 | null | 2022-12-16T08:48:35 | 2019-04-15T13:40:48 | Java | UTF-8 | Java | false | false | 543 | java | package com.yhh.springcloud.scloudservice.config;
import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FeignClientConfig {
@Bean
public Logger.Level getFeignLoggerLevel() {
return feign.Logger.Level.FULL ;
}
@Bean
public BasicAuthRequestInterceptor getBasicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("admin", "enjoy");
}
} | [
"[email protected]"
] | |
6dd589b1cf32d2ebfa1013c448edaf78e3a20821 | db7fdddf1a542a88243fce0b8b5729cbb9ffb554 | /src/main/java/pattern/strategy/PromotionStrategy.java | 53fc268a4a4597b8ac9637738e9e1215cf95a89d | [] | no_license | star12138/myTest | d8a9ae3859c216bbf7606fb4fc50f16c6390aae6 | 5e13c2a6ea012c95eb47a0f02f72640421d7801f | refs/heads/master | 2022-12-21T23:32:14.691589 | 2020-06-19T02:08:09 | 2020-06-19T02:08:09 | 177,903,745 | 0 | 0 | null | 2022-12-10T03:31:38 | 2019-03-27T02:28:29 | Java | UTF-8 | Java | false | false | 146 | java | package pattern.strategy;
/**
* @author bike
* @create 2020-03-19 10:25 上午
**/
public interface PromotionStrategy {
void execute();
}
| [
"[email protected]"
] | |
1360d5f5e5da67aa0d5216de7c639dd5e6f8b95d | 109ae6c2edb213e67fc80d8659b2c623218f180d | /BulletinBoard/src/main/java/web/ControllerEditing.java | 4ed8b36c20226c028717ca9c536a496a69d61862 | [] | no_license | KonstantinBuzhin/boardTest | 4b4f0e3293be07fb25351c5e5ff4dc23e0e816ef | 6e6d4654a1f93bcdca07f853c36f2a5bd80601f3 | refs/heads/master | 2022-12-23T09:59:24.057887 | 2020-09-24T09:31:25 | 2020-09-24T09:31:25 | 297,640,684 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,566 | java | package web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import model.User;
import service.UserEngine;
@Controller
@Scope("session")
public class ControllerEditing {
@Autowired
private User user;
@Autowired
private UserEngine userDB;
@RequestMapping(value = "/editing", method = RequestMethod.GET)
public String getGetEditingPage(HttpSession session, ModelMap model) {
if (session.getAttribute("currentUser") != null) {
User user = (User) session.getAttribute("currentUser");
System.out.println(user);
model.addAttribute("firstName", user.getFirstName());
model.addAttribute("lastName", user.getLastName());
model.addAttribute("email", user.getEmail());
if (session.getAttribute("updating") != null) {
model.addAttribute("updating", session.getAttribute("updating"));
session.removeAttribute("updating");
}
}
return "editing";
}
@RequestMapping(value = "/editing", method = RequestMethod.POST)
public String getPostEditingPage(HttpSession session, ModelMap model) {
if (session.getAttribute("currentUser") != null) {
User user = (User) session.getAttribute("currentUser");
System.out.println(user);
model.addAttribute("firstName", user.getFirstName());
model.addAttribute("lastName", user.getLastName());
model.addAttribute("email", user.getEmail());
}
return "editing";
}
@RequestMapping(value = "/editing", method = RequestMethod.POST, params = { "firstName", "email", "password" })
public String getPostEditingPage(@RequestParam("firstName") String firstName, @RequestParam("email") String email,
@RequestParam("password") String password, HttpSession session, HttpServletRequest request,
ModelMap model) {
if (firstName != null && email != null && password != null) {
user = (User) session.getAttribute("currentUser");
userDB.updateClient(user, firstName, email, password);
session.setAttribute("currentUser", userDB.getUserById(user.getIdUser()));
session.setAttribute("updating", "active");
}
return "editing";
}
}
| [
"[email protected]"
] | |
dae935b5e03e3ef81719d9003217ca98b073d54c | f814710852d4794080e24fe3d8e4c135a2ebdc94 | /src/a0706/MainTT.java | 1de3a2c8f93e88da805c17e869dc80d77a119b9d | [] | no_license | yanzi99522/lxy | 8a30c782e1023d35b0431e550fdad5739f1fb607 | 227f702f695af2eb56d398f2d62eb416870daa39 | refs/heads/master | 2020-04-28T08:40:29.828229 | 2019-09-14T02:12:10 | 2019-09-14T02:12:10 | 175,137,201 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 572 | java | package a0706;
import java.util.Scanner;
/**
* @author lxy
*/
public class MainTT {//放苹果问题
static int fangpingguo(int m,int n){
if (m==0||n==1){
return 1;
}
if (n>m){
return fangpingguo(m,m);
} else {
return fangpingguo(m,n-1)+fangpingguo(m-n,n);
}
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int m=in.nextInt();
int n=in.nextInt();
int num=fangpingguo(m ,n);
System.out.println(num);
}
}
| [
"[email protected]"
] | |
f604feb4462f1420d904bd92c96321e97c8be9c2 | 9002c0f18bb01b7a895651b6011ce67c5856ac20 | /DesignPattern/src/main/java/com/neo/structure/component/MenuComponent.java | 30e45ea4f50657dfdb70c7e066ac75c8ce086bdc | [] | no_license | liangbingtao/JavaLife | dbfc1efba1173761c28389fd36d1a6d543206bbc | 3f507c31b3c198e9498e777a7d6c76a2b86b5f78 | refs/heads/main | 2023-07-02T05:00:24.761585 | 2021-07-30T17:14:31 | 2021-07-30T17:14:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 811 | java | package com.neo.structure.component;
/**
* @Author : neo
* @Date 2021/3/25 19:40
* @Description : 菜单组件(抽象根节点)
*/
public abstract class MenuComponent {
protected String name;
protected int level;
//添加菜单
public void add(MenuComponent menuComponent) {
throw new UnsupportedOperationException();
}
//移除菜单
public void remove(MenuComponent menuComponent) {
throw new UnsupportedOperationException();
}
//获取指定的子菜单
public MenuComponent getChild(int i) {
throw new UnsupportedOperationException();
}
//获取菜单名称
public String getName() {
return name;
}
//打印菜单名称的方法(包含子菜单和子菜单项)
public abstract void print();
}
| [
"[email protected]"
] | |
8c0bd31ee20ac1228ca399966d706f93a19ecd70 | 3f7a5d7c700199625ed2ab3250b939342abee9f1 | /src/gcom/cobranca/FiltroRotaAcaoCriterio.java | 1553264a04e344954f81639a9486b43aadd32771 | [] | 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 | 3,892 | 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.cobranca;
import gcom.util.filtro.Filtro;
import java.io.Serializable;
/**
* Filtro utilizado na pesquisa de RotaAcaoCriterio
*
* @author Pedro Alexandre
* @date 26/04/2006
*/
public class FiltroRotaAcaoCriterio extends Filtro implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Constructor for the FiltroRotaAcaoCriterio object
*/
public FiltroRotaAcaoCriterio() {
}
/**
* Constructor for the FiltroRotaAcaoCriterio object
*
* @param campoOrderBy
* Description of the Parameter
*/
public FiltroRotaAcaoCriterio(String campoOrderBy) {
this.campoOrderBy = campoOrderBy;
}
/**
* Description of the Field
*/
public final static String ID = "id";
/**
* Description of the Field
*/
public final static String ROTA_ID = "rota.id";
/**
* Description of the Field
*/
public final static String COBRANCA_ACAO_ID = "cobrancaAcao.id";
}
| [
"[email protected]"
] | |
5b5e8f747be98442458643ddeb1cb0f1247da68e | 017449c53d94693d4d8c88fccca8bdfef1215087 | /src/main/java/io/swagger/client/model/OrderbookGetOrderResponseErrorCode.java | b402aea9f01dfd939bee9a9b6a4919064393e829 | [] | no_license | qume-exchange/qume-java-client | 03e9a17a5d13fb13181aadc4bc702ea569921aeb | 15676cf009daef64510aee5847f35f7c18cd2ae7 | refs/heads/master | 2022-06-11T23:01:47.486208 | 2019-07-11T06:29:01 | 2019-07-11T06:29:01 | 196,333,046 | 1 | 0 | null | 2022-05-20T21:02:30 | 2019-07-11T06:28:27 | Java | UTF-8 | Java | false | false | 6,524 | java | /*
* Qume Sandbox API Documentation
* # Overview > Qume provides APIs for accessing exchange features programmatically. By querying REST endpoints and/or connecting to WebSocket channels, developers can implement custom trading systems in any programming language capable of managing HTTP requests. Authenticated REST endpoints are used for transactional operations, such as: - Placing and cancelling orders - Managing positions - Querying historical data - Modifying leverage WebSocket channels provide real-time streams of information, including: - *Level-1* and *Level-2* order book data - Market statistics # REST API ## Creating an API Key To use the REST API, you must generate a pair of unique API keys on the “Accounts” page of the sandbox website. Your *Public Key, Secret Key*, and *Passphrase* only appear once, so make sure they are safely stored before exiting the page. Example key generation output: - *Public Key*: ```“d284cb87-0b27-47f9-a82d-c43173ea7c87”``` - *Secret Key*: ```“9ed4c73db9abae81d72f53e14cc4e842”``` - *Passphrase*: ```“example_passphrase”``` ## Authentication Headers REST operations all require authentication. To authenticate a request, you must supply four HTTP headers: - ```X-QUME-SIGNATURE```: See [Generate Authentication String](#/introduction/rest-api/generate-authentication-string). - ```X-QUME-TIMESTAMP```: The Unix timestamp (also called Unix epoch or Unix time) in milliseconds. The server will deny requests with a timestamp that is more than 10 seconds old. - ```X-QUME-PASSPHRASE```: The unique passphrase that you chose in order to generate your API keys. - ```X-QUME-API-KEY```: Your Public API Key. ## Generate Authentication String In order to generate ```X-QUME-SIGNATURE```, you must perform the following steps: 1. Concatenate *request body + Unix timestamp + path*. <br> *Example Output*: ```{“foo”:”bar”}1538524732000/v1/orders``` <br> 3. Generate a HMAC-SHA-256 using the result from step 1 and your API Secret Key. 4. Hex-encode the output. **NOTES** - All request bodies should be valid JSON with content type ```application/json``` - If the request body is ```{}```, treat it as an empty string - Include the ```/v1``` prefix in the path - The Unix timestamp must be in milliseconds ## Example A shell script for placing a limit order via REST with authentication: ``` #!/bin/bash pubkey=\"$YOUR_PUBLIC_API_KEY_HERE\" privkey=\"$YOUR_PRIVATE_API_KEY_HERE\" pass=\"$YOUR_API_KEY_PASSPHRASE_HERE\" timestamp=\"$(($(date +'%s') * 1000))\" body='{ \"symbol\": \"BTCUSDQ\", \"side\": \"BUY\", \"qty\": 100, \"price\": 1000.00, \"type\": \"LIMIT\", \"TimeInForce\": \"UNTIL_CANCEL\", \"PostOnly\": false }' path='/v1/orders' message=$(printf '%s%s%s' \"$body\" \"$timestamp\" \"$path\") sig=$(printf '%s' \"$message\" | openssl dgst -sha256 -hmac \"$privkey\" -binary | od -A n -t x1 | tr -d '\\n ') curl \"https://api.qume.io${path}\" -H \"Content-Type: application/json\" -H \"X-QUME-API-KEY: ${pubkey}\" -H \"X-QUME-SIGNATURE: ${sig}\" -H \"X-QUME-TIMESTAMP: ${timestamp}\" -H \"X-QUME-PASSPHRASE: ${pass}\" -d \"$body\" ``` # WebSockets > Subscribe to real-time data streams (“topics”) ## Subscribe To subscribe to a topic, simply open a websocket connection to ```wss://websocket.qume.io/public``` then send a message specifying the desired topic. - *Example subscription message*: ```{ \"topic\" : \"l2/BTCUSDQ\" }``` To unsubscribe, simply close the websocket connection. ## Topics ### Level-1 (Ticker) Publishes a message every time a new trade occurs. *Topic Name:* ```l1/BTCUSDQ``` Example message: ``` { \"TopicName\": \"l1/BTCUSDQ\", \"Message\": { \"Symbol\": \"BTCUSDQ\", \"Qty\": 4, \"Price\": 25954, \"Ts\": { \"seconds\": 1552098314, \"nanos\": 834534238 } } } ``` ### Level-2 (Orderbook) Publishes a new message when the order book changes. Each message contains the top-50 price levels on each side of the order book. *Topic name*: ```l2/BTCUSDQ``` Example message: ``` { \"TopicName\": \"l2/BTCUSDQ\", \"Message\": { \"MarketId\": \"BTCUSDQ\", \"Buys\": [{\"Price\" : 300, \"Size\" : 1}, ...], \"Sells\": [{\"Price\" : 310, \"Size\" : 4}, ...] } } ``` ### Market Statistics Streams various market statistics. *Topic name*: ```stats/BTCUSDQ``` Example message: ``` { \"TopicName\": \"stats/BTCUSDQ\", \"Message\": { \"Symbol\": \"BTCUSDQ\", \"Price\": 300, \"High\": 350, \"Low\": 250, \"Change\": 25, \"Volume\": 2 } } ```
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.model;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import java.io.IOException;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Gets or Sets orderbookGetOrderResponseErrorCode
*/
@JsonAdapter(OrderbookGetOrderResponseErrorCode.Adapter.class)
public enum OrderbookGetOrderResponseErrorCode {
_UNUSED_("_unused_"),
OK("OK");
private String value;
OrderbookGetOrderResponseErrorCode(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static OrderbookGetOrderResponseErrorCode fromValue(String text) {
for (OrderbookGetOrderResponseErrorCode b : OrderbookGetOrderResponseErrorCode.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter<OrderbookGetOrderResponseErrorCode> {
@Override
public void write(final JsonWriter jsonWriter, final OrderbookGetOrderResponseErrorCode enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public OrderbookGetOrderResponseErrorCode read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return OrderbookGetOrderResponseErrorCode.fromValue(String.valueOf(value));
}
}
}
| [
"[email protected]"
] | |
470fe4c5ddae09876ac6c981d876eb18e111b4a0 | e40ca81f3d1076e8e54e09fcede7c213caf8121d | /IAIC_PRACTICA2/src/Vista/FiltroArchivos.java | f15859d81e550a6b6db70c4db1c908c1957b6ee6 | [] | no_license | BackupTheBerlios/pitusoiaic | 2e5752fbf6650e822fdbf9a6c0ab4897a7542b5f | 6b97a6c79441b93c3f742d3e97a9a9e64e82a8fb | refs/heads/master | 2021-01-19T16:22:00.425450 | 2007-06-16T22:09:01 | 2007-06-16T22:09:01 | 40,072,679 | 0 | 0 | null | null | null | null | ISO-8859-10 | Java | false | false | 1,200 | java | package Vista;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
*
*/
/**
* Clase que crea un fliro de archivos para el tipo txt.
*/
public class FiltroArchivos extends FileFilter{
/**
* Metodo que verifica el tipo de archivo.
* @return booleano que si se acepta un archivo
*/
public boolean accept(File archivo) {
if (archivo!=null) {
if (archivo.isDirectory()) return false;
String extension = devolverExtension(archivo);
if (extension!=null)
if (extension.compareTo("txt")==0)
return true;
}
return false;
}
/**
* Metodo que devuelve una descipcion del tipo de archivo de juego.
*/
public String getDescription() {
return ("Archivos del juego (.txt)");
}
/**
* Metoto que devuelve ņa extension de un archivo.
* @param f es un archivo que se pasa por parametro
* @return un string que es la extension del archivo
*/
public static String devolverExtension(File f) {
if(f != null) {
String nombre = f.getName();
int i = nombre.lastIndexOf('.');
if((i>0) && (i<nombre.length()-1)) {
return nombre.substring(i+1).toLowerCase();
};
}
return null;
}
}
| [
"namaja"
] | namaja |
b9beba5df2f2a566522e5c3e9546419d127e1776 | 289b07dcae8ee4fa203cd33071430940c464ea16 | /Mate20_9_0_0/src/main/java/com/android/server/mtm/iaware/appmng/AwareProcessInfo.java | f6fec8512308cdbc2bbf63da03d94b2836a34120 | [] | no_license | hsymhsym/HwFrameWorkSource | c892bc24392777fa36dc4eacfb92df379c9e9d90 | 001d8c0db514d94724783b97ebba89c9dd44c75e | refs/heads/master | 2021-09-28T07:55:43.589992 | 2018-11-15T15:10:38 | 2018-11-15T15:10:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,813 | java | package com.android.server.mtm.iaware.appmng;
import android.app.mtm.iaware.appmng.AppMngConstant.BroadcastSource;
import android.app.mtm.iaware.appmng.AppMngConstant.CleanReason;
import android.content.Intent;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.android.server.mtm.iaware.appmng.AwareAppMngSort.ClassRate;
import com.android.server.mtm.iaware.appmng.policy.BrFilterPolicy;
import com.android.server.mtm.iaware.appmng.rule.BroadcastMngRule;
import com.android.server.mtm.iaware.appmng.rule.RuleNode;
import com.android.server.mtm.iaware.appmng.rule.RuleParserUtil.AppMngTag;
import com.android.server.mtm.taskstatus.ProcessCleaner.CleanType;
import com.android.server.mtm.taskstatus.ProcessInfo;
import com.android.server.mtm.taskstatus.ProcessInfoCollector;
import com.android.server.mtm.utils.AppStatusUtils.Status;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class AwareProcessInfo {
private boolean isFas = false;
private boolean isFreeze = false;
private boolean isRare = false;
private boolean isStandBy = false;
private ArrayMap<String, BrFilterPolicy> mBrPolicys = new ArrayMap();
public int mClassRate;
public CleanType mCleanType;
public Map<String, Integer> mDetailedReason;
public boolean mHasShownUi;
public int mImportance;
public int mMemGroup;
public int mPid;
public ProcessInfo mProcInfo;
public String mReason;
public boolean mRestartFlag = false;
private int mState = 10;
public int mSubClassRate;
public int mTaskId = -1;
public XmlConfig mXmlConfig;
public static class XmlConfig {
public int mCfgDefaultGroup;
public boolean mFrequentlyUsed;
public boolean mResCleanAllow;
public boolean mRestartFlag;
public XmlConfig(int groupId, boolean frequentUsed, boolean allowCleanRes, boolean restartFlag) {
this.mCfgDefaultGroup = groupId;
this.mFrequentlyUsed = frequentUsed;
this.mResCleanAllow = allowCleanRes;
this.mRestartFlag = restartFlag;
}
}
public boolean getRestartFlag() {
if (this.mRestartFlag) {
return true;
}
if (this.mXmlConfig == null) {
return false;
}
return this.mXmlConfig.mRestartFlag;
}
public AwareProcessInfo(int pid, int memGroup, int importance, int classRate, ProcessInfo procInfo) {
this.mPid = pid;
this.mMemGroup = memGroup;
this.mImportance = importance;
this.mClassRate = classRate;
this.mSubClassRate = 0;
this.mProcInfo = procInfo;
}
public AwareProcessInfo(int pid, ProcessInfo procInfo) {
this.mPid = pid;
this.mProcInfo = procInfo;
}
public String getProcessStatus() {
if (this.mDetailedReason == null) {
return null;
}
Status[] values = Status.values();
Integer statType = (Integer) this.mDetailedReason.get(AppMngTag.STATUS.getDesc());
if (statType == null || values.length <= statType.intValue() || statType.intValue() < 0) {
return null;
}
return values[statType.intValue()].description();
}
public boolean isForegroundApp() {
if (this.mDetailedReason == null) {
return false;
}
Integer statType = (Integer) this.mDetailedReason.get(AppMngTag.STATUS.getDesc());
if (statType == null) {
return false;
}
if (Status.TOP_ACTIVITY.ordinal() == statType.intValue() || Status.FOREGROUND_APP.ordinal() == statType.intValue()) {
return true;
}
return false;
}
public boolean isVisibleApp(int visibleAppAdj) {
if (this.mDetailedReason == null || this.mProcInfo == null || this.mProcInfo.mCurAdj != visibleAppAdj) {
return false;
}
Integer statType = (Integer) this.mDetailedReason.get(AppMngTag.STATUS.getDesc());
if (statType != null && Status.VISIBLE_APP.ordinal() == statType.intValue()) {
return true;
}
return false;
}
public boolean isAwareProtected() {
if (TextUtils.isEmpty(this.mReason)) {
return false;
}
return CleanReason.LIST.getCode().equals(this.mReason);
}
public String getStatisticsInfo() {
StringBuilder build = new StringBuilder();
build.append("proc info pid:");
build.append(this.mPid);
build.append(",classRate:");
build.append(this.mClassRate);
build.append(",");
build.append(getClassRateStr());
build.append(",importance:");
build.append(this.mImportance);
if (this.mProcInfo != null) {
if (this.mProcInfo.mPackageName != null) {
build.append(",packageName:");
int size = this.mProcInfo.mPackageName.size();
for (int i = 0; i < size; i++) {
String pkg = (String) this.mProcInfo.mPackageName.get(i);
build.append(" ");
build.append(pkg);
}
}
build.append(",procName:");
build.append(this.mProcInfo.mProcessName);
build.append(",adj:");
build.append(this.mProcInfo.mCurAdj);
}
return build.toString();
}
public String getClassRateStr() {
return AwareAppMngSort.getClassRateStr(this.mClassRate);
}
public static List<AwareProcessInfo> getAwareProcInfosList() {
List<AwareProcessInfo> awareProcList = new ArrayList();
ProcessInfoCollector processInfoCollector = ProcessInfoCollector.getInstance();
if (processInfoCollector == null) {
return awareProcList;
}
List<ProcessInfo> procList = processInfoCollector.getProcessInfoList();
if (procList.isEmpty()) {
return awareProcList;
}
int size = procList.size();
for (int i = 0; i < size; i++) {
ProcessInfo procInfo = (ProcessInfo) procList.get(i);
awareProcList.add(new AwareProcessInfo(procInfo.mPid, 0, 0, ClassRate.NORMAL.ordinal(), procInfo));
}
return awareProcList;
}
/* JADX WARNING: Missing block: B:16:0x004a, code:
return r0;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
public static ArrayList<AwareProcessInfo> getAwareProcInfosFromPackage(String packageName, int userId) {
ArrayList<AwareProcessInfo> awareProcList = new ArrayList();
if (packageName == null || userId < 0 || packageName.equals("")) {
return awareProcList;
}
ProcessInfoCollector processInfoCollector = ProcessInfoCollector.getInstance();
if (processInfoCollector == null) {
return awareProcList;
}
ArrayList<ProcessInfo> procList = processInfoCollector.getProcessInfosFromPackage(packageName, userId);
if (procList.isEmpty()) {
return awareProcList;
}
int size = procList.size();
for (int i = 0; i < size; i++) {
ProcessInfo procInfo = (ProcessInfo) procList.get(i);
awareProcList.add(new AwareProcessInfo(procInfo.mPid, 0, 0, ClassRate.NORMAL.ordinal(), procInfo));
}
return awareProcList;
}
/* JADX WARNING: Missing block: B:19:0x006f, code:
return r2;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
public static ArrayList<AwareProcessInfo> getAwareProcInfosFromPackageList(List<String> packlist, List<Integer> uidList) {
List<String> list = packlist;
List<Integer> list2 = uidList;
ArrayList<AwareProcessInfo> awareProcList = new ArrayList();
if (list == null || list2 == null || packlist.size() != uidList.size()) {
return awareProcList;
}
ProcessInfoCollector processInfoCollector = ProcessInfoCollector.getInstance();
if (processInfoCollector == null) {
return awareProcList;
}
ArrayMap<String, Integer> packMap = new ArrayMap();
int listSize = packlist.size();
for (int i = 0; i < listSize; i++) {
packMap.put((String) list.get(i), (Integer) list2.get(i));
}
ArrayList<ProcessInfo> procList = processInfoCollector.getProcessInfosFromPackageMap(packMap);
if (procList.isEmpty()) {
return awareProcList;
}
int size = procList.size();
for (int i2 = 0; i2 < size; i2++) {
ProcessInfo procInfo = (ProcessInfo) procList.get(i2);
awareProcList.add(new AwareProcessInfo(procInfo.mPid, 0, 0, ClassRate.NORMAL.ordinal(), procInfo));
}
return awareProcList;
}
public static ArrayList<AwareProcessInfo> getAwareProcInfosFromTask(int taskId, int userId) {
ArrayList<AwareProcessInfo> awareProcList = new ArrayList();
if (taskId < 0 || userId < 0) {
return awareProcList;
}
ProcessInfoCollector processInfoCollector = ProcessInfoCollector.getInstance();
if (processInfoCollector == null) {
return awareProcList;
}
ArrayList<ProcessInfo> procList = processInfoCollector.getProcessInfosFromTask(taskId, userId);
if (procList.isEmpty()) {
return awareProcList;
}
int size = procList.size();
for (int i = 0; i < size; i++) {
ProcessInfo procInfo = (ProcessInfo) procList.get(i);
AwareProcessInfo awareProcInfo = new AwareProcessInfo(procInfo.mPid, 0, 0, ClassRate.NORMAL.ordinal(), procInfo);
awareProcInfo.mTaskId = taskId;
awareProcList.add(awareProcInfo);
}
return awareProcList;
}
public static ArrayList<AwareProcessInfo> getAwareProcInfosFromTaskList(List<Integer> taskIdList, List<Integer> userIdList) {
if (taskIdList == null || userIdList == null || taskIdList.size() != userIdList.size()) {
return null;
}
ArrayList<AwareProcessInfo> awareProcList = new ArrayList();
int listSize = taskIdList.size();
for (int i = 0; i < listSize; i++) {
awareProcList.addAll(getAwareProcInfosFromTask(((Integer) taskIdList.get(i)).intValue(), ((Integer) userIdList.get(i)).intValue()));
}
return awareProcList;
}
public int getState() {
if (this.mState == 1) {
return this.mState;
}
if (this.mProcInfo == null || (!this.mProcInfo.mForegroundActivities && !this.mProcInfo.mForegroundServices && !this.mProcInfo.mForceToForeground)) {
return this.mState;
}
return 9;
}
public void setState(int state) {
switch (state) {
case 1:
this.isFreeze = true;
break;
case 2:
this.isFreeze = false;
break;
case 3:
this.isStandBy = true;
break;
case 4:
this.isStandBy = false;
break;
case 5:
this.isRare = true;
break;
case 6:
this.isRare = false;
break;
case 7:
this.isFas = true;
break;
case 8:
this.isFas = false;
break;
}
resetState();
}
private void resetState() {
if (this.isFreeze) {
this.mState = 1;
} else if (this.isFas) {
this.mState = 7;
} else if (this.isRare) {
this.mState = 5;
} else if (this.isStandBy) {
this.mState = 3;
} else {
this.mState = 10;
}
}
public void updateProcessInfo(ProcessInfo procInfo) {
this.mProcInfo = procInfo;
}
public void updateBrPolicy() {
BroadcastMngRule brRule = DecisionMaker.getInstance().getBroadcastMngRule(BroadcastSource.BROADCAST_FILTER);
if (brRule != null) {
ArrayMap<String, RuleNode> rules = brRule.getBrRules();
synchronized (this.mBrPolicys) {
for (Entry<String, RuleNode> ent : rules.entrySet()) {
String action = (String) ent.getKey();
RuleNode node = (RuleNode) ent.getValue();
BrFilterPolicy brPolicy = (BrFilterPolicy) this.mBrPolicys.get(action);
String id = (String) this.mProcInfo.mPackageName.get(0);
Intent intent = new Intent(action);
if (brPolicy == null) {
brPolicy = new BrFilterPolicy(id, 0, getState());
this.mBrPolicys.put(action, brPolicy);
}
BrFilterPolicy brPolicy2 = brPolicy;
brPolicy2.setPolicy(brRule.updateApply(BroadcastSource.BROADCAST_FILTER, id, intent, this, node));
brPolicy2.setStae(getState());
}
}
}
}
public BrFilterPolicy getBrPolicy(Intent intent) {
synchronized (this.mBrPolicys) {
if (intent == null) {
return null;
}
BrFilterPolicy brFilterPolicy = (BrFilterPolicy) this.mBrPolicys.get(intent.getAction());
return brFilterPolicy;
}
}
public ArrayMap<String, BrFilterPolicy> getBrFilterPolicyMap() {
ArrayMap<String, BrFilterPolicy> arrayMap;
synchronized (this.mBrPolicys) {
arrayMap = new ArrayMap(this.mBrPolicys);
}
return arrayMap;
}
}
| [
"[email protected]"
] | |
6941623a095886260d7eb6e5b4a0bfc7344c5cee | e0712719305368ad6f775bf055f297027ccb3f70 | /com.trusted-bank.www/src/main/java/com/verisign/www/_2006/_08/vipservice/GetTokenInformationResponseType.java | 70aaab43ca9ef8206c81d3756ff6793d57fd4eb4 | [] | no_license | authshark/TrustedBank | d95d034cc67ac98c0435128b12ff7a5024524cad | 2a2e9803cdd561f6ed74b4259ff47dac9b69eb3f | refs/heads/master | 2016-08-12T02:40:58.868803 | 2016-02-09T02:03:26 | 2016-02-09T02:03:26 | 51,340,822 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,414 | java | /**
* GetTokenInformationResponseType.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
*/
package com.verisign.www._2006._08.vipservice;
/**
* Response to a request to get token information
*/
public class GetTokenInformationResponseType extends com.verisign.www._2006._08.vipservice.ResponseWithStatusType implements java.io.Serializable {
private com.verisign.www._2006._08.vipservice.TokenInformationType tokenInformation;
private com.verisign.www._2006._08.vipservice.NetworkIntelligenceType networkIntelligence;
public GetTokenInformationResponseType() {
}
public GetTokenInformationResponseType(
java.lang.String version,
java.lang.String requestId,
com.verisign.www._2006._08.vipservice.StatusType status,
com.verisign.www._2006._08.vipservice.TokenInformationType tokenInformation,
com.verisign.www._2006._08.vipservice.NetworkIntelligenceType networkIntelligence) {
super(
version,
requestId,
status);
this.tokenInformation = tokenInformation;
this.networkIntelligence = networkIntelligence;
}
/**
* Gets the tokenInformation value for this GetTokenInformationResponseType.
*
* @return tokenInformation
*/
public com.verisign.www._2006._08.vipservice.TokenInformationType getTokenInformation() {
return tokenInformation;
}
/**
* Sets the tokenInformation value for this GetTokenInformationResponseType.
*
* @param tokenInformation
*/
public void setTokenInformation(com.verisign.www._2006._08.vipservice.TokenInformationType tokenInformation) {
this.tokenInformation = tokenInformation;
}
/**
* Gets the networkIntelligence value for this GetTokenInformationResponseType.
*
* @return networkIntelligence
*/
public com.verisign.www._2006._08.vipservice.NetworkIntelligenceType getNetworkIntelligence() {
return networkIntelligence;
}
/**
* Sets the networkIntelligence value for this GetTokenInformationResponseType.
*
* @param networkIntelligence
*/
public void setNetworkIntelligence(com.verisign.www._2006._08.vipservice.NetworkIntelligenceType networkIntelligence) {
this.networkIntelligence = networkIntelligence;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof GetTokenInformationResponseType)) return false;
GetTokenInformationResponseType other = (GetTokenInformationResponseType) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = super.equals(obj) &&
((this.tokenInformation==null && other.getTokenInformation()==null) ||
(this.tokenInformation!=null &&
this.tokenInformation.equals(other.getTokenInformation()))) &&
((this.networkIntelligence==null && other.getNetworkIntelligence()==null) ||
(this.networkIntelligence!=null &&
this.networkIntelligence.equals(other.getNetworkIntelligence())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = super.hashCode();
if (getTokenInformation() != null) {
_hashCode += getTokenInformation().hashCode();
}
if (getNetworkIntelligence() != null) {
_hashCode += getNetworkIntelligence().hashCode();
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(GetTokenInformationResponseType.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://www.verisign.com/2006/08/vipservice", "GetTokenInformationResponseType"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("tokenInformation");
elemField.setXmlName(new javax.xml.namespace.QName("http://www.verisign.com/2006/08/vipservice", "TokenInformation"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.verisign.com/2006/08/vipservice", "TokenInformationType"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("networkIntelligence");
elemField.setXmlName(new javax.xml.namespace.QName("http://www.verisign.com/2006/08/vipservice", "NetworkIntelligence"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.verisign.com/2006/08/vipservice", "NetworkIntelligenceType"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
| [
"[email protected]"
] | |
913e04cdcc9d9bd35a9698d9918106b60b406fb3 | 72ccad0f396356a15961a7c57a1af28678e8bba5 | /service-circuitbreaker-reactive-r4j/src/main/java/xw/cloud/sample/web/SlowRestController.java | 61d7bf328079d71cf534022cee02cc94266b5f1c | [] | no_license | shrimp32/springcloud-demo | 7366c7339a54855c19bf9adecf7ed8f2e9e3dcd6 | d08bd60530c7a9a2279113dba5d65926d76a7aba | refs/heads/master | 2021-06-13T15:48:38.353117 | 2020-06-02T04:38:07 | 2020-06-02T04:38:07 | 123,388,910 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 697 | java | package xw.cloud.sample.web;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import xw.cloud.sample.model.Tweet;
import java.util.Arrays;
import java.util.List;
/**
* @author : 夏玮
* Created on 2019-07-24 15:57
*/
@RestController
public class SlowRestController {
@GetMapping("/slow")
private List<Tweet> getAllTweets() throws InterruptedException {
Thread.sleep(2000); // delay
return Arrays.asList(
new Tweet("RestTemplate rules", "@user1"),
new Tweet("WebClient is better", "@user2"),
new Tweet("OK, both are useful", "@user1"));
}
}
| [
"[email protected]"
] | |
a68cb5f097393757715d4918338c9c7ffabfdbae | 4ac57945469ef0f889dc1665effbe465f572d1f3 | /src/main/java/net/liuxuan/db/repository/UsergroupRoleinfoRepository.java | 6eeb6cc0c03b0fa34244cbd95c0d3b8071784bfd | [] | no_license | mosliu/workflow | 5235cc7aca2aebfff9c6313529b537114c075ff7 | 1d96c48db61e90267523a736e3a8df2ba54e5823 | refs/heads/master | 2023-06-27T12:15:15.446418 | 2021-07-22T07:21:18 | 2021-07-22T07:21:18 | 381,945,585 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 364 | java | package net.liuxuan.db.repository;
import net.liuxuan.db.entity.UsergroupRoleinfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface UsergroupRoleinfoRepository extends JpaRepository<UsergroupRoleinfo, Integer>, JpaSpecificationExecutor<UsergroupRoleinfo> {
} | [
"[email protected]"
] | |
9179992e3c31adf43c9517eb73404657de7414bf | e46b3653799b0ee8df9525e8a2a5039bdb7d0915 | /Workshop/codes/ScrollDelete.java | 57465921e2079e0fcbc1cf2db43a70817907173a | [] | no_license | hkhur/IITDHN_JEE | be5ac8480ecc19b9f046e798e2c5a436c690e38e | 00e4e9fa6271cd8b5628cc02c32ee909d6ff0358 | refs/heads/master | 2020-04-19T22:18:29.449542 | 2019-02-25T07:01:56 | 2019-02-25T07:01:56 | 168,465,574 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 943 | java | package com.srpec.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ScrollDelete {
public static void main(String[] args) throws Exception {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/srpecdb","root","19991");
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ResultSet rs=st.executeQuery("Select * from student");
rs.beforeFirst();
while(rs.next()) {
System.out.println();
float marks = rs.getFloat(3);
if(marks>=100){
String name = rs.getString("Sname");
rs.deleteRow();
System.out.println(" the student deleted is "+name);
}
}
}
catch(Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
88469bc68b005136dfadb8476e1000b31d4dd690 | 98bcb36b307ce97f2e3a61c720bd0898c00d71f8 | /modules/dfp_axis/src/main/java/com/google/api/ads/dfp/axis/v201505/CustomTargetingValueStatus.java | 5efe984629733893b4e00ce36d46cc5b1a3f31af | [
"Apache-2.0"
] | permissive | goliva/googleads-java-lib | 7050c16adbdfe1bf966414c1c412124b4f1352cc | ed88ac7508c382453682d18f46e53e9673286039 | refs/heads/master | 2021-01-22T00:52:23.999379 | 2015-07-17T22:20:42 | 2015-07-17T22:20:42 | 36,671,823 | 0 | 1 | null | 2015-07-17T22:20:42 | 2015-06-01T15:58:41 | Java | UTF-8 | Java | false | false | 3,051 | java | /**
* CustomTargetingValueStatus.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Mar 02, 2009 (07:08:06 PST) WSDL2Java emitter.
*/
package com.google.api.ads.dfp.axis.v201505;
public class CustomTargetingValueStatus implements java.io.Serializable {
private java.lang.String _value_;
private static java.util.HashMap _table_ = new java.util.HashMap();
// Constructor
protected CustomTargetingValueStatus(java.lang.String value) {
_value_ = value;
_table_.put(_value_,this);
}
public static final java.lang.String _ACTIVE = "ACTIVE";
public static final java.lang.String _INACTIVE = "INACTIVE";
public static final java.lang.String _UNKNOWN = "UNKNOWN";
public static final CustomTargetingValueStatus ACTIVE = new CustomTargetingValueStatus(_ACTIVE);
public static final CustomTargetingValueStatus INACTIVE = new CustomTargetingValueStatus(_INACTIVE);
public static final CustomTargetingValueStatus UNKNOWN = new CustomTargetingValueStatus(_UNKNOWN);
public java.lang.String getValue() { return _value_;}
public static CustomTargetingValueStatus fromValue(java.lang.String value)
throws java.lang.IllegalArgumentException {
CustomTargetingValueStatus enumeration = (CustomTargetingValueStatus)
_table_.get(value);
if (enumeration==null) throw new java.lang.IllegalArgumentException();
return enumeration;
}
public static CustomTargetingValueStatus fromString(java.lang.String value)
throws java.lang.IllegalArgumentException {
return fromValue(value);
}
public boolean equals(java.lang.Object obj) {return (obj == this);}
public int hashCode() { return toString().hashCode();}
public java.lang.String toString() { return _value_;}
public java.lang.Object readResolve() throws java.io.ObjectStreamException { return fromValue(_value_);}
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.EnumSerializer(
_javaType, _xmlType);
}
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.EnumDeserializer(
_javaType, _xmlType);
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(CustomTargetingValueStatus.class);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("https://www.google.com/apis/ads/publisher/v201505", "CustomTargetingValue.Status"));
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
}
| [
"[email protected]"
] | |
ddd86c4b206967cd40654a4deaff5c1c67dd15c4 | 10c55847c69575b792b05da31c1aded37e2a0733 | /src/main/java/com/exam/io/FileParser.java | 5243e4e02e9af6a91c201676f50e99e3432254dd | [] | no_license | valiobar/hibernate-exam | 24acb81298aa8ac501672e50143824025c5ad74d | 2923b595e60fc78a88ccd517d3c16f9714493c98 | refs/heads/master | 2021-05-01T23:35:14.013919 | 2016-12-30T19:08:36 | 2016-12-30T19:08:36 | 77,694,519 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 968 | java | package com.exam.io;
import org.springframework.stereotype.Component;
import java.io.*;
@Component
public class FileParser {
public String readFile(String fileName) throws IOException {
StringBuilder fileContent = new StringBuilder();
try (
InputStream is = getClass().getResourceAsStream(fileName);
BufferedReader bfr = new BufferedReader(new InputStreamReader(is))
) {
String line = null;
while ((line = bfr.readLine()) != null) {
fileContent.append(line);
}
}
return fileContent.toString();
}
public void writeFile(String fileName, String content) throws IOException {
try (OutputStream os = new FileOutputStream(fileName);
BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(os))
) {
bfw.write(String.valueOf(content));
}
}
}
| [
"[email protected]"
] | |
3b291a5bbb0b4317782ccad1b018d2f7fcecfe03 | 13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3 | /crash-reproduction-new-fitness/results/MATH-38b-2-3-Single_Objective_GGA-IntegrationSingleObjective-BasicBlockCoverage-opt/org/apache/commons/math/optimization/direct/BOBYQAOptimizer_ESTest.java | 441d5dcb582758559685aeaab73a743d58946ab4 | [
"MIT",
"CC-BY-4.0"
] | permissive | STAMP-project/Botsing-basic-block-coverage-application | 6c1095c6be945adc0be2b63bbec44f0014972793 | 80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da | refs/heads/master | 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,681 | java | /*
* This file was automatically generated by EvoSuite
* Fri Oct 29 05:25:28 UTC 2021
*/
package org.apache.commons.math.optimization.direct;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import org.apache.commons.math.analysis.SumSincFunction;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.direct.BOBYQAOptimizer;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class BOBYQAOptimizer_ESTest extends BOBYQAOptimizer_ESTest_scaffolding {
@Test(timeout = 4000)
public void test0() throws Throwable {
int int0 = 6;
SumSincFunction sumSincFunction0 = new SumSincFunction(6);
SumSincFunction sumSincFunction1 = new SumSincFunction(0.27009703383667416);
double[] doubleArray0 = new double[9];
doubleArray0[0] = (double) 6;
doubleArray0[1] = 0.27009703383667416;
doubleArray0[2] = 0.27009703383667416;
doubleArray0[3] = (double) 6;
doubleArray0[4] = 0.27009703383667416;
doubleArray0[5] = 0.27009703383667416;
doubleArray0[6] = (double) 6;
doubleArray0[7] = 0.27009703383667416;
doubleArray0[8] = 0.27009703383667416;
sumSincFunction1.value(doubleArray0);
BOBYQAOptimizer bOBYQAOptimizer0 = new BOBYQAOptimizer(20, 0.27009703383667416, 2349.036);
GoalType goalType0 = GoalType.MINIMIZE;
// Undeclared exception!
bOBYQAOptimizer0.optimize(1243, sumSincFunction1, goalType0, doubleArray0);
}
}
| [
"[email protected]"
] | |
150a90cefe9260841e6a7fb183d66e32a625de1f | f0a50969e0a956395de6fd686295a523b2b9d04f | /src/com/goblin/factorymethod/product/JavaVideo.java | 7b3548937350946816430e97f30ec931ecd81135 | [] | no_license | slpgoblin/design-pattern | 0706dd7268649d40575702941032430a24a7ac48 | 6c6e7c1693efe6b7fb9025d8d5872da8c50acbce | refs/heads/master | 2022-11-07T20:37:42.202272 | 2020-06-23T14:44:58 | 2020-06-23T14:44:58 | 274,266,931 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 318 | java | package com.goblin.factorymethod.product;
/**
* @program: design-pattern
* @description:
* @author: Guojs
* @create: 2020-06-23 11:37
**/
public class JavaVideo extends Video{
/**
* 生产视频课
*/
@Override
public void prodVideo() {
System.out.println("java视频课");
}
}
| [
"[email protected]"
] | |
68d735bf90bbfc68b2717fddf603e0911b313ea5 | 468d5e268e3bc593dceb3fd5210d1d578f1c35a0 | /src/POO/Guanabara/Aula07/Lutadora.java | 443f2e2b04684c9936e9374f06a5250b597664e5 | [
"MIT"
] | permissive | larissamartinsss/CursoJavaCompleto | 60eedba81d6757b4c4a92b30d53c5218ea5ad8f4 | 3a54684506915fedd9c9286261a5a6bc9cec3347 | refs/heads/main | 2023-08-31T15:47:19.708309 | 2021-10-20T00:43:25 | 2021-10-20T00:43:25 | 381,136,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,432 | java | package POO.Guanabara.Aula07;
public class Lutadora {
private String nome;
private String nacionalidade;
private int idade;
private double altura;
private double peso;
private String categoria;
private int vitorias, derrotas, empates;
// Construtor
public Lutadora(String nome, String nacionalidade, int idade, double altura,
double peso, int vitorias, int derrotas, int empates)
{
this.nome = nome;
this.nacionalidade = nacionalidade;
this.idade = idade;
this.altura = altura;
this.setPeso(peso);
this.vitorias = vitorias;
this.derrotas = derrotas;
this.empates = empates;
}
public void apresentar(){
System.out.println("CHEGOU A HORA! Apresentamos: ");
System.out.println("Lutadora: "+getNome());
System.out.println("Origem: "+getNacionalidade());
System.out.println(+getIdade()+" anos");
System.out.println(getAltura()+ "m de altura");
System.out.println("Pesando: "+getPeso()+"Kg");
System.out.println("Ganhou: "+getVitorias());
System.out.println("Perdeu: "+getDerrotas());
System.out.println("Empatou: "+getEmpates());
}
public void status(){
System.out.println(getNome());
System.out.println("É um peso "+getCategoria());
System.out.println(getVitorias() + "vitórias");
System.out.println(getDerrotas() + "derrotas");
}
public void ganharLuta(){
this.setVitorias(this.getVitorias()+1);
}
public void perderLuta(){
this.setVitorias(this.getVitorias()+1);
}
public void empatarLuta(){
this.setVitorias(this.getVitorias()+1);
}
// Metodos especiais:
public String getNome() {
return this.nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getNacionalidade() {
return this.nacionalidade;
}
public void setNacionalidade(String nacionalidade) {
this.nacionalidade = nacionalidade;
}
public int getIdade() {
return this.idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public double getAltura() {
return altura;
}
public void setAltura(double altura) {
this.altura = altura;
}
public double getPeso() {
return peso;
}
public void setPeso(double peso) {
this.peso = peso;
this.setCategoria();
}
public String getCategoria() {
return categoria;
}
private void setCategoria() {
if(getPeso() < 52.2){
this.categoria = "Inválido";
}else if(getPeso() <=70.3){
this.categoria = "Leve";
}else if(getPeso() <=83.9){
this.categoria = "Médio";
}else if(getPeso() <=120.2){
this.categoria = "Pesado";
}else{
System.out.println("Inválido");
}
}
public int getVitorias() {
return vitorias;
}
public void setVitorias(int vitorias) {
this.vitorias = vitorias;
}
public int getDerrotas() {
return derrotas;
}
public void setDerrotas(int derrotas) {
this.derrotas = derrotas;
}
public int getEmpates() {
return empates;
}
public void setEmpates(int empates) {
this.empates = empates;
}
}
| [
"[email protected]"
] | |
f87877b29a6d07b3a2a0715759b150cf05fedff9 | 17d96a9c35944161f0d230bae87320104afe8e64 | /AliLiveSDK4.0.2_Demo_Android/app/src/main/java/com/alilive/alilivesdk_demo/wheel/base/WheelItemView.java | b98e4b1fadefa13ad7b1543c841382f831448078 | [
"Apache-2.0"
] | permissive | lichtz/Queen_SDK_Android | 04700a9a03db14dc54172f29065e05eee8f37a21 | 2164958a19c9f60ef9d35a0c968f6c6e1b1563b2 | refs/heads/main | 2023-08-14T21:53:16.875074 | 2021-09-06T09:30:31 | 2021-09-06T09:30:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,819 | java | package com.alilive.alilivesdk_demo.wheel.base;
import android.content.Context;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.FrameLayout;
/**
* Wheel view with selected mask.
*
* <br>Email:[email protected]
* <br>QQ:1006368252
* <br><a href="https://github.com/JustinRoom/WheelViewDemo" target="_blank">https://github.com/JustinRoom/WheelViewDemo</a>
*
* @author jiangshicheng
*/
public class WheelItemView extends FrameLayout implements IWheelViewSetting {
private WheelView wheelView;
private WheelMaskView wheelMaskView;
public WheelItemView(@NonNull Context context) {
super(context);
initAttr(context, null, 0);
}
public WheelItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initAttr(context, attrs, 0);
}
public WheelItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initAttr(context, attrs, defStyleAttr);
}
private void initAttr(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
wheelView = new WheelView(context);
wheelView.initAttr(context, attrs, defStyleAttr);
wheelMaskView = new WheelMaskView(context);
wheelMaskView.initAttr(context, attrs, defStyleAttr);
addView(wheelView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
addView(wheelMaskView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
ViewGroup.LayoutParams params = wheelMaskView.getLayoutParams();
params.height = wheelView.getMeasuredHeight();
wheelMaskView.setLayoutParams(params);
wheelMaskView.updateMask(wheelView.getShowCount(), wheelView.getItemHeight());
}
@Override
public void setTextSize(float textSize) {
wheelView.setTextSize(textSize);
}
@Override
public void setTextColor(@ColorInt int textColor) {
wheelView.setTextColor(textColor);
}
@Override
public void setShowCount(int showCount) {
wheelView.setShowCount(showCount);
}
@Override
public void setTotalOffsetX(int totalOffsetX) {
wheelView.setTotalOffsetX(totalOffsetX);
}
@Override
public void setItemVerticalSpace(int itemVerticalSpace) {
wheelView.setItemVerticalSpace(itemVerticalSpace);
}
@Override
public void setItems(IWheel[] items) {
wheelView.setItems(items);
}
@Override
public int getSelectedIndex() {
return wheelView.getSelectedIndex();
}
@Override
public void setSelectedIndex(int targetIndexPosition) {
setSelectedIndex(targetIndexPosition, true);
}
@Override
public void setSelectedIndex(int targetIndexPosition, boolean withAnimation) {
wheelView.setSelectedIndex(targetIndexPosition, withAnimation);
}
@Override
public void setOnSelectedListener(WheelView.OnSelectedListener onSelectedListener) {
wheelView.setOnSelectedListener(onSelectedListener);
}
public void setMaskLineColor(@ColorInt int color) {
wheelMaskView.setLineColor(color);
}
@Override
public boolean isScrolling() {
return wheelView.isScrolling();
}
public WheelView getWheelView() {
return wheelView;
}
public WheelMaskView getWheelMaskView() {
return wheelMaskView;
}
}
| [
"[email protected]"
] | |
a26e048ed02806af5ddbbe847f5568bb056ea5a9 | ac6831483d6c457b34b2885fd7f6aca20e80101c | /src/selenium/FacebookLoginTest.java | 53798938e1082628632e9d9b110d0ca7840640d0 | [] | no_license | 19preet96/FirstRepo | ecdde2ff20b4effcb3b092d5bdbfbfdc81340cfc | 64fa0c8842909bf2b69c524686a42515e88bcf8b | refs/heads/master | 2023-03-01T01:34:08.997653 | 2021-02-10T21:26:04 | 2021-02-10T21:26:04 | 337,851,885 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,248 | java | package selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FacebookLoginTest {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "C:/Learning/Program/SeleniumJars/geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com");
//driver.findElement(By.className("inputtext _55r1 _6luy")).sendKeys("[email protected]"); failed because attr contains spaces
//driver.findElement(By.id("email")).sendKeys("[email protected]"); working
//driver.findElement(By.name("email")).sendKeys("[email protected]"); // working
//driver.findElement(By.tagName("input")).sendKeys("[email protected]"); fails not unique and not first
//driver.findElement(By.xpath(null))
//driver.findElement(By.name("pass")).sendKeys("asda");
//driver.findElement(By.name("login")).click();
//works with xpath too
driver.findElement(By.xpath("//input[@class='inputtext _55r1 _6luy']")).sendKeys("jxh");
driver.findElement(By.xpath("//div/input[@class='inputtext _55r1 _6luy' and @name='pass']")).sendKeys("pass");
driver.findElement(By.xpath("//div/button[starts-with(@id,'u_0')]")).click();
}
}
| [
"[email protected]"
] | |
82b04e772b057bf714dbb4ab699fa1e9beea9be5 | 883b7801d828a0994cae7367a7097000f2d2e06a | /python/experiments/projects/atlanmod-NeoEMF/real_error_dataset/1/13/AbstractBlueprintsBackend.java | 7fc1593055407164ba8773a260090bb0f75bad5d | [] | no_license | pombredanne/styler | 9c423917619912789289fe2f8982d9c0b331654b | f3d752d2785c2ab76bacbe5793bd8306ac7961a1 | refs/heads/master | 2023-07-08T05:55:18.284539 | 2020-11-06T05:09:47 | 2020-11-06T05:09:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,888 | java | /*
* Copyright (c) 2013-2017 Atlanmod, Inria, LS2N, and IMT Nantes.
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v2.0 which accompanies
* this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/
*/
package fr.inria.atlanmod.neoemf.data.blueprints;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Index;
import com.tinkerpop.blueprints.KeyIndexableGraph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import com.tinkerpop.blueprints.util.GraphHelper;
import com.tinkerpop.blueprints.util.wrappers.WrapperGraph;
import com.tinkerpop.blueprints.util.wrappers.id.IdEdge;
import com.tinkerpop.blueprints.util.wrappers.id.IdGraph;
import fr.inria.atlanmod.commons.cache.Cache;
import fr.inria.atlanmod.commons.cache.CacheBuilder;
import fr.inria.atlanmod.commons.collect.MoreIterables;
import fr.inria.atlanmod.commons.function.Converter;
import fr.inria.atlanmod.neoemf.core.Id;
import fr.inria.atlanmod.neoemf.core.IdConverters;
import fr.inria.atlanmod.neoemf.data.AbstractBackend;
import fr.inria.atlanmod.neoemf.data.bean.ClassBean;
import fr.inria.atlanmod.neoemf.data.bean.FeatureBean;
import fr.inria.atlanmod.neoemf.data.bean.SingleFeatureBean;
import fr.inria.atlanmod.neoemf.data.mapping.DataMapper;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import static fr.inria.atlanmod.commons.Preconditions.checkNotNull;
/**
* An abstract {@link BlueprintsBackend} that provides overall behavior for the management of a Blueprints database.
*/
@ParametersAreNonnullByDefault
abstract class AbstractBlueprintsBackend extends AbstractBackend implements BlueprintsBackend {
/**
* The {@link Converter} to use a long representation instead of {@link Id}.
* <p>
* This converter is specific to Blueprints which returns each identifier as an {@link Object}.
*/
@Nonnull
protected static final Converter<Id, Object> AS_LONG_OBJECT = Converter.from(
IdConverters.withLong()::convert,
o -> IdConverters.withLong().revert(Long.class.cast(o)));
/**
* The property key used to define the index of an edge.
*/
protected static final String PROPERTY_INDEX = "_p";
/**
* The property key used to define the number of edges with a specific label.
*/
protected static final String PROPERTY_SIZE = "_s";
/**
* The label used to define container {@link Edge}s.
*/
private static final String EDGE_CONTAINER = "_c";
/**
* The label of type conformance {@link Edge}s.
*/
private static final String EDGE_INSTANCE_OF = "_i";
/**
* The property key used to define the name of the the opposite containing feature in container {@link Edge}s.
*/
private static final String PROPERTY_FEATURE_NAME = "_cn";
/**
* The property key used to define the name of meta-class {@link Vertex}s.
*/
private static final String PROPERTY_CLASS_NAME = "_in";
/**
* The property key used to define the URI of meta-class {@link Vertex}s.
*/
private static final String PROPERTY_CLASS_URI = "_iu";
/**
* In-memory cache that holds recently loaded {@link Vertex}s, identified by the associated object {@link Id}.
*/
@Nonnull
private final Cache<Id, Vertex> verticesCache = CacheBuilder.builder()
.softValues()
.build();
/**
* A set that holds indexed {@link ClassBean}.
*
* @see #metaClassIndex
* @see #innerCopyTo(DataMapper)
*/
@Nonnull
private final Set<ClassBean> metaClassSet;
/**
* Index containing meta-classes.
*/
@Nonnull
private final Index<Vertex> metaClassIndex;
/**
* The Blueprints graph.
*/
@Nonnull
private final IdGraph<KeyIndexableGraph> graph;
/**
* {@code true} if the base {@link Graph} requires unique labels and properties.
* <p>
* Some {@link Graph} implementations, as {@link TinkerGraph}, associates each label and property with a type, even
* if it appears in a different Vertex/Edge. A simple {@link Integer} cause some troubles because they appear in
* different {@link com.tinkerpop.blueprints.Element} but don't represent the same thing.
*/
private final boolean requireUniqueLabels;
/**
* Constructs a new {@code AbstractBlueprintsBackend} wrapping the provided {@code baseGraph}.
*
* @param baseGraph the base {@link KeyIndexableGraph} used to access the database
*
* @see BlueprintsBackendFactory
*/
protected AbstractBlueprintsBackend(KeyIndexableGraph baseGraph) {
checkNotNull(baseGraph);
graph = new SmartIdGraph(baseGraph);
requireUniqueLabels = TinkerGraph.class.isInstance(getOrigin(baseGraph));
metaClassSet = new HashSet<>();
metaClassIndex = getOrCreateIndex("instances");
}
/**
* Builds the {@link Id} used to identify a {@link ClassBean} {@link Vertex}.
*
* @param metaClass the {@link ClassBean} to build an {@link Id} from
*
* @return the create {@link Id}
*/
@Nonnull
private static Id generateClassId(ClassBean metaClass) {
return Id.getProvider().generate(metaClass.name() + metaClass.uri());
}
/**
* Retrieves the base graph of the {@code graph}.
*
* @param graph the graph from which to retrieve the base graph
*
* @return the base graph of the {@code graph}, or {@code graph} is it is not a wrapper.
*
* @see com.tinkerpop.blueprints.Features#isWrapper
* @see WrapperGraph
*/
@Nonnull
private Graph getOrigin(Graph graph) {
return graph.getFeatures().isWrapper
? getOrigin(WrapperGraph.class.cast(graph).getBaseGraph())
: graph;
}
/**
* Formats a property as {@code label:suffix}.
*
* @param feature the feature associated with the property
* @param suffix the suffix of the property
*
* @return the formatted property
*/
@Nonnull
protected String formatProperty(FeatureBean feature, Object suffix) {
return formatLabel(feature) + ':' + String.valueOf(suffix);
}
/**
* Formats a label.
*
* @param feature the feature associated with the label
*
* @return the formatted label
*/
@Nonnull
protected String formatLabel(FeatureBean feature) {
return requireUniqueLabels
// TODO Can cause a massive overhead (metaClassNameOf)
? metaClassNameOf(feature.owner()) + ':' + Integer.toString(feature.id())
: Integer.toString(feature.id());
}
/**
* Retrieves or create an index for the given {@code name}.
*
* @param name the name of the index
*
* @return the index
*/
@Nonnull
private Index<Vertex> getOrCreateIndex(String name) {
return Optional.ofNullable(graph.getIndex(name, Vertex.class))
.orElseGet(() -> graph.createIndex(name, Vertex.class));
}
@Override
public void save() {
if (graph.getFeatures().supportsTransactions) {
graph.commit();
}
else {
graph.shutdown();
}
}
@Override
protected void innerClose() {
graph.shutdown();
}
@Override
protected void innerCopyTo(DataMapper target) {
AbstractBlueprintsBackend to = AbstractBlueprintsBackend.class.cast(target);
GraphHelper.copyGraph(graph, to.graph);
metaClassSet.forEach(m -> {
Id id = generateClassId(m);
Vertex vertex = get(id).<IllegalStateException>orElseThrow(IllegalStateException::new);
to.metaClassIndex.put(PROPERTY_CLASS_NAME, m.name(), vertex);
});
}
@Nonnull
@Override
public Optional<SingleFeatureBean> containerOf(Id id) {
checkNotNull(id);
Optional<Vertex> containmentVertex = get(id);
if (!containmentVertex.isPresent()) {
return Optional.empty();
}
Iterable<Edge> edges = containmentVertex.get().query()
.labels(EDGE_CONTAINER)
.direction(Direction.OUT)
.limit(1)
.edges();
return MoreIterables.onlyElement(edges)
.map(e -> SingleFeatureBean.of(
AS_LONG_OBJECT.revert(e.getVertex(Direction.IN).getId()),
e.getProperty(PROPERTY_FEATURE_NAME)));
}
@Override
public void containerFor(Id id, SingleFeatureBean container) {
checkNotNull(id);
checkNotNull(container);
Vertex containmentVertex = getOrCreate(id);
Vertex containerVertex = getOrCreate(container.owner());
Iterable<Edge> containmentEdges = containmentVertex.query()
.labels(EDGE_CONTAINER)
.direction(Direction.OUT)
.limit(1)
.edges();
containmentEdges.forEach(Edge::remove);
Edge edge = containmentVertex.addEdge(EDGE_CONTAINER, containerVertex);
edge.setProperty(PROPERTY_FEATURE_NAME, container.id());
}
@Override
public void removeContainer(Id id) {
checkNotNull(id);
Optional<Vertex> containmentVertex = get(id);
if (!containmentVertex.isPresent()) {
return;
}
Iterable<Edge> containmentEdges = containmentVertex.get().query()
.labels(EDGE_CONTAINER)
.direction(Direction.OUT)
.limit(1)
.edges();
containmentEdges.forEach(Edge::remove);
}
@Nonnull
@Override
public Optional<ClassBean> metaClassOf(Id id) {
checkNotNull(id);
Optional<Vertex> vertex = get(id);
if (!vertex.isPresent()) {
return Optional.empty();
}
Iterable<Vertex> metaClassVertices = vertex.get().query()
.labels(EDGE_INSTANCE_OF)
.direction(Direction.OUT)
.limit(1)
.vertices();
return MoreIterables.onlyElement(metaClassVertices)
.map(v -> ClassBean.of(
v.getProperty(PROPERTY_CLASS_NAME),
v.getProperty(PROPERTY_CLASS_URI)));
}
@Override
public boolean metaClassFor(Id id, ClassBean metaClass) {
checkNotNull(id);
checkNotNull(metaClass);
Vertex vertex = getOrCreate(id);
// Check the presence of a meta-class
Iterable<Edge> instanceEdges = vertex.query()
.labels(EDGE_INSTANCE_OF)
.direction(Direction.OUT)
.limit(1)
.edges();
if (MoreIterables.onlyElement(instanceEdges).isPresent()) {
return false;
}
// Retrieve or create the meta-class and store it in the index
Iterable<Vertex> instanceVertices = metaClassIndex.get(PROPERTY_CLASS_NAME, metaClass.name());
Vertex metaClassVertex = MoreIterables.onlyElement(instanceVertices).orElseGet(() -> {
Vertex mcv = graph.addVertex(AS_LONG_OBJECT.convert(generateClassId(metaClass)));
mcv.setProperty(PROPERTY_CLASS_NAME, metaClass.name());
mcv.setProperty(PROPERTY_CLASS_URI, metaClass.uri());
metaClassIndex.put(PROPERTY_CLASS_NAME, metaClass.name(), mcv);
metaClassSet.add(metaClass);
return mcv;
});
// Defines the meta-class
vertex.addEdge(EDGE_INSTANCE_OF, metaClassVertex);
return true;
}
@Nonnull
@Override
public Iterable<Id> allInstancesOf(Set<ClassBean> metaClasses) {
return metaClasses.stream()
.map(mc -> metaClassIndex.get(PROPERTY_CLASS_NAME, mc.name()))
.flatMap(MoreIterables::stream)
.map(mcv -> mcv.getVertices(Direction.IN, EDGE_INSTANCE_OF))
.flatMap(MoreIterables::stream)
.map(v -> AS_LONG_OBJECT.revert(v.getId()))
.collect(Collectors.toSet());
}
/**
* Returns the name of the meta-class of the specified {@code id}.
*
* @param id the identifier
*
* @return the name of the meta-class
*/
@Nonnull
private String metaClassNameOf(Id id) {
// If the meta-class is not defined, the identifier represents the 'ROOT' element
return metaClassOf(id).map(ClassBean::name).orElse(":");
}
/**
* Retrieves the {@link Vertex} corresponding to the provided {@code id}.
*
* @param id the {@link Id} of the element to find
*
* @return an {@link Optional} containing the {@link Vertex}, or {@link Optional#empty()} if it doesn't exist
*/
@Nonnull
protected Optional<Vertex> get(Id id) {
return Optional.ofNullable(verticesCache.get(id, i -> graph.getVertex(AS_LONG_OBJECT.convert(i))));
}
/**
* Retrieves the {@link Vertex} corresponding to the provided {@code id}. If it doesn't already exist, it will be
* created.
*
* @param id the {@link Id} of the element to find, or create
*
* @return the {@link Vertex}
*/
@Nonnull
protected Vertex getOrCreate(Id id) {
return verticesCache.get(id, i ->
Optional.ofNullable(graph.getVertex(AS_LONG_OBJECT.convert(i)))
.orElseGet(() -> graph.addVertex(AS_LONG_OBJECT.convert(i))));
}
/**
* Provides a direct access to the underlying graph.
* <p>
* This method is public for tool compatibility (see the <a href="https://github.com/atlanmod/Mogwai">Mogwaï</a>)
* framework, NeoEMF consistency is not guaranteed if the graph is modified manually.
*
* @return the underlying Blueprints {@link IdGraph}
*/
@Nonnull
@SuppressWarnings("unchecked")
public <T> T getGraph() {
return (T) graph;
}
/**
* An {@link IdGraph} that automatically removes unused {@link Vertex}.
*/
@ParametersAreNonnullByDefault
private static class SmartIdGraph extends IdGraph<KeyIndexableGraph> {
/**
* Constructs a new {@code SmartIdGraph} on the specified {@code baseGraph}.
*
* @param baseGraph the base graph
*/
public SmartIdGraph(KeyIndexableGraph baseGraph) {
super(baseGraph, true, false);
enforceUniqueIds(false);
}
@Override
public Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label) {
return createFrom(super.addEdge(id, outVertex, inVertex, label));
}
@Override
public Edge getEdge(Object id) {
return createFrom(super.getEdge(id));
}
/**
* Creates a new {@link SmartIdEdge} from another {@link Edge}.
*
* @param edge the base edge
*
* @return an {@link SmartIdEdge}
*/
private Edge createFrom(@Nullable Edge edge) {
return Optional.ofNullable(edge)
.map(SmartIdEdge::new)
.orElse(null);
}
/**
* An {@link IdEdge} that automatically removes {@link Vertex} that are no longer referenced.
*/
@ParametersAreNonnullByDefault
private class SmartIdEdge extends IdEdge {
/**
* Constructs a new {@code SmartIdEdge} on the specified {@code edge}.
*
* @param edge the base edge
*/
public SmartIdEdge(Edge edge) {
super(edge, SmartIdGraph.this);
}
/**
* {@inheritDoc}
* <p>
* If the {@link Edge} references a {@link Vertex} with no more incoming {@link Edge}, the referenced {@link
* Vertex} is removed as well.
*/
@Override
public void remove() {
Vertex referencedVertex = getVertex(Direction.IN);
super.remove();
Iterable<Edge> edges = referencedVertex.query()
.direction(Direction.IN)
.limit(1)
.edges();
if (MoreIterables.isEmpty(edges)) {
// If the Vertex has no more incoming edges remove it from the DB
referencedVertex.remove();
}
}
}
}
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.